{"id":14385157,"url":"https://github.com/borbit/react-mask-mixin","last_synced_at":"2026-01-23T02:49:29.829Z","repository":{"id":28826592,"uuid":"32350066","full_name":"borbit/react-mask-mixin","owner":"borbit","description":"Input mask for text input http://borbit.github.io/react-mask-mixin/","archived":false,"fork":false,"pushed_at":"2016-04-30T18:43:33.000Z","size":29,"stargazers_count":36,"open_issues_count":6,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-23T21:45:48.283Z","etag":null,"topics":[],"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/borbit.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":"2015-03-16T20:10:04.000Z","updated_at":"2019-12-13T15:59:52.000Z","dependencies_parsed_at":"2022-09-05T05:01:26.561Z","dependency_job_id":null,"html_url":"https://github.com/borbit/react-mask-mixin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/borbit/react-mask-mixin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borbit%2Freact-mask-mixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borbit%2Freact-mask-mixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borbit%2Freact-mask-mixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borbit%2Freact-mask-mixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borbit","download_url":"https://codeload.github.com/borbit/react-mask-mixin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borbit%2Freact-mask-mixin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28679138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T01:00:35.747Z","status":"online","status_checked_at":"2026-01-23T02:00:08.296Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-28T18:01:59.709Z","updated_at":"2026-01-23T02:49:29.811Z","avatar_url":"https://github.com/borbit.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# react-mask-mixin\r\n\r\n![gif](http://g.recordit.co/nKufU2TKCj.gif)\r\n\r\nInput mask for text input.\r\n\r\n[Example](http://borbit.github.io/react-mask-mixin/)\r\n\r\n### Install with npm\r\n```\r\nnpm install react-mask-mixin\r\n```\r\n\r\n## Usage\r\nThe goal I wanted to reach in the very beginning was to make basic `\u003cinput/\u003e` element understand custom property `mask` which would define strict format for user input (for example date or phone number). Somewhat, I thought that `LinkedStateMixin`, from `React.addons`, made input elements understand `valueLink` property (that looks like custom at the first glance) and I naively believed that it was possible to write similar solution. After several minutes of digging into React source code it turned out that `valueLink` was a part of `\u003cinput/\u003e` and `\u003ctextarea/\u003e` implementation and `LinkedStateMixin` just utilized it. Now I wander if there is a case when `valueLink` can be used without `LinkedStateMixin`.\r\n\r\n### Solution:\r\n\r\n1. Wrap `\u003cinput/\u003e` with custom component\r\n2. Add `react-mask-mixin` into `mixins` array\r\n3. Spread `this.mask.props` over the `\u003cinput/\u003e`\r\n\r\nMixin polutes your component scope with `mask` object where It keeps eveithing needed. `mask.props` consists of several event handlers and `value` prop that you should necessarily spread over the `\u003cinput/\u003e` element in order to enable masking.\r\n\r\nAs a code it would look like this:\r\n```javascript\r\nvar React = require('react')\r\nvar ReactDOM = require('react-dom')\r\nvar ReactMaskMixin = require('react-mask-mixin')\r\n\r\nvar Input = React.createClass({\r\n  mixins: [ReactMaskMixin],\r\n  render() {\r\n    return \u003cinput {...this.props} {...this.mask.props}/\u003e\r\n  }\r\n})\r\n\r\nvar Component = React.createElement({\r\n  render(): {\r\n    return \u003cInput mask=\"99/99/99\"/\u003e\r\n  }\r\n})\r\n\r\nReactDOM.render(\u003cComponent/\u003e, document.body)\r\n```\r\n\r\n### Masking definitions\r\n\r\n- `9` - numeric\r\n- `A` - alphabetical\r\n- `*` - alphanumeric\r\n\r\n## Tests\r\n\r\nreact-mask-mixin is covered by [Mocha](http://mochajs.org/) tests. To run tests just open `test/test.html` in a browser.\r\n\r\n## License\r\n\r\nreact-mask-mixin may be freely distributed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License#License_terms).\r\n\r\nCopyright (c) 2015 Serge Borbit \u0026lt;serge.borbit@gmail.com\u0026gt;\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborbit%2Freact-mask-mixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborbit%2Freact-mask-mixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborbit%2Freact-mask-mixin/lists"}