Skip to content

Commit

Permalink
Merge pull request #136 from katywings/feat-submit-helper
Browse files Browse the repository at this point in the history
Add form submit method #130
  • Loading branch information
fabian-hiller committed Sep 30, 2023
2 parents 23b619d + cd29b29 commit 8639ba1
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/preact/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the library will be documented in this file.

## vX.X.X (Month DD, YYYY)

- Add `submit` method (issue #130, pull request #136)

## v0.6.2 (August 23, 2023)

- Fix `valiField` and `valiForm` adapter for Valibot v0.13.0
Expand Down
1 change: 1 addition & 0 deletions packages/preact/src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export * from './setError';
export * from './setResponse';
export * from './setValue';
export * from './setValues';
export * from './submit';
export * from './swap';
export * from './validate';
13 changes: 13 additions & 0 deletions packages/preact/src/methods/submit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FieldValues, FormStore, ResponseData } from '../types';

/**
* Validates and submits the form.
*
* @param form The form to be submitted.
*/
export function submit<
TFieldValues extends FieldValues,
TResponseData extends ResponseData
>(form: FormStore<TFieldValues, TResponseData>): void {
form.element.peek()?.requestSubmit();
}
4 changes: 4 additions & 0 deletions packages/qwik/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the library will be documented in this file.

## vX.X.X (Month DD, YYYY)

- Add `submit` method (issue #130, pull request #136)

## v0.20.2 (August 23, 2023)

- Fix `valiField$` and `valiForm$` adapter for Valibot v0.13.0
Expand Down
1 change: 1 addition & 0 deletions packages/qwik/src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export * from './setError';
export * from './setResponse';
export * from './setValue';
export * from './setValues';
export * from './submit';
export * from './swap';
export * from './validate';
13 changes: 13 additions & 0 deletions packages/qwik/src/methods/submit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FieldValues, FormStore, ResponseData } from '../types';

/**
* Validates and submits the form.
*
* @param form The form to be submitted.
*/
export function submit<
TFieldValues extends FieldValues,
TResponseData extends ResponseData
>(form: FormStore<TFieldValues, TResponseData>): void {
form.element?.requestSubmit();
}
4 changes: 4 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the library will be documented in this file.

## vX.X.X (Month DD, YYYY)

- Add `submit` method (issue #130, pull request #136)

## v0.5.2 (August 23, 2023)

- Fix `valiField` and `valiForm` adapter for Valibot v0.13.0
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export * from './setError';
export * from './setResponse';
export * from './setValue';
export * from './setValues';
export * from './submit';
export * from './swap';
export * from './validate';
13 changes: 13 additions & 0 deletions packages/react/src/methods/submit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FieldValues, FormStore, ResponseData } from '../types';

/**
* Validates and submits the form.
*
* @param form The form to be submitted.
*/
export function submit<
TFieldValues extends FieldValues,
TResponseData extends ResponseData
>(form: FormStore<TFieldValues, TResponseData>): void {
form.element.peek()?.requestSubmit();
}
4 changes: 4 additions & 0 deletions packages/solid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the library will be documented in this file.

## vX.X.X (Month DD, YYYY)

- Add `submit` method (issue #130, pull request #136)

## v0.19.2 (August 23, 2023)

- Fix `valiField$` and `valiForm$` adapter for Valibot v0.13.0
Expand Down
1 change: 1 addition & 0 deletions packages/solid/src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export * from './setError';
export * from './setResponse';
export * from './setValue';
export * from './setValues';
export * from './submit';
export * from './swap';
export * from './validate';
14 changes: 14 additions & 0 deletions packages/solid/src/methods/submit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { untrack } from 'solid-js';
import type { FieldValues, FormStore, ResponseData } from '../types';

/**
* Validates and submits the form.
*
* @param form The form to be submitted.
*/
export function submit<
TFieldValues extends FieldValues,
TResponseData extends ResponseData
>(form: FormStore<TFieldValues, TResponseData>): void {
untrack(() => form.element)?.requestSubmit();
}
24 changes: 24 additions & 0 deletions website/public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,12 @@
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/solid/api/submit</loc>
<lastmod>2023-09-21</lastmod>
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/solid/api/swap</loc>
<lastmod>2023-05-18</lastmod>
Expand Down Expand Up @@ -1041,6 +1047,12 @@
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/qwik/api/submit</loc>
<lastmod>2023-09-21</lastmod>
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/qwik/api/swap</loc>
<lastmod>2023-05-18</lastmod>
Expand Down Expand Up @@ -1493,6 +1505,12 @@
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/preact/api/submit</loc>
<lastmod>2023-09-21</lastmod>
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/preact/api/swap</loc>
<lastmod>2023-05-18</lastmod>
Expand Down Expand Up @@ -1915,6 +1933,12 @@
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/react/api/submit</loc>
<lastmod>2023-09-21</lastmod>
<priority>0.40</priority>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://modularforms.dev/react/api/swap</loc>
<lastmod>2023-05-24</lastmod>
Expand Down
1 change: 1 addition & 0 deletions website/src/routes/(layout)/[framework]/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function ApiLayout() {
'setResponse',
'setValue',
'setValues',
'submit',
'swap',
'validate',
],
Expand Down
26 changes: 26 additions & 0 deletions website/src/routes/(layout)/[framework]/api/submit.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Description, Property, Title } from '~/components';

<Title>submit</Title>
<Description>Validates and submits the specified form.</Description>

# submit

Validates and submits the specified form.

```ts
submit(form);
```

## Parameters

- `form` <Property {...properties.form} />

export const properties = {
form: {
type: {
type: 'custom',
name: 'FormStore',
href: '../FormStore',
},
},
};

0 comments on commit 8639ba1

Please sign in to comment.