From 85ecd5e05eb50abf13608cfa40ee7a008f7b3203 Mon Sep 17 00:00:00 2001 From: Justin Shih <36183898+Jshhhh@users.noreply.github.com> Date: Fri, 6 Oct 2023 21:37:36 -0700 Subject: [PATCH] feat: add override and variant exports from ui-react to utils (#1104) Co-authored-by: Justin Shih --- ...udio-template-renderer-helper.test.ts.snap | 18 +- ...studio-ui-codegen-react-forms.test.ts.snap | 530 ++++++---------- ...studio-ui-codegen-react-views.test.ts.snap | 9 +- .../studio-ui-codegen-react.test.ts.snap | 595 +++++------------- .../render-util-functions.test.ts.snap | 77 +++ .../lib/imports/import-mapping.ts | 26 +- packages/codegen-ui-react/lib/index.ts | 1 + .../__tests__/getOverrideProps.test.tsx | 58 ++ .../getOverridesFromVariants.test.tsx | 133 ++++ .../mergeVariantsAndOverrides.test.tsx | 124 ++++ .../lib/overrides/findChildOverrides.ts | 242 +++++++ .../lib/overrides/getOverrideProps.ts | 248 ++++++++ .../lib/overrides/getOverridesFromVariants.ts | 496 +++++++++++++++ .../codegen-ui-react/lib/overrides/index.ts | 21 + .../overrides/mergeVariantsAndOverrides.ts | 286 +++++++++ .../codegen-ui-react/lib/overrides/types.ts | 104 +++ .../lib/react-component-renderer.ts | 2 +- .../react-utils-studio-template-renderer.ts | 19 +- 18 files changed, 2198 insertions(+), 791 deletions(-) create mode 100644 packages/codegen-ui-react/lib/overrides/__tests__/getOverrideProps.test.tsx create mode 100644 packages/codegen-ui-react/lib/overrides/__tests__/getOverridesFromVariants.test.tsx create mode 100644 packages/codegen-ui-react/lib/overrides/__tests__/mergeVariantsAndOverrides.test.tsx create mode 100644 packages/codegen-ui-react/lib/overrides/findChildOverrides.ts create mode 100644 packages/codegen-ui-react/lib/overrides/getOverrideProps.ts create mode 100644 packages/codegen-ui-react/lib/overrides/getOverridesFromVariants.ts create mode 100644 packages/codegen-ui-react/lib/overrides/index.ts create mode 100644 packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts create mode 100644 packages/codegen-ui-react/lib/overrides/types.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 7c7e53389..864577de2 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 @@ -14,7 +14,7 @@ exports[`react-studio-template-renderer-helper transpile fails to transpile with exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES3 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -31,7 +31,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES5 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -48,7 +48,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2015 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -65,7 +65,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2016 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -82,7 +82,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2017 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -99,7 +99,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2018 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -116,7 +116,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2019 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -133,7 +133,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2020 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -150,7 +150,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`react-studio-template-renderer-helper transpile successfully transpiles with ScriptTarget ES2021 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; 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 bc9b7ca88..67e568362 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 @@ -16,8 +16,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listDogs } from \\"../graphql/queries\\"; import { createOwner, updateDog, updateOwner } from \\"../graphql/mutations\\"; @@ -516,7 +515,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -566,8 +565,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { generateClient } from \\"aws-amplify/api\\"; import { listDogs } from \\"../graphql/queries\\"; import { createOwner, updateDog, updateOwner } from \\"../graphql/mutations\\"; @@ -1067,7 +1065,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -1117,8 +1115,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { generateClient } from \\"aws-amplify/api\\"; import { createPost } from \\"../graphql/mutations\\"; const client = generateClient(); @@ -1714,7 +1711,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -1780,8 +1777,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { createPost } from \\"../graphql/mutations\\"; function ArrayField({ @@ -2376,7 +2372,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -2442,8 +2438,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listTeams } from \\"../graphql/queries\\"; import { createMember } from \\"../graphql/mutations\\"; @@ -3054,7 +3049,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Team } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -3109,9 +3104,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Tag } from \\"../API\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listTags } from \\"../graphql/queries\\"; import { createMovie, createMovieTags } from \\"../graphql/mutations\\"; @@ -3704,7 +3698,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Tag } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -3764,8 +3758,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listStudents } from \\"../graphql/queries\\"; import { createSchool, updateStudent } from \\"../graphql/mutations\\"; @@ -4262,7 +4255,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Student } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -4314,8 +4307,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listAuthors } from \\"../graphql/queries\\"; import { createBook } from \\"../graphql/mutations\\"; @@ -4805,7 +4797,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Author } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -4857,8 +4849,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listPosts } from \\"../graphql/queries\\"; import { createComment } from \\"../graphql/mutations\\"; @@ -5318,7 +5309,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -5369,9 +5360,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Post } from \\"../API\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listPosts } from \\"../graphql/queries\\"; import { createTag, createTagPost } from \\"../graphql/mutations\\"; @@ -5946,7 +5936,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Post } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -6001,8 +5991,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listAuthors, listTitles } from \\"../graphql/queries\\"; import { createBook } from \\"../graphql/mutations\\"; @@ -6625,7 +6614,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Author, Title } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -6680,9 +6669,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { CPKClass } from \\"../API\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listCPKClasses, @@ -7465,7 +7453,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CPKClass, CPKProject, CPKStudent } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -7523,8 +7511,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listParentTables } from \\"../graphql/queries\\"; import { createBasicTable } from \\"../graphql/mutations\\"; @@ -8033,7 +8020,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { ParentTable } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -8087,8 +8074,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getPost, listComments } from \\"../graphql/queries\\"; import { updateComment, updatePost } from \\"../graphql/mutations\\"; @@ -8726,7 +8712,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Comment, Post } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -8784,8 +8770,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { generateClient } from \\"aws-amplify/api\\"; import { getPost } from \\"../graphql/queries\\"; import { updatePost } from \\"../graphql/mutations\\"; @@ -9502,7 +9487,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Post } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -9573,8 +9558,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getPost } from \\"../graphql/queries\\"; import { updatePost } from \\"../graphql/mutations\\"; @@ -10290,7 +10274,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Post } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -10361,8 +10345,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { getMovie, listMovieTags, @@ -11080,7 +11063,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Movie, Tag } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -11145,8 +11128,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { getMovie, listMovieTags, @@ -11863,7 +11845,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Movie, Tag } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -11928,8 +11910,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getComment, getPost, listPosts } from \\"../graphql/queries\\"; import { updateComment } from \\"../graphql/mutations\\"; @@ -12603,7 +12584,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Comment, Post } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -12661,8 +12642,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { generateClient } from \\"aws-amplify/api\\"; import { getComment, getPost, listPosts } from \\"../graphql/queries\\"; import { updateComment } from \\"../graphql/mutations\\"; @@ -13337,7 +13317,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -13394,8 +13374,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getComment, getPost, listPosts } from \\"../graphql/queries\\"; import { updateComment } from \\"../graphql/mutations\\"; @@ -14069,7 +14048,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -14126,8 +14105,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getComment, getPost, listPosts } from \\"../graphql/queries\\"; import { updateComment } from \\"../graphql/mutations\\"; @@ -14621,7 +14599,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Comment } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -14672,8 +14650,7 @@ import { Text, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { getClass, listStudentClasses, @@ -15239,7 +15216,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Class, Student } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -15287,8 +15264,7 @@ import { Text, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { getClass, listStudentClasses, @@ -15853,7 +15829,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Class, Student } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -15903,8 +15879,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getBasicTable, listParentTables } from \\"../graphql/queries\\"; import { updateBasicTable } from \\"../graphql/mutations\\"; @@ -16444,7 +16419,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { BasicTable, ParentTable } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -16499,8 +16474,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { cPKTeacherCPKClassesByCPKTeacherSpecialTeacherId, getCPKTeacher, @@ -17460,7 +17434,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CPKClass, CPKProject, CPKStudent, CPKTeacher } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -17518,8 +17492,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { cPKTeacherCPKClassesByCPKTeacherSpecialTeacherId, getCPKTeacher, @@ -18478,7 +18451,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CPKClass, CPKProject, CPKStudent, CPKTeacher } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -18536,8 +18509,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listCompositeDogs } from \\"../graphql/queries\\"; import { createCompositeToy } from \\"../graphql/mutations\\"; @@ -19262,7 +19234,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -19318,8 +19290,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listOrgs, listPosts, listUsers } from \\"../graphql/queries\\"; import { createComment } from \\"../graphql/mutations\\"; @@ -20200,7 +20171,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Org, Post, User } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -20260,9 +20231,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { CompositeVet } from \\"../API\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listCompositeBowls, @@ -21311,7 +21281,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CompositeBowl, CompositeOwner, CompositeToy, CompositeVet } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -21374,8 +21344,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listComments } from \\"../graphql/queries\\"; import { createPost, updateComment } from \\"../graphql/mutations\\"; @@ -21863,7 +21832,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Comment } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -21914,8 +21883,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getPost, listComments } from \\"../graphql/queries\\"; import { updateComment, updatePost } from \\"../graphql/mutations\\"; @@ -22462,7 +22430,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Comment, Post } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -22514,8 +22482,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getChildItem, @@ -23081,7 +23048,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { ChildItem } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -23133,8 +23100,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getPost, listBlogs, listComments } from \\"../graphql/queries\\"; import { updateComment, updatePost } from \\"../graphql/mutations\\"; @@ -23816,7 +23782,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Blog, Comment, Post } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -23871,8 +23837,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listOwners } from \\"../graphql/queries\\"; import { createDog, updateOwner } from \\"../graphql/mutations\\"; @@ -24367,7 +24332,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Owner } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -24418,8 +24383,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { listDogs } from \\"../graphql/queries\\"; import { createOwner, updateDog, updateOwner } from \\"../graphql/mutations\\"; @@ -24918,7 +24882,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Dog } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -24969,8 +24933,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getComment, getPost, listPosts } from \\"../graphql/queries\\"; import { updateComment } from \\"../graphql/mutations\\"; @@ -25464,7 +25427,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Comment } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -25516,8 +25479,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { API } from \\"aws-amplify\\"; import { getCustomKeyModel, listChildItems } from \\"../graphql/queries\\"; import { updateChildItem, updateCustomKeyModel } from \\"../graphql/mutations\\"; @@ -26105,7 +26067,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { ChildItem, CustomKeyModel } from \\"../API\\"; export declare type ValidationResponse = { hasError: boolean; @@ -26160,8 +26122,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; function ArrayField({ items = [], onChange, @@ -26626,7 +26587,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -26680,12 +26641,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { CompositeToy, CompositeDog } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -27278,7 +27236,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -27334,12 +27292,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Comment, Post, User as User0, Org as Org0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -28067,7 +28022,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Post, User as User0, Org as Org0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -28127,10 +28082,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { CompositeDog, CompositeBowl as CompositeBowl0, @@ -28139,7 +28091,7 @@ import { CompositeVet, CompositeDogCompositeVet, } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -29019,7 +28971,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CompositeBowl as CompositeBowl0, CompositeOwner as CompositeOwner0, CompositeToy, CompositeVet } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -29079,8 +29031,7 @@ import { StepperField, TextField, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; export default function CustomDataForm(props) { const { onSubmit, onCancel, onValidate, onChange, overrides, ...rest } = props; @@ -29417,7 +29368,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -29475,8 +29426,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; export default function CustomDataForm(props) { const { onSubmit, onCancel, onValidate, onChange, overrides, ...rest } = props; @@ -29814,7 +29764,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -29874,8 +29824,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; function ArrayField({ items = [], onChange, @@ -30340,7 +30289,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -30392,8 +30341,7 @@ import { TextAreaField, TextField, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; export default function CustomDataForm(props) { const { initialData, @@ -30753,7 +30701,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -30814,9 +30762,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Post } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -31486,7 +31433,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -31556,12 +31503,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Org, Comment } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -32057,7 +32001,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Org, Comment } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -32109,10 +32053,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { CompositeDog, CompositeBowl as CompositeBowl0, @@ -32121,7 +32062,7 @@ import { CompositeVet, CompositeDogCompositeVet, } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -33182,7 +33123,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CompositeDog, CompositeBowl as CompositeBowl0, CompositeOwner as CompositeOwner0, CompositeToy, CompositeVet } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -33249,10 +33190,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { CPKTeacher, CPKStudent as CPKStudent0, @@ -33260,7 +33198,7 @@ import { CPKProject, CPKTeacherCPKClass, } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -34077,7 +34015,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CPKTeacher, CPKStudent as CPKStudent0, CPKClass, CPKProject } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -34136,8 +34074,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; function ArrayField({ items = [], onChange, @@ -34649,7 +34586,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -34723,8 +34660,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; function ArrayField({ items = [], onChange, @@ -35249,7 +35185,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -35324,8 +35260,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; function ArrayField({ items = [], onChange, @@ -35971,7 +35906,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -36050,8 +35985,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; function ArrayField({ items = [], onChange, @@ -36496,7 +36430,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -36558,10 +36492,7 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { CompositeDog, CompositeOwner as CompositeOwner0, @@ -36570,7 +36501,7 @@ import { CompositeDogCompositeVet, CompositeBowl, } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -37634,7 +37565,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { CompositeDog, CompositeOwner as CompositeOwner0, CompositeToy, CompositeVet } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -37697,8 +37628,7 @@ import { Text, TextField, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; export default function CustomWithSectionalElements(props) { const { onSubmit, onCancel, onValidate, onChange, overrides, ...rest } = props; @@ -37844,7 +37774,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -37892,12 +37822,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Dog, Owner } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -38339,7 +38266,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Owner } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -38390,12 +38317,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Dog, Owner } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -38874,7 +38798,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Dog, Owner } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -38926,12 +38850,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Owner, Dog as Dog0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -39374,7 +39295,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Dog as Dog0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -39425,12 +39346,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Owner, Dog as Dog0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -39911,7 +39829,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Owner, Dog as Dog0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -39963,9 +39881,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Post } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -40551,7 +40468,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -40618,12 +40535,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Tag, Post, TagPost } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -41154,7 +41068,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Post } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -41209,12 +41123,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Member, Team as Team0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -41736,7 +41647,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Team as Team0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -41791,12 +41702,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { School, Student } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -42246,7 +42154,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Student } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -42298,12 +42206,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Book, Author } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -42746,7 +42651,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Author } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -42799,12 +42704,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Tag, Post, TagPost } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -43335,7 +43237,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Post } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -43390,12 +43292,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Book, Author, Title } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -43944,7 +43843,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Author, Title } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -43999,9 +43898,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Post } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -44705,7 +44603,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Post } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -44776,12 +44674,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { School, Student } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -45286,7 +45181,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { School, Student } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -45339,12 +45234,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { School, Student as Student0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -45896,7 +45788,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { School, Student as Student0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -45952,12 +45844,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Member, Team as Team0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -46508,7 +46397,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Member, Team as Team0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -46565,12 +46454,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Tag, Post, TagPost } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -47184,7 +47070,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Tag, Post } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -47239,9 +47125,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Flex as Flex0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -47770,7 +47655,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -47831,9 +47716,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Blog } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -48327,7 +48211,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -48390,9 +48274,8 @@ import { ToggleButton, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { InputGallery } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -49298,7 +49181,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -49380,9 +49263,8 @@ import { ToggleButton, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { InputGallery } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -50209,7 +50091,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { InputGallery } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -50288,9 +50170,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Flex as Flex0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -50897,7 +50778,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Flex as Flex0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -50964,9 +50845,8 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Post } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -51611,7 +51491,7 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; export declare type ValidationResponse = { hasError: boolean; errorMessage?: string; @@ -51681,12 +51561,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Member, Team as Team0 } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -52208,7 +52085,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Team as Team0 } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -52252,9 +52129,14 @@ 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, getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { + fetchByPath, + getOverrideProps, + processFile, + validateField, +} from \\"./utils\\"; import { Product } from \\"../models\\"; -import { fetchByPath, processFile, validateField } from \\"./utils\\"; +import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; export default function CreateProductForm(props) { const { @@ -52464,9 +52346,14 @@ 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, getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { + fetchByPath, + getOverrideProps, + processFile, + validateField, +} from \\"./utils\\"; import { Product } from \\"../models\\"; -import { fetchByPath, processFile, validateField } from \\"./utils\\"; +import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; export default function UpdateProductForm(props) { const { @@ -52696,7 +52583,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Product } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -52737,9 +52624,14 @@ 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, getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { + fetchByPath, + getOverrideProps, + processFile, + validateField, +} from \\"./utils\\"; import { Product } from \\"../models\\"; -import { fetchByPath, processFile, validateField } from \\"./utils\\"; +import { Field } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; export default function UpdateProductForm(props) { const { @@ -52986,12 +52878,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Car, Dealership } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -53440,7 +53329,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Car, Dealership } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; @@ -53492,12 +53381,9 @@ import { TextField, useTheme, } from \\"@aws-amplify/ui-react\\"; -import { - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { fetchByPath, getOverrideProps, validateField } from \\"./utils\\"; import { Dealership, Car } from \\"../models\\"; -import { fetchByPath, validateField } from \\"./utils\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { DataStore } from \\"aws-amplify\\"; function ArrayField({ items = [], @@ -53989,7 +53875,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { Dealership, Car } from \\"../models\\"; export declare type ValidationResponse = { hasError: boolean; 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..946cf2c9d 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,8 @@ 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 { EscapeHatchProps } from \\"./utils\\"; +import { createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; export declare type MyPostTableProps = React.PropsWithChildren<{ overrides?: EscapeHatchProps | undefined | null; predicateOverride?: ReturnType | undefined | null; @@ -286,7 +287,8 @@ 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 { EscapeHatchProps } from \\"./utils\\"; +import { createDataStorePredicate } from \\"@aws-amplify/ui-react/internal\\"; export declare type CustomTableProps = React.PropsWithChildren<{ overrides?: EscapeHatchProps | undefined | null; predicateOverride?: ReturnType | undefined | null; @@ -398,7 +400,8 @@ 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\\"; +import { EscapeHatchProps } from \\"./utils\\"; 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 479bdbf4e..f86d865d0 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,13 +4,10 @@ exports[`amplify render tests actions DataStore DataStoreCreateItem 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - 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 { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -54,13 +51,10 @@ exports[`amplify render tests actions DataStore DataStoreDeleteItem 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - 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 { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -104,13 +98,10 @@ exports[`amplify render tests actions DataStore DataStoreUpdateItem 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - 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 { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -157,10 +148,7 @@ import * as React from \\"react\\"; import { generateClient } from \\"aws-amplify/api\\"; import { createCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -211,10 +199,7 @@ import * as React from \\"react\\"; import { API } from \\"aws-amplify\\"; import { createCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -267,10 +252,7 @@ import * as React from \\"react\\"; import { API } from \\"aws-amplify\\"; import { deleteCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -322,10 +304,7 @@ import * as React from \\"react\\"; import { API } from \\"aws-amplify\\"; import { updateCustomer } from \\"../graphql/mutations\\"; import { Customer } from \\"../API\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -376,11 +355,8 @@ exports[`amplify render tests actions auth signs out 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useAuthSignOutAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useAuthSignOutAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -420,11 +396,8 @@ exports[`amplify render tests actions navigation anchor navigation action 1`] = Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useNavigateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useNavigateAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -467,11 +440,8 @@ exports[`amplify render tests actions navigation hard navigation action 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useNavigateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useNavigateAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -514,11 +484,8 @@ exports[`amplify render tests actions navigation new tab navigation action 1`] = Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useNavigateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useNavigateAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -562,11 +529,8 @@ exports[`amplify render tests actions navigation reload navigation action 1`] = Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useNavigateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useNavigateAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -608,12 +572,11 @@ Object { import * as React from \\"react\\"; import { User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, - getOverrideProps, useDataStoreBinding, useStateMutationAction, } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -686,10 +649,7 @@ export default function ConditionalInMutation( exports[`amplify render tests basic component tests should generate a simple button component 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -723,10 +683,7 @@ export default function CustomButton( exports[`amplify render tests basic component tests should generate a simple text component 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -758,10 +715,7 @@ export default function CustomText(props: CustomTextProps): React.ReactElement { exports[`amplify render tests basic component tests should generate a simple view component 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -793,13 +747,12 @@ exports[`amplify render tests bindings auth supports auth bindings in actions 1` "/* eslint-disable */ import * as React from \\"react\\"; import { - EscapeHatchProps, - getOverrideProps, useAuth, useDataStoreCreateAction, } from \\"@aws-amplify/ui-react/internal\\"; import { Customer } from \\"../models\\"; import { schema } from \\"../models/schema\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -844,10 +797,7 @@ exports[`amplify render tests bindings data supports bindings with reserved keyw "/* eslint-disable */ import * as React from \\"react\\"; import { Class } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -882,10 +832,7 @@ exports[`amplify render tests bindings data supports model with conflicting comp "/* eslint-disable */ import * as React from \\"react\\"; import { Flex as Flex0 } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -922,10 +869,7 @@ exports[`amplify render tests collection GraphQL should not render nested query import * as React from \\"react\\"; import { listAuthors } from \\"../graphql/queries\\"; import AuthorProfile, { AuthorProfileProps } from \\"./AuthorProfile\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps, @@ -1068,11 +1012,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, - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { generateClient } from \\"aws-amplify/api\\"; import { Button, @@ -1084,6 +1024,7 @@ import { Pagination, Placeholder, } from \\"@aws-amplify/ui-react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; export declare type PrimitiveOverrideProps = Partial & @@ -1270,11 +1211,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, - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { API } from \\"aws-amplify\\"; import { Button, @@ -1286,6 +1223,7 @@ import { Pagination, Placeholder, } from \\"@aws-amplify/ui-react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; export declare type PrimitiveOverrideProps = Partial & @@ -1471,10 +1409,7 @@ exports[`amplify render tests collection GraphQL should render collection with d import * as React from \\"react\\"; import { listUntitledModels } from \\"../graphql/queries\\"; import ListingCard, { ListingCardProps } from \\"./ListingCard\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps, @@ -1618,10 +1553,7 @@ exports[`amplify render tests collection GraphQL should render collection withou "/* eslint-disable */ import * as React from \\"react\\"; import ListingCard, { ListingCardProps } from \\"./ListingCard\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps, @@ -1742,10 +1674,7 @@ exports[`amplify render tests collection GraphQL should render nested query if m import * as React from \\"react\\"; import { listAuthors } from \\"../graphql/queries\\"; import AuthorProfile, { AuthorProfileProps } from \\"./AuthorProfile\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps, @@ -1887,12 +1816,9 @@ 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, - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import AuthorProfile, { AuthorProfileProps } from \\"./AuthorProfile\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -1959,9 +1885,7 @@ exports[`amplify render tests collection should render collection with data bind import * as React from \\"react\\"; import { UserPreferences, User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, - getOverrideProps, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; import { @@ -1972,6 +1896,7 @@ import { Flex, FlexProps, } from \\"@aws-amplify/ui-react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2104,9 +2029,7 @@ Object { import * as React from \\"react\\"; import { UserPreferences, User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, - getOverrideProps, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; import { SortDirection, SortPredicate } from \\"@aws-amplify/datastore\\"; @@ -2118,6 +2041,7 @@ import { Flex, FlexProps, } from \\"@aws-amplify/ui-react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2231,9 +2155,7 @@ exports[`amplify render tests collection should render collection with data bind import * as React from \\"react\\"; import { UserPreferences, User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, - getOverrideProps, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; import { @@ -2244,6 +2166,7 @@ import { Flex, FlexProps, } from \\"@aws-amplify/ui-react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2348,12 +2271,9 @@ exports[`amplify render tests collection should render collection with data bind "/* eslint-disable */ import * as React from \\"react\\"; import { UntitledModel } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import ListingCard, { ListingCardProps } from \\"./ListingCard\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2421,10 +2341,7 @@ exports[`amplify render tests collection should render collection without data b "/* eslint-disable */ import * as React from \\"react\\"; import ListingCard, { ListingCardProps } from \\"./ListingCard\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2473,14 +2390,11 @@ exports[`amplify render tests collection should render concatenated keys if mode "/* eslint-disable */ import * as React from \\"react\\"; import { CompositePerson } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import CompositePersonProfile, { CompositePersonProfileProps, } from \\"./CompositePersonProfile\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2550,9 +2464,7 @@ 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, - getOverrideProps, useDataStoreBinding, } from \\"@aws-amplify/ui-react/internal\\"; import { SortDirection, SortPredicate } from \\"@aws-amplify/datastore\\"; @@ -2564,6 +2476,7 @@ import { Flex, FlexProps, } from \\"@aws-amplify/ui-react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { MyFlexProps } from \\"./MyFlex\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2685,12 +2598,9 @@ 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, - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import AuthorProfile, { AuthorProfileProps } from \\"./AuthorProfile\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Collection, CollectionProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2765,10 +2675,7 @@ export default function AuthorProfileCollection( exports[`amplify render tests complex component tests should generate a button within a view component 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2803,10 +2710,7 @@ export default function ViewWithButton( exports[`amplify render tests complex component tests should generate a component with custom child (malformed property) 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; @@ -2841,10 +2745,7 @@ export default function ViewWithCustomButton( exports[`amplify render tests complex component tests should generate a component with custom child 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; @@ -2880,10 +2781,7 @@ export default function ViewWithCustomButton( exports[`amplify render tests complex component tests should generate a component with exposeAs prop 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2918,10 +2816,7 @@ export default function ViewWithButton( exports[`amplify render tests complex examples should render complex sample 1 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -2975,10 +2870,7 @@ export default function ComplexTest1( exports[`amplify render tests complex examples should render complex sample 2 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -3052,10 +2944,7 @@ export default function ComplexTest2( exports[`amplify render tests complex examples should render complex sample 3 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -3155,7 +3044,7 @@ import { getOverrideProps, getOverridesFromVariants, mergeVariantsAndOverrides, -} from \\"@aws-amplify/ui-react/internal\\"; +} from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -3275,10 +3164,7 @@ export default function ComplexTest4( exports[`amplify render tests complex examples should render complex sample 5 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -3336,10 +3222,7 @@ export default function ComplexTest5( exports[`amplify render tests complex examples should render complex sample 6 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -3422,10 +3305,7 @@ export default function ComplexTest6( exports[`amplify render tests complex examples should render complex sample 7 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Image, ImageProps, @@ -3511,10 +3391,7 @@ export default function ComplexTest7( exports[`amplify render tests complex examples should render complex sample 8 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -3592,7 +3469,7 @@ import { getOverrideProps, getOverridesFromVariants, mergeVariantsAndOverrides, -} from \\"@aws-amplify/ui-react/internal\\"; +} from \\"./utils\\"; import { Button, ButtonProps, @@ -3996,10 +3873,7 @@ export default function ComplexTest9( exports[`amplify render tests complex examples should render complex sample 10 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -4949,10 +4823,7 @@ export default function ComplexTest10( exports[`amplify render tests complex examples should render complex sample 11 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Badge, BadgeProps, @@ -5937,10 +5808,7 @@ export default function ComplexTest11( exports[`amplify render tests component with binding should render build property on Text 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -5976,10 +5844,7 @@ export default function TextWithDataBinding( exports[`amplify render tests component with binding should render slot binding 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -6026,10 +5891,7 @@ exports[`amplify render tests component with data binding should add GraphQL mod "/* eslint-disable */ import * as React from \\"react\\"; import { User } from \\"../API\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6070,10 +5932,7 @@ exports[`amplify render tests component with data binding should add model impor "/* eslint-disable */ import * as React from \\"react\\"; import { User } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6114,10 +5973,7 @@ exports[`amplify render tests component with data binding should not have useDat "/* eslint-disable */ import * as React from \\"react\\"; import { UntitledModel } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6182,10 +6038,7 @@ export default function SectionHeading( exports[`amplify render tests component with data binding should render with data binding in child elements 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6231,7 +6084,7 @@ import { getOverrideProps, getOverridesFromVariants, mergeVariantsAndOverrides, -} from \\"@aws-amplify/ui-react/internal\\"; +} from \\"./utils\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6287,7 +6140,7 @@ import { getOverrideProps, getOverridesFromVariants, mergeVariantsAndOverrides, -} from \\"@aws-amplify/ui-react/internal\\"; +} from \\"./utils\\"; import { Icon, IconProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6363,7 +6216,7 @@ import { getOverrideProps, getOverridesFromVariants, mergeVariantsAndOverrides, -} from \\"@aws-amplify/ui-react/internal\\"; +} from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6422,7 +6275,7 @@ import { getOverrideProps, getOverridesFromVariants, mergeVariantsAndOverrides, -} from \\"@aws-amplify/ui-react/internal\\"; +} from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6485,10 +6338,7 @@ export default function CustomButton( exports[`amplify render tests concat and conditional transform should render child component with data bound concatenation 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6536,10 +6386,7 @@ export default function ChildComponentWithDataBoundConcatenation( exports[`amplify render tests concat and conditional transform should render child component with static concatenation 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6581,10 +6428,7 @@ exports[`amplify render tests concat and conditional transform should render com "/* eslint-disable */ import * as React from \\"react\\"; import { User } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6624,10 +6468,7 @@ exports[`amplify render tests concat and conditional transform should render com "/* eslint-disable */ import * as React from \\"react\\"; import { User } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6678,10 +6519,7 @@ exports[`amplify render tests concat and conditional transform should render com "/* eslint-disable */ import * as React from \\"react\\"; import { Student } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -6742,10 +6580,7 @@ export default function ConditionalComponentWithDataBinding( exports[`amplify render tests concat and conditional transform should render component with conditional simple binding prop 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -6778,7 +6613,7 @@ export default function CustomButton( exports[`amplify render tests custom components alias parent should render declarations 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { GridProps } from \\"./Grid\\"; import { ButtonProps } from \\"@aws-amplify/ui-react\\"; import { ViewTestProps } from \\"./ViewTest\\"; @@ -6798,10 +6633,7 @@ export default function AliasParent(props: AliasParentProps): React.ReactElement exports[`amplify render tests custom components alias parent should render parent with aliased child instead of primitive 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Grid as GridCustom, GridProps } from \\"./Grid\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; import ViewTest, { ViewTestProps } from \\"./ViewTest\\"; @@ -6836,10 +6668,7 @@ export default function AliasParent( exports[`amplify render tests custom components custom children should render component with custom children 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import MyView, { MyViewProps } from \\"./MyView\\"; @@ -6905,7 +6734,7 @@ var __rest = }; /* eslint-disable */ import * as React from \\"react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { getOverrideProps } from \\"./utils\\"; import CustomButton from \\"./CustomButton\\"; import MyView from \\"./MyView\\"; export default function CustomChildren(props) { @@ -6925,7 +6754,7 @@ export default function CustomChildren(props) { exports[`amplify render tests custom components custom children should render declarations 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { MyViewProps } from \\"./MyView\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -6943,10 +6772,7 @@ export default function CustomChildren(props: CustomChildrenProps): React.ReactE exports[`amplify render tests custom components custom parent and children should render component with custom parent and children 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import ViewTest, { ViewTestProps } from \\"./ViewTest\\"; @@ -7015,7 +6841,7 @@ var __rest = }; /* eslint-disable */ import * as React from \\"react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { getOverrideProps } from \\"./utils\\"; import CustomButton from \\"./CustomButton\\"; import ViewTest from \\"./ViewTest\\"; export default function CustomParentAndChildren(props) { @@ -7035,7 +6861,7 @@ export default function CustomParentAndChildren(props) { exports[`amplify render tests custom components custom parent and children should render declarations 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { CustomButtonProps } from \\"./CustomButton\\"; import { ViewTestProps } from \\"./ViewTest\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -7053,10 +6879,7 @@ export default function CustomParentAndChildren(props: CustomParentAndChildrenPr exports[`amplify render tests custom components custom parent should render component 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; import MyView, { MyViewProps } from \\"./MyView\\"; @@ -7120,7 +6943,7 @@ var __rest = }; /* eslint-disable */ import * as React from \\"react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { getOverrideProps } from \\"./utils\\"; import { Button } from \\"@aws-amplify/ui-react\\"; import MyView from \\"./MyView\\"; export default function CustomParent(props) { @@ -7140,7 +6963,7 @@ export default function CustomParent(props) { exports[`amplify render tests custom components custom parent should render declarations 1`] = ` "import * as React from \\"react\\"; -import { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { ButtonProps } from \\"@aws-amplify/ui-react\\"; import { MyViewProps } from \\"./MyView\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; @@ -7190,7 +7013,7 @@ var __rest = }; /* eslint-disable */ import * as React from \\"react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { getOverrideProps } from \\"./utils\\"; import { Button, View } from \\"@aws-amplify/ui-react\\"; export default function ViewWithButton(props) { var overrides = props.overrides, @@ -7230,7 +7053,7 @@ exports[`amplify render tests custom render config should render JSX 1`] = ` }; /* eslint-disable */ import * as React from \\"react\\"; -import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\"; +import { getOverrideProps } from \\"./utils\\"; import { Button, View } from \\"@aws-amplify/ui-react\\"; export default function ViewWithButton(props) { const { overrides } = props, @@ -7307,7 +7130,7 @@ var __rest = Object.defineProperty(exports, \\"__esModule\\", { value: true }); /* eslint-disable */ const React = __importStar(require(\\"react\\")); -const internal_1 = require(\\"@aws-amplify/ui-react/internal\\"); +const utils_1 = require(\\"./utils\\"); const ui_react_1 = require(\\"@aws-amplify/ui-react\\"); function ViewWithButton(props) { const { overrides } = props, @@ -7316,14 +7139,14 @@ function ViewWithButton(props) { ui_react_1.View, Object.assign( {}, - (0, internal_1.getOverrideProps)(overrides, \\"ViewWithButton\\"), + (0, utils_1.getOverrideProps)(overrides, \\"ViewWithButton\\"), rest ), React.createElement( ui_react_1.Button, Object.assign( { color: \\"#ff0000\\", width: \\"20px\\" }, - (0, internal_1.getOverrideProps)(overrides, \\"MyButton\\") + (0, utils_1.getOverrideProps)(overrides, \\"MyButton\\") ) ) ); @@ -7334,7 +7157,7 @@ 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 { EscapeHatchProps } from \\"./utils\\"; import { ButtonProps, FlexProps, ImageProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ProfileOverridesProps = { @@ -7354,10 +7177,7 @@ exports[`amplify render tests default value should render bound default value 1` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -7396,17 +7216,14 @@ Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; import { User } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, - useDataStoreBinding, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useDataStoreBinding } from \\"@aws-amplify/ui-react/internal\\"; import { Collection, CollectionProps, Text, TextProps, } from \\"@aws-amplify/ui-react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { MyTextProps } from \\"./MyText\\"; export declare type PrimitiveOverrideProps = Partial & @@ -7469,10 +7286,7 @@ exports[`amplify render tests default value should render simple and bound defau Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -7510,10 +7324,7 @@ exports[`amplify render tests default value should render simple default value 1 Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -7553,10 +7364,7 @@ export default function SimplePropertyBindingDefaultValue( exports[`amplify render tests icon-indices does not return negative indices for icons 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -7886,11 +7694,8 @@ exports[`amplify render tests mutations controls an input that is modified by a Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -7951,13 +7756,12 @@ Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; import { - EscapeHatchProps, - getOverrideProps, useDataStoreUpdateAction, useStateMutationAction, } from \\"@aws-amplify/ui-react/internal\\"; import { Customer } from \\"../models\\"; import { schema } from \\"../models/schema\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -8020,11 +7824,8 @@ exports[`amplify render tests mutations internal mutation 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, Flex, FlexProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -8075,11 +7876,8 @@ exports[`amplify render tests mutations modifies text in component on input chan Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -8140,11 +7938,8 @@ exports[`amplify render tests mutations supports a controlled checkbox primitive Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { CheckboxField, CheckboxFieldProps, @@ -8201,11 +7996,8 @@ exports[`amplify render tests mutations supports a controlled stepper primitive Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -8265,11 +8057,8 @@ exports[`amplify render tests mutations supports a controlled switch primitive 1 Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -8323,14 +8112,13 @@ Object { import * as React from \\"react\\"; import { User } from \\"../models\\"; import { - EscapeHatchProps, createDataStorePredicate, - getOverrideProps, useAuth, useDataStoreBinding, useStateMutationAction, } from \\"@aws-amplify/ui-react/internal\\"; import { useEffect } from \\"react\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -8663,11 +8451,8 @@ Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; import { Listing } from \\"../models\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -8814,10 +8599,8 @@ var __rest = }; /* eslint-disable */ import * as React from \\"react\\"; -import { - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { getOverrideProps } from \\"./utils\\"; import { Flex, Image, Text } from \\"@aws-amplify/ui-react\\"; export default function CardA(props) { var listing = props.listing, @@ -8931,11 +8714,8 @@ exports[`amplify render tests mutations supports multiple actions pointing to th Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -9004,11 +8784,8 @@ exports[`amplify render tests mutations supports mutations on synthetic props 1` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -9069,11 +8846,8 @@ exports[`amplify render tests mutations supports mutations on visibility props 1 Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -9143,11 +8917,8 @@ exports[`amplify render tests mutations supports mutations with no initial state Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -9220,11 +8991,8 @@ exports[`amplify render tests mutations supports names that cant be directly tur Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useNavigateAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useNavigateAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, Text, TextProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -9269,11 +9037,8 @@ exports[`amplify render tests mutations supports nested mutation 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -9338,11 +9103,8 @@ exports[`amplify render tests mutations supports two-way data binding on form el Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useStateMutationAction, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useStateMutationAction } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, @@ -9901,10 +9663,7 @@ export default function TwoWayBindings( exports[`amplify render tests primitives CheckboxField 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { CheckboxField, CheckboxFieldProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -9938,10 +9697,7 @@ export default function CheckBoxFieldPrimitive( exports[`amplify render tests primitives Expander 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Expander, ExpanderItem, @@ -9994,10 +9750,7 @@ export default function ExpanderPrimitive( exports[`amplify render tests primitives ExpanderItem 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { ExpanderItem, ExpanderItemProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -10031,10 +9784,7 @@ export default function MyExpanderItem( exports[`amplify render tests primitives Icon 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Icon, IconProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -10073,10 +9823,7 @@ export default function IconPrimitive( exports[`amplify render tests primitives Icon with lower-cased type \`object\` for values 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Icon, IconProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -10118,10 +9865,7 @@ export default function IconPrimitiveWithLowerCasedType( exports[`amplify render tests primitives Menu 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Menu, MenuItem, @@ -10160,10 +9904,7 @@ export default function MenuPrimitive( exports[`amplify render tests primitives MenuButton 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { ButtonProps, MenuButton, @@ -10199,10 +9940,7 @@ export default function MenuButtonPrimitive( exports[`amplify render tests primitives SliderField 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { SliderField, SliderFieldProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -10239,10 +9977,7 @@ export default function SliderFieldPrimitive( exports[`amplify render tests primitives Table 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Table, TableBody, @@ -10396,10 +10131,7 @@ export default function TablePrimitive( exports[`amplify render tests primitives TextAreaField 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { TextAreaField, TextAreaFieldProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -10433,10 +10165,7 @@ export default function TextAreaFieldPrimitive( exports[`amplify render tests primitives TextField 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { TextField, TextFieldProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -10471,10 +10200,7 @@ export default function TextFieldPrimitive( exports[`amplify render tests renderer configurations with NoApi should render component without data binding successfully 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & @@ -10507,7 +10233,7 @@ 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 { EscapeHatchProps } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps } from \\"./utils\\"; import { ButtonProps } from \\"@aws-amplify/ui-react\\"; export declare type PrimitiveOverrideProps = Partial & React.DOMAttributes; export declare type ComponentWithDataBindingOverridesProps = { @@ -10528,10 +10254,7 @@ export default function ComponentWithDataBinding(props: ComponentWithDataBinding exports[`amplify render tests sample code snippet tests should generate a sample code snippet for components 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import CustomButton, { CustomButtonProps } from \\"./CustomButton\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; @@ -10573,10 +10296,7 @@ exports[`amplify render tests should render events 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Flex, FlexProps, @@ -10753,10 +10473,7 @@ exports[`amplify render tests should render parsed fixed values 1`] = ` Object { "componentText": "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, -} from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import Input, { InputProps } from \\"./Input\\"; import { View, ViewProps } from \\"@aws-amplify/ui-react\\"; @@ -10876,7 +10593,8 @@ exports[`amplify render tests source maps should render inline source maps 1`] = }; /* eslint-disable */ import * as React from \\"react\\"; -import { getOverrideProps, useAuth } from \\"@aws-amplify/ui-react/internal\\"; +import { useAuth } from \\"@aws-amplify/ui-react/internal\\"; +import { getOverrideProps } from \\"./utils\\"; import { Button, Flex, Image } from \\"@aws-amplify/ui-react\\"; export default function Profile(props) { var _a, _b; @@ -10915,18 +10633,15 @@ export default function Profile(props) { ) ); } -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibW9kdWxlLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBLG9CQUFvQjtBQUNwQixPQUFPLEtBQUssS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUMvQixPQUFPLEVBQW9CLGdCQUFnQixFQUFFLE9BQU8sRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQzdGLE9BQU8sRUFBRSxNQUFNLEVBQWUsSUFBSSxFQUFhLEtBQUssRUFBYyxNQUFNLHVCQUF1QixDQUFDO0FBVWhHLE1BQU0sQ0FBQyxPQUFPLFVBQVUsT0FBTyxDQUFDLEtBQW1COztJQUMvQyxNQUFNLEVBQUUsU0FBUyxLQUFjLEtBQUssRUFBZCxJQUFJLFVBQUssS0FBSyxFQUE5QixhQUFzQixDQUFRLENBQUM7SUFDckMsTUFBTSxjQUFjLEdBQUcsTUFBQSxNQUFBLE9BQU8sRUFBRSxDQUFDLElBQUksMENBQUUsVUFBVSxtQ0FBSSxFQUFFLENBQUM7SUFDeEQsT0FBTyxDQUFDLG9CQUFDLElBQUksb0JBQUssZ0JBQWdCLENBQUMsU0FBUyxFQUFFLFNBQVMsQ0FBQyxFQUFNLElBQUk7UUFBRSxvQkFBQyxLQUFLLGtCQUFDLEdBQUcsRUFBRSxjQUFjLENBQUMsVUFBVSxDQUFDLElBQU0sZ0JBQWdCLENBQUMsU0FBUyxFQUFFLFFBQVEsQ0FBQyxFQUFVO1FBQUEsb0JBQUMsTUFBTSxrQkFBQyxRQUFRLEVBQUUsY0FBYyxDQUFDLFNBQVMsQ0FBQyxJQUFNLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsRUFBVztRQUFBLG9CQUFDLE1BQU0sa0JBQUMsUUFBUSxFQUFFLGNBQWMsQ0FBQywwQkFBMEIsQ0FBQyxJQUFNLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsRUFBVyxDQUFPLENBQUMsQ0FBQztBQUMvWCxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50LWRpc2FibGUgKi9cbmltcG9ydCAqIGFzIFJlYWN0IGZyb20gXCJyZWFjdFwiO1xuaW1wb3J0IHsgRXNjYXBlSGF0Y2hQcm9wcywgZ2V0T3ZlcnJpZGVQcm9wcywgdXNlQXV0aCB9IGZyb20gXCJAYXdzLWFtcGxpZnkvdWktcmVhY3QvaW50ZXJuYWxcIjtcbmltcG9ydCB7IEJ1dHRvbiwgQnV0dG9uUHJvcHMsIEZsZXgsIEZsZXhQcm9wcywgSW1hZ2UsIEltYWdlUHJvcHMgfSBmcm9tIFwiQGF3cy1hbXBsaWZ5L3VpLXJlYWN0XCI7XG5cbmV4cG9ydCBkZWNsYXJlIHR5cGUgUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxUPiA9IFBhcnRpYWw8VD4gJiBSZWFjdC5ET01BdHRyaWJ1dGVzPEhUTUxEaXZFbGVtZW50PjtleHBvcnQgZGVjbGFyZSB0eXBlIFByb2ZpbGVPdmVycmlkZXNQcm9wcyA9IHtcbiAgICBQcm9maWxlPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxGbGV4UHJvcHM+O1xuICAgIGNoaWxkMT86IFByaW1pdGl2ZU92ZXJyaWRlUHJvcHM8SW1hZ2VQcm9wcz47XG4gICAgY2hpbGQyPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxCdXR0b25Qcm9wcz47XG4gICAgY2hpbGQzPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxCdXR0b25Qcm9wcz47XG59ICYgRXNjYXBlSGF0Y2hQcm9wcztleHBvcnQgdHlwZSBQcm9maWxlUHJvcHMgPSBSZWFjdC5Qcm9wc1dpdGhDaGlsZHJlbjxQYXJ0aWFsPEZsZXhQcm9wcz4gJiB7XG4gICAgb3ZlcnJpZGVzPzogUHJvZmlsZU92ZXJyaWRlc1Byb3BzIHwgdW5kZWZpbmVkIHwgbnVsbDtcbn0+O1xuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gUHJvZmlsZShwcm9wczogUHJvZmlsZVByb3BzKTogUmVhY3QuUmVhY3RFbGVtZW50IHtcbiAgICBjb25zdCB7IG92ZXJyaWRlcywgLi4ucmVzdCB9ID0gcHJvcHM7XG4gICAgY29uc3QgYXV0aEF0dHJpYnV0ZXMgPSB1c2VBdXRoKCkudXNlcj8uYXR0cmlidXRlcyA/PyB7fTtcbiAgICByZXR1cm4gKDxGbGV4IHsuLi5nZXRPdmVycmlkZVByb3BzKG92ZXJyaWRlcywgXCJQcm9maWxlXCIpfSB7Li4ucmVzdH0+PEltYWdlIHNyYz17YXV0aEF0dHJpYnV0ZXNbXCJ1c2VybmFtZVwiXX0gey4uLmdldE92ZXJyaWRlUHJvcHMob3ZlcnJpZGVzLCBcImNoaWxkMVwiKX0+PC9JbWFnZT48QnV0dG9uIGNoaWxkcmVuPXthdXRoQXR0cmlidXRlc1tcInBpY3R1cmVcIl19IHsuLi5nZXRPdmVycmlkZVByb3BzKG92ZXJyaWRlcywgXCJjaGlsZDJcIil9PjwvQnV0dG9uPjxCdXR0b24gY2hpbGRyZW49e2F1dGhBdHRyaWJ1dGVzW1wiY3VzdG9tOmZhdm9yaXRlX2ljZWNyZWFtXCJdfSB7Li4uZ2V0T3ZlcnJpZGVQcm9wcyhvdmVycmlkZXMsIFwiY2hpbGQzXCIpfT48L0J1dHRvbj48L0ZsZXg+KTtcbn0iXX0= +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibW9kdWxlLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBLG9CQUFvQjtBQUNwQixPQUFPLEtBQUssS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUMvQixPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxFQUFvQixnQkFBZ0IsRUFBRSxNQUFNLFNBQVMsQ0FBQztBQUM3RCxPQUFPLEVBQUUsTUFBTSxFQUFlLElBQUksRUFBYSxLQUFLLEVBQWMsTUFBTSx1QkFBdUIsQ0FBQztBQVVoRyxNQUFNLENBQUMsT0FBTyxVQUFVLE9BQU8sQ0FBQyxLQUFtQjs7SUFDL0MsTUFBTSxFQUFFLFNBQVMsS0FBYyxLQUFLLEVBQWQsSUFBSSxVQUFLLEtBQUssRUFBOUIsYUFBc0IsQ0FBUSxDQUFDO0lBQ3JDLE1BQU0sY0FBYyxHQUFHLE1BQUEsTUFBQSxPQUFPLEVBQUUsQ0FBQyxJQUFJLDBDQUFFLFVBQVUsbUNBQUksRUFBRSxDQUFDO0lBQ3hELE9BQU8sQ0FBQyxvQkFBQyxJQUFJLG9CQUFLLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxTQUFTLENBQUMsRUFBTSxJQUFJO1FBQUUsb0JBQUMsS0FBSyxrQkFBQyxHQUFHLEVBQUUsY0FBYyxDQUFDLFVBQVUsQ0FBQyxJQUFNLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsRUFBVTtRQUFBLG9CQUFDLE1BQU0sa0JBQUMsUUFBUSxFQUFFLGNBQWMsQ0FBQyxTQUFTLENBQUMsSUFBTSxnQkFBZ0IsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLEVBQVc7UUFBQSxvQkFBQyxNQUFNLGtCQUFDLFFBQVEsRUFBRSxjQUFjLENBQUMsMEJBQTBCLENBQUMsSUFBTSxnQkFBZ0IsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLEVBQVcsQ0FBTyxDQUFDLENBQUM7QUFDL1gsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qIGVzbGludC1kaXNhYmxlICovXG5pbXBvcnQgKiBhcyBSZWFjdCBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCB7IHVzZUF1dGggfSBmcm9tIFwiQGF3cy1hbXBsaWZ5L3VpLXJlYWN0L2ludGVybmFsXCI7XG5pbXBvcnQgeyBFc2NhcGVIYXRjaFByb3BzLCBnZXRPdmVycmlkZVByb3BzIH0gZnJvbSBcIi4vdXRpbHNcIjtcbmltcG9ydCB7IEJ1dHRvbiwgQnV0dG9uUHJvcHMsIEZsZXgsIEZsZXhQcm9wcywgSW1hZ2UsIEltYWdlUHJvcHMgfSBmcm9tIFwiQGF3cy1hbXBsaWZ5L3VpLXJlYWN0XCI7XG5cbmV4cG9ydCBkZWNsYXJlIHR5cGUgUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxUPiA9IFBhcnRpYWw8VD4gJiBSZWFjdC5ET01BdHRyaWJ1dGVzPEhUTUxEaXZFbGVtZW50PjtleHBvcnQgZGVjbGFyZSB0eXBlIFByb2ZpbGVPdmVycmlkZXNQcm9wcyA9IHtcbiAgICBQcm9maWxlPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxGbGV4UHJvcHM+O1xuICAgIGNoaWxkMT86IFByaW1pdGl2ZU92ZXJyaWRlUHJvcHM8SW1hZ2VQcm9wcz47XG4gICAgY2hpbGQyPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxCdXR0b25Qcm9wcz47XG4gICAgY2hpbGQzPzogUHJpbWl0aXZlT3ZlcnJpZGVQcm9wczxCdXR0b25Qcm9wcz47XG59ICYgRXNjYXBlSGF0Y2hQcm9wcztleHBvcnQgdHlwZSBQcm9maWxlUHJvcHMgPSBSZWFjdC5Qcm9wc1dpdGhDaGlsZHJlbjxQYXJ0aWFsPEZsZXhQcm9wcz4gJiB7XG4gICAgb3ZlcnJpZGVzPzogUHJvZmlsZU92ZXJyaWRlc1Byb3BzIHwgdW5kZWZpbmVkIHwgbnVsbDtcbn0+O1xuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gUHJvZmlsZShwcm9wczogUHJvZmlsZVByb3BzKTogUmVhY3QuUmVhY3RFbGVtZW50IHtcbiAgICBjb25zdCB7IG92ZXJyaWRlcywgLi4ucmVzdCB9ID0gcHJvcHM7XG4gICAgY29uc3QgYXV0aEF0dHJpYnV0ZXMgPSB1c2VBdXRoKCkudXNlcj8uYXR0cmlidXRlcyA/PyB7fTtcbiAgICByZXR1cm4gKDxGbGV4IHsuLi5nZXRPdmVycmlkZVByb3BzKG92ZXJyaWRlcywgXCJQcm9maWxlXCIpfSB7Li4ucmVzdH0+PEltYWdlIHNyYz17YXV0aEF0dHJpYnV0ZXNbXCJ1c2VybmFtZVwiXX0gey4uLmdldE92ZXJyaWRlUHJvcHMob3ZlcnJpZGVzLCBcImNoaWxkMVwiKX0+PC9JbWFnZT48QnV0dG9uIGNoaWxkcmVuPXthdXRoQXR0cmlidXRlc1tcInBpY3R1cmVcIl19IHsuLi5nZXRPdmVycmlkZVByb3BzKG92ZXJyaWRlcywgXCJjaGlsZDJcIil9PjwvQnV0dG9uPjxCdXR0b24gY2hpbGRyZW49e2F1dGhBdHRyaWJ1dGVzW1wiY3VzdG9tOmZhdm9yaXRlX2ljZWNyZWFtXCJdfSB7Li4uZ2V0T3ZlcnJpZGVQcm9wcyhvdmVycmlkZXMsIFwiY2hpbGQzXCIpfT48L0J1dHRvbj48L0ZsZXg+KTtcbn0iXX0= " `; exports[`amplify render tests user specific attributes should render user specific attributes 1`] = ` "/* eslint-disable */ import * as React from \\"react\\"; -import { - EscapeHatchProps, - getOverrideProps, - useAuth, -} from \\"@aws-amplify/ui-react/internal\\"; +import { useAuth } from \\"@aws-amplify/ui-react/internal\\"; +import { EscapeHatchProps, getOverrideProps } from \\"./utils\\"; import { Button, ButtonProps, 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 466f3357a..16de067bf 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 @@ -2,6 +2,83 @@ exports[`render utils file render all 1`] = ` "/* eslint-disable */ +export const findChildOverrides = (overrides, elementHierarchy) => { + 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, + })) + ); +}; +export const getOverrideProps = (overrides, elementHierarchy) => { + 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); +}; +export function getOverridesFromVariants(variants, props) { + const variantValueKeys = [ + ...new Set( + variants.flatMap((variant) => Object.keys(variant.variantValues)) + ), + ]; + const variantValuesFromProps = 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 mergeVariantsAndOverrides = (variants, overrides) => { + 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 validateField = (value, validations) => { for (const validation of validations) { if (value === undefined || value === \\"\\" || value === null) { diff --git a/packages/codegen-ui-react/lib/imports/import-mapping.ts b/packages/codegen-ui-react/lib/imports/import-mapping.ts index d383134a5..548382bf3 100644 --- a/packages/codegen-ui-react/lib/imports/import-mapping.ts +++ b/packages/codegen-ui-react/lib/imports/import-mapping.ts @@ -60,33 +60,33 @@ export enum ImportValue { } export const ImportMapping: Record = { + [ImportValue.API]: ImportSource.AMPLIFY, + [ImportValue.GENERATE_CLIENT]: ImportSource.AMPLIFY_API, + [ImportValue.SORT_DIRECTION]: ImportSource.AMPLIFY_DATASTORE, + [ImportValue.SORT_PREDICATE]: ImportSource.AMPLIFY_DATASTORE, [ImportValue.CREATE_THEME]: ImportSource.UI_REACT, [ImportValue.DEFAULT_THEME]: ImportSource.UI_REACT, - [ImportValue.ESCAPE_HATCH_PROPS]: ImportSource.UI_REACT_INTERNAL, - [ImportValue.GET_OVERRIDE_PROPS]: ImportSource.UI_REACT_INTERNAL, - [ImportValue.USE_AUTH]: ImportSource.UI_REACT_INTERNAL, - [ImportValue.GET_OVERRIDES_FROM_VARIANTS]: ImportSource.UI_REACT_INTERNAL, + [ImportValue.PAGINATION]: ImportSource.UI_REACT, + [ImportValue.PLACEHOLDER]: ImportSource.UI_REACT, [ImportValue.USE_BREAKPOINT_VALUE]: ImportSource.UI_REACT, - [ImportValue.VARIANT]: ImportSource.UI_REACT_INTERNAL, + [ImportValue.USE_AUTH]: ImportSource.UI_REACT_INTERNAL, [ImportValue.CREATE_DATA_STORE_PREDICATE]: ImportSource.UI_REACT_INTERNAL, [ImportValue.USE_DATA_STORE_BINDING]: ImportSource.UI_REACT_INTERNAL, - [ImportValue.SORT_DIRECTION]: ImportSource.AMPLIFY_DATASTORE, - [ImportValue.SORT_PREDICATE]: ImportSource.AMPLIFY_DATASTORE, - [ImportValue.MERGE_VARIANTS_OVERRIDES]: ImportSource.UI_REACT_INTERNAL, [ImportValue.USE_NAVIGATE_ACTION]: ImportSource.UI_REACT_INTERNAL, [ImportValue.USE_DATA_STORE_CREATE_ACTION]: ImportSource.UI_REACT_INTERNAL, [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.USE_STATE_MUTATION_ACTION]: ImportSource.UI_REACT_INTERNAL, - [ImportValue.USE_EFFECT]: ImportSource.REACT, + [ImportValue.ESCAPE_HATCH_PROPS]: ImportSource.UTILS, + [ImportValue.GET_OVERRIDE_PROPS]: ImportSource.UTILS, + [ImportValue.MERGE_VARIANTS_OVERRIDES]: ImportSource.UTILS, + [ImportValue.GET_OVERRIDES_FROM_VARIANTS]: ImportSource.UTILS, + [ImportValue.VARIANT]: ImportSource.UTILS, [ImportValue.FORMATTER]: ImportSource.UTILS, [ImportValue.VALIDATE_FIELD]: ImportSource.UTILS, [ImportValue.FETCH_BY_PATH]: ImportSource.UTILS, [ImportValue.PROCESS_FILE]: ImportSource.UTILS, + [ImportValue.USE_EFFECT]: ImportSource.REACT, [ImportValue.USE_STATE]: ImportSource.REACT, - [ImportValue.API]: ImportSource.AMPLIFY, - [ImportValue.PAGINATION]: ImportSource.UI_REACT, - [ImportValue.PLACEHOLDER]: ImportSource.UI_REACT, - [ImportValue.GENERATE_CLIENT]: ImportSource.AMPLIFY_API, }; diff --git a/packages/codegen-ui-react/lib/index.ts b/packages/codegen-ui-react/lib/index.ts index 7e466532d..0625eeb9f 100644 --- a/packages/codegen-ui-react/lib/index.ts +++ b/packages/codegen-ui-react/lib/index.ts @@ -30,5 +30,6 @@ export * from './react-index-studio-template-renderer'; export * from './react-utils-studio-template-renderer'; export * from './react-required-dependency-provider'; export * from './utils/forms/validation'; +export * from './overrides'; export { fetchByPath } from './utils/json-path-fetch'; export { processFile } from './utils/storage-manager'; diff --git a/packages/codegen-ui-react/lib/overrides/__tests__/getOverrideProps.test.tsx b/packages/codegen-ui-react/lib/overrides/__tests__/getOverrideProps.test.tsx new file mode 100644 index 000000000..beadd3724 --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/__tests__/getOverrideProps.test.tsx @@ -0,0 +1,58 @@ +/* + 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 '../getOverrideProps'; + +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/overrides/__tests__/getOverridesFromVariants.test.tsx b/packages/codegen-ui-react/lib/overrides/__tests__/getOverridesFromVariants.test.tsx new file mode 100644 index 000000000..906aa1948 --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/__tests__/getOverridesFromVariants.test.tsx @@ -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 type { Variant } from '../types'; +import { getOverridesFromVariants } from '../getOverridesFromVariants'; + +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/overrides/__tests__/mergeVariantsAndOverrides.test.tsx b/packages/codegen-ui-react/lib/overrides/__tests__/mergeVariantsAndOverrides.test.tsx new file mode 100644 index 000000000..a5cb6b625 --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/__tests__/mergeVariantsAndOverrides.test.tsx @@ -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 type { EscapeHatchProps } from '../types'; +import { mergeVariantsAndOverrides } from '../mergeVariantsAndOverrides'; + +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/overrides/findChildOverrides.ts b/packages/codegen-ui-react/lib/overrides/findChildOverrides.ts new file mode 100644 index 000000000..f2ba8fb7f --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/findChildOverrides.ts @@ -0,0 +1,242 @@ +/* + 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 new file mode 100644 index 000000000..ad4ccc530 --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/getOverrideProps.ts @@ -0,0 +1,248 @@ +/* + 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 new file mode 100644 index 000000000..b2979f99f --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/getOverridesFromVariants.ts @@ -0,0 +1,496 @@ +/* + 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/index.ts b/packages/codegen-ui-react/lib/overrides/index.ts new file mode 100644 index 000000000..c2af9e09e --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/index.ts @@ -0,0 +1,21 @@ +/* + 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, 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'; diff --git a/packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts b/packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts new file mode 100644 index 000000000..5a5b5fc01 --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/mergeVariantsAndOverrides.ts @@ -0,0 +1,286 @@ +/* + 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 new file mode 100644 index 000000000..ad22f5b98 --- /dev/null +++ b/packages/codegen-ui-react/lib/overrides/types.ts @@ -0,0 +1,104 @@ +/* + 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-component-renderer.ts b/packages/codegen-ui-react/lib/react-component-renderer.ts index e778c1561..50d830719 100644 --- a/packages/codegen-ui-react/lib/react-component-renderer.ts +++ b/packages/codegen-ui-react/lib/react-component-renderer.ts @@ -89,7 +89,7 @@ export class ReactComponentRenderer extends ComponentRendererBase< if (this.component.componentType === 'StorageField') { this.importCollection.addImport(ImportSource.REACT_STORAGE, 'StorageManager'); this.importCollection.addImport(ImportSource.UI_REACT_INTERNAL, 'Field'); - this.importCollection.addImport(ImportSource.UI_REACT_INTERNAL, ImportValue.GET_OVERRIDE_PROPS); + this.importCollection.addMappedImport(ImportValue.GET_OVERRIDE_PROPS); this.importCollection.addImport(ImportSource.UTILS, 'processFile'); return renderStorageFieldComponent( this.component, 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 b932f2e00..ebbfed888 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 @@ -16,7 +16,7 @@ import { EOL } from 'os'; import ts, { EmitHint } from 'typescript'; import { StudioTemplateRenderer } from '@aws-amplify/codegen-ui'; -import { ReactRenderConfig, scriptKindToFileExtensionNonReact } from './react-render-config'; +import { ReactRenderConfig, scriptKindToFileExtension } from './react-render-config'; import { ImportCollection } from './imports'; import { ReactOutputManager } from './react-output-manager'; import { transpile, buildPrinter, defaultRenderConfig } from './react-studio-template-renderer-helper'; @@ -24,6 +24,13 @@ 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 { + buildEscapeHatchAndVariantTypes, + buildFindChildOverrides, + buildGetOverrideProps, + buildGetOverridesFromVariants, + buildMergeVariantsAndOverrides, +} from './overrides'; export type UtilTemplateType = 'validation' | 'formatter' | 'fetchByPath' | 'processFile'; @@ -55,12 +62,18 @@ export class ReactUtilsStudioTemplateRenderer extends StudioTemplateRenderer< ...renderConfig, renderTypeDeclarations: false, // Never render type declarations for index.js|ts file. }; - this.fileName = `utils.${scriptKindToFileExtensionNonReact(this.renderConfig.script)}`; + this.fileName = `utils.${scriptKindToFileExtension(this.renderConfig.script)}`; } renderComponentInternal() { const { printer, file } = buildPrinter(this.fileName, this.renderConfig); - const utilsStatements: (ts.VariableStatement | ts.TypeAliasDeclaration | ts.FunctionDeclaration)[] = []; + const utilsStatements: (ts.VariableStatement | ts.TypeAliasDeclaration | ts.FunctionDeclaration)[] = [ + ...buildEscapeHatchAndVariantTypes(), + ...buildFindChildOverrides(), + ...buildGetOverrideProps(), + ...buildGetOverridesFromVariants(), + ...buildMergeVariantsAndOverrides(), + ]; const skipReactImport = true; const utilsSet = new Set(this.utils);