{"id":19273911,"url":"https://github.com/rintoj/native-x-form","last_synced_at":"2026-05-16T04:42:41.748Z","repository":{"id":46384089,"uuid":"335877317","full_name":"rintoj/native-x-form","owner":"rintoj","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-18T09:52:07.000Z","size":154,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T21:40:41.249Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/rintoj.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":"2021-02-04T07:43:39.000Z","updated_at":"2021-10-18T09:51:01.000Z","dependencies_parsed_at":"2022-09-26T17:51:34.534Z","dependency_job_id":null,"html_url":"https://github.com/rintoj/native-x-form","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fnative-x-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fnative-x-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fnative-x-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Fnative-x-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rintoj","download_url":"https://codeload.github.com/rintoj/native-x-form/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240378873,"owners_count":19792039,"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":[],"created_at":"2024-11-09T20:44:27.973Z","updated_at":"2026-05-16T04:42:36.708Z","avatar_url":"https://github.com/rintoj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# native-x-form\n\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\nThis component helps you add and manage form in react native\n\n## Install\n\n### Yarn\n\n```sh\nyarn add native-x-form\n```\n\n### NPM\n\n```sh\nnpm install native-x-form\n```\n\n## Usage\n\n```tsx\nimport { Form, FormItem, isEmpty, isInvalidEmail } from 'native-x-form'\nimport { Button } from 'native-x-button'\nimport { TextInput } from 'native-x-text-input'\nimport { Stack } from 'native-x-stack'\n\ninterface FormData {\n  email: string\n  password: string\n}\n\nconst state: FormData = {\n  email: '',\n  password: '',\n}\n\nfunction MyComponent() {\n  const onSubmit = useCallback(\n    async ({ state: { email, password }, isValid }: { state: FormData; isValid: boolean }) =\u003e {\n      if (!isValid) {\n        return\n      }\n      // your logic\n    },\n    [],\n  )\n\n  return (\n    \u003cForm\u003cFormData\u003e state={state} onSubmit={onSubmit}\u003e\n      {({ submitForm }) =\u003e (\n        \u003cStack\u003e\n          \u003cFormItem name='email' validators={[isEmpty('Email is required'), isInvalidEmail()]}\u003e\n            \u003cTextInput /\u003e\n          \u003c/FormItem\u003e\n          \u003cButton onTap={submitForm}\u003eSubmit\u003c/Button\u003e\n        \u003c/Stack\u003e\n      )}\n    \u003c/Form\u003e\n  )\n}\n```\n\nAny component can be placed inside `FormItem` as long as the props are extended from `FormChildProp`\n\n```tsx\nexport type AcceptableFormValue = string | boolean | number\n\ntype FormChildProp\u003cT extends AcceptableFormValue\u003e = {\n  value?: T\n  onChange?: (value: T) =\u003e void\n  onChangeText?: (value: T) =\u003e void\n  onBlur?: () =\u003e void\n  error?: string | Error | null\n  isLoading?: boolean\n}\n```\n\nSample implementation:\n\n```tsx\nimport { FormChildProps } from 'native-x-form'\n\ninterface InputProps extends FormChildProps\u003cstring\u003e {\n  ...\n}\n\nfunction Input(props: InputProps) {\n  const {\n    value,\n    onChange,\n    onChangeText,\n    onBlur,\n    error,\n    isLoading\n  } = props\n  return (\n    ...\n  )\n}\n```\n\n## API - Form\n\n| Property                                                          | Default Value | Usage                               |\n| ----------------------------------------------------------------- | ------------- | ----------------------------------- |\n| state?: T                                                         | any           | State of the form                   |\n| submitIfValid?: boolean                                           | true          | Call onSubmit only if form is valid |\n| children?: ReactNode[]                                            |               | Content of the form                 |\n| onSubmit?: (props: { state: T, isValid: boolean}) =\u003e Promise\u003cany\u003e |               | Handler for submitting the form     |\n| onChange?: (props: { state: T, isValid: boolean}) =\u003e Promise\u003cany\u003e |               | Event handler for change            |\n\n## API - Form-Item\n\n| Property                   | Default Value | Usage                                                |\n| -------------------------- | ------------- | ---------------------------------------------------- |\n| name: string               | any           | Name of the item in `state`. This input is mandatory |\n| children?: ReactNode[]     |               | Content of the form                                  |\n| validators: Validator\u003cT\u003e[] |               | An array of validators                               |\n\n## Validators\n\nYou can build a custom validator function by implementing `Validator\u003cT\u003e` type\n\n```tsx\nexport type Validator\u003cT\u003e = (input: T) =\u003e string | undefined\n```\n\nThe return value of `Validator` function must be the error message.\n\nFew validator function creators are provided with this module.\n\n```tsx\nisEmpty(errorMessage: string): Validator\u003cT\u003e\nisInvalidEmail(errorMessage: string): Validator\u003cT\u003e\nisNonAlphaNumeric(errorMessage: string): Validator\u003cT\u003e\n```\n\n## Automatic Release\n\nHere is an example of the release type that will be done based on a commit messages:\n\n| Commit message      | Release type          |\n| ------------------- | --------------------- |\n| fix: [comment]      | Patch Release         |\n| feat: [comment]     | Minor Feature Release |\n| perf: [comment]     | Major Feature Release |\n| doc: [comment]      | No Release            |\n| refactor: [comment] | No Release            |\n| chore: [comment]    | No Release            |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frintoj%2Fnative-x-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frintoj%2Fnative-x-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frintoj%2Fnative-x-form/lists"}