{"id":15627726,"url":"https://github.com/fabienjuif/from-form-submit","last_synced_at":"2025-07-09T17:37:11.085Z","repository":{"id":37952430,"uuid":"201215905","full_name":"fabienjuif/from-form-submit","owner":"fabienjuif","description":"Simply convert a form submit event to a Javascript object","archived":false,"fork":false,"pushed_at":"2023-01-07T04:25:06.000Z","size":856,"stargazers_count":2,"open_issues_count":24,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T12:42:02.530Z","etag":null,"topics":["browser","convert","event","form","light","object","submit","tiny"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabienjuif.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-08T08:39:09.000Z","updated_at":"2021-02-23T09:10:29.000Z","dependencies_parsed_at":"2023-02-06T11:46:16.169Z","dependency_job_id":null,"html_url":"https://github.com/fabienjuif/from-form-submit","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabienjuif%2Ffrom-form-submit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabienjuif%2Ffrom-form-submit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabienjuif%2Ffrom-form-submit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabienjuif%2Ffrom-form-submit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabienjuif","download_url":"https://codeload.github.com/fabienjuif/from-form-submit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247569123,"owners_count":20959758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","convert","event","form","light","object","submit","tiny"],"created_at":"2024-10-03T10:19:05.685Z","updated_at":"2025-04-06T23:33:12.236Z","avatar_url":"https://github.com/fabienjuif.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# from-form-submit\n\n\u003e Simply convert a form submit event to a Javascript object\n\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/from-form-submit) ![npm](https://img.shields.io/npm/v/from-form-submit) [![Coverage Status](https://coveralls.io/repos/github/fabienjuif/from-form-submit/badge.svg)](https://coveralls.io/github/fabienjuif/from-form-submit)\n\n## Features\n\n- Convert input values by looking at their types\n  - date\n  - number\n  - text\n  - checkbox\n- Support arrays (eg: `name=\"values.0.name\"` will be converted as `{ values: [{ name }] }`)\n- Vanilla JS, meaning it should work with all frameworks!\n- Prevent the default form submit behaviour\n\n## API\n\n- `fromEvent(event: SubmitEvent, starter: Object): Object`: convert the submit event ̀`event` to a Javascript object\n\n  - types are casted when we can\n  - inputs must have a `name` attribute for this to work\n  - you can give a `starter` object, in which case this object will be copied and then populated with the form informations\n\n- `wrapSubmit(callback: Function, starter: Object): Function`: wrap your implementation before giving it to your \"submit\" callback form\n  - this function catch the form event, then calls ̀formEvent to retrieve data, then calls your callback with it\n  - `callback(data: object, event: window.Event): void`\n\n## Examples (ReactJS)\n\n**fromEvent**\n\n```js\nimport React from 'react'\nimport { fromEvent } from 'from-form-submit'\n\nconst Component = () =\u003e (\n  \u003cform\n    onSubmit={(event) =\u003e {\n      console.log(fromEvent(event))\n    }}\n  \u003e\n    \u003cinput type=\"number\" name=\"age\" /\u003e\n    \u003cinput type=\"string\" name=\"name\" /\u003e\n  \u003c/form\u003e\n)\n```\n\n**wrapSubmit**\n\n```js\nimport React from 'react'\nimport { wrapSubmit } from 'from-form-submit'\n\nconst Component = () =\u003e (\n  \u003cform onSubmit={wrapSubmit(console.log)}\u003e\n    \u003cinput type=\"number\" name=\"age\" /\u003e\n    \u003cinput type=\"string\" name=\"name\" /\u003e\n  \u003c/form\u003e\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabienjuif%2Ffrom-form-submit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabienjuif%2Ffrom-form-submit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabienjuif%2Ffrom-form-submit/lists"}