├── .babelrc
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── demo
├── index.html
├── index.js
└── index.jsx
├── index.js
├── index.jsx
├── package.json
└── webpack.config.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "react", "stage-1"]
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27 | node_modules
28 | .idea
29 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | 1.0.8 / 2016-11-07
3 | ==================
4 | * Merged PR [#26](https://github.com/kaivi/ReactInlineEdit/pull/26)
5 | - Remove onReturn props From Element
6 |
7 | 1.0.7 / 2016-04-28
8 | ==================
9 |
10 | * Merged PR [#16](https://github.com/kaivi/ReactInlineEdit/pull/16)
11 | - Implement option to disable editing
12 | * Merged PR [#17](https://github.com/kaivi/ReactInlineEdit/pull/16)
13 | - Update peer dependencies to allow React 15.x.x
14 |
15 | 1.0.6 / 2016-01-25
16 | ==================
17 |
18 | * Merged PR [#11](https://github.com/kaivi/ReactInlineEdit/pull/11)
19 | - fixed a bug introduced in [#6](https://github.com/kaivi/ReactInlineEdit/pull/6)
20 |
21 | 1.0.5 / 2016-01-19
22 | ==================
23 |
24 | * Merged PR [#9](https://github.com/kaivi/ReactInlineEdit/pull/9)
25 | - consistent style (and basic lint stuff)
26 | - spacing
27 | - spaces after if
28 | - let instead of var
29 | - dangling commas
30 | - lower case `functionName`
31 | - life-cycle methods before others, followed by render.
32 | - class properties (since stage 0 is being utilized)
33 | - other initialization stuff in `componentWillMount` as opposed to `constructor`
34 |
35 | * Upgraded peerDependency to React 0.14.6 PR [#10](https://github.com/kaivi/ReactInlineEdit/pull/10)
36 |
37 | 1.0.4 / 2016-01-18
38 | ==================
39 |
40 | * Added `editingElement` and `staticElement` props, so one can pass custom component names: [\#5](https://github.com/kaivi/ReactInlineEdit/issues/5)
41 | * Added proper Babel v6.4 dependency to `devDependencies`, so it just builds on `npm install` with OS X
42 | * Added a small demo under `demo/` directory
43 | * Added tab stops via `tabIndex` property on `staticElement`
44 | * Added custom `style` prop to pass styles, obviously
45 | * When `text` prop changes, the component is now re-rendered: [\#6](https://github.com/kaivi/ReactInlineEdit/pull/6)
46 | * Upgraded React peer dependency, so it matches React of any `v0.x.x` version
47 | * Updated `LICENSE` to MIT, as in `package.json`
48 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2014 Kai Vik
3 |
4 | Permission 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:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE 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.
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Inline Edit Component for React
2 |
3 | Before you continue, check out a successor to this repo: [React Inline Edit Kit](https://github.com/kaivi/riek). It is more functional, and will be maintained in future.
4 |
5 | This is a simple React component for in-place text editing. It turns into an `` when focused, and tries to validate and save input on Enter or `blur`. Esc works as well for cancelling.
6 |
7 | 
8 |
9 | Watch a [demo](http://htmlpreview.github.io/?https://github.com/kaivi/ReactInlineEdit/blob/master/demo/index.html), then check out [demo/index.jsx](demo/index.jsx) for a quick example.
10 |
11 | ### Installation
12 |
13 | `npm install react-edit-inline --save-dev`
14 |
15 | ### Required props
16 | - `text`:`string` initial text
17 | - `paramName`:`string` name of the parameter to be returned to `change` function
18 | - `change`:`function` function to call when new text is changed and validated, it will receive `{paramName: value}`
19 |
20 | ### Optional props
21 | - `className`:_string_ CSS class name
22 | - `activeClassName`:_string_ CSS class replacement for when in edit mode
23 | - `validate`:_function_ boolean function for custom validation, using this overrides the two props below
24 | - `minLength`:_number_ minimum text length, **default** `1`
25 | - `maxLength`:_number_ maximum text length, **default** `256`
26 | - `editingElement`:_string_ element name to use when in edit mode (DOM must have `value` property) **default** `input`
27 | - `staticElement`:_string_ element name for displaying data **default** `span`
28 | - `editing`:_boolean_ If true, element will be in edit mode
29 | - `tabIndex`:_number_ tab index used for focusing with TAB key **default** `0`
30 | - `stopPropagation`:_boolean_ If true, the event onClick will not be further propagated.
31 |
32 | ### Usage example
33 | ```javascript
34 | import React from 'react';
35 | import InlineEdit from 'react-edit-inline';
36 |
37 | class MyParentComponent extends React.Component {
38 |
39 | constructor(props){
40 | super(props);
41 | this.dataChanged = this.dataChanged.bind(this);
42 | this.state = {
43 | message: 'ReactInline demo'
44 | }
45 | }
46 |
47 | dataChanged(data) {
48 | // data = { description: "New validated text comes here" }
49 | // Update your model from here
50 | console.log(data)
51 | this.setState({...data})
52 | }
53 |
54 | customValidateText(text) {
55 | return (text.length > 0 && text.length < 64);
56 | }
57 |
58 | render() {
59 | return (
60 |
{this.state.message}
61 | Edit me:
62 |
79 |
)
80 | }
81 | }
82 | ```
83 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ReactInlineEdit Component
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/demo/index.js:
--------------------------------------------------------------------------------
1 | /******/ (function(modules) { // webpackBootstrap
2 | /******/ // The module cache
3 | /******/ var installedModules = {};
4 |
5 | /******/ // The require function
6 | /******/ function __webpack_require__(moduleId) {
7 |
8 | /******/ // Check if module is in cache
9 | /******/ if(installedModules[moduleId])
10 | /******/ return installedModules[moduleId].exports;
11 |
12 | /******/ // Create a new module (and put it into the cache)
13 | /******/ var module = installedModules[moduleId] = {
14 | /******/ exports: {},
15 | /******/ id: moduleId,
16 | /******/ loaded: false
17 | /******/ };
18 |
19 | /******/ // Execute the module function
20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 |
22 | /******/ // Flag the module as loaded
23 | /******/ module.loaded = true;
24 |
25 | /******/ // Return the exports of the module
26 | /******/ return module.exports;
27 | /******/ }
28 |
29 |
30 | /******/ // expose the modules object (__webpack_modules__)
31 | /******/ __webpack_require__.m = modules;
32 |
33 | /******/ // expose the module cache
34 | /******/ __webpack_require__.c = installedModules;
35 |
36 | /******/ // __webpack_public_path__
37 | /******/ __webpack_require__.p = "";
38 |
39 | /******/ // Load entry module and return exports
40 | /******/ return __webpack_require__(0);
41 | /******/ })
42 | /************************************************************************/
43 | /******/ ([
44 | /* 0 */
45 | /***/ (function(module, exports, __webpack_require__) {
46 |
47 | 'use strict';
48 |
49 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
50 |
51 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
52 |
53 | var _index = __webpack_require__(1);
54 |
55 | var _index2 = _interopRequireDefault(_index);
56 |
57 | var _react = __webpack_require__(2);
58 |
59 | var _react2 = _interopRequireDefault(_react);
60 |
61 | var _reactDom = __webpack_require__(3);
62 |
63 | var _reactDom2 = _interopRequireDefault(_reactDom);
64 |
65 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
66 |
67 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
68 |
69 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
70 |
71 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
72 |
73 | var MyParentComponent = function (_React$Component) {
74 | _inherits(MyParentComponent, _React$Component);
75 |
76 | function MyParentComponent(props) {
77 | _classCallCheck(this, MyParentComponent);
78 |
79 | var _this = _possibleConstructorReturn(this, (MyParentComponent.__proto__ || Object.getPrototypeOf(MyParentComponent)).call(this, props));
80 |
81 | _this.dataChanged = _this.dataChanged.bind(_this);
82 | _this.state = {
83 | message: 'ReactInline demo'
84 | };
85 | return _this;
86 | }
87 |
88 | _createClass(MyParentComponent, [{
89 | key: 'dataChanged',
90 | value: function dataChanged(data) {
91 | // data = { description: "New validated text comes here" }
92 | // Update your model from here
93 | console.log(data);
94 | this.setState(_extends({}, data));
95 | }
96 | }, {
97 | key: 'customValidateText',
98 | value: function customValidateText(text) {
99 | return text.length > 0 && text.length < 64;
100 | }
101 | }, {
102 | key: 'render',
103 | value: function render() {
104 | return _react2.default.createElement(
105 | 'div',
106 | null,
107 | _react2.default.createElement(
108 | 'h2',
109 | null,
110 | this.state.message
111 | ),
112 | _react2.default.createElement(
113 | 'span',
114 | null,
115 | 'Edit me: '
116 | ),
117 | _react2.default.createElement(_index2.default, {
118 | validate: this.customValidateText,
119 | activeClassName: 'editing',
120 | text: this.state.message,
121 | paramName: 'message',
122 | change: this.dataChanged,
123 | style: {
124 | backgroundColor: 'yellow',
125 | minWidth: 150,
126 | display: 'inline-block',
127 | margin: 0,
128 | padding: 0,
129 | fontSize: 15,
130 | outline: 0,
131 | border: 0
132 | }
133 | })
134 | );
135 | }
136 | }]);
137 |
138 | return MyParentComponent;
139 | }(_react2.default.Component);
140 |
141 | _reactDom2.default.render(_react2.default.createElement(MyParentComponent, null), document.getElementById('app'));
142 |
143 | /***/ }),
144 | /* 1 */
145 | /***/ (function(module, exports, __webpack_require__) {
146 |
147 | 'use strict';
148 |
149 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
150 |
151 | Object.defineProperty(exports, "__esModule", {
152 | value: true
153 | });
154 |
155 | var _createClass = function () {
156 | function defineProperties(target, props) {
157 | for (var i = 0; i < props.length; i++) {
158 | var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
159 | }
160 | }return function (Constructor, protoProps, staticProps) {
161 | if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
162 | };
163 | }();
164 |
165 | var _react = __webpack_require__(2);
166 |
167 | var _react2 = _interopRequireDefault(_react);
168 |
169 | var _reactDom = __webpack_require__(3);
170 |
171 | var _reactDom2 = _interopRequireDefault(_reactDom);
172 |
173 | var _propTypes = __webpack_require__(4);
174 |
175 | var _propTypes2 = _interopRequireDefault(_propTypes);
176 |
177 | function _interopRequireDefault(obj) {
178 | return obj && obj.__esModule ? obj : { default: obj };
179 | }
180 |
181 | function _classCallCheck(instance, Constructor) {
182 | if (!(instance instanceof Constructor)) {
183 | throw new TypeError("Cannot call a class as a function");
184 | }
185 | }
186 |
187 | function _possibleConstructorReturn(self, call) {
188 | if (!self) {
189 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
190 | }return call && ((typeof call === "undefined" ? "undefined" : _typeof(call)) === "object" || typeof call === "function") ? call : self;
191 | }
192 |
193 | function _inherits(subClass, superClass) {
194 | if (typeof superClass !== "function" && superClass !== null) {
195 | throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof(superClass)));
196 | }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
197 | }
198 |
199 | function selectInputText(element) {
200 | element.setSelectionRange(0, element.value.length);
201 | }
202 |
203 | var InlineEdit = function (_React$Component) {
204 | _inherits(InlineEdit, _React$Component);
205 |
206 | function InlineEdit() {
207 | var _ref;
208 |
209 | var _temp, _this, _ret;
210 |
211 | _classCallCheck(this, InlineEdit);
212 |
213 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
214 | args[_key] = arguments[_key];
215 | }
216 |
217 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = InlineEdit.__proto__ || Object.getPrototypeOf(InlineEdit)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
218 | editing: _this.props.editing,
219 | text: _this.props.text,
220 | minLength: _this.props.minLength,
221 | maxLength: _this.props.maxLength
222 | }, _this.startEditing = function (e) {
223 | if (_this.props.stopPropagation) {
224 | e.stopPropagation();
225 | }
226 | _this.setState({ editing: true, text: _this.props.text });
227 | }, _this.finishEditing = function () {
228 | if (_this.isInputValid(_this.state.text) && _this.props.text != _this.state.text) {
229 | _this.commitEditing();
230 | } else if (_this.props.text === _this.state.text || !_this.isInputValid(_this.state.text)) {
231 | _this.cancelEditing();
232 | }
233 | }, _this.cancelEditing = function () {
234 | _this.setState({ editing: false, text: _this.props.text });
235 | }, _this.commitEditing = function () {
236 | _this.setState({ editing: false, text: _this.state.text });
237 | var newProp = {};
238 | newProp[_this.props.paramName] = _this.state.text;
239 | _this.props.change(newProp);
240 | }, _this.clickWhenEditing = function (e) {
241 | if (_this.props.stopPropagation) {
242 | e.stopPropagation();
243 | }
244 | }, _this.isInputValid = function (text) {
245 | return text.length >= _this.state.minLength && text.length <= _this.state.maxLength;
246 | }, _this.keyDown = function (event) {
247 | if (event.keyCode === 13) {
248 | _this.finishEditing();
249 | } else if (event.keyCode === 27) {
250 | _this.cancelEditing();
251 | }
252 | }, _this.textChanged = function (event) {
253 | _this.setState({
254 | text: event.target.value.trim()
255 | });
256 | }, _temp), _possibleConstructorReturn(_this, _ret);
257 | }
258 |
259 | _createClass(InlineEdit, [{
260 | key: 'componentWillMount',
261 | value: function componentWillMount() {
262 | this.isInputValid = this.props.validate || this.isInputValid;
263 | // Warn about deprecated elements
264 | if (this.props.element) {
265 | console.warn('`element` prop is deprecated: instead pass editingElement or staticElement to InlineEdit component');
266 | }
267 | }
268 | }, {
269 | key: 'componentWillReceiveProps',
270 | value: function componentWillReceiveProps(nextProps) {
271 | var isTextChanged = nextProps.text !== this.props.text;
272 | var isEditingChanged = nextProps.editing !== this.props.editing;
273 | var nextState = {};
274 | if (isTextChanged) {
275 | nextState.text = nextProps.text;
276 | }
277 | if (isEditingChanged) {
278 | nextState.editing = nextProps.editing;
279 | }
280 | if (isTextChanged || isEditingChanged) {
281 | this.setState(nextState);
282 | }
283 | }
284 | }, {
285 | key: 'componentDidUpdate',
286 | value: function componentDidUpdate(prevProps, prevState) {
287 | var inputElem = _reactDom2.default.findDOMNode(this.refs.input);
288 | if (this.state.editing && !prevState.editing) {
289 | inputElem.focus();
290 | selectInputText(inputElem);
291 | } else if (this.state.editing && prevProps.text != this.props.text) {
292 | this.finishEditing();
293 | }
294 | }
295 | }, {
296 | key: 'render',
297 | value: function render() {
298 | if (this.props.isDisabled) {
299 | var Element = this.props.element || this.props.staticElement;
300 | return _react2.default.createElement(Element, {
301 | className: this.props.className,
302 | style: this.props.style }, this.state.text || this.props.placeholder);
303 | } else if (!this.state.editing) {
304 | var _Element = this.props.element || this.props.staticElement;
305 | return _react2.default.createElement(_Element, {
306 | className: this.props.className,
307 | onClick: this.startEditing,
308 | tabIndex: this.props.tabIndex,
309 | style: this.props.style }, this.state.text || this.props.placeholder);
310 | } else {
311 | var _Element2 = this.props.element || this.props.editingElement;
312 | return _react2.default.createElement(_Element2, {
313 | onClick: this.clickWhenEditing,
314 | onKeyDown: this.keyDown,
315 | onBlur: this.finishEditing,
316 | className: this.props.activeClassName,
317 | placeholder: this.props.placeholder,
318 | defaultValue: this.state.text,
319 | onChange: this.textChanged,
320 | style: this.props.style,
321 | ref: 'input' });
322 | }
323 | }
324 | }]);
325 |
326 | return InlineEdit;
327 | }(_react2.default.Component);
328 |
329 | InlineEdit.propTypes = {
330 | text: _propTypes2.default.string.isRequired,
331 | paramName: _propTypes2.default.string.isRequired,
332 | change: _propTypes2.default.func.isRequired,
333 | placeholder: _propTypes2.default.string,
334 | className: _propTypes2.default.string,
335 | activeClassName: _propTypes2.default.string,
336 | minLength: _propTypes2.default.number,
337 | maxLength: _propTypes2.default.number,
338 | validate: _propTypes2.default.func,
339 | style: _propTypes2.default.object,
340 | editingElement: _propTypes2.default.string,
341 | staticElement: _propTypes2.default.string,
342 | tabIndex: _propTypes2.default.number,
343 | isDisabled: _propTypes2.default.bool,
344 | editing: _propTypes2.default.bool
345 | };
346 | InlineEdit.defaultProps = {
347 | minLength: 1,
348 | maxLength: 256,
349 | editingElement: 'input',
350 | staticElement: 'span',
351 | tabIndex: 0,
352 | isDisabled: false,
353 | editing: false
354 | };
355 | exports.default = InlineEdit;
356 |
357 | /***/ }),
358 | /* 2 */
359 | /***/ (function(module, exports) {
360 |
361 | module.exports = React;
362 |
363 | /***/ }),
364 | /* 3 */
365 | /***/ (function(module, exports) {
366 |
367 | module.exports = ReactDOM;
368 |
369 | /***/ }),
370 | /* 4 */
371 | /***/ (function(module, exports, __webpack_require__) {
372 |
373 | /* WEBPACK VAR INJECTION */(function(process) {/**
374 | * Copyright (c) 2013-present, Facebook, Inc.
375 | *
376 | * This source code is licensed under the MIT license found in the
377 | * LICENSE file in the root directory of this source tree.
378 | */
379 |
380 | if (process.env.NODE_ENV !== 'production') {
381 | var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
382 | Symbol.for &&
383 | Symbol.for('react.element')) ||
384 | 0xeac7;
385 |
386 | var isValidElement = function(object) {
387 | return typeof object === 'object' &&
388 | object !== null &&
389 | object.$$typeof === REACT_ELEMENT_TYPE;
390 | };
391 |
392 | // By explicitly using `prop-types` you are opting into new development behavior.
393 | // http://fb.me/prop-types-in-prod
394 | var throwOnDirectAccess = true;
395 | module.exports = __webpack_require__(6)(isValidElement, throwOnDirectAccess);
396 | } else {
397 | // By explicitly using `prop-types` you are opting into new production behavior.
398 | // http://fb.me/prop-types-in-prod
399 | module.exports = __webpack_require__(13)();
400 | }
401 |
402 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
403 |
404 | /***/ }),
405 | /* 5 */
406 | /***/ (function(module, exports) {
407 |
408 | // shim for using process in browser
409 | var process = module.exports = {};
410 |
411 | // cached from whatever global is present so that test runners that stub it
412 | // don't break things. But we need to wrap it in a try catch in case it is
413 | // wrapped in strict mode code which doesn't define any globals. It's inside a
414 | // function because try/catches deoptimize in certain engines.
415 |
416 | var cachedSetTimeout;
417 | var cachedClearTimeout;
418 |
419 | function defaultSetTimout() {
420 | throw new Error('setTimeout has not been defined');
421 | }
422 | function defaultClearTimeout () {
423 | throw new Error('clearTimeout has not been defined');
424 | }
425 | (function () {
426 | try {
427 | if (typeof setTimeout === 'function') {
428 | cachedSetTimeout = setTimeout;
429 | } else {
430 | cachedSetTimeout = defaultSetTimout;
431 | }
432 | } catch (e) {
433 | cachedSetTimeout = defaultSetTimout;
434 | }
435 | try {
436 | if (typeof clearTimeout === 'function') {
437 | cachedClearTimeout = clearTimeout;
438 | } else {
439 | cachedClearTimeout = defaultClearTimeout;
440 | }
441 | } catch (e) {
442 | cachedClearTimeout = defaultClearTimeout;
443 | }
444 | } ())
445 | function runTimeout(fun) {
446 | if (cachedSetTimeout === setTimeout) {
447 | //normal enviroments in sane situations
448 | return setTimeout(fun, 0);
449 | }
450 | // if setTimeout wasn't available but was latter defined
451 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
452 | cachedSetTimeout = setTimeout;
453 | return setTimeout(fun, 0);
454 | }
455 | try {
456 | // when when somebody has screwed with setTimeout but no I.E. maddness
457 | return cachedSetTimeout(fun, 0);
458 | } catch(e){
459 | try {
460 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
461 | return cachedSetTimeout.call(null, fun, 0);
462 | } catch(e){
463 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
464 | return cachedSetTimeout.call(this, fun, 0);
465 | }
466 | }
467 |
468 |
469 | }
470 | function runClearTimeout(marker) {
471 | if (cachedClearTimeout === clearTimeout) {
472 | //normal enviroments in sane situations
473 | return clearTimeout(marker);
474 | }
475 | // if clearTimeout wasn't available but was latter defined
476 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
477 | cachedClearTimeout = clearTimeout;
478 | return clearTimeout(marker);
479 | }
480 | try {
481 | // when when somebody has screwed with setTimeout but no I.E. maddness
482 | return cachedClearTimeout(marker);
483 | } catch (e){
484 | try {
485 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
486 | return cachedClearTimeout.call(null, marker);
487 | } catch (e){
488 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
489 | // Some versions of I.E. have different rules for clearTimeout vs setTimeout
490 | return cachedClearTimeout.call(this, marker);
491 | }
492 | }
493 |
494 |
495 |
496 | }
497 | var queue = [];
498 | var draining = false;
499 | var currentQueue;
500 | var queueIndex = -1;
501 |
502 | function cleanUpNextTick() {
503 | if (!draining || !currentQueue) {
504 | return;
505 | }
506 | draining = false;
507 | if (currentQueue.length) {
508 | queue = currentQueue.concat(queue);
509 | } else {
510 | queueIndex = -1;
511 | }
512 | if (queue.length) {
513 | drainQueue();
514 | }
515 | }
516 |
517 | function drainQueue() {
518 | if (draining) {
519 | return;
520 | }
521 | var timeout = runTimeout(cleanUpNextTick);
522 | draining = true;
523 |
524 | var len = queue.length;
525 | while(len) {
526 | currentQueue = queue;
527 | queue = [];
528 | while (++queueIndex < len) {
529 | if (currentQueue) {
530 | currentQueue[queueIndex].run();
531 | }
532 | }
533 | queueIndex = -1;
534 | len = queue.length;
535 | }
536 | currentQueue = null;
537 | draining = false;
538 | runClearTimeout(timeout);
539 | }
540 |
541 | process.nextTick = function (fun) {
542 | var args = new Array(arguments.length - 1);
543 | if (arguments.length > 1) {
544 | for (var i = 1; i < arguments.length; i++) {
545 | args[i - 1] = arguments[i];
546 | }
547 | }
548 | queue.push(new Item(fun, args));
549 | if (queue.length === 1 && !draining) {
550 | runTimeout(drainQueue);
551 | }
552 | };
553 |
554 | // v8 likes predictible objects
555 | function Item(fun, array) {
556 | this.fun = fun;
557 | this.array = array;
558 | }
559 | Item.prototype.run = function () {
560 | this.fun.apply(null, this.array);
561 | };
562 | process.title = 'browser';
563 | process.browser = true;
564 | process.env = {};
565 | process.argv = [];
566 | process.version = ''; // empty string to avoid regexp issues
567 | process.versions = {};
568 |
569 | function noop() {}
570 |
571 | process.on = noop;
572 | process.addListener = noop;
573 | process.once = noop;
574 | process.off = noop;
575 | process.removeListener = noop;
576 | process.removeAllListeners = noop;
577 | process.emit = noop;
578 | process.prependListener = noop;
579 | process.prependOnceListener = noop;
580 |
581 | process.listeners = function (name) { return [] }
582 |
583 | process.binding = function (name) {
584 | throw new Error('process.binding is not supported');
585 | };
586 |
587 | process.cwd = function () { return '/' };
588 | process.chdir = function (dir) {
589 | throw new Error('process.chdir is not supported');
590 | };
591 | process.umask = function() { return 0; };
592 |
593 |
594 | /***/ }),
595 | /* 6 */
596 | /***/ (function(module, exports, __webpack_require__) {
597 |
598 | /* WEBPACK VAR INJECTION */(function(process) {/**
599 | * Copyright (c) 2013-present, Facebook, Inc.
600 | *
601 | * This source code is licensed under the MIT license found in the
602 | * LICENSE file in the root directory of this source tree.
603 | */
604 |
605 | 'use strict';
606 |
607 | var emptyFunction = __webpack_require__(7);
608 | var invariant = __webpack_require__(8);
609 | var warning = __webpack_require__(9);
610 | var assign = __webpack_require__(10);
611 |
612 | var ReactPropTypesSecret = __webpack_require__(11);
613 | var checkPropTypes = __webpack_require__(12);
614 |
615 | module.exports = function(isValidElement, throwOnDirectAccess) {
616 | /* global Symbol */
617 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
618 | var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
619 |
620 | /**
621 | * Returns the iterator method function contained on the iterable object.
622 | *
623 | * Be sure to invoke the function with the iterable as context:
624 | *
625 | * var iteratorFn = getIteratorFn(myIterable);
626 | * if (iteratorFn) {
627 | * var iterator = iteratorFn.call(myIterable);
628 | * ...
629 | * }
630 | *
631 | * @param {?object} maybeIterable
632 | * @return {?function}
633 | */
634 | function getIteratorFn(maybeIterable) {
635 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
636 | if (typeof iteratorFn === 'function') {
637 | return iteratorFn;
638 | }
639 | }
640 |
641 | /**
642 | * Collection of methods that allow declaration and validation of props that are
643 | * supplied to React components. Example usage:
644 | *
645 | * var Props = require('ReactPropTypes');
646 | * var MyArticle = React.createClass({
647 | * propTypes: {
648 | * // An optional string prop named "description".
649 | * description: Props.string,
650 | *
651 | * // A required enum prop named "category".
652 | * category: Props.oneOf(['News','Photos']).isRequired,
653 | *
654 | * // A prop named "dialog" that requires an instance of Dialog.
655 | * dialog: Props.instanceOf(Dialog).isRequired
656 | * },
657 | * render: function() { ... }
658 | * });
659 | *
660 | * A more formal specification of how these methods are used:
661 | *
662 | * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
663 | * decl := ReactPropTypes.{type}(.isRequired)?
664 | *
665 | * Each and every declaration produces a function with the same signature. This
666 | * allows the creation of custom validation functions. For example:
667 | *
668 | * var MyLink = React.createClass({
669 | * propTypes: {
670 | * // An optional string or URI prop named "href".
671 | * href: function(props, propName, componentName) {
672 | * var propValue = props[propName];
673 | * if (propValue != null && typeof propValue !== 'string' &&
674 | * !(propValue instanceof URI)) {
675 | * return new Error(
676 | * 'Expected a string or an URI for ' + propName + ' in ' +
677 | * componentName
678 | * );
679 | * }
680 | * }
681 | * },
682 | * render: function() {...}
683 | * });
684 | *
685 | * @internal
686 | */
687 |
688 | var ANONYMOUS = '<>';
689 |
690 | // Important!
691 | // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
692 | var ReactPropTypes = {
693 | array: createPrimitiveTypeChecker('array'),
694 | bool: createPrimitiveTypeChecker('boolean'),
695 | func: createPrimitiveTypeChecker('function'),
696 | number: createPrimitiveTypeChecker('number'),
697 | object: createPrimitiveTypeChecker('object'),
698 | string: createPrimitiveTypeChecker('string'),
699 | symbol: createPrimitiveTypeChecker('symbol'),
700 |
701 | any: createAnyTypeChecker(),
702 | arrayOf: createArrayOfTypeChecker,
703 | element: createElementTypeChecker(),
704 | instanceOf: createInstanceTypeChecker,
705 | node: createNodeChecker(),
706 | objectOf: createObjectOfTypeChecker,
707 | oneOf: createEnumTypeChecker,
708 | oneOfType: createUnionTypeChecker,
709 | shape: createShapeTypeChecker,
710 | exact: createStrictShapeTypeChecker,
711 | };
712 |
713 | /**
714 | * inlined Object.is polyfill to avoid requiring consumers ship their own
715 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
716 | */
717 | /*eslint-disable no-self-compare*/
718 | function is(x, y) {
719 | // SameValue algorithm
720 | if (x === y) {
721 | // Steps 1-5, 7-10
722 | // Steps 6.b-6.e: +0 != -0
723 | return x !== 0 || 1 / x === 1 / y;
724 | } else {
725 | // Step 6.a: NaN == NaN
726 | return x !== x && y !== y;
727 | }
728 | }
729 | /*eslint-enable no-self-compare*/
730 |
731 | /**
732 | * We use an Error-like object for backward compatibility as people may call
733 | * PropTypes directly and inspect their output. However, we don't use real
734 | * Errors anymore. We don't inspect their stack anyway, and creating them
735 | * is prohibitively expensive if they are created too often, such as what
736 | * happens in oneOfType() for any type before the one that matched.
737 | */
738 | function PropTypeError(message) {
739 | this.message = message;
740 | this.stack = '';
741 | }
742 | // Make `instanceof Error` still work for returned errors.
743 | PropTypeError.prototype = Error.prototype;
744 |
745 | function createChainableTypeChecker(validate) {
746 | if (process.env.NODE_ENV !== 'production') {
747 | var manualPropTypeCallCache = {};
748 | var manualPropTypeWarningCount = 0;
749 | }
750 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
751 | componentName = componentName || ANONYMOUS;
752 | propFullName = propFullName || propName;
753 |
754 | if (secret !== ReactPropTypesSecret) {
755 | if (throwOnDirectAccess) {
756 | // New behavior only for users of `prop-types` package
757 | invariant(
758 | false,
759 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
760 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
761 | 'Read more at http://fb.me/use-check-prop-types'
762 | );
763 | } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
764 | // Old behavior for people using React.PropTypes
765 | var cacheKey = componentName + ':' + propName;
766 | if (
767 | !manualPropTypeCallCache[cacheKey] &&
768 | // Avoid spamming the console because they are often not actionable except for lib authors
769 | manualPropTypeWarningCount < 3
770 | ) {
771 | warning(
772 | false,
773 | 'You are manually calling a React.PropTypes validation ' +
774 | 'function for the `%s` prop on `%s`. This is deprecated ' +
775 | 'and will throw in the standalone `prop-types` package. ' +
776 | 'You may be seeing this warning due to a third-party PropTypes ' +
777 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
778 | propFullName,
779 | componentName
780 | );
781 | manualPropTypeCallCache[cacheKey] = true;
782 | manualPropTypeWarningCount++;
783 | }
784 | }
785 | }
786 | if (props[propName] == null) {
787 | if (isRequired) {
788 | if (props[propName] === null) {
789 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
790 | }
791 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
792 | }
793 | return null;
794 | } else {
795 | return validate(props, propName, componentName, location, propFullName);
796 | }
797 | }
798 |
799 | var chainedCheckType = checkType.bind(null, false);
800 | chainedCheckType.isRequired = checkType.bind(null, true);
801 |
802 | return chainedCheckType;
803 | }
804 |
805 | function createPrimitiveTypeChecker(expectedType) {
806 | function validate(props, propName, componentName, location, propFullName, secret) {
807 | var propValue = props[propName];
808 | var propType = getPropType(propValue);
809 | if (propType !== expectedType) {
810 | // `propValue` being instance of, say, date/regexp, pass the 'object'
811 | // check, but we can offer a more precise error message here rather than
812 | // 'of type `object`'.
813 | var preciseType = getPreciseType(propValue);
814 |
815 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
816 | }
817 | return null;
818 | }
819 | return createChainableTypeChecker(validate);
820 | }
821 |
822 | function createAnyTypeChecker() {
823 | return createChainableTypeChecker(emptyFunction.thatReturnsNull);
824 | }
825 |
826 | function createArrayOfTypeChecker(typeChecker) {
827 | function validate(props, propName, componentName, location, propFullName) {
828 | if (typeof typeChecker !== 'function') {
829 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
830 | }
831 | var propValue = props[propName];
832 | if (!Array.isArray(propValue)) {
833 | var propType = getPropType(propValue);
834 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
835 | }
836 | for (var i = 0; i < propValue.length; i++) {
837 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
838 | if (error instanceof Error) {
839 | return error;
840 | }
841 | }
842 | return null;
843 | }
844 | return createChainableTypeChecker(validate);
845 | }
846 |
847 | function createElementTypeChecker() {
848 | function validate(props, propName, componentName, location, propFullName) {
849 | var propValue = props[propName];
850 | if (!isValidElement(propValue)) {
851 | var propType = getPropType(propValue);
852 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
853 | }
854 | return null;
855 | }
856 | return createChainableTypeChecker(validate);
857 | }
858 |
859 | function createInstanceTypeChecker(expectedClass) {
860 | function validate(props, propName, componentName, location, propFullName) {
861 | if (!(props[propName] instanceof expectedClass)) {
862 | var expectedClassName = expectedClass.name || ANONYMOUS;
863 | var actualClassName = getClassName(props[propName]);
864 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
865 | }
866 | return null;
867 | }
868 | return createChainableTypeChecker(validate);
869 | }
870 |
871 | function createEnumTypeChecker(expectedValues) {
872 | if (!Array.isArray(expectedValues)) {
873 | process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
874 | return emptyFunction.thatReturnsNull;
875 | }
876 |
877 | function validate(props, propName, componentName, location, propFullName) {
878 | var propValue = props[propName];
879 | for (var i = 0; i < expectedValues.length; i++) {
880 | if (is(propValue, expectedValues[i])) {
881 | return null;
882 | }
883 | }
884 |
885 | var valuesString = JSON.stringify(expectedValues);
886 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
887 | }
888 | return createChainableTypeChecker(validate);
889 | }
890 |
891 | function createObjectOfTypeChecker(typeChecker) {
892 | function validate(props, propName, componentName, location, propFullName) {
893 | if (typeof typeChecker !== 'function') {
894 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
895 | }
896 | var propValue = props[propName];
897 | var propType = getPropType(propValue);
898 | if (propType !== 'object') {
899 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
900 | }
901 | for (var key in propValue) {
902 | if (propValue.hasOwnProperty(key)) {
903 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
904 | if (error instanceof Error) {
905 | return error;
906 | }
907 | }
908 | }
909 | return null;
910 | }
911 | return createChainableTypeChecker(validate);
912 | }
913 |
914 | function createUnionTypeChecker(arrayOfTypeCheckers) {
915 | if (!Array.isArray(arrayOfTypeCheckers)) {
916 | process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
917 | return emptyFunction.thatReturnsNull;
918 | }
919 |
920 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
921 | var checker = arrayOfTypeCheckers[i];
922 | if (typeof checker !== 'function') {
923 | warning(
924 | false,
925 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
926 | 'received %s at index %s.',
927 | getPostfixForTypeWarning(checker),
928 | i
929 | );
930 | return emptyFunction.thatReturnsNull;
931 | }
932 | }
933 |
934 | function validate(props, propName, componentName, location, propFullName) {
935 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
936 | var checker = arrayOfTypeCheckers[i];
937 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
938 | return null;
939 | }
940 | }
941 |
942 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
943 | }
944 | return createChainableTypeChecker(validate);
945 | }
946 |
947 | function createNodeChecker() {
948 | function validate(props, propName, componentName, location, propFullName) {
949 | if (!isNode(props[propName])) {
950 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
951 | }
952 | return null;
953 | }
954 | return createChainableTypeChecker(validate);
955 | }
956 |
957 | function createShapeTypeChecker(shapeTypes) {
958 | function validate(props, propName, componentName, location, propFullName) {
959 | var propValue = props[propName];
960 | var propType = getPropType(propValue);
961 | if (propType !== 'object') {
962 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
963 | }
964 | for (var key in shapeTypes) {
965 | var checker = shapeTypes[key];
966 | if (!checker) {
967 | continue;
968 | }
969 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
970 | if (error) {
971 | return error;
972 | }
973 | }
974 | return null;
975 | }
976 | return createChainableTypeChecker(validate);
977 | }
978 |
979 | function createStrictShapeTypeChecker(shapeTypes) {
980 | function validate(props, propName, componentName, location, propFullName) {
981 | var propValue = props[propName];
982 | var propType = getPropType(propValue);
983 | if (propType !== 'object') {
984 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
985 | }
986 | // We need to check all keys in case some are required but missing from
987 | // props.
988 | var allKeys = assign({}, props[propName], shapeTypes);
989 | for (var key in allKeys) {
990 | var checker = shapeTypes[key];
991 | if (!checker) {
992 | return new PropTypeError(
993 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
994 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
995 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
996 | );
997 | }
998 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
999 | if (error) {
1000 | return error;
1001 | }
1002 | }
1003 | return null;
1004 | }
1005 |
1006 | return createChainableTypeChecker(validate);
1007 | }
1008 |
1009 | function isNode(propValue) {
1010 | switch (typeof propValue) {
1011 | case 'number':
1012 | case 'string':
1013 | case 'undefined':
1014 | return true;
1015 | case 'boolean':
1016 | return !propValue;
1017 | case 'object':
1018 | if (Array.isArray(propValue)) {
1019 | return propValue.every(isNode);
1020 | }
1021 | if (propValue === null || isValidElement(propValue)) {
1022 | return true;
1023 | }
1024 |
1025 | var iteratorFn = getIteratorFn(propValue);
1026 | if (iteratorFn) {
1027 | var iterator = iteratorFn.call(propValue);
1028 | var step;
1029 | if (iteratorFn !== propValue.entries) {
1030 | while (!(step = iterator.next()).done) {
1031 | if (!isNode(step.value)) {
1032 | return false;
1033 | }
1034 | }
1035 | } else {
1036 | // Iterator will provide entry [k,v] tuples rather than values.
1037 | while (!(step = iterator.next()).done) {
1038 | var entry = step.value;
1039 | if (entry) {
1040 | if (!isNode(entry[1])) {
1041 | return false;
1042 | }
1043 | }
1044 | }
1045 | }
1046 | } else {
1047 | return false;
1048 | }
1049 |
1050 | return true;
1051 | default:
1052 | return false;
1053 | }
1054 | }
1055 |
1056 | function isSymbol(propType, propValue) {
1057 | // Native Symbol.
1058 | if (propType === 'symbol') {
1059 | return true;
1060 | }
1061 |
1062 | // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1063 | if (propValue['@@toStringTag'] === 'Symbol') {
1064 | return true;
1065 | }
1066 |
1067 | // Fallback for non-spec compliant Symbols which are polyfilled.
1068 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1069 | return true;
1070 | }
1071 |
1072 | return false;
1073 | }
1074 |
1075 | // Equivalent of `typeof` but with special handling for array and regexp.
1076 | function getPropType(propValue) {
1077 | var propType = typeof propValue;
1078 | if (Array.isArray(propValue)) {
1079 | return 'array';
1080 | }
1081 | if (propValue instanceof RegExp) {
1082 | // Old webkits (at least until Android 4.0) return 'function' rather than
1083 | // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1084 | // passes PropTypes.object.
1085 | return 'object';
1086 | }
1087 | if (isSymbol(propType, propValue)) {
1088 | return 'symbol';
1089 | }
1090 | return propType;
1091 | }
1092 |
1093 | // This handles more types than `getPropType`. Only used for error messages.
1094 | // See `createPrimitiveTypeChecker`.
1095 | function getPreciseType(propValue) {
1096 | if (typeof propValue === 'undefined' || propValue === null) {
1097 | return '' + propValue;
1098 | }
1099 | var propType = getPropType(propValue);
1100 | if (propType === 'object') {
1101 | if (propValue instanceof Date) {
1102 | return 'date';
1103 | } else if (propValue instanceof RegExp) {
1104 | return 'regexp';
1105 | }
1106 | }
1107 | return propType;
1108 | }
1109 |
1110 | // Returns a string that is postfixed to a warning about an invalid type.
1111 | // For example, "undefined" or "of type array"
1112 | function getPostfixForTypeWarning(value) {
1113 | var type = getPreciseType(value);
1114 | switch (type) {
1115 | case 'array':
1116 | case 'object':
1117 | return 'an ' + type;
1118 | case 'boolean':
1119 | case 'date':
1120 | case 'regexp':
1121 | return 'a ' + type;
1122 | default:
1123 | return type;
1124 | }
1125 | }
1126 |
1127 | // Returns class name of the object, if any.
1128 | function getClassName(propValue) {
1129 | if (!propValue.constructor || !propValue.constructor.name) {
1130 | return ANONYMOUS;
1131 | }
1132 | return propValue.constructor.name;
1133 | }
1134 |
1135 | ReactPropTypes.checkPropTypes = checkPropTypes;
1136 | ReactPropTypes.PropTypes = ReactPropTypes;
1137 |
1138 | return ReactPropTypes;
1139 | };
1140 |
1141 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
1142 |
1143 | /***/ }),
1144 | /* 7 */
1145 | /***/ (function(module, exports) {
1146 |
1147 | "use strict";
1148 |
1149 | /**
1150 | * Copyright (c) 2013-present, Facebook, Inc.
1151 | *
1152 | * This source code is licensed under the MIT license found in the
1153 | * LICENSE file in the root directory of this source tree.
1154 | *
1155 | *
1156 | */
1157 |
1158 | function makeEmptyFunction(arg) {
1159 | return function () {
1160 | return arg;
1161 | };
1162 | }
1163 |
1164 | /**
1165 | * This function accepts and discards inputs; it has no side effects. This is
1166 | * primarily useful idiomatically for overridable function endpoints which
1167 | * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
1168 | */
1169 | var emptyFunction = function emptyFunction() {};
1170 |
1171 | emptyFunction.thatReturns = makeEmptyFunction;
1172 | emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
1173 | emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
1174 | emptyFunction.thatReturnsNull = makeEmptyFunction(null);
1175 | emptyFunction.thatReturnsThis = function () {
1176 | return this;
1177 | };
1178 | emptyFunction.thatReturnsArgument = function (arg) {
1179 | return arg;
1180 | };
1181 |
1182 | module.exports = emptyFunction;
1183 |
1184 | /***/ }),
1185 | /* 8 */
1186 | /***/ (function(module, exports, __webpack_require__) {
1187 |
1188 | /* WEBPACK VAR INJECTION */(function(process) {/**
1189 | * Copyright (c) 2013-present, Facebook, Inc.
1190 | *
1191 | * This source code is licensed under the MIT license found in the
1192 | * LICENSE file in the root directory of this source tree.
1193 | *
1194 | */
1195 |
1196 | 'use strict';
1197 |
1198 | /**
1199 | * Use invariant() to assert state which your program assumes to be true.
1200 | *
1201 | * Provide sprintf-style format (only %s is supported) and arguments
1202 | * to provide information about what broke and what you were
1203 | * expecting.
1204 | *
1205 | * The invariant message will be stripped in production, but the invariant
1206 | * will remain to ensure logic does not differ in production.
1207 | */
1208 |
1209 | var validateFormat = function validateFormat(format) {};
1210 |
1211 | if (process.env.NODE_ENV !== 'production') {
1212 | validateFormat = function validateFormat(format) {
1213 | if (format === undefined) {
1214 | throw new Error('invariant requires an error message argument');
1215 | }
1216 | };
1217 | }
1218 |
1219 | function invariant(condition, format, a, b, c, d, e, f) {
1220 | validateFormat(format);
1221 |
1222 | if (!condition) {
1223 | var error;
1224 | if (format === undefined) {
1225 | error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
1226 | } else {
1227 | var args = [a, b, c, d, e, f];
1228 | var argIndex = 0;
1229 | error = new Error(format.replace(/%s/g, function () {
1230 | return args[argIndex++];
1231 | }));
1232 | error.name = 'Invariant Violation';
1233 | }
1234 |
1235 | error.framesToPop = 1; // we don't care about invariant's own frame
1236 | throw error;
1237 | }
1238 | }
1239 |
1240 | module.exports = invariant;
1241 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
1242 |
1243 | /***/ }),
1244 | /* 9 */
1245 | /***/ (function(module, exports, __webpack_require__) {
1246 |
1247 | /* WEBPACK VAR INJECTION */(function(process) {/**
1248 | * Copyright (c) 2014-present, Facebook, Inc.
1249 | *
1250 | * This source code is licensed under the MIT license found in the
1251 | * LICENSE file in the root directory of this source tree.
1252 | *
1253 | */
1254 |
1255 | 'use strict';
1256 |
1257 | var emptyFunction = __webpack_require__(7);
1258 |
1259 | /**
1260 | * Similar to invariant but only logs a warning if the condition is not met.
1261 | * This can be used to log issues in development environments in critical
1262 | * paths. Removing the logging code for production environments will keep the
1263 | * same logic and follow the same code paths.
1264 | */
1265 |
1266 | var warning = emptyFunction;
1267 |
1268 | if (process.env.NODE_ENV !== 'production') {
1269 | var printWarning = function printWarning(format) {
1270 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1271 | args[_key - 1] = arguments[_key];
1272 | }
1273 |
1274 | var argIndex = 0;
1275 | var message = 'Warning: ' + format.replace(/%s/g, function () {
1276 | return args[argIndex++];
1277 | });
1278 | if (typeof console !== 'undefined') {
1279 | console.error(message);
1280 | }
1281 | try {
1282 | // --- Welcome to debugging React ---
1283 | // This error was thrown as a convenience so that you can use this stack
1284 | // to find the callsite that caused this warning to fire.
1285 | throw new Error(message);
1286 | } catch (x) {}
1287 | };
1288 |
1289 | warning = function warning(condition, format) {
1290 | if (format === undefined) {
1291 | throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
1292 | }
1293 |
1294 | if (format.indexOf('Failed Composite propType: ') === 0) {
1295 | return; // Ignore CompositeComponent proptype check.
1296 | }
1297 |
1298 | if (!condition) {
1299 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
1300 | args[_key2 - 2] = arguments[_key2];
1301 | }
1302 |
1303 | printWarning.apply(undefined, [format].concat(args));
1304 | }
1305 | };
1306 | }
1307 |
1308 | module.exports = warning;
1309 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
1310 |
1311 | /***/ }),
1312 | /* 10 */
1313 | /***/ (function(module, exports) {
1314 |
1315 | /*
1316 | object-assign
1317 | (c) Sindre Sorhus
1318 | @license MIT
1319 | */
1320 |
1321 | 'use strict';
1322 | /* eslint-disable no-unused-vars */
1323 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1324 | var hasOwnProperty = Object.prototype.hasOwnProperty;
1325 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
1326 |
1327 | function toObject(val) {
1328 | if (val === null || val === undefined) {
1329 | throw new TypeError('Object.assign cannot be called with null or undefined');
1330 | }
1331 |
1332 | return Object(val);
1333 | }
1334 |
1335 | function shouldUseNative() {
1336 | try {
1337 | if (!Object.assign) {
1338 | return false;
1339 | }
1340 |
1341 | // Detect buggy property enumeration order in older V8 versions.
1342 |
1343 | // https://bugs.chromium.org/p/v8/issues/detail?id=4118
1344 | var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
1345 | test1[5] = 'de';
1346 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
1347 | return false;
1348 | }
1349 |
1350 | // https://bugs.chromium.org/p/v8/issues/detail?id=3056
1351 | var test2 = {};
1352 | for (var i = 0; i < 10; i++) {
1353 | test2['_' + String.fromCharCode(i)] = i;
1354 | }
1355 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
1356 | return test2[n];
1357 | });
1358 | if (order2.join('') !== '0123456789') {
1359 | return false;
1360 | }
1361 |
1362 | // https://bugs.chromium.org/p/v8/issues/detail?id=3056
1363 | var test3 = {};
1364 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
1365 | test3[letter] = letter;
1366 | });
1367 | if (Object.keys(Object.assign({}, test3)).join('') !==
1368 | 'abcdefghijklmnopqrst') {
1369 | return false;
1370 | }
1371 |
1372 | return true;
1373 | } catch (err) {
1374 | // We don't expect any of the above to throw, but better to be safe.
1375 | return false;
1376 | }
1377 | }
1378 |
1379 | module.exports = shouldUseNative() ? Object.assign : function (target, source) {
1380 | var from;
1381 | var to = toObject(target);
1382 | var symbols;
1383 |
1384 | for (var s = 1; s < arguments.length; s++) {
1385 | from = Object(arguments[s]);
1386 |
1387 | for (var key in from) {
1388 | if (hasOwnProperty.call(from, key)) {
1389 | to[key] = from[key];
1390 | }
1391 | }
1392 |
1393 | if (getOwnPropertySymbols) {
1394 | symbols = getOwnPropertySymbols(from);
1395 | for (var i = 0; i < symbols.length; i++) {
1396 | if (propIsEnumerable.call(from, symbols[i])) {
1397 | to[symbols[i]] = from[symbols[i]];
1398 | }
1399 | }
1400 | }
1401 | }
1402 |
1403 | return to;
1404 | };
1405 |
1406 |
1407 | /***/ }),
1408 | /* 11 */
1409 | /***/ (function(module, exports) {
1410 |
1411 | /**
1412 | * Copyright (c) 2013-present, Facebook, Inc.
1413 | *
1414 | * This source code is licensed under the MIT license found in the
1415 | * LICENSE file in the root directory of this source tree.
1416 | */
1417 |
1418 | 'use strict';
1419 |
1420 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1421 |
1422 | module.exports = ReactPropTypesSecret;
1423 |
1424 |
1425 | /***/ }),
1426 | /* 12 */
1427 | /***/ (function(module, exports, __webpack_require__) {
1428 |
1429 | /* WEBPACK VAR INJECTION */(function(process) {/**
1430 | * Copyright (c) 2013-present, Facebook, Inc.
1431 | *
1432 | * This source code is licensed under the MIT license found in the
1433 | * LICENSE file in the root directory of this source tree.
1434 | */
1435 |
1436 | 'use strict';
1437 |
1438 | if (process.env.NODE_ENV !== 'production') {
1439 | var invariant = __webpack_require__(8);
1440 | var warning = __webpack_require__(9);
1441 | var ReactPropTypesSecret = __webpack_require__(11);
1442 | var loggedTypeFailures = {};
1443 | }
1444 |
1445 | /**
1446 | * Assert that the values match with the type specs.
1447 | * Error messages are memorized and will only be shown once.
1448 | *
1449 | * @param {object} typeSpecs Map of name to a ReactPropType
1450 | * @param {object} values Runtime values that need to be type-checked
1451 | * @param {string} location e.g. "prop", "context", "child context"
1452 | * @param {string} componentName Name of the component for error messages.
1453 | * @param {?Function} getStack Returns the component stack.
1454 | * @private
1455 | */
1456 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
1457 | if (process.env.NODE_ENV !== 'production') {
1458 | for (var typeSpecName in typeSpecs) {
1459 | if (typeSpecs.hasOwnProperty(typeSpecName)) {
1460 | var error;
1461 | // Prop type validation may throw. In case they do, we don't want to
1462 | // fail the render phase where it didn't fail before. So we log it.
1463 | // After these have been cleaned up, we'll let them throw.
1464 | try {
1465 | // This is intentionally an invariant that gets caught. It's the same
1466 | // behavior as without this statement except with a better message.
1467 | invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
1468 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
1469 | } catch (ex) {
1470 | error = ex;
1471 | }
1472 | warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
1473 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
1474 | // Only monitor this failure once because there tends to be a lot of the
1475 | // same error.
1476 | loggedTypeFailures[error.message] = true;
1477 |
1478 | var stack = getStack ? getStack() : '';
1479 |
1480 | warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
1481 | }
1482 | }
1483 | }
1484 | }
1485 | }
1486 |
1487 | module.exports = checkPropTypes;
1488 |
1489 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
1490 |
1491 | /***/ }),
1492 | /* 13 */
1493 | /***/ (function(module, exports, __webpack_require__) {
1494 |
1495 | /**
1496 | * Copyright (c) 2013-present, Facebook, Inc.
1497 | *
1498 | * This source code is licensed under the MIT license found in the
1499 | * LICENSE file in the root directory of this source tree.
1500 | */
1501 |
1502 | 'use strict';
1503 |
1504 | var emptyFunction = __webpack_require__(7);
1505 | var invariant = __webpack_require__(8);
1506 | var ReactPropTypesSecret = __webpack_require__(11);
1507 |
1508 | module.exports = function() {
1509 | function shim(props, propName, componentName, location, propFullName, secret) {
1510 | if (secret === ReactPropTypesSecret) {
1511 | // It is still safe when called from React.
1512 | return;
1513 | }
1514 | invariant(
1515 | false,
1516 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1517 | 'Use PropTypes.checkPropTypes() to call them. ' +
1518 | 'Read more at http://fb.me/use-check-prop-types'
1519 | );
1520 | };
1521 | shim.isRequired = shim;
1522 | function getShim() {
1523 | return shim;
1524 | };
1525 | // Important!
1526 | // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1527 | var ReactPropTypes = {
1528 | array: shim,
1529 | bool: shim,
1530 | func: shim,
1531 | number: shim,
1532 | object: shim,
1533 | string: shim,
1534 | symbol: shim,
1535 |
1536 | any: shim,
1537 | arrayOf: getShim,
1538 | element: shim,
1539 | instanceOf: getShim,
1540 | node: shim,
1541 | objectOf: getShim,
1542 | oneOf: getShim,
1543 | oneOfType: getShim,
1544 | shape: getShim,
1545 | exact: getShim
1546 | };
1547 |
1548 | ReactPropTypes.checkPropTypes = emptyFunction;
1549 | ReactPropTypes.PropTypes = ReactPropTypes;
1550 |
1551 | return ReactPropTypes;
1552 | };
1553 |
1554 |
1555 | /***/ })
1556 | /******/ ]);
--------------------------------------------------------------------------------
/demo/index.jsx:
--------------------------------------------------------------------------------
1 | import InlineEdit from '../index';
2 | import React from 'react';
3 | import ReactDOM from 'react-dom';
4 |
5 | class MyParentComponent extends React.Component {
6 |
7 | constructor(props){
8 | super(props);
9 | this.dataChanged = this.dataChanged.bind(this);
10 | this.state = {
11 | message: 'ReactInline demo'
12 | }
13 | }
14 |
15 | dataChanged(data) {
16 | // data = { description: "New validated text comes here" }
17 | // Update your model from here
18 | console.log(data)
19 | this.setState({...data})
20 | }
21 |
22 | customValidateText(text) {
23 | return (text.length > 0 && text.length < 64);
24 | }
25 |
26 | render() {
27 | return (