{"_id":"@attently/riek","_rev":"4-67e8b93aae5cbe8c4de59eb2a542e776","name":"@attently/riek","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"@attently/riek","version":"2.0.0","description":"React Inline Edit Kit","author":{"name":"Kai Vik","email":"kvi@ieee.org"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/attently/riek.git"},"main":"lib/index.js","keywords":["react","in-place","edit","editor","inplace","inline"],"bugs":{"url":"https://github.com/attently/riek/issues"},"homepage":"https://github.com/attently/riek#readme","scripts":{"test":"echo \"Error: no test specified\" && exit 1","prepublish":"npm run build","build-lib":"rm -rf lib/*; babel src --out-dir lib","build-demo":"rm demo/demo.js; webpack demo/demo.jsx demo/demo.js","build":"npm run build-lib && npm run build-demo"},"peerDependencies":{"react":"<16.0.0 || ^16.0.0","react-dom":"<16.0.0 || ^16.0.0"},"dependencies":{"debug":"^2.6.8","prop-types":"^15.5.10"},"devDependencies":{"babel-cli":"^6.4.0","babel-core":"^6.4.0","babel-loader":"^6.2.1","babel-preset-es2015":"^6.3.13","babel-preset-react":"^6.3.13","babel-preset-stage-1":"^6.3.13","highlight.js":"^9.1.0","react-highlight":"^0.6.1","webpack":"^1.12.11"},"licenseText":"The MIT License (MIT)\nCopyright (c) 2016 Kai Vik\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"@attently/riek@2.0.0","dist":{"shasum":"185180525b6eef3fa5133c4fbdade42b6f2785a6","tarball":"https://registry.npmjs.org/@attently/riek/-/riek-2.0.0.tgz","fileCount":19,"unpackedSize":169847,"integrity":"sha512-2pRmvkIzV/SxXlE+c4M4nKqkfGlLFiqxslynC/zCF1J7m/HDYIBmIXnLFLcO8dypBvKShYvFMXw2DTbcmwlUoA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC2001WlXDGWZGbrWkCrOv9zj95CYS/46oQs+JERHc/HAIhAPNInPIJHIrhjET95NICwv95oLiVTs9O2OzIJ8+uxgnM"}]},"maintainers":[{"name":"fizzygalacticus","email":"dustinleedodson@gmail.com"}],"_npmUser":{"name":"fizzygalacticus","email":"dustinleedodson@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/riek_2.0.0_1523042617801_0.05557568500558818"},"_hasShrinkwrap":false},"2.0.1":{"name":"@attently/riek","version":"2.0.1","description":"React Inline Edit Kit","author":{"name":"Kai Vik","email":"kvi@ieee.org"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/attently/riek.git"},"main":"lib/index.js","keywords":["react","in-place","edit","editor","inplace","inline"],"bugs":{"url":"https://github.com/attently/riek/issues"},"homepage":"https://github.com/attently/riek#readme","scripts":{"test":"echo \"Error: no test specified\" && exit 1","prepublish":"npm run build","build-lib":"rm -rf lib/*; babel src --out-dir lib","build-demo":"rm demo/demo.js; webpack demo/demo.jsx demo/demo.js","build":"npm run build-lib && npm run build-demo"},"peerDependencies":{"react":"<16.0.0 || ^16.0.0","react-dom":"<16.0.0 || ^16.0.0"},"dependencies":{"debug":"^2.6.8","prop-types":"^15.5.10"},"devDependencies":{"babel-cli":"^6.4.0","babel-core":"^6.4.0","babel-loader":"^6.2.1","babel-preset-es2015":"^6.3.13","babel-preset-react":"^6.3.13","babel-preset-stage-1":"^6.3.13","highlight.js":"^9.1.0","react-highlight":"^0.6.1","webpack":"^1.12.11"},"licenseText":"The MIT License (MIT)\nCopyright (c) 2016 Kai Vik\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"@attently/riek@2.0.1","dist":{"shasum":"0052785a5bab1ca7a99236f135624d39e6619024","tarball":"https://registry.npmjs.org/@attently/riek/-/riek-2.0.1.tgz","fileCount":19,"unpackedSize":169877,"integrity":"sha512-fjMfPCN2Lty9C0yeswFw+swvbQlkvGKiFlNhRoBfr5YqILQ02FedtP2XoceW0DB0jm8mozQ8zvBwL5zjiMUX1g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF9LWjnZNOPRaS7kC5k2zB728eiSnjZrBC5X2h+zczOoAiBXuO1ugfsHNgRcYZFk5J5j5YxN1wY3qnTuzagUXIs2MA=="}]},"maintainers":[{"name":"fizzygalacticus","email":"dustinleedodson@gmail.com"}],"_npmUser":{"name":"fizzygalacticus","email":"dustinleedodson@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/riek_2.0.1_1523048329798_0.4773125694793925"},"_hasShrinkwrap":false}},"time":{"created":"2018-04-06T19:23:37.746Z","2.0.0":"2018-04-06T19:23:38.101Z","modified":"2022-06-12T14:51:21.031Z","2.0.1":"2018-04-06T20:58:50.320Z"},"maintainers":[{"name":"fizzygalacticus","email":"dustinleedodson@gmail.com"}],"description":"React Inline Edit Kit","homepage":"https://github.com/attently/riek#readme","keywords":["react","in-place","edit","editor","inplace","inline"],"repository":{"type":"git","url":"git+https://github.com/attently/riek.git"},"author":{"name":"Kai Vik","email":"kvi@ieee.org"},"bugs":{"url":"https://github.com/attently/riek/issues"},"license":"MIT","readme":"# React Inline Edit Kit\nAn assortment of common HTML form elements, editable in-line the React way.\n\nTry out [the demo](http://kaivi.github.io/riek/) and see what it looks like.\n\n# Installation\n`npm install @attently/riek --save-dev`\n\n*or*\n\n`yarn add @attently/riek --dev`\n\n*Use `--save-dev` because you don't want to build and pack JS/CSS in production*\n\n# Usage\nImport the library:\n\n```javascript\nimport { RIEToggle, RIEInput, RIETextArea, RIENumber, RIETags, RIESelect } from '@attently/riek'\nimport _ from 'lodash'\n```\n\nSuppose we want to be able to edit title of a `Task` and send changes to server. Here is a `Task` stored flat inside of our parent React component:\n\n```javascript\nthis.state = {\n  id: 1,\n  title: 'Cover with tests',\n  completed: false\n}\n```\n\nNow we need a function which will send the single altered `{ key: value }` and upsert local state. You can implement it inside of your flux/redux/mobx store:\n\n```javascript\nconst httpTaskCallback = (task) => {\n  request.post(`/api/task/${this.state.id}`)\n    .send(task)\n    .end((err, res) => {\n      if (!err) return this.setState({ ...task })\n      // Handle HTTP error\n    })\n}\n```\n\nMeanwhile, there is a simple Express handler on our API server:\n\n```javascript\napp.use('/api/task/:id', async (req, res) => {\n  // req.body will equal to { title: 'A new title' }\n  const { id } = req.params\n  await Task.update({ ...req.body }).where({ id })\n  res.send('OK')\n})\n```\n\nFinally, in our `render` method, we add a minimal `RIEInput`:\n\n```javascript\n<RIEInput\n  value={this.state.text}\n  change={this.httpTaskCallback}\n  propName='title'\n  validate={_.isString} />\n```\n\n...repeat the last step, adding a Riek component for any object property we wish to edit.\n\nComponents come unstyled, so take a look at [demo.jsx](https://github.com/kaivi/riek/blob/master/demo/demo.jsx) for examples.\n\n## Common props\n\n### Required\n* **value**: initial prop value\n* **propName**: name of the prop to return to the _change_ function\n* **change**: function which will receive a plain object with a single key, provided in _propName_\n\n### Optional\n* **editing**: editing state, to change editing state programmatically\n* **validate**: validator function, returning a boolean\n* **shouldBlockWhileLoading**: disables editing until a new value is confirmed by parent\n* **shouldRemainWhileInvalid**: remain in editing mode if validation fails\n* **shouldStartEditOnDoubleClick**: start editing mode on click if `false` or on double click if `true`, default : `false`\n* **defaultProps**: Additional props for idle component.\n\n#### Customization\n* **classLoading**: CSS class name to use when loading\n* **classEditing**: CSS class name to apply while in editing mode\n* **classInvalid**: CSS class name to apply when _validate_ returned false\n* **className**: CSS base class\n* **editProps**: Additional props for the editing component. This allows you to, for example, specify a maxLength attribute to control the maximum number of characters in the textarea, or add `style`.\n* **selectAll**: Default true. When editing, select all the input's contents if true, otherwise simply `focus()`\n\n#### Hooks\n* **beforeStart**: Fires before editing starts\n* **afterStart**: Fires after editing starts\n* **beforeFinish**: Fires before editing ends, before validations\n* **afterFinish**: Fires after editing ends, after validations\n\n### Component-specific props\n\n#### RIENumber\n* **format**: custom formatting function, returns formatted string\n\n#### RIETextArea\n* **rows**: rows property on textarea tag while editing\n* **cols**: rows property on textarea tag while editing\n\n#### RIESelect\n* **options**: an array of objects containing values and text for [select options](http://www.w3schools.com/tags/tag_option.asp)\n```javascript\n<RIESelect ... options={[\n  {id: '1', text: 'one'},\n  {id: '2', text: 'two'},\n  {id: '3', text: 'three'}\n]} />\n```\n\n# Contributing\n\nThe build process does not work with Node v6 at the moment: use [Node Version Manager](https://github.com/creationix/nvm), or just plain Node v5.6.0.\n\n1. Clone this repo locally, run `npm i`\n2. Make your changes\n3. Do `npm run build` to compile the lib and demo\n4. Open `index.html` and check if it works\n5. Open JS console in browser, set `localStorage.debug = '*'` to see debug messages, add more if necessary\n6. ???\n7. Submit a pull request\n","readmeFilename":"README.md"}