[
  {
    "path": ".babelrc",
    "content": "{\n  \"presets\": [\"env\"]\n}"
  },
  {
    "path": ".editorconfig",
    "content": "# EditorConfig helps developers define and maintain consistent\n# coding styles between different editors and IDEs\n# http://editorconfig.org\n\nroot = true\n\n[**]\n\n# 编码格式\ncharset = utf-8\n\n# 文件结尾符\nend_of_line = lf\ninsert_final_newline = true\n\n# 去除行尾空白字符\ntrim_trailing_whitespace = true\n\n# space 缩进\nindent_style = space\nindent_size = 2\n\n[*.md]\ntrim_trailing_whitespace = false\n"
  },
  {
    "path": ".eslintignore",
    "content": "build\nnode_modules"
  },
  {
    "path": ".eslintrc",
    "content": "{\n  \"extends\": \"booheefe\"\n}\n"
  },
  {
    "path": ".gitignore",
    "content": ".idea\nnode_modules\nbuild/app.js\n.coveralls.yml\ncoverage"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n- \"9\"\n\nafter_success:\n- yarn coveralls"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2018 simbawu\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README-zh_CN.md",
    "content": " [English](README.md) | 简体中文\n\n# DigitalKeyboard 数字键盘\n\n[![Build Status](https://travis-ci.org/simbawus/digital-keyboard.svg?branch=master)](https://travis-ci.org/simbawus/digital-keyboard)\n[![Coverage Status](https://coveralls.io/repos/github/simbawus/digital-keyboard/badge.svg?branch=master)](https://coveralls.io/github/simbawus/digital-keyboard?branch=master)\n[![npm](https://img.shields.io/npm/v/digital-keyboard.svg)](https://www.npmjs.com/package/digital-keyboard)\n[![npm](https://img.shields.io/npm/dt/digital-keyboard.svg)](https://www.npmjs.com/package/digital-keyboard)\n[![GitHub license](https://img.shields.io/github/license/simbawus/digital-keyboard.svg)](https://github.com/simbawus/digital-keyboard/blob/master/LICENSE)\n\n- 原生js开发、不依赖任何框架和库的轻量级移动端数字键盘\n- 支持身份证、手机号、整数、小数多类型输入\n- API简洁，非常好上手\n- 开发总结：[从0开始发布一个无依赖、高质量的npm](https://github.com/simbawus/blog/issues/12)\n\n[![Example](https://i.loli.net/2018/05/16/5afc5086957b3.gif)](https://i.loli.net/2018/05/16/5afc5086957b3.gif)\n\n## 键盘类型\n\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"middle\">\n        <img width=\"240px\" src=\"https://i.loli.net/2018/05/16/5afc5360a4c21.jpg\">\n        <p>小数</p>\n      </td>\n      <td align=\"center\" valign=\"middle\">\n        <img width=\"240px\" src=\"https://i.loli.net/2018/05/17/5afc59314b61c.jpg\">\n        <p>整数/手机号</p>\n      </td>\n      <td align=\"center\" valign=\"middle\">\n        <img width=\"240px\" src=\"https://i.loli.net/2018/05/16/5afc5360c635f.jpg\">\n        <p>身份证</p>\n      </td>\n    </tr>\n  </tbody>\n</table>\n\n## 属性\n\n| Property      | Type     | Default | Description                              |\n| :------------ | :------- | :------ | :--------------------------------------- |\n| el            | DOM      |         | 键盘父节点                                    |\n| className     | String   |         | 外部传入可控制键盘样式的class                        |\n| type          | String   | decimal | 键盘类型：decimal小数，integer整数，phone手机号，idcard身份证 |\n| language      | String   | chinese | 语言：chinese，english                         |\n| inputValue    | Function |         | 键盘输入返回值                                  |\n| integerDigits | Number   |         | 限制整数位数                                   |\n| decimalDigits | Number   |         | 限制小数位数                                   |\n\n## 开始上手\n\n### 安装\n\n```shell\nyarn add digital-keyboard --dev\n```\n\n### 使用示例\n\n- **原生 JavaScript**\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"author\" content=\"吴胜斌,simbawu\">\n  <title>数字键盘</title>\n  <style>\n    .container {\n      color: #333;\n    }\n  </style>\n</head>\n<body>\n  <div id=\"values\"></div>\n  <div id=\"app\"></div>\n  <script src=\"./digitalKeyboard.js\"></script>\n</body>\n</html>\n```\n\n```javascript\n//digitalKeyboard.js\nimport DigitalKeyboard from 'digital-keyboard';\n\nfunction inputValue(value){\n  console.log(value); //DigitalKeyboard return value\n  document.querySelector('#values').innerHTML = value;\n}\n\nnew DigitalKeyboard(\n    {\n        el: document.querySelector('#app'),\n        type: 'idcard',\n        className: 'container',\n        inputValue: inputValue,\n        integerDigits: 4,\n        decimalDigits: 2\n    }\n);\n```\n\n- **React**\n\n```jsx\nimport React from 'react';\nimport DigitalKeyboard from \"digital-keyboard\";\nimport s from './digitalKeyboard.scss;\n\nclass KeyboardPage extends React.Component {\n\n  constructor(){\n    super();\n\n    this.inputValue = this.inputValue.bind(this);\n    this._renderKeyboard = this._renderKeyboard.bind(this);\n  }\n\n  componentDidMount(){\n    this._renderKeyboard();\n  }\n\n  inputValue(value){\n    console.log(value); //DigitalKeyboard return value\n  }\n\n  _renderKeyboard(){\n    return new DigitalKeyboard (\n      {\n        el: this.refs.digitalKeyboard,\n        className: s.container,\n        type: 'number',\n        inputValue: this.inputValue,\n        integerDigits: 4,\n        decimalDigits: 2\n      }\n    );\n  }\n\n  render(){\n    return (\n      <div ref='digitalKeyboard'></div>\n    )\n  }\n}\n\nexport default KeyboardPage;\n```\n\n- **Vue**\n\n```js\n<template>\n  <div></div>\n</template>\n<style scoped lang=\"less\">\n    .container {\n        color: #333;\n    }\n</style>\n<script>\nimport DigitalKeyboard from \"digital-keyboard\";\nexport default {\n  mounted () {\n    this._renderDigitalKeyboard();\n  },\n  methods: () {\n    _renderDigitalKeyboard() {\n    \treturn new DigitalKeyboard (\n          {\n            el: this.$el,\n            className: 'container',\n            type: 'number',\n            inputValue: this.inputValue,\n            integerDigits: 4,\n            decimalDigits: 2\n          }\n        );\n    },\n\n    inputValue(value) {\n      console.log(value); //DigitalKeyboard return value\n    }\n  }\n}\n</script>\n```\n- **Angular**\n\n```typescript\n// Online-demo: https://stackblitz.com/edit/angular-hkexnq\nimport { Component, ViewChild, OnInit, ViewEncapsulation} from '@angular/core';\nimport DigitalKeyboard from \"digital-keyboard\";\n\n@Component({\n  selector: 'my-app',\n  template: `\n   <div #keyboard></div>\n  `,\n  styles: [`\n    .container {\n        color: #333;\n    }\n  `],\n  encapsulation: ViewEncapsulation.None\n})\nexport class AppComponent  implements OnInit{\n\n  @ViewChild('keyboard') keyboard;\n\n  ngOnInit(){\n    this._renderDigitalKeyboard();\n  }\n\n  _renderDigitalKeyboard(){\n    return new DigitalKeyboard (\n          {\n            el: this.keyboard.nativeElement,\n            className: 'container',\n            type: 'number',\n            inputValue: this.inputValue,\n            integerDigits: 4,\n            decimalDigits: 2\n          }\n        );\n  }\n\n  inputValue(value) {\n    console.log(value); //DigitalKeyboard return value\n  }\n}\n```\n\n## 如何贡献\n\n欢迎每个人为这个项目做出贡献。可以从查看我们[未解决的问题](https://github.com/simbawus/DigitalKeyboard/issues)、[提交新问题](https://github.com/simbawus/DigitalKeyboard/issues/new?labels=bug)或[提出新功能](https://github.com/simbawus/DigitalKeyboard/issues/new?labels=enhancement)入手，参与讨论投票您喜欢或不喜欢的问题。\n\n## 开源证书\n\n[**The MIT License**](LICENSE).\n\n"
  },
  {
    "path": "README.md",
    "content": "English | [简体中文](README-zh_CN.md)\n\n# Digital Keyboard\n\n[![Build Status](https://travis-ci.org/simbawus/digital-keyboard.svg?branch=master)](https://travis-ci.org/simbawus/digital-keyboard)\n[![Coverage Status](https://coveralls.io/repos/github/simbawus/digital-keyboard/badge.svg?branch=master)](https://coveralls.io/github/simbawus/digital-keyboard?branch=master)\n[![npm](https://img.shields.io/npm/v/digital-keyboard.svg)](https://www.npmjs.com/package/digital-keyboard)\n[![npm](https://img.shields.io/npm/dt/digital-keyboard.svg)](https://www.npmjs.com/package/digital-keyboard)\n[![GitHub license](https://img.shields.io/github/license/simbawus/digital-keyboard.svg)](https://github.com/simbawus/digital-keyboard/blob/master/LICENSE)\n\n- Develop with native javascript, doesn't rely on any frameworks and libraries.\n- Support ID card, mobile number, integer, decimal, etc.\n- Easy API, easy use.\n- Development summary：[How to release a npm package](https://github.com/simbawus/blog/issues/12).\n\n[![Example](https://i.loli.net/2018/05/16/5afc5086957b3.gif)](https://i.loli.net/2018/05/16/5afc5086957b3.gif)\n\n## Type\n\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"middle\">\n        <img width=\"240px\" src=\"https://i.loli.net/2018/05/16/5afc5360a4c21.jpg\">\n        <p>decimal</p>\n      </td>\n      <td align=\"center\" valign=\"middle\">\n        <img width=\"240px\" src=\"https://i.loli.net/2018/05/17/5afc59314b61c.jpg\">\n        <p>integer/phone</p>\n      </td>\n      <td align=\"center\" valign=\"middle\">\n        <img width=\"240px\" src=\"https://i.loli.net/2018/05/16/5afc5360c635f.jpg\">\n        <p>idcard</p>\n      </td>\n    </tr>\n  </tbody>\n</table>\n\n## PropTypes\n\n| Property      | Type     | Default | Description                              |\n| :------------ | :------- | :------ | :--------------------------------------- |\n| el            | DOM      |         | parent node                              |\n| className     | String   |         | additonal class to control keyboard's style |\n| type          | String   | decimal | decimal，integer，phone，idcard             |\n| language      | String   | chinese | chinese，english                         |\n| inputValue    | Function |         | return keyboard value                    |\n| integerDigits | Number   |         | limit integer digits                     |\n| decimalDigits | Number   |         | limit decimal digits                     |\n\n## Getting Started\n\n### Install\n\n```shell\nyarn add digital-keyboard --dev\n```\n\n### Usage Example\n\n- **Native JavaScript**\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"author\" content=\"simbawu\">\n  <title>Digital Keyboard</title>\n  <style>\n    .container {\n      color: #333;\n    }\n  </style>\n</head>\n<body>\n  <div id=\"values\"></div>\n  <div id=\"app\"></div>\n  <script src=\"./digitalKeyboard.js\"></script>\n</body>\n</html>\n```\n\n```javascript\n//digitalKeyboard.js\nimport DigitalKeyboard from 'digital-keyboard';\n\nfunction inputValue(value){\n  console.log(value); //DigitalKeyboard return value\n  document.querySelector('#values').innerHTML = value;\n}\n\nnew DigitalKeyboard(\n    {\n        el: document.querySelector('#app'),\n        className: 'container',\n        type: 'idcard',\n        inputValue: inputValue,\n        integerDigits: 4,\n        decimalDigits: 2\n    }\n);\n```\n\n- **React**\n\n```jsx\nimport React from 'react';\nimport DigitalKeyboard from 'digital-keyboard';\nimport s from './digitalKeyboard.scss';\n\nclass KeyboardPage extends React.Component {\n\n  constructor(){\n    super();\n\n    this.inputValue = this.inputValue.bind(this);\n    this._renderKeyboard = this._renderKeyboard.bind(this);\n  }\n\n  componentDidMount(){\n    this._renderKeyboard();\n  }\n\n  inputValue(value){\n    console.log(value); //DigitalKeyboard return value\n  }\n\n  _renderKeyboard(){\n    return new DigitalKeyboard (\n      {\n        el: this.refs.digitalKeyboard,\n        className: s.container,\n        type: 'number',\n        inputValue: this.inputValue,\n        integerDigits: 4,\n        decimalDigits: 2\n      }\n    );\n  }\n\n  render(){\n    return (\n      <div ref='digitalKeyboard'></div>\n    )\n  }\n}\n\nexport default KeyboardPage;\n```\n\n- **Vue**\n\n```js\n<template>\n  <div></div>\n</template>\n<style scoped lang=\"less\">\n    .container {\n        color: #333;\n    }\n</style>\n<script>\nimport DigitalKeyboard from \"digital-keyboard\";\nexport default {\n  mounted () {\n    this._renderDigitalKeyboard();\n  },\n  methods: () {\n    _renderDigitalKeyboard() {\n    \treturn new DigitalKeyboard (\n          {\n            el: this.$el,\n            className: 'container',\n            type: 'number',\n            inputValue: this.inputValue,\n            integerDigits: 4,\n            decimalDigits: 2\n          }\n        );\n    },\n\n    inputValue(value) {\n      console.log(value); //DigitalKeyboard return value\n    }\n  }\n}\n</script>\n```\n* **Angular**\n\n```typescript\n// Online-demo: https://stackblitz.com/edit/angular-hkexnq\nimport { Component, ViewChild, OnInit, ViewEncapsulation} from '@angular/core';\nimport DigitalKeyboard from \"digital-keyboard\";\n\n@Component({\n  selector: 'my-app',\n  template: `\n   <div #keyboard></div>\n  `,\n  styles: [`\n    .container {\n        color: #333;\n    }\n  `],\n  encapsulation: ViewEncapsulation.None\n})\nexport class AppComponent  implements OnInit{\n\n  @ViewChild('keyboard') keyboard;\n\n  ngOnInit(){\n    this._renderDigitalKeyboard();\n  }\n\n  _renderDigitalKeyboard(){\n    return new DigitalKeyboard (\n          {\n            el: this.keyboard.nativeElement,\n            className: 'container',\n            type: 'number',\n            inputValue: this.inputValue,\n            integerDigits: 4,\n            decimalDigits: 2\n          }\n        );\n  }\n\n  inputValue(value) {\n    console.log(value); //DigitalKeyboard return value\n  }\n}\n```\n\n## How to Contribute\n\nAnyone and everyone is welcome to contribute to this project. The best way to start is by checking our [open issues](https://github.com/simbawus/digital-keyboard/issues),[submit a new issues](https://github.com/simbawus/digital-keyboard/issues/new?labels=bug) or [feature request](https://github.com/simbawus/digital-keyboard/issues/new?labels=enhancement), participate in discussions, upvote or downvote the issues you like or dislike.\n\n## License\n\n[**The MIT License**](LICENSE).\n\n"
  },
  {
    "path": "build/Keyboard.js",
    "content": "!function(e,t){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=t():\"function\"==typeof define&&define.amd?define([],t):\"object\"==typeof exports?exports.DigitalKeyboard=t():e.DigitalKeyboard=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,\"__esModule\",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,\"a\",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=\"/build/\",n(n.s=6)}([function(e,t){e.exports=function(e){var t=\"undefined\"!=typeof window&&window.location;if(!t)throw new Error(\"fixUrls requires window.location\");if(!e||\"string\"!=typeof e)return e;var n=t.protocol+\"//\"+t.host,r=n+t.pathname.replace(/\\/[^\\/]*$/,\"/\");return e.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi,function(e,t){var o,a=t.trim().replace(/^\"(.*)\"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});return/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/|\\s*$)/i.test(a)?e:(o=0===a.indexOf(\"//\")?a:0===a.indexOf(\"/\")?n+a:r+a.replace(/^\\.\\//,\"\"),\"url(\"+JSON.stringify(o)+\")\")})}},function(e,t,n){var r,o,a={},i=(r=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===o&&(o=r.apply(this,arguments)),o}),s=function(e){var t={};return function(e){if(\"function\"==typeof e)return e();if(void 0===t[e]){var n=function(e){return document.querySelector(e)}.call(this,e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}}(),c=null,u=0,l=[],f=n(0);function d(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=a[r.id];if(o){o.refs++;for(var i=0;i<o.parts.length;i++)o.parts[i](r.parts[i]);for(;i<r.parts.length;i++)o.parts.push(g(r.parts[i],t))}else{var s=[];for(i=0;i<r.parts.length;i++)s.push(g(r.parts[i],t));a[r.id]={id:r.id,refs:1,parts:s}}}}function h(e,t){for(var n=[],r={},o=0;o<e.length;o++){var a=e[o],i=t.base?a[0]+t.base:a[0],s={css:a[1],media:a[2],sourceMap:a[3]};r[i]?r[i].parts.push(s):n.push(r[i]={id:i,parts:[s]})}return n}function p(e,t){var n=s(e.insertInto);if(!n)throw new Error(\"Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.\");var r=l[l.length-1];if(\"top\"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),l.push(t);else if(\"bottom\"===e.insertAt)n.appendChild(t);else{if(\"object\"!=typeof e.insertAt||!e.insertAt.before)throw new Error(\"[Style Loader]\\n\\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\\n Must be 'top', 'bottom', or Object.\\n (https://github.com/webpack-contrib/style-loader#insertat)\\n\");var o=s(e.insertInto+\" \"+e.insertAt.before);n.insertBefore(t,o)}}function b(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=l.indexOf(e);t>=0&&l.splice(t,1)}function v(e){var t=document.createElement(\"style\");return e.attrs.type=\"text/css\",y(t,e.attrs),p(e,t),t}function y(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function g(e,t){var n,r,o,a;if(t.transform&&e.css){if(!(a=t.transform(e.css)))return function(){};e.css=a}if(t.singleton){var i=u++;n=c||(c=v(t)),r=w.bind(null,n,i,!1),o=w.bind(null,n,i,!0)}else e.sourceMap&&\"function\"==typeof URL&&\"function\"==typeof URL.createObjectURL&&\"function\"==typeof URL.revokeObjectURL&&\"function\"==typeof Blob&&\"function\"==typeof btoa?(n=function(e){var t=document.createElement(\"link\");return e.attrs.type=\"text/css\",e.attrs.rel=\"stylesheet\",y(t,e.attrs),p(e,t),t}(t),r=function(e,t,n){var r=n.css,o=n.sourceMap,a=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||a)&&(r=f(r));o&&(r+=\"\\n/*# sourceMappingURL=data:application/json;base64,\"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+\" */\");var i=new Blob([r],{type:\"text/css\"}),s=e.href;e.href=URL.createObjectURL(i),s&&URL.revokeObjectURL(s)}.bind(null,n,t),o=function(){b(n),n.href&&URL.revokeObjectURL(n.href)}):(n=v(t),r=function(e,t){var n=t.css,r=t.media;r&&e.setAttribute(\"media\",r);if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),o=function(){b(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}e.exports=function(e,t){if(\"undefined\"!=typeof DEBUG&&DEBUG&&\"object\"!=typeof document)throw new Error(\"The style-loader cannot be used in a non-browser environment\");(t=t||{}).attrs=\"object\"==typeof t.attrs?t.attrs:{},t.singleton||\"boolean\"==typeof t.singleton||(t.singleton=i()),t.insertInto||(t.insertInto=\"head\"),t.insertAt||(t.insertAt=\"bottom\");var n=h(e,t);return d(n,t),function(e){for(var r=[],o=0;o<n.length;o++){var i=n[o];(s=a[i.id]).refs--,r.push(s)}e&&d(h(e,t),t);for(o=0;o<r.length;o++){var s;if(0===(s=r[o]).refs){for(var c=0;c<s.parts.length;c++)s.parts[c]();delete a[s.id]}}}};var m,k=(m=[],function(e,t){return m[e]=t,m.filter(Boolean).join(\"\\n\")});function w(e,t,n,r){var o=n?\"\":r.css;if(e.styleSheet)e.styleSheet.cssText=k(t,o);else{var a=document.createTextNode(o),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(a,i[t]):e.appendChild(a)}}},function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||\"\",r=e[3];if(!r)return n;if(t&&\"function\"==typeof btoa){var o=(i=r,\"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,\"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+\" */\"),a=r.sources.map(function(e){return\"/*# sourceURL=\"+r.sourceRoot+e+\" */\"});return[n].concat(a).concat([o]).join(\"\\n\")}var i;return[n].join(\"\\n\")}(t,e);return t[2]?\"@media \"+t[2]+\"{\"+n+\"}\":n}).join(\"\")},t.i=function(e,n){\"string\"==typeof e&&(e=[[null,e,\"\"]]);for(var r={},o=0;o<this.length;o++){var a=this[o][0];\"number\"==typeof a&&(r[a]=!0)}for(o=0;o<e.length;o++){var i=e[o];\"number\"==typeof i[0]&&r[i[0]]||(n&&!i[2]?i[2]=n:n&&(i[2]=\"(\"+i[2]+\") and (\"+n+\")\"),t.push(i))}},t}},function(e,t,n){(t=e.exports=n(2)(!1)).push([e.i,'.Keyboard_keyboard_15A {\\n  display: flex;\\n  flex-wrap: wrap;\\n  justify-content: space-around;\\n  font-family: PingFang-SC, \"San Francisco\", \"Source Sans\", Rotobo, \"Helvetica Neue\";\\n  font-size: 12px; }\\n  .Keyboard_keyboard_15A button {\\n    width: calc(100% /3);\\n    height: 2.17em;\\n    line-height: 2.17em;\\n    font-family: PingFang-SC, \"San Francisco\", \"Source Sans\", Rotobo, \"Helvetica Neue\";\\n    font-size: 2em;\\n    text-align: center;\\n    color: #3f3f3f;\\n    border: 0;\\n    background-color: #fff;\\n    cursor: pointer;\\n    touch-action: none;\\n    -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }\\n    .Keyboard_keyboard_15A button:focus {\\n      outline: none; }\\n    .Keyboard_keyboard_15A button:active {\\n      background-color: #dfdfdf; }\\n    .Keyboard_keyboard_15A button.Keyboard_keyClear_1ZM {\\n      height: 2.89em;\\n      line-height: 2.89em;\\n      font-size: 1.5em; }\\n    .Keyboard_keyboard_15A button.Keyboard_keyDelete_2ew {\\n      font-weight: bold; }\\n    .Keyboard_keyboard_15A button.Keyboard_keyX_38u {\\n      height: 2.55em;\\n      line-height: 2.55em;\\n      font-size: 1.7em; }\\n',\"\"]),t.locals={keyboard:\"Keyboard_keyboard_15A\",keyClear:\"Keyboard_keyClear_1ZM\",keyDelete:\"Keyboard_keyDelete_2ew\",keyX:\"Keyboard_keyX_38u\"}},function(e,t,n){var r=n(3);\"string\"==typeof r&&(r=[[e.i,r,\"\"]]);var o={hmr:!0,transform:void 0,insertInto:void 0};n(1)(r,o);r.locals&&(e.exports=r.locals)},function(e,t,n){\"use strict\";Object.defineProperty(t,\"__esModule\",{value:!0});var r,o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(4),i=(r=a)&&r.__esModule?r:{default:r};var s=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}(this,e),this.value=\"\",this.options={language:\"chinese\",clearName:\"清空\"},Object.assign(this.options,t),this.init(t)}return o(e,[{key:\"handleClick\",value:function(e,t){var n=this.options;switch(e){case\"delete\":this.value=this.value.substr(0,this.value.length-1);break;case\"clear\":this.value=\"\";break;default:switch(n.type){case\"phone\":this.value.length<11&&(this.value+=t);break;case\"idcard\":this.value.length<18&&(this.value+=t);break;case\"integer\":n.integerDigits&&n.integerDigits<=this.value.length?this.value=this.value:this.value+=t;break;default:var r=(this.value+t).split(\".\"),o=r[0]&&r[0].length||0,a=r[1]&&r[1].length||0,i=!n.integerDigits||n.integerDigits>=o,s=!n.decimalDigits||n.decimalDigits>=a;1===r.length&&i?this.value+=t:2===r.length&&s?this.value+=t:this.value=this.value}}n.inputValue(this.value)}},{key:\"handleClearName\",value:function(){var e=\"清空\";switch(this.options.language){case\"chinese\":e=\"清空\";break;case\"english\":e=\"Clear\";break;default:e=\"清空\"}this.options.clearName=e}},{key:\"initKeys\",value:function(e){var t=this.options.clearName,n={};switch(e){case\"integer\":case\"phone\":n={content:t,action:\"clear\"};break;case\"idcard\":n={content:\"X\",action:\"value\"};break;default:n={content:\".\",action:\"value\"}}this.items=[{content:\"1\",action:\"value\"},{content:\"2\",action:\"value\"},{content:\"3\",action:\"value\"},{content:\"4\",action:\"value\"},{content:\"5\",action:\"value\"},{content:\"6\",action:\"value\"},{content:\"7\",action:\"value\"},{content:\"8\",action:\"value\"},{content:\"9\",action:\"value\"},n,{content:\"0\",action:\"value\"},{content:\"&larr;\",action:\"delete\"}]}},{key:\"_renderKeyboard\",value:function(e){var t=this,n=this.options.clearName,r=\"\",o=this.items.map(function(e){switch(e.content){case\"X\":r=i.default.keyX;break;case n:r=i.default.keyClear;break;case\"&larr;\":r=i.default.keyDelete;break;default:r=\"\"}return'<button ontouchstart=\"\" class=\"'+r+'\" data-action=\"'+e.action+'\" data-content=\"'+e.content+'\">'+e.content+\"</button>\"}),a=document.createElement(\"div\");a.className=i.default.keyboard+\" \"+this.options.className,a.innerHTML=o.join(\"\"),a.addEventListener(\"touchend\",function(e){var n=e.target.dataset,r=n.action,o=n.content;t.handleClick(r,o)}),e.appendChild(a)}},{key:\"init\",value:function(e){this.handleClearName(),this.initKeys(e.type),this._renderKeyboard(e.el)}}]),e}();t.default=s},function(e,t,n){e.exports=n(5)}])});"
  },
  {
    "path": "config/webpack/webpack.base.config.js",
    "content": "const path = require('path');\nconst webpack = require('webpack');\n\nmodule.exports = {\n  output: {\n    path: path.resolve(__dirname, '../../build'),\n    filename: '[name].js',\n    publicPath: '/build/',\n    libraryTarget: 'umd',\n    library: 'DigitalKeyboard'\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.jsx?$/,\n        loader: 'babel-loader',\n        exclude: /(node_modules|build|coverage)/,\n        query: {\n          presets: ['env']\n        }\n      }, {\n        test: /\\.scss$/,\n        use: [{\n          loader: 'style-loader'\n        }, {\n          loader: 'css-loader',\n          options: {\n            modules: true,\n            localIdentName: '[name]_[local]_[hash:base64:3]'\n          }\n        }, {\n          loader: 'sass-loader'\n        }]\n      }\n    ]\n  },\n  plugins: [\n    new webpack.DefinePlugin({ // 定义环境变量\n      'process.env': JSON.stringify(process.env.NODE_ENV)\n    })\n  ]\n};\n"
  },
  {
    "path": "config/webpack/webpack.config.js",
    "content": "const base = require('./webpack.base.config');\nconst merge = require('webpack-merge');\n\nlet config;\nif (process.env.NODE_ENV === 'production') {\n  config = require('./webpack.prod.config');\n} else {\n  config = require('./webpack.dev.config');\n}\n\nmodule.exports = merge(base, config);\n"
  },
  {
    "path": "config/webpack/webpack.dev.config.js",
    "content": "const webpack = require('webpack');\n\nmodule.exports = {\n  entry: {\n    app: ['./src/main.js']\n  },\n  plugins: [\n    new webpack.HotModuleReplacementPlugin()\n  ],\n  devServer: {\n    inline: true,\n    hot: true,\n    host: '0.0.0.0',\n    historyApiFallback: true,\n    port: process.env.PORT || 8101\n  }\n};\n"
  },
  {
    "path": "config/webpack/webpack.prod.config.js",
    "content": "module.exports = {\n  entry: {\n    Keyboard: ['./src/Keyboard.js']\n  }\n};\n"
  },
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0,user-scalable=no\">\n  <meta name=\"author\" content=\"吴胜斌,simbawu\">\n  <title>数字键盘</title>\n</head>\n<body>\n  <div id=\"clear\">清空</div>\n  <div id=\"values\"></div>\n  <div id=\"app\"></div>\n  <script src=\"/build/app.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"digital-keyboard\",\n  \"version\": \"1.2.2\",\n  \"main\": \"build/Keyboard.js\",\n  \"repository\": \"https://github.com/simbawus/digital-keyboard.git\",\n  \"author\": \"Simbawu <connect@simbawu.com>\",\n  \"description\": \"DigitalKeyboard Component\",\n  \"keywords\": [\n    \"DigitalKeyboard\",\n    \"Digital\",\n    \"Keyboard\",\n    \"key\",\n    \"webpack\",\n    \"simbawu\"\n  ],\n  \"license\": \"MIT\",\n  \"devDependencies\": {\n    \"babel-core\": \"^6.26.0\",\n    \"babel-loader\": \"^7.1.2\",\n    \"babel-polyfill\": \"^6.26.0\",\n    \"babel-preset-env\": \"^1.6.1\",\n    \"chai\": \"^4.1.2\",\n    \"coveralls\": \"^3.0.1\",\n    \"cross-env\": \"^5.1.5\",\n    \"css-loader\": \"^0.28.9\",\n    \"digital-keyboard\": \"^1.1.0\",\n    \"eslint\": \"^4.19.1\",\n    \"eslint-config-booheefe\": \"^1.1.0\",\n    \"istanbul\": \"^0.4.5\",\n    \"jsdom\": \"^11.10.0\",\n    \"mocha\": \"^5.1.1\",\n    \"node-sass\": \"^4.7.2\",\n    \"sass-loader\": \"^6.0.6\",\n    \"style-loader\": \"^0.20.1\",\n    \"webpack\": \"^4.8.1\",\n    \"webpack-cli\": \"^2.1.3\",\n    \"webpack-dev-server\": \"^3.1.4\",\n    \"webpack-merge\": \"^4.1.2\"\n  },\n  \"scripts\": {\n    \"build\": \"cross-env NODE_ENV=production webpack --mode production --config  ./config/webpack/webpack.config.js\",\n    \"start\": \"yarn && cross-env NODE_ENV=development webpack-dev-server --mode development --open 'Google Chrome' --config ./config/webpack/webpack.config.js\",\n    \"test\": \"node ./node_modules/mocha/bin/mocha --compilers js:babel-core/register ./test/Keyboard.test.js\",\n    \"cover\": \"istanbul cover ./node_modules/mocha/bin/_mocha\",\n    \"coveralls\": \"yarn cover --report lcovonly && cat ./coverage/lcov.info | coveralls\"\n  }\n}\n"
  },
  {
    "path": "src/Keyboard.js",
    "content": "import s from './Keyboard.scss';\n\nclass DigitalKeyboard {\n  constructor(options = {}) {\n    this.value = '';\n    this.options = {\n      language: 'chinese',\n      clearName: '清空'\n    };\n\n    Object.assign(this.options, options);\n\n    this.init(options);\n  }\n\n  handleClick(action, content) {\n    let { options } = this;\n\n    switch (action) {\n      case 'delete':\n        this.value = this.value.substr(0, this.value.length - 1);\n        break;\n      case 'clear':\n        this.value = '';\n        break;\n      default:\n        switch (options.type) {\n          case 'phone':\n            if (this.value.length < 11) {\n              this.value += content;\n            }\n            break;\n          case 'idcard':\n            if (this.value.length < 18) {\n              this.value += content;\n            }\n            break;\n          case 'integer':\n            if (options.integerDigits && options.integerDigits <= this.value.length) {\n              this.value = this.value;\n            } else {\n              this.value += content;\n            }\n            break;\n          default:\n            let _value = this.value + content;\n            let _valueArr = _value.split('.');\n            let integerDigits = _valueArr[0] && _valueArr[0].length || 0;\n            let decimalDigits = _valueArr[1] && _valueArr[1].length || 0;\n            let integerPass = !options.integerDigits || options.integerDigits >= integerDigits;\n            let decimalPass = !options.decimalDigits || options.decimalDigits >= decimalDigits;\n            if (_valueArr.length === 1 && integerPass) {\n              this.value += content;\n            } else if (_valueArr.length === 2 && decimalPass) {\n              this.value += content;\n            } else {\n              this.value = this.value;\n            }\n\n        }\n        break;\n    }\n\n    options.inputValue(this.value);\n  }\n\n  handleClearName() {\n    const { language } = this.options;\n    let clearName = '清空';\n    switch (language) {\n      case 'chinese':\n        clearName = '清空';\n        break;\n      case 'english':\n        clearName = 'Clear';\n        break;\n      default:\n        clearName = '清空';\n    }\n    this.options.clearName = clearName;\n  }\n\n  initKeys(type) {\n    const { clearName } = this.options;\n    let typeKey = {};\n    switch (typeKey) {\n\n    }\n    switch (type) {\n      case 'integer':\n        typeKey = {\n          content: clearName,\n          action: 'clear'\n        };\n        break;\n      case 'phone':\n        typeKey = {\n          content: clearName,\n          action: 'clear'\n        };\n        break;\n      case 'idcard':\n        typeKey = {\n          content: 'X',\n          action: 'value'\n        };\n        break;\n      default:\n        typeKey = {\n          content: '.',\n          action: 'value'\n        };\n        break;\n    }\n\n    this.items = [\n      {\n        'content': '1',\n        'action': 'value'\n      }, {\n        'content': '2',\n        'action': 'value'\n      }, {\n        'content': '3',\n        'action': 'value'\n      }, {\n        'content': '4',\n        'action': 'value'\n      }, {\n        'content': '5',\n        'action': 'value'\n      }, {\n        'content': '6',\n        'action': 'value'\n      }, {\n        'content': '7',\n        'action': 'value'\n      }, {\n        'content': '8',\n        'action': 'value'\n      }, {\n        'content': '9',\n        'action': 'value'\n      }, typeKey, {\n        'content': '0',\n        'action': 'value'\n      }, {\n        'content': '&larr;',\n        'action': 'delete'\n      }\n    ];\n  }\n\n  _renderKeyboard(container) {\n    const { clearName } = this.options;\n    let className = '';\n    let keyboards = this.items.map((item) => {\n      switch (item.content) {\n        case 'X':\n          className = s.keyX;\n          break;\n        case clearName:\n          className = s.keyClear;\n          break;\n        case '&larr;':\n          className = s.keyDelete;\n          break;\n        default:\n          className = '';\n          break;\n      }\n\n      return `<button ontouchstart=\"\" class=\"${className}\" data-action=\"${item.action}\" data-content=\"${item.content}\">${item.content}</button>`;\n    });\n\n    const keyboardBox = document.createElement('div');\n    keyboardBox.className = `${s.keyboard} ${this.options.className}`;\n    keyboardBox.innerHTML = keyboards.join('');\n    keyboardBox.addEventListener('touchend', (e) => {\n      let {action, content} = e.target.dataset;\n      this.handleClick(action, content);\n    });\n\n    container.appendChild(keyboardBox);\n  }\n\n  init(options) {\n    this.handleClearName();\n    this.initKeys(options.type);\n    this._renderKeyboard(options.el);\n  }\n}\n\nexport default DigitalKeyboard;\n"
  },
  {
    "path": "src/Keyboard.scss",
    "content": "$fontFamily: PingFang-SC, \"San Francisco\", \"Source Sans\", Rotobo, \"Helvetica Neue\";\n\n@mixin hlh($height) {\n  height: $height;\n  line-height: $height;\n}\n\n.keyboard {\n  display: flex;\n  flex-wrap: wrap;\n  justify-content: space-around;\n  font-family: $fontFamily;\n  font-size: 12px;\n\n  button {\n    width: calc(100% /3);\n    @include hlh(2.17em);\n    font-family: $fontFamily;\n    font-size: 2em;\n    text-align: center;\n    color: #3f3f3f;\n    border:0;\n    background-color: #fff;\n    cursor: pointer;\n    touch-action: none;\n    -webkit-tap-highlight-color: rgba(0,0,0,0);\n\n    &:focus {\n      outline: none;\n    }\n\n    &:active {\n      background-color: #dfdfdf;\n    }\n\n    &.keyClear {\n      @include hlh(2.89em);\n      font-size: 1.5em;\n    }\n\n    &.keyDelete{\n      font-weight: bold;\n    }\n\n    &.keyX{\n      @include hlh(2.55em);\n      font-size: 1.7em;\n    }\n  }\n}"
  },
  {
    "path": "src/main.js",
    "content": "import DigitalKeyboard from './Keyboard';\n// import DigitalKeyboard from 'digital-keyboard';\nimport s from './main.scss';\n\nfunction inputValue(value) {\n  document.querySelector('#values').innerHTML = value;\n}\n\ndocument.querySelector('#clear').addEventListener('click', clearValue);\n\nfunction clearValue() {\n  Keyboard.value = '';\n}\n\nlet Keyboard = new DigitalKeyboard({\n  el: document.querySelector('#app'),\n  className: s.container,\n  type: 'integer',\n  inputValue: inputValue,\n  integerDigits: 4,\n  decimalDigits: 2,\n  language: 'english'\n});\n"
  },
  {
    "path": "src/main.scss",
    "content": ".container {\n  color: #bbbbbb;\n}"
  },
  {
    "path": "test/Keyboard.test.js",
    "content": "const expect = require('chai').expect, {JSDOM} = require('jsdom'),\n  {window} = new JSDOM(`<!DOCTYPE html>\n  <html>\n  <head>\n      <meta charset=\"UTF-8\">\n      <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0,user-scalable=no\">\n      <meta name=\"author\" content=\"吴胜斌,simbawu\">\n      <title>数字键盘</title>\n  </head>\n  <body>\n  <div id=\"values\"></div>\n  <div id=\"app\"></div>\n  </body>\n  </html>`);\n\npropagateToGlobal(window);\n\nfunction propagateToGlobal(window) {\n  for (let key in window) {\n    if (!window.hasOwnProperty(key)) continue;\n    if (key in global) continue;\n    global[key] = window[key];\n  }\n}\n\nconst DigitalKeyboard = require('../build/Keyboard').default;\n\ndescribe('mocha tests', function() {\n\n  let inputValue, currentValue = '', tempValue = '';\n\n  before(function() {\n    inputValue = function(value) {\n      document.querySelector('#values').innerHTML = value;\n      currentValue = value;\n    };\n  });\n\n  ['idcard', 'integer', 'phone', 'normal'].forEach(function(keyboardType) {\n    it('render correct', function() {\n      tempValue = '';\n      switch (keyboardType) {\n        case 'integer':\n          new DigitalKeyboard({el: document.querySelector('#app'), type: keyboardType, inputValue: inputValue});\n          expect(document.querySelectorAll('button')[9].innerHTML).be.equal('清空');\n          break;\n        case 'phone':\n          new DigitalKeyboard({el: document.querySelector('#app'), type: keyboardType, inputValue: inputValue});\n          expect(document.querySelectorAll('button')[9].innerHTML).be.equal('清空');\n          break;\n        case 'idcard':\n          new DigitalKeyboard({el: document.querySelector('#app'), type: keyboardType, inputValue: inputValue});\n          expect(document.querySelectorAll('button')[9].innerHTML).be.equal('X');\n          break;\n        default:\n          new DigitalKeyboard({el: document.querySelector('#app'), type: keyboardType, inputValue: inputValue});\n          expect(document.querySelectorAll('button')[9].innerHTML).be.equal('.');\n          break;\n      }\n    });\n\n    it('get correct value', function() {\n      document.querySelectorAll('button').forEach(function(itemKey) {\n        let event = document.createEvent('HTMLEvents');\n        event.initEvent('touchend', true, true);\n        itemKey.dispatchEvent(event);\n        let action = itemKey.getAttribute('data-action'), content = itemKey.getAttribute('data-content');\n        switch (action) {\n          case 'delete':\n            tempValue = tempValue.substr(0, tempValue.length - 1);\n            break;\n          case 'clear':\n            tempValue = '';\n            break;\n          default:\n            switch (keyboardType) {\n              case 'phone':\n                if (tempValue.length < 11) {\n                  tempValue += content;\n                }\n                break;\n              case 'idcard':\n                if (tempValue.length < 18) {\n                  tempValue += content;\n                }\n                break;\n              default:\n                tempValue += content;\n            }\n            break;\n        }\n\n        expect(currentValue).to.be.equal(tempValue);\n      });\n\n      document.querySelector('#app').innerHTML = '';\n    });\n\n  });\n\n});\n\n"
  }
]