{"id":25510219,"url":"https://github.com/yayoc/react-textfield","last_synced_at":"2025-04-10T14:56:38.913Z","repository":{"id":57346330,"uuid":"79634390","full_name":"yayoc/react-textfield","owner":"yayoc","description":"Elegant text filed of React Component","archived":false,"fork":false,"pushed_at":"2017-07-17T13:03:34.000Z","size":900,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T20:41:28.124Z","etag":null,"topics":["component","demo","input","npm","props","react","storybook","textfield"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yayoc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-21T08:45:33.000Z","updated_at":"2019-11-01T02:28:41.000Z","dependencies_parsed_at":"2022-09-18T11:02:02.740Z","dependency_job_id":null,"html_url":"https://github.com/yayoc/react-textfield","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Freact-textfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Freact-textfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Freact-textfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yayoc%2Freact-textfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yayoc","download_url":"https://codeload.github.com/yayoc/react-textfield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248239649,"owners_count":21070772,"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":["component","demo","input","npm","props","react","storybook","textfield"],"created_at":"2025-02-19T09:28:47.387Z","updated_at":"2025-04-10T14:56:38.491Z","avatar_url":"https://github.com/yayoc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-textfield \u003csup\u003e\n[![npm version](https://badge.fury.io/js/react-textfield.svg)](https://badge.fury.io/js/react-textfield)\n[![Build Status](https://travis-ci.org/yayoc/react-textfield.svg?branch=master)](https://travis-ci.org/yayoc/react-textfield)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\u003c/sup\u003e\n\n[![NPM](https://nodei.co/npm/react-textfield.png)](https://nodei.co/npm/react-textfield/)\n\n![react-textfield in demo](https://raw.githubusercontent.com/yayoc/react-textfield/master/react-textfield-demo.gif)\n\n\n\u003e Elegant textfield of React Component.\n\n## Live Playground\n\nFor examples of the react-textfield in action, go to http://blog.yayoc.com/react-textfield.\n\nOR\n\nTo run that demo on your own computer:\n* Clone this repository\n* `npm install`\n* `npm run storybook`\n* Visit http://localhost:9001/\n\n## Getting Started\n#### Install dependencies\nEnsure packages are installed with correct version numbers by running:\n```sh\n(\n  export PKG=react-textfield;\n  npm info \"$PKG\" peerDependencies --json | command sed 's/[\\{\\},]//g ; s/: /@/g; s/ *//g' | xargs npm install --save \"$PKG\"\n)\n```\n\nWhich produces and runs a command like:\n\n```sh\nnpm install --save react-textfield\n```\n\n#### Include component\n```js\nimport { TextField, validator } from 'react-textfield';\n```\n\n#### Make some elegant textfield\n```jsx\n\u003cReactTextField\n  name=\"username\"\n  type=\"text\"\n  placeholder=\"username\"\n  validators={usernameValidators}\n  successMessage=\"This Username is available.\"\n/\u003e\n```\n\n## API\n\nWe have one component and validators for all of your textfield needs.\n\n### `ReactTextField`\n\nThis `controlled components` is designed to make input textfield with some messages easily.   \nWe will make accessible and convenient form for end-users by showing appropriate success or error messages.  \n\n#### `props`\n\n**Type:**\nThis props will pass as a type attribute of Input tag.  \n\n```js\ntype: PropTypes.oneOf([\n  'text',\n  'password',\n  'email',\n  'tel',\n  'url',\n])\n```\n\n**Name:**\nThis props will pass as a name attribute of Input tag.  \n**If you are using multiple components, This props must be unique.**\n\n**Validators:**\nThis props is array of `validator object` which contains both `error message` and `handler` as properties.  \nArgs of the handler is *string value* ( text field value ), Return value is *boolean type*.  \nYou can set validator from utilities, or register custom validator by yourself.  \nIndeed, it is possible to confirm validator methods provided [here](#-validators-).  \nAbout using custom validater, please check [example](#examples).\n\n```js\n// One of Error object includes validater and error message.\nvalidators: PropTypes.arrayOf(React.PropTypes.shape({\n  message: PropTypes.string.isRequired,\n  validator: PropTypes.func.isRequired,\n})),\n```\n\n**Placehodler:**\nThis props will pass as placeholder attribute of Input tag.\n\n**successMessage:**\nThe success message will appear when validation is passed.  \nUnless you set this props, success message will not appear.\n\n**afterValidate:**\nA handler will execute after validating.  \nFirst args is `isValid`(boolean type), second args is `name` (string type).\n\n**onChange:**\nA event handler of input text filed. In addition to original args, Name will pass as second args.\n\n**onBlur:**\nA event handler of input text filed.\n\n**onFocus:**\nA event handler of input text filed.\n\n**ValidateOnBlur:**\nDefault value is false. When embedding true, validating will be occurred onBlur event only.\n\n### `Validators`\n\n**length:**\nValidate the length of value. The second args { min: integer, max: integer }.\n\n**isAlphanumeric:**\nValidate whether alphanumeric or not.\n\n**mustContainUpperCase:**\nValidate whether value contains upper case at least one.\n\n**isEmail:**\nValidate whether value is formatted of Email address.\n\n**isURL:**\nValidate whether value is formatted of Email address.\n\n### Examples\n\n```js\nrender() {\n  const usernameValidators = [\n    {\n      message: 'Username must be 4 - 12 characters',\n      validator: value =\u003e validator.length(value, { min: 4, max: 12 }),\n    },\n    {\n      message: 'Username must be alphanumeric.',\n      validator: value =\u003e validator.isAlphanumeric(value),\n    },\n  ];\n\n  \u003cReactTextField\n    name=\"username\"\n    placeholder=\"username\"\n    validators={usernameValidators}\n    successMessage=\"This Username is available.\"\n  /\u003e\n}\n\n```\n**Custom validator sample**  \ncheck the value of input text is `some text`.\n\n```js\nconst customValidator = {\n  message: 'text must be some text.',\n  validator: value =\u003e value === 'some text',\n}\n```\n\n\n### Style\n\nPassing **style props** make override default style by embedding inline style.\nStyle object must be following format. \n\n```js\nconst style = {\n  container: {\n    textAlign: 'center',\n  },\n  input: {\n    margin: '30px',\n  },\n  successMessage: {\n    fontSize: '20px',\n    color: '#3949AB',\n  },\n  errorMessage: {\n    fontSize: '20px',\n    color: '#E91E63',\n  },\n};\n``` \n\n### Tests\n\n`npm test`\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyayoc%2Freact-textfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyayoc%2Freact-textfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyayoc%2Freact-textfield/lists"}