-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,235 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
packages/react/spec/auto/form/PolarisAutoRelationshipForm.stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { AppProvider, Card, Page, Text } from "@shopify/polaris"; | ||
import translations from "@shopify/polaris/locales/en.json"; | ||
import React from "react"; | ||
import { Provider } from "../../../src/GadgetProvider.tsx"; | ||
import { PolarisAutoForm } from "../../../src/auto/polaris/PolarisAutoForm.tsx"; | ||
import { PolarisAutoInput } from "../../../src/auto/polaris/inputs/PolarisAutoInput.tsx"; | ||
import { PolarisAutoBelongsToInput } from "../../../src/auto/polaris/inputs/relationships/PolarisAutoBelongsToInput.tsx"; | ||
import { PolarisAutoRelationshipForm } from "../../../src/auto/polaris/inputs/relationships/PolarisAutoRelationshipForm.tsx"; | ||
import { PolarisAutoSubmit } from "../../../src/auto/polaris/submit/PolarisAutoSubmit.tsx"; | ||
import { FormProvider, useForm } from "../../../src/useActionForm.ts"; | ||
import { testApi as api } from "../../apis.ts"; | ||
|
||
const ExampleWidgetAutoRelatedForm = (props) => { | ||
return ( | ||
<Page> | ||
<PolarisAutoForm {...props}> | ||
<Card> | ||
<Text as="h2" variant="headingSm"> | ||
Top Level Form -- Widget | ||
</Text> | ||
<PolarisAutoInput field="name" /> | ||
<PolarisAutoInput field="description" /> | ||
<PolarisAutoInput field="inventoryCount" /> | ||
</Card> | ||
|
||
<Card> | ||
<Text as="h2" variant="headingSm"> | ||
Belongs To Form -- Section | ||
</Text> | ||
<PolarisAutoBelongsToInput field="section" optionLabel="id" /> | ||
</Card> | ||
|
||
<Card> | ||
<Text as="h2" variant="headingSm"> | ||
Has Many Form -- Gizmos | ||
</Text> | ||
<PolarisAutoRelationshipForm | ||
field="gizmos" | ||
selectPaths={["name", "orientation"]} | ||
primaryLabel="name" | ||
secondaryLabel="orientation" | ||
> | ||
<PolarisAutoInput field="name" /> | ||
<PolarisAutoInput field="orientation" /> | ||
<PolarisAutoInput field="attachment" /> | ||
</PolarisAutoRelationshipForm> | ||
</Card> | ||
<PolarisAutoSubmit /> | ||
</PolarisAutoForm> | ||
</Page> | ||
); | ||
}; | ||
|
||
const ExampleSectionAutoRelatedForm = (props) => { | ||
return ( | ||
<Page> | ||
<PolarisAutoForm {...props}> | ||
<Card> | ||
<Text as="h2" variant="headingSm"> | ||
Top Level Form -- Section | ||
</Text> | ||
<PolarisAutoInput field="name" /> | ||
<PolarisAutoInput field="label" /> | ||
</Card> | ||
|
||
<Card> | ||
<Text as="h2" variant="headingSm"> | ||
Has Many Form -- Widgets | ||
</Text> | ||
<PolarisAutoRelationshipForm field="widgets"> | ||
<PolarisAutoInput field="name" /> | ||
<PolarisAutoInput field="inventoryCount" /> | ||
</PolarisAutoRelationshipForm> | ||
</Card> | ||
<PolarisAutoSubmit /> | ||
</PolarisAutoForm> | ||
</Page> | ||
); | ||
}; | ||
|
||
export default { | ||
title: "Polaris/AutoForm/AutoRelationshipForm", | ||
component: ExampleWidgetAutoRelatedForm, | ||
decorators: [ | ||
(Story) => { | ||
return ( | ||
<Provider api={api}> | ||
<AppProvider i18n={translations}> | ||
<FormProvider {...useForm()}> | ||
<Story /> | ||
</FormProvider> | ||
</AppProvider> | ||
</Provider> | ||
); | ||
}, | ||
], | ||
}; | ||
|
||
export const Create = { | ||
args: { | ||
action: api.widget.create, | ||
}, | ||
}; | ||
|
||
export const Update = { | ||
args: { | ||
action: api.widget.update, | ||
findBy: "1", | ||
}, | ||
}; | ||
|
||
export const CreateWithLargeHasMany = { | ||
render: (args) => <ExampleSectionAutoRelatedForm {...args} />, | ||
args: { | ||
action: api.section.create, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.