From b5d16518eaccf9ce7061bacef6937e05dcd333a4 Mon Sep 17 00:00:00 2001 From: Justin Shih Date: Thu, 12 Oct 2023 16:55:09 -0700 Subject: [PATCH] feat: refactor override and utils to strings --- ...udio-template-renderer-helper.test.ts.snap | 99 +- ...studio-ui-codegen-react-forms.test.ts.snap | 956 +++++++++++-- ...studio-ui-codegen-react-views.test.ts.snap | 36 +- .../studio-ui-codegen-react.test.ts.snap | 1177 ++++++++++++++--- .../overrides/getOverrideProps.test.ts | 59 + .../getOverridesFromVariants.test.ts | 133 ++ .../mergeVariantsAndOverrides.test.ts | 124 ++ .../render-util-functions.test.ts.snap | 10 +- .../lib/forms/react-form-renderer.ts | 5 +- .../lib/imports/import-mapping.ts | 2 - .../lib/overrides/findChildOverrides.ts | 242 ---- .../lib/overrides/getOverrideProps.ts | 248 ---- .../lib/overrides/getOverridesFromVariants.ts | 496 ------- .../overrides/mergeVariantsAndOverrides.ts | 286 ---- .../codegen-ui-react/lib/overrides/types.ts | 104 -- .../lib/react-studio-template-renderer.ts | 4 +- .../react-utils-studio-template-renderer.ts | 50 +- .../lib/utils-file-functions/index.ts | 5 + .../utils-file-functions/json-path-fetch.ts | 52 + .../__tests__/getOverrideProps.test.tsx | 0 .../getOverridesFromVariants.test.tsx | 2 +- .../mergeVariantsAndOverrides.test.tsx | 2 +- .../overrides/findChildOverrides.ts | 63 + .../overrides/getOverrideProps.ts | 47 + .../overrides/getOverridesFromVariants.ts | 74 ++ .../overrides/index.ts | 11 +- .../overrides/mergeVariantsAndOverrides.ts | 79 ++ .../overrides/override-types.ts | 35 + .../utils-file-functions/storage-manager.ts | 42 + .../utils-file-functions/string-formatter.ts | 118 ++ .../lib/utils-file-functions/utils.ts | 46 + .../lib/utils-file-functions/validation.ts | 309 +++++ .../lib/views/react-view-renderer.ts | 5 +- packages/codegen-ui-react/package.json | 4 +- 34 files changed, 3227 insertions(+), 1698 deletions(-) create mode 100644 packages/codegen-ui-react/lib/__tests__/overrides/getOverrideProps.test.ts create mode 100644 packages/codegen-ui-react/lib/__tests__/overrides/getOverridesFromVariants.test.ts create mode 100644 packages/codegen-ui-react/lib/__tests__/overrides/mergeVariantsAndOverrides.test.ts delete mode 100644 packages/codegen-ui-react/lib/overrides/findChildOverrides.ts delete mode 100644 packages/codegen-ui-react/lib/overrides/getOverrideProps.ts delete mode 100644 packages/codegen-ui-react/lib/overrides/getOverridesFromVariants.ts delete mode 100644 packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts delete mode 100644 packages/codegen-ui-react/lib/overrides/types.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/json-path-fetch.ts rename packages/codegen-ui-react/lib/{ => utils-file-functions}/overrides/__tests__/getOverrideProps.test.tsx (100%) rename packages/codegen-ui-react/lib/{ => utils-file-functions}/overrides/__tests__/getOverridesFromVariants.test.tsx (98%) rename packages/codegen-ui-react/lib/{ => utils-file-functions}/overrides/__tests__/mergeVariantsAndOverrides.test.tsx (98%) create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/overrides/findChildOverrides.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverrideProps.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverridesFromVariants.ts rename packages/codegen-ui-react/lib/{ => utils-file-functions}/overrides/index.ts (56%) create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/overrides/mergeVariantsAndOverrides.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/overrides/override-types.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/storage-manager.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/string-formatter.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/utils.ts create mode 100644 packages/codegen-ui-react/lib/utils-file-functions/validation.ts diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/react-studio-template-renderer-helper.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/react-studio-template-renderer-helper.test.ts.snap index 2f733d0ed..9fee26d74 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/react-studio-template-renderer-helper.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/react-studio-template-renderer-helper.test.ts.snap @@ -16,7 +16,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -33,7 +42,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -50,7 +68,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -67,7 +94,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -84,7 +120,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -101,7 +146,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -118,7 +172,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -135,7 +198,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -152,7 +224,16 @@ exports[`react-studio-template-renderer-helper transpile successfully transpiles "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; 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 04e54e330..331716501 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 @@ -515,7 +515,16 @@ export default function CreateOwnerForm(props) { exports[`amplify form renderer tests GraphQL form tests should 1:1 relationships without types file path - Create 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -1065,7 +1074,16 @@ export default function CreateOwnerForm(props) { exports[`amplify form renderer tests GraphQL form tests should 1:1 relationships without types file path - Create amplify js v6 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -1711,7 +1729,16 @@ export default function MyPostForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form - amplify js v6 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -2372,7 +2399,16 @@ export default function MyPostForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -3049,8 +3085,17 @@ export default function MyMemberForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Team } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -3698,8 +3743,17 @@ export default function MovieCreateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with composite primary key 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Tag } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -4255,8 +4309,17 @@ export default function SchoolCreateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with hasMany relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Student } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -4797,8 +4860,17 @@ export default function BookCreateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with hasOne relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Author } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -5309,7 +5381,16 @@ export default function CommentCreateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with id field instead of belongsTo 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -5936,8 +6017,17 @@ export default function TagCreateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with manyToMany relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, SelectFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Post } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -6614,8 +6704,17 @@ export default function BookCreateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with multiple hasOne relationships 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Author, Title } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -7453,8 +7552,17 @@ export default function CreateCPKTeacherForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with multiple relationship & cpk 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CPKClass, CPKProject, CPKStudent } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -8020,8 +8128,17 @@ export default function CreateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a create form with nonModel field 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { ParentTable } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -8712,8 +8829,17 @@ export default function PostUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a relationship update form with autocomplete 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Comment, Post } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -9487,8 +9613,17 @@ export default function MyPostForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a update form without relationships - amplify js v6 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Post } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -10274,8 +10409,17 @@ export default function MyPostForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate a update form without relationships 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Post } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -11063,8 +11207,17 @@ export default function MovieUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with composite primary key - amplify js v6 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Movie, Tag } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -11845,8 +11998,17 @@ export default function MovieUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with composite primary key 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Movie, Tag } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -12584,8 +12746,17 @@ export default function CommentUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with hasMany relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Comment, Post } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -13317,7 +13488,16 @@ export default function CommentUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with hasMany relationship without types file - amplify js v6 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -14048,7 +14228,16 @@ export default function CommentUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with hasMany relationship without types file 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -14599,8 +14788,17 @@ export default function CommentUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with id field instead of belongsTo 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Comment } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -15216,8 +15414,17 @@ export default function ClassUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with many to many relationship - amplify js v6 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Class, Student } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -15829,8 +16036,17 @@ export default function ClassUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with many to many relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Class, Student } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -16419,8 +16635,17 @@ export default function UpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an update form with nonModel field 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { BasicTable, ParentTable } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -17434,8 +17659,17 @@ export default function UpdateCPKTeacherForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an upgrade form with multiple relationship & cpk - amplify js v6 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CPKClass, CPKProject, CPKStudent, CPKTeacher } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -18451,8 +18685,17 @@ export default function UpdateCPKTeacherForm(props) { exports[`amplify form renderer tests GraphQL form tests should generate an upgrade form with multiple relationship & cpk 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CPKClass, CPKProject, CPKStudent, CPKTeacher } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -19234,7 +19477,16 @@ export default function CreateCompositeToyForm(props) { exports[`amplify form renderer tests GraphQL form tests should render a create form for child of 1:m relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -20171,8 +20423,17 @@ export default function CreateCommentForm(props) { exports[`amplify form renderer tests GraphQL form tests should render a create form for child of 1:m-belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Org, Post, User } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -21281,8 +21542,17 @@ export default function CreateCompositeDogForm(props) { exports[`amplify form renderer tests GraphQL form tests should render a create form for model with composite keys 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeBowl, CompositeOwner, CompositeToy, CompositeVet } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -21832,8 +22102,17 @@ export default function CreatePostForm(props) { exports[`amplify form renderer tests GraphQL form tests should render a create form for parent of 1:m-belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Comment } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -22430,8 +22709,17 @@ export default function UpdatePostForm(props) { exports[`amplify form renderer tests GraphQL form tests should render a update form for parent of 1:m-belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Comment, Post } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -23048,8 +23336,17 @@ export default function ChildItemUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should render an update form with child field 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { ChildItem } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -23782,8 +24079,17 @@ export default function PostUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should render an update form with id field instead of belongsTo 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Blog, Comment, Post } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -24332,8 +24638,17 @@ export default function CreateDogForm(props) { exports[`amplify form renderer tests GraphQL form tests should render thrown error for required parent field 1:1 relationships - Create 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Owner } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -24882,8 +25197,17 @@ export default function CreateOwnerForm(props) { exports[`amplify form renderer tests GraphQL form tests should render thrown error for required related field 1:1 relationships - Create 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Dog } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -25427,8 +25751,17 @@ export default function CommentUpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should treat relationship as bidirectional without belongsTo 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Comment } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -26067,8 +26400,17 @@ export default function UpdateForm(props) { exports[`amplify form renderer tests GraphQL form tests should use custom primary key on fetch query for update form 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { ChildItem, CustomKeyModel } from \\"../API\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -26587,7 +26929,16 @@ export default function CustomDataForm(props) { exports[`amplify form renderer tests NoApi form tests should render custom data form successfully with no configured API 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -26641,9 +26992,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeToy, CompositeDog } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -27236,7 +27587,16 @@ export default function CreateCompositeToyForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a create form for child of 1:m relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -27292,9 +27652,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Comment, Post, User as User0, Org as Org0 } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -28022,8 +28382,17 @@ export default function CreateCommentForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a create form for child of 1:m-belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Post, User as User0, Org as Org0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -28082,7 +28451,6 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeDog, CompositeBowl as CompositeBowl0, @@ -28092,6 +28460,7 @@ import { CompositeDogCompositeVet, } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -28971,8 +29340,17 @@ export default function CreateCompositeDogForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a create form for model with composite keys 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeBowl as CompositeBowl0, CompositeOwner as CompositeOwner0, CompositeToy, CompositeVet } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -29368,7 +29746,16 @@ export default function CustomDataForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a custom backed create form 2`] = ` "import * as React from \\"react\\"; import { GridProps, RadioGroupFieldProps, SelectFieldProps, StepperFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -29764,7 +30151,16 @@ export default function CustomDataForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a custom backed create form with styled gaps 2`] = ` "import * as React from \\"react\\"; import { GridProps, RadioGroupFieldProps, SelectFieldProps, StepperFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -30289,7 +30685,16 @@ export default function CustomDataForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a custom backed form with an array field 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -30701,7 +31106,16 @@ export default function CustomDataForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a custom backed update form 2`] = ` "import * as React from \\"react\\"; import { GridProps, RadioGroupFieldProps, SelectFieldProps, StepperFieldProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -31433,7 +31847,16 @@ export default function MyPostForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a datastore backed form with a custom array field 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -31503,9 +31926,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Org, Comment } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -32001,8 +32424,17 @@ export default function UpdateOrgForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render a update form for parent of 1:m-belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Org, Comment } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -32053,7 +32485,6 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeDog, CompositeBowl as CompositeBowl0, @@ -32063,6 +32494,7 @@ import { CompositeDogCompositeVet, } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -33123,8 +33555,17 @@ export default function UpdateCompositeDogForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render an update form for model with composite keys 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeDog, CompositeBowl as CompositeBowl0, CompositeOwner as CompositeOwner0, CompositeToy, CompositeVet } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -33190,7 +33631,6 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { CPKTeacher, CPKStudent as CPKStudent0, @@ -33199,6 +33639,7 @@ import { CPKTeacherCPKClass, } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -34015,8 +34456,17 @@ export default function UpdateCPKTeacherForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render an update form for model with cpk 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CPKTeacher, CPKStudent as CPKStudent0, CPKClass, CPKProject } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -34586,7 +35036,16 @@ export default function HappyPathJSONCreate(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render happy path nested json fields for create form 2`] = ` "import * as React from \\"react\\"; import { DividerProps, GridProps, HeadingProps, SwitchFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -35185,7 +35644,16 @@ export default function HappyPathJSONUpdate(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render happy path nested json fields for update form 2`] = ` "import * as React from \\"react\\"; import { DividerProps, GridProps, HeadingProps, SwitchFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -35906,7 +36374,16 @@ export default function NestedJson(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render nested json fields for create form 2`] = ` "import * as React from \\"react\\"; import { GridProps, HeadingProps, SwitchFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -36430,7 +36907,16 @@ export default function NestedJson(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render nested json fields for update form 2`] = ` "import * as React from \\"react\\"; import { GridProps, HeadingProps, SelectFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -36492,7 +36978,6 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeDog, CompositeOwner as CompositeOwner0, @@ -36502,6 +36987,7 @@ import { CompositeBowl, } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -37565,8 +38051,17 @@ export default function UpdateCompositeDogForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render scalar relationship fields if overrides 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { CompositeDog, CompositeOwner as CompositeOwner0, CompositeToy, CompositeVet } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -37774,7 +38269,16 @@ export default function CustomWithSectionalElements(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render sectional elements 2`] = ` "import * as React from \\"react\\"; import { DividerProps, GridProps, HeadingProps, TextFieldProps, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -37822,9 +38326,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Dog, Owner } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -38266,8 +38770,17 @@ export default function CreateDogForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render thrown error for required parent field 1:1 relationships - Create 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Owner } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -38317,9 +38830,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Dog, Owner } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -38798,8 +39311,17 @@ export default function UpdateDogForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render thrown error for required parent field 1:1 relationships - Update 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Dog, Owner } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -38850,9 +39372,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Owner, Dog as Dog0 } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -39295,8 +39817,17 @@ export default function CreateOwnerForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render thrown error for required related field 1:1 relationships - Create 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Dog as Dog0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -39346,9 +39877,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Owner, Dog as Dog0 } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -39829,8 +40360,17 @@ export default function UpdateOwnerForm(props) { exports[`amplify form renderer tests datastore form tests custom form tests should render thrown error for required related field 1:1 relationships - Update 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Owner, Dog as Dog0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -40468,7 +41008,16 @@ export default function MyPostForm(props) { exports[`amplify form renderer tests datastore form tests should generate a create form 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -40535,9 +41084,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Tag, Post, TagPost } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -41068,8 +41617,17 @@ export default function TagCreateForm(props) { exports[`amplify form renderer tests datastore form tests should generate a create form with array of Enums 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, SelectFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Post } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -41123,9 +41681,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Member, Team as Team0 } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -41647,8 +42205,17 @@ export default function MyMemberForm(props) { exports[`amplify form renderer tests datastore form tests should generate a create form with belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Team as Team0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -41702,9 +42269,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { School, Student } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -42154,8 +42721,17 @@ export default function SchoolCreateForm(props) { exports[`amplify form renderer tests datastore form tests should generate a create form with hasMany relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Student } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -42206,9 +42782,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Book, Author } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -42651,8 +43227,17 @@ export default function BookCreateForm(props) { exports[`amplify form renderer tests datastore form tests should generate a create form with hasOne relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Author } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -42704,9 +43289,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Tag, Post, TagPost } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -43237,8 +43822,17 @@ export default function TagCreateForm(props) { exports[`amplify form renderer tests datastore form tests should generate a create form with manyToMany relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, SelectFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Post } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -43292,9 +43886,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Book, Author, Title } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -43843,8 +44437,17 @@ export default function BookCreateForm(props) { exports[`amplify form renderer tests datastore form tests should generate a create form with multiple hasOne relationships 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Author, Title } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -44603,8 +45206,17 @@ export default function MyPostForm(props) { exports[`amplify form renderer tests datastore form tests should generate a update form 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Post } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -44674,9 +45286,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { School, Student } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -45181,8 +45793,17 @@ export default function SchoolUpdateForm(props) { exports[`amplify form renderer tests datastore form tests should generate a update form with hasMany relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { School, Student } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -45234,9 +45855,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { School, Student as Student0 } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -45788,8 +46409,17 @@ export default function SchoolUpdateForm(props) { exports[`amplify form renderer tests datastore form tests should generate a update form with hasMany relationship with model name collision 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { School, Student as Student0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -45844,9 +46474,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Member, Team as Team0 } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -46397,8 +47027,17 @@ export default function MyMemberForm(props) { exports[`amplify form renderer tests datastore form tests should generate an update form with belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Member, Team as Team0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -46454,9 +47093,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Tag, Post, TagPost } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -47070,8 +47709,17 @@ export default function TagUpdateForm(props) { exports[`amplify form renderer tests datastore form tests should generate an update form with manyToMany relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, SelectFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Tag, Post } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -47655,7 +48303,16 @@ export default function MyFlexCreateForm(props) { exports[`amplify form renderer tests datastore form tests should render a create form with colliding model name 2`] = ` "import * as React from \\"react\\"; import { GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -48211,7 +48868,16 @@ export default function BlogCreateForm(props) { exports[`amplify form renderer tests datastore form tests should render a form with a javascript reserved word as the field name 2`] = ` "import * as React from \\"react\\"; import { GridProps, SwitchFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -49181,7 +49847,16 @@ export default function InputGalleryCreateForm(props) { exports[`amplify form renderer tests datastore form tests should render a form with multiple date types on create form 2`] = ` "import * as React from \\"react\\"; import { CheckboxFieldProps, GridProps, RadioGroupFieldProps, TextAreaFieldProps, TextFieldProps, ToggleButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -50091,8 +50766,17 @@ export default function InputGalleryUpdateForm(props) { exports[`amplify form renderer tests datastore form tests should render a form with multiple date types on update form 2`] = ` "import * as React from \\"react\\"; import { CheckboxFieldProps, GridProps, RadioGroupFieldProps, TextAreaFieldProps, TextFieldProps, ToggleButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { InputGallery } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -50778,8 +51462,17 @@ export default function MyFlexUpdateForm(props) { exports[`amplify form renderer tests datastore form tests should render a update form with colliding model name 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Flex as Flex0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -51491,7 +52184,16 @@ export default function PostCreateFormRow(props) { exports[`amplify form renderer tests datastore form tests should render form with a two inputs in row 2`] = ` "import * as React from \\"react\\"; import { GridProps, SelectFieldProps, TextAreaFieldProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -51561,9 +52263,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Member, Team as Team0 } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -52085,8 +52787,17 @@ export default function MyMemberForm(props) { exports[`amplify form renderer tests datastore form tests should use proper field overrides for belongsTo relationship 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Team as Team0 } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -52129,7 +52840,6 @@ exports[`amplify form renderer tests forms with StorageField tests should render import * as React from \\"react\\"; import { Button, Flex, Grid, TextField } from \\"@aws-amplify/ui-react\\"; import { StorageManager } from \\"@aws-amplify/ui-react-storage\\"; -import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { Product } from \\"../models\\"; import { fetchByPath, @@ -52137,6 +52847,7 @@ import { processFile, validateField, } from \\"./utils\\"; +import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; export default function CreateProductForm(props) { const { @@ -52346,7 +53057,6 @@ exports[`amplify form renderer tests forms with StorageField tests should render import * as React from \\"react\\"; import { Button, Flex, Grid, TextField } from \\"@aws-amplify/ui-react\\"; import { StorageManager } from \\"@aws-amplify/ui-react-storage\\"; -import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { Product } from \\"../models\\"; import { fetchByPath, @@ -52354,6 +53064,7 @@ import { processFile, validateField, } from \\"./utils\\"; +import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; export default function UpdateProductForm(props) { const { @@ -52583,8 +53294,17 @@ exports[`amplify form renderer tests forms with StorageField tests should render "import * as React from \\"react\\"; import { GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; import { StorageManagerProps } from \\"@aws-amplify/ui-react-storage\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Product } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -52624,7 +53344,6 @@ exports[`amplify form renderer tests forms with StorageField tests should render import * as React from \\"react\\"; import { Button, Flex, Grid, TextField } from \\"@aws-amplify/ui-react\\"; import { StorageManager } from \\"@aws-amplify/ui-react-storage\\"; -import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { Product } from \\"../models\\"; import { fetchByPath, @@ -52632,6 +53351,7 @@ import { processFile, validateField, } from \\"./utils\\"; +import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; export default function UpdateProductForm(props) { const { @@ -52878,9 +53598,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Car, Dealership } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -53329,8 +54049,17 @@ export default function UpdateCarForm(props) { exports[`amplify form renderer tests should render form for child of bidirectional 1:m when field defined on parent 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Car, Dealership } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -53381,9 +54110,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Dealership, Car } from \\"../models\\"; import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -53875,8 +54604,17 @@ export default function UpdateDealershipForm(props) { exports[`amplify form renderer tests should render form for parent of bidirectional 1:m when field defined on parent 2`] = ` "import * as React from \\"react\\"; import { AutocompleteProps, GridProps, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { Dealership, Car } from \\"../models\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-views.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-views.test.ts.snap index 8608d9deb..3239909b9 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-views.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react-views.test.ts.snap @@ -218,7 +218,17 @@ export default function MyPostTable(props) { exports[`amplify view renderer tests should call util file if rendered 2`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps, createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; +import { createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type MyPostTableProps = React.PropsWithChildren<{ overrides?: EscapeHatchProps | undefined | null; predicateOverride?: ReturnType | undefined | null; @@ -286,7 +296,17 @@ export default function CustomTable(props) { exports[`amplify view renderer tests should render view with custom datastore 2`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps, createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; +import { createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type CustomTableProps = React.PropsWithChildren<{ overrides?: EscapeHatchProps | undefined | null; predicateOverride?: ReturnType | undefined | null; @@ -398,7 +418,17 @@ export default function MyPostTable(props) { exports[`amplify view renderer tests should render view with passed in predicate and sort 2`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps, createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; +import { createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type MyPostTableProps = React.PropsWithChildren<{ overrides?: EscapeHatchProps | undefined | null; predicateOverride?: ReturnType | undefined | null; diff --git a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react.test.ts.snap index 4e76067cf..d10fa5231 100644 --- a/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react.test.ts.snap @@ -4,15 +4,21 @@ exports[`amplify render tests actions DataStore DataStoreCreateItem 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - useDataStoreCreateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreCreateAction } from \\"@aws-amplify/ui-react/internal\\"; import { Customer } from \\"../models\\"; import { schema } from \\"../models/schema\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CreateCustomerButtonOverridesProps = { @@ -54,15 +60,21 @@ exports[`amplify render tests actions DataStore DataStoreDeleteItem 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - useDataStoreDeleteAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreDeleteAction } from \\"@aws-amplify/ui-react/internal\\"; import { Customer } from \\"../models\\"; import { schema } from \\"../models/schema\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type DeleteCustomerButtonOverridesProps = { @@ -104,15 +116,21 @@ exports[`amplify render tests actions DataStore DataStoreUpdateItem 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - useDataStoreUpdateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreUpdateAction } from \\"@aws-amplify/ui-react/internal\\"; import { Customer } from \\"../models\\"; import { schema } from \\"../models/schema\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type UpdateCustomerButtonOverridesProps = { @@ -159,8 +177,16 @@ import { createCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CreateCustomerButtonOverridesProps = { @@ -211,8 +237,16 @@ import { createCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CreateCustomerButtonOverridesProps = { @@ -265,8 +299,16 @@ import { deleteCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type DeleteCustomerButtonOverridesProps = { @@ -318,8 +360,16 @@ import { updateCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type UpdateCustomerButtonOverridesProps = { @@ -368,13 +418,19 @@ exports[`amplify render tests actions auth signs out 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - useAuthSignOutAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useAuthSignOutAction } from \\"@aws-amplify/ui-react/internal\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SignOutButtonOverridesProps = { @@ -414,8 +470,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps, useNavigateAction } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type NavigateButtonOverridesProps = { @@ -458,8 +522,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps, useNavigateAction } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type NavigateButtonOverridesProps = { @@ -502,8 +574,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps, useNavigateAction } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type NavigateButtonOverridesProps = { @@ -547,8 +627,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps, useNavigateAction } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ReloadButtonOverridesProps = { @@ -588,7 +676,6 @@ Object { import * as React from \\"react\\"; import { User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; @@ -602,6 +689,15 @@ import { TextProps, } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ConditionalInMutationOverridesProps = { @@ -667,8 +763,16 @@ exports[`amplify render tests basic component tests should generate a simple but import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomButtonOverridesProps = { @@ -702,8 +806,16 @@ exports[`amplify render tests basic component tests should generate a simple tex import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomTextOverridesProps = { @@ -735,8 +847,16 @@ exports[`amplify render tests basic component tests should generate a simple vie import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type TestOverridesProps = { @@ -766,7 +886,6 @@ exports[`amplify render tests bindings auth supports auth bindings in actions 1` "/* eslint-disable */ import * as React from \\"react\\"; import { - EscapeHatchProps, useAuth, useDataStoreCreateAction, } from \\"@aws-amplify/ui-react/internal\\"; @@ -775,6 +894,15 @@ import { schema } from \\"../models/schema\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComponentWithAuthEventBindingOverridesProps = { @@ -819,8 +947,16 @@ import * as React from \\"react\\"; import { Class } from \\"../models\\"; import { getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type DataBindingNamedClassOverridesProps = { @@ -855,8 +991,16 @@ import * as React from \\"react\\"; import { Flex as Flex0 } from \\"../models\\"; import { getOverrideProps } from \\"./utils\\"; import { FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type DataBindingNamedClassOverridesProps = { @@ -899,8 +1043,16 @@ import { Placeholder, } from \\"@aws-amplify/ui-react\\"; import { API } from \\"aws-amplify\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type AuthorProfileCollectionOverridesProps = { @@ -1035,10 +1187,7 @@ exports[`amplify render tests collection GraphQL should render collection with d import * as React from \\"react\\"; import { UserPreferences } from \\"../API\\"; import { listUserPreferences, listUsers } from \\"../graphql/queries\\"; -import { - EscapeHatchProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { generateClient } from \\"aws-amplify/api\\"; import { Button, @@ -1053,6 +1202,15 @@ import { import { getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CollectionOfCustomButtonsOverridesProps = { @@ -1237,10 +1395,7 @@ exports[`amplify render tests collection GraphQL should render collection with d import * as React from \\"react\\"; import { UserPreferences } from \\"../API\\"; import { listUserPreferences, listUsers } from \\"../graphql/queries\\"; -import { - EscapeHatchProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { API } from \\"aws-amplify\\"; import { Button, @@ -1255,6 +1410,15 @@ import { import { getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CollectionOfCustomButtonsOverridesProps = { @@ -1446,8 +1610,16 @@ import { Placeholder, } from \\"@aws-amplify/ui-react\\"; import { API } from \\"aws-amplify\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ListingCardCollectionOverridesProps = { @@ -1591,8 +1763,16 @@ import { Placeholder, } from \\"@aws-amplify/ui-react\\"; import { API } from \\"aws-amplify\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ListingCardCollectionOverridesProps = { @@ -1713,8 +1893,16 @@ import { Placeholder, } from \\"@aws-amplify/ui-react\\"; import { API } from \\"aws-amplify\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type AuthorProfileCollectionOverridesProps = { @@ -1848,14 +2036,20 @@ exports[`amplify render tests collection should not render nested query if the d "/* eslint-disable */ import * as React from \\"react\\"; import { Author } from \\"../models\\"; -import { - EscapeHatchProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import AuthorProfile, { AuthorProfileProps } from \\"./AuthorProfile\\"; import { getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type AuthorProfileCollectionOverridesProps = { @@ -1920,7 +2114,6 @@ exports[`amplify render tests collection should render collection with data bind import * as React from \\"react\\"; import { UserPreferences, User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; @@ -1935,6 +2128,15 @@ import { import { getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CollectionOfCustomButtonsOverridesProps = { @@ -2065,7 +2267,6 @@ Object { import * as React from \\"react\\"; import { UserPreferences, User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; @@ -2081,6 +2282,15 @@ import { import { getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CollectionOfCustomButtonsOverridesProps = { @@ -2192,7 +2402,6 @@ exports[`amplify render tests collection should render collection with data bind import * as React from \\"react\\"; import { UserPreferences, User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; @@ -2207,6 +2416,15 @@ import { import { getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CollectionOfCustomButtonsOverridesProps = { @@ -2309,14 +2527,20 @@ exports[`amplify render tests collection should render collection with data bind "/* eslint-disable */ import * as React from \\"react\\"; import { UntitledModel } from \\"../models\\"; -import { - EscapeHatchProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import ListingCard, { ListingCardProps } from \\"./ListingCard\\"; import { getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ListingCardCollectionOverridesProps = { @@ -2384,8 +2608,16 @@ import * as React from \\"react\\"; import ListingCard, { ListingCardProps } from \\"./ListingCard\\"; import { getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ListingCardCollectionOverridesProps = { @@ -2432,16 +2664,22 @@ exports[`amplify render tests collection should render concatenated keys if mode "/* eslint-disable */ import * as React from \\"react\\"; import { CompositePerson } from \\"../models\\"; -import { - EscapeHatchProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import CompositePersonProfile, { CompositePersonProfileProps, } from \\"./CompositePersonProfile\\"; import { getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CompositePersonProfileCollectionOverridesProps = { @@ -2509,7 +2747,6 @@ exports[`amplify render tests collection should render if model name collides wi import * as React from \\"react\\"; import { Flex as Flex0, FlexModel, Button as Button0 } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; @@ -2525,6 +2762,15 @@ import { import { getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CollectionWithModelNameCollisionsOverridesProps = { @@ -2644,14 +2890,20 @@ exports[`amplify render tests collection should render nested query if model has "/* eslint-disable */ import * as React from \\"react\\"; import { Author } from \\"../models\\"; -import { - EscapeHatchProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import AuthorProfile, { AuthorProfileProps } from \\"./AuthorProfile\\"; import { getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type AuthorProfileCollectionOverridesProps = { @@ -2726,8 +2978,16 @@ exports[`amplify render tests complex component tests should generate a button w import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ViewWithButtonOverridesProps = { @@ -2763,8 +3023,16 @@ import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ViewWithCustomButtonOverridesProps = { @@ -2799,8 +3067,16 @@ import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ViewWithCustomButtonOverridesProps = { @@ -2835,8 +3111,16 @@ exports[`amplify render tests complex component tests should generate a componen import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ViewWithButtonOverridesProps = { @@ -2871,8 +3155,16 @@ exports[`amplify render tests complex examples should render complex sample 1 1` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest1OverridesProps = { @@ -2926,8 +3218,16 @@ exports[`amplify render tests complex examples should render complex sample 2 1` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest2OverridesProps = { @@ -3009,8 +3309,16 @@ import { ViewProps, } from \\"@aws-amplify/ui-react\\"; import ReneButton, { ReneButtonProps } from \\"./ReneButton\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest3OverridesProps = { @@ -3101,8 +3409,16 @@ import { mergeVariantsAndOverrides, } from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest4OverridesProps = { @@ -3222,8 +3538,16 @@ exports[`amplify render tests complex examples should render complex sample 5 1` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest5OverridesProps = { @@ -3281,8 +3605,16 @@ exports[`amplify render tests complex examples should render complex sample 6 1` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest6OverridesProps = { @@ -3372,8 +3704,16 @@ import { View, ViewProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest7OverridesProps = { @@ -3452,8 +3792,16 @@ exports[`amplify render tests complex examples should render complex sample 8 1` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest8OverridesProps = { @@ -3537,8 +3885,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest9OverridesProps = { @@ -3946,8 +4302,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest10OverridesProps = { @@ -4907,8 +5271,16 @@ import { View, ViewProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComplexTest11OverridesProps = { @@ -5872,8 +6244,16 @@ exports[`amplify render tests component with binding should render build propert import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type TextWithDataBindingOverridesProps = { @@ -5915,8 +6295,16 @@ import { View, ViewProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComponentWithSlotBindingOverridesProps = { @@ -5957,8 +6345,16 @@ import * as React from \\"react\\"; import { User } from \\"../API\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComponentWithDataBindingOverridesProps = { @@ -5999,8 +6395,16 @@ import * as React from \\"react\\"; import { User } from \\"../models\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComponentWithDataBindingOverridesProps = { @@ -6041,8 +6445,16 @@ import * as React from \\"react\\"; import { UntitledModel } from \\"../models\\"; import { getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SectionHeadingOverridesProps = { @@ -6107,8 +6519,16 @@ exports[`amplify render tests component with data binding should render with dat import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ChildComponentWithDataBindingOverridesProps = { @@ -6153,8 +6573,16 @@ import { mergeVariantsAndOverrides, } from \\"./utils\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ViewPrimitiveOverridesProps = { @@ -6209,8 +6637,16 @@ import { mergeVariantsAndOverrides, } from \\"./utils\\"; import { Icon, IconProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type IconVariantsOverridesProps = { @@ -6285,8 +6721,16 @@ import { mergeVariantsAndOverrides, } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomButtonOverridesProps = { @@ -6344,8 +6788,16 @@ import { mergeVariantsAndOverrides, } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomButtonOverridesProps = { @@ -6408,8 +6860,16 @@ exports[`amplify render tests concat and conditional transform should render chi import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ChildComponentWithDataBoundConcatenationOverridesProps = { @@ -6457,8 +6917,16 @@ exports[`amplify render tests concat and conditional transform should render chi import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ChildComponentWithStaticConcatenationOverridesProps = { @@ -6500,8 +6968,16 @@ import * as React from \\"react\\"; import { User } from \\"../models\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomButtonOverridesProps = { @@ -6541,8 +7017,16 @@ import * as React from \\"react\\"; import { User } from \\"../models\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomButtonOverridesProps = { @@ -6600,8 +7084,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ConditionalComponentWithDataBindingOverridesProps = { @@ -6655,8 +7147,16 @@ exports[`amplify render tests concat and conditional transform should render com import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomButtonOverridesProps = { @@ -6690,7 +7190,16 @@ exports[`amplify render tests custom components alias parent should render decla import { GridProps } from \\"./Grid\\"; import { ButtonProps } from \\"@aws-amplify/ui-react\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type AliasParentOverridesProps = { AliasParent?: ViewTestProps; @@ -6711,8 +7220,16 @@ import { getOverrideProps } from \\"./utils\\"; import { Grid as GridCustom, GridProps } from \\"./Grid\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; import ViewTest, { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type AliasParentOverridesProps = { @@ -6746,8 +7263,16 @@ import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import MyView, { MyViewProps } from \\"./MyView\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomChildrenOverridesProps = { @@ -6832,7 +7357,16 @@ exports[`amplify render tests custom components custom children should render de "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { MyViewProps } from \\"./MyView\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomChildrenOverridesProps = { CustomChildren?: MyViewProps; @@ -6851,8 +7385,16 @@ import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import ViewTest, { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { @@ -6940,7 +7482,16 @@ exports[`amplify render tests custom components custom parent and children shoul "import * as React from \\"react\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentAndChildrenOverridesProps = { CustomParentAndChildren?: ViewTestProps; @@ -6959,8 +7510,16 @@ import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; import MyView, { MyViewProps } from \\"./MyView\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentOverridesProps = { @@ -7043,7 +7602,16 @@ exports[`amplify render tests custom components custom parent should render decl "import * as React from \\"react\\"; import { ButtonProps } from \\"@aws-amplify/ui-react\\"; import { MyViewProps } from \\"./MyView\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomParentOverridesProps = { CustomParent?: MyViewProps; @@ -7235,8 +7803,17 @@ exports.default = ViewWithButton; exports[`amplify render tests declarations should render declarations 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { ButtonProps, FlexProps, ImageProps } from \\"@aws-amplify/ui-react\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ProfileOverridesProps = { Profile?: PrimitiveOverrideProps; @@ -7257,8 +7834,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type BoundDefaultValueOverridesProps = { @@ -7295,10 +7880,7 @@ Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; import { User } from \\"../models\\"; -import { - EscapeHatchProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Collection, CollectionProps, @@ -7308,6 +7890,15 @@ import { import { getOverrideProps } from \\"./utils\\"; import { MyTextProps } from \\"./MyText\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CollectionDefaultValueOverridesProps = { @@ -7370,8 +7961,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SimpleAndBoundDefaultValueOverridesProps = { @@ -7409,8 +8008,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SimplePropertyBindingDefaultValueOverridesProps = { @@ -7459,8 +8066,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SocialAOverridesProps = { @@ -7788,8 +8403,16 @@ import { TextField, TextFieldProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type InputMutationOnClickOverridesProps = { @@ -7841,10 +8464,7 @@ Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; import { getOverrideProps, useStateMutationAction } from \\"./utils\\"; -import { - EscapeHatchProps, - useDataStoreUpdateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreUpdateAction } from \\"@aws-amplify/ui-react/internal\\"; import { Customer } from \\"../models\\"; import { schema } from \\"../models/schema\\"; import { @@ -7856,6 +8476,15 @@ import { TextFieldProps, } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type MyFormOverridesProps = { @@ -7911,8 +8540,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps, useStateMutationAction } from \\"./utils\\"; import { Button, ButtonProps, Flex, FlexProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ColorChangeOnClickOverridesProps = { @@ -7970,8 +8607,16 @@ import { TextFieldProps, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type TwoWayBindingsOverridesProps = { @@ -8032,8 +8677,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CheckboxControlledElementOverridesProps = { @@ -8090,8 +8743,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type StepperControlledElementOverridesProps = { @@ -8151,8 +8812,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SwitchControlledElementOverridesProps = { @@ -8197,7 +8866,6 @@ Object { import * as React from \\"react\\"; import { User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, useAuth, useDataStoreBinding, @@ -8217,6 +8885,15 @@ import { TextProps, } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type InitialValueBindingsOverridesProps = { @@ -8545,8 +9222,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CardAOverridesProps = { @@ -8807,8 +9492,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ButtonsToggleStateOverridesProps = { @@ -8877,8 +9570,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type MutationWithSyntheticPropOverridesProps = { @@ -8939,8 +9640,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type UpdateVisibilityOverridesProps = { @@ -9010,8 +9719,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SetStateWithoutInitialValueOverridesProps = { @@ -9077,8 +9794,16 @@ Object { import * as React from \\"react\\"; import { getOverrideProps, useNavigateAction } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type InvalidNameForMethodOverridesProps = { @@ -9130,8 +9855,16 @@ import { Text, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type NestedMutationOverridesProps = { @@ -9223,8 +9956,16 @@ import { TextProps, } from \\"@aws-amplify/ui-react\\"; import option, { optionProps } from \\"./option\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type TwoWayBindingsOverridesProps = { @@ -9749,8 +10490,16 @@ exports[`amplify render tests primitives CheckboxField 1`] = ` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { CheckboxField, CheckboxFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CheckBoxFieldPrimitiveOverridesProps = { @@ -9789,8 +10538,16 @@ import { ExpanderItemProps, ExpanderProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ExpanderPrimitiveOverridesProps = { @@ -9838,8 +10595,16 @@ exports[`amplify render tests primitives ExpanderItem 1`] = ` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { ExpanderItem, ExpanderItemProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type MyExpanderItemOverridesProps = { @@ -9873,8 +10638,16 @@ exports[`amplify render tests primitives Icon 1`] = ` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Icon, IconProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type IconPrimitiveOverridesProps = { @@ -9913,8 +10686,16 @@ exports[`amplify render tests primitives Icon with lower-cased type \`object\` f import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Icon, IconProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type IconPrimitiveWithLowerCasedTypeOverridesProps = { @@ -9961,8 +10742,16 @@ import { MenuItemProps, MenuProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type MenuPrimitiveOverridesProps = { @@ -10000,8 +10789,16 @@ import { MenuButton, MenuButtonProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type MenuButtonPrimitiveOverridesProps = { @@ -10033,8 +10830,16 @@ exports[`amplify render tests primitives SliderField 1`] = ` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { SliderField, SliderFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type SliderFieldPrimitiveOverridesProps = { @@ -10084,8 +10889,16 @@ import { TableRow, TableRowProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type TablePrimitiveOverridesProps = { @@ -10226,8 +11039,16 @@ exports[`amplify render tests primitives TextAreaField 1`] = ` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { TextAreaField, TextAreaFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type TextAreaFieldPrimitiveOverridesProps = { @@ -10261,8 +11082,16 @@ exports[`amplify render tests primitives TextField 1`] = ` import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { TextField, TextFieldProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type TextFieldPrimitiveOverridesProps = { @@ -10297,8 +11126,16 @@ exports[`amplify render tests renderer configurations with NoApi should render c import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type CustomButtonOverridesProps = { @@ -10330,7 +11167,16 @@ export default function CustomButton( exports[`amplify render tests renderer configurations with NoApi should render component without graphql types 1`] = ` "import * as React from \\"react\\"; import { ButtonProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export declare type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; +export declare type VariantValues = { + [key: string]: string; +}; +export declare type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComponentWithDataBindingOverridesProps = { ComponentWithDataBinding?: PrimitiveOverrideProps; @@ -10353,8 +11199,16 @@ import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ViewWithButtonOverridesProps = { @@ -10402,9 +11256,17 @@ import { TextFieldProps, TextProps, } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; import { SyntheticEvent } from \\"react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type EventsOverridesProps = { @@ -10574,8 +11436,16 @@ import * as React from \\"react\\"; import { getOverrideProps } from \\"./utils\\"; import Input, { InputProps } from \\"./Input\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ParsedFixedValuesOverridesProps = { @@ -10732,14 +11602,14 @@ export default function Profile(props) { ) ); } -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibW9kdWxlLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBLG9CQUFvQjtBQUNwQixPQUFPLEtBQUssS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUMvQixPQUFPLEVBQW9CLE9BQU8sRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQzNFLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLFNBQVMsQ0FBQztBQUMzQyxPQUFPLEVBQUUsTUFBTSxFQUFlLElBQUksRUFBYSxLQUFLLEVBQWMsTUFBTSx1QkFBdUIsQ0FBQztBQVVoRyxNQUFNLENBQUMsT0FBTyxVQUFVLE9BQU8sQ0FBQyxLQUFtQjs7SUFDL0MsTUFBTSxFQUFFLFNBQVMsS0FBYyxLQUFLLEVBQWQsSUFBSSxVQUFLLEtBQUssRUFBOUIsYUFBc0IsQ0FBUSxDQUFDO0lBQ3JDLE1BQU0sY0FBYyxHQUFHLE1BQUEsTUFBQSxPQUFPLEVBQUUsQ0FBQyxJQUFJLDBDQUFFLFVBQVUsbUNBQUksRUFBRSxDQUFDO0lBQ3hELE9BQU8sQ0FBQyxvQkFBQyxJQUFJLG9CQUFLLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxTQUFTLENBQUMsRUFBTSxJQUFJO1FBQUUsb0JBQUMsS0FBSyxrQkFBQyxHQUFHLEVBQUUsY0FBYyxDQUFDLFVBQVUsQ0FBQyxJQUFNLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsRUFBVTtRQUFBLG9CQUFDLE1BQU0sa0JBQUMsUUFBUSxFQUFFLGNBQWMsQ0FBQyxTQUFTLENBQUMsSUFBTSxnQkFBZ0IsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLEVBQVc7UUFBQSxvQkFBQyxNQUFNLGtCQUFDLFFBQVEsRUFBRSxjQUFjLENBQUMsMEJBQTBCLENBQUMsSUFBTSxnQkFBZ0IsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLEVBQVcsQ0FBTyxDQUFDLENBQUM7QUFDL1gsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlICovXG5pbXBvcnQgKiBhcyBSZWFjdCBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCB7IEVzY2FwZUhhdGNoUHJvcHMsIHVzZUF1dGggfSBmcm9tIFwiQGF3cy1hbXBsaWZ5L3VpLXJlYWN0L2ludGVybmFsXCI7XG5pbXBvcnQgeyBnZXRPdmVycmlkZVByb3BzIH0gZnJvbSBcIi4vdXRpbHNcIjtcbmltcG9ydCB7IEJ1dHRvbiwgQnV0dG9uUHJvcHMsIEZsZXgsIEZsZXhQcm9wcywgSW1hZ2UsIEltYWdlUHJvcHMgfSBmcm9tIFwiQGF3cy1hbXBsaWZ5L3VpLXJlYWN0XCI7XG5cbmV4cG9ydCBkZWNsYXJlIHR5cGUgUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxUPiA9IFBhcnRpYWw8VD4gJiBSZWFjdC5ET01BdHRyaWJ1dGVzPEhUTUxEaXZFbGVtZW50PjtleHBvcnQgZGVjbGFyZSB0eXBlIFByb2ZpbGVPdmVycmlkZXNQcm9wcyA9IHtcbiAgICBQcm9maWxlPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxGbGV4UHJvcHM+O1xuICAgIGNoaWxkMT86IFByaW1pdGl2ZU92ZXJyaWRlUHJvcHM8SW1hZ2VQcm9wcz47XG4gICAgY2hpbGQyPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxCdXR0b25Qcm9wcz47XG4gICAgY2hpbGQzPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxCdXR0b25Qcm9wcz47XG59ICYgRXNjYXBlSGF0Y2hQcm9wcztleHBvcnQgdHlwZSBQcm9maWxlUHJvcHMgPSBSZWFjdC5Qcm9wc1dpdGhDaGlsZHJlbjxQYXJ0aWFsPEZsZXhQcm9wcz4gJiB7XG4gICAgb3ZlcnJpZGVzPzogUHJvZmlsZU92ZXJyaWRlc1Byb3BzIHwgdW5kZWZpbmVkIHwgbnVsbDtcbn0+O1xuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gUHJvZmlsZShwcm9wczogUHJvZmlsZVByb3BzKTogUmVhY3QuUmVhY3RFbGVtZW50IHtcbiAgICBjb25zdCB7IG92ZXJyaWRlcywgLi4ucmVzdCB9ID0gcHJvcHM7XG4gICAgY29uc3QgYXV0aEF0dHJpYnV0ZXMgPSB1c2VBdXRoKCkudXNlcj8uYXR0cmlidXRlcyA/PyB7fTtcbiAgICByZXR1cm4gKDxGbGV4IHsuLi5nZXRPdmVycmlkZVByb3BzKG92ZXJyaWRlcywgXCJQcm9maWxlXCIpfSB7Li4ucmVzdH0+PEltYWdlIHNyYz17YXV0aEF0dHJpYnV0ZXNbXCJ1c2VybmFtZVwiXX0gey4uLmdldE92ZXJyaWRlUHJvcHMob3ZlcnJpZGVzLCBcImNoaWxkMVwiKX0+PC9JbWFnZT48QnV0dG9uIGNoaWxkcmVuPXthdXRoQXR0cmlidXRlc1tcInBpY3R1cmVcIl19IHsuLi5nZXRPdmVycmlkZVByb3BzKG92ZXJyaWRlcywgXCJjaGlsZDJcIil9PjwvQnV0dG9uPjxCdXR0b24gY2hpbGRyZW49e2F1dGhBdHRyaWJ1dGVzW1wiY3VzdG9tOmZhdm9yaXRlX2ljZWNyZWFtXCJdfSB7Li4uZ2V0T3ZlcnJpZGVQcm9wcyhvdmVycmlkZXMsIFwiY2hpbGQzXCIpfT48L0J1dHRvbj48L0ZsZXg+KTtcbn0iXX0= +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibW9kdWxlLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBLG9CQUFvQjtBQUNwQixPQUFPLEtBQUssS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUMvQixPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sU0FBUyxDQUFDO0FBQzNDLE9BQU8sRUFBRSxNQUFNLEVBQWUsSUFBSSxFQUFhLEtBQUssRUFBYyxNQUFNLHVCQUF1QixDQUFDO0FBbUJoRyxNQUFNLENBQUMsT0FBTyxVQUFVLE9BQU8sQ0FBQyxLQUFtQjs7SUFDL0MsTUFBTSxFQUFFLFNBQVMsS0FBYyxLQUFLLEVBQWQsSUFBSSxVQUFLLEtBQUssRUFBOUIsYUFBc0IsQ0FBUSxDQUFDO0lBQ3JDLE1BQU0sY0FBYyxHQUFHLE1BQUEsTUFBQSxPQUFPLEVBQUUsQ0FBQyxJQUFJLDBDQUFFLFVBQVUsbUNBQUksRUFBRSxDQUFDO0lBQ3hELE9BQU8sQ0FBQyxvQkFBQyxJQUFJLG9CQUFLLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxTQUFTLENBQUMsRUFBTSxJQUFJO1FBQUUsb0JBQUMsS0FBSyxrQkFBQyxHQUFHLEVBQUUsY0FBYyxDQUFDLFVBQVUsQ0FBQyxJQUFNLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsRUFBVTtRQUFBLG9CQUFDLE1BQU0sa0JBQUMsUUFBUSxFQUFFLGNBQWMsQ0FBQyxTQUFTLENBQUMsSUFBTSxnQkFBZ0IsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLEVBQVc7UUFBQSxvQkFBQyxNQUFNLGtCQUFDLFFBQVEsRUFBRSxjQUFjLENBQUMsMEJBQTBCLENBQUMsSUFBTSxnQkFBZ0IsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLEVBQVcsQ0FBTyxDQUFDLENBQUM7QUFDL1gsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlICovXG5pbXBvcnQgKiBhcyBSZWFjdCBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCB7IHVzZUF1dGggfSBmcm9tIFwiQGF3cy1hbXBsaWZ5L3VpLXJlYWN0L2ludGVybmFsXCI7XG5pbXBvcnQgeyBnZXRPdmVycmlkZVByb3BzIH0gZnJvbSBcIi4vdXRpbHNcIjtcbmltcG9ydCB7IEJ1dHRvbiwgQnV0dG9uUHJvcHMsIEZsZXgsIEZsZXhQcm9wcywgSW1hZ2UsIEltYWdlUHJvcHMgfSBmcm9tIFwiQGF3cy1hbXBsaWZ5L3VpLXJlYWN0XCI7XG5cbmV4cG9ydCB0eXBlIEVzY2FwZUhhdGNoUHJvcHMgPSB7XG4gIFtlbGVtZW50SGllcmFyY2h5OiBzdHJpbmddOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPjtcbn0gfCBudWxsO1xuXG5leHBvcnQgdHlwZSBWYXJpYW50VmFsdWVzID0geyBba2V5OiBzdHJpbmddOiBzdHJpbmcgfTtcbmV4cG9ydCB0eXBlIFZhcmlhbnQgPSB7XG4gIHZhcmlhbnRWYWx1ZXM6IFZhcmlhbnRWYWx1ZXM7XG4gIG92ZXJyaWRlczogRXNjYXBlSGF0Y2hQcm9wcztcbn07XG5leHBvcnQgZGVjbGFyZSB0eXBlIFByaW1pdGl2ZU92ZXJyaWRlUHJvcHM8VD4gPSBQYXJ0aWFsPFQ+ICYgUmVhY3QuRE9NQXR0cmlidXRlczxIVE1MRGl2RWxlbWVudD47ZXhwb3J0IGRlY2xhcmUgdHlwZSBQcm9maWxlT3ZlcnJpZGVzUHJvcHMgPSB7XG4gICAgUHJvZmlsZT86IFByaW1pdGl2ZU92ZXJyaWRlUHJvcHM8RmxleFByb3BzPjtcbiAgICBjaGlsZDE/OiBQcmltaXRpdmVPdmVycmlkZVByb3BzPEltYWdlUHJvcHM+O1xuICAgIGNoaWxkMj86IFByaW1pdGl2ZU92ZXJyaWRlUHJvcHM8QnV0dG9uUHJvcHM+O1xuICAgIGNoaWxkMz86IFByaW1pdGl2ZU92ZXJyaWRlUHJvcHM8QnV0dG9uUHJvcHM+O1xufSAmIEVzY2FwZUhhdGNoUHJvcHM7ZXhwb3J0IHR5cGUgUHJvZmlsZVByb3BzID0gUmVhY3QuUHJvcHNXaXRoQ2hpbGRyZW48UGFydGlhbDxGbGV4UHJvcHM+ICYge1xuICAgIG92ZXJyaWRlcz86IFByb2ZpbGVPdmVycmlkZXNQcm9wcyB8IHVuZGVmaW5lZCB8IG51bGw7XG59PjtcbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIFByb2ZpbGUocHJvcHM6IFByb2ZpbGVQcm9wcyk6IFJlYWN0LlJlYWN0RWxlbWVudCB7XG4gICAgY29uc3QgeyBvdmVycmlkZXMsIC4uLnJlc3QgfSA9IHByb3BzO1xuICAgIGNvbnN0IGF1dGhBdHRyaWJ1dGVzID0gdXNlQXV0aCgpLnVzZXI/LmF0dHJpYnV0ZXMgPz8ge307XG4gICAgcmV0dXJuICg8RmxleCB7Li4uZ2V0T3ZlcnJpZGVQcm9wcyhvdmVycmlkZXMsIFwiUHJvZmlsZVwiKX0gey4uLnJlc3R9PjxJbWFnZSBzcmM9e2F1dGhBdHRyaWJ1dGVzW1widXNlcm5hbWVcIl19IHsuLi5nZXRPdmVycmlkZVByb3BzKG92ZXJyaWRlcywgXCJjaGlsZDFcIil9PjwvSW1hZ2U+PEJ1dHRvbiBjaGlsZHJlbj17YXV0aEF0dHJpYnV0ZXNbXCJwaWN0dXJlXCJdfSB7Li4uZ2V0T3ZlcnJpZGVQcm9wcyhvdmVycmlkZXMsIFwiY2hpbGQyXCIpfT48L0J1dHRvbj48QnV0dG9uIGNoaWxkcmVuPXthdXRoQXR0cmlidXRlc1tcImN1c3RvbTpmYXZvcml0ZV9pY2VjcmVhbVwiXX0gey4uLmdldE92ZXJyaWRlUHJvcHMob3ZlcnJpZGVzLCBcImNoaWxkM1wiKX0+PC9CdXR0b24+PC9GbGV4Pik7XG59Il19 " `; exports[`amplify render tests user specific attributes should render user specific attributes 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { EscapeHatchProps, useAuth } from \\"@aws-amplify/ui-react/internal\\"; +import { useAuth } from \\"@aws-amplify/ui-react/internal\\"; import { getOverrideProps } from \\"./utils\\"; import { Button, @@ -10750,6 +11620,15 @@ import { ImageProps, } from \\"@aws-amplify/ui-react\\"; +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ProfileOverridesProps = { diff --git a/packages/codegen-ui-react/lib/__tests__/overrides/getOverrideProps.test.ts b/packages/codegen-ui-react/lib/__tests__/overrides/getOverrideProps.test.ts new file mode 100644 index 000000000..cf2030030 --- /dev/null +++ b/packages/codegen-ui-react/lib/__tests__/overrides/getOverrideProps.test.ts @@ -0,0 +1,59 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import { getOverrideProps } from '../../utils-file-functions'; + +describe('getOverrideProps', () => { + const overrides = { + View: { + width: '436px', + padding: '0px 0px 0px 0px', + backgroundColor: 'rgba(50.36245197057724,0,251.81250303983688,1)', + overflow: 'hidden', + position: 'relative', + height: '98px', + }, + 'View.Text[0]': { + fontSize: '12px', + color: 'red', + }, + }; + + it('returns the correct overrides when path matches', () => { + const result = getOverrideProps(overrides, 'View'); + expect(result).toEqual({ + width: '436px', + padding: '0px 0px 0px 0px', + backgroundColor: 'rgba(50.36245197057724,0,251.81250303983688,1)', + overflow: 'hidden', + position: 'relative', + height: '98px', + }); + }); + + it('returns the correct overrides when path matches complex', () => { + const result = getOverrideProps(overrides, 'View.Text[0]'); + expect(result).toEqual({ + fontSize: '12px', + color: 'red', + }); + }); + + it('returns an empty object when nothing matches', () => { + const result = getOverrideProps(overrides, 'Flex'); + expect(result).toEqual({}); + }); +}); diff --git a/packages/codegen-ui-react/lib/__tests__/overrides/getOverridesFromVariants.test.ts b/packages/codegen-ui-react/lib/__tests__/overrides/getOverridesFromVariants.test.ts new file mode 100644 index 000000000..661326cff --- /dev/null +++ b/packages/codegen-ui-react/lib/__tests__/overrides/getOverridesFromVariants.test.ts @@ -0,0 +1,133 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import { Variant, getOverridesFromVariants } from '../../utils-file-functions'; + +describe('getOverridesFromVariants', () => { + const variants: Variant[] = [ + { + variantValues: { + variant: 'primary', + }, + overrides: { + Button: { + fontSize: '12px', + }, + }, + }, + { + variantValues: { + variant: 'secondary', + }, + overrides: { + Button: { + fontSize: '40px', + }, + }, + }, + { + variantValues: { + variant: 'primary', + size: 'large', + }, + overrides: { + Button: { + width: '500', + }, + }, + }, + ]; + + it('should return overrides for primary variant, without optional', () => { + const selectedVariantValue = { variant: 'primary' }; + const expected = { + Button: { + fontSize: '12px', + }, + }; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); + + it('should return overrides for alternative', () => { + const selectedVariantValue = { variant: 'secondary' }; + const expected = { + Button: { + fontSize: '40px', + }, + }; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); + + it('should return overrides for multiple values, including optional', () => { + const selectedVariantValue = { variant: 'primary', size: 'large' }; + const expected = { + Button: { + width: '500', + }, + }; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); + + it('should return no overrides invalid combo', () => { + const selectedVariantValue = { variant: 'secondary', size: 'large' }; + const expected = {}; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); + + it('should return no overrides on unexpected variant parameter', () => { + const selectedVariantValue = { unexpected: 'yes' }; + const expected = {}; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); + + it('should match on expected variants even with additional props', () => { + const selectedVariantValue = { variant: 'primary', unexpected: 'yes' }; + const expected = { + Button: { + fontSize: '12px', + }, + }; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); + + it('should match on expected variants with optional even with additional props', () => { + const selectedVariantValue = { + variant: 'primary', + size: 'large', + unexpected: 'yes', + }; + const expected = { + Button: { + width: '500', + }, + }; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); + + it('should match on expected variants with undefined for optional', () => { + const selectedVariantValue = { + variant: 'primary', + size: undefined, + unexpected: 'yes', + }; + const expected = { + Button: { + fontSize: '12px', + }, + }; + expect(getOverridesFromVariants(variants, selectedVariantValue)).toEqual(expected); + }); +}); diff --git a/packages/codegen-ui-react/lib/__tests__/overrides/mergeVariantsAndOverrides.test.ts b/packages/codegen-ui-react/lib/__tests__/overrides/mergeVariantsAndOverrides.test.ts new file mode 100644 index 000000000..d17cf11d0 --- /dev/null +++ b/packages/codegen-ui-react/lib/__tests__/overrides/mergeVariantsAndOverrides.test.ts @@ -0,0 +1,124 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import { EscapeHatchProps, mergeVariantsAndOverrides } from '../../utils-file-functions'; + +describe('mergeVariantsAndOverrides', () => { + const expected: EscapeHatchProps = { + 'Flex.Button[0]': { + color: 'red', + size: 'large', + }, + 'Flex.CheckBox[1]': { + isEnabled: 'false', + size: 'large', + }, + }; + it('should return merged variants after applying overrides', () => { + const variants: EscapeHatchProps = { + 'Flex.Button[0]': { + color: 'red', + }, + 'Flex.CheckBox[1]': { + isEnabled: 'false', + size: 'small', + }, + }; + + const overrides: EscapeHatchProps = { + 'Flex.Button[0]': { + size: 'large', + }, + 'Flex.CheckBox[1]': { + size: 'large', + }, + }; + + expect(mergeVariantsAndOverrides(variants, overrides)).toEqual(expected); + }); + + it('should return merged variants when override includes new control', () => { + const variants: EscapeHatchProps = { + 'Flex.Button[0]': { + color: 'red', + size: 'large', + }, + }; + + const overrides: EscapeHatchProps = { + 'Flex.CheckBox[1]': { + isEnabled: 'false', + size: 'large', + }, + }; + + expect(mergeVariantsAndOverrides(variants, overrides)).toEqual(expected); + }); + + it('should return merged variants when all variants overridden', () => { + const variants: EscapeHatchProps = { + 'Flex.Button[0]': { + color: 'green', + size: 'small', + }, + 'Flex.CheckBox[1]': { + isEnabled: 'true', + size: 'small', + }, + }; + + const overrides: EscapeHatchProps = { + ...expected, + }; + + expect(mergeVariantsAndOverrides(variants, overrides)).toEqual(expected); + }); + + it('should return original variants when override is empty', () => { + const variants: EscapeHatchProps = { + ...expected, + }; + + const overrides: EscapeHatchProps = {}; + + expect(mergeVariantsAndOverrides(variants, overrides)).toEqual(expected); + }); + + it('should return original variants when override is null', () => { + const variants: EscapeHatchProps = { + ...expected, + }; + + // cast null as EscapeHatchProps for exhaustive test case + expect(mergeVariantsAndOverrides(variants, null as unknown as EscapeHatchProps)).toEqual(expected); + }); + + it('should return overrides when variant is null', () => { + const overrides: EscapeHatchProps = { + ...expected, + }; + + // cast null as EscapeHatchProps for exhaustive test case + expect(mergeVariantsAndOverrides(null as unknown as EscapeHatchProps, overrides)).toEqual(expected); + }); + + it('should return null when both variant & override are null', () => { + expect( + // cast null as EscapeHatchProps for exhaustive test case + mergeVariantsAndOverrides(null as unknown as EscapeHatchProps, null as unknown as EscapeHatchProps), + ).toEqual(null); + }); +}); diff --git a/packages/codegen-ui-react/lib/__tests__/utils/__snapshots__/render-util-functions.test.ts.snap b/packages/codegen-ui-react/lib/__tests__/utils/__snapshots__/render-util-functions.test.ts.snap index bed90e000..a22578d62 100644 --- a/packages/codegen-ui-react/lib/__tests__/utils/__snapshots__/render-util-functions.test.ts.snap +++ b/packages/codegen-ui-react/lib/__tests__/utils/__snapshots__/render-util-functions.test.ts.snap @@ -232,14 +232,14 @@ const checkValidation = (value, validation) => { hasError: !(value.length <= validation.numValues[0]), errorMessage: validation.validationMessage || - \`The value must be shorter than \${validation.numValues[0]}\`, + \`The value must be shorter than \${validation.numValues[0]} characters\`, }; case \\"GreaterThanChar\\": return { hasError: !(value.length > validation.numValues[0]), errorMessage: validation.validationMessage || - \`The value must be longer than \${validation.numValues[0]}\`, + \`The value must be longer than \${validation.numValues[0]} characters\`, }; case \\"LessThanNum\\": return { @@ -319,7 +319,7 @@ const checkValidation = (value, validation) => { switch (validation.type) { case \\"Email\\": const EMAIL_ADDRESS_REGEX = - /^[-!#$%&'*+\\\\/0-9=?A-Z^_a-z\`{|}~](\\\\.?[-!#$%&'*+\\\\/0-9=?A-Z^_a-z\`{|}~])*@[a-zA-Z0-9](-*\\\\.?[a-zA-Z0-9])*\\\\.[a-zA-Z](-?[a-zA-Z0-9])+$/; + /^[-!#$%&'*+/0-9=?A-Z^_a-z\`{|}~](.?[-!#$%&'*+/0-9=?A-Z^_a-z\`{|}~])*@[a-zA-Z0-9](-*.?[a-zA-Z0-9])*.[a-zA-Z](-?[a-zA-Z0-9])+$/; return { hasError: !EMAIL_ADDRESS_REGEX.test(value), errorMessage: @@ -451,7 +451,7 @@ export function formatDateTime(dateTimeStr, dateTimeFormat) { if (dateTimeStr === undefined || dateTimeStr === null) { return dateTimeStr; } - const dateTime = /^d+$/.test(dateTimeStr) + const dateTime = /^\\\\d+$/.test(dateTimeStr) ? new Date(Number.parseInt(dateTimeStr, 10)) : new Date(Date.parse(dateTimeStr)); if (dateTime.toString() === invalidDateStr) { @@ -477,7 +477,7 @@ export function formatter(value, formatterInput) { return value; } } -export const fetchByPath = (input, path = \\"\\", accumlator = []) => { +export const fetchByPath = (input, path, accumlator = []) => { const currentPath = path.split(\\".\\"); const head = currentPath.shift(); if (input && head && input[head] !== undefined) { diff --git a/packages/codegen-ui-react/lib/forms/react-form-renderer.ts b/packages/codegen-ui-react/lib/forms/react-form-renderer.ts index 02181759b..931843688 100644 --- a/packages/codegen-ui-react/lib/forms/react-form-renderer.ts +++ b/packages/codegen-ui-react/lib/forms/react-form-renderer.ts @@ -106,6 +106,7 @@ import { buildSelectedRecordsIdSet } from './form-renderer-helper/model-values'; import { AMPLIFY_JS_V6, COMPOSITE_PRIMARY_KEY_PROP_NAME } from '../utils/constants'; import { getFetchRelatedRecordsCallbacks, isGraphqlConfig } from '../utils/graphql'; import { getAmplifyJSVersionToRender } from '../helpers/amplify-js-versioning'; +import { overrideTypesString } from '../utils-file-functions'; type RenderComponentOnlyResponse = { compText: string; @@ -236,6 +237,8 @@ export abstract class ReactFormTemplateRenderer extends StudioTemplateRenderer< componentText += EOL; + componentText += overrideTypesString + EOL; + propsDeclaration.forEach((typeNode) => { const propsPrinted = printer.printNode(EmitHint.Unspecified, typeNode, file); componentText += propsPrinted; @@ -353,8 +356,6 @@ export abstract class ReactFormTemplateRenderer extends StudioTemplateRenderer< ]); const formPropType = getComponentPropName(formName); - this.importCollection.addMappedImport(ImportValue.ESCAPE_HATCH_PROPS); - let modelName = dataTypeName; // add model import for datastore type diff --git a/packages/codegen-ui-react/lib/imports/import-mapping.ts b/packages/codegen-ui-react/lib/imports/import-mapping.ts index aace3e37d..08d63259e 100644 --- a/packages/codegen-ui-react/lib/imports/import-mapping.ts +++ b/packages/codegen-ui-react/lib/imports/import-mapping.ts @@ -28,7 +28,6 @@ export enum ImportSource { export enum ImportValue { GET_OVERRIDE_PROPS = 'getOverrideProps', - ESCAPE_HATCH_PROPS = 'EscapeHatchProps', USE_AUTH = 'useAuth', GET_OVERRIDES_FROM_VARIANTS = 'getOverridesFromVariants', USE_BREAKPOINT_VALUE = 'useBreakpointValue', @@ -79,7 +78,6 @@ export const ImportMapping: Record = { [ImportValue.USE_DATA_STORE_UPDATE_ACTION]: ImportSource.UI_REACT_INTERNAL, [ImportValue.USE_DATA_STORE_DELETE_ACTION]: ImportSource.UI_REACT_INTERNAL, [ImportValue.USE_AUTH_SIGN_OUT_ACTION]: ImportSource.UI_REACT_INTERNAL, - [ImportValue.ESCAPE_HATCH_PROPS]: ImportSource.UI_REACT_INTERNAL, [ImportValue.USE_STATE_MUTATION_ACTION]: ImportSource.UTILS, [ImportValue.GET_OVERRIDE_PROPS]: ImportSource.UTILS, [ImportValue.MERGE_VARIANTS_OVERRIDES]: ImportSource.UTILS, diff --git a/packages/codegen-ui-react/lib/overrides/findChildOverrides.ts b/packages/codegen-ui-react/lib/overrides/findChildOverrides.ts deleted file mode 100644 index f2ba8fb7f..000000000 --- a/packages/codegen-ui-react/lib/overrides/findChildOverrides.ts +++ /dev/null @@ -1,242 +0,0 @@ -/* - Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"). - You may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -import ts, { factory } from 'typescript'; -import { EscapeHatchProps } from './types'; - -/** - * This method is used to parse through all of the overrides and - * only pass the relevant child overrides for a given component. - * @internal - * @param overrides escape hatch props - * @param elementHierarchy - * @returns overrides only for specified element - */ -export const findChildOverrides = ( - overrides: EscapeHatchProps | null | undefined, - elementHierarchy: string, -): EscapeHatchProps | null => { - if (!overrides) { - return null; - } - - const filteredOverrides = Object.entries(overrides).filter((m) => m[0].startsWith(elementHierarchy)); - - return Object.assign( - {}, - ...Array.from(filteredOverrides, ([k, v]) => ({ - [k.replace(elementHierarchy, '')]: v, - })), - ) as EscapeHatchProps; -}; - -export const buildFindChildOverrides = () => [ - factory.createVariableStatement( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('findChildOverrides'), - undefined, - undefined, - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('overrides'), - undefined, - factory.createUnionTypeNode([ - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - factory.createLiteralTypeNode(factory.createNull()), - factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword), - ]), - undefined, - ), - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('elementHierarchy'), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined, - ), - ], - factory.createUnionTypeNode([ - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - factory.createLiteralTypeNode(factory.createNull()), - ]), - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBlock( - [ - factory.createIfStatement( - factory.createPrefixUnaryExpression( - ts.SyntaxKind.ExclamationToken, - factory.createIdentifier('overrides'), - ), - factory.createBlock([factory.createReturnStatement(factory.createNull())], true), - undefined, - ), - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('filteredOverrides'), - undefined, - undefined, - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('entries'), - ), - undefined, - [factory.createIdentifier('overrides')], - ), - factory.createIdentifier('filter'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('m'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createElementAccessExpression( - factory.createIdentifier('m'), - factory.createNumericLiteral('0'), - ), - factory.createIdentifier('startsWith'), - ), - undefined, - [factory.createIdentifier('elementHierarchy')], - ), - ), - ], - ), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createReturnStatement( - factory.createAsExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('assign'), - ), - undefined, - [ - factory.createObjectLiteralExpression([], false), - factory.createSpreadElement( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Array'), - factory.createIdentifier('from'), - ), - undefined, - [ - factory.createIdentifier('filteredOverrides'), - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createArrayBindingPattern([ - factory.createBindingElement( - undefined, - undefined, - factory.createIdentifier('k'), - undefined, - ), - factory.createBindingElement( - undefined, - undefined, - factory.createIdentifier('v'), - undefined, - ), - ]), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createParenthesizedExpression( - factory.createObjectLiteralExpression( - [ - factory.createPropertyAssignment( - factory.createComputedPropertyName( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('k'), - factory.createIdentifier('replace'), - ), - undefined, - [ - factory.createIdentifier('elementHierarchy'), - factory.createStringLiteral(''), - ], - ), - ), - factory.createIdentifier('v'), - ), - ], - true, - ), - ), - ), - ], - ), - ), - ], - ), - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - ), - ), - ], - true, - ), - ), - ), - ], - ts.NodeFlags.Const, - ), - ), -]; diff --git a/packages/codegen-ui-react/lib/overrides/getOverrideProps.ts b/packages/codegen-ui-react/lib/overrides/getOverrideProps.ts deleted file mode 100644 index ad4ccc530..000000000 --- a/packages/codegen-ui-react/lib/overrides/getOverrideProps.ts +++ /dev/null @@ -1,248 +0,0 @@ -/* - Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"). - You may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -import ts, { factory } from 'typescript'; -import { EscapeHatchProps } from './types'; - -/** - * This helper method is used to get the overrides - * that will be applied to a component - * @internal - * @param overrides escape hatch props - * @param elementHierarchy - * @returns component overrides - */ -export const getOverrideProps = ( - overrides: EscapeHatchProps | null | undefined, - elementHierarchy: string, -): EscapeHatchProps | null => { - if (!overrides) { - return null; - } - - const componentOverrides = Object.entries(overrides) - .filter(([key]) => key === elementHierarchy) - .flatMap(([, value]) => Object.entries(value)) - .filter((m) => m?.[0]); - - return Object.fromEntries(componentOverrides) as unknown as EscapeHatchProps; -}; - -export const buildGetOverrideProps = () => [ - factory.createVariableStatement( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('getOverrideProps'), - undefined, - undefined, - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('overrides'), - undefined, - factory.createUnionTypeNode([ - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - factory.createLiteralTypeNode(factory.createNull()), - factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword), - ]), - undefined, - ), - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('elementHierarchy'), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined, - ), - ], - factory.createUnionTypeNode([ - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - factory.createLiteralTypeNode(factory.createNull()), - ]), - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBlock( - [ - factory.createIfStatement( - factory.createPrefixUnaryExpression( - ts.SyntaxKind.ExclamationToken, - factory.createIdentifier('overrides'), - ), - factory.createBlock([factory.createReturnStatement(factory.createNull())], true), - undefined, - ), - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('componentOverrides'), - undefined, - undefined, - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('entries'), - ), - undefined, - [factory.createIdentifier('overrides')], - ), - factory.createIdentifier('filter'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createArrayBindingPattern([ - factory.createBindingElement( - undefined, - undefined, - factory.createIdentifier('key'), - undefined, - ), - ]), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBinaryExpression( - factory.createIdentifier('key'), - factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken), - factory.createIdentifier('elementHierarchy'), - ), - ), - ], - ), - factory.createIdentifier('flatMap'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createArrayBindingPattern([ - factory.createOmittedExpression(), - factory.createBindingElement( - undefined, - undefined, - factory.createIdentifier('value'), - undefined, - ), - ]), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('entries'), - ), - undefined, - [factory.createIdentifier('value')], - ), - ), - ], - ), - factory.createIdentifier('filter'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('m'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createElementAccessChain( - factory.createIdentifier('m'), - factory.createToken(ts.SyntaxKind.QuestionDotToken), - factory.createNumericLiteral('0'), - ), - ), - ], - ), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createReturnStatement( - factory.createAsExpression( - factory.createAsExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('fromEntries'), - ), - undefined, - [factory.createIdentifier('componentOverrides')], - ), - factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword), - ), - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - ), - ), - ], - true, - ), - ), - ), - ], - ts.NodeFlags.Const, - ), - ), -]; diff --git a/packages/codegen-ui-react/lib/overrides/getOverridesFromVariants.ts b/packages/codegen-ui-react/lib/overrides/getOverridesFromVariants.ts deleted file mode 100644 index b2979f99f..000000000 --- a/packages/codegen-ui-react/lib/overrides/getOverridesFromVariants.ts +++ /dev/null @@ -1,496 +0,0 @@ -/* - Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"). - You may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -import ts, { factory } from 'typescript'; -import { Variant, VariantValues } from './types'; - -/** - * Given a list of style variants, select a given one based on input props - * @internal - * @param variants list of style variants to select from - * @param props variant values to select from the list, may include additional props, to tidy up usage upstream - */ -export function getOverridesFromVariants( - variants: Variant[], - props: { [key: string]: T }, -): { [key: string]: Variant } { - // Get unique keys from the provided variants - const variantValueKeys = [...new Set(variants.flatMap((variant) => Object.keys(variant.variantValues)))]; - - /* - Get variant value object from provided props, - dropping keys that aren't in variantValueKeys, or whose vals are falsey - */ - const variantValuesFromProps: VariantValues = Object.keys(props) - .filter((i) => variantValueKeys.includes(i) && props[i]) - .reduce((acc, key) => { - return { - ...acc, - [key]: props[key], - }; - }, {}); - - const matchedVariants = variants.filter(({ variantValues }) => { - return ( - Object.keys(variantValues).length === Object.keys(variantValuesFromProps).length && - Object.entries(variantValues).every(([key, value]) => variantValuesFromProps[key] === value) - ); - }); - - return matchedVariants.reduce((overrides, variant) => { - return { ...overrides, ...variant.overrides }; - }, {}); -} - -export const buildGetOverridesFromVariants = () => [ - factory.createFunctionDeclaration( - undefined, - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - undefined, - factory.createIdentifier('getOverridesFromVariants'), - [factory.createTypeParameterDeclaration(factory.createIdentifier('T'), undefined, undefined)], - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('variants'), - undefined, - factory.createArrayTypeNode(factory.createTypeReferenceNode(factory.createIdentifier('Variant'), undefined)), - undefined, - ), - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('props'), - undefined, - factory.createTypeLiteralNode([ - factory.createIndexSignature( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('key'), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined, - ), - ], - factory.createTypeReferenceNode(factory.createIdentifier('T'), undefined), - ), - ]), - undefined, - ), - ], - factory.createTypeLiteralNode([ - factory.createIndexSignature( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('key'), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined, - ), - ], - factory.createTypeReferenceNode(factory.createIdentifier('Variant'), undefined), - ), - ]), - factory.createBlock( - [ - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('variantValueKeys'), - undefined, - undefined, - factory.createArrayLiteralExpression( - [ - factory.createSpreadElement( - factory.createNewExpression(factory.createIdentifier('Set'), undefined, [ - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('variants'), - factory.createIdentifier('flatMap'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('variant'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('keys'), - ), - undefined, - [ - factory.createPropertyAccessExpression( - factory.createIdentifier('variant'), - factory.createIdentifier('variantValues'), - ), - ], - ), - ), - ], - ), - ]), - ), - ], - false, - ), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('variantValuesFromProps'), - undefined, - factory.createTypeReferenceNode(factory.createIdentifier('VariantValues'), undefined), - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('keys'), - ), - undefined, - [factory.createIdentifier('props')], - ), - factory.createIdentifier('filter'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('i'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBinaryExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('variantValueKeys'), - factory.createIdentifier('includes'), - ), - undefined, - [factory.createIdentifier('i')], - ), - factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), - factory.createElementAccessExpression( - factory.createIdentifier('props'), - factory.createIdentifier('i'), - ), - ), - ), - ], - ), - factory.createIdentifier('reduce'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('acc'), - undefined, - undefined, - undefined, - ), - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('key'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBlock( - [ - factory.createReturnStatement( - factory.createObjectLiteralExpression( - [ - factory.createSpreadAssignment(factory.createIdentifier('acc')), - factory.createPropertyAssignment( - factory.createComputedPropertyName(factory.createIdentifier('key')), - factory.createElementAccessExpression( - factory.createIdentifier('props'), - factory.createIdentifier('key'), - ), - ), - ], - true, - ), - ), - ], - true, - ), - ), - factory.createObjectLiteralExpression([], false), - ], - ), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('matchedVariants'), - undefined, - undefined, - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('variants'), - factory.createIdentifier('filter'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createObjectBindingPattern([ - factory.createBindingElement( - undefined, - undefined, - factory.createIdentifier('variantValues'), - undefined, - ), - ]), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBlock( - [ - factory.createReturnStatement( - factory.createParenthesizedExpression( - factory.createBinaryExpression( - factory.createBinaryExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('keys'), - ), - undefined, - [factory.createIdentifier('variantValues')], - ), - factory.createIdentifier('length'), - ), - factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken), - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('keys'), - ), - undefined, - [factory.createIdentifier('variantValuesFromProps')], - ), - factory.createIdentifier('length'), - ), - ), - factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('entries'), - ), - undefined, - [factory.createIdentifier('variantValues')], - ), - factory.createIdentifier('every'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createArrayBindingPattern([ - factory.createBindingElement( - undefined, - undefined, - factory.createIdentifier('key'), - undefined, - ), - factory.createBindingElement( - undefined, - undefined, - factory.createIdentifier('value'), - undefined, - ), - ]), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBinaryExpression( - factory.createElementAccessExpression( - factory.createIdentifier('variantValuesFromProps'), - factory.createIdentifier('key'), - ), - factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken), - factory.createIdentifier('value'), - ), - ), - ], - ), - ), - ), - ), - ], - true, - ), - ), - ], - ), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createReturnStatement( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('matchedVariants'), - factory.createIdentifier('reduce'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('overrides'), - undefined, - undefined, - undefined, - ), - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('variant'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBlock( - [ - factory.createReturnStatement( - factory.createObjectLiteralExpression( - [ - factory.createSpreadAssignment(factory.createIdentifier('overrides')), - factory.createSpreadAssignment( - factory.createPropertyAccessExpression( - factory.createIdentifier('variant'), - factory.createIdentifier('overrides'), - ), - ), - ], - false, - ), - ), - ], - true, - ), - ), - factory.createObjectLiteralExpression([], false), - ], - ), - ), - ], - true, - ), - ), -]; diff --git a/packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts b/packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts deleted file mode 100644 index 5a5b5fc01..000000000 --- a/packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts +++ /dev/null @@ -1,286 +0,0 @@ -/* - Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"). - You may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -import ts, { factory } from 'typescript'; -import { EscapeHatchProps } from './types'; - -/** - * This helper method is used to merge - * variants with overrides - * @internal - * @param variants - * @param overrides - * @returns merged variants with overrides - */ -export const mergeVariantsAndOverrides = ( - variants: EscapeHatchProps, - overrides: EscapeHatchProps, -): EscapeHatchProps => { - if (!variants && !overrides) { - return null; - } - if (!overrides) { - return variants; - } - if (!variants) { - return overrides; - } - const overrideKeys = new Set(Object.keys(overrides)); - const sharedKeys = Object.keys(variants).filter((variantKey) => overrideKeys.has(variantKey)); - const merged = Object.fromEntries( - sharedKeys.map((sharedKey) => [sharedKey, { ...variants[sharedKey], ...overrides[sharedKey] }]), - ); - return { - ...variants, - ...overrides, - ...merged, - }; -}; - -export const buildMergeVariantsAndOverrides = () => [ - factory.createVariableStatement( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('mergeVariantsAndOverrides'), - undefined, - undefined, - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('variants'), - undefined, - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - undefined, - ), - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('overrides'), - undefined, - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - undefined, - ), - ], - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createBlock( - [ - factory.createIfStatement( - factory.createBinaryExpression( - factory.createPrefixUnaryExpression( - ts.SyntaxKind.ExclamationToken, - factory.createIdentifier('variants'), - ), - factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), - factory.createPrefixUnaryExpression( - ts.SyntaxKind.ExclamationToken, - factory.createIdentifier('overrides'), - ), - ), - factory.createBlock([factory.createReturnStatement(factory.createNull())], true), - undefined, - ), - factory.createIfStatement( - factory.createPrefixUnaryExpression( - ts.SyntaxKind.ExclamationToken, - factory.createIdentifier('overrides'), - ), - factory.createBlock([factory.createReturnStatement(factory.createIdentifier('variants'))], true), - undefined, - ), - factory.createIfStatement( - factory.createPrefixUnaryExpression( - ts.SyntaxKind.ExclamationToken, - factory.createIdentifier('variants'), - ), - factory.createBlock([factory.createReturnStatement(factory.createIdentifier('overrides'))], true), - undefined, - ), - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('overrideKeys'), - undefined, - undefined, - factory.createNewExpression(factory.createIdentifier('Set'), undefined, [ - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('keys'), - ), - undefined, - [factory.createIdentifier('overrides')], - ), - ]), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('sharedKeys'), - undefined, - undefined, - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('keys'), - ), - undefined, - [factory.createIdentifier('variants')], - ), - factory.createIdentifier('filter'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('variantKey'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('overrideKeys'), - factory.createIdentifier('has'), - ), - undefined, - [factory.createIdentifier('variantKey')], - ), - ), - ], - ), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createVariableStatement( - undefined, - factory.createVariableDeclarationList( - [ - factory.createVariableDeclaration( - factory.createIdentifier('merged'), - undefined, - undefined, - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('Object'), - factory.createIdentifier('fromEntries'), - ), - undefined, - [ - factory.createCallExpression( - factory.createPropertyAccessExpression( - factory.createIdentifier('sharedKeys'), - factory.createIdentifier('map'), - ), - undefined, - [ - factory.createArrowFunction( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('sharedKey'), - undefined, - undefined, - undefined, - ), - ], - undefined, - factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - factory.createArrayLiteralExpression( - [ - factory.createIdentifier('sharedKey'), - factory.createObjectLiteralExpression( - [ - factory.createSpreadAssignment( - factory.createElementAccessExpression( - factory.createIdentifier('variants'), - factory.createIdentifier('sharedKey'), - ), - ), - factory.createSpreadAssignment( - factory.createElementAccessExpression( - factory.createIdentifier('overrides'), - factory.createIdentifier('sharedKey'), - ), - ), - ], - false, - ), - ], - false, - ), - ), - ], - ), - ], - ), - ), - ], - ts.NodeFlags.Const, - ), - ), - factory.createReturnStatement( - factory.createObjectLiteralExpression( - [ - factory.createSpreadAssignment(factory.createIdentifier('variants')), - factory.createSpreadAssignment(factory.createIdentifier('overrides')), - factory.createSpreadAssignment(factory.createIdentifier('merged')), - ], - true, - ), - ), - ], - true, - ), - ), - ), - ], - ts.NodeFlags.Const, - ), - ), -]; diff --git a/packages/codegen-ui-react/lib/overrides/types.ts b/packages/codegen-ui-react/lib/overrides/types.ts deleted file mode 100644 index ad22f5b98..000000000 --- a/packages/codegen-ui-react/lib/overrides/types.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"). - You may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -import { SyntaxKind, factory } from 'typescript'; - -export type EscapeHatchProps = { - [elementHierarchy: string]: Record; -} | null; - -export type VariantValues = { [key: string]: string }; -export type Variant = { - variantValues: VariantValues; - overrides: EscapeHatchProps; -}; - -export const buildEscapeHatchAndVariantTypes = () => [ - factory.createTypeAliasDeclaration( - undefined, - [factory.createToken(SyntaxKind.ExportKeyword)], - factory.createIdentifier('EscapeHatchProps'), - undefined, - factory.createUnionTypeNode([ - factory.createTypeLiteralNode([ - factory.createIndexSignature( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('elementHierarchy'), - undefined, - factory.createKeywordTypeNode(SyntaxKind.StringKeyword), - undefined, - ), - ], - factory.createTypeReferenceNode(factory.createIdentifier('Record'), [ - factory.createKeywordTypeNode(SyntaxKind.StringKeyword), - factory.createKeywordTypeNode(SyntaxKind.UnknownKeyword), - ]), - ), - ]), - factory.createLiteralTypeNode(factory.createNull()), - ]), - ), - factory.createTypeAliasDeclaration( - undefined, - [factory.createToken(SyntaxKind.ExportKeyword)], - factory.createIdentifier('VariantValues'), - undefined, - factory.createTypeLiteralNode([ - factory.createIndexSignature( - undefined, - undefined, - [ - factory.createParameterDeclaration( - undefined, - undefined, - undefined, - factory.createIdentifier('key'), - undefined, - factory.createKeywordTypeNode(SyntaxKind.StringKeyword), - undefined, - ), - ], - factory.createKeywordTypeNode(SyntaxKind.StringKeyword), - ), - ]), - ), - factory.createTypeAliasDeclaration( - undefined, - [factory.createToken(SyntaxKind.ExportKeyword)], - factory.createIdentifier('Variant'), - undefined, - factory.createTypeLiteralNode([ - factory.createPropertySignature( - undefined, - factory.createIdentifier('variantValues'), - undefined, - factory.createTypeReferenceNode(factory.createIdentifier('VariantValues'), undefined), - ), - factory.createPropertySignature( - undefined, - factory.createIdentifier('overrides'), - undefined, - factory.createTypeReferenceNode(factory.createIdentifier('EscapeHatchProps'), undefined), - ), - ]), - ), -]; diff --git a/packages/codegen-ui-react/lib/react-studio-template-renderer.ts b/packages/codegen-ui-react/lib/react-studio-template-renderer.ts index dd8ecf024..1e00a5c5b 100644 --- a/packages/codegen-ui-react/lib/react-studio-template-renderer.ts +++ b/packages/codegen-ui-react/lib/react-studio-template-renderer.ts @@ -125,6 +125,7 @@ import { addUseEffectWrapper } from './utils/generate-react-hooks'; import { ActionType, getGraphqlCallExpression, getGraphqlQueryForModel, isGraphqlConfig } from './utils/graphql'; import { AMPLIFY_JS_V5, AMPLIFY_JS_V6 } from './utils/constants'; import { getAmplifyJSVersionToRender } from './helpers/amplify-js-versioning'; +import { overrideTypesString } from './utils-file-functions'; export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer< string, @@ -245,6 +246,8 @@ export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer componentText += EOL; + componentText += overrideTypesString + EOL; + propsDeclarations.forEach((propsDeclaration) => { const propsPrinted = printer.printNode(EmitHint.Unspecified, propsDeclaration, file); componentText += propsPrinted; @@ -420,7 +423,6 @@ export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer const componentPropType = getComponentPropName(component.name); const propsTypeParameter = PrimitiveTypeParameter[Primitive[component.componentType as Primitive]]; - this.importCollection.addMappedImport(ImportValue.ESCAPE_HATCH_PROPS); const overridesProps = factory.createTypeAliasDeclaration( undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword), factory.createModifier(ts.SyntaxKind.DeclareKeyword)], diff --git a/packages/codegen-ui-react/lib/react-utils-studio-template-renderer.ts b/packages/codegen-ui-react/lib/react-utils-studio-template-renderer.ts index e7db29c8c..e9c8b1651 100644 --- a/packages/codegen-ui-react/lib/react-utils-studio-template-renderer.ts +++ b/packages/codegen-ui-react/lib/react-utils-studio-template-renderer.ts @@ -14,29 +14,26 @@ limitations under the License. */ import { EOL } from 'os'; -import ts, { EmitHint } from 'typescript'; +import { EmitHint } from 'typescript'; import { StudioTemplateRenderer } from '@aws-amplify/codegen-ui'; import { ReactRenderConfig, scriptKindToFileExtension } from './react-render-config'; import { ImportCollection, ImportValue } from './imports'; import { ReactOutputManager } from './react-output-manager'; import { transpile, buildPrinter, defaultRenderConfig } from './react-studio-template-renderer-helper'; -import { generateValidationFunction } from './utils/forms/validation'; -import { getFetchByPathNodeFunction } from './utils/json-path-fetch'; -import { generateFormatUtil } from './utils/string-formatter'; -import { buildStorageManagerProcessFileVariableStatement } from './utils/forms/storage-field-component'; import { constantsString, amplifySymbolString, useNavigateActionString, useStateMutationActionString, + getOverridePropsString, + getOverridesFromVariantsString, + mergeVariantsAndOverridesString, + formatterString, + fetchByPathString, + processFileString, + validationString, + findChildOverridesString, } from './utils-file-functions'; -import { - buildEscapeHatchAndVariantTypes, - buildFindChildOverrides, - buildGetOverrideProps, - buildGetOverridesFromVariants, - buildMergeVariantsAndOverrides, -} from './overrides'; export type UtilTemplateType = 'validation' | 'formatter' | 'fetchByPath' | 'processFile'; @@ -73,37 +70,35 @@ export class ReactUtilsStudioTemplateRenderer extends StudioTemplateRenderer< renderComponentInternal() { const { printer, file } = buildPrinter(this.fileName, this.renderConfig); - const utilsStatements: (ts.VariableStatement | ts.TypeAliasDeclaration | ts.FunctionDeclaration)[] = [ - ...buildEscapeHatchAndVariantTypes(), - ...buildFindChildOverrides(), - ...buildGetOverrideProps(), - ...buildGetOverridesFromVariants(), - ...buildMergeVariantsAndOverrides(), - ]; + this.importCollection.addMappedImport(ImportValue.HUB); + const parsedUtils: string[] = [ constantsString, amplifySymbolString, useStateMutationActionString, useNavigateActionString, + findChildOverridesString, + getOverridePropsString, + getOverridesFromVariantsString, + mergeVariantsAndOverridesString, ]; - this.importCollection.addMappedImport(ImportValue.HUB); const utilsSet = new Set(this.utils); if (utilsSet.has('validation')) { - utilsStatements.push(...generateValidationFunction()); + parsedUtils.push(validationString); } if (utilsSet.has('formatter')) { - utilsStatements.push(...generateFormatUtil()); + parsedUtils.push(formatterString); } if (utilsSet.has('fetchByPath')) { - utilsStatements.push(getFetchByPathNodeFunction()); + parsedUtils.push(fetchByPathString); } if (utilsSet.has('processFile')) { - utilsStatements.push(buildStorageManagerProcessFileVariableStatement()); + parsedUtils.push(processFileString); } let componentText = `/* eslint-disable */${EOL}`; @@ -116,13 +111,6 @@ export class ReactUtilsStudioTemplateRenderer extends StudioTemplateRenderer< componentText += parsedUtils.join(EOL) + EOL; - utilsStatements.forEach((util) => { - const result = printer.printNode(EmitHint.Unspecified, util, file); - componentText += result + EOL; - }); - - componentText += EOL; - const { componentText: transpliedText } = transpile(componentText, this.renderConfig); return { diff --git a/packages/codegen-ui-react/lib/utils-file-functions/index.ts b/packages/codegen-ui-react/lib/utils-file-functions/index.ts index 685890a4f..33e6445d4 100644 --- a/packages/codegen-ui-react/lib/utils-file-functions/index.ts +++ b/packages/codegen-ui-react/lib/utils-file-functions/index.ts @@ -13,7 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ +export * from './overrides'; export * from './hooks/constants'; export * from './amplify-symbol'; export * from './hooks/useNavigateAction'; export * from './hooks/useStateMutationAction'; +export * from './validation'; +export * from './json-path-fetch'; +export * from './storage-manager'; +export * from './string-formatter'; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/json-path-fetch.ts b/packages/codegen-ui-react/lib/utils-file-functions/json-path-fetch.ts new file mode 100644 index 000000000..f27a5bbb6 --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/json-path-fetch.ts @@ -0,0 +1,52 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +/** + * does not support array types within objects as it's currently not supported + * + * ref: https://stackoverflow.com/questions/45942118/lodash-return-array-of-values-if-the-path-is-valid + * + * @param input object input + * @param path dot notation path for the provided input + * @param accumlator array + * @returns returns value at the end of object + */ +export const fetchByPath = >(input: T, path: string, accumlator: any[] = []) => { + const currentPath = path.split('.'); + const head = currentPath.shift(); + if (input && head && input[head] !== undefined) { + if (!currentPath.length) { + accumlator.push(input[head]); + } else { + fetchByPath(input[head], currentPath.join('.'), accumlator); + } + } + return accumlator[0]; +}; + +export const fetchByPathString = `export const fetchByPath = +>(input: T, path: string, accumlator: any[] = []) => { + const currentPath = path.split('.'); + const head = currentPath.shift(); + if (input && head && input[head] !== undefined) { + if (!currentPath.length) { + accumlator.push(input[head]); + } else { + fetchByPath(input[head], currentPath.join('.'), accumlator); + } + } + return accumlator[0]; +};`; diff --git a/packages/codegen-ui-react/lib/overrides/__tests__/getOverrideProps.test.tsx b/packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/getOverrideProps.test.tsx similarity index 100% rename from packages/codegen-ui-react/lib/overrides/__tests__/getOverrideProps.test.tsx rename to packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/getOverrideProps.test.tsx diff --git a/packages/codegen-ui-react/lib/overrides/__tests__/getOverridesFromVariants.test.tsx b/packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/getOverridesFromVariants.test.tsx similarity index 98% rename from packages/codegen-ui-react/lib/overrides/__tests__/getOverridesFromVariants.test.tsx rename to packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/getOverridesFromVariants.test.tsx index 906aa1948..5d8a01d8c 100644 --- a/packages/codegen-ui-react/lib/overrides/__tests__/getOverridesFromVariants.test.tsx +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/getOverridesFromVariants.test.tsx @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import type { Variant } from '../types'; +import type { Variant } from '../override-types'; import { getOverridesFromVariants } from '../getOverridesFromVariants'; describe('getOverridesFromVariants', () => { diff --git a/packages/codegen-ui-react/lib/overrides/__tests__/mergeVariantsAndOverrides.test.tsx b/packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/mergeVariantsAndOverrides.test.tsx similarity index 98% rename from packages/codegen-ui-react/lib/overrides/__tests__/mergeVariantsAndOverrides.test.tsx rename to packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/mergeVariantsAndOverrides.test.tsx index a5cb6b625..2b956b510 100644 --- a/packages/codegen-ui-react/lib/overrides/__tests__/mergeVariantsAndOverrides.test.tsx +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/__tests__/mergeVariantsAndOverrides.test.tsx @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import type { EscapeHatchProps } from '../types'; +import type { EscapeHatchProps } from '../override-types'; import { mergeVariantsAndOverrides } from '../mergeVariantsAndOverrides'; describe('mergeVariantsAndOverrides', () => { diff --git a/packages/codegen-ui-react/lib/utils-file-functions/overrides/findChildOverrides.ts b/packages/codegen-ui-react/lib/utils-file-functions/overrides/findChildOverrides.ts new file mode 100644 index 000000000..44a0c8a57 --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/findChildOverrides.ts @@ -0,0 +1,63 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import { EscapeHatchProps } from './override-types'; + +/** + * This method is used to parse through all of the overrides and + * only pass the relevant child overrides for a given component. + * @internal + * @param overrides escape hatch props + * @param elementHierarchy + * @returns overrides only for specified element + */ +export const findChildOverrides = ( + overrides: EscapeHatchProps | null | undefined, + elementHierarchy: string, +): EscapeHatchProps | null => { + if (!overrides) { + return null; + } + + const filteredOverrides = Object.entries(overrides).filter((m) => m[0].startsWith(elementHierarchy)); + + return Object.assign( + {}, + ...Array.from(filteredOverrides, ([k, v]) => ({ + [k.replace(elementHierarchy, '')]: v, + })), + ) as EscapeHatchProps; +}; + +export const findChildOverridesString = `export const findChildOverrides = ( + overrides: EscapeHatchProps | null | undefined, + elementHierarchy: string +): EscapeHatchProps | null => { + if (!overrides) { + return null; + } + + const filteredOverrides = Object.entries(overrides).filter((m) => + m[0].startsWith(elementHierarchy) + ); + + return Object.assign( + {}, + ...Array.from(filteredOverrides, ([k, v]) => ({ + [k.replace(elementHierarchy, '')]: v, + })) + ) as EscapeHatchProps; +};`; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverrideProps.ts b/packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverrideProps.ts new file mode 100644 index 000000000..85bcfceef --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverrideProps.ts @@ -0,0 +1,47 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +import { EscapeHatchProps } from './override-types'; + +export const getOverrideProps = ( + overrides: EscapeHatchProps | null | undefined, + elementHierarchy: string, +): EscapeHatchProps | null => { + if (!overrides) { + return null; + } + + const componentOverrides = Object.entries(overrides) + .filter(([key]) => key === elementHierarchy) + .flatMap(([, value]) => Object.entries(value)) + .filter((m) => m?.[0]); + + return Object.fromEntries(componentOverrides) as unknown as EscapeHatchProps; +}; +export const getOverridePropsString = `export const getOverrideProps = ( + overrides: EscapeHatchProps | null | undefined, + elementHierarchy: string +): EscapeHatchProps | null => { + if (!overrides) { + return null; + } + + const componentOverrides = Object.entries(overrides) + .filter(([key]) => key === elementHierarchy) + .flatMap(([, value]) => Object.entries(value)) + .filter((m) => m?.[0]); + + return Object.fromEntries(componentOverrides) as unknown as EscapeHatchProps; +};`; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverridesFromVariants.ts b/packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverridesFromVariants.ts new file mode 100644 index 000000000..bd1eacf95 --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/getOverridesFromVariants.ts @@ -0,0 +1,74 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +import { Variant, VariantValues } from './override-types'; + +export function getOverridesFromVariants( + variants: Variant[], + props: { [key: string]: T }, +): { [key: string]: Variant } { + // Get unique keys from the provided variants + const variantValueKeys = [...new Set(variants.flatMap((variant) => Object.keys(variant.variantValues)))]; + + const variantValuesFromProps: VariantValues = Object.keys(props) + .filter((i) => variantValueKeys.includes(i) && props[i]) + .reduce((acc, key) => { + return { + ...acc, + [key]: props[key], + }; + }, {}); + + const matchedVariants = variants.filter(({ variantValues }) => { + return ( + Object.keys(variantValues).length === Object.keys(variantValuesFromProps).length && + Object.entries(variantValues).every(([key, value]) => variantValuesFromProps[key] === value) + ); + }); + + return matchedVariants.reduce((overrides, variant) => { + return { ...overrides, ...variant.overrides }; + }, {}); +} +export const getOverridesFromVariantsString = `export function getOverridesFromVariants( + variants: Variant[], + props: { [key: string]: T } +): { [key: string]: Variant } { + const variantValueKeys = [ + ...new Set( + variants.flatMap((variant) => Object.keys(variant.variantValues)) + ), + ]; + const variantValuesFromProps: VariantValues = Object.keys(props) + .filter((i) => variantValueKeys.includes(i) && props[i]) + .reduce((acc, key) => { + return { + ...acc, + [key]: props[key], + }; + }, {}); + const matchedVariants = variants.filter(({ variantValues }) => { + return ( + Object.keys(variantValues).length === + Object.keys(variantValuesFromProps).length && + Object.entries(variantValues).every( + ([key, value]) => variantValuesFromProps[key] === value + ) + ); + }); + return matchedVariants.reduce((overrides, variant) => { + return { ...overrides, ...variant.overrides }; + }, {}); +}`; diff --git a/packages/codegen-ui-react/lib/overrides/index.ts b/packages/codegen-ui-react/lib/utils-file-functions/overrides/index.ts similarity index 56% rename from packages/codegen-ui-react/lib/overrides/index.ts rename to packages/codegen-ui-react/lib/utils-file-functions/overrides/index.ts index c2af9e09e..0309fd20d 100644 --- a/packages/codegen-ui-react/lib/overrides/index.ts +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/index.ts @@ -13,9 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -export type { EscapeHatchProps, Variant } from './types'; -export { buildEscapeHatchAndVariantTypes } from './types'; -export { findChildOverrides, buildFindChildOverrides } from './findChildOverrides'; -export { getOverridesFromVariants, buildGetOverridesFromVariants } from './getOverridesFromVariants'; -export { getOverrideProps, buildGetOverrideProps } from './getOverrideProps'; -export { mergeVariantsAndOverrides, buildMergeVariantsAndOverrides } from './mergeVariantsAndOverrides'; +export * from './findChildOverrides'; +export * from './getOverrideProps'; +export * from './getOverridesFromVariants'; +export * from './mergeVariantsAndOverrides'; +export * from './override-types'; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/overrides/mergeVariantsAndOverrides.ts b/packages/codegen-ui-react/lib/utils-file-functions/overrides/mergeVariantsAndOverrides.ts new file mode 100644 index 000000000..7fb0bc05c --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/mergeVariantsAndOverrides.ts @@ -0,0 +1,79 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import { EscapeHatchProps } from './override-types'; + +/** + * This helper method is used to merge + * variants with overrides + * @internal + * @param variants + * @param overrides + * @returns merged variants with overrides + */ +export const mergeVariantsAndOverrides = ( + variants: EscapeHatchProps, + overrides: EscapeHatchProps, +): EscapeHatchProps => { + if (!variants && !overrides) { + return null; + } + if (!overrides) { + return variants; + } + if (!variants) { + return overrides; + } + const overrideKeys = new Set(Object.keys(overrides)); + const sharedKeys = Object.keys(variants).filter((variantKey) => overrideKeys.has(variantKey)); + const merged = Object.fromEntries( + sharedKeys.map((sharedKey) => [sharedKey, { ...variants[sharedKey], ...overrides[sharedKey] }]), + ); + return { + ...variants, + ...overrides, + ...merged, + }; +}; +export const mergeVariantsAndOverridesString = `export const mergeVariantsAndOverrides = ( + variants: EscapeHatchProps, + overrides: EscapeHatchProps +): EscapeHatchProps => { + if (!variants && !overrides) { + return null; + } + if (!overrides) { + return variants; + } + if (!variants) { + return overrides; + } + const overrideKeys = new Set(Object.keys(overrides)); + const sharedKeys = Object.keys(variants).filter((variantKey) => + overrideKeys.has(variantKey) + ); + const merged = Object.fromEntries( + sharedKeys.map((sharedKey) => [ + sharedKey, + { ...variants[sharedKey], ...overrides[sharedKey] }, + ]) + ); + return { + ...variants, + ...overrides, + ...merged, + }; +};`; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/overrides/override-types.ts b/packages/codegen-ui-react/lib/utils-file-functions/overrides/override-types.ts new file mode 100644 index 000000000..73bc1cb2c --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/overrides/override-types.ts @@ -0,0 +1,35 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +}; + +export const overrideTypesString = `export type EscapeHatchProps = { + [elementHierarchy: string]: Record; +} | null; + +export type VariantValues = { [key: string]: string }; +export type Variant = { + variantValues: VariantValues; + overrides: EscapeHatchProps; +};`; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/storage-manager.ts b/packages/codegen-ui-react/lib/utils-file-functions/storage-manager.ts new file mode 100644 index 000000000..b17b91b38 --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/storage-manager.ts @@ -0,0 +1,42 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import { StorageManagerProps } from '@aws-amplify/ui-react-storage'; +import { STORAGE_FILE_ALGO_TYPE } from '../utils/constants'; + +export const processFile = async ({ file }: Parameters>[0]) => { + const fileExtension = file.name.split('.').pop(); + return file + .arrayBuffer() + .then((filebuffer) => window.crypto.subtle.digest(STORAGE_FILE_ALGO_TYPE, filebuffer)) + .then((hashBuffer) => { + const hashArray = Array.from(new Uint8Array(hashBuffer)); + const hashHex = hashArray.map((a) => a.toString(16).padStart(2, '0')).join(''); + return { file, key: `${hashHex}.${fileExtension}` }; + }); +}; + +export const processFileString = `export const processFile = async ({ file }) => { + const fileExtension = file.name.split('.').pop(); + return file + .arrayBuffer() + .then((filebuffer) => window.crypto.subtle.digest("SHA-1", filebuffer)) + .then((hashBuffer) => { + const hashArray = Array.from(new Uint8Array(hashBuffer)); + const hashHex = hashArray.map((a) => a.toString(16).padStart(2, '0')).join(''); + return { file, key: \`\${hashHex}.\${fileExtension}\` }; + }); +};`; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/string-formatter.ts b/packages/codegen-ui-react/lib/utils-file-functions/string-formatter.ts new file mode 100644 index 000000000..ad626d9eb --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/string-formatter.ts @@ -0,0 +1,118 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +export const formatterString = ` +const monthToShortMon = { + "1": "Jan", + "2": "Feb", + "3": "Mar", + "4": "Apr", + "5": "May", + "6": "Jun", + "7": "Jul", + "8": "Aug", + "9": "Sep", + "10": "Oct", + "11": "Nov", + "12": "Dec", +}; +const invalidDateStr = "Invalid Date"; +export function formatDate(date, dateFormat) { + if (date === undefined || date === null) { + return date; + } + const validDate = new Date(Date.parse(date)); + if (validDate.toString() === invalidDateStr) { + return date; + } + const splitDate = date.split(/-|\\+|Z/); + const year = splitDate[0]; + const month = splitDate[1]; + const day = splitDate[2]; + const truncatedMonth = month.replace(/^0+/, ""); + switch (dateFormat) { + case "locale": + return validDate.toLocaleDateString(); + case "YYYY.MM.DD": + return \`\${year}.\${month}.\${day}\`; + case "DD.MM.YYYY": + return \`\${day}.\${month}.\${year}\`; + case "MM/DD/YYYY": + return \`\${month}/\${day}/\${year}\`; + case "Mmm DD, YYYY": + return \`\${monthToShortMon[truncatedMonth]} \${day}, \${year}\`; + default: + return date; + } +} +export function formatTime(time, timeFormat) { + if (time === undefined || time === null) { + return time; + } + const splitTime = time.split(/:|Z/); + if (splitTime.length < 3) { + return time; + } + const validTime = new Date(); + validTime.setHours(Number.parseInt(splitTime[0], 10)); + validTime.setMinutes(Number.parseInt(splitTime[1], 10)); + const splitSeconds = splitTime[2].split("."); + validTime.setSeconds(Number.parseInt(splitSeconds[0], 10), Number.parseInt(splitSeconds[1], 10)); + if (validTime.toString() === invalidDateStr) { + return time; + } + + switch (timeFormat) { + case "locale": + return validTime.toLocaleTimeString(); + case "hours24": + return validTime.toLocaleTimeString("en-gb"); + case "hours12": + return validTime.toLocaleTimeString("en-us"); + default: + return time; + } +} +export function formatDateTime(dateTimeStr, dateTimeFormat) { + if (dateTimeStr === undefined || dateTimeStr === null) { + return dateTimeStr; + } + const dateTime = /^\\d+$/.test(dateTimeStr) + ? new Date(Number.parseInt(dateTimeStr, 10)) + : new Date(Date.parse(dateTimeStr)); + if (dateTime.toString() === invalidDateStr) { + return dateTimeStr; + } + if (dateTimeFormat === "locale") { + return dateTime.toLocaleString(); + } + const dateAndTime = dateTime.toISOString().split("T"); + const date = formatDate(dateAndTime[0], dateTimeFormat.dateFormat); + const time = formatTime(dateAndTime[1], dateTimeFormat.timeFormat); + return \`\${date} - \${time}\`; +} +export function formatter(value, formatterInput) { + switch (formatterInput.type) { + case "DateFormat": + return formatDate(value, formatterInput.format); + case "DateTimeFormat": + return formatDateTime(value, formatterInput.format); + case "TimeFormat": + return formatTime(value, formatterInput.format); + default: + return value; + } +}`; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/utils.ts b/packages/codegen-ui-react/lib/utils-file-functions/utils.ts new file mode 100644 index 000000000..0b0d11116 --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/utils.ts @@ -0,0 +1,46 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +// Error message handling source: +// https://kentcdodds.com/blog/get-a-catch-block-error-message-with-typescript +type ErrorWithMessage = { + message: string; +}; + +export const isErrorWithMessage = (error: unknown): error is ErrorWithMessage => { + return ( + typeof error === 'object' && + error !== null && + 'message' in error && + typeof (error as Record).message === 'string' + ); +}; + +export const toErrorWithMessage = (maybeError: unknown): ErrorWithMessage => { + if (isErrorWithMessage(maybeError)) return maybeError; + + try { + return new Error(JSON.stringify(maybeError)); + } catch { + // fallback in case there's an error stringifying the maybeError + // like with circular references for example. + return new Error(String(maybeError)); + } +}; + +export const getErrorMessage = (error: unknown): string => { + return toErrorWithMessage(error).message; +}; diff --git a/packages/codegen-ui-react/lib/utils-file-functions/validation.ts b/packages/codegen-ui-react/lib/utils-file-functions/validation.ts new file mode 100644 index 000000000..22dee6f64 --- /dev/null +++ b/packages/codegen-ui-react/lib/utils-file-functions/validation.ts @@ -0,0 +1,309 @@ +/* eslint-disable */ + +type ValidationResponse = { hasError: boolean; errorMessage?: string }; +type FieldValidationConfiguration = { + type: string; + strValues?: string[]; + numValues?: number[]; + validationMessage?: string; +}; + +export const validateField = (value: any, validations: FieldValidationConfiguration[]): ValidationResponse => { + for (const validation of validations) { + if (value === undefined || value === '' || value === null) { + if (validation.type === 'Required') { + return { + hasError: true, + errorMessage: validation.validationMessage || 'The value is required', + }; + } else { + return { + hasError: false, + }; + } + } + + const validationResult = checkValidation(value, validation); + + if (validationResult?.hasError) { + return validationResult; + } + } + return { hasError: false }; +}; + +export const parseDateValidator = (dateValidator: string) => { + const isTimestamp = `${parseInt(dateValidator)}`.length === dateValidator.length; + return isTimestamp ? parseInt(dateValidator) : dateValidator; +}; + +const checkValidation = (value: any, validation: FieldValidationConfiguration) => { + if (validation.numValues?.length) { + switch (validation.type) { + case 'LessThanChar': + return { + hasError: !(value.length <= validation.numValues[0]), + errorMessage: + validation.validationMessage || `The value must be shorter than ${validation.numValues[0]} characters`, + }; + case 'GreaterThanChar': + return { + hasError: !(value.length > validation.numValues[0]), + errorMessage: + validation.validationMessage || `The value must be longer than ${validation.numValues[0]} characters`, + }; + case 'LessThanNum': + return { + hasError: !(value < validation.numValues[0]), + errorMessage: validation.validationMessage || `The value must be less than ${validation.numValues[0]}`, + }; + case 'GreaterThanNum': + return { + hasError: !(value > validation.numValues[0]), + errorMessage: validation.validationMessage || `The value must be greater than ${validation.numValues[0]}`, + }; + case 'EqualTo': + return { + hasError: !validation.numValues.some((el) => el === value), + errorMessage: + validation.validationMessage || `The value must be equal to ${validation.numValues.join(' or ')}`, + }; + default: + } + } else if (validation.strValues?.length) { + switch (validation.type) { + case 'StartWith': + return { + hasError: !validation.strValues.some((el: any) => value.startsWith(el)), + errorMessage: validation.validationMessage || `The value must start with ${validation.strValues.join(', ')}`, + }; + case 'EndWith': + return { + hasError: !validation.strValues.some((el: any) => value.endsWith(el)), + errorMessage: validation.validationMessage || `The value must end with ${validation.strValues.join(', ')}`, + }; + case 'Contains': + return { + hasError: !validation.strValues.some((el: any) => value.includes(el)), + errorMessage: validation.validationMessage || `The value must contain ${validation.strValues.join(', ')}`, + }; + case 'NotContains': + return { + hasError: !validation.strValues.every((el: any) => !value.includes(el)), + errorMessage: validation.validationMessage || `The value must not contain ${validation.strValues.join(', ')}`, + }; + case 'BeAfter': + return { + hasError: !(new Date(value) > new Date(parseDateValidator(validation.strValues[0]))), + errorMessage: validation.validationMessage || `The value must be after ${validation.strValues[0]}`, + }; + case 'BeBefore': + return { + hasError: !(new Date(value) < new Date(parseDateValidator(validation.strValues[0]))), + errorMessage: validation.validationMessage || `The value must be before ${validation.strValues[0]}`, + }; + } + } + switch (validation.type) { + case 'Email': + const EMAIL_ADDRESS_REGEX = + /^[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/; + return { + hasError: !EMAIL_ADDRESS_REGEX.test(value), + errorMessage: validation.validationMessage || 'The value must be a valid email address', + }; + case 'JSON': + let isInvalidJSON = false; + try { + JSON.parse(value); + } catch (e) { + isInvalidJSON = true; + } + return { + hasError: isInvalidJSON, + errorMessage: validation.validationMessage || 'The value must be in a correct JSON format', + }; + case 'IpAddress': + const IPV_4 = /^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/; + const IPV_6 = + /^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(?::[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(?::[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(?::[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(?::[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$/; + return { + hasError: !(IPV_4.test(value) || IPV_6.test(value)), + errorMessage: validation.validationMessage || 'The value must be an IPv4 or IPv6 address', + }; + case 'URL': + let isInvalidUrl = false; + try { + new URL(value); + } catch (e) { + isInvalidUrl = true; + } + return { + hasError: isInvalidUrl, + errorMessage: + validation.validationMessage || + 'The value must be a valid URL that begins with a schema (i.e. http:// or mailto:)', + }; + case 'Phone': + const PHONE = /^\+?\d[\d\s-]+$/; + return { + hasError: !PHONE.test(value), + errorMessage: validation.validationMessage || 'The value must be a valid phone number', + }; + default: + } +}; + +export const validationString = `type ValidationResponse = { hasError: boolean; errorMessage?: string }; +type FieldValidationConfiguration = { + type: string; + strValues?: string[]; + numValues?: number[]; + validationMessage?: string; +}; + +export const validateField = (value: any, validations: FieldValidationConfiguration[]): ValidationResponse => { + for (const validation of validations) { + if (value === undefined || value === '' || value === null) { + if (validation.type === 'Required') { + return { + hasError: true, + errorMessage: validation.validationMessage || 'The value is required', + }; + } else { + return { + hasError: false, + }; + } + } + + const validationResult = checkValidation(value, validation); + + if (validationResult?.hasError) { + return validationResult; + } + } + return { hasError: false }; +}; + +export const parseDateValidator = (dateValidator: string) => { + const isTimestamp = \`\${parseInt(dateValidator)}\`.length === dateValidator.length; + return isTimestamp ? parseInt(dateValidator) : dateValidator; +}; + +const checkValidation = (value: any, validation: FieldValidationConfiguration) => { + if (validation.numValues?.length) { + switch (validation.type) { + case 'LessThanChar': + return { + hasError: !(value.length <= validation.numValues[0]), + errorMessage: + validation.validationMessage || \`The value must be shorter than \${validation.numValues[0]} characters\`, + }; + case 'GreaterThanChar': + return { + hasError: !(value.length > validation.numValues[0]), + errorMessage: + validation.validationMessage || \`The value must be longer than \${validation.numValues[0]} characters\`, + }; + case 'LessThanNum': + return { + hasError: !(value < validation.numValues[0]), + errorMessage: validation.validationMessage || \`The value must be less than \${validation.numValues[0]}\`, + }; + case 'GreaterThanNum': + return { + hasError: !(value > validation.numValues[0]), + errorMessage: validation.validationMessage || \`The value must be greater than \${validation.numValues[0]}\`, + }; + case 'EqualTo': + return { + hasError: !validation.numValues.some((el) => el === value), + errorMessage: + validation.validationMessage || \`The value must be equal to \${validation.numValues.join(' or ')}\`, + }; + default: + } + } else if (validation.strValues?.length) { + switch (validation.type) { + case 'StartWith': + return { + hasError: !validation.strValues.some((el: any) => value.startsWith(el)), + errorMessage: validation.validationMessage || \`The value must start with \${validation.strValues.join(', ')}\`, + }; + case 'EndWith': + return { + hasError: !validation.strValues.some((el: any) => value.endsWith(el)), + errorMessage: validation.validationMessage || \`The value must end with \${validation.strValues.join(', ')}\`, + }; + case 'Contains': + return { + hasError: !validation.strValues.some((el: any) => value.includes(el)), + errorMessage: validation.validationMessage || \`The value must contain \${validation.strValues.join(', ')}\`, + }; + case 'NotContains': + return { + hasError: !validation.strValues.every((el: any) => !value.includes(el)), + errorMessage: validation.validationMessage || \`The value must not contain \${validation.strValues.join(', ')}\`, + }; + case 'BeAfter': + return { + hasError: !(new Date(value) > new Date(parseDateValidator(validation.strValues[0]))), + errorMessage: validation.validationMessage || \`The value must be after \${validation.strValues[0]}\`, + }; + case 'BeBefore': + return { + hasError: !(new Date(value) < new Date(parseDateValidator(validation.strValues[0]))), + errorMessage: validation.validationMessage || \`The value must be before \${validation.strValues[0]}\`, + }; + } + } + switch (validation.type) { + case 'Email': + const EMAIL_ADDRESS_REGEX = + /^[-!#$%&'*+\/0-9=?A-Z^_a-z\`{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z\`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/; + return { + hasError: !EMAIL_ADDRESS_REGEX.test(value), + errorMessage: validation.validationMessage || 'The value must be a valid email address', + }; + case 'JSON': + let isInvalidJSON = false; + try { + JSON.parse(value); + } catch (e) { + isInvalidJSON = true; + } + return { + hasError: isInvalidJSON, + errorMessage: validation.validationMessage || 'The value must be in a correct JSON format', + }; + case 'IpAddress': + const IPV_4 = /^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$/; + const IPV_6 = + /^(?:(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,2}|:)|(?:[a-fA-F\\d]{1,4}:){4}(?:(?::[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,3}|:)|(?:[a-fA-F\\d]{1,4}:){3}(?:(?::[a-fA-F\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,4}|:)|(?:[a-fA-F\\d]{1,4}:){2}(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$/; + return { + hasError: !(IPV_4.test(value) || IPV_6.test(value)), + errorMessage: validation.validationMessage || 'The value must be an IPv4 or IPv6 address', + }; + case 'URL': + let isInvalidUrl = false; + try { + new URL(value); + } catch (e) { + isInvalidUrl = true; + } + return { + hasError: isInvalidUrl, + errorMessage: + validation.validationMessage || + 'The value must be a valid URL that begins with a schema (i.e. http:// or mailto:)', + }; + case 'Phone': + const PHONE = /^\\+?\\d[\\d\\s-]+$/; + return { + hasError: !PHONE.test(value), + errorMessage: validation.validationMessage || 'The value must be a valid phone number', + }; + default: + } +};`; diff --git a/packages/codegen-ui-react/lib/views/react-view-renderer.ts b/packages/codegen-ui-react/lib/views/react-view-renderer.ts index 94dfb7de5..81492d2d9 100644 --- a/packages/codegen-ui-react/lib/views/react-view-renderer.ts +++ b/packages/codegen-ui-react/lib/views/react-view-renderer.ts @@ -66,6 +66,7 @@ import { getPredicateName, needsFormatter, } from '../react-table-renderer-helper'; +import { overrideTypesString } from '../utils-file-functions'; export abstract class ReactViewTemplateRenderer extends StudioTemplateRenderer< string, @@ -177,6 +178,8 @@ export abstract class ReactViewTemplateRenderer extends StudioTemplateRenderer< componentText += EOL; + componentText += overrideTypesString + EOL; + propsDeclaration.forEach((typeNode) => { const propsPrinted = printer.printNode(EmitHint.Unspecified, typeNode, file); componentText += propsPrinted; @@ -475,7 +478,7 @@ export abstract class ReactViewTemplateRenderer extends StudioTemplateRenderer< ]); const formPropType = getComponentPropName(this.component.name); - this.importCollection.addMappedImport(ImportValue.ESCAPE_HATCH_PROPS, ImportValue.CREATE_DATA_STORE_PREDICATE); + this.importCollection.addMappedImport(ImportValue.CREATE_DATA_STORE_PREDICATE); return [ factory.createTypeAliasDeclaration( diff --git a/packages/codegen-ui-react/package.json b/packages/codegen-ui-react/package.json index 0153e0592..fd8bfe075 100644 --- a/packages/codegen-ui-react/package.json +++ b/packages/codegen-ui-react/package.json @@ -64,8 +64,8 @@ "testEnvironment": "jsdom", "testRegex": [ "(lib/__tests__/.*.test.ts)$", - "(lib/utils-file-functions/hooks/__tests__/.*.test.tsx)$", - "(lib/utils-file-functions/hooks/__tests__/.*.test.ts)$" + "(lib/utils-file-functions/.*/__tests__/.*.test.tsx)$", + "(lib/utils-file-functions/.*/__tests__/.*.test.ts)$" ], "testPathIgnorePatterns": [ "/lib/__tests__/__utils__/"