Skip to content

Commit

Permalink
docs: story form not resetable for list field
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroslavPetrik committed Dec 4, 2023
1 parent 9f97f99 commit fa2b810
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 0 additions & 10 deletions src/components/list-field/Docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ const Example = () => (
- ✅ Handles adding and removal of array items.
- ✅ Supports deeply nested arrays in arrays.

## Usage

```ts
import { ListField } from "@form-atoms/field";
```

### Props

<Controls of={ListFieldStories.Primary} sort="requiredFirst" />

## Examples

### Flat
Expand Down
6 changes: 6 additions & 0 deletions src/components/list-field/ListField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const Primary = formStory({
},
},
args: {
resettable: false,
fields: {
envVars: envVarsBuilder([
{ variable: "GITHUB_TOKEN", value: "ff52d09a" },
Expand Down Expand Up @@ -92,6 +93,7 @@ export const Flat = formStory({
},
},
args: {
resettable: false,
fields: {
benefits: typescriptBenefits(["safe function calls", "it's fast"]),
},
Expand Down Expand Up @@ -138,6 +140,7 @@ export const Prepend = formStory({
},
},
args: {
resettable: false,
fields: {
hobbies: [fieldAtom({ value: "gardening" })],
},
Expand Down Expand Up @@ -179,6 +182,7 @@ export const Ordering = formStory({
},
},
args: {
resettable: false,
fields: {
hobbies: [fieldAtom({ value: "gardening" })],
},
Expand Down Expand Up @@ -215,6 +219,7 @@ export const Ordering = formStory({

export const Nested = formStory({
args: {
resettable: false,
fields: {
people: [
{
Expand Down Expand Up @@ -296,6 +301,7 @@ export const Nested = formStory({

export const WithRadioControl = formStory({
args: {
resettable: false,
fields: {
phones: [
{
Expand Down
10 changes: 7 additions & 3 deletions src/scenarios/StoryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RenderProp } from "react-render-prop-type";

type Props<Fields extends FormFields> = {
fields: Fields;
resettable?: boolean;
required?: boolean;
} & RenderProp<{
form: FormAtom<Fields>;
Expand All @@ -14,6 +15,7 @@ type Props<Fields extends FormFields> = {
}>;

export const StoryForm = <Fields extends FormFields>({
resettable = true,
fields,
children,
required = true,
Expand All @@ -25,9 +27,11 @@ export const StoryForm = <Fields extends FormFields>({
<form onSubmit={submit(action("submit"))}>
{children({ fields, required, form })}
<button>Submit</button>
<button className="outline secondary" type="button" onClick={reset}>
Reset
</button>
{resettable && (
<button className="outline secondary" type="button" onClick={reset}>
Reset
</button>
)}
</form>
);
};
Expand Down

0 comments on commit fa2b810

Please sign in to comment.