diff options
author | 崖鹰 <zhao.wuz@alipay.com> | 2015-11-16 14:58:35 +0800 |
---|---|---|
committer | 崖鹰 <zhao.wuz@alipay.com> | 2015-11-16 14:58:35 +0800 |
commit | 80256746c1b81af8b19a4df9a93029e904d03859 (patch) | |
tree | c56268f890150bf45345359f54151b33129caa71 /examples/pick-time.js | |
download | time-picker-80256746c1b81af8b19a4df9a93029e904d03859.tar.gz time-picker-80256746c1b81af8b19a4df9a93029e904d03859.tar.zst time-picker-80256746c1b81af8b19a4df9a93029e904d03859.zip |
Updates
Diffstat (limited to 'examples/pick-time.js')
-rw-r--r-- | examples/pick-time.js | 28337 |
1 files changed, 28337 insertions, 0 deletions
diff --git a/examples/pick-time.js b/examples/pick-time.js new file mode 100644 index 0000000..0bce1d3 --- /dev/null +++ b/examples/pick-time.js | |||
@@ -0,0 +1,28337 @@ | |||
1 | webpackJsonp([0,1],[ | ||
2 | /* 0 */ | ||
3 | /***/ function(module, exports, __webpack_require__) { | ||
4 | |||
5 | module.exports = __webpack_require__(1); | ||
6 | |||
7 | |||
8 | /***/ }, | ||
9 | /* 1 */ | ||
10 | /***/ function(module, exports, __webpack_require__) { | ||
11 | |||
12 | 'use strict'; | ||
13 | |||
14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
15 | |||
16 | __webpack_require__(2); | ||
17 | |||
18 | var _react = __webpack_require__(3); | ||
19 | |||
20 | var _react2 = _interopRequireDefault(_react); | ||
21 | |||
22 | var _reactDom = __webpack_require__(160); | ||
23 | |||
24 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
25 | |||
26 | var _gregorianCalendar = __webpack_require__(161); | ||
27 | |||
28 | var _gregorianCalendar2 = _interopRequireDefault(_gregorianCalendar); | ||
29 | |||
30 | var _gregorianCalendarFormat = __webpack_require__(165); | ||
31 | |||
32 | var _gregorianCalendarFormat2 = _interopRequireDefault(_gregorianCalendarFormat); | ||
33 | |||
34 | var _gregorianCalendarLibLocaleZh_CN = __webpack_require__(168); | ||
35 | |||
36 | var _gregorianCalendarLibLocaleZh_CN2 = _interopRequireDefault(_gregorianCalendarLibLocaleZh_CN); | ||
37 | |||
38 | var _rcTimePickerSrcTimePicker = __webpack_require__(169); | ||
39 | |||
40 | var _rcTimePickerSrcTimePicker2 = _interopRequireDefault(_rcTimePickerSrcTimePicker); | ||
41 | |||
42 | var _rcTimePickerSrcTimePanel = __webpack_require__(230); | ||
43 | |||
44 | var _rcTimePickerSrcTimePanel2 = _interopRequireDefault(_rcTimePickerSrcTimePanel); | ||
45 | |||
46 | var _rcTimePickerSrcLocaleZh_CN = __webpack_require__(234); | ||
47 | |||
48 | var _rcTimePickerSrcLocaleZh_CN2 = _interopRequireDefault(_rcTimePickerSrcLocaleZh_CN); | ||
49 | |||
50 | var formatter = new _gregorianCalendarFormat2['default']('HH:mm:ss'); | ||
51 | |||
52 | var now = new _gregorianCalendar2['default'](_gregorianCalendarLibLocaleZh_CN2['default']); | ||
53 | now.setTime(Date.now()); | ||
54 | |||
55 | var timePanel = _react2['default'].createElement(_rcTimePickerSrcTimePanel2['default'], { | ||
56 | defaultValue: now, | ||
57 | locale: _rcTimePickerSrcLocaleZh_CN2['default'], | ||
58 | formatter: formatter, | ||
59 | minuteOptions: [0, 30] | ||
60 | }); | ||
61 | |||
62 | _reactDom2['default'].render(_react2['default'].createElement( | ||
63 | _rcTimePickerSrcTimePicker2['default'], | ||
64 | { panel: timePanel, value: now }, | ||
65 | function (_ref) { | ||
66 | var value = _ref.value; | ||
67 | |||
68 | return _react2['default'].createElement('input', { type: 'text', placeholder: '请选择时间', readOnly: true, value: value && formatter.format(value) }); | ||
69 | } | ||
70 | ), document.getElementById('__react-content')); | ||
71 | |||
72 | /***/ }, | ||
73 | /* 2 */ | ||
74 | /***/ function(module, exports) { | ||
75 | |||
76 | // removed by extract-text-webpack-plugin | ||
77 | |||
78 | /***/ }, | ||
79 | /* 3 */ | ||
80 | /***/ function(module, exports, __webpack_require__) { | ||
81 | |||
82 | 'use strict'; | ||
83 | |||
84 | module.exports = __webpack_require__(4); | ||
85 | |||
86 | |||
87 | /***/ }, | ||
88 | /* 4 */ | ||
89 | /***/ function(module, exports, __webpack_require__) { | ||
90 | |||
91 | /** | ||
92 | * Copyright 2013-2015, Facebook, Inc. | ||
93 | * All rights reserved. | ||
94 | * | ||
95 | * This source code is licensed under the BSD-style license found in the | ||
96 | * LICENSE file in the root directory of this source tree. An additional grant | ||
97 | * of patent rights can be found in the PATENTS file in the same directory. | ||
98 | * | ||
99 | * @providesModule React | ||
100 | */ | ||
101 | |||
102 | 'use strict'; | ||
103 | |||
104 | var ReactDOM = __webpack_require__(5); | ||
105 | var ReactDOMServer = __webpack_require__(150); | ||
106 | var ReactIsomorphic = __webpack_require__(154); | ||
107 | |||
108 | var assign = __webpack_require__(41); | ||
109 | var deprecated = __webpack_require__(159); | ||
110 | |||
111 | // `version` will be added here by ReactIsomorphic. | ||
112 | var React = {}; | ||
113 | |||
114 | assign(React, ReactIsomorphic); | ||
115 | |||
116 | assign(React, { | ||
117 | // ReactDOM | ||
118 | findDOMNode: deprecated('findDOMNode', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.findDOMNode), | ||
119 | render: deprecated('render', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.render), | ||
120 | unmountComponentAtNode: deprecated('unmountComponentAtNode', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.unmountComponentAtNode), | ||
121 | |||
122 | // ReactDOMServer | ||
123 | renderToString: deprecated('renderToString', 'ReactDOMServer', 'react-dom/server', ReactDOMServer, ReactDOMServer.renderToString), | ||
124 | renderToStaticMarkup: deprecated('renderToStaticMarkup', 'ReactDOMServer', 'react-dom/server', ReactDOMServer, ReactDOMServer.renderToStaticMarkup) | ||
125 | }); | ||
126 | |||
127 | React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM; | ||
128 | |||
129 | module.exports = React; | ||
130 | |||
131 | /***/ }, | ||
132 | /* 5 */ | ||
133 | /***/ function(module, exports, __webpack_require__) { | ||
134 | |||
135 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
136 | * Copyright 2013-2015, Facebook, Inc. | ||
137 | * All rights reserved. | ||
138 | * | ||
139 | * This source code is licensed under the BSD-style license found in the | ||
140 | * LICENSE file in the root directory of this source tree. An additional grant | ||
141 | * of patent rights can be found in the PATENTS file in the same directory. | ||
142 | * | ||
143 | * @providesModule ReactDOM | ||
144 | */ | ||
145 | |||
146 | /* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/ | ||
147 | |||
148 | 'use strict'; | ||
149 | |||
150 | var ReactCurrentOwner = __webpack_require__(7); | ||
151 | var ReactDOMTextComponent = __webpack_require__(8); | ||
152 | var ReactDefaultInjection = __webpack_require__(73); | ||
153 | var ReactInstanceHandles = __webpack_require__(47); | ||
154 | var ReactMount = __webpack_require__(30); | ||
155 | var ReactPerf = __webpack_require__(20); | ||
156 | var ReactReconciler = __webpack_require__(52); | ||
157 | var ReactUpdates = __webpack_require__(56); | ||
158 | var ReactVersion = __webpack_require__(148); | ||
159 | |||
160 | var findDOMNode = __webpack_require__(93); | ||
161 | var renderSubtreeIntoContainer = __webpack_require__(149); | ||
162 | var warning = __webpack_require__(27); | ||
163 | |||
164 | ReactDefaultInjection.inject(); | ||
165 | |||
166 | var render = ReactPerf.measure('React', 'render', ReactMount.render); | ||
167 | |||
168 | var React = { | ||
169 | findDOMNode: findDOMNode, | ||
170 | render: render, | ||
171 | unmountComponentAtNode: ReactMount.unmountComponentAtNode, | ||
172 | version: ReactVersion, | ||
173 | |||
174 | /* eslint-disable camelcase */ | ||
175 | unstable_batchedUpdates: ReactUpdates.batchedUpdates, | ||
176 | unstable_renderSubtreeIntoContainer: renderSubtreeIntoContainer | ||
177 | }; | ||
178 | |||
179 | // Inject the runtime into a devtools global hook regardless of browser. | ||
180 | // Allows for debugging when the hook is injected on the page. | ||
181 | /* eslint-enable camelcase */ | ||
182 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') { | ||
183 | __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ | ||
184 | CurrentOwner: ReactCurrentOwner, | ||
185 | InstanceHandles: ReactInstanceHandles, | ||
186 | Mount: ReactMount, | ||
187 | Reconciler: ReactReconciler, | ||
188 | TextComponent: ReactDOMTextComponent | ||
189 | }); | ||
190 | } | ||
191 | |||
192 | if (process.env.NODE_ENV !== 'production') { | ||
193 | var ExecutionEnvironment = __webpack_require__(11); | ||
194 | if (ExecutionEnvironment.canUseDOM && window.top === window.self) { | ||
195 | |||
196 | // First check if devtools is not installed | ||
197 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { | ||
198 | // If we're in Chrome or Firefox, provide a download link if not installed. | ||
199 | if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { | ||
200 | console.debug('Download the React DevTools for a better development experience: ' + 'https://fb.me/react-devtools'); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | // If we're in IE8, check to see if we are in compatibility mode and provide | ||
205 | // information on preventing compatibility mode | ||
206 | var ieCompatibilityMode = document.documentMode && document.documentMode < 8; | ||
207 | |||
208 | process.env.NODE_ENV !== 'production' ? warning(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '<meta http-equiv="X-UA-Compatible" content="IE=edge" />') : undefined; | ||
209 | |||
210 | var expectedFeatures = [ | ||
211 | // shims | ||
212 | Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim, | ||
213 | |||
214 | // shams | ||
215 | Object.create, Object.freeze]; | ||
216 | |||
217 | for (var i = 0; i < expectedFeatures.length; i++) { | ||
218 | if (!expectedFeatures[i]) { | ||
219 | console.error('One or more ES5 shim/shams expected by React are not available: ' + 'https://fb.me/react-warning-polyfills'); | ||
220 | break; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | module.exports = React; | ||
227 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
228 | |||
229 | /***/ }, | ||
230 | /* 6 */ | ||
231 | /***/ function(module, exports) { | ||
232 | |||
233 | // shim for using process in browser | ||
234 | |||
235 | var process = module.exports = {}; | ||
236 | var queue = []; | ||
237 | var draining = false; | ||
238 | var currentQueue; | ||
239 | var queueIndex = -1; | ||
240 | |||
241 | function cleanUpNextTick() { | ||
242 | draining = false; | ||
243 | if (currentQueue.length) { | ||
244 | queue = currentQueue.concat(queue); | ||
245 | } else { | ||
246 | queueIndex = -1; | ||
247 | } | ||
248 | if (queue.length) { | ||
249 | drainQueue(); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | function drainQueue() { | ||
254 | if (draining) { | ||
255 | return; | ||
256 | } | ||
257 | var timeout = setTimeout(cleanUpNextTick); | ||
258 | draining = true; | ||
259 | |||
260 | var len = queue.length; | ||
261 | while(len) { | ||
262 | currentQueue = queue; | ||
263 | queue = []; | ||
264 | while (++queueIndex < len) { | ||
265 | if (currentQueue) { | ||
266 | currentQueue[queueIndex].run(); | ||
267 | } | ||
268 | } | ||
269 | queueIndex = -1; | ||
270 | len = queue.length; | ||
271 | } | ||
272 | currentQueue = null; | ||
273 | draining = false; | ||
274 | clearTimeout(timeout); | ||
275 | } | ||
276 | |||
277 | process.nextTick = function (fun) { | ||
278 | var args = new Array(arguments.length - 1); | ||
279 | if (arguments.length > 1) { | ||
280 | for (var i = 1; i < arguments.length; i++) { | ||
281 | args[i - 1] = arguments[i]; | ||
282 | } | ||
283 | } | ||
284 | queue.push(new Item(fun, args)); | ||
285 | if (queue.length === 1 && !draining) { | ||
286 | setTimeout(drainQueue, 0); | ||
287 | } | ||
288 | }; | ||
289 | |||
290 | // v8 likes predictible objects | ||
291 | function Item(fun, array) { | ||
292 | this.fun = fun; | ||
293 | this.array = array; | ||
294 | } | ||
295 | Item.prototype.run = function () { | ||
296 | this.fun.apply(null, this.array); | ||
297 | }; | ||
298 | process.title = 'browser'; | ||
299 | process.browser = true; | ||
300 | process.env = {}; | ||
301 | process.argv = []; | ||
302 | process.version = ''; // empty string to avoid regexp issues | ||
303 | process.versions = {}; | ||
304 | |||
305 | function noop() {} | ||
306 | |||
307 | process.on = noop; | ||
308 | process.addListener = noop; | ||
309 | process.once = noop; | ||
310 | process.off = noop; | ||
311 | process.removeListener = noop; | ||
312 | process.removeAllListeners = noop; | ||
313 | process.emit = noop; | ||
314 | |||
315 | process.binding = function (name) { | ||
316 | throw new Error('process.binding is not supported'); | ||
317 | }; | ||
318 | |||
319 | process.cwd = function () { return '/' }; | ||
320 | process.chdir = function (dir) { | ||
321 | throw new Error('process.chdir is not supported'); | ||
322 | }; | ||
323 | process.umask = function() { return 0; }; | ||
324 | |||
325 | |||
326 | /***/ }, | ||
327 | /* 7 */ | ||
328 | /***/ function(module, exports) { | ||
329 | |||
330 | /** | ||
331 | * Copyright 2013-2015, Facebook, Inc. | ||
332 | * All rights reserved. | ||
333 | * | ||
334 | * This source code is licensed under the BSD-style license found in the | ||
335 | * LICENSE file in the root directory of this source tree. An additional grant | ||
336 | * of patent rights can be found in the PATENTS file in the same directory. | ||
337 | * | ||
338 | * @providesModule ReactCurrentOwner | ||
339 | */ | ||
340 | |||
341 | 'use strict'; | ||
342 | |||
343 | /** | ||
344 | * Keeps track of the current owner. | ||
345 | * | ||
346 | * The current owner is the component who should own any components that are | ||
347 | * currently being constructed. | ||
348 | */ | ||
349 | var ReactCurrentOwner = { | ||
350 | |||
351 | /** | ||
352 | * @internal | ||
353 | * @type {ReactComponent} | ||
354 | */ | ||
355 | current: null | ||
356 | |||
357 | }; | ||
358 | |||
359 | module.exports = ReactCurrentOwner; | ||
360 | |||
361 | /***/ }, | ||
362 | /* 8 */ | ||
363 | /***/ function(module, exports, __webpack_require__) { | ||
364 | |||
365 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
366 | * Copyright 2013-2015, Facebook, Inc. | ||
367 | * All rights reserved. | ||
368 | * | ||
369 | * This source code is licensed under the BSD-style license found in the | ||
370 | * LICENSE file in the root directory of this source tree. An additional grant | ||
371 | * of patent rights can be found in the PATENTS file in the same directory. | ||
372 | * | ||
373 | * @providesModule ReactDOMTextComponent | ||
374 | * @typechecks static-only | ||
375 | */ | ||
376 | |||
377 | 'use strict'; | ||
378 | |||
379 | var DOMChildrenOperations = __webpack_require__(9); | ||
380 | var DOMPropertyOperations = __webpack_require__(24); | ||
381 | var ReactComponentBrowserEnvironment = __webpack_require__(28); | ||
382 | var ReactMount = __webpack_require__(30); | ||
383 | |||
384 | var assign = __webpack_require__(41); | ||
385 | var escapeTextContentForBrowser = __webpack_require__(23); | ||
386 | var setTextContent = __webpack_require__(22); | ||
387 | var validateDOMNesting = __webpack_require__(72); | ||
388 | |||
389 | /** | ||
390 | * Text nodes violate a couple assumptions that React makes about components: | ||
391 | * | ||
392 | * - When mounting text into the DOM, adjacent text nodes are merged. | ||
393 | * - Text nodes cannot be assigned a React root ID. | ||
394 | * | ||
395 | * This component is used to wrap strings in elements so that they can undergo | ||
396 | * the same reconciliation that is applied to elements. | ||
397 | * | ||
398 | * TODO: Investigate representing React components in the DOM with text nodes. | ||
399 | * | ||
400 | * @class ReactDOMTextComponent | ||
401 | * @extends ReactComponent | ||
402 | * @internal | ||
403 | */ | ||
404 | var ReactDOMTextComponent = function (props) { | ||
405 | // This constructor and its argument is currently used by mocks. | ||
406 | }; | ||
407 | |||
408 | assign(ReactDOMTextComponent.prototype, { | ||
409 | |||
410 | /** | ||
411 | * @param {ReactText} text | ||
412 | * @internal | ||
413 | */ | ||
414 | construct: function (text) { | ||
415 | // TODO: This is really a ReactText (ReactNode), not a ReactElement | ||
416 | this._currentElement = text; | ||
417 | this._stringText = '' + text; | ||
418 | |||
419 | // Properties | ||
420 | this._rootNodeID = null; | ||
421 | this._mountIndex = 0; | ||
422 | }, | ||
423 | |||
424 | /** | ||
425 | * Creates the markup for this text node. This node is not intended to have | ||
426 | * any features besides containing text content. | ||
427 | * | ||
428 | * @param {string} rootID DOM ID of the root node. | ||
429 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
430 | * @return {string} Markup for this text node. | ||
431 | * @internal | ||
432 | */ | ||
433 | mountComponent: function (rootID, transaction, context) { | ||
434 | if (process.env.NODE_ENV !== 'production') { | ||
435 | if (context[validateDOMNesting.ancestorInfoContextKey]) { | ||
436 | validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]); | ||
437 | } | ||
438 | } | ||
439 | |||
440 | this._rootNodeID = rootID; | ||
441 | if (transaction.useCreateElement) { | ||
442 | var ownerDocument = context[ReactMount.ownerDocumentContextKey]; | ||
443 | var el = ownerDocument.createElement('span'); | ||
444 | DOMPropertyOperations.setAttributeForID(el, rootID); | ||
445 | // Populate node cache | ||
446 | ReactMount.getID(el); | ||
447 | setTextContent(el, this._stringText); | ||
448 | return el; | ||
449 | } else { | ||
450 | var escapedText = escapeTextContentForBrowser(this._stringText); | ||
451 | |||
452 | if (transaction.renderToStaticMarkup) { | ||
453 | // Normally we'd wrap this in a `span` for the reasons stated above, but | ||
454 | // since this is a situation where React won't take over (static pages), | ||
455 | // we can simply return the text as it is. | ||
456 | return escapedText; | ||
457 | } | ||
458 | |||
459 | return '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' + escapedText + '</span>'; | ||
460 | } | ||
461 | }, | ||
462 | |||
463 | /** | ||
464 | * Updates this component by updating the text content. | ||
465 | * | ||
466 | * @param {ReactText} nextText The next text content | ||
467 | * @param {ReactReconcileTransaction} transaction | ||
468 | * @internal | ||
469 | */ | ||
470 | receiveComponent: function (nextText, transaction) { | ||
471 | if (nextText !== this._currentElement) { | ||
472 | this._currentElement = nextText; | ||
473 | var nextStringText = '' + nextText; | ||
474 | if (nextStringText !== this._stringText) { | ||
475 | // TODO: Save this as pending props and use performUpdateIfNecessary | ||
476 | // and/or updateComponent to do the actual update for consistency with | ||
477 | // other component types? | ||
478 | this._stringText = nextStringText; | ||
479 | var node = ReactMount.getNode(this._rootNodeID); | ||
480 | DOMChildrenOperations.updateTextContent(node, nextStringText); | ||
481 | } | ||
482 | } | ||
483 | }, | ||
484 | |||
485 | unmountComponent: function () { | ||
486 | ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID); | ||
487 | } | ||
488 | |||
489 | }); | ||
490 | |||
491 | module.exports = ReactDOMTextComponent; | ||
492 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
493 | |||
494 | /***/ }, | ||
495 | /* 9 */ | ||
496 | /***/ function(module, exports, __webpack_require__) { | ||
497 | |||
498 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
499 | * Copyright 2013-2015, Facebook, Inc. | ||
500 | * All rights reserved. | ||
501 | * | ||
502 | * This source code is licensed under the BSD-style license found in the | ||
503 | * LICENSE file in the root directory of this source tree. An additional grant | ||
504 | * of patent rights can be found in the PATENTS file in the same directory. | ||
505 | * | ||
506 | * @providesModule DOMChildrenOperations | ||
507 | * @typechecks static-only | ||
508 | */ | ||
509 | |||
510 | 'use strict'; | ||
511 | |||
512 | var Danger = __webpack_require__(10); | ||
513 | var ReactMultiChildUpdateTypes = __webpack_require__(18); | ||
514 | var ReactPerf = __webpack_require__(20); | ||
515 | |||
516 | var setInnerHTML = __webpack_require__(21); | ||
517 | var setTextContent = __webpack_require__(22); | ||
518 | var invariant = __webpack_require__(15); | ||
519 | |||
520 | /** | ||
521 | * Inserts `childNode` as a child of `parentNode` at the `index`. | ||
522 | * | ||
523 | * @param {DOMElement} parentNode Parent node in which to insert. | ||
524 | * @param {DOMElement} childNode Child node to insert. | ||
525 | * @param {number} index Index at which to insert the child. | ||
526 | * @internal | ||
527 | */ | ||
528 | function insertChildAt(parentNode, childNode, index) { | ||
529 | // By exploiting arrays returning `undefined` for an undefined index, we can | ||
530 | // rely exclusively on `insertBefore(node, null)` instead of also using | ||
531 | // `appendChild(node)`. However, using `undefined` is not allowed by all | ||
532 | // browsers so we must replace it with `null`. | ||
533 | |||
534 | // fix render order error in safari | ||
535 | // IE8 will throw error when index out of list size. | ||
536 | var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index); | ||
537 | |||
538 | parentNode.insertBefore(childNode, beforeChild); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Operations for updating with DOM children. | ||
543 | */ | ||
544 | var DOMChildrenOperations = { | ||
545 | |||
546 | dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup, | ||
547 | |||
548 | updateTextContent: setTextContent, | ||
549 | |||
550 | /** | ||
551 | * Updates a component's children by processing a series of updates. The | ||
552 | * update configurations are each expected to have a `parentNode` property. | ||
553 | * | ||
554 | * @param {array<object>} updates List of update configurations. | ||
555 | * @param {array<string>} markupList List of markup strings. | ||
556 | * @internal | ||
557 | */ | ||
558 | processUpdates: function (updates, markupList) { | ||
559 | var update; | ||
560 | // Mapping from parent IDs to initial child orderings. | ||
561 | var initialChildren = null; | ||
562 | // List of children that will be moved or removed. | ||
563 | var updatedChildren = null; | ||
564 | |||
565 | for (var i = 0; i < updates.length; i++) { | ||
566 | update = updates[i]; | ||
567 | if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) { | ||
568 | var updatedIndex = update.fromIndex; | ||
569 | var updatedChild = update.parentNode.childNodes[updatedIndex]; | ||
570 | var parentID = update.parentID; | ||
571 | |||
572 | !updatedChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processUpdates(): Unable to find child %s of element. This ' + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + 'browser), usually due to forgetting a <tbody> when using tables, ' + 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' + 'in an <svg> parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(false) : undefined; | ||
573 | |||
574 | initialChildren = initialChildren || {}; | ||
575 | initialChildren[parentID] = initialChildren[parentID] || []; | ||
576 | initialChildren[parentID][updatedIndex] = updatedChild; | ||
577 | |||
578 | updatedChildren = updatedChildren || []; | ||
579 | updatedChildren.push(updatedChild); | ||
580 | } | ||
581 | } | ||
582 | |||
583 | var renderedMarkup; | ||
584 | // markupList is either a list of markup or just a list of elements | ||
585 | if (markupList.length && typeof markupList[0] === 'string') { | ||
586 | renderedMarkup = Danger.dangerouslyRenderMarkup(markupList); | ||
587 | } else { | ||
588 | renderedMarkup = markupList; | ||
589 | } | ||
590 | |||
591 | // Remove updated children first so that `toIndex` is consistent. | ||
592 | if (updatedChildren) { | ||
593 | for (var j = 0; j < updatedChildren.length; j++) { | ||
594 | updatedChildren[j].parentNode.removeChild(updatedChildren[j]); | ||
595 | } | ||
596 | } | ||
597 | |||
598 | for (var k = 0; k < updates.length; k++) { | ||
599 | update = updates[k]; | ||
600 | switch (update.type) { | ||
601 | case ReactMultiChildUpdateTypes.INSERT_MARKUP: | ||
602 | insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex); | ||
603 | break; | ||
604 | case ReactMultiChildUpdateTypes.MOVE_EXISTING: | ||
605 | insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex); | ||
606 | break; | ||
607 | case ReactMultiChildUpdateTypes.SET_MARKUP: | ||
608 | setInnerHTML(update.parentNode, update.content); | ||
609 | break; | ||
610 | case ReactMultiChildUpdateTypes.TEXT_CONTENT: | ||
611 | setTextContent(update.parentNode, update.content); | ||
612 | break; | ||
613 | case ReactMultiChildUpdateTypes.REMOVE_NODE: | ||
614 | // Already removed by the for-loop above. | ||
615 | break; | ||
616 | } | ||
617 | } | ||
618 | } | ||
619 | |||
620 | }; | ||
621 | |||
622 | ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', { | ||
623 | updateTextContent: 'updateTextContent' | ||
624 | }); | ||
625 | |||
626 | module.exports = DOMChildrenOperations; | ||
627 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
628 | |||
629 | /***/ }, | ||
630 | /* 10 */ | ||
631 | /***/ function(module, exports, __webpack_require__) { | ||
632 | |||
633 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
634 | * Copyright 2013-2015, Facebook, Inc. | ||
635 | * All rights reserved. | ||
636 | * | ||
637 | * This source code is licensed under the BSD-style license found in the | ||
638 | * LICENSE file in the root directory of this source tree. An additional grant | ||
639 | * of patent rights can be found in the PATENTS file in the same directory. | ||
640 | * | ||
641 | * @providesModule Danger | ||
642 | * @typechecks static-only | ||
643 | */ | ||
644 | |||
645 | 'use strict'; | ||
646 | |||
647 | var ExecutionEnvironment = __webpack_require__(11); | ||
648 | |||
649 | var createNodesFromMarkup = __webpack_require__(12); | ||
650 | var emptyFunction = __webpack_require__(17); | ||
651 | var getMarkupWrap = __webpack_require__(16); | ||
652 | var invariant = __webpack_require__(15); | ||
653 | |||
654 | var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/; | ||
655 | var RESULT_INDEX_ATTR = 'data-danger-index'; | ||
656 | |||
657 | /** | ||
658 | * Extracts the `nodeName` from a string of markup. | ||
659 | * | ||
660 | * NOTE: Extracting the `nodeName` does not require a regular expression match | ||
661 | * because we make assumptions about React-generated markup (i.e. there are no | ||
662 | * spaces surrounding the opening tag and there is at least one attribute). | ||
663 | * | ||
664 | * @param {string} markup String of markup. | ||
665 | * @return {string} Node name of the supplied markup. | ||
666 | * @see http://jsperf.com/extract-nodename | ||
667 | */ | ||
668 | function getNodeName(markup) { | ||
669 | return markup.substring(1, markup.indexOf(' ')); | ||
670 | } | ||
671 | |||
672 | var Danger = { | ||
673 | |||
674 | /** | ||
675 | * Renders markup into an array of nodes. The markup is expected to render | ||
676 | * into a list of root nodes. Also, the length of `resultList` and | ||
677 | * `markupList` should be the same. | ||
678 | * | ||
679 | * @param {array<string>} markupList List of markup strings to render. | ||
680 | * @return {array<DOMElement>} List of rendered nodes. | ||
681 | * @internal | ||
682 | */ | ||
683 | dangerouslyRenderMarkup: function (markupList) { | ||
684 | !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : undefined; | ||
685 | var nodeName; | ||
686 | var markupByNodeName = {}; | ||
687 | // Group markup by `nodeName` if a wrap is necessary, else by '*'. | ||
688 | for (var i = 0; i < markupList.length; i++) { | ||
689 | !markupList[i] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined; | ||
690 | nodeName = getNodeName(markupList[i]); | ||
691 | nodeName = getMarkupWrap(nodeName) ? nodeName : '*'; | ||
692 | markupByNodeName[nodeName] = markupByNodeName[nodeName] || []; | ||
693 | markupByNodeName[nodeName][i] = markupList[i]; | ||
694 | } | ||
695 | var resultList = []; | ||
696 | var resultListAssignmentCount = 0; | ||
697 | for (nodeName in markupByNodeName) { | ||
698 | if (!markupByNodeName.hasOwnProperty(nodeName)) { | ||
699 | continue; | ||
700 | } | ||
701 | var markupListByNodeName = markupByNodeName[nodeName]; | ||
702 | |||
703 | // This for-in loop skips the holes of the sparse array. The order of | ||
704 | // iteration should follow the order of assignment, which happens to match | ||
705 | // numerical index order, but we don't rely on that. | ||
706 | var resultIndex; | ||
707 | for (resultIndex in markupListByNodeName) { | ||
708 | if (markupListByNodeName.hasOwnProperty(resultIndex)) { | ||
709 | var markup = markupListByNodeName[resultIndex]; | ||
710 | |||
711 | // Push the requested markup with an additional RESULT_INDEX_ATTR | ||
712 | // attribute. If the markup does not start with a < character, it | ||
713 | // will be discarded below (with an appropriate console.error). | ||
714 | markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP, | ||
715 | // This index will be parsed back out below. | ||
716 | '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '); | ||
717 | } | ||
718 | } | ||
719 | |||
720 | // Render each group of markup with similar wrapping `nodeName`. | ||
721 | var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with <script> tags. | ||
722 | ); | ||
723 | |||
724 | for (var j = 0; j < renderNodes.length; ++j) { | ||
725 | var renderNode = renderNodes[j]; | ||
726 | if (renderNode.hasAttribute && renderNode.hasAttribute(RESULT_INDEX_ATTR)) { | ||
727 | |||
728 | resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR); | ||
729 | renderNode.removeAttribute(RESULT_INDEX_ATTR); | ||
730 | |||
731 | !!resultList.hasOwnProperty(resultIndex) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Assigning to an already-occupied result index.') : invariant(false) : undefined; | ||
732 | |||
733 | resultList[resultIndex] = renderNode; | ||
734 | |||
735 | // This should match resultList.length and markupList.length when | ||
736 | // we're done. | ||
737 | resultListAssignmentCount += 1; | ||
738 | } else if (process.env.NODE_ENV !== 'production') { | ||
739 | console.error('Danger: Discarding unexpected node:', renderNode); | ||
740 | } | ||
741 | } | ||
742 | } | ||
743 | |||
744 | // Although resultList was populated out of order, it should now be a dense | ||
745 | // array. | ||
746 | !(resultListAssignmentCount === resultList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Did not assign to every index of resultList.') : invariant(false) : undefined; | ||
747 | |||
748 | !(resultList.length === markupList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Expected markup to render %s nodes, but rendered %s.', markupList.length, resultList.length) : invariant(false) : undefined; | ||
749 | |||
750 | return resultList; | ||
751 | }, | ||
752 | |||
753 | /** | ||
754 | * Replaces a node with a string of markup at its current position within its | ||
755 | * parent. The markup must render into a single root node. | ||
756 | * | ||
757 | * @param {DOMElement} oldChild Child node to replace. | ||
758 | * @param {string} markup Markup to render in place of the child node. | ||
759 | * @internal | ||
760 | */ | ||
761 | dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) { | ||
762 | !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' + 'worker thread. Make sure `window` and `document` are available ' + 'globally before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined; | ||
763 | !markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined; | ||
764 | !(oldChild.tagName.toLowerCase() !== 'html') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' + '<html> node. This is because browser quirks make this unreliable ' + 'and/or slow. If you want to render to the root you must use ' + 'server rendering. See ReactDOMServer.renderToString().') : invariant(false) : undefined; | ||
765 | |||
766 | var newChild; | ||
767 | if (typeof markup === 'string') { | ||
768 | newChild = createNodesFromMarkup(markup, emptyFunction)[0]; | ||
769 | } else { | ||
770 | newChild = markup; | ||
771 | } | ||
772 | oldChild.parentNode.replaceChild(newChild, oldChild); | ||
773 | } | ||
774 | |||
775 | }; | ||
776 | |||
777 | module.exports = Danger; | ||
778 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
779 | |||
780 | /***/ }, | ||
781 | /* 11 */ | ||
782 | /***/ function(module, exports) { | ||
783 | |||
784 | /** | ||
785 | * Copyright 2013-2015, Facebook, Inc. | ||
786 | * All rights reserved. | ||
787 | * | ||
788 | * This source code is licensed under the BSD-style license found in the | ||
789 | * LICENSE file in the root directory of this source tree. An additional grant | ||
790 | * of patent rights can be found in the PATENTS file in the same directory. | ||
791 | * | ||
792 | * @providesModule ExecutionEnvironment | ||
793 | */ | ||
794 | |||
795 | 'use strict'; | ||
796 | |||
797 | var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); | ||
798 | |||
799 | /** | ||
800 | * Simple, lightweight module assisting with the detection and context of | ||
801 | * Worker. Helps avoid circular dependencies and allows code to reason about | ||
802 | * whether or not they are in a Worker, even if they never include the main | ||
803 | * `ReactWorker` dependency. | ||
804 | */ | ||
805 | var ExecutionEnvironment = { | ||
806 | |||
807 | canUseDOM: canUseDOM, | ||
808 | |||
809 | canUseWorkers: typeof Worker !== 'undefined', | ||
810 | |||
811 | canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), | ||
812 | |||
813 | canUseViewport: canUseDOM && !!window.screen, | ||
814 | |||
815 | isInWorker: !canUseDOM // For now, this is true - might change in the future. | ||
816 | |||
817 | }; | ||
818 | |||
819 | module.exports = ExecutionEnvironment; | ||
820 | |||
821 | /***/ }, | ||
822 | /* 12 */ | ||
823 | /***/ function(module, exports, __webpack_require__) { | ||
824 | |||
825 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
826 | * Copyright 2013-2015, Facebook, Inc. | ||
827 | * All rights reserved. | ||
828 | * | ||
829 | * This source code is licensed under the BSD-style license found in the | ||
830 | * LICENSE file in the root directory of this source tree. An additional grant | ||
831 | * of patent rights can be found in the PATENTS file in the same directory. | ||
832 | * | ||
833 | * @providesModule createNodesFromMarkup | ||
834 | * @typechecks | ||
835 | */ | ||
836 | |||
837 | /*eslint-disable fb-www/unsafe-html*/ | ||
838 | |||
839 | 'use strict'; | ||
840 | |||
841 | var ExecutionEnvironment = __webpack_require__(11); | ||
842 | |||
843 | var createArrayFromMixed = __webpack_require__(13); | ||
844 | var getMarkupWrap = __webpack_require__(16); | ||
845 | var invariant = __webpack_require__(15); | ||
846 | |||
847 | /** | ||
848 | * Dummy container used to render all markup. | ||
849 | */ | ||
850 | var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; | ||
851 | |||
852 | /** | ||
853 | * Pattern used by `getNodeName`. | ||
854 | */ | ||
855 | var nodeNamePattern = /^\s*<(\w+)/; | ||
856 | |||
857 | /** | ||
858 | * Extracts the `nodeName` of the first element in a string of markup. | ||
859 | * | ||
860 | * @param {string} markup String of markup. | ||
861 | * @return {?string} Node name of the supplied markup. | ||
862 | */ | ||
863 | function getNodeName(markup) { | ||
864 | var nodeNameMatch = markup.match(nodeNamePattern); | ||
865 | return nodeNameMatch && nodeNameMatch[1].toLowerCase(); | ||
866 | } | ||
867 | |||
868 | /** | ||
869 | * Creates an array containing the nodes rendered from the supplied markup. The | ||
870 | * optionally supplied `handleScript` function will be invoked once for each | ||
871 | * <script> element that is rendered. If no `handleScript` function is supplied, | ||
872 | * an exception is thrown if any <script> elements are rendered. | ||
873 | * | ||
874 | * @param {string} markup A string of valid HTML markup. | ||
875 | * @param {?function} handleScript Invoked once for each rendered <script>. | ||
876 | * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes. | ||
877 | */ | ||
878 | function createNodesFromMarkup(markup, handleScript) { | ||
879 | var node = dummyNode; | ||
880 | !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : undefined; | ||
881 | var nodeName = getNodeName(markup); | ||
882 | |||
883 | var wrap = nodeName && getMarkupWrap(nodeName); | ||
884 | if (wrap) { | ||
885 | node.innerHTML = wrap[1] + markup + wrap[2]; | ||
886 | |||
887 | var wrapDepth = wrap[0]; | ||
888 | while (wrapDepth--) { | ||
889 | node = node.lastChild; | ||
890 | } | ||
891 | } else { | ||
892 | node.innerHTML = markup; | ||
893 | } | ||
894 | |||
895 | var scripts = node.getElementsByTagName('script'); | ||
896 | if (scripts.length) { | ||
897 | !handleScript ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : undefined; | ||
898 | createArrayFromMixed(scripts).forEach(handleScript); | ||
899 | } | ||
900 | |||
901 | var nodes = createArrayFromMixed(node.childNodes); | ||
902 | while (node.lastChild) { | ||
903 | node.removeChild(node.lastChild); | ||
904 | } | ||
905 | return nodes; | ||
906 | } | ||
907 | |||
908 | module.exports = createNodesFromMarkup; | ||
909 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
910 | |||
911 | /***/ }, | ||
912 | /* 13 */ | ||
913 | /***/ function(module, exports, __webpack_require__) { | ||
914 | |||
915 | /** | ||
916 | * Copyright 2013-2015, Facebook, Inc. | ||
917 | * All rights reserved. | ||
918 | * | ||
919 | * This source code is licensed under the BSD-style license found in the | ||
920 | * LICENSE file in the root directory of this source tree. An additional grant | ||
921 | * of patent rights can be found in the PATENTS file in the same directory. | ||
922 | * | ||
923 | * @providesModule createArrayFromMixed | ||
924 | * @typechecks | ||
925 | */ | ||
926 | |||
927 | 'use strict'; | ||
928 | |||
929 | var toArray = __webpack_require__(14); | ||
930 | |||
931 | /** | ||
932 | * Perform a heuristic test to determine if an object is "array-like". | ||
933 | * | ||
934 | * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" | ||
935 | * Joshu replied: "Mu." | ||
936 | * | ||
937 | * This function determines if its argument has "array nature": it returns | ||
938 | * true if the argument is an actual array, an `arguments' object, or an | ||
939 | * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). | ||
940 | * | ||
941 | * It will return false for other array-like objects like Filelist. | ||
942 | * | ||
943 | * @param {*} obj | ||
944 | * @return {boolean} | ||
945 | */ | ||
946 | function hasArrayNature(obj) { | ||
947 | return( | ||
948 | // not null/false | ||
949 | !!obj && ( | ||
950 | // arrays are objects, NodeLists are functions in Safari | ||
951 | typeof obj == 'object' || typeof obj == 'function') && | ||
952 | // quacks like an array | ||
953 | 'length' in obj && | ||
954 | // not window | ||
955 | !('setInterval' in obj) && | ||
956 | // no DOM node should be considered an array-like | ||
957 | // a 'select' element has 'length' and 'item' properties on IE8 | ||
958 | typeof obj.nodeType != 'number' && ( | ||
959 | // a real array | ||
960 | Array.isArray(obj) || | ||
961 | // arguments | ||
962 | 'callee' in obj || | ||
963 | // HTMLCollection/NodeList | ||
964 | 'item' in obj) | ||
965 | ); | ||
966 | } | ||
967 | |||
968 | /** | ||
969 | * Ensure that the argument is an array by wrapping it in an array if it is not. | ||
970 | * Creates a copy of the argument if it is already an array. | ||
971 | * | ||
972 | * This is mostly useful idiomatically: | ||
973 | * | ||
974 | * var createArrayFromMixed = require('createArrayFromMixed'); | ||
975 | * | ||
976 | * function takesOneOrMoreThings(things) { | ||
977 | * things = createArrayFromMixed(things); | ||
978 | * ... | ||
979 | * } | ||
980 | * | ||
981 | * This allows you to treat `things' as an array, but accept scalars in the API. | ||
982 | * | ||
983 | * If you need to convert an array-like object, like `arguments`, into an array | ||
984 | * use toArray instead. | ||
985 | * | ||
986 | * @param {*} obj | ||
987 | * @return {array} | ||
988 | */ | ||
989 | function createArrayFromMixed(obj) { | ||
990 | if (!hasArrayNature(obj)) { | ||
991 | return [obj]; | ||
992 | } else if (Array.isArray(obj)) { | ||
993 | return obj.slice(); | ||
994 | } else { | ||
995 | return toArray(obj); | ||
996 | } | ||
997 | } | ||
998 | |||
999 | module.exports = createArrayFromMixed; | ||
1000 | |||
1001 | /***/ }, | ||
1002 | /* 14 */ | ||
1003 | /***/ function(module, exports, __webpack_require__) { | ||
1004 | |||
1005 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
1006 | * Copyright 2013-2015, Facebook, Inc. | ||
1007 | * All rights reserved. | ||
1008 | * | ||
1009 | * This source code is licensed under the BSD-style license found in the | ||
1010 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1011 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1012 | * | ||
1013 | * @providesModule toArray | ||
1014 | * @typechecks | ||
1015 | */ | ||
1016 | |||
1017 | 'use strict'; | ||
1018 | |||
1019 | var invariant = __webpack_require__(15); | ||
1020 | |||
1021 | /** | ||
1022 | * Convert array-like objects to arrays. | ||
1023 | * | ||
1024 | * This API assumes the caller knows the contents of the data type. For less | ||
1025 | * well defined inputs use createArrayFromMixed. | ||
1026 | * | ||
1027 | * @param {object|function|filelist} obj | ||
1028 | * @return {array} | ||
1029 | */ | ||
1030 | function toArray(obj) { | ||
1031 | var length = obj.length; | ||
1032 | |||
1033 | // Some browse builtin objects can report typeof 'function' (e.g. NodeList in | ||
1034 | // old versions of Safari). | ||
1035 | !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : undefined; | ||
1036 | |||
1037 | !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : undefined; | ||
1038 | |||
1039 | !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : undefined; | ||
1040 | |||
1041 | // Old IE doesn't give collections access to hasOwnProperty. Assume inputs | ||
1042 | // without method will throw during the slice call and skip straight to the | ||
1043 | // fallback. | ||
1044 | if (obj.hasOwnProperty) { | ||
1045 | try { | ||
1046 | return Array.prototype.slice.call(obj); | ||
1047 | } catch (e) { | ||
1048 | // IE < 9 does not support Array#slice on collections objects | ||
1049 | } | ||
1050 | } | ||
1051 | |||
1052 | // Fall back to copying key by key. This assumes all keys have a value, | ||
1053 | // so will not preserve sparsely populated inputs. | ||
1054 | var ret = Array(length); | ||
1055 | for (var ii = 0; ii < length; ii++) { | ||
1056 | ret[ii] = obj[ii]; | ||
1057 | } | ||
1058 | return ret; | ||
1059 | } | ||
1060 | |||
1061 | module.exports = toArray; | ||
1062 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
1063 | |||
1064 | /***/ }, | ||
1065 | /* 15 */ | ||
1066 | /***/ function(module, exports, __webpack_require__) { | ||
1067 | |||
1068 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
1069 | * Copyright 2013-2015, Facebook, Inc. | ||
1070 | * All rights reserved. | ||
1071 | * | ||
1072 | * This source code is licensed under the BSD-style license found in the | ||
1073 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1074 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1075 | * | ||
1076 | * @providesModule invariant | ||
1077 | */ | ||
1078 | |||
1079 | 'use strict'; | ||
1080 | |||
1081 | /** | ||
1082 | * Use invariant() to assert state which your program assumes to be true. | ||
1083 | * | ||
1084 | * Provide sprintf-style format (only %s is supported) and arguments | ||
1085 | * to provide information about what broke and what you were | ||
1086 | * expecting. | ||
1087 | * | ||
1088 | * The invariant message will be stripped in production, but the invariant | ||
1089 | * will remain to ensure logic does not differ in production. | ||
1090 | */ | ||
1091 | |||
1092 | var invariant = function (condition, format, a, b, c, d, e, f) { | ||
1093 | if (process.env.NODE_ENV !== 'production') { | ||
1094 | if (format === undefined) { | ||
1095 | throw new Error('invariant requires an error message argument'); | ||
1096 | } | ||
1097 | } | ||
1098 | |||
1099 | if (!condition) { | ||
1100 | var error; | ||
1101 | if (format === undefined) { | ||
1102 | error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); | ||
1103 | } else { | ||
1104 | var args = [a, b, c, d, e, f]; | ||
1105 | var argIndex = 0; | ||
1106 | error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () { | ||
1107 | return args[argIndex++]; | ||
1108 | })); | ||
1109 | } | ||
1110 | |||
1111 | error.framesToPop = 1; // we don't care about invariant's own frame | ||
1112 | throw error; | ||
1113 | } | ||
1114 | }; | ||
1115 | |||
1116 | module.exports = invariant; | ||
1117 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
1118 | |||
1119 | /***/ }, | ||
1120 | /* 16 */ | ||
1121 | /***/ function(module, exports, __webpack_require__) { | ||
1122 | |||
1123 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
1124 | * Copyright 2013-2015, Facebook, Inc. | ||
1125 | * All rights reserved. | ||
1126 | * | ||
1127 | * This source code is licensed under the BSD-style license found in the | ||
1128 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1129 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1130 | * | ||
1131 | * @providesModule getMarkupWrap | ||
1132 | */ | ||
1133 | |||
1134 | /*eslint-disable fb-www/unsafe-html */ | ||
1135 | |||
1136 | 'use strict'; | ||
1137 | |||
1138 | var ExecutionEnvironment = __webpack_require__(11); | ||
1139 | |||
1140 | var invariant = __webpack_require__(15); | ||
1141 | |||
1142 | /** | ||
1143 | * Dummy container used to detect which wraps are necessary. | ||
1144 | */ | ||
1145 | var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; | ||
1146 | |||
1147 | /** | ||
1148 | * Some browsers cannot use `innerHTML` to render certain elements standalone, | ||
1149 | * so we wrap them, render the wrapped nodes, then extract the desired node. | ||
1150 | * | ||
1151 | * In IE8, certain elements cannot render alone, so wrap all elements ('*'). | ||
1152 | */ | ||
1153 | |||
1154 | var shouldWrap = {}; | ||
1155 | |||
1156 | var selectWrap = [1, '<select multiple="true">', '</select>']; | ||
1157 | var tableWrap = [1, '<table>', '</table>']; | ||
1158 | var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
1159 | |||
1160 | var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>']; | ||
1161 | |||
1162 | var markupWrap = { | ||
1163 | '*': [1, '?<div>', '</div>'], | ||
1164 | |||
1165 | 'area': [1, '<map>', '</map>'], | ||
1166 | 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'], | ||
1167 | 'legend': [1, '<fieldset>', '</fieldset>'], | ||
1168 | 'param': [1, '<object>', '</object>'], | ||
1169 | 'tr': [2, '<table><tbody>', '</tbody></table>'], | ||
1170 | |||
1171 | 'optgroup': selectWrap, | ||
1172 | 'option': selectWrap, | ||
1173 | |||
1174 | 'caption': tableWrap, | ||
1175 | 'colgroup': tableWrap, | ||
1176 | 'tbody': tableWrap, | ||
1177 | 'tfoot': tableWrap, | ||
1178 | 'thead': tableWrap, | ||
1179 | |||
1180 | 'td': trWrap, | ||
1181 | 'th': trWrap | ||
1182 | }; | ||
1183 | |||
1184 | // Initialize the SVG elements since we know they'll always need to be wrapped | ||
1185 | // consistently. If they are created inside a <div> they will be initialized in | ||
1186 | // the wrong namespace (and will not display). | ||
1187 | var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan']; | ||
1188 | svgElements.forEach(function (nodeName) { | ||
1189 | markupWrap[nodeName] = svgWrap; | ||
1190 | shouldWrap[nodeName] = true; | ||
1191 | }); | ||
1192 | |||
1193 | /** | ||
1194 | * Gets the markup wrap configuration for the supplied `nodeName`. | ||
1195 | * | ||
1196 | * NOTE: This lazily detects which wraps are necessary for the current browser. | ||
1197 | * | ||
1198 | * @param {string} nodeName Lowercase `nodeName`. | ||
1199 | * @return {?array} Markup wrap configuration, if applicable. | ||
1200 | */ | ||
1201 | function getMarkupWrap(nodeName) { | ||
1202 | !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : undefined; | ||
1203 | if (!markupWrap.hasOwnProperty(nodeName)) { | ||
1204 | nodeName = '*'; | ||
1205 | } | ||
1206 | if (!shouldWrap.hasOwnProperty(nodeName)) { | ||
1207 | if (nodeName === '*') { | ||
1208 | dummyNode.innerHTML = '<link />'; | ||
1209 | } else { | ||
1210 | dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>'; | ||
1211 | } | ||
1212 | shouldWrap[nodeName] = !dummyNode.firstChild; | ||
1213 | } | ||
1214 | return shouldWrap[nodeName] ? markupWrap[nodeName] : null; | ||
1215 | } | ||
1216 | |||
1217 | module.exports = getMarkupWrap; | ||
1218 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
1219 | |||
1220 | /***/ }, | ||
1221 | /* 17 */ | ||
1222 | /***/ function(module, exports) { | ||
1223 | |||
1224 | /** | ||
1225 | * Copyright 2013-2015, Facebook, Inc. | ||
1226 | * All rights reserved. | ||
1227 | * | ||
1228 | * This source code is licensed under the BSD-style license found in the | ||
1229 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1230 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1231 | * | ||
1232 | * @providesModule emptyFunction | ||
1233 | */ | ||
1234 | |||
1235 | "use strict"; | ||
1236 | |||
1237 | function makeEmptyFunction(arg) { | ||
1238 | return function () { | ||
1239 | return arg; | ||
1240 | }; | ||
1241 | } | ||
1242 | |||
1243 | /** | ||
1244 | * This function accepts and discards inputs; it has no side effects. This is | ||
1245 | * primarily useful idiomatically for overridable function endpoints which | ||
1246 | * always need to be callable, since JS lacks a null-call idiom ala Cocoa. | ||
1247 | */ | ||
1248 | function emptyFunction() {} | ||
1249 | |||
1250 | emptyFunction.thatReturns = makeEmptyFunction; | ||
1251 | emptyFunction.thatReturnsFalse = makeEmptyFunction(false); | ||
1252 | emptyFunction.thatReturnsTrue = makeEmptyFunction(true); | ||
1253 | emptyFunction.thatReturnsNull = makeEmptyFunction(null); | ||
1254 | emptyFunction.thatReturnsThis = function () { | ||
1255 | return this; | ||
1256 | }; | ||
1257 | emptyFunction.thatReturnsArgument = function (arg) { | ||
1258 | return arg; | ||
1259 | }; | ||
1260 | |||
1261 | module.exports = emptyFunction; | ||
1262 | |||
1263 | /***/ }, | ||
1264 | /* 18 */ | ||
1265 | /***/ function(module, exports, __webpack_require__) { | ||
1266 | |||
1267 | /** | ||
1268 | * Copyright 2013-2015, Facebook, Inc. | ||
1269 | * All rights reserved. | ||
1270 | * | ||
1271 | * This source code is licensed under the BSD-style license found in the | ||
1272 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1273 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1274 | * | ||
1275 | * @providesModule ReactMultiChildUpdateTypes | ||
1276 | */ | ||
1277 | |||
1278 | 'use strict'; | ||
1279 | |||
1280 | var keyMirror = __webpack_require__(19); | ||
1281 | |||
1282 | /** | ||
1283 | * When a component's children are updated, a series of update configuration | ||
1284 | * objects are created in order to batch and serialize the required changes. | ||
1285 | * | ||
1286 | * Enumerates all the possible types of update configurations. | ||
1287 | * | ||
1288 | * @internal | ||
1289 | */ | ||
1290 | var ReactMultiChildUpdateTypes = keyMirror({ | ||
1291 | INSERT_MARKUP: null, | ||
1292 | MOVE_EXISTING: null, | ||
1293 | REMOVE_NODE: null, | ||
1294 | SET_MARKUP: null, | ||
1295 | TEXT_CONTENT: null | ||
1296 | }); | ||
1297 | |||
1298 | module.exports = ReactMultiChildUpdateTypes; | ||
1299 | |||
1300 | /***/ }, | ||
1301 | /* 19 */ | ||
1302 | /***/ function(module, exports, __webpack_require__) { | ||
1303 | |||
1304 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
1305 | * Copyright 2013-2015, Facebook, Inc. | ||
1306 | * All rights reserved. | ||
1307 | * | ||
1308 | * This source code is licensed under the BSD-style license found in the | ||
1309 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1310 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1311 | * | ||
1312 | * @providesModule keyMirror | ||
1313 | * @typechecks static-only | ||
1314 | */ | ||
1315 | |||
1316 | 'use strict'; | ||
1317 | |||
1318 | var invariant = __webpack_require__(15); | ||
1319 | |||
1320 | /** | ||
1321 | * Constructs an enumeration with keys equal to their value. | ||
1322 | * | ||
1323 | * For example: | ||
1324 | * | ||
1325 | * var COLORS = keyMirror({blue: null, red: null}); | ||
1326 | * var myColor = COLORS.blue; | ||
1327 | * var isColorValid = !!COLORS[myColor]; | ||
1328 | * | ||
1329 | * The last line could not be performed if the values of the generated enum were | ||
1330 | * not equal to their keys. | ||
1331 | * | ||
1332 | * Input: {key1: val1, key2: val2} | ||
1333 | * Output: {key1: key1, key2: key2} | ||
1334 | * | ||
1335 | * @param {object} obj | ||
1336 | * @return {object} | ||
1337 | */ | ||
1338 | var keyMirror = function (obj) { | ||
1339 | var ret = {}; | ||
1340 | var key; | ||
1341 | !(obj instanceof Object && !Array.isArray(obj)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'keyMirror(...): Argument must be an object.') : invariant(false) : undefined; | ||
1342 | for (key in obj) { | ||
1343 | if (!obj.hasOwnProperty(key)) { | ||
1344 | continue; | ||
1345 | } | ||
1346 | ret[key] = key; | ||
1347 | } | ||
1348 | return ret; | ||
1349 | }; | ||
1350 | |||
1351 | module.exports = keyMirror; | ||
1352 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
1353 | |||
1354 | /***/ }, | ||
1355 | /* 20 */ | ||
1356 | /***/ function(module, exports, __webpack_require__) { | ||
1357 | |||
1358 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
1359 | * Copyright 2013-2015, Facebook, Inc. | ||
1360 | * All rights reserved. | ||
1361 | * | ||
1362 | * This source code is licensed under the BSD-style license found in the | ||
1363 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1364 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1365 | * | ||
1366 | * @providesModule ReactPerf | ||
1367 | * @typechecks static-only | ||
1368 | */ | ||
1369 | |||
1370 | 'use strict'; | ||
1371 | |||
1372 | /** | ||
1373 | * ReactPerf is a general AOP system designed to measure performance. This | ||
1374 | * module only has the hooks: see ReactDefaultPerf for the analysis tool. | ||
1375 | */ | ||
1376 | var ReactPerf = { | ||
1377 | /** | ||
1378 | * Boolean to enable/disable measurement. Set to false by default to prevent | ||
1379 | * accidental logging and perf loss. | ||
1380 | */ | ||
1381 | enableMeasure: false, | ||
1382 | |||
1383 | /** | ||
1384 | * Holds onto the measure function in use. By default, don't measure | ||
1385 | * anything, but we'll override this if we inject a measure function. | ||
1386 | */ | ||
1387 | storedMeasure: _noMeasure, | ||
1388 | |||
1389 | /** | ||
1390 | * @param {object} object | ||
1391 | * @param {string} objectName | ||
1392 | * @param {object<string>} methodNames | ||
1393 | */ | ||
1394 | measureMethods: function (object, objectName, methodNames) { | ||
1395 | if (process.env.NODE_ENV !== 'production') { | ||
1396 | for (var key in methodNames) { | ||
1397 | if (!methodNames.hasOwnProperty(key)) { | ||
1398 | continue; | ||
1399 | } | ||
1400 | object[key] = ReactPerf.measure(objectName, methodNames[key], object[key]); | ||
1401 | } | ||
1402 | } | ||
1403 | }, | ||
1404 | |||
1405 | /** | ||
1406 | * Use this to wrap methods you want to measure. Zero overhead in production. | ||
1407 | * | ||
1408 | * @param {string} objName | ||
1409 | * @param {string} fnName | ||
1410 | * @param {function} func | ||
1411 | * @return {function} | ||
1412 | */ | ||
1413 | measure: function (objName, fnName, func) { | ||
1414 | if (process.env.NODE_ENV !== 'production') { | ||
1415 | var measuredFunc = null; | ||
1416 | var wrapper = function () { | ||
1417 | if (ReactPerf.enableMeasure) { | ||
1418 | if (!measuredFunc) { | ||
1419 | measuredFunc = ReactPerf.storedMeasure(objName, fnName, func); | ||
1420 | } | ||
1421 | return measuredFunc.apply(this, arguments); | ||
1422 | } | ||
1423 | return func.apply(this, arguments); | ||
1424 | }; | ||
1425 | wrapper.displayName = objName + '_' + fnName; | ||
1426 | return wrapper; | ||
1427 | } | ||
1428 | return func; | ||
1429 | }, | ||
1430 | |||
1431 | injection: { | ||
1432 | /** | ||
1433 | * @param {function} measure | ||
1434 | */ | ||
1435 | injectMeasure: function (measure) { | ||
1436 | ReactPerf.storedMeasure = measure; | ||
1437 | } | ||
1438 | } | ||
1439 | }; | ||
1440 | |||
1441 | /** | ||
1442 | * Simply passes through the measured function, without measuring it. | ||
1443 | * | ||
1444 | * @param {string} objName | ||
1445 | * @param {string} fnName | ||
1446 | * @param {function} func | ||
1447 | * @return {function} | ||
1448 | */ | ||
1449 | function _noMeasure(objName, fnName, func) { | ||
1450 | return func; | ||
1451 | } | ||
1452 | |||
1453 | module.exports = ReactPerf; | ||
1454 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
1455 | |||
1456 | /***/ }, | ||
1457 | /* 21 */ | ||
1458 | /***/ function(module, exports, __webpack_require__) { | ||
1459 | |||
1460 | /** | ||
1461 | * Copyright 2013-2015, Facebook, Inc. | ||
1462 | * All rights reserved. | ||
1463 | * | ||
1464 | * This source code is licensed under the BSD-style license found in the | ||
1465 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1466 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1467 | * | ||
1468 | * @providesModule setInnerHTML | ||
1469 | */ | ||
1470 | |||
1471 | /* globals MSApp */ | ||
1472 | |||
1473 | 'use strict'; | ||
1474 | |||
1475 | var ExecutionEnvironment = __webpack_require__(11); | ||
1476 | |||
1477 | var WHITESPACE_TEST = /^[ \r\n\t\f]/; | ||
1478 | var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/; | ||
1479 | |||
1480 | /** | ||
1481 | * Set the innerHTML property of a node, ensuring that whitespace is preserved | ||
1482 | * even in IE8. | ||
1483 | * | ||
1484 | * @param {DOMElement} node | ||
1485 | * @param {string} html | ||
1486 | * @internal | ||
1487 | */ | ||
1488 | var setInnerHTML = function (node, html) { | ||
1489 | node.innerHTML = html; | ||
1490 | }; | ||
1491 | |||
1492 | // Win8 apps: Allow all html to be inserted | ||
1493 | if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { | ||
1494 | setInnerHTML = function (node, html) { | ||
1495 | MSApp.execUnsafeLocalFunction(function () { | ||
1496 | node.innerHTML = html; | ||
1497 | }); | ||
1498 | }; | ||
1499 | } | ||
1500 | |||
1501 | if (ExecutionEnvironment.canUseDOM) { | ||
1502 | // IE8: When updating a just created node with innerHTML only leading | ||
1503 | // whitespace is removed. When updating an existing node with innerHTML | ||
1504 | // whitespace in root TextNodes is also collapsed. | ||
1505 | // @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html | ||
1506 | |||
1507 | // Feature detection; only IE8 is known to behave improperly like this. | ||
1508 | var testElement = document.createElement('div'); | ||
1509 | testElement.innerHTML = ' '; | ||
1510 | if (testElement.innerHTML === '') { | ||
1511 | setInnerHTML = function (node, html) { | ||
1512 | // Magic theory: IE8 supposedly differentiates between added and updated | ||
1513 | // nodes when processing innerHTML, innerHTML on updated nodes suffers | ||
1514 | // from worse whitespace behavior. Re-adding a node like this triggers | ||
1515 | // the initial and more favorable whitespace behavior. | ||
1516 | // TODO: What to do on a detached node? | ||
1517 | if (node.parentNode) { | ||
1518 | node.parentNode.replaceChild(node, node); | ||
1519 | } | ||
1520 | |||
1521 | // We also implement a workaround for non-visible tags disappearing into | ||
1522 | // thin air on IE8, this only happens if there is no visible text | ||
1523 | // in-front of the non-visible tags. Piggyback on the whitespace fix | ||
1524 | // and simply check if any non-visible tags appear in the source. | ||
1525 | if (WHITESPACE_TEST.test(html) || html[0] === '<' && NONVISIBLE_TEST.test(html)) { | ||
1526 | // Recover leading whitespace by temporarily prepending any character. | ||
1527 | // \uFEFF has the potential advantage of being zero-width/invisible. | ||
1528 | // UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode | ||
1529 | // in hopes that this is preserved even if "\uFEFF" is transformed to | ||
1530 | // the actual Unicode character (by Babel, for example). | ||
1531 | // https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216 | ||
1532 | node.innerHTML = String.fromCharCode(0xFEFF) + html; | ||
1533 | |||
1534 | // deleteData leaves an empty `TextNode` which offsets the index of all | ||
1535 | // children. Definitely want to avoid this. | ||
1536 | var textNode = node.firstChild; | ||
1537 | if (textNode.data.length === 1) { | ||
1538 | node.removeChild(textNode); | ||
1539 | } else { | ||
1540 | textNode.deleteData(0, 1); | ||
1541 | } | ||
1542 | } else { | ||
1543 | node.innerHTML = html; | ||
1544 | } | ||
1545 | }; | ||
1546 | } | ||
1547 | } | ||
1548 | |||
1549 | module.exports = setInnerHTML; | ||
1550 | |||
1551 | /***/ }, | ||
1552 | /* 22 */ | ||
1553 | /***/ function(module, exports, __webpack_require__) { | ||
1554 | |||
1555 | /** | ||
1556 | * Copyright 2013-2015, Facebook, Inc. | ||
1557 | * All rights reserved. | ||
1558 | * | ||
1559 | * This source code is licensed under the BSD-style license found in the | ||
1560 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1561 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1562 | * | ||
1563 | * @providesModule setTextContent | ||
1564 | */ | ||
1565 | |||
1566 | 'use strict'; | ||
1567 | |||
1568 | var ExecutionEnvironment = __webpack_require__(11); | ||
1569 | var escapeTextContentForBrowser = __webpack_require__(23); | ||
1570 | var setInnerHTML = __webpack_require__(21); | ||
1571 | |||
1572 | /** | ||
1573 | * Set the textContent property of a node, ensuring that whitespace is preserved | ||
1574 | * even in IE8. innerText is a poor substitute for textContent and, among many | ||
1575 | * issues, inserts <br> instead of the literal newline chars. innerHTML behaves | ||
1576 | * as it should. | ||
1577 | * | ||
1578 | * @param {DOMElement} node | ||
1579 | * @param {string} text | ||
1580 | * @internal | ||
1581 | */ | ||
1582 | var setTextContent = function (node, text) { | ||
1583 | node.textContent = text; | ||
1584 | }; | ||
1585 | |||
1586 | if (ExecutionEnvironment.canUseDOM) { | ||
1587 | if (!('textContent' in document.documentElement)) { | ||
1588 | setTextContent = function (node, text) { | ||
1589 | setInnerHTML(node, escapeTextContentForBrowser(text)); | ||
1590 | }; | ||
1591 | } | ||
1592 | } | ||
1593 | |||
1594 | module.exports = setTextContent; | ||
1595 | |||
1596 | /***/ }, | ||
1597 | /* 23 */ | ||
1598 | /***/ function(module, exports) { | ||
1599 | |||
1600 | /** | ||
1601 | * Copyright 2013-2015, Facebook, Inc. | ||
1602 | * All rights reserved. | ||
1603 | * | ||
1604 | * This source code is licensed under the BSD-style license found in the | ||
1605 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1606 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1607 | * | ||
1608 | * @providesModule escapeTextContentForBrowser | ||
1609 | */ | ||
1610 | |||
1611 | 'use strict'; | ||
1612 | |||
1613 | var ESCAPE_LOOKUP = { | ||
1614 | '&': '&', | ||
1615 | '>': '>', | ||
1616 | '<': '<', | ||
1617 | '"': '"', | ||
1618 | '\'': ''' | ||
1619 | }; | ||
1620 | |||
1621 | var ESCAPE_REGEX = /[&><"']/g; | ||
1622 | |||
1623 | function escaper(match) { | ||
1624 | return ESCAPE_LOOKUP[match]; | ||
1625 | } | ||
1626 | |||
1627 | /** | ||
1628 | * Escapes text to prevent scripting attacks. | ||
1629 | * | ||
1630 | * @param {*} text Text value to escape. | ||
1631 | * @return {string} An escaped string. | ||
1632 | */ | ||
1633 | function escapeTextContentForBrowser(text) { | ||
1634 | return ('' + text).replace(ESCAPE_REGEX, escaper); | ||
1635 | } | ||
1636 | |||
1637 | module.exports = escapeTextContentForBrowser; | ||
1638 | |||
1639 | /***/ }, | ||
1640 | /* 24 */ | ||
1641 | /***/ function(module, exports, __webpack_require__) { | ||
1642 | |||
1643 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
1644 | * Copyright 2013-2015, Facebook, Inc. | ||
1645 | * All rights reserved. | ||
1646 | * | ||
1647 | * This source code is licensed under the BSD-style license found in the | ||
1648 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1649 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1650 | * | ||
1651 | * @providesModule DOMPropertyOperations | ||
1652 | * @typechecks static-only | ||
1653 | */ | ||
1654 | |||
1655 | 'use strict'; | ||
1656 | |||
1657 | var DOMProperty = __webpack_require__(25); | ||
1658 | var ReactPerf = __webpack_require__(20); | ||
1659 | |||
1660 | var quoteAttributeValueForBrowser = __webpack_require__(26); | ||
1661 | var warning = __webpack_require__(27); | ||
1662 | |||
1663 | // Simplified subset | ||
1664 | var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][\w\.\-]*$/; | ||
1665 | var illegalAttributeNameCache = {}; | ||
1666 | var validatedAttributeNameCache = {}; | ||
1667 | |||
1668 | function isAttributeNameSafe(attributeName) { | ||
1669 | if (validatedAttributeNameCache.hasOwnProperty(attributeName)) { | ||
1670 | return true; | ||
1671 | } | ||
1672 | if (illegalAttributeNameCache.hasOwnProperty(attributeName)) { | ||
1673 | return false; | ||
1674 | } | ||
1675 | if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { | ||
1676 | validatedAttributeNameCache[attributeName] = true; | ||
1677 | return true; | ||
1678 | } | ||
1679 | illegalAttributeNameCache[attributeName] = true; | ||
1680 | process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : undefined; | ||
1681 | return false; | ||
1682 | } | ||
1683 | |||
1684 | function shouldIgnoreValue(propertyInfo, value) { | ||
1685 | return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false; | ||
1686 | } | ||
1687 | |||
1688 | if (process.env.NODE_ENV !== 'production') { | ||
1689 | var reactProps = { | ||
1690 | children: true, | ||
1691 | dangerouslySetInnerHTML: true, | ||
1692 | key: true, | ||
1693 | ref: true | ||
1694 | }; | ||
1695 | var warnedProperties = {}; | ||
1696 | |||
1697 | var warnUnknownProperty = function (name) { | ||
1698 | if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) { | ||
1699 | return; | ||
1700 | } | ||
1701 | |||
1702 | warnedProperties[name] = true; | ||
1703 | var lowerCasedName = name.toLowerCase(); | ||
1704 | |||
1705 | // data-* attributes should be lowercase; suggest the lowercase version | ||
1706 | var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null; | ||
1707 | |||
1708 | // For now, only warn when we have a suggested correction. This prevents | ||
1709 | // logging too much when using transferPropsTo. | ||
1710 | process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined; | ||
1711 | }; | ||
1712 | } | ||
1713 | |||
1714 | /** | ||
1715 | * Operations for dealing with DOM properties. | ||
1716 | */ | ||
1717 | var DOMPropertyOperations = { | ||
1718 | |||
1719 | /** | ||
1720 | * Creates markup for the ID property. | ||
1721 | * | ||
1722 | * @param {string} id Unescaped ID. | ||
1723 | * @return {string} Markup string. | ||
1724 | */ | ||
1725 | createMarkupForID: function (id) { | ||
1726 | return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id); | ||
1727 | }, | ||
1728 | |||
1729 | setAttributeForID: function (node, id) { | ||
1730 | node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id); | ||
1731 | }, | ||
1732 | |||
1733 | /** | ||
1734 | * Creates markup for a property. | ||
1735 | * | ||
1736 | * @param {string} name | ||
1737 | * @param {*} value | ||
1738 | * @return {?string} Markup string, or null if the property was invalid. | ||
1739 | */ | ||
1740 | createMarkupForProperty: function (name, value) { | ||
1741 | var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null; | ||
1742 | if (propertyInfo) { | ||
1743 | if (shouldIgnoreValue(propertyInfo, value)) { | ||
1744 | return ''; | ||
1745 | } | ||
1746 | var attributeName = propertyInfo.attributeName; | ||
1747 | if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { | ||
1748 | return attributeName + '=""'; | ||
1749 | } | ||
1750 | return attributeName + '=' + quoteAttributeValueForBrowser(value); | ||
1751 | } else if (DOMProperty.isCustomAttribute(name)) { | ||
1752 | if (value == null) { | ||
1753 | return ''; | ||
1754 | } | ||
1755 | return name + '=' + quoteAttributeValueForBrowser(value); | ||
1756 | } else if (process.env.NODE_ENV !== 'production') { | ||
1757 | warnUnknownProperty(name); | ||
1758 | } | ||
1759 | return null; | ||
1760 | }, | ||
1761 | |||
1762 | /** | ||
1763 | * Creates markup for a custom property. | ||
1764 | * | ||
1765 | * @param {string} name | ||
1766 | * @param {*} value | ||
1767 | * @return {string} Markup string, or empty string if the property was invalid. | ||
1768 | */ | ||
1769 | createMarkupForCustomAttribute: function (name, value) { | ||
1770 | if (!isAttributeNameSafe(name) || value == null) { | ||
1771 | return ''; | ||
1772 | } | ||
1773 | return name + '=' + quoteAttributeValueForBrowser(value); | ||
1774 | }, | ||
1775 | |||
1776 | /** | ||
1777 | * Sets the value for a property on a node. | ||
1778 | * | ||
1779 | * @param {DOMElement} node | ||
1780 | * @param {string} name | ||
1781 | * @param {*} value | ||
1782 | */ | ||
1783 | setValueForProperty: function (node, name, value) { | ||
1784 | var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null; | ||
1785 | if (propertyInfo) { | ||
1786 | var mutationMethod = propertyInfo.mutationMethod; | ||
1787 | if (mutationMethod) { | ||
1788 | mutationMethod(node, value); | ||
1789 | } else if (shouldIgnoreValue(propertyInfo, value)) { | ||
1790 | this.deleteValueForProperty(node, name); | ||
1791 | } else if (propertyInfo.mustUseAttribute) { | ||
1792 | var attributeName = propertyInfo.attributeName; | ||
1793 | var namespace = propertyInfo.attributeNamespace; | ||
1794 | // `setAttribute` with objects becomes only `[object]` in IE8/9, | ||
1795 | // ('' + value) makes it output the correct toString()-value. | ||
1796 | if (namespace) { | ||
1797 | node.setAttributeNS(namespace, attributeName, '' + value); | ||
1798 | } else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { | ||
1799 | node.setAttribute(attributeName, ''); | ||
1800 | } else { | ||
1801 | node.setAttribute(attributeName, '' + value); | ||
1802 | } | ||
1803 | } else { | ||
1804 | var propName = propertyInfo.propertyName; | ||
1805 | // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the | ||
1806 | // property type before comparing; only `value` does and is string. | ||
1807 | if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) { | ||
1808 | // Contrary to `setAttribute`, object properties are properly | ||
1809 | // `toString`ed by IE8/9. | ||
1810 | node[propName] = value; | ||
1811 | } | ||
1812 | } | ||
1813 | } else if (DOMProperty.isCustomAttribute(name)) { | ||
1814 | DOMPropertyOperations.setValueForAttribute(node, name, value); | ||
1815 | } else if (process.env.NODE_ENV !== 'production') { | ||
1816 | warnUnknownProperty(name); | ||
1817 | } | ||
1818 | }, | ||
1819 | |||
1820 | setValueForAttribute: function (node, name, value) { | ||
1821 | if (!isAttributeNameSafe(name)) { | ||
1822 | return; | ||
1823 | } | ||
1824 | if (value == null) { | ||
1825 | node.removeAttribute(name); | ||
1826 | } else { | ||
1827 | node.setAttribute(name, '' + value); | ||
1828 | } | ||
1829 | }, | ||
1830 | |||
1831 | /** | ||
1832 | * Deletes the value for a property on a node. | ||
1833 | * | ||
1834 | * @param {DOMElement} node | ||
1835 | * @param {string} name | ||
1836 | */ | ||
1837 | deleteValueForProperty: function (node, name) { | ||
1838 | var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null; | ||
1839 | if (propertyInfo) { | ||
1840 | var mutationMethod = propertyInfo.mutationMethod; | ||
1841 | if (mutationMethod) { | ||
1842 | mutationMethod(node, undefined); | ||
1843 | } else if (propertyInfo.mustUseAttribute) { | ||
1844 | node.removeAttribute(propertyInfo.attributeName); | ||
1845 | } else { | ||
1846 | var propName = propertyInfo.propertyName; | ||
1847 | var defaultValue = DOMProperty.getDefaultValueForProperty(node.nodeName, propName); | ||
1848 | if (!propertyInfo.hasSideEffects || '' + node[propName] !== defaultValue) { | ||
1849 | node[propName] = defaultValue; | ||
1850 | } | ||
1851 | } | ||
1852 | } else if (DOMProperty.isCustomAttribute(name)) { | ||
1853 | node.removeAttribute(name); | ||
1854 | } else if (process.env.NODE_ENV !== 'production') { | ||
1855 | warnUnknownProperty(name); | ||
1856 | } | ||
1857 | } | ||
1858 | |||
1859 | }; | ||
1860 | |||
1861 | ReactPerf.measureMethods(DOMPropertyOperations, 'DOMPropertyOperations', { | ||
1862 | setValueForProperty: 'setValueForProperty', | ||
1863 | setValueForAttribute: 'setValueForAttribute', | ||
1864 | deleteValueForProperty: 'deleteValueForProperty' | ||
1865 | }); | ||
1866 | |||
1867 | module.exports = DOMPropertyOperations; | ||
1868 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
1869 | |||
1870 | /***/ }, | ||
1871 | /* 25 */ | ||
1872 | /***/ function(module, exports, __webpack_require__) { | ||
1873 | |||
1874 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
1875 | * Copyright 2013-2015, Facebook, Inc. | ||
1876 | * All rights reserved. | ||
1877 | * | ||
1878 | * This source code is licensed under the BSD-style license found in the | ||
1879 | * LICENSE file in the root directory of this source tree. An additional grant | ||
1880 | * of patent rights can be found in the PATENTS file in the same directory. | ||
1881 | * | ||
1882 | * @providesModule DOMProperty | ||
1883 | * @typechecks static-only | ||
1884 | */ | ||
1885 | |||
1886 | 'use strict'; | ||
1887 | |||
1888 | var invariant = __webpack_require__(15); | ||
1889 | |||
1890 | function checkMask(value, bitmask) { | ||
1891 | return (value & bitmask) === bitmask; | ||
1892 | } | ||
1893 | |||
1894 | var DOMPropertyInjection = { | ||
1895 | /** | ||
1896 | * Mapping from normalized, camelcased property names to a configuration that | ||
1897 | * specifies how the associated DOM property should be accessed or rendered. | ||
1898 | */ | ||
1899 | MUST_USE_ATTRIBUTE: 0x1, | ||
1900 | MUST_USE_PROPERTY: 0x2, | ||
1901 | HAS_SIDE_EFFECTS: 0x4, | ||
1902 | HAS_BOOLEAN_VALUE: 0x8, | ||
1903 | HAS_NUMERIC_VALUE: 0x10, | ||
1904 | HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10, | ||
1905 | HAS_OVERLOADED_BOOLEAN_VALUE: 0x40, | ||
1906 | |||
1907 | /** | ||
1908 | * Inject some specialized knowledge about the DOM. This takes a config object | ||
1909 | * with the following properties: | ||
1910 | * | ||
1911 | * isCustomAttribute: function that given an attribute name will return true | ||
1912 | * if it can be inserted into the DOM verbatim. Useful for data-* or aria-* | ||
1913 | * attributes where it's impossible to enumerate all of the possible | ||
1914 | * attribute names, | ||
1915 | * | ||
1916 | * Properties: object mapping DOM property name to one of the | ||
1917 | * DOMPropertyInjection constants or null. If your attribute isn't in here, | ||
1918 | * it won't get written to the DOM. | ||
1919 | * | ||
1920 | * DOMAttributeNames: object mapping React attribute name to the DOM | ||
1921 | * attribute name. Attribute names not specified use the **lowercase** | ||
1922 | * normalized name. | ||
1923 | * | ||
1924 | * DOMAttributeNamespaces: object mapping React attribute name to the DOM | ||
1925 | * attribute namespace URL. (Attribute names not specified use no namespace.) | ||
1926 | * | ||
1927 | * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties. | ||
1928 | * Property names not specified use the normalized name. | ||
1929 | * | ||
1930 | * DOMMutationMethods: Properties that require special mutation methods. If | ||
1931 | * `value` is undefined, the mutation method should unset the property. | ||
1932 | * | ||
1933 | * @param {object} domPropertyConfig the config as described above. | ||
1934 | */ | ||
1935 | injectDOMPropertyConfig: function (domPropertyConfig) { | ||
1936 | var Injection = DOMPropertyInjection; | ||
1937 | var Properties = domPropertyConfig.Properties || {}; | ||
1938 | var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {}; | ||
1939 | var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {}; | ||
1940 | var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {}; | ||
1941 | var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {}; | ||
1942 | |||
1943 | if (domPropertyConfig.isCustomAttribute) { | ||
1944 | DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute); | ||
1945 | } | ||
1946 | |||
1947 | for (var propName in Properties) { | ||
1948 | !!DOMProperty.properties.hasOwnProperty(propName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName) : invariant(false) : undefined; | ||
1949 | |||
1950 | var lowerCased = propName.toLowerCase(); | ||
1951 | var propConfig = Properties[propName]; | ||
1952 | |||
1953 | var propertyInfo = { | ||
1954 | attributeName: lowerCased, | ||
1955 | attributeNamespace: null, | ||
1956 | propertyName: propName, | ||
1957 | mutationMethod: null, | ||
1958 | |||
1959 | mustUseAttribute: checkMask(propConfig, Injection.MUST_USE_ATTRIBUTE), | ||
1960 | mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY), | ||
1961 | hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS), | ||
1962 | hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE), | ||
1963 | hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE), | ||
1964 | hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE), | ||
1965 | hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE) | ||
1966 | }; | ||
1967 | |||
1968 | !(!propertyInfo.mustUseAttribute || !propertyInfo.mustUseProperty) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Cannot require using both attribute and property: %s', propName) : invariant(false) : undefined; | ||
1969 | !(propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Properties that have side effects must use property: %s', propName) : invariant(false) : undefined; | ||
1970 | !(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(false) : undefined; | ||
1971 | |||
1972 | if (process.env.NODE_ENV !== 'production') { | ||
1973 | DOMProperty.getPossibleStandardName[lowerCased] = propName; | ||
1974 | } | ||
1975 | |||
1976 | if (DOMAttributeNames.hasOwnProperty(propName)) { | ||
1977 | var attributeName = DOMAttributeNames[propName]; | ||
1978 | propertyInfo.attributeName = attributeName; | ||
1979 | if (process.env.NODE_ENV !== 'production') { | ||
1980 | DOMProperty.getPossibleStandardName[attributeName] = propName; | ||
1981 | } | ||
1982 | } | ||
1983 | |||
1984 | if (DOMAttributeNamespaces.hasOwnProperty(propName)) { | ||
1985 | propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName]; | ||
1986 | } | ||
1987 | |||
1988 | if (DOMPropertyNames.hasOwnProperty(propName)) { | ||
1989 | propertyInfo.propertyName = DOMPropertyNames[propName]; | ||
1990 | } | ||
1991 | |||
1992 | if (DOMMutationMethods.hasOwnProperty(propName)) { | ||
1993 | propertyInfo.mutationMethod = DOMMutationMethods[propName]; | ||
1994 | } | ||
1995 | |||
1996 | DOMProperty.properties[propName] = propertyInfo; | ||
1997 | } | ||
1998 | } | ||
1999 | }; | ||
2000 | var defaultValueCache = {}; | ||
2001 | |||
2002 | /** | ||
2003 | * DOMProperty exports lookup objects that can be used like functions: | ||
2004 | * | ||
2005 | * > DOMProperty.isValid['id'] | ||
2006 | * true | ||
2007 | * > DOMProperty.isValid['foobar'] | ||
2008 | * undefined | ||
2009 | * | ||
2010 | * Although this may be confusing, it performs better in general. | ||
2011 | * | ||
2012 | * @see http://jsperf.com/key-exists | ||
2013 | * @see http://jsperf.com/key-missing | ||
2014 | */ | ||
2015 | var DOMProperty = { | ||
2016 | |||
2017 | ID_ATTRIBUTE_NAME: 'data-reactid', | ||
2018 | |||
2019 | /** | ||
2020 | * Map from property "standard name" to an object with info about how to set | ||
2021 | * the property in the DOM. Each object contains: | ||
2022 | * | ||
2023 | * attributeName: | ||
2024 | * Used when rendering markup or with `*Attribute()`. | ||
2025 | * attributeNamespace | ||
2026 | * propertyName: | ||
2027 | * Used on DOM node instances. (This includes properties that mutate due to | ||
2028 | * external factors.) | ||
2029 | * mutationMethod: | ||
2030 | * If non-null, used instead of the property or `setAttribute()` after | ||
2031 | * initial render. | ||
2032 | * mustUseAttribute: | ||
2033 | * Whether the property must be accessed and mutated using `*Attribute()`. | ||
2034 | * (This includes anything that fails `<propName> in <element>`.) | ||
2035 | * mustUseProperty: | ||
2036 | * Whether the property must be accessed and mutated as an object property. | ||
2037 | * hasSideEffects: | ||
2038 | * Whether or not setting a value causes side effects such as triggering | ||
2039 | * resources to be loaded or text selection changes. If true, we read from | ||
2040 | * the DOM before updating to ensure that the value is only set if it has | ||
2041 | * changed. | ||
2042 | * hasBooleanValue: | ||
2043 | * Whether the property should be removed when set to a falsey value. | ||
2044 | * hasNumericValue: | ||
2045 | * Whether the property must be numeric or parse as a numeric and should be | ||
2046 | * removed when set to a falsey value. | ||
2047 | * hasPositiveNumericValue: | ||
2048 | * Whether the property must be positive numeric or parse as a positive | ||
2049 | * numeric and should be removed when set to a falsey value. | ||
2050 | * hasOverloadedBooleanValue: | ||
2051 | * Whether the property can be used as a flag as well as with a value. | ||
2052 | * Removed when strictly equal to false; present without a value when | ||
2053 | * strictly equal to true; present with a value otherwise. | ||
2054 | */ | ||
2055 | properties: {}, | ||
2056 | |||
2057 | /** | ||
2058 | * Mapping from lowercase property names to the properly cased version, used | ||
2059 | * to warn in the case of missing properties. Available only in __DEV__. | ||
2060 | * @type {Object} | ||
2061 | */ | ||
2062 | getPossibleStandardName: process.env.NODE_ENV !== 'production' ? {} : null, | ||
2063 | |||
2064 | /** | ||
2065 | * All of the isCustomAttribute() functions that have been injected. | ||
2066 | */ | ||
2067 | _isCustomAttributeFunctions: [], | ||
2068 | |||
2069 | /** | ||
2070 | * Checks whether a property name is a custom attribute. | ||
2071 | * @method | ||
2072 | */ | ||
2073 | isCustomAttribute: function (attributeName) { | ||
2074 | for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) { | ||
2075 | var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i]; | ||
2076 | if (isCustomAttributeFn(attributeName)) { | ||
2077 | return true; | ||
2078 | } | ||
2079 | } | ||
2080 | return false; | ||
2081 | }, | ||
2082 | |||
2083 | /** | ||
2084 | * Returns the default property value for a DOM property (i.e., not an | ||
2085 | * attribute). Most default values are '' or false, but not all. Worse yet, | ||
2086 | * some (in particular, `type`) vary depending on the type of element. | ||
2087 | * | ||
2088 | * TODO: Is it better to grab all the possible properties when creating an | ||
2089 | * element to avoid having to create the same element twice? | ||
2090 | */ | ||
2091 | getDefaultValueForProperty: function (nodeName, prop) { | ||
2092 | var nodeDefaults = defaultValueCache[nodeName]; | ||
2093 | var testElement; | ||
2094 | if (!nodeDefaults) { | ||
2095 | defaultValueCache[nodeName] = nodeDefaults = {}; | ||
2096 | } | ||
2097 | if (!(prop in nodeDefaults)) { | ||
2098 | testElement = document.createElement(nodeName); | ||
2099 | nodeDefaults[prop] = testElement[prop]; | ||
2100 | } | ||
2101 | return nodeDefaults[prop]; | ||
2102 | }, | ||
2103 | |||
2104 | injection: DOMPropertyInjection | ||
2105 | }; | ||
2106 | |||
2107 | module.exports = DOMProperty; | ||
2108 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
2109 | |||
2110 | /***/ }, | ||
2111 | /* 26 */ | ||
2112 | /***/ function(module, exports, __webpack_require__) { | ||
2113 | |||
2114 | /** | ||
2115 | * Copyright 2013-2015, Facebook, Inc. | ||
2116 | * All rights reserved. | ||
2117 | * | ||
2118 | * This source code is licensed under the BSD-style license found in the | ||
2119 | * LICENSE file in the root directory of this source tree. An additional grant | ||
2120 | * of patent rights can be found in the PATENTS file in the same directory. | ||
2121 | * | ||
2122 | * @providesModule quoteAttributeValueForBrowser | ||
2123 | */ | ||
2124 | |||
2125 | 'use strict'; | ||
2126 | |||
2127 | var escapeTextContentForBrowser = __webpack_require__(23); | ||
2128 | |||
2129 | /** | ||
2130 | * Escapes attribute value to prevent scripting attacks. | ||
2131 | * | ||
2132 | * @param {*} value Value to escape. | ||
2133 | * @return {string} An escaped string. | ||
2134 | */ | ||
2135 | function quoteAttributeValueForBrowser(value) { | ||
2136 | return '"' + escapeTextContentForBrowser(value) + '"'; | ||
2137 | } | ||
2138 | |||
2139 | module.exports = quoteAttributeValueForBrowser; | ||
2140 | |||
2141 | /***/ }, | ||
2142 | /* 27 */ | ||
2143 | /***/ function(module, exports, __webpack_require__) { | ||
2144 | |||
2145 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
2146 | * Copyright 2014-2015, Facebook, Inc. | ||
2147 | * All rights reserved. | ||
2148 | * | ||
2149 | * This source code is licensed under the BSD-style license found in the | ||
2150 | * LICENSE file in the root directory of this source tree. An additional grant | ||
2151 | * of patent rights can be found in the PATENTS file in the same directory. | ||
2152 | * | ||
2153 | * @providesModule warning | ||
2154 | */ | ||
2155 | |||
2156 | 'use strict'; | ||
2157 | |||
2158 | var emptyFunction = __webpack_require__(17); | ||
2159 | |||
2160 | /** | ||
2161 | * Similar to invariant but only logs a warning if the condition is not met. | ||
2162 | * This can be used to log issues in development environments in critical | ||
2163 | * paths. Removing the logging code for production environments will keep the | ||
2164 | * same logic and follow the same code paths. | ||
2165 | */ | ||
2166 | |||
2167 | var warning = emptyFunction; | ||
2168 | |||
2169 | if (process.env.NODE_ENV !== 'production') { | ||
2170 | warning = function (condition, format) { | ||
2171 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
2172 | args[_key - 2] = arguments[_key]; | ||
2173 | } | ||
2174 | |||
2175 | if (format === undefined) { | ||
2176 | throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
2177 | } | ||
2178 | |||
2179 | if (format.indexOf('Failed Composite propType: ') === 0) { | ||
2180 | return; // Ignore CompositeComponent proptype check. | ||
2181 | } | ||
2182 | |||
2183 | if (!condition) { | ||
2184 | var argIndex = 0; | ||
2185 | var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
2186 | return args[argIndex++]; | ||
2187 | }); | ||
2188 | if (typeof console !== 'undefined') { | ||
2189 | console.error(message); | ||
2190 | } | ||
2191 | try { | ||
2192 | // --- Welcome to debugging React --- | ||
2193 | // This error was thrown as a convenience so that you can use this stack | ||
2194 | // to find the callsite that caused this warning to fire. | ||
2195 | throw new Error(message); | ||
2196 | } catch (x) {} | ||
2197 | } | ||
2198 | }; | ||
2199 | } | ||
2200 | |||
2201 | module.exports = warning; | ||
2202 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
2203 | |||
2204 | /***/ }, | ||
2205 | /* 28 */ | ||
2206 | /***/ function(module, exports, __webpack_require__) { | ||
2207 | |||
2208 | /** | ||
2209 | * Copyright 2013-2015, Facebook, Inc. | ||
2210 | * All rights reserved. | ||
2211 | * | ||
2212 | * This source code is licensed under the BSD-style license found in the | ||
2213 | * LICENSE file in the root directory of this source tree. An additional grant | ||
2214 | * of patent rights can be found in the PATENTS file in the same directory. | ||
2215 | * | ||
2216 | * @providesModule ReactComponentBrowserEnvironment | ||
2217 | */ | ||
2218 | |||
2219 | 'use strict'; | ||
2220 | |||
2221 | var ReactDOMIDOperations = __webpack_require__(29); | ||
2222 | var ReactMount = __webpack_require__(30); | ||
2223 | |||
2224 | /** | ||
2225 | * Abstracts away all functionality of the reconciler that requires knowledge of | ||
2226 | * the browser context. TODO: These callers should be refactored to avoid the | ||
2227 | * need for this injection. | ||
2228 | */ | ||
2229 | var ReactComponentBrowserEnvironment = { | ||
2230 | |||
2231 | processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates, | ||
2232 | |||
2233 | replaceNodeWithMarkupByID: ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID, | ||
2234 | |||
2235 | /** | ||
2236 | * If a particular environment requires that some resources be cleaned up, | ||
2237 | * specify this in the injected Mixin. In the DOM, we would likely want to | ||
2238 | * purge any cached node ID lookups. | ||
2239 | * | ||
2240 | * @private | ||
2241 | */ | ||
2242 | unmountIDFromEnvironment: function (rootNodeID) { | ||
2243 | ReactMount.purgeID(rootNodeID); | ||
2244 | } | ||
2245 | |||
2246 | }; | ||
2247 | |||
2248 | module.exports = ReactComponentBrowserEnvironment; | ||
2249 | |||
2250 | /***/ }, | ||
2251 | /* 29 */ | ||
2252 | /***/ function(module, exports, __webpack_require__) { | ||
2253 | |||
2254 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
2255 | * Copyright 2013-2015, Facebook, Inc. | ||
2256 | * All rights reserved. | ||
2257 | * | ||
2258 | * This source code is licensed under the BSD-style license found in the | ||
2259 | * LICENSE file in the root directory of this source tree. An additional grant | ||
2260 | * of patent rights can be found in the PATENTS file in the same directory. | ||
2261 | * | ||
2262 | * @providesModule ReactDOMIDOperations | ||
2263 | * @typechecks static-only | ||
2264 | */ | ||
2265 | |||
2266 | 'use strict'; | ||
2267 | |||
2268 | var DOMChildrenOperations = __webpack_require__(9); | ||
2269 | var DOMPropertyOperations = __webpack_require__(24); | ||
2270 | var ReactMount = __webpack_require__(30); | ||
2271 | var ReactPerf = __webpack_require__(20); | ||
2272 | |||
2273 | var invariant = __webpack_require__(15); | ||
2274 | |||
2275 | /** | ||
2276 | * Errors for properties that should not be updated with `updatePropertyByID()`. | ||
2277 | * | ||
2278 | * @type {object} | ||
2279 | * @private | ||
2280 | */ | ||
2281 | var INVALID_PROPERTY_ERRORS = { | ||
2282 | dangerouslySetInnerHTML: '`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.', | ||
2283 | style: '`style` must be set using `updateStylesByID()`.' | ||
2284 | }; | ||
2285 | |||
2286 | /** | ||
2287 | * Operations used to process updates to DOM nodes. | ||
2288 | */ | ||
2289 | var ReactDOMIDOperations = { | ||
2290 | |||
2291 | /** | ||
2292 | * Updates a DOM node with new property values. This should only be used to | ||
2293 | * update DOM properties in `DOMProperty`. | ||
2294 | * | ||
2295 | * @param {string} id ID of the node to update. | ||
2296 | * @param {string} name A valid property name, see `DOMProperty`. | ||
2297 | * @param {*} value New value of the property. | ||
2298 | * @internal | ||
2299 | */ | ||
2300 | updatePropertyByID: function (id, name, value) { | ||
2301 | var node = ReactMount.getNode(id); | ||
2302 | !!INVALID_PROPERTY_ERRORS.hasOwnProperty(name) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name]) : invariant(false) : undefined; | ||
2303 | |||
2304 | // If we're updating to null or undefined, we should remove the property | ||
2305 | // from the DOM node instead of inadvertantly setting to a string. This | ||
2306 | // brings us in line with the same behavior we have on initial render. | ||
2307 | if (value != null) { | ||
2308 | DOMPropertyOperations.setValueForProperty(node, name, value); | ||
2309 | } else { | ||
2310 | DOMPropertyOperations.deleteValueForProperty(node, name); | ||
2311 | } | ||
2312 | }, | ||
2313 | |||
2314 | /** | ||
2315 | * Replaces a DOM node that exists in the document with markup. | ||
2316 | * | ||
2317 | * @param {string} id ID of child to be replaced. | ||
2318 | * @param {string} markup Dangerous markup to inject in place of child. | ||
2319 | * @internal | ||
2320 | * @see {Danger.dangerouslyReplaceNodeWithMarkup} | ||
2321 | */ | ||
2322 | dangerouslyReplaceNodeWithMarkupByID: function (id, markup) { | ||
2323 | var node = ReactMount.getNode(id); | ||
2324 | DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup); | ||
2325 | }, | ||
2326 | |||
2327 | /** | ||
2328 | * Updates a component's children by processing a series of updates. | ||
2329 | * | ||
2330 | * @param {array<object>} updates List of update configurations. | ||
2331 | * @param {array<string>} markup List of markup strings. | ||
2332 | * @internal | ||
2333 | */ | ||
2334 | dangerouslyProcessChildrenUpdates: function (updates, markup) { | ||
2335 | for (var i = 0; i < updates.length; i++) { | ||
2336 | updates[i].parentNode = ReactMount.getNode(updates[i].parentID); | ||
2337 | } | ||
2338 | DOMChildrenOperations.processUpdates(updates, markup); | ||
2339 | } | ||
2340 | }; | ||
2341 | |||
2342 | ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', { | ||
2343 | dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID', | ||
2344 | dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates' | ||
2345 | }); | ||
2346 | |||
2347 | module.exports = ReactDOMIDOperations; | ||
2348 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
2349 | |||
2350 | /***/ }, | ||
2351 | /* 30 */ | ||
2352 | /***/ function(module, exports, __webpack_require__) { | ||
2353 | |||
2354 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
2355 | * Copyright 2013-2015, Facebook, Inc. | ||
2356 | * All rights reserved. | ||
2357 | * | ||
2358 | * This source code is licensed under the BSD-style license found in the | ||
2359 | * LICENSE file in the root directory of this source tree. An additional grant | ||
2360 | * of patent rights can be found in the PATENTS file in the same directory. | ||
2361 | * | ||
2362 | * @providesModule ReactMount | ||
2363 | */ | ||
2364 | |||
2365 | 'use strict'; | ||
2366 | |||
2367 | var DOMProperty = __webpack_require__(25); | ||
2368 | var ReactBrowserEventEmitter = __webpack_require__(31); | ||
2369 | var ReactCurrentOwner = __webpack_require__(7); | ||
2370 | var ReactDOMFeatureFlags = __webpack_require__(43); | ||
2371 | var ReactElement = __webpack_require__(44); | ||
2372 | var ReactEmptyComponentRegistry = __webpack_require__(46); | ||
2373 | var ReactInstanceHandles = __webpack_require__(47); | ||
2374 | var ReactInstanceMap = __webpack_require__(49); | ||
2375 | var ReactMarkupChecksum = __webpack_require__(50); | ||
2376 | var ReactPerf = __webpack_require__(20); | ||
2377 | var ReactReconciler = __webpack_require__(52); | ||
2378 | var ReactUpdateQueue = __webpack_require__(55); | ||
2379 | var ReactUpdates = __webpack_require__(56); | ||
2380 | |||
2381 | var assign = __webpack_require__(41); | ||
2382 | var emptyObject = __webpack_require__(60); | ||
2383 | var containsNode = __webpack_require__(61); | ||
2384 | var instantiateReactComponent = __webpack_require__(64); | ||
2385 | var invariant = __webpack_require__(15); | ||
2386 | var setInnerHTML = __webpack_require__(21); | ||
2387 | var shouldUpdateReactComponent = __webpack_require__(69); | ||
2388 | var validateDOMNesting = __webpack_require__(72); | ||
2389 | var warning = __webpack_require__(27); | ||
2390 | |||
2391 | var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME; | ||
2392 | var nodeCache = {}; | ||
2393 | |||
2394 | var ELEMENT_NODE_TYPE = 1; | ||
2395 | var DOC_NODE_TYPE = 9; | ||
2396 | var DOCUMENT_FRAGMENT_NODE_TYPE = 11; | ||
2397 | |||
2398 | var ownerDocumentContextKey = '__ReactMount_ownerDocument$' + Math.random().toString(36).slice(2); | ||
2399 | |||
2400 | /** Mapping from reactRootID to React component instance. */ | ||
2401 | var instancesByReactRootID = {}; | ||
2402 | |||
2403 | /** Mapping from reactRootID to `container` nodes. */ | ||
2404 | var containersByReactRootID = {}; | ||
2405 | |||
2406 | if (process.env.NODE_ENV !== 'production') { | ||
2407 | /** __DEV__-only mapping from reactRootID to root elements. */ | ||
2408 | var rootElementsByReactRootID = {}; | ||
2409 | } | ||
2410 | |||
2411 | // Used to store breadth-first search state in findComponentRoot. | ||
2412 | var findComponentRootReusableArray = []; | ||
2413 | |||
2414 | /** | ||
2415 | * Finds the index of the first character | ||
2416 | * that's not common between the two given strings. | ||
2417 | * | ||
2418 | * @return {number} the index of the character where the strings diverge | ||
2419 | */ | ||
2420 | function firstDifferenceIndex(string1, string2) { | ||
2421 | var minLen = Math.min(string1.length, string2.length); | ||
2422 | for (var i = 0; i < minLen; i++) { | ||
2423 | if (string1.charAt(i) !== string2.charAt(i)) { | ||
2424 | return i; | ||
2425 | } | ||
2426 | } | ||
2427 | return string1.length === string2.length ? -1 : minLen; | ||
2428 | } | ||
2429 | |||
2430 | /** | ||
2431 | * @param {DOMElement|DOMDocument} container DOM element that may contain | ||
2432 | * a React component | ||
2433 | * @return {?*} DOM element that may have the reactRoot ID, or null. | ||
2434 | */ | ||
2435 | function getReactRootElementInContainer(container) { | ||
2436 | if (!container) { | ||
2437 | return null; | ||
2438 | } | ||
2439 | |||
2440 | if (container.nodeType === DOC_NODE_TYPE) { | ||
2441 | return container.documentElement; | ||
2442 | } else { | ||
2443 | return container.firstChild; | ||
2444 | } | ||
2445 | } | ||
2446 | |||
2447 | /** | ||
2448 | * @param {DOMElement} container DOM element that may contain a React component. | ||
2449 | * @return {?string} A "reactRoot" ID, if a React component is rendered. | ||
2450 | */ | ||
2451 | function getReactRootID(container) { | ||
2452 | var rootElement = getReactRootElementInContainer(container); | ||
2453 | return rootElement && ReactMount.getID(rootElement); | ||
2454 | } | ||
2455 | |||
2456 | /** | ||
2457 | * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form | ||
2458 | * element can return its control whose name or ID equals ATTR_NAME. All | ||
2459 | * DOM nodes support `getAttributeNode` but this can also get called on | ||
2460 | * other objects so just return '' if we're given something other than a | ||
2461 | * DOM node (such as window). | ||
2462 | * | ||
2463 | * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node. | ||
2464 | * @return {string} ID of the supplied `domNode`. | ||
2465 | */ | ||
2466 | function getID(node) { | ||
2467 | var id = internalGetID(node); | ||
2468 | if (id) { | ||
2469 | if (nodeCache.hasOwnProperty(id)) { | ||
2470 | var cached = nodeCache[id]; | ||
2471 | if (cached !== node) { | ||
2472 | !!isValid(cached, id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined; | ||
2473 | |||
2474 | nodeCache[id] = node; | ||
2475 | } | ||
2476 | } else { | ||
2477 | nodeCache[id] = node; | ||
2478 | } | ||
2479 | } | ||
2480 | |||
2481 | return id; | ||
2482 | } | ||
2483 | |||
2484 | function internalGetID(node) { | ||
2485 | // If node is something like a window, document, or text node, none of | ||
2486 | // which support attributes or a .getAttribute method, gracefully return | ||
2487 | // the empty string, as if the attribute were missing. | ||
2488 | return node && node.getAttribute && node.getAttribute(ATTR_NAME) || ''; | ||
2489 | } | ||
2490 | |||
2491 | /** | ||
2492 | * Sets the React-specific ID of the given node. | ||
2493 | * | ||
2494 | * @param {DOMElement} node The DOM node whose ID will be set. | ||
2495 | * @param {string} id The value of the ID attribute. | ||
2496 | */ | ||
2497 | function setID(node, id) { | ||
2498 | var oldID = internalGetID(node); | ||
2499 | if (oldID !== id) { | ||
2500 | delete nodeCache[oldID]; | ||
2501 | } | ||
2502 | node.setAttribute(ATTR_NAME, id); | ||
2503 | nodeCache[id] = node; | ||
2504 | } | ||
2505 | |||
2506 | /** | ||
2507 | * Finds the node with the supplied React-generated DOM ID. | ||
2508 | * | ||
2509 | * @param {string} id A React-generated DOM ID. | ||
2510 | * @return {DOMElement} DOM node with the suppled `id`. | ||
2511 | * @internal | ||
2512 | */ | ||
2513 | function getNode(id) { | ||
2514 | if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) { | ||
2515 | nodeCache[id] = ReactMount.findReactNodeByID(id); | ||
2516 | } | ||
2517 | return nodeCache[id]; | ||
2518 | } | ||
2519 | |||
2520 | /** | ||
2521 | * Finds the node with the supplied public React instance. | ||
2522 | * | ||
2523 | * @param {*} instance A public React instance. | ||
2524 | * @return {?DOMElement} DOM node with the suppled `id`. | ||
2525 | * @internal | ||
2526 | */ | ||
2527 | function getNodeFromInstance(instance) { | ||
2528 | var id = ReactInstanceMap.get(instance)._rootNodeID; | ||
2529 | if (ReactEmptyComponentRegistry.isNullComponentID(id)) { | ||
2530 | return null; | ||
2531 | } | ||
2532 | if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) { | ||
2533 | nodeCache[id] = ReactMount.findReactNodeByID(id); | ||
2534 | } | ||
2535 | return nodeCache[id]; | ||
2536 | } | ||
2537 | |||
2538 | /** | ||
2539 | * A node is "valid" if it is contained by a currently mounted container. | ||
2540 | * | ||
2541 | * This means that the node does not have to be contained by a document in | ||
2542 | * order to be considered valid. | ||
2543 | * | ||
2544 | * @param {?DOMElement} node The candidate DOM node. | ||
2545 | * @param {string} id The expected ID of the node. | ||
2546 | * @return {boolean} Whether the node is contained by a mounted container. | ||
2547 | */ | ||
2548 | function isValid(node, id) { | ||
2549 | if (node) { | ||
2550 | !(internalGetID(node) === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined; | ||
2551 | |||
2552 | var container = ReactMount.findReactContainerForID(id); | ||
2553 | if (container && containsNode(container, node)) { | ||
2554 | return true; | ||
2555 | } | ||
2556 | } | ||
2557 | |||
2558 | return false; | ||
2559 | } | ||
2560 | |||
2561 | /** | ||
2562 | * Causes the cache to forget about one React-specific ID. | ||
2563 | * | ||
2564 | * @param {string} id The ID to forget. | ||
2565 | */ | ||
2566 | function purgeID(id) { | ||
2567 | delete nodeCache[id]; | ||
2568 | } | ||
2569 | |||
2570 | var deepestNodeSoFar = null; | ||
2571 | function findDeepestCachedAncestorImpl(ancestorID) { | ||
2572 | var ancestor = nodeCache[ancestorID]; | ||
2573 | if (ancestor && isValid(ancestor, ancestorID)) { | ||
2574 | deepestNodeSoFar = ancestor; | ||
2575 | } else { | ||
2576 | // This node isn't populated in the cache, so presumably none of its | ||
2577 | // descendants are. Break out of the loop. | ||
2578 | return false; | ||
2579 | } | ||
2580 | } | ||
2581 | |||
2582 | /** | ||
2583 | * Return the deepest cached node whose ID is a prefix of `targetID`. | ||
2584 | */ | ||
2585 | function findDeepestCachedAncestor(targetID) { | ||
2586 | deepestNodeSoFar = null; | ||
2587 | ReactInstanceHandles.traverseAncestors(targetID, findDeepestCachedAncestorImpl); | ||
2588 | |||
2589 | var foundNode = deepestNodeSoFar; | ||
2590 | deepestNodeSoFar = null; | ||
2591 | return foundNode; | ||
2592 | } | ||
2593 | |||
2594 | /** | ||
2595 | * Mounts this component and inserts it into the DOM. | ||
2596 | * | ||
2597 | * @param {ReactComponent} componentInstance The instance to mount. | ||
2598 | * @param {string} rootID DOM ID of the root node. | ||
2599 | * @param {DOMElement} container DOM element to mount into. | ||
2600 | * @param {ReactReconcileTransaction} transaction | ||
2601 | * @param {boolean} shouldReuseMarkup If true, do not insert markup | ||
2602 | */ | ||
2603 | function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) { | ||
2604 | if (ReactDOMFeatureFlags.useCreateElement) { | ||
2605 | context = assign({}, context); | ||
2606 | if (container.nodeType === DOC_NODE_TYPE) { | ||
2607 | context[ownerDocumentContextKey] = container; | ||
2608 | } else { | ||
2609 | context[ownerDocumentContextKey] = container.ownerDocument; | ||
2610 | } | ||
2611 | } | ||
2612 | if (process.env.NODE_ENV !== 'production') { | ||
2613 | if (context === emptyObject) { | ||
2614 | context = {}; | ||
2615 | } | ||
2616 | var tag = container.nodeName.toLowerCase(); | ||
2617 | context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null); | ||
2618 | } | ||
2619 | var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context); | ||
2620 | componentInstance._renderedComponent._topLevelWrapper = componentInstance; | ||
2621 | ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup, transaction); | ||
2622 | } | ||
2623 | |||
2624 | /** | ||
2625 | * Batched mount. | ||
2626 | * | ||
2627 | * @param {ReactComponent} componentInstance The instance to mount. | ||
2628 | * @param {string} rootID DOM ID of the root node. | ||
2629 | * @param {DOMElement} container DOM element to mount into. | ||
2630 | * @param {boolean} shouldReuseMarkup If true, do not insert markup | ||
2631 | */ | ||
2632 | function batchedMountComponentIntoNode(componentInstance, rootID, container, shouldReuseMarkup, context) { | ||
2633 | var transaction = ReactUpdates.ReactReconcileTransaction.getPooled( | ||
2634 | /* forceHTML */shouldReuseMarkup); | ||
2635 | transaction.perform(mountComponentIntoNode, null, componentInstance, rootID, container, transaction, shouldReuseMarkup, context); | ||
2636 | ReactUpdates.ReactReconcileTransaction.release(transaction); | ||
2637 | } | ||
2638 | |||
2639 | /** | ||
2640 | * Unmounts a component and removes it from the DOM. | ||
2641 | * | ||
2642 | * @param {ReactComponent} instance React component instance. | ||
2643 | * @param {DOMElement} container DOM element to unmount from. | ||
2644 | * @final | ||
2645 | * @internal | ||
2646 | * @see {ReactMount.unmountComponentAtNode} | ||
2647 | */ | ||
2648 | function unmountComponentFromNode(instance, container) { | ||
2649 | ReactReconciler.unmountComponent(instance); | ||
2650 | |||
2651 | if (container.nodeType === DOC_NODE_TYPE) { | ||
2652 | container = container.documentElement; | ||
2653 | } | ||
2654 | |||
2655 | // http://jsperf.com/emptying-a-node | ||
2656 | while (container.lastChild) { | ||
2657 | container.removeChild(container.lastChild); | ||
2658 | } | ||
2659 | } | ||
2660 | |||
2661 | /** | ||
2662 | * True if the supplied DOM node has a direct React-rendered child that is | ||
2663 | * not a React root element. Useful for warning in `render`, | ||
2664 | * `unmountComponentAtNode`, etc. | ||
2665 | * | ||
2666 | * @param {?DOMElement} node The candidate DOM node. | ||
2667 | * @return {boolean} True if the DOM element contains a direct child that was | ||
2668 | * rendered by React but is not a root element. | ||
2669 | * @internal | ||
2670 | */ | ||
2671 | function hasNonRootReactChild(node) { | ||
2672 | var reactRootID = getReactRootID(node); | ||
2673 | return reactRootID ? reactRootID !== ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID) : false; | ||
2674 | } | ||
2675 | |||
2676 | /** | ||
2677 | * Returns the first (deepest) ancestor of a node which is rendered by this copy | ||
2678 | * of React. | ||
2679 | */ | ||
2680 | function findFirstReactDOMImpl(node) { | ||
2681 | // This node might be from another React instance, so we make sure not to | ||
2682 | // examine the node cache here | ||
2683 | for (; node && node.parentNode !== node; node = node.parentNode) { | ||
2684 | if (node.nodeType !== 1) { | ||
2685 | // Not a DOMElement, therefore not a React component | ||
2686 | continue; | ||
2687 | } | ||
2688 | var nodeID = internalGetID(node); | ||
2689 | if (!nodeID) { | ||
2690 | continue; | ||
2691 | } | ||
2692 | var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID); | ||
2693 | |||
2694 | // If containersByReactRootID contains the container we find by crawling up | ||
2695 | // the tree, we know that this instance of React rendered the node. | ||
2696 | // nb. isValid's strategy (with containsNode) does not work because render | ||
2697 | // trees may be nested and we don't want a false positive in that case. | ||
2698 | var current = node; | ||
2699 | var lastID; | ||
2700 | do { | ||
2701 | lastID = internalGetID(current); | ||
2702 | current = current.parentNode; | ||
2703 | if (current == null) { | ||
2704 | // The passed-in node has been detached from the container it was | ||
2705 | // originally rendered into. | ||
2706 | return null; | ||
2707 | } | ||
2708 | } while (lastID !== reactRootID); | ||
2709 | |||
2710 | if (current === containersByReactRootID[reactRootID]) { | ||
2711 | return node; | ||
2712 | } | ||
2713 | } | ||
2714 | return null; | ||
2715 | } | ||
2716 | |||
2717 | /** | ||
2718 | * Temporary (?) hack so that we can store all top-level pending updates on | ||
2719 | * composites instead of having to worry about different types of components | ||
2720 | * here. | ||
2721 | */ | ||
2722 | var TopLevelWrapper = function () {}; | ||
2723 | TopLevelWrapper.prototype.isReactComponent = {}; | ||
2724 | if (process.env.NODE_ENV !== 'production') { | ||
2725 | TopLevelWrapper.displayName = 'TopLevelWrapper'; | ||
2726 | } | ||
2727 | TopLevelWrapper.prototype.render = function () { | ||
2728 | // this.props is actually a ReactElement | ||
2729 | return this.props; | ||
2730 | }; | ||
2731 | |||
2732 | /** | ||
2733 | * Mounting is the process of initializing a React component by creating its | ||
2734 | * representative DOM elements and inserting them into a supplied `container`. | ||
2735 | * Any prior content inside `container` is destroyed in the process. | ||
2736 | * | ||
2737 | * ReactMount.render( | ||
2738 | * component, | ||
2739 | * document.getElementById('container') | ||
2740 | * ); | ||
2741 | * | ||
2742 | * <div id="container"> <-- Supplied `container`. | ||
2743 | * <div data-reactid=".3"> <-- Rendered reactRoot of React | ||
2744 | * // ... component. | ||
2745 | * </div> | ||
2746 | * </div> | ||
2747 | * | ||
2748 | * Inside of `container`, the first element rendered is the "reactRoot". | ||
2749 | */ | ||
2750 | var ReactMount = { | ||
2751 | |||
2752 | TopLevelWrapper: TopLevelWrapper, | ||
2753 | |||
2754 | /** Exposed for debugging purposes **/ | ||
2755 | _instancesByReactRootID: instancesByReactRootID, | ||
2756 | |||
2757 | /** | ||
2758 | * This is a hook provided to support rendering React components while | ||
2759 | * ensuring that the apparent scroll position of its `container` does not | ||
2760 | * change. | ||
2761 | * | ||
2762 | * @param {DOMElement} container The `container` being rendered into. | ||
2763 | * @param {function} renderCallback This must be called once to do the render. | ||
2764 | */ | ||
2765 | scrollMonitor: function (container, renderCallback) { | ||
2766 | renderCallback(); | ||
2767 | }, | ||
2768 | |||
2769 | /** | ||
2770 | * Take a component that's already mounted into the DOM and replace its props | ||
2771 | * @param {ReactComponent} prevComponent component instance already in the DOM | ||
2772 | * @param {ReactElement} nextElement component instance to render | ||
2773 | * @param {DOMElement} container container to render into | ||
2774 | * @param {?function} callback function triggered on completion | ||
2775 | */ | ||
2776 | _updateRootComponent: function (prevComponent, nextElement, container, callback) { | ||
2777 | ReactMount.scrollMonitor(container, function () { | ||
2778 | ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement); | ||
2779 | if (callback) { | ||
2780 | ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback); | ||
2781 | } | ||
2782 | }); | ||
2783 | |||
2784 | if (process.env.NODE_ENV !== 'production') { | ||
2785 | // Record the root element in case it later gets transplanted. | ||
2786 | rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container); | ||
2787 | } | ||
2788 | |||
2789 | return prevComponent; | ||
2790 | }, | ||
2791 | |||
2792 | /** | ||
2793 | * Register a component into the instance map and starts scroll value | ||
2794 | * monitoring | ||
2795 | * @param {ReactComponent} nextComponent component instance to render | ||
2796 | * @param {DOMElement} container container to render into | ||
2797 | * @return {string} reactRoot ID prefix | ||
2798 | */ | ||
2799 | _registerComponent: function (nextComponent, container) { | ||
2800 | !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined; | ||
2801 | |||
2802 | ReactBrowserEventEmitter.ensureScrollValueMonitoring(); | ||
2803 | |||
2804 | var reactRootID = ReactMount.registerContainer(container); | ||
2805 | instancesByReactRootID[reactRootID] = nextComponent; | ||
2806 | return reactRootID; | ||
2807 | }, | ||
2808 | |||
2809 | /** | ||
2810 | * Render a new component into the DOM. | ||
2811 | * @param {ReactElement} nextElement element to render | ||
2812 | * @param {DOMElement} container container to render into | ||
2813 | * @param {boolean} shouldReuseMarkup if we should skip the markup insertion | ||
2814 | * @return {ReactComponent} nextComponent | ||
2815 | */ | ||
2816 | _renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) { | ||
2817 | // Various parts of our code (such as ReactCompositeComponent's | ||
2818 | // _renderValidatedComponent) assume that calls to render aren't nested; | ||
2819 | // verify that that's the case. | ||
2820 | process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined; | ||
2821 | |||
2822 | var componentInstance = instantiateReactComponent(nextElement, null); | ||
2823 | var reactRootID = ReactMount._registerComponent(componentInstance, container); | ||
2824 | |||
2825 | // The initial render is synchronous but any updates that happen during | ||
2826 | // rendering, in componentWillMount or componentDidMount, will be batched | ||
2827 | // according to the current batching strategy. | ||
2828 | |||
2829 | ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context); | ||
2830 | |||
2831 | if (process.env.NODE_ENV !== 'production') { | ||
2832 | // Record the root element in case it later gets transplanted. | ||
2833 | rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container); | ||
2834 | } | ||
2835 | |||
2836 | return componentInstance; | ||
2837 | }, | ||
2838 | |||
2839 | /** | ||
2840 | * Renders a React component into the DOM in the supplied `container`. | ||
2841 | * | ||
2842 | * If the React component was previously rendered into `container`, this will | ||
2843 | * perform an update on it and only mutate the DOM as necessary to reflect the | ||
2844 | * latest React component. | ||
2845 | * | ||
2846 | * @param {ReactComponent} parentComponent The conceptual parent of this render tree. | ||
2847 | * @param {ReactElement} nextElement Component element to render. | ||
2848 | * @param {DOMElement} container DOM element to render into. | ||
2849 | * @param {?function} callback function triggered on completion | ||
2850 | * @return {ReactComponent} Component instance rendered in `container`. | ||
2851 | */ | ||
2852 | renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) { | ||
2853 | !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined; | ||
2854 | return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback); | ||
2855 | }, | ||
2856 | |||
2857 | _renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) { | ||
2858 | !ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing an element string, make sure to instantiate ' + 'it by passing it to React.createElement.' : typeof nextElement === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : | ||
2859 | // Check if it quacks like an element | ||
2860 | nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined; | ||
2861 | |||
2862 | process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : undefined; | ||
2863 | |||
2864 | var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement); | ||
2865 | |||
2866 | var prevComponent = instancesByReactRootID[getReactRootID(container)]; | ||
2867 | |||
2868 | if (prevComponent) { | ||
2869 | var prevWrappedElement = prevComponent._currentElement; | ||
2870 | var prevElement = prevWrappedElement.props; | ||
2871 | if (shouldUpdateReactComponent(prevElement, nextElement)) { | ||
2872 | var publicInst = prevComponent._renderedComponent.getPublicInstance(); | ||
2873 | var updatedCallback = callback && function () { | ||
2874 | callback.call(publicInst); | ||
2875 | }; | ||
2876 | ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, updatedCallback); | ||
2877 | return publicInst; | ||
2878 | } else { | ||
2879 | ReactMount.unmountComponentAtNode(container); | ||
2880 | } | ||
2881 | } | ||
2882 | |||
2883 | var reactRootElement = getReactRootElementInContainer(container); | ||
2884 | var containerHasReactMarkup = reactRootElement && !!internalGetID(reactRootElement); | ||
2885 | var containerHasNonRootReactChild = hasNonRootReactChild(container); | ||
2886 | |||
2887 | if (process.env.NODE_ENV !== 'production') { | ||
2888 | process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : undefined; | ||
2889 | |||
2890 | if (!containerHasReactMarkup || reactRootElement.nextSibling) { | ||
2891 | var rootElementSibling = reactRootElement; | ||
2892 | while (rootElementSibling) { | ||
2893 | if (internalGetID(rootElementSibling)) { | ||
2894 | process.env.NODE_ENV !== 'production' ? warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.') : undefined; | ||
2895 | break; | ||
2896 | } | ||
2897 | rootElementSibling = rootElementSibling.nextSibling; | ||
2898 | } | ||
2899 | } | ||
2900 | } | ||
2901 | |||
2902 | var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild; | ||
2903 | var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject)._renderedComponent.getPublicInstance(); | ||
2904 | if (callback) { | ||
2905 | callback.call(component); | ||
2906 | } | ||
2907 | return component; | ||
2908 | }, | ||
2909 | |||
2910 | /** | ||
2911 | * Renders a React component into the DOM in the supplied `container`. | ||
2912 | * | ||
2913 | * If the React component was previously rendered into `container`, this will | ||
2914 | * perform an update on it and only mutate the DOM as necessary to reflect the | ||
2915 | * latest React component. | ||
2916 | * | ||
2917 | * @param {ReactElement} nextElement Component element to render. | ||
2918 | * @param {DOMElement} container DOM element to render into. | ||
2919 | * @param {?function} callback function triggered on completion | ||
2920 | * @return {ReactComponent} Component instance rendered in `container`. | ||
2921 | */ | ||
2922 | render: function (nextElement, container, callback) { | ||
2923 | return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback); | ||
2924 | }, | ||
2925 | |||
2926 | /** | ||
2927 | * Registers a container node into which React components will be rendered. | ||
2928 | * This also creates the "reactRoot" ID that will be assigned to the element | ||
2929 | * rendered within. | ||
2930 | * | ||
2931 | * @param {DOMElement} container DOM element to register as a container. | ||
2932 | * @return {string} The "reactRoot" ID of elements rendered within. | ||
2933 | */ | ||
2934 | registerContainer: function (container) { | ||
2935 | var reactRootID = getReactRootID(container); | ||
2936 | if (reactRootID) { | ||
2937 | // If one exists, make sure it is a valid "reactRoot" ID. | ||
2938 | reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID); | ||
2939 | } | ||
2940 | if (!reactRootID) { | ||
2941 | // No valid "reactRoot" ID found, create one. | ||
2942 | reactRootID = ReactInstanceHandles.createReactRootID(); | ||
2943 | } | ||
2944 | containersByReactRootID[reactRootID] = container; | ||
2945 | return reactRootID; | ||
2946 | }, | ||
2947 | |||
2948 | /** | ||
2949 | * Unmounts and destroys the React component rendered in the `container`. | ||
2950 | * | ||
2951 | * @param {DOMElement} container DOM element containing a React component. | ||
2952 | * @return {boolean} True if a component was found in and unmounted from | ||
2953 | * `container` | ||
2954 | */ | ||
2955 | unmountComponentAtNode: function (container) { | ||
2956 | // Various parts of our code (such as ReactCompositeComponent's | ||
2957 | // _renderValidatedComponent) assume that calls to render aren't nested; | ||
2958 | // verify that that's the case. (Strictly speaking, unmounting won't cause a | ||
2959 | // render but we still don't expect to be in a render call here.) | ||
2960 | process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined; | ||
2961 | |||
2962 | !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined; | ||
2963 | |||
2964 | var reactRootID = getReactRootID(container); | ||
2965 | var component = instancesByReactRootID[reactRootID]; | ||
2966 | if (!component) { | ||
2967 | // Check if the node being unmounted was rendered by React, but isn't a | ||
2968 | // root node. | ||
2969 | var containerHasNonRootReactChild = hasNonRootReactChild(container); | ||
2970 | |||
2971 | // Check if the container itself is a React root node. | ||
2972 | var containerID = internalGetID(container); | ||
2973 | var isContainerReactRoot = containerID && containerID === ReactInstanceHandles.getReactRootIDFromNodeID(containerID); | ||
2974 | |||
2975 | if (process.env.NODE_ENV !== 'production') { | ||
2976 | process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : undefined; | ||
2977 | } | ||
2978 | |||
2979 | return false; | ||
2980 | } | ||
2981 | ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container); | ||
2982 | delete instancesByReactRootID[reactRootID]; | ||
2983 | delete containersByReactRootID[reactRootID]; | ||
2984 | if (process.env.NODE_ENV !== 'production') { | ||
2985 | delete rootElementsByReactRootID[reactRootID]; | ||
2986 | } | ||
2987 | return true; | ||
2988 | }, | ||
2989 | |||
2990 | /** | ||
2991 | * Finds the container DOM element that contains React component to which the | ||
2992 | * supplied DOM `id` belongs. | ||
2993 | * | ||
2994 | * @param {string} id The ID of an element rendered by a React component. | ||
2995 | * @return {?DOMElement} DOM element that contains the `id`. | ||
2996 | */ | ||
2997 | findReactContainerForID: function (id) { | ||
2998 | var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id); | ||
2999 | var container = containersByReactRootID[reactRootID]; | ||
3000 | |||
3001 | if (process.env.NODE_ENV !== 'production') { | ||
3002 | var rootElement = rootElementsByReactRootID[reactRootID]; | ||
3003 | if (rootElement && rootElement.parentNode !== container) { | ||
3004 | process.env.NODE_ENV !== 'production' ? warning( | ||
3005 | // Call internalGetID here because getID calls isValid which calls | ||
3006 | // findReactContainerForID (this function). | ||
3007 | internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : undefined; | ||
3008 | var containerChild = container.firstChild; | ||
3009 | if (containerChild && reactRootID === internalGetID(containerChild)) { | ||
3010 | // If the container has a new child with the same ID as the old | ||
3011 | // root element, then rootElementsByReactRootID[reactRootID] is | ||
3012 | // just stale and needs to be updated. The case that deserves a | ||
3013 | // warning is when the container is empty. | ||
3014 | rootElementsByReactRootID[reactRootID] = containerChild; | ||
3015 | } else { | ||
3016 | process.env.NODE_ENV !== 'production' ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined; | ||
3017 | } | ||
3018 | } | ||
3019 | } | ||
3020 | |||
3021 | return container; | ||
3022 | }, | ||
3023 | |||
3024 | /** | ||
3025 | * Finds an element rendered by React with the supplied ID. | ||
3026 | * | ||
3027 | * @param {string} id ID of a DOM node in the React component. | ||
3028 | * @return {DOMElement} Root DOM node of the React component. | ||
3029 | */ | ||
3030 | findReactNodeByID: function (id) { | ||
3031 | var reactRoot = ReactMount.findReactContainerForID(id); | ||
3032 | return ReactMount.findComponentRoot(reactRoot, id); | ||
3033 | }, | ||
3034 | |||
3035 | /** | ||
3036 | * Traverses up the ancestors of the supplied node to find a node that is a | ||
3037 | * DOM representation of a React component rendered by this copy of React. | ||
3038 | * | ||
3039 | * @param {*} node | ||
3040 | * @return {?DOMEventTarget} | ||
3041 | * @internal | ||
3042 | */ | ||
3043 | getFirstReactDOM: function (node) { | ||
3044 | return findFirstReactDOMImpl(node); | ||
3045 | }, | ||
3046 | |||
3047 | /** | ||
3048 | * Finds a node with the supplied `targetID` inside of the supplied | ||
3049 | * `ancestorNode`. Exploits the ID naming scheme to perform the search | ||
3050 | * quickly. | ||
3051 | * | ||
3052 | * @param {DOMEventTarget} ancestorNode Search from this root. | ||
3053 | * @pararm {string} targetID ID of the DOM representation of the component. | ||
3054 | * @return {DOMEventTarget} DOM node with the supplied `targetID`. | ||
3055 | * @internal | ||
3056 | */ | ||
3057 | findComponentRoot: function (ancestorNode, targetID) { | ||
3058 | var firstChildren = findComponentRootReusableArray; | ||
3059 | var childIndex = 0; | ||
3060 | |||
3061 | var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode; | ||
3062 | |||
3063 | if (process.env.NODE_ENV !== 'production') { | ||
3064 | // This will throw on the next line; give an early warning | ||
3065 | process.env.NODE_ENV !== 'production' ? warning(deepestAncestor != null, 'React can\'t find the root component node for data-reactid value ' + '`%s`. If you\'re seeing this message, it probably means that ' + 'you\'ve loaded two copies of React on the page. At this time, only ' + 'a single copy of React can be loaded at a time.', targetID) : undefined; | ||
3066 | } | ||
3067 | |||
3068 | firstChildren[0] = deepestAncestor.firstChild; | ||
3069 | firstChildren.length = 1; | ||
3070 | |||
3071 | while (childIndex < firstChildren.length) { | ||
3072 | var child = firstChildren[childIndex++]; | ||
3073 | var targetChild; | ||
3074 | |||
3075 | while (child) { | ||
3076 | var childID = ReactMount.getID(child); | ||
3077 | if (childID) { | ||
3078 | // Even if we find the node we're looking for, we finish looping | ||
3079 | // through its siblings to ensure they're cached so that we don't have | ||
3080 | // to revisit this node again. Otherwise, we make n^2 calls to getID | ||
3081 | // when visiting the many children of a single node in order. | ||
3082 | |||
3083 | if (targetID === childID) { | ||
3084 | targetChild = child; | ||
3085 | } else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) { | ||
3086 | // If we find a child whose ID is an ancestor of the given ID, | ||
3087 | // then we can be sure that we only want to search the subtree | ||
3088 | // rooted at this child, so we can throw out the rest of the | ||
3089 | // search state. | ||
3090 | firstChildren.length = childIndex = 0; | ||
3091 | firstChildren.push(child.firstChild); | ||
3092 | } | ||
3093 | } else { | ||
3094 | // If this child had no ID, then there's a chance that it was | ||
3095 | // injected automatically by the browser, as when a `<table>` | ||
3096 | // element sprouts an extra `<tbody>` child as a side effect of | ||
3097 | // `.innerHTML` parsing. Optimistically continue down this | ||
3098 | // branch, but not before examining the other siblings. | ||
3099 | firstChildren.push(child.firstChild); | ||
3100 | } | ||
3101 | |||
3102 | child = child.nextSibling; | ||
3103 | } | ||
3104 | |||
3105 | if (targetChild) { | ||
3106 | // Emptying firstChildren/findComponentRootReusableArray is | ||
3107 | // not necessary for correctness, but it helps the GC reclaim | ||
3108 | // any nodes that were left at the end of the search. | ||
3109 | firstChildren.length = 0; | ||
3110 | |||
3111 | return targetChild; | ||
3112 | } | ||
3113 | } | ||
3114 | |||
3115 | firstChildren.length = 0; | ||
3116 | |||
3117 | true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findComponentRoot(..., %s): Unable to find element. This probably ' + 'means the DOM was unexpectedly mutated (e.g., by the browser), ' + 'usually due to forgetting a <tbody> when using tables, nesting tags ' + 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' + 'parent. ' + 'Try inspecting the child nodes of the element with React ID `%s`.', targetID, ReactMount.getID(ancestorNode)) : invariant(false) : undefined; | ||
3118 | }, | ||
3119 | |||
3120 | _mountImageIntoNode: function (markup, container, shouldReuseMarkup, transaction) { | ||
3121 | !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined; | ||
3122 | |||
3123 | if (shouldReuseMarkup) { | ||
3124 | var rootElement = getReactRootElementInContainer(container); | ||
3125 | if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) { | ||
3126 | return; | ||
3127 | } else { | ||
3128 | var checksum = rootElement.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME); | ||
3129 | rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME); | ||
3130 | |||
3131 | var rootMarkup = rootElement.outerHTML; | ||
3132 | rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum); | ||
3133 | |||
3134 | var normalizedMarkup = markup; | ||
3135 | if (process.env.NODE_ENV !== 'production') { | ||
3136 | // because rootMarkup is retrieved from the DOM, various normalizations | ||
3137 | // will have occurred which will not be present in `markup`. Here, | ||
3138 | // insert markup into a <div> or <iframe> depending on the container | ||
3139 | // type to perform the same normalizations before comparing. | ||
3140 | var normalizer; | ||
3141 | if (container.nodeType === ELEMENT_NODE_TYPE) { | ||
3142 | normalizer = document.createElement('div'); | ||
3143 | normalizer.innerHTML = markup; | ||
3144 | normalizedMarkup = normalizer.innerHTML; | ||
3145 | } else { | ||
3146 | normalizer = document.createElement('iframe'); | ||
3147 | document.body.appendChild(normalizer); | ||
3148 | normalizer.contentDocument.write(markup); | ||
3149 | normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML; | ||
3150 | document.body.removeChild(normalizer); | ||
3151 | } | ||
3152 | } | ||
3153 | |||
3154 | var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup); | ||
3155 | var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20); | ||
3156 | |||
3157 | !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference) : invariant(false) : undefined; | ||
3158 | |||
3159 | if (process.env.NODE_ENV !== 'production') { | ||
3160 | process.env.NODE_ENV !== 'production' ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : undefined; | ||
3161 | } | ||
3162 | } | ||
3163 | } | ||
3164 | |||
3165 | !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined; | ||
3166 | |||
3167 | if (transaction.useCreateElement) { | ||
3168 | while (container.lastChild) { | ||
3169 | container.removeChild(container.lastChild); | ||
3170 | } | ||
3171 | container.appendChild(markup); | ||
3172 | } else { | ||
3173 | setInnerHTML(container, markup); | ||
3174 | } | ||
3175 | }, | ||
3176 | |||
3177 | ownerDocumentContextKey: ownerDocumentContextKey, | ||
3178 | |||
3179 | /** | ||
3180 | * React ID utilities. | ||
3181 | */ | ||
3182 | |||
3183 | getReactRootID: getReactRootID, | ||
3184 | |||
3185 | getID: getID, | ||
3186 | |||
3187 | setID: setID, | ||
3188 | |||
3189 | getNode: getNode, | ||
3190 | |||
3191 | getNodeFromInstance: getNodeFromInstance, | ||
3192 | |||
3193 | isValid: isValid, | ||
3194 | |||
3195 | purgeID: purgeID | ||
3196 | }; | ||
3197 | |||
3198 | ReactPerf.measureMethods(ReactMount, 'ReactMount', { | ||
3199 | _renderNewRootComponent: '_renderNewRootComponent', | ||
3200 | _mountImageIntoNode: '_mountImageIntoNode' | ||
3201 | }); | ||
3202 | |||
3203 | module.exports = ReactMount; | ||
3204 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
3205 | |||
3206 | /***/ }, | ||
3207 | /* 31 */ | ||
3208 | /***/ function(module, exports, __webpack_require__) { | ||
3209 | |||
3210 | /** | ||
3211 | * Copyright 2013-2015, Facebook, Inc. | ||
3212 | * All rights reserved. | ||
3213 | * | ||
3214 | * This source code is licensed under the BSD-style license found in the | ||
3215 | * LICENSE file in the root directory of this source tree. An additional grant | ||
3216 | * of patent rights can be found in the PATENTS file in the same directory. | ||
3217 | * | ||
3218 | * @providesModule ReactBrowserEventEmitter | ||
3219 | * @typechecks static-only | ||
3220 | */ | ||
3221 | |||
3222 | 'use strict'; | ||
3223 | |||
3224 | var EventConstants = __webpack_require__(32); | ||
3225 | var EventPluginHub = __webpack_require__(33); | ||
3226 | var EventPluginRegistry = __webpack_require__(34); | ||
3227 | var ReactEventEmitterMixin = __webpack_require__(39); | ||
3228 | var ReactPerf = __webpack_require__(20); | ||
3229 | var ViewportMetrics = __webpack_require__(40); | ||
3230 | |||
3231 | var assign = __webpack_require__(41); | ||
3232 | var isEventSupported = __webpack_require__(42); | ||
3233 | |||
3234 | /** | ||
3235 | * Summary of `ReactBrowserEventEmitter` event handling: | ||
3236 | * | ||
3237 | * - Top-level delegation is used to trap most native browser events. This | ||
3238 | * may only occur in the main thread and is the responsibility of | ||
3239 | * ReactEventListener, which is injected and can therefore support pluggable | ||
3240 | * event sources. This is the only work that occurs in the main thread. | ||
3241 | * | ||
3242 | * - We normalize and de-duplicate events to account for browser quirks. This | ||
3243 | * may be done in the worker thread. | ||
3244 | * | ||
3245 | * - Forward these native events (with the associated top-level type used to | ||
3246 | * trap it) to `EventPluginHub`, which in turn will ask plugins if they want | ||
3247 | * to extract any synthetic events. | ||
3248 | * | ||
3249 | * - The `EventPluginHub` will then process each event by annotating them with | ||
3250 | * "dispatches", a sequence of listeners and IDs that care about that event. | ||
3251 | * | ||
3252 | * - The `EventPluginHub` then dispatches the events. | ||
3253 | * | ||
3254 | * Overview of React and the event system: | ||
3255 | * | ||
3256 | * +------------+ . | ||
3257 | * | DOM | . | ||
3258 | * +------------+ . | ||
3259 | * | . | ||
3260 | * v . | ||
3261 | * +------------+ . | ||
3262 | * | ReactEvent | . | ||
3263 | * | Listener | . | ||
3264 | * +------------+ . +-----------+ | ||
3265 | * | . +--------+|SimpleEvent| | ||
3266 | * | . | |Plugin | | ||
3267 | * +-----|------+ . v +-----------+ | ||
3268 | * | | | . +--------------+ +------------+ | ||
3269 | * | +-----------.--->|EventPluginHub| | Event | | ||
3270 | * | | . | | +-----------+ | Propagators| | ||
3271 | * | ReactEvent | . | | |TapEvent | |------------| | ||
3272 | * | Emitter | . | |<---+|Plugin | |other plugin| | ||
3273 | * | | . | | +-----------+ | utilities | | ||
3274 | * | +-----------.--->| | +------------+ | ||
3275 | * | | | . +--------------+ | ||
3276 | * +-----|------+ . ^ +-----------+ | ||
3277 | * | . | |Enter/Leave| | ||
3278 | * + . +-------+|Plugin | | ||
3279 | * +-------------+ . +-----------+ | ||
3280 | * | application | . | ||
3281 | * |-------------| . | ||
3282 | * | | . | ||
3283 | * | | . | ||
3284 | * +-------------+ . | ||
3285 | * . | ||
3286 | * React Core . General Purpose Event Plugin System | ||
3287 | */ | ||
3288 | |||
3289 | var alreadyListeningTo = {}; | ||
3290 | var isMonitoringScrollValue = false; | ||
3291 | var reactTopListenersCounter = 0; | ||
3292 | |||
3293 | // For events like 'submit' which don't consistently bubble (which we trap at a | ||
3294 | // lower node than `document`), binding at `document` would cause duplicate | ||
3295 | // events so we don't include them here | ||
3296 | var topEventMapping = { | ||
3297 | topAbort: 'abort', | ||
3298 | topBlur: 'blur', | ||
3299 | topCanPlay: 'canplay', | ||
3300 | topCanPlayThrough: 'canplaythrough', | ||
3301 | topChange: 'change', | ||
3302 | topClick: 'click', | ||
3303 | topCompositionEnd: 'compositionend', | ||
3304 | topCompositionStart: 'compositionstart', | ||
3305 | topCompositionUpdate: 'compositionupdate', | ||
3306 | topContextMenu: 'contextmenu', | ||
3307 | topCopy: 'copy', | ||
3308 | topCut: 'cut', | ||
3309 | topDoubleClick: 'dblclick', | ||
3310 | topDrag: 'drag', | ||
3311 | topDragEnd: 'dragend', | ||
3312 | topDragEnter: 'dragenter', | ||
3313 | topDragExit: 'dragexit', | ||
3314 | topDragLeave: 'dragleave', | ||
3315 | topDragOver: 'dragover', | ||
3316 | topDragStart: 'dragstart', | ||
3317 | topDrop: 'drop', | ||
3318 | topDurationChange: 'durationchange', | ||
3319 | topEmptied: 'emptied', | ||
3320 | topEncrypted: 'encrypted', | ||
3321 | topEnded: 'ended', | ||
3322 | topError: 'error', | ||
3323 | topFocus: 'focus', | ||
3324 | topInput: 'input', | ||
3325 | topKeyDown: 'keydown', | ||
3326 | topKeyPress: 'keypress', | ||
3327 | topKeyUp: 'keyup', | ||
3328 | topLoadedData: 'loadeddata', | ||
3329 | topLoadedMetadata: 'loadedmetadata', | ||
3330 | topLoadStart: 'loadstart', | ||
3331 | topMouseDown: 'mousedown', | ||
3332 | topMouseMove: 'mousemove', | ||
3333 | topMouseOut: 'mouseout', | ||
3334 | topMouseOver: 'mouseover', | ||
3335 | topMouseUp: 'mouseup', | ||
3336 | topPaste: 'paste', | ||
3337 | topPause: 'pause', | ||
3338 | topPlay: 'play', | ||
3339 | topPlaying: 'playing', | ||
3340 | topProgress: 'progress', | ||
3341 | topRateChange: 'ratechange', | ||
3342 | topScroll: 'scroll', | ||
3343 | topSeeked: 'seeked', | ||
3344 | topSeeking: 'seeking', | ||
3345 | topSelectionChange: 'selectionchange', | ||
3346 | topStalled: 'stalled', | ||
3347 | topSuspend: 'suspend', | ||
3348 | topTextInput: 'textInput', | ||
3349 | topTimeUpdate: 'timeupdate', | ||
3350 | topTouchCancel: 'touchcancel', | ||
3351 | topTouchEnd: 'touchend', | ||
3352 | topTouchMove: 'touchmove', | ||
3353 | topTouchStart: 'touchstart', | ||
3354 | topVolumeChange: 'volumechange', | ||
3355 | topWaiting: 'waiting', | ||
3356 | topWheel: 'wheel' | ||
3357 | }; | ||
3358 | |||
3359 | /** | ||
3360 | * To ensure no conflicts with other potential React instances on the page | ||
3361 | */ | ||
3362 | var topListenersIDKey = '_reactListenersID' + String(Math.random()).slice(2); | ||
3363 | |||
3364 | function getListeningForDocument(mountAt) { | ||
3365 | // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` | ||
3366 | // directly. | ||
3367 | if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { | ||
3368 | mountAt[topListenersIDKey] = reactTopListenersCounter++; | ||
3369 | alreadyListeningTo[mountAt[topListenersIDKey]] = {}; | ||
3370 | } | ||
3371 | return alreadyListeningTo[mountAt[topListenersIDKey]]; | ||
3372 | } | ||
3373 | |||
3374 | /** | ||
3375 | * `ReactBrowserEventEmitter` is used to attach top-level event listeners. For | ||
3376 | * example: | ||
3377 | * | ||
3378 | * ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction); | ||
3379 | * | ||
3380 | * This would allocate a "registration" of `('onClick', myFunction)` on 'myID'. | ||
3381 | * | ||
3382 | * @internal | ||
3383 | */ | ||
3384 | var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, { | ||
3385 | |||
3386 | /** | ||
3387 | * Injectable event backend | ||
3388 | */ | ||
3389 | ReactEventListener: null, | ||
3390 | |||
3391 | injection: { | ||
3392 | /** | ||
3393 | * @param {object} ReactEventListener | ||
3394 | */ | ||
3395 | injectReactEventListener: function (ReactEventListener) { | ||
3396 | ReactEventListener.setHandleTopLevel(ReactBrowserEventEmitter.handleTopLevel); | ||
3397 | ReactBrowserEventEmitter.ReactEventListener = ReactEventListener; | ||
3398 | } | ||
3399 | }, | ||
3400 | |||
3401 | /** | ||
3402 | * Sets whether or not any created callbacks should be enabled. | ||
3403 | * | ||
3404 | * @param {boolean} enabled True if callbacks should be enabled. | ||
3405 | */ | ||
3406 | setEnabled: function (enabled) { | ||
3407 | if (ReactBrowserEventEmitter.ReactEventListener) { | ||
3408 | ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled); | ||
3409 | } | ||
3410 | }, | ||
3411 | |||
3412 | /** | ||
3413 | * @return {boolean} True if callbacks are enabled. | ||
3414 | */ | ||
3415 | isEnabled: function () { | ||
3416 | return !!(ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled()); | ||
3417 | }, | ||
3418 | |||
3419 | /** | ||
3420 | * We listen for bubbled touch events on the document object. | ||
3421 | * | ||
3422 | * Firefox v8.01 (and possibly others) exhibited strange behavior when | ||
3423 | * mounting `onmousemove` events at some node that was not the document | ||
3424 | * element. The symptoms were that if your mouse is not moving over something | ||
3425 | * contained within that mount point (for example on the background) the | ||
3426 | * top-level listeners for `onmousemove` won't be called. However, if you | ||
3427 | * register the `mousemove` on the document object, then it will of course | ||
3428 | * catch all `mousemove`s. This along with iOS quirks, justifies restricting | ||
3429 | * top-level listeners to the document object only, at least for these | ||
3430 | * movement types of events and possibly all events. | ||
3431 | * | ||
3432 | * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html | ||
3433 | * | ||
3434 | * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but | ||
3435 | * they bubble to document. | ||
3436 | * | ||
3437 | * @param {string} registrationName Name of listener (e.g. `onClick`). | ||
3438 | * @param {object} contentDocumentHandle Document which owns the container | ||
3439 | */ | ||
3440 | listenTo: function (registrationName, contentDocumentHandle) { | ||
3441 | var mountAt = contentDocumentHandle; | ||
3442 | var isListening = getListeningForDocument(mountAt); | ||
3443 | var dependencies = EventPluginRegistry.registrationNameDependencies[registrationName]; | ||
3444 | |||
3445 | var topLevelTypes = EventConstants.topLevelTypes; | ||
3446 | for (var i = 0; i < dependencies.length; i++) { | ||
3447 | var dependency = dependencies[i]; | ||
3448 | if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { | ||
3449 | if (dependency === topLevelTypes.topWheel) { | ||
3450 | if (isEventSupported('wheel')) { | ||
3451 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'wheel', mountAt); | ||
3452 | } else if (isEventSupported('mousewheel')) { | ||
3453 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'mousewheel', mountAt); | ||
3454 | } else { | ||
3455 | // Firefox needs to capture a different mouse scroll event. | ||
3456 | // @see http://www.quirksmode.org/dom/events/tests/scroll.html | ||
3457 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'DOMMouseScroll', mountAt); | ||
3458 | } | ||
3459 | } else if (dependency === topLevelTypes.topScroll) { | ||
3460 | |||
3461 | if (isEventSupported('scroll', true)) { | ||
3462 | ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topScroll, 'scroll', mountAt); | ||
3463 | } else { | ||
3464 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topScroll, 'scroll', ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE); | ||
3465 | } | ||
3466 | } else if (dependency === topLevelTypes.topFocus || dependency === topLevelTypes.topBlur) { | ||
3467 | |||
3468 | if (isEventSupported('focus', true)) { | ||
3469 | ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topFocus, 'focus', mountAt); | ||
3470 | ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topBlur, 'blur', mountAt); | ||
3471 | } else if (isEventSupported('focusin')) { | ||
3472 | // IE has `focusin` and `focusout` events which bubble. | ||
3473 | // @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html | ||
3474 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topFocus, 'focusin', mountAt); | ||
3475 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topBlur, 'focusout', mountAt); | ||
3476 | } | ||
3477 | |||
3478 | // to make sure blur and focus event listeners are only attached once | ||
3479 | isListening[topLevelTypes.topBlur] = true; | ||
3480 | isListening[topLevelTypes.topFocus] = true; | ||
3481 | } else if (topEventMapping.hasOwnProperty(dependency)) { | ||
3482 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(dependency, topEventMapping[dependency], mountAt); | ||
3483 | } | ||
3484 | |||
3485 | isListening[dependency] = true; | ||
3486 | } | ||
3487 | } | ||
3488 | }, | ||
3489 | |||
3490 | trapBubbledEvent: function (topLevelType, handlerBaseName, handle) { | ||
3491 | return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelType, handlerBaseName, handle); | ||
3492 | }, | ||
3493 | |||
3494 | trapCapturedEvent: function (topLevelType, handlerBaseName, handle) { | ||
3495 | return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelType, handlerBaseName, handle); | ||
3496 | }, | ||
3497 | |||
3498 | /** | ||
3499 | * Listens to window scroll and resize events. We cache scroll values so that | ||
3500 | * application code can access them without triggering reflows. | ||
3501 | * | ||
3502 | * NOTE: Scroll events do not bubble. | ||
3503 | * | ||
3504 | * @see http://www.quirksmode.org/dom/events/scroll.html | ||
3505 | */ | ||
3506 | ensureScrollValueMonitoring: function () { | ||
3507 | if (!isMonitoringScrollValue) { | ||
3508 | var refresh = ViewportMetrics.refreshScrollValues; | ||
3509 | ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh); | ||
3510 | isMonitoringScrollValue = true; | ||
3511 | } | ||
3512 | }, | ||
3513 | |||
3514 | eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs, | ||
3515 | |||
3516 | registrationNameModules: EventPluginHub.registrationNameModules, | ||
3517 | |||
3518 | putListener: EventPluginHub.putListener, | ||
3519 | |||
3520 | getListener: EventPluginHub.getListener, | ||
3521 | |||
3522 | deleteListener: EventPluginHub.deleteListener, | ||
3523 | |||
3524 | deleteAllListeners: EventPluginHub.deleteAllListeners | ||
3525 | |||
3526 | }); | ||
3527 | |||
3528 | ReactPerf.measureMethods(ReactBrowserEventEmitter, 'ReactBrowserEventEmitter', { | ||
3529 | putListener: 'putListener', | ||
3530 | deleteListener: 'deleteListener' | ||
3531 | }); | ||
3532 | |||
3533 | module.exports = ReactBrowserEventEmitter; | ||
3534 | |||
3535 | /***/ }, | ||
3536 | /* 32 */ | ||
3537 | /***/ function(module, exports, __webpack_require__) { | ||
3538 | |||
3539 | /** | ||
3540 | * Copyright 2013-2015, Facebook, Inc. | ||
3541 | * All rights reserved. | ||
3542 | * | ||
3543 | * This source code is licensed under the BSD-style license found in the | ||
3544 | * LICENSE file in the root directory of this source tree. An additional grant | ||
3545 | * of patent rights can be found in the PATENTS file in the same directory. | ||
3546 | * | ||
3547 | * @providesModule EventConstants | ||
3548 | */ | ||
3549 | |||
3550 | 'use strict'; | ||
3551 | |||
3552 | var keyMirror = __webpack_require__(19); | ||
3553 | |||
3554 | var PropagationPhases = keyMirror({ bubbled: null, captured: null }); | ||
3555 | |||
3556 | /** | ||
3557 | * Types of raw signals from the browser caught at the top level. | ||
3558 | */ | ||
3559 | var topLevelTypes = keyMirror({ | ||
3560 | topAbort: null, | ||
3561 | topBlur: null, | ||
3562 | topCanPlay: null, | ||
3563 | topCanPlayThrough: null, | ||
3564 | topChange: null, | ||
3565 | topClick: null, | ||
3566 | topCompositionEnd: null, | ||
3567 | topCompositionStart: null, | ||
3568 | topCompositionUpdate: null, | ||
3569 | topContextMenu: null, | ||
3570 | topCopy: null, | ||
3571 | topCut: null, | ||
3572 | topDoubleClick: null, | ||
3573 | topDrag: null, | ||
3574 | topDragEnd: null, | ||
3575 | topDragEnter: null, | ||
3576 | topDragExit: null, | ||
3577 | topDragLeave: null, | ||
3578 | topDragOver: null, | ||
3579 | topDragStart: null, | ||
3580 | topDrop: null, | ||
3581 | topDurationChange: null, | ||
3582 | topEmptied: null, | ||
3583 | topEncrypted: null, | ||
3584 | topEnded: null, | ||
3585 | topError: null, | ||
3586 | topFocus: null, | ||
3587 | topInput: null, | ||
3588 | topKeyDown: null, | ||
3589 | topKeyPress: null, | ||
3590 | topKeyUp: null, | ||
3591 | topLoad: null, | ||
3592 | topLoadedData: null, | ||
3593 | topLoadedMetadata: null, | ||
3594 | topLoadStart: null, | ||
3595 | topMouseDown: null, | ||
3596 | topMouseMove: null, | ||
3597 | topMouseOut: null, | ||
3598 | topMouseOver: null, | ||
3599 | topMouseUp: null, | ||
3600 | topPaste: null, | ||
3601 | topPause: null, | ||
3602 | topPlay: null, | ||
3603 | topPlaying: null, | ||
3604 | topProgress: null, | ||
3605 | topRateChange: null, | ||
3606 | topReset: null, | ||
3607 | topScroll: null, | ||
3608 | topSeeked: null, | ||
3609 | topSeeking: null, | ||
3610 | topSelectionChange: null, | ||
3611 | topStalled: null, | ||
3612 | topSubmit: null, | ||
3613 | topSuspend: null, | ||
3614 | topTextInput: null, | ||
3615 | topTimeUpdate: null, | ||
3616 | topTouchCancel: null, | ||
3617 | topTouchEnd: null, | ||
3618 | topTouchMove: null, | ||
3619 | topTouchStart: null, | ||
3620 | topVolumeChange: null, | ||
3621 | topWaiting: null, | ||
3622 | topWheel: null | ||
3623 | }); | ||
3624 | |||
3625 | var EventConstants = { | ||
3626 | topLevelTypes: topLevelTypes, | ||
3627 | PropagationPhases: PropagationPhases | ||
3628 | }; | ||
3629 | |||
3630 | module.exports = EventConstants; | ||
3631 | |||
3632 | /***/ }, | ||
3633 | /* 33 */ | ||
3634 | /***/ function(module, exports, __webpack_require__) { | ||
3635 | |||
3636 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
3637 | * Copyright 2013-2015, Facebook, Inc. | ||
3638 | * All rights reserved. | ||
3639 | * | ||
3640 | * This source code is licensed under the BSD-style license found in the | ||
3641 | * LICENSE file in the root directory of this source tree. An additional grant | ||
3642 | * of patent rights can be found in the PATENTS file in the same directory. | ||
3643 | * | ||
3644 | * @providesModule EventPluginHub | ||
3645 | */ | ||
3646 | |||
3647 | 'use strict'; | ||
3648 | |||
3649 | var EventPluginRegistry = __webpack_require__(34); | ||
3650 | var EventPluginUtils = __webpack_require__(35); | ||
3651 | var ReactErrorUtils = __webpack_require__(36); | ||
3652 | |||
3653 | var accumulateInto = __webpack_require__(37); | ||
3654 | var forEachAccumulated = __webpack_require__(38); | ||
3655 | var invariant = __webpack_require__(15); | ||
3656 | var warning = __webpack_require__(27); | ||
3657 | |||
3658 | /** | ||
3659 | * Internal store for event listeners | ||
3660 | */ | ||
3661 | var listenerBank = {}; | ||
3662 | |||
3663 | /** | ||
3664 | * Internal queue of events that have accumulated their dispatches and are | ||
3665 | * waiting to have their dispatches executed. | ||
3666 | */ | ||
3667 | var eventQueue = null; | ||
3668 | |||
3669 | /** | ||
3670 | * Dispatches an event and releases it back into the pool, unless persistent. | ||
3671 | * | ||
3672 | * @param {?object} event Synthetic event to be dispatched. | ||
3673 | * @param {boolean} simulated If the event is simulated (changes exn behavior) | ||
3674 | * @private | ||
3675 | */ | ||
3676 | var executeDispatchesAndRelease = function (event, simulated) { | ||
3677 | if (event) { | ||
3678 | EventPluginUtils.executeDispatchesInOrder(event, simulated); | ||
3679 | |||
3680 | if (!event.isPersistent()) { | ||
3681 | event.constructor.release(event); | ||
3682 | } | ||
3683 | } | ||
3684 | }; | ||
3685 | var executeDispatchesAndReleaseSimulated = function (e) { | ||
3686 | return executeDispatchesAndRelease(e, true); | ||
3687 | }; | ||
3688 | var executeDispatchesAndReleaseTopLevel = function (e) { | ||
3689 | return executeDispatchesAndRelease(e, false); | ||
3690 | }; | ||
3691 | |||
3692 | /** | ||
3693 | * - `InstanceHandle`: [required] Module that performs logical traversals of DOM | ||
3694 | * hierarchy given ids of the logical DOM elements involved. | ||
3695 | */ | ||
3696 | var InstanceHandle = null; | ||
3697 | |||
3698 | function validateInstanceHandle() { | ||
3699 | var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave; | ||
3700 | process.env.NODE_ENV !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined; | ||
3701 | } | ||
3702 | |||
3703 | /** | ||
3704 | * This is a unified interface for event plugins to be installed and configured. | ||
3705 | * | ||
3706 | * Event plugins can implement the following properties: | ||
3707 | * | ||
3708 | * `extractEvents` {function(string, DOMEventTarget, string, object): *} | ||
3709 | * Required. When a top-level event is fired, this method is expected to | ||
3710 | * extract synthetic events that will in turn be queued and dispatched. | ||
3711 | * | ||
3712 | * `eventTypes` {object} | ||
3713 | * Optional, plugins that fire events must publish a mapping of registration | ||
3714 | * names that are used to register listeners. Values of this mapping must | ||
3715 | * be objects that contain `registrationName` or `phasedRegistrationNames`. | ||
3716 | * | ||
3717 | * `executeDispatch` {function(object, function, string)} | ||
3718 | * Optional, allows plugins to override how an event gets dispatched. By | ||
3719 | * default, the listener is simply invoked. | ||
3720 | * | ||
3721 | * Each plugin that is injected into `EventsPluginHub` is immediately operable. | ||
3722 | * | ||
3723 | * @public | ||
3724 | */ | ||
3725 | var EventPluginHub = { | ||
3726 | |||
3727 | /** | ||
3728 | * Methods for injecting dependencies. | ||
3729 | */ | ||
3730 | injection: { | ||
3731 | |||
3732 | /** | ||
3733 | * @param {object} InjectedMount | ||
3734 | * @public | ||
3735 | */ | ||
3736 | injectMount: EventPluginUtils.injection.injectMount, | ||
3737 | |||
3738 | /** | ||
3739 | * @param {object} InjectedInstanceHandle | ||
3740 | * @public | ||
3741 | */ | ||
3742 | injectInstanceHandle: function (InjectedInstanceHandle) { | ||
3743 | InstanceHandle = InjectedInstanceHandle; | ||
3744 | if (process.env.NODE_ENV !== 'production') { | ||
3745 | validateInstanceHandle(); | ||
3746 | } | ||
3747 | }, | ||
3748 | |||
3749 | getInstanceHandle: function () { | ||
3750 | if (process.env.NODE_ENV !== 'production') { | ||
3751 | validateInstanceHandle(); | ||
3752 | } | ||
3753 | return InstanceHandle; | ||
3754 | }, | ||
3755 | |||
3756 | /** | ||
3757 | * @param {array} InjectedEventPluginOrder | ||
3758 | * @public | ||
3759 | */ | ||
3760 | injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder, | ||
3761 | |||
3762 | /** | ||
3763 | * @param {object} injectedNamesToPlugins Map from names to plugin modules. | ||
3764 | */ | ||
3765 | injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName | ||
3766 | |||
3767 | }, | ||
3768 | |||
3769 | eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs, | ||
3770 | |||
3771 | registrationNameModules: EventPluginRegistry.registrationNameModules, | ||
3772 | |||
3773 | /** | ||
3774 | * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent. | ||
3775 | * | ||
3776 | * @param {string} id ID of the DOM element. | ||
3777 | * @param {string} registrationName Name of listener (e.g. `onClick`). | ||
3778 | * @param {?function} listener The callback to store. | ||
3779 | */ | ||
3780 | putListener: function (id, registrationName, listener) { | ||
3781 | !(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : undefined; | ||
3782 | |||
3783 | var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {}); | ||
3784 | bankForRegistrationName[id] = listener; | ||
3785 | |||
3786 | var PluginModule = EventPluginRegistry.registrationNameModules[registrationName]; | ||
3787 | if (PluginModule && PluginModule.didPutListener) { | ||
3788 | PluginModule.didPutListener(id, registrationName, listener); | ||
3789 | } | ||
3790 | }, | ||
3791 | |||
3792 | /** | ||
3793 | * @param {string} id ID of the DOM element. | ||
3794 | * @param {string} registrationName Name of listener (e.g. `onClick`). | ||
3795 | * @return {?function} The stored callback. | ||
3796 | */ | ||
3797 | getListener: function (id, registrationName) { | ||
3798 | var bankForRegistrationName = listenerBank[registrationName]; | ||
3799 | return bankForRegistrationName && bankForRegistrationName[id]; | ||
3800 | }, | ||
3801 | |||
3802 | /** | ||
3803 | * Deletes a listener from the registration bank. | ||
3804 | * | ||
3805 | * @param {string} id ID of the DOM element. | ||
3806 | * @param {string} registrationName Name of listener (e.g. `onClick`). | ||
3807 | */ | ||
3808 | deleteListener: function (id, registrationName) { | ||
3809 | var PluginModule = EventPluginRegistry.registrationNameModules[registrationName]; | ||
3810 | if (PluginModule && PluginModule.willDeleteListener) { | ||
3811 | PluginModule.willDeleteListener(id, registrationName); | ||
3812 | } | ||
3813 | |||
3814 | var bankForRegistrationName = listenerBank[registrationName]; | ||
3815 | // TODO: This should never be null -- when is it? | ||
3816 | if (bankForRegistrationName) { | ||
3817 | delete bankForRegistrationName[id]; | ||
3818 | } | ||
3819 | }, | ||
3820 | |||
3821 | /** | ||
3822 | * Deletes all listeners for the DOM element with the supplied ID. | ||
3823 | * | ||
3824 | * @param {string} id ID of the DOM element. | ||
3825 | */ | ||
3826 | deleteAllListeners: function (id) { | ||
3827 | for (var registrationName in listenerBank) { | ||
3828 | if (!listenerBank[registrationName][id]) { | ||
3829 | continue; | ||
3830 | } | ||
3831 | |||
3832 | var PluginModule = EventPluginRegistry.registrationNameModules[registrationName]; | ||
3833 | if (PluginModule && PluginModule.willDeleteListener) { | ||
3834 | PluginModule.willDeleteListener(id, registrationName); | ||
3835 | } | ||
3836 | |||
3837 | delete listenerBank[registrationName][id]; | ||
3838 | } | ||
3839 | }, | ||
3840 | |||
3841 | /** | ||
3842 | * Allows registered plugins an opportunity to extract events from top-level | ||
3843 | * native browser events. | ||
3844 | * | ||
3845 | * @param {string} topLevelType Record from `EventConstants`. | ||
3846 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
3847 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
3848 | * @param {object} nativeEvent Native browser event. | ||
3849 | * @return {*} An accumulation of synthetic events. | ||
3850 | * @internal | ||
3851 | */ | ||
3852 | extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
3853 | var events; | ||
3854 | var plugins = EventPluginRegistry.plugins; | ||
3855 | for (var i = 0; i < plugins.length; i++) { | ||
3856 | // Not every plugin in the ordering may be loaded at runtime. | ||
3857 | var possiblePlugin = plugins[i]; | ||
3858 | if (possiblePlugin) { | ||
3859 | var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget); | ||
3860 | if (extractedEvents) { | ||
3861 | events = accumulateInto(events, extractedEvents); | ||
3862 | } | ||
3863 | } | ||
3864 | } | ||
3865 | return events; | ||
3866 | }, | ||
3867 | |||
3868 | /** | ||
3869 | * Enqueues a synthetic event that should be dispatched when | ||
3870 | * `processEventQueue` is invoked. | ||
3871 | * | ||
3872 | * @param {*} events An accumulation of synthetic events. | ||
3873 | * @internal | ||
3874 | */ | ||
3875 | enqueueEvents: function (events) { | ||
3876 | if (events) { | ||
3877 | eventQueue = accumulateInto(eventQueue, events); | ||
3878 | } | ||
3879 | }, | ||
3880 | |||
3881 | /** | ||
3882 | * Dispatches all synthetic events on the event queue. | ||
3883 | * | ||
3884 | * @internal | ||
3885 | */ | ||
3886 | processEventQueue: function (simulated) { | ||
3887 | // Set `eventQueue` to null before processing it so that we can tell if more | ||
3888 | // events get enqueued while processing. | ||
3889 | var processingEventQueue = eventQueue; | ||
3890 | eventQueue = null; | ||
3891 | if (simulated) { | ||
3892 | forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated); | ||
3893 | } else { | ||
3894 | forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); | ||
3895 | } | ||
3896 | !!eventQueue ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) : undefined; | ||
3897 | // This would be a good time to rethrow if any of the event handlers threw. | ||
3898 | ReactErrorUtils.rethrowCaughtError(); | ||
3899 | }, | ||
3900 | |||
3901 | /** | ||
3902 | * These are needed for tests only. Do not use! | ||
3903 | */ | ||
3904 | __purge: function () { | ||
3905 | listenerBank = {}; | ||
3906 | }, | ||
3907 | |||
3908 | __getListenerBank: function () { | ||
3909 | return listenerBank; | ||
3910 | } | ||
3911 | |||
3912 | }; | ||
3913 | |||
3914 | module.exports = EventPluginHub; | ||
3915 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
3916 | |||
3917 | /***/ }, | ||
3918 | /* 34 */ | ||
3919 | /***/ function(module, exports, __webpack_require__) { | ||
3920 | |||
3921 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
3922 | * Copyright 2013-2015, Facebook, Inc. | ||
3923 | * All rights reserved. | ||
3924 | * | ||
3925 | * This source code is licensed under the BSD-style license found in the | ||
3926 | * LICENSE file in the root directory of this source tree. An additional grant | ||
3927 | * of patent rights can be found in the PATENTS file in the same directory. | ||
3928 | * | ||
3929 | * @providesModule EventPluginRegistry | ||
3930 | * @typechecks static-only | ||
3931 | */ | ||
3932 | |||
3933 | 'use strict'; | ||
3934 | |||
3935 | var invariant = __webpack_require__(15); | ||
3936 | |||
3937 | /** | ||
3938 | * Injectable ordering of event plugins. | ||
3939 | */ | ||
3940 | var EventPluginOrder = null; | ||
3941 | |||
3942 | /** | ||
3943 | * Injectable mapping from names to event plugin modules. | ||
3944 | */ | ||
3945 | var namesToPlugins = {}; | ||
3946 | |||
3947 | /** | ||
3948 | * Recomputes the plugin list using the injected plugins and plugin ordering. | ||
3949 | * | ||
3950 | * @private | ||
3951 | */ | ||
3952 | function recomputePluginOrdering() { | ||
3953 | if (!EventPluginOrder) { | ||
3954 | // Wait until an `EventPluginOrder` is injected. | ||
3955 | return; | ||
3956 | } | ||
3957 | for (var pluginName in namesToPlugins) { | ||
3958 | var PluginModule = namesToPlugins[pluginName]; | ||
3959 | var pluginIndex = EventPluginOrder.indexOf(pluginName); | ||
3960 | !(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined; | ||
3961 | if (EventPluginRegistry.plugins[pluginIndex]) { | ||
3962 | continue; | ||
3963 | } | ||
3964 | !PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined; | ||
3965 | EventPluginRegistry.plugins[pluginIndex] = PluginModule; | ||
3966 | var publishedEvents = PluginModule.eventTypes; | ||
3967 | for (var eventName in publishedEvents) { | ||
3968 | !publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined; | ||
3969 | } | ||
3970 | } | ||
3971 | } | ||
3972 | |||
3973 | /** | ||
3974 | * Publishes an event so that it can be dispatched by the supplied plugin. | ||
3975 | * | ||
3976 | * @param {object} dispatchConfig Dispatch configuration for the event. | ||
3977 | * @param {object} PluginModule Plugin publishing the event. | ||
3978 | * @return {boolean} True if the event was successfully published. | ||
3979 | * @private | ||
3980 | */ | ||
3981 | function publishEventForPlugin(dispatchConfig, PluginModule, eventName) { | ||
3982 | !!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined; | ||
3983 | EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig; | ||
3984 | |||
3985 | var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; | ||
3986 | if (phasedRegistrationNames) { | ||
3987 | for (var phaseName in phasedRegistrationNames) { | ||
3988 | if (phasedRegistrationNames.hasOwnProperty(phaseName)) { | ||
3989 | var phasedRegistrationName = phasedRegistrationNames[phaseName]; | ||
3990 | publishRegistrationName(phasedRegistrationName, PluginModule, eventName); | ||
3991 | } | ||
3992 | } | ||
3993 | return true; | ||
3994 | } else if (dispatchConfig.registrationName) { | ||
3995 | publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName); | ||
3996 | return true; | ||
3997 | } | ||
3998 | return false; | ||
3999 | } | ||
4000 | |||
4001 | /** | ||
4002 | * Publishes a registration name that is used to identify dispatched events and | ||
4003 | * can be used with `EventPluginHub.putListener` to register listeners. | ||
4004 | * | ||
4005 | * @param {string} registrationName Registration name to add. | ||
4006 | * @param {object} PluginModule Plugin publishing the event. | ||
4007 | * @private | ||
4008 | */ | ||
4009 | function publishRegistrationName(registrationName, PluginModule, eventName) { | ||
4010 | !!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined; | ||
4011 | EventPluginRegistry.registrationNameModules[registrationName] = PluginModule; | ||
4012 | EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies; | ||
4013 | } | ||
4014 | |||
4015 | /** | ||
4016 | * Registers plugins so that they can extract and dispatch events. | ||
4017 | * | ||
4018 | * @see {EventPluginHub} | ||
4019 | */ | ||
4020 | var EventPluginRegistry = { | ||
4021 | |||
4022 | /** | ||
4023 | * Ordered list of injected plugins. | ||
4024 | */ | ||
4025 | plugins: [], | ||
4026 | |||
4027 | /** | ||
4028 | * Mapping from event name to dispatch config | ||
4029 | */ | ||
4030 | eventNameDispatchConfigs: {}, | ||
4031 | |||
4032 | /** | ||
4033 | * Mapping from registration name to plugin module | ||
4034 | */ | ||
4035 | registrationNameModules: {}, | ||
4036 | |||
4037 | /** | ||
4038 | * Mapping from registration name to event name | ||
4039 | */ | ||
4040 | registrationNameDependencies: {}, | ||
4041 | |||
4042 | /** | ||
4043 | * Injects an ordering of plugins (by plugin name). This allows the ordering | ||
4044 | * to be decoupled from injection of the actual plugins so that ordering is | ||
4045 | * always deterministic regardless of packaging, on-the-fly injection, etc. | ||
4046 | * | ||
4047 | * @param {array} InjectedEventPluginOrder | ||
4048 | * @internal | ||
4049 | * @see {EventPluginHub.injection.injectEventPluginOrder} | ||
4050 | */ | ||
4051 | injectEventPluginOrder: function (InjectedEventPluginOrder) { | ||
4052 | !!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : undefined; | ||
4053 | // Clone the ordering so it cannot be dynamically mutated. | ||
4054 | EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder); | ||
4055 | recomputePluginOrdering(); | ||
4056 | }, | ||
4057 | |||
4058 | /** | ||
4059 | * Injects plugins to be used by `EventPluginHub`. The plugin names must be | ||
4060 | * in the ordering injected by `injectEventPluginOrder`. | ||
4061 | * | ||
4062 | * Plugins can be injected as part of page initialization or on-the-fly. | ||
4063 | * | ||
4064 | * @param {object} injectedNamesToPlugins Map from names to plugin modules. | ||
4065 | * @internal | ||
4066 | * @see {EventPluginHub.injection.injectEventPluginsByName} | ||
4067 | */ | ||
4068 | injectEventPluginsByName: function (injectedNamesToPlugins) { | ||
4069 | var isOrderingDirty = false; | ||
4070 | for (var pluginName in injectedNamesToPlugins) { | ||
4071 | if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { | ||
4072 | continue; | ||
4073 | } | ||
4074 | var PluginModule = injectedNamesToPlugins[pluginName]; | ||
4075 | if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) { | ||
4076 | !!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : undefined; | ||
4077 | namesToPlugins[pluginName] = PluginModule; | ||
4078 | isOrderingDirty = true; | ||
4079 | } | ||
4080 | } | ||
4081 | if (isOrderingDirty) { | ||
4082 | recomputePluginOrdering(); | ||
4083 | } | ||
4084 | }, | ||
4085 | |||
4086 | /** | ||
4087 | * Looks up the plugin for the supplied event. | ||
4088 | * | ||
4089 | * @param {object} event A synthetic event. | ||
4090 | * @return {?object} The plugin that created the supplied event. | ||
4091 | * @internal | ||
4092 | */ | ||
4093 | getPluginModuleForEvent: function (event) { | ||
4094 | var dispatchConfig = event.dispatchConfig; | ||
4095 | if (dispatchConfig.registrationName) { | ||
4096 | return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null; | ||
4097 | } | ||
4098 | for (var phase in dispatchConfig.phasedRegistrationNames) { | ||
4099 | if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) { | ||
4100 | continue; | ||
4101 | } | ||
4102 | var PluginModule = EventPluginRegistry.registrationNameModules[dispatchConfig.phasedRegistrationNames[phase]]; | ||
4103 | if (PluginModule) { | ||
4104 | return PluginModule; | ||
4105 | } | ||
4106 | } | ||
4107 | return null; | ||
4108 | }, | ||
4109 | |||
4110 | /** | ||
4111 | * Exposed for unit testing. | ||
4112 | * @private | ||
4113 | */ | ||
4114 | _resetEventPlugins: function () { | ||
4115 | EventPluginOrder = null; | ||
4116 | for (var pluginName in namesToPlugins) { | ||
4117 | if (namesToPlugins.hasOwnProperty(pluginName)) { | ||
4118 | delete namesToPlugins[pluginName]; | ||
4119 | } | ||
4120 | } | ||
4121 | EventPluginRegistry.plugins.length = 0; | ||
4122 | |||
4123 | var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs; | ||
4124 | for (var eventName in eventNameDispatchConfigs) { | ||
4125 | if (eventNameDispatchConfigs.hasOwnProperty(eventName)) { | ||
4126 | delete eventNameDispatchConfigs[eventName]; | ||
4127 | } | ||
4128 | } | ||
4129 | |||
4130 | var registrationNameModules = EventPluginRegistry.registrationNameModules; | ||
4131 | for (var registrationName in registrationNameModules) { | ||
4132 | if (registrationNameModules.hasOwnProperty(registrationName)) { | ||
4133 | delete registrationNameModules[registrationName]; | ||
4134 | } | ||
4135 | } | ||
4136 | } | ||
4137 | |||
4138 | }; | ||
4139 | |||
4140 | module.exports = EventPluginRegistry; | ||
4141 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
4142 | |||
4143 | /***/ }, | ||
4144 | /* 35 */ | ||
4145 | /***/ function(module, exports, __webpack_require__) { | ||
4146 | |||
4147 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
4148 | * Copyright 2013-2015, Facebook, Inc. | ||
4149 | * All rights reserved. | ||
4150 | * | ||
4151 | * This source code is licensed under the BSD-style license found in the | ||
4152 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4153 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4154 | * | ||
4155 | * @providesModule EventPluginUtils | ||
4156 | */ | ||
4157 | |||
4158 | 'use strict'; | ||
4159 | |||
4160 | var EventConstants = __webpack_require__(32); | ||
4161 | var ReactErrorUtils = __webpack_require__(36); | ||
4162 | |||
4163 | var invariant = __webpack_require__(15); | ||
4164 | var warning = __webpack_require__(27); | ||
4165 | |||
4166 | /** | ||
4167 | * Injected dependencies: | ||
4168 | */ | ||
4169 | |||
4170 | /** | ||
4171 | * - `Mount`: [required] Module that can convert between React dom IDs and | ||
4172 | * actual node references. | ||
4173 | */ | ||
4174 | var injection = { | ||
4175 | Mount: null, | ||
4176 | injectMount: function (InjectedMount) { | ||
4177 | injection.Mount = InjectedMount; | ||
4178 | if (process.env.NODE_ENV !== 'production') { | ||
4179 | process.env.NODE_ENV !== 'production' ? warning(InjectedMount && InjectedMount.getNode && InjectedMount.getID, 'EventPluginUtils.injection.injectMount(...): Injected Mount ' + 'module is missing getNode or getID.') : undefined; | ||
4180 | } | ||
4181 | } | ||
4182 | }; | ||
4183 | |||
4184 | var topLevelTypes = EventConstants.topLevelTypes; | ||
4185 | |||
4186 | function isEndish(topLevelType) { | ||
4187 | return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel; | ||
4188 | } | ||
4189 | |||
4190 | function isMoveish(topLevelType) { | ||
4191 | return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove; | ||
4192 | } | ||
4193 | function isStartish(topLevelType) { | ||
4194 | return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart; | ||
4195 | } | ||
4196 | |||
4197 | var validateEventDispatches; | ||
4198 | if (process.env.NODE_ENV !== 'production') { | ||
4199 | validateEventDispatches = function (event) { | ||
4200 | var dispatchListeners = event._dispatchListeners; | ||
4201 | var dispatchIDs = event._dispatchIDs; | ||
4202 | |||
4203 | var listenersIsArr = Array.isArray(dispatchListeners); | ||
4204 | var idsIsArr = Array.isArray(dispatchIDs); | ||
4205 | var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0; | ||
4206 | var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; | ||
4207 | |||
4208 | process.env.NODE_ENV !== 'production' ? warning(idsIsArr === listenersIsArr && IDsLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined; | ||
4209 | }; | ||
4210 | } | ||
4211 | |||
4212 | /** | ||
4213 | * Dispatch the event to the listener. | ||
4214 | * @param {SyntheticEvent} event SyntheticEvent to handle | ||
4215 | * @param {boolean} simulated If the event is simulated (changes exn behavior) | ||
4216 | * @param {function} listener Application-level callback | ||
4217 | * @param {string} domID DOM id to pass to the callback. | ||
4218 | */ | ||
4219 | function executeDispatch(event, simulated, listener, domID) { | ||
4220 | var type = event.type || 'unknown-event'; | ||
4221 | event.currentTarget = injection.Mount.getNode(domID); | ||
4222 | if (simulated) { | ||
4223 | ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event, domID); | ||
4224 | } else { | ||
4225 | ReactErrorUtils.invokeGuardedCallback(type, listener, event, domID); | ||
4226 | } | ||
4227 | event.currentTarget = null; | ||
4228 | } | ||
4229 | |||
4230 | /** | ||
4231 | * Standard/simple iteration through an event's collected dispatches. | ||
4232 | */ | ||
4233 | function executeDispatchesInOrder(event, simulated) { | ||
4234 | var dispatchListeners = event._dispatchListeners; | ||
4235 | var dispatchIDs = event._dispatchIDs; | ||
4236 | if (process.env.NODE_ENV !== 'production') { | ||
4237 | validateEventDispatches(event); | ||
4238 | } | ||
4239 | if (Array.isArray(dispatchListeners)) { | ||
4240 | for (var i = 0; i < dispatchListeners.length; i++) { | ||
4241 | if (event.isPropagationStopped()) { | ||
4242 | break; | ||
4243 | } | ||
4244 | // Listeners and IDs are two parallel arrays that are always in sync. | ||
4245 | executeDispatch(event, simulated, dispatchListeners[i], dispatchIDs[i]); | ||
4246 | } | ||
4247 | } else if (dispatchListeners) { | ||
4248 | executeDispatch(event, simulated, dispatchListeners, dispatchIDs); | ||
4249 | } | ||
4250 | event._dispatchListeners = null; | ||
4251 | event._dispatchIDs = null; | ||
4252 | } | ||
4253 | |||
4254 | /** | ||
4255 | * Standard/simple iteration through an event's collected dispatches, but stops | ||
4256 | * at the first dispatch execution returning true, and returns that id. | ||
4257 | * | ||
4258 | * @return {?string} id of the first dispatch execution who's listener returns | ||
4259 | * true, or null if no listener returned true. | ||
4260 | */ | ||
4261 | function executeDispatchesInOrderStopAtTrueImpl(event) { | ||
4262 | var dispatchListeners = event._dispatchListeners; | ||
4263 | var dispatchIDs = event._dispatchIDs; | ||
4264 | if (process.env.NODE_ENV !== 'production') { | ||
4265 | validateEventDispatches(event); | ||
4266 | } | ||
4267 | if (Array.isArray(dispatchListeners)) { | ||
4268 | for (var i = 0; i < dispatchListeners.length; i++) { | ||
4269 | if (event.isPropagationStopped()) { | ||
4270 | break; | ||
4271 | } | ||
4272 | // Listeners and IDs are two parallel arrays that are always in sync. | ||
4273 | if (dispatchListeners[i](event, dispatchIDs[i])) { | ||
4274 | return dispatchIDs[i]; | ||
4275 | } | ||
4276 | } | ||
4277 | } else if (dispatchListeners) { | ||
4278 | if (dispatchListeners(event, dispatchIDs)) { | ||
4279 | return dispatchIDs; | ||
4280 | } | ||
4281 | } | ||
4282 | return null; | ||
4283 | } | ||
4284 | |||
4285 | /** | ||
4286 | * @see executeDispatchesInOrderStopAtTrueImpl | ||
4287 | */ | ||
4288 | function executeDispatchesInOrderStopAtTrue(event) { | ||
4289 | var ret = executeDispatchesInOrderStopAtTrueImpl(event); | ||
4290 | event._dispatchIDs = null; | ||
4291 | event._dispatchListeners = null; | ||
4292 | return ret; | ||
4293 | } | ||
4294 | |||
4295 | /** | ||
4296 | * Execution of a "direct" dispatch - there must be at most one dispatch | ||
4297 | * accumulated on the event or it is considered an error. It doesn't really make | ||
4298 | * sense for an event with multiple dispatches (bubbled) to keep track of the | ||
4299 | * return values at each dispatch execution, but it does tend to make sense when | ||
4300 | * dealing with "direct" dispatches. | ||
4301 | * | ||
4302 | * @return {*} The return value of executing the single dispatch. | ||
4303 | */ | ||
4304 | function executeDirectDispatch(event) { | ||
4305 | if (process.env.NODE_ENV !== 'production') { | ||
4306 | validateEventDispatches(event); | ||
4307 | } | ||
4308 | var dispatchListener = event._dispatchListeners; | ||
4309 | var dispatchID = event._dispatchIDs; | ||
4310 | !!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined; | ||
4311 | var res = dispatchListener ? dispatchListener(event, dispatchID) : null; | ||
4312 | event._dispatchListeners = null; | ||
4313 | event._dispatchIDs = null; | ||
4314 | return res; | ||
4315 | } | ||
4316 | |||
4317 | /** | ||
4318 | * @param {SyntheticEvent} event | ||
4319 | * @return {boolean} True iff number of dispatches accumulated is greater than 0. | ||
4320 | */ | ||
4321 | function hasDispatches(event) { | ||
4322 | return !!event._dispatchListeners; | ||
4323 | } | ||
4324 | |||
4325 | /** | ||
4326 | * General utilities that are useful in creating custom Event Plugins. | ||
4327 | */ | ||
4328 | var EventPluginUtils = { | ||
4329 | isEndish: isEndish, | ||
4330 | isMoveish: isMoveish, | ||
4331 | isStartish: isStartish, | ||
4332 | |||
4333 | executeDirectDispatch: executeDirectDispatch, | ||
4334 | executeDispatchesInOrder: executeDispatchesInOrder, | ||
4335 | executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue, | ||
4336 | hasDispatches: hasDispatches, | ||
4337 | |||
4338 | getNode: function (id) { | ||
4339 | return injection.Mount.getNode(id); | ||
4340 | }, | ||
4341 | getID: function (node) { | ||
4342 | return injection.Mount.getID(node); | ||
4343 | }, | ||
4344 | |||
4345 | injection: injection | ||
4346 | }; | ||
4347 | |||
4348 | module.exports = EventPluginUtils; | ||
4349 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
4350 | |||
4351 | /***/ }, | ||
4352 | /* 36 */ | ||
4353 | /***/ function(module, exports, __webpack_require__) { | ||
4354 | |||
4355 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
4356 | * Copyright 2013-2015, Facebook, Inc. | ||
4357 | * All rights reserved. | ||
4358 | * | ||
4359 | * This source code is licensed under the BSD-style license found in the | ||
4360 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4361 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4362 | * | ||
4363 | * @providesModule ReactErrorUtils | ||
4364 | * @typechecks | ||
4365 | */ | ||
4366 | |||
4367 | 'use strict'; | ||
4368 | |||
4369 | var caughtError = null; | ||
4370 | |||
4371 | /** | ||
4372 | * Call a function while guarding against errors that happens within it. | ||
4373 | * | ||
4374 | * @param {?String} name of the guard to use for logging or debugging | ||
4375 | * @param {Function} func The function to invoke | ||
4376 | * @param {*} a First argument | ||
4377 | * @param {*} b Second argument | ||
4378 | */ | ||
4379 | function invokeGuardedCallback(name, func, a, b) { | ||
4380 | try { | ||
4381 | return func(a, b); | ||
4382 | } catch (x) { | ||
4383 | if (caughtError === null) { | ||
4384 | caughtError = x; | ||
4385 | } | ||
4386 | return undefined; | ||
4387 | } | ||
4388 | } | ||
4389 | |||
4390 | var ReactErrorUtils = { | ||
4391 | invokeGuardedCallback: invokeGuardedCallback, | ||
4392 | |||
4393 | /** | ||
4394 | * Invoked by ReactTestUtils.Simulate so that any errors thrown by the event | ||
4395 | * handler are sure to be rethrown by rethrowCaughtError. | ||
4396 | */ | ||
4397 | invokeGuardedCallbackWithCatch: invokeGuardedCallback, | ||
4398 | |||
4399 | /** | ||
4400 | * During execution of guarded functions we will capture the first error which | ||
4401 | * we will rethrow to be handled by the top level error handler. | ||
4402 | */ | ||
4403 | rethrowCaughtError: function () { | ||
4404 | if (caughtError) { | ||
4405 | var error = caughtError; | ||
4406 | caughtError = null; | ||
4407 | throw error; | ||
4408 | } | ||
4409 | } | ||
4410 | }; | ||
4411 | |||
4412 | if (process.env.NODE_ENV !== 'production') { | ||
4413 | /** | ||
4414 | * To help development we can get better devtools integration by simulating a | ||
4415 | * real browser event. | ||
4416 | */ | ||
4417 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { | ||
4418 | var fakeNode = document.createElement('react'); | ||
4419 | ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) { | ||
4420 | var boundFunc = func.bind(null, a, b); | ||
4421 | var evtType = 'react-' + name; | ||
4422 | fakeNode.addEventListener(evtType, boundFunc, false); | ||
4423 | var evt = document.createEvent('Event'); | ||
4424 | evt.initEvent(evtType, false, false); | ||
4425 | fakeNode.dispatchEvent(evt); | ||
4426 | fakeNode.removeEventListener(evtType, boundFunc, false); | ||
4427 | }; | ||
4428 | } | ||
4429 | } | ||
4430 | |||
4431 | module.exports = ReactErrorUtils; | ||
4432 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
4433 | |||
4434 | /***/ }, | ||
4435 | /* 37 */ | ||
4436 | /***/ function(module, exports, __webpack_require__) { | ||
4437 | |||
4438 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
4439 | * Copyright 2014-2015, Facebook, Inc. | ||
4440 | * All rights reserved. | ||
4441 | * | ||
4442 | * This source code is licensed under the BSD-style license found in the | ||
4443 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4444 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4445 | * | ||
4446 | * @providesModule accumulateInto | ||
4447 | */ | ||
4448 | |||
4449 | 'use strict'; | ||
4450 | |||
4451 | var invariant = __webpack_require__(15); | ||
4452 | |||
4453 | /** | ||
4454 | * | ||
4455 | * Accumulates items that must not be null or undefined into the first one. This | ||
4456 | * is used to conserve memory by avoiding array allocations, and thus sacrifices | ||
4457 | * API cleanness. Since `current` can be null before being passed in and not | ||
4458 | * null after this function, make sure to assign it back to `current`: | ||
4459 | * | ||
4460 | * `a = accumulateInto(a, b);` | ||
4461 | * | ||
4462 | * This API should be sparingly used. Try `accumulate` for something cleaner. | ||
4463 | * | ||
4464 | * @return {*|array<*>} An accumulation of items. | ||
4465 | */ | ||
4466 | |||
4467 | function accumulateInto(current, next) { | ||
4468 | !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) : undefined; | ||
4469 | if (current == null) { | ||
4470 | return next; | ||
4471 | } | ||
4472 | |||
4473 | // Both are not empty. Warning: Never call x.concat(y) when you are not | ||
4474 | // certain that x is an Array (x could be a string with concat method). | ||
4475 | var currentIsArray = Array.isArray(current); | ||
4476 | var nextIsArray = Array.isArray(next); | ||
4477 | |||
4478 | if (currentIsArray && nextIsArray) { | ||
4479 | current.push.apply(current, next); | ||
4480 | return current; | ||
4481 | } | ||
4482 | |||
4483 | if (currentIsArray) { | ||
4484 | current.push(next); | ||
4485 | return current; | ||
4486 | } | ||
4487 | |||
4488 | if (nextIsArray) { | ||
4489 | // A bit too dangerous to mutate `next`. | ||
4490 | return [current].concat(next); | ||
4491 | } | ||
4492 | |||
4493 | return [current, next]; | ||
4494 | } | ||
4495 | |||
4496 | module.exports = accumulateInto; | ||
4497 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
4498 | |||
4499 | /***/ }, | ||
4500 | /* 38 */ | ||
4501 | /***/ function(module, exports) { | ||
4502 | |||
4503 | /** | ||
4504 | * Copyright 2013-2015, Facebook, Inc. | ||
4505 | * All rights reserved. | ||
4506 | * | ||
4507 | * This source code is licensed under the BSD-style license found in the | ||
4508 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4509 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4510 | * | ||
4511 | * @providesModule forEachAccumulated | ||
4512 | */ | ||
4513 | |||
4514 | 'use strict'; | ||
4515 | |||
4516 | /** | ||
4517 | * @param {array} arr an "accumulation" of items which is either an Array or | ||
4518 | * a single item. Useful when paired with the `accumulate` module. This is a | ||
4519 | * simple utility that allows us to reason about a collection of items, but | ||
4520 | * handling the case when there is exactly one item (and we do not need to | ||
4521 | * allocate an array). | ||
4522 | */ | ||
4523 | var forEachAccumulated = function (arr, cb, scope) { | ||
4524 | if (Array.isArray(arr)) { | ||
4525 | arr.forEach(cb, scope); | ||
4526 | } else if (arr) { | ||
4527 | cb.call(scope, arr); | ||
4528 | } | ||
4529 | }; | ||
4530 | |||
4531 | module.exports = forEachAccumulated; | ||
4532 | |||
4533 | /***/ }, | ||
4534 | /* 39 */ | ||
4535 | /***/ function(module, exports, __webpack_require__) { | ||
4536 | |||
4537 | /** | ||
4538 | * Copyright 2013-2015, Facebook, Inc. | ||
4539 | * All rights reserved. | ||
4540 | * | ||
4541 | * This source code is licensed under the BSD-style license found in the | ||
4542 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4543 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4544 | * | ||
4545 | * @providesModule ReactEventEmitterMixin | ||
4546 | */ | ||
4547 | |||
4548 | 'use strict'; | ||
4549 | |||
4550 | var EventPluginHub = __webpack_require__(33); | ||
4551 | |||
4552 | function runEventQueueInBatch(events) { | ||
4553 | EventPluginHub.enqueueEvents(events); | ||
4554 | EventPluginHub.processEventQueue(false); | ||
4555 | } | ||
4556 | |||
4557 | var ReactEventEmitterMixin = { | ||
4558 | |||
4559 | /** | ||
4560 | * Streams a fired top-level event to `EventPluginHub` where plugins have the | ||
4561 | * opportunity to create `ReactEvent`s to be dispatched. | ||
4562 | * | ||
4563 | * @param {string} topLevelType Record from `EventConstants`. | ||
4564 | * @param {object} topLevelTarget The listening component root node. | ||
4565 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
4566 | * @param {object} nativeEvent Native environment event. | ||
4567 | */ | ||
4568 | handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
4569 | var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget); | ||
4570 | runEventQueueInBatch(events); | ||
4571 | } | ||
4572 | }; | ||
4573 | |||
4574 | module.exports = ReactEventEmitterMixin; | ||
4575 | |||
4576 | /***/ }, | ||
4577 | /* 40 */ | ||
4578 | /***/ function(module, exports) { | ||
4579 | |||
4580 | /** | ||
4581 | * Copyright 2013-2015, Facebook, Inc. | ||
4582 | * All rights reserved. | ||
4583 | * | ||
4584 | * This source code is licensed under the BSD-style license found in the | ||
4585 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4586 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4587 | * | ||
4588 | * @providesModule ViewportMetrics | ||
4589 | */ | ||
4590 | |||
4591 | 'use strict'; | ||
4592 | |||
4593 | var ViewportMetrics = { | ||
4594 | |||
4595 | currentScrollLeft: 0, | ||
4596 | |||
4597 | currentScrollTop: 0, | ||
4598 | |||
4599 | refreshScrollValues: function (scrollPosition) { | ||
4600 | ViewportMetrics.currentScrollLeft = scrollPosition.x; | ||
4601 | ViewportMetrics.currentScrollTop = scrollPosition.y; | ||
4602 | } | ||
4603 | |||
4604 | }; | ||
4605 | |||
4606 | module.exports = ViewportMetrics; | ||
4607 | |||
4608 | /***/ }, | ||
4609 | /* 41 */ | ||
4610 | /***/ function(module, exports) { | ||
4611 | |||
4612 | /** | ||
4613 | * Copyright 2014-2015, Facebook, Inc. | ||
4614 | * All rights reserved. | ||
4615 | * | ||
4616 | * This source code is licensed under the BSD-style license found in the | ||
4617 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4618 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4619 | * | ||
4620 | * @providesModule Object.assign | ||
4621 | */ | ||
4622 | |||
4623 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign | ||
4624 | |||
4625 | 'use strict'; | ||
4626 | |||
4627 | function assign(target, sources) { | ||
4628 | if (target == null) { | ||
4629 | throw new TypeError('Object.assign target cannot be null or undefined'); | ||
4630 | } | ||
4631 | |||
4632 | var to = Object(target); | ||
4633 | var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
4634 | |||
4635 | for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) { | ||
4636 | var nextSource = arguments[nextIndex]; | ||
4637 | if (nextSource == null) { | ||
4638 | continue; | ||
4639 | } | ||
4640 | |||
4641 | var from = Object(nextSource); | ||
4642 | |||
4643 | // We don't currently support accessors nor proxies. Therefore this | ||
4644 | // copy cannot throw. If we ever supported this then we must handle | ||
4645 | // exceptions and side-effects. We don't support symbols so they won't | ||
4646 | // be transferred. | ||
4647 | |||
4648 | for (var key in from) { | ||
4649 | if (hasOwnProperty.call(from, key)) { | ||
4650 | to[key] = from[key]; | ||
4651 | } | ||
4652 | } | ||
4653 | } | ||
4654 | |||
4655 | return to; | ||
4656 | } | ||
4657 | |||
4658 | module.exports = assign; | ||
4659 | |||
4660 | /***/ }, | ||
4661 | /* 42 */ | ||
4662 | /***/ function(module, exports, __webpack_require__) { | ||
4663 | |||
4664 | /** | ||
4665 | * Copyright 2013-2015, Facebook, Inc. | ||
4666 | * All rights reserved. | ||
4667 | * | ||
4668 | * This source code is licensed under the BSD-style license found in the | ||
4669 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4670 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4671 | * | ||
4672 | * @providesModule isEventSupported | ||
4673 | */ | ||
4674 | |||
4675 | 'use strict'; | ||
4676 | |||
4677 | var ExecutionEnvironment = __webpack_require__(11); | ||
4678 | |||
4679 | var useHasFeature; | ||
4680 | if (ExecutionEnvironment.canUseDOM) { | ||
4681 | useHasFeature = document.implementation && document.implementation.hasFeature && | ||
4682 | // always returns true in newer browsers as per the standard. | ||
4683 | // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature | ||
4684 | document.implementation.hasFeature('', '') !== true; | ||
4685 | } | ||
4686 | |||
4687 | /** | ||
4688 | * Checks if an event is supported in the current execution environment. | ||
4689 | * | ||
4690 | * NOTE: This will not work correctly for non-generic events such as `change`, | ||
4691 | * `reset`, `load`, `error`, and `select`. | ||
4692 | * | ||
4693 | * Borrows from Modernizr. | ||
4694 | * | ||
4695 | * @param {string} eventNameSuffix Event name, e.g. "click". | ||
4696 | * @param {?boolean} capture Check if the capture phase is supported. | ||
4697 | * @return {boolean} True if the event is supported. | ||
4698 | * @internal | ||
4699 | * @license Modernizr 3.0.0pre (Custom Build) | MIT | ||
4700 | */ | ||
4701 | function isEventSupported(eventNameSuffix, capture) { | ||
4702 | if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) { | ||
4703 | return false; | ||
4704 | } | ||
4705 | |||
4706 | var eventName = 'on' + eventNameSuffix; | ||
4707 | var isSupported = (eventName in document); | ||
4708 | |||
4709 | if (!isSupported) { | ||
4710 | var element = document.createElement('div'); | ||
4711 | element.setAttribute(eventName, 'return;'); | ||
4712 | isSupported = typeof element[eventName] === 'function'; | ||
4713 | } | ||
4714 | |||
4715 | if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') { | ||
4716 | // This is the only way to test support for the `wheel` event in IE9+. | ||
4717 | isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); | ||
4718 | } | ||
4719 | |||
4720 | return isSupported; | ||
4721 | } | ||
4722 | |||
4723 | module.exports = isEventSupported; | ||
4724 | |||
4725 | /***/ }, | ||
4726 | /* 43 */ | ||
4727 | /***/ function(module, exports) { | ||
4728 | |||
4729 | /** | ||
4730 | * Copyright 2013-2015, Facebook, Inc. | ||
4731 | * All rights reserved. | ||
4732 | * | ||
4733 | * This source code is licensed under the BSD-style license found in the | ||
4734 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4735 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4736 | * | ||
4737 | * @providesModule ReactDOMFeatureFlags | ||
4738 | */ | ||
4739 | |||
4740 | 'use strict'; | ||
4741 | |||
4742 | var ReactDOMFeatureFlags = { | ||
4743 | useCreateElement: false | ||
4744 | }; | ||
4745 | |||
4746 | module.exports = ReactDOMFeatureFlags; | ||
4747 | |||
4748 | /***/ }, | ||
4749 | /* 44 */ | ||
4750 | /***/ function(module, exports, __webpack_require__) { | ||
4751 | |||
4752 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
4753 | * Copyright 2014-2015, Facebook, Inc. | ||
4754 | * All rights reserved. | ||
4755 | * | ||
4756 | * This source code is licensed under the BSD-style license found in the | ||
4757 | * LICENSE file in the root directory of this source tree. An additional grant | ||
4758 | * of patent rights can be found in the PATENTS file in the same directory. | ||
4759 | * | ||
4760 | * @providesModule ReactElement | ||
4761 | */ | ||
4762 | |||
4763 | 'use strict'; | ||
4764 | |||
4765 | var ReactCurrentOwner = __webpack_require__(7); | ||
4766 | |||
4767 | var assign = __webpack_require__(41); | ||
4768 | var canDefineProperty = __webpack_require__(45); | ||
4769 | |||
4770 | // The Symbol used to tag the ReactElement type. If there is no native Symbol | ||
4771 | // nor polyfill, then a plain number is used for performance. | ||
4772 | var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7; | ||
4773 | |||
4774 | var RESERVED_PROPS = { | ||
4775 | key: true, | ||
4776 | ref: true, | ||
4777 | __self: true, | ||
4778 | __source: true | ||
4779 | }; | ||
4780 | |||
4781 | /** | ||
4782 | * Base constructor for all React elements. This is only used to make this | ||
4783 | * work with a dynamic instanceof check. Nothing should live on this prototype. | ||
4784 | * | ||
4785 | * @param {*} type | ||
4786 | * @param {*} key | ||
4787 | * @param {string|object} ref | ||
4788 | * @param {*} self A *temporary* helper to detect places where `this` is | ||
4789 | * different from the `owner` when React.createElement is called, so that we | ||
4790 | * can warn. We want to get rid of owner and replace string `ref`s with arrow | ||
4791 | * functions, and as long as `this` and owner are the same, there will be no | ||
4792 | * change in behavior. | ||
4793 | * @param {*} source An annotation object (added by a transpiler or otherwise) | ||
4794 | * indicating filename, line number, and/or other information. | ||
4795 | * @param {*} owner | ||
4796 | * @param {*} props | ||
4797 | * @internal | ||
4798 | */ | ||
4799 | var ReactElement = function (type, key, ref, self, source, owner, props) { | ||
4800 | var element = { | ||
4801 | // This tag allow us to uniquely identify this as a React Element | ||
4802 | $$typeof: REACT_ELEMENT_TYPE, | ||
4803 | |||
4804 | // Built-in properties that belong on the element | ||
4805 | type: type, | ||
4806 | key: key, | ||
4807 | ref: ref, | ||
4808 | props: props, | ||
4809 | |||
4810 | // Record the component responsible for creating this element. | ||
4811 | _owner: owner | ||
4812 | }; | ||
4813 | |||
4814 | if (process.env.NODE_ENV !== 'production') { | ||
4815 | // The validation flag is currently mutative. We put it on | ||
4816 | // an external backing store so that we can freeze the whole object. | ||
4817 | // This can be replaced with a WeakMap once they are implemented in | ||
4818 | // commonly used development environments. | ||
4819 | element._store = {}; | ||
4820 | |||
4821 | // To make comparing ReactElements easier for testing purposes, we make | ||
4822 | // the validation flag non-enumerable (where possible, which should | ||
4823 | // include every environment we run tests in), so the test framework | ||
4824 | // ignores it. | ||
4825 | if (canDefineProperty) { | ||
4826 | Object.defineProperty(element._store, 'validated', { | ||
4827 | configurable: false, | ||
4828 | enumerable: false, | ||
4829 | writable: true, | ||
4830 | value: false | ||
4831 | }); | ||
4832 | // self and source are DEV only properties. | ||
4833 | Object.defineProperty(element, '_self', { | ||
4834 | configurable: false, | ||
4835 | enumerable: false, | ||
4836 | writable: false, | ||
4837 | value: self | ||
4838 | }); | ||
4839 | // Two elements created in two different places should be considered | ||
4840 | // equal for testing purposes and therefore we hide it from enumeration. | ||
4841 | Object.defineProperty(element, '_source', { | ||
4842 | configurable: false, | ||
4843 | enumerable: false, | ||
4844 | writable: false, | ||
4845 | value: source | ||
4846 | }); | ||
4847 | } else { | ||
4848 | element._store.validated = false; | ||
4849 | element._self = self; | ||
4850 | element._source = source; | ||
4851 | } | ||
4852 | Object.freeze(element.props); | ||
4853 | Object.freeze(element); | ||
4854 | } | ||
4855 | |||
4856 | return element; | ||
4857 | }; | ||
4858 | |||
4859 | ReactElement.createElement = function (type, config, children) { | ||
4860 | var propName; | ||
4861 | |||
4862 | // Reserved names are extracted | ||
4863 | var props = {}; | ||
4864 | |||
4865 | var key = null; | ||
4866 | var ref = null; | ||
4867 | var self = null; | ||
4868 | var source = null; | ||
4869 | |||
4870 | if (config != null) { | ||
4871 | ref = config.ref === undefined ? null : config.ref; | ||
4872 | key = config.key === undefined ? null : '' + config.key; | ||
4873 | self = config.__self === undefined ? null : config.__self; | ||
4874 | source = config.__source === undefined ? null : config.__source; | ||
4875 | // Remaining properties are added to a new props object | ||
4876 | for (propName in config) { | ||
4877 | if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { | ||
4878 | props[propName] = config[propName]; | ||
4879 | } | ||
4880 | } | ||
4881 | } | ||
4882 | |||
4883 | // Children can be more than one argument, and those are transferred onto | ||
4884 | // the newly allocated props object. | ||
4885 | var childrenLength = arguments.length - 2; | ||
4886 | if (childrenLength === 1) { | ||
4887 | props.children = children; | ||
4888 | } else if (childrenLength > 1) { | ||
4889 | var childArray = Array(childrenLength); | ||
4890 | for (var i = 0; i < childrenLength; i++) { | ||
4891 | childArray[i] = arguments[i + 2]; | ||
4892 | } | ||
4893 | props.children = childArray; | ||
4894 | } | ||
4895 | |||
4896 | // Resolve default props | ||
4897 | if (type && type.defaultProps) { | ||
4898 | var defaultProps = type.defaultProps; | ||
4899 | for (propName in defaultProps) { | ||
4900 | if (typeof props[propName] === 'undefined') { | ||
4901 | props[propName] = defaultProps[propName]; | ||
4902 | } | ||
4903 | } | ||
4904 | } | ||
4905 | |||
4906 | return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); | ||
4907 | }; | ||
4908 | |||
4909 | ReactElement.createFactory = function (type) { | ||
4910 | var factory = ReactElement.createElement.bind(null, type); | ||
4911 | // Expose the type on the factory and the prototype so that it can be | ||
4912 | // easily accessed on elements. E.g. `<Foo />.type === Foo`. | ||
4913 | // This should not be named `constructor` since this may not be the function | ||
4914 | // that created the element, and it may not even be a constructor. | ||
4915 | // Legacy hook TODO: Warn if this is accessed | ||
4916 | factory.type = type; | ||
4917 | return factory; | ||
4918 | }; | ||
4919 | |||
4920 | ReactElement.cloneAndReplaceKey = function (oldElement, newKey) { | ||
4921 | var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); | ||
4922 | |||
4923 | return newElement; | ||
4924 | }; | ||
4925 | |||
4926 | ReactElement.cloneAndReplaceProps = function (oldElement, newProps) { | ||
4927 | var newElement = ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, newProps); | ||
4928 | |||
4929 | if (process.env.NODE_ENV !== 'production') { | ||
4930 | // If the key on the original is valid, then the clone is valid | ||
4931 | newElement._store.validated = oldElement._store.validated; | ||
4932 | } | ||
4933 | |||
4934 | return newElement; | ||
4935 | }; | ||
4936 | |||
4937 | ReactElement.cloneElement = function (element, config, children) { | ||
4938 | var propName; | ||
4939 | |||
4940 | // Original props are copied | ||
4941 | var props = assign({}, element.props); | ||
4942 | |||
4943 | // Reserved names are extracted | ||
4944 | var key = element.key; | ||
4945 | var ref = element.ref; | ||
4946 | // Self is preserved since the owner is preserved. | ||
4947 | var self = element._self; | ||
4948 | // Source is preserved since cloneElement is unlikely to be targeted by a | ||
4949 | // transpiler, and the original source is probably a better indicator of the | ||
4950 | // true owner. | ||
4951 | var source = element._source; | ||
4952 | |||
4953 | // Owner will be preserved, unless ref is overridden | ||
4954 | var owner = element._owner; | ||
4955 | |||
4956 | if (config != null) { | ||
4957 | if (config.ref !== undefined) { | ||
4958 | // Silently steal the ref from the parent. | ||
4959 | ref = config.ref; | ||
4960 | owner = ReactCurrentOwner.current; | ||
4961 | } | ||
4962 | if (config.key !== undefined) { | ||
4963 | key = '' + config.key; | ||
4964 | } | ||
4965 | // Remaining properties override existing props | ||
4966 | for (propName in config) { | ||
4967 | if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { | ||
4968 | props[propName] = config[propName]; | ||
4969 | } | ||
4970 | } | ||
4971 | } | ||
4972 | |||
4973 | // Children can be more than one argument, and those are transferred onto | ||
4974 | // the newly allocated props object. | ||
4975 | var childrenLength = arguments.length - 2; | ||
4976 | if (childrenLength === 1) { | ||
4977 | props.children = children; | ||
4978 | } else if (childrenLength > 1) { | ||
4979 | var childArray = Array(childrenLength); | ||
4980 | for (var i = 0; i < childrenLength; i++) { | ||
4981 | childArray[i] = arguments[i + 2]; | ||
4982 | } | ||
4983 | props.children = childArray; | ||
4984 | } | ||
4985 | |||
4986 | return ReactElement(element.type, key, ref, self, source, owner, props); | ||
4987 | }; | ||
4988 | |||
4989 | /** | ||
4990 | * @param {?object} object | ||
4991 | * @return {boolean} True if `object` is a valid component. | ||
4992 | * @final | ||
4993 | */ | ||
4994 | ReactElement.isValidElement = function (object) { | ||
4995 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; | ||
4996 | }; | ||
4997 | |||
4998 | module.exports = ReactElement; | ||
4999 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
5000 | |||
5001 | /***/ }, | ||
5002 | /* 45 */ | ||
5003 | /***/ function(module, exports, __webpack_require__) { | ||
5004 | |||
5005 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
5006 | * Copyright 2013-2015, Facebook, Inc. | ||
5007 | * All rights reserved. | ||
5008 | * | ||
5009 | * This source code is licensed under the BSD-style license found in the | ||
5010 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5011 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5012 | * | ||
5013 | * @providesModule canDefineProperty | ||
5014 | */ | ||
5015 | |||
5016 | 'use strict'; | ||
5017 | |||
5018 | var canDefineProperty = false; | ||
5019 | if (process.env.NODE_ENV !== 'production') { | ||
5020 | try { | ||
5021 | Object.defineProperty({}, 'x', { get: function () {} }); | ||
5022 | canDefineProperty = true; | ||
5023 | } catch (x) { | ||
5024 | // IE will fail on defineProperty | ||
5025 | } | ||
5026 | } | ||
5027 | |||
5028 | module.exports = canDefineProperty; | ||
5029 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
5030 | |||
5031 | /***/ }, | ||
5032 | /* 46 */ | ||
5033 | /***/ function(module, exports) { | ||
5034 | |||
5035 | /** | ||
5036 | * Copyright 2014-2015, Facebook, Inc. | ||
5037 | * All rights reserved. | ||
5038 | * | ||
5039 | * This source code is licensed under the BSD-style license found in the | ||
5040 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5041 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5042 | * | ||
5043 | * @providesModule ReactEmptyComponentRegistry | ||
5044 | */ | ||
5045 | |||
5046 | 'use strict'; | ||
5047 | |||
5048 | // This registry keeps track of the React IDs of the components that rendered to | ||
5049 | // `null` (in reality a placeholder such as `noscript`) | ||
5050 | var nullComponentIDsRegistry = {}; | ||
5051 | |||
5052 | /** | ||
5053 | * @param {string} id Component's `_rootNodeID`. | ||
5054 | * @return {boolean} True if the component is rendered to null. | ||
5055 | */ | ||
5056 | function isNullComponentID(id) { | ||
5057 | return !!nullComponentIDsRegistry[id]; | ||
5058 | } | ||
5059 | |||
5060 | /** | ||
5061 | * Mark the component as having rendered to null. | ||
5062 | * @param {string} id Component's `_rootNodeID`. | ||
5063 | */ | ||
5064 | function registerNullComponentID(id) { | ||
5065 | nullComponentIDsRegistry[id] = true; | ||
5066 | } | ||
5067 | |||
5068 | /** | ||
5069 | * Unmark the component as having rendered to null: it renders to something now. | ||
5070 | * @param {string} id Component's `_rootNodeID`. | ||
5071 | */ | ||
5072 | function deregisterNullComponentID(id) { | ||
5073 | delete nullComponentIDsRegistry[id]; | ||
5074 | } | ||
5075 | |||
5076 | var ReactEmptyComponentRegistry = { | ||
5077 | isNullComponentID: isNullComponentID, | ||
5078 | registerNullComponentID: registerNullComponentID, | ||
5079 | deregisterNullComponentID: deregisterNullComponentID | ||
5080 | }; | ||
5081 | |||
5082 | module.exports = ReactEmptyComponentRegistry; | ||
5083 | |||
5084 | /***/ }, | ||
5085 | /* 47 */ | ||
5086 | /***/ function(module, exports, __webpack_require__) { | ||
5087 | |||
5088 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
5089 | * Copyright 2013-2015, Facebook, Inc. | ||
5090 | * All rights reserved. | ||
5091 | * | ||
5092 | * This source code is licensed under the BSD-style license found in the | ||
5093 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5094 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5095 | * | ||
5096 | * @providesModule ReactInstanceHandles | ||
5097 | * @typechecks static-only | ||
5098 | */ | ||
5099 | |||
5100 | 'use strict'; | ||
5101 | |||
5102 | var ReactRootIndex = __webpack_require__(48); | ||
5103 | |||
5104 | var invariant = __webpack_require__(15); | ||
5105 | |||
5106 | var SEPARATOR = '.'; | ||
5107 | var SEPARATOR_LENGTH = SEPARATOR.length; | ||
5108 | |||
5109 | /** | ||
5110 | * Maximum depth of traversals before we consider the possibility of a bad ID. | ||
5111 | */ | ||
5112 | var MAX_TREE_DEPTH = 10000; | ||
5113 | |||
5114 | /** | ||
5115 | * Creates a DOM ID prefix to use when mounting React components. | ||
5116 | * | ||
5117 | * @param {number} index A unique integer | ||
5118 | * @return {string} React root ID. | ||
5119 | * @internal | ||
5120 | */ | ||
5121 | function getReactRootIDString(index) { | ||
5122 | return SEPARATOR + index.toString(36); | ||
5123 | } | ||
5124 | |||
5125 | /** | ||
5126 | * Checks if a character in the supplied ID is a separator or the end. | ||
5127 | * | ||
5128 | * @param {string} id A React DOM ID. | ||
5129 | * @param {number} index Index of the character to check. | ||
5130 | * @return {boolean} True if the character is a separator or end of the ID. | ||
5131 | * @private | ||
5132 | */ | ||
5133 | function isBoundary(id, index) { | ||
5134 | return id.charAt(index) === SEPARATOR || index === id.length; | ||
5135 | } | ||
5136 | |||
5137 | /** | ||
5138 | * Checks if the supplied string is a valid React DOM ID. | ||
5139 | * | ||
5140 | * @param {string} id A React DOM ID, maybe. | ||
5141 | * @return {boolean} True if the string is a valid React DOM ID. | ||
5142 | * @private | ||
5143 | */ | ||
5144 | function isValidID(id) { | ||
5145 | return id === '' || id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR; | ||
5146 | } | ||
5147 | |||
5148 | /** | ||
5149 | * Checks if the first ID is an ancestor of or equal to the second ID. | ||
5150 | * | ||
5151 | * @param {string} ancestorID | ||
5152 | * @param {string} descendantID | ||
5153 | * @return {boolean} True if `ancestorID` is an ancestor of `descendantID`. | ||
5154 | * @internal | ||
5155 | */ | ||
5156 | function isAncestorIDOf(ancestorID, descendantID) { | ||
5157 | return descendantID.indexOf(ancestorID) === 0 && isBoundary(descendantID, ancestorID.length); | ||
5158 | } | ||
5159 | |||
5160 | /** | ||
5161 | * Gets the parent ID of the supplied React DOM ID, `id`. | ||
5162 | * | ||
5163 | * @param {string} id ID of a component. | ||
5164 | * @return {string} ID of the parent, or an empty string. | ||
5165 | * @private | ||
5166 | */ | ||
5167 | function getParentID(id) { | ||
5168 | return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : ''; | ||
5169 | } | ||
5170 | |||
5171 | /** | ||
5172 | * Gets the next DOM ID on the tree path from the supplied `ancestorID` to the | ||
5173 | * supplied `destinationID`. If they are equal, the ID is returned. | ||
5174 | * | ||
5175 | * @param {string} ancestorID ID of an ancestor node of `destinationID`. | ||
5176 | * @param {string} destinationID ID of the destination node. | ||
5177 | * @return {string} Next ID on the path from `ancestorID` to `destinationID`. | ||
5178 | * @private | ||
5179 | */ | ||
5180 | function getNextDescendantID(ancestorID, destinationID) { | ||
5181 | !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined; | ||
5182 | !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined; | ||
5183 | if (ancestorID === destinationID) { | ||
5184 | return ancestorID; | ||
5185 | } | ||
5186 | // Skip over the ancestor and the immediate separator. Traverse until we hit | ||
5187 | // another separator or we reach the end of `destinationID`. | ||
5188 | var start = ancestorID.length + SEPARATOR_LENGTH; | ||
5189 | var i; | ||
5190 | for (i = start; i < destinationID.length; i++) { | ||
5191 | if (isBoundary(destinationID, i)) { | ||
5192 | break; | ||
5193 | } | ||
5194 | } | ||
5195 | return destinationID.substr(0, i); | ||
5196 | } | ||
5197 | |||
5198 | /** | ||
5199 | * Gets the nearest common ancestor ID of two IDs. | ||
5200 | * | ||
5201 | * Using this ID scheme, the nearest common ancestor ID is the longest common | ||
5202 | * prefix of the two IDs that immediately preceded a "marker" in both strings. | ||
5203 | * | ||
5204 | * @param {string} oneID | ||
5205 | * @param {string} twoID | ||
5206 | * @return {string} Nearest common ancestor ID, or the empty string if none. | ||
5207 | * @private | ||
5208 | */ | ||
5209 | function getFirstCommonAncestorID(oneID, twoID) { | ||
5210 | var minLength = Math.min(oneID.length, twoID.length); | ||
5211 | if (minLength === 0) { | ||
5212 | return ''; | ||
5213 | } | ||
5214 | var lastCommonMarkerIndex = 0; | ||
5215 | // Use `<=` to traverse until the "EOL" of the shorter string. | ||
5216 | for (var i = 0; i <= minLength; i++) { | ||
5217 | if (isBoundary(oneID, i) && isBoundary(twoID, i)) { | ||
5218 | lastCommonMarkerIndex = i; | ||
5219 | } else if (oneID.charAt(i) !== twoID.charAt(i)) { | ||
5220 | break; | ||
5221 | } | ||
5222 | } | ||
5223 | var longestCommonID = oneID.substr(0, lastCommonMarkerIndex); | ||
5224 | !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined; | ||
5225 | return longestCommonID; | ||
5226 | } | ||
5227 | |||
5228 | /** | ||
5229 | * Traverses the parent path between two IDs (either up or down). The IDs must | ||
5230 | * not be the same, and there must exist a parent path between them. If the | ||
5231 | * callback returns `false`, traversal is stopped. | ||
5232 | * | ||
5233 | * @param {?string} start ID at which to start traversal. | ||
5234 | * @param {?string} stop ID at which to end traversal. | ||
5235 | * @param {function} cb Callback to invoke each ID with. | ||
5236 | * @param {*} arg Argument to invoke the callback with. | ||
5237 | * @param {?boolean} skipFirst Whether or not to skip the first node. | ||
5238 | * @param {?boolean} skipLast Whether or not to skip the last node. | ||
5239 | * @private | ||
5240 | */ | ||
5241 | function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) { | ||
5242 | start = start || ''; | ||
5243 | stop = stop || ''; | ||
5244 | !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined; | ||
5245 | var traverseUp = isAncestorIDOf(stop, start); | ||
5246 | !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined; | ||
5247 | // Traverse from `start` to `stop` one depth at a time. | ||
5248 | var depth = 0; | ||
5249 | var traverse = traverseUp ? getParentID : getNextDescendantID; | ||
5250 | for (var id = start;; /* until break */id = traverse(id, stop)) { | ||
5251 | var ret; | ||
5252 | if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) { | ||
5253 | ret = cb(id, traverseUp, arg); | ||
5254 | } | ||
5255 | if (ret === false || id === stop) { | ||
5256 | // Only break //after// visiting `stop`. | ||
5257 | break; | ||
5258 | } | ||
5259 | !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : undefined; | ||
5260 | } | ||
5261 | } | ||
5262 | |||
5263 | /** | ||
5264 | * Manages the IDs assigned to DOM representations of React components. This | ||
5265 | * uses a specific scheme in order to traverse the DOM efficiently (e.g. in | ||
5266 | * order to simulate events). | ||
5267 | * | ||
5268 | * @internal | ||
5269 | */ | ||
5270 | var ReactInstanceHandles = { | ||
5271 | |||
5272 | /** | ||
5273 | * Constructs a React root ID | ||
5274 | * @return {string} A React root ID. | ||
5275 | */ | ||
5276 | createReactRootID: function () { | ||
5277 | return getReactRootIDString(ReactRootIndex.createReactRootIndex()); | ||
5278 | }, | ||
5279 | |||
5280 | /** | ||
5281 | * Constructs a React ID by joining a root ID with a name. | ||
5282 | * | ||
5283 | * @param {string} rootID Root ID of a parent component. | ||
5284 | * @param {string} name A component's name (as flattened children). | ||
5285 | * @return {string} A React ID. | ||
5286 | * @internal | ||
5287 | */ | ||
5288 | createReactID: function (rootID, name) { | ||
5289 | return rootID + name; | ||
5290 | }, | ||
5291 | |||
5292 | /** | ||
5293 | * Gets the DOM ID of the React component that is the root of the tree that | ||
5294 | * contains the React component with the supplied DOM ID. | ||
5295 | * | ||
5296 | * @param {string} id DOM ID of a React component. | ||
5297 | * @return {?string} DOM ID of the React component that is the root. | ||
5298 | * @internal | ||
5299 | */ | ||
5300 | getReactRootIDFromNodeID: function (id) { | ||
5301 | if (id && id.charAt(0) === SEPARATOR && id.length > 1) { | ||
5302 | var index = id.indexOf(SEPARATOR, 1); | ||
5303 | return index > -1 ? id.substr(0, index) : id; | ||
5304 | } | ||
5305 | return null; | ||
5306 | }, | ||
5307 | |||
5308 | /** | ||
5309 | * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that | ||
5310 | * should would receive a `mouseEnter` or `mouseLeave` event. | ||
5311 | * | ||
5312 | * NOTE: Does not invoke the callback on the nearest common ancestor because | ||
5313 | * nothing "entered" or "left" that element. | ||
5314 | * | ||
5315 | * @param {string} leaveID ID being left. | ||
5316 | * @param {string} enterID ID being entered. | ||
5317 | * @param {function} cb Callback to invoke on each entered/left ID. | ||
5318 | * @param {*} upArg Argument to invoke the callback with on left IDs. | ||
5319 | * @param {*} downArg Argument to invoke the callback with on entered IDs. | ||
5320 | * @internal | ||
5321 | */ | ||
5322 | traverseEnterLeave: function (leaveID, enterID, cb, upArg, downArg) { | ||
5323 | var ancestorID = getFirstCommonAncestorID(leaveID, enterID); | ||
5324 | if (ancestorID !== leaveID) { | ||
5325 | traverseParentPath(leaveID, ancestorID, cb, upArg, false, true); | ||
5326 | } | ||
5327 | if (ancestorID !== enterID) { | ||
5328 | traverseParentPath(ancestorID, enterID, cb, downArg, true, false); | ||
5329 | } | ||
5330 | }, | ||
5331 | |||
5332 | /** | ||
5333 | * Simulates the traversal of a two-phase, capture/bubble event dispatch. | ||
5334 | * | ||
5335 | * NOTE: This traversal happens on IDs without touching the DOM. | ||
5336 | * | ||
5337 | * @param {string} targetID ID of the target node. | ||
5338 | * @param {function} cb Callback to invoke. | ||
5339 | * @param {*} arg Argument to invoke the callback with. | ||
5340 | * @internal | ||
5341 | */ | ||
5342 | traverseTwoPhase: function (targetID, cb, arg) { | ||
5343 | if (targetID) { | ||
5344 | traverseParentPath('', targetID, cb, arg, true, false); | ||
5345 | traverseParentPath(targetID, '', cb, arg, false, true); | ||
5346 | } | ||
5347 | }, | ||
5348 | |||
5349 | /** | ||
5350 | * Same as `traverseTwoPhase` but skips the `targetID`. | ||
5351 | */ | ||
5352 | traverseTwoPhaseSkipTarget: function (targetID, cb, arg) { | ||
5353 | if (targetID) { | ||
5354 | traverseParentPath('', targetID, cb, arg, true, true); | ||
5355 | traverseParentPath(targetID, '', cb, arg, true, true); | ||
5356 | } | ||
5357 | }, | ||
5358 | |||
5359 | /** | ||
5360 | * Traverse a node ID, calling the supplied `cb` for each ancestor ID. For | ||
5361 | * example, passing `.0.$row-0.1` would result in `cb` getting called | ||
5362 | * with `.0`, `.0.$row-0`, and `.0.$row-0.1`. | ||
5363 | * | ||
5364 | * NOTE: This traversal happens on IDs without touching the DOM. | ||
5365 | * | ||
5366 | * @param {string} targetID ID of the target node. | ||
5367 | * @param {function} cb Callback to invoke. | ||
5368 | * @param {*} arg Argument to invoke the callback with. | ||
5369 | * @internal | ||
5370 | */ | ||
5371 | traverseAncestors: function (targetID, cb, arg) { | ||
5372 | traverseParentPath('', targetID, cb, arg, true, false); | ||
5373 | }, | ||
5374 | |||
5375 | getFirstCommonAncestorID: getFirstCommonAncestorID, | ||
5376 | |||
5377 | /** | ||
5378 | * Exposed for unit testing. | ||
5379 | * @private | ||
5380 | */ | ||
5381 | _getNextDescendantID: getNextDescendantID, | ||
5382 | |||
5383 | isAncestorIDOf: isAncestorIDOf, | ||
5384 | |||
5385 | SEPARATOR: SEPARATOR | ||
5386 | |||
5387 | }; | ||
5388 | |||
5389 | module.exports = ReactInstanceHandles; | ||
5390 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
5391 | |||
5392 | /***/ }, | ||
5393 | /* 48 */ | ||
5394 | /***/ function(module, exports) { | ||
5395 | |||
5396 | /** | ||
5397 | * Copyright 2013-2015, Facebook, Inc. | ||
5398 | * All rights reserved. | ||
5399 | * | ||
5400 | * This source code is licensed under the BSD-style license found in the | ||
5401 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5402 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5403 | * | ||
5404 | * @providesModule ReactRootIndex | ||
5405 | * @typechecks | ||
5406 | */ | ||
5407 | |||
5408 | 'use strict'; | ||
5409 | |||
5410 | var ReactRootIndexInjection = { | ||
5411 | /** | ||
5412 | * @param {function} _createReactRootIndex | ||
5413 | */ | ||
5414 | injectCreateReactRootIndex: function (_createReactRootIndex) { | ||
5415 | ReactRootIndex.createReactRootIndex = _createReactRootIndex; | ||
5416 | } | ||
5417 | }; | ||
5418 | |||
5419 | var ReactRootIndex = { | ||
5420 | createReactRootIndex: null, | ||
5421 | injection: ReactRootIndexInjection | ||
5422 | }; | ||
5423 | |||
5424 | module.exports = ReactRootIndex; | ||
5425 | |||
5426 | /***/ }, | ||
5427 | /* 49 */ | ||
5428 | /***/ function(module, exports) { | ||
5429 | |||
5430 | /** | ||
5431 | * Copyright 2013-2015, Facebook, Inc. | ||
5432 | * All rights reserved. | ||
5433 | * | ||
5434 | * This source code is licensed under the BSD-style license found in the | ||
5435 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5436 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5437 | * | ||
5438 | * @providesModule ReactInstanceMap | ||
5439 | */ | ||
5440 | |||
5441 | 'use strict'; | ||
5442 | |||
5443 | /** | ||
5444 | * `ReactInstanceMap` maintains a mapping from a public facing stateful | ||
5445 | * instance (key) and the internal representation (value). This allows public | ||
5446 | * methods to accept the user facing instance as an argument and map them back | ||
5447 | * to internal methods. | ||
5448 | */ | ||
5449 | |||
5450 | // TODO: Replace this with ES6: var ReactInstanceMap = new Map(); | ||
5451 | var ReactInstanceMap = { | ||
5452 | |||
5453 | /** | ||
5454 | * This API should be called `delete` but we'd have to make sure to always | ||
5455 | * transform these to strings for IE support. When this transform is fully | ||
5456 | * supported we can rename it. | ||
5457 | */ | ||
5458 | remove: function (key) { | ||
5459 | key._reactInternalInstance = undefined; | ||
5460 | }, | ||
5461 | |||
5462 | get: function (key) { | ||
5463 | return key._reactInternalInstance; | ||
5464 | }, | ||
5465 | |||
5466 | has: function (key) { | ||
5467 | return key._reactInternalInstance !== undefined; | ||
5468 | }, | ||
5469 | |||
5470 | set: function (key, value) { | ||
5471 | key._reactInternalInstance = value; | ||
5472 | } | ||
5473 | |||
5474 | }; | ||
5475 | |||
5476 | module.exports = ReactInstanceMap; | ||
5477 | |||
5478 | /***/ }, | ||
5479 | /* 50 */ | ||
5480 | /***/ function(module, exports, __webpack_require__) { | ||
5481 | |||
5482 | /** | ||
5483 | * Copyright 2013-2015, Facebook, Inc. | ||
5484 | * All rights reserved. | ||
5485 | * | ||
5486 | * This source code is licensed under the BSD-style license found in the | ||
5487 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5488 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5489 | * | ||
5490 | * @providesModule ReactMarkupChecksum | ||
5491 | */ | ||
5492 | |||
5493 | 'use strict'; | ||
5494 | |||
5495 | var adler32 = __webpack_require__(51); | ||
5496 | |||
5497 | var TAG_END = /\/?>/; | ||
5498 | |||
5499 | var ReactMarkupChecksum = { | ||
5500 | CHECKSUM_ATTR_NAME: 'data-react-checksum', | ||
5501 | |||
5502 | /** | ||
5503 | * @param {string} markup Markup string | ||
5504 | * @return {string} Markup string with checksum attribute attached | ||
5505 | */ | ||
5506 | addChecksumToMarkup: function (markup) { | ||
5507 | var checksum = adler32(markup); | ||
5508 | |||
5509 | // Add checksum (handle both parent tags and self-closing tags) | ||
5510 | return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&'); | ||
5511 | }, | ||
5512 | |||
5513 | /** | ||
5514 | * @param {string} markup to use | ||
5515 | * @param {DOMElement} element root React element | ||
5516 | * @returns {boolean} whether or not the markup is the same | ||
5517 | */ | ||
5518 | canReuseMarkup: function (markup, element) { | ||
5519 | var existingChecksum = element.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME); | ||
5520 | existingChecksum = existingChecksum && parseInt(existingChecksum, 10); | ||
5521 | var markupChecksum = adler32(markup); | ||
5522 | return markupChecksum === existingChecksum; | ||
5523 | } | ||
5524 | }; | ||
5525 | |||
5526 | module.exports = ReactMarkupChecksum; | ||
5527 | |||
5528 | /***/ }, | ||
5529 | /* 51 */ | ||
5530 | /***/ function(module, exports) { | ||
5531 | |||
5532 | /** | ||
5533 | * Copyright 2013-2015, Facebook, Inc. | ||
5534 | * All rights reserved. | ||
5535 | * | ||
5536 | * This source code is licensed under the BSD-style license found in the | ||
5537 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5538 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5539 | * | ||
5540 | * @providesModule adler32 | ||
5541 | */ | ||
5542 | |||
5543 | 'use strict'; | ||
5544 | |||
5545 | var MOD = 65521; | ||
5546 | |||
5547 | // adler32 is not cryptographically strong, and is only used to sanity check that | ||
5548 | // markup generated on the server matches the markup generated on the client. | ||
5549 | // This implementation (a modified version of the SheetJS version) has been optimized | ||
5550 | // for our use case, at the expense of conforming to the adler32 specification | ||
5551 | // for non-ascii inputs. | ||
5552 | function adler32(data) { | ||
5553 | var a = 1; | ||
5554 | var b = 0; | ||
5555 | var i = 0; | ||
5556 | var l = data.length; | ||
5557 | var m = l & ~0x3; | ||
5558 | while (i < m) { | ||
5559 | for (; i < Math.min(i + 4096, m); i += 4) { | ||
5560 | b += (a += data.charCodeAt(i)) + (a += data.charCodeAt(i + 1)) + (a += data.charCodeAt(i + 2)) + (a += data.charCodeAt(i + 3)); | ||
5561 | } | ||
5562 | a %= MOD; | ||
5563 | b %= MOD; | ||
5564 | } | ||
5565 | for (; i < l; i++) { | ||
5566 | b += a += data.charCodeAt(i); | ||
5567 | } | ||
5568 | a %= MOD; | ||
5569 | b %= MOD; | ||
5570 | return a | b << 16; | ||
5571 | } | ||
5572 | |||
5573 | module.exports = adler32; | ||
5574 | |||
5575 | /***/ }, | ||
5576 | /* 52 */ | ||
5577 | /***/ function(module, exports, __webpack_require__) { | ||
5578 | |||
5579 | /** | ||
5580 | * Copyright 2013-2015, Facebook, Inc. | ||
5581 | * All rights reserved. | ||
5582 | * | ||
5583 | * This source code is licensed under the BSD-style license found in the | ||
5584 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5585 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5586 | * | ||
5587 | * @providesModule ReactReconciler | ||
5588 | */ | ||
5589 | |||
5590 | 'use strict'; | ||
5591 | |||
5592 | var ReactRef = __webpack_require__(53); | ||
5593 | |||
5594 | /** | ||
5595 | * Helper to call ReactRef.attachRefs with this composite component, split out | ||
5596 | * to avoid allocations in the transaction mount-ready queue. | ||
5597 | */ | ||
5598 | function attachRefs() { | ||
5599 | ReactRef.attachRefs(this, this._currentElement); | ||
5600 | } | ||
5601 | |||
5602 | var ReactReconciler = { | ||
5603 | |||
5604 | /** | ||
5605 | * Initializes the component, renders markup, and registers event listeners. | ||
5606 | * | ||
5607 | * @param {ReactComponent} internalInstance | ||
5608 | * @param {string} rootID DOM ID of the root node. | ||
5609 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
5610 | * @return {?string} Rendered markup to be inserted into the DOM. | ||
5611 | * @final | ||
5612 | * @internal | ||
5613 | */ | ||
5614 | mountComponent: function (internalInstance, rootID, transaction, context) { | ||
5615 | var markup = internalInstance.mountComponent(rootID, transaction, context); | ||
5616 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) { | ||
5617 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance); | ||
5618 | } | ||
5619 | return markup; | ||
5620 | }, | ||
5621 | |||
5622 | /** | ||
5623 | * Releases any resources allocated by `mountComponent`. | ||
5624 | * | ||
5625 | * @final | ||
5626 | * @internal | ||
5627 | */ | ||
5628 | unmountComponent: function (internalInstance) { | ||
5629 | ReactRef.detachRefs(internalInstance, internalInstance._currentElement); | ||
5630 | internalInstance.unmountComponent(); | ||
5631 | }, | ||
5632 | |||
5633 | /** | ||
5634 | * Update a component using a new element. | ||
5635 | * | ||
5636 | * @param {ReactComponent} internalInstance | ||
5637 | * @param {ReactElement} nextElement | ||
5638 | * @param {ReactReconcileTransaction} transaction | ||
5639 | * @param {object} context | ||
5640 | * @internal | ||
5641 | */ | ||
5642 | receiveComponent: function (internalInstance, nextElement, transaction, context) { | ||
5643 | var prevElement = internalInstance._currentElement; | ||
5644 | |||
5645 | if (nextElement === prevElement && context === internalInstance._context) { | ||
5646 | // Since elements are immutable after the owner is rendered, | ||
5647 | // we can do a cheap identity compare here to determine if this is a | ||
5648 | // superfluous reconcile. It's possible for state to be mutable but such | ||
5649 | // change should trigger an update of the owner which would recreate | ||
5650 | // the element. We explicitly check for the existence of an owner since | ||
5651 | // it's possible for an element created outside a composite to be | ||
5652 | // deeply mutated and reused. | ||
5653 | |||
5654 | // TODO: Bailing out early is just a perf optimization right? | ||
5655 | // TODO: Removing the return statement should affect correctness? | ||
5656 | return; | ||
5657 | } | ||
5658 | |||
5659 | var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement); | ||
5660 | |||
5661 | if (refsChanged) { | ||
5662 | ReactRef.detachRefs(internalInstance, prevElement); | ||
5663 | } | ||
5664 | |||
5665 | internalInstance.receiveComponent(nextElement, transaction, context); | ||
5666 | |||
5667 | if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) { | ||
5668 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance); | ||
5669 | } | ||
5670 | }, | ||
5671 | |||
5672 | /** | ||
5673 | * Flush any dirty changes in a component. | ||
5674 | * | ||
5675 | * @param {ReactComponent} internalInstance | ||
5676 | * @param {ReactReconcileTransaction} transaction | ||
5677 | * @internal | ||
5678 | */ | ||
5679 | performUpdateIfNecessary: function (internalInstance, transaction) { | ||
5680 | internalInstance.performUpdateIfNecessary(transaction); | ||
5681 | } | ||
5682 | |||
5683 | }; | ||
5684 | |||
5685 | module.exports = ReactReconciler; | ||
5686 | |||
5687 | /***/ }, | ||
5688 | /* 53 */ | ||
5689 | /***/ function(module, exports, __webpack_require__) { | ||
5690 | |||
5691 | /** | ||
5692 | * Copyright 2013-2015, Facebook, Inc. | ||
5693 | * All rights reserved. | ||
5694 | * | ||
5695 | * This source code is licensed under the BSD-style license found in the | ||
5696 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5697 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5698 | * | ||
5699 | * @providesModule ReactRef | ||
5700 | */ | ||
5701 | |||
5702 | 'use strict'; | ||
5703 | |||
5704 | var ReactOwner = __webpack_require__(54); | ||
5705 | |||
5706 | var ReactRef = {}; | ||
5707 | |||
5708 | function attachRef(ref, component, owner) { | ||
5709 | if (typeof ref === 'function') { | ||
5710 | ref(component.getPublicInstance()); | ||
5711 | } else { | ||
5712 | // Legacy ref | ||
5713 | ReactOwner.addComponentAsRefTo(component, ref, owner); | ||
5714 | } | ||
5715 | } | ||
5716 | |||
5717 | function detachRef(ref, component, owner) { | ||
5718 | if (typeof ref === 'function') { | ||
5719 | ref(null); | ||
5720 | } else { | ||
5721 | // Legacy ref | ||
5722 | ReactOwner.removeComponentAsRefFrom(component, ref, owner); | ||
5723 | } | ||
5724 | } | ||
5725 | |||
5726 | ReactRef.attachRefs = function (instance, element) { | ||
5727 | if (element === null || element === false) { | ||
5728 | return; | ||
5729 | } | ||
5730 | var ref = element.ref; | ||
5731 | if (ref != null) { | ||
5732 | attachRef(ref, instance, element._owner); | ||
5733 | } | ||
5734 | }; | ||
5735 | |||
5736 | ReactRef.shouldUpdateRefs = function (prevElement, nextElement) { | ||
5737 | // If either the owner or a `ref` has changed, make sure the newest owner | ||
5738 | // has stored a reference to `this`, and the previous owner (if different) | ||
5739 | // has forgotten the reference to `this`. We use the element instead | ||
5740 | // of the public this.props because the post processing cannot determine | ||
5741 | // a ref. The ref conceptually lives on the element. | ||
5742 | |||
5743 | // TODO: Should this even be possible? The owner cannot change because | ||
5744 | // it's forbidden by shouldUpdateReactComponent. The ref can change | ||
5745 | // if you swap the keys of but not the refs. Reconsider where this check | ||
5746 | // is made. It probably belongs where the key checking and | ||
5747 | // instantiateReactComponent is done. | ||
5748 | |||
5749 | var prevEmpty = prevElement === null || prevElement === false; | ||
5750 | var nextEmpty = nextElement === null || nextElement === false; | ||
5751 | |||
5752 | return( | ||
5753 | // This has a few false positives w/r/t empty components. | ||
5754 | prevEmpty || nextEmpty || nextElement._owner !== prevElement._owner || nextElement.ref !== prevElement.ref | ||
5755 | ); | ||
5756 | }; | ||
5757 | |||
5758 | ReactRef.detachRefs = function (instance, element) { | ||
5759 | if (element === null || element === false) { | ||
5760 | return; | ||
5761 | } | ||
5762 | var ref = element.ref; | ||
5763 | if (ref != null) { | ||
5764 | detachRef(ref, instance, element._owner); | ||
5765 | } | ||
5766 | }; | ||
5767 | |||
5768 | module.exports = ReactRef; | ||
5769 | |||
5770 | /***/ }, | ||
5771 | /* 54 */ | ||
5772 | /***/ function(module, exports, __webpack_require__) { | ||
5773 | |||
5774 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
5775 | * Copyright 2013-2015, Facebook, Inc. | ||
5776 | * All rights reserved. | ||
5777 | * | ||
5778 | * This source code is licensed under the BSD-style license found in the | ||
5779 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5780 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5781 | * | ||
5782 | * @providesModule ReactOwner | ||
5783 | */ | ||
5784 | |||
5785 | 'use strict'; | ||
5786 | |||
5787 | var invariant = __webpack_require__(15); | ||
5788 | |||
5789 | /** | ||
5790 | * ReactOwners are capable of storing references to owned components. | ||
5791 | * | ||
5792 | * All components are capable of //being// referenced by owner components, but | ||
5793 | * only ReactOwner components are capable of //referencing// owned components. | ||
5794 | * The named reference is known as a "ref". | ||
5795 | * | ||
5796 | * Refs are available when mounted and updated during reconciliation. | ||
5797 | * | ||
5798 | * var MyComponent = React.createClass({ | ||
5799 | * render: function() { | ||
5800 | * return ( | ||
5801 | * <div onClick={this.handleClick}> | ||
5802 | * <CustomComponent ref="custom" /> | ||
5803 | * </div> | ||
5804 | * ); | ||
5805 | * }, | ||
5806 | * handleClick: function() { | ||
5807 | * this.refs.custom.handleClick(); | ||
5808 | * }, | ||
5809 | * componentDidMount: function() { | ||
5810 | * this.refs.custom.initialize(); | ||
5811 | * } | ||
5812 | * }); | ||
5813 | * | ||
5814 | * Refs should rarely be used. When refs are used, they should only be done to | ||
5815 | * control data that is not handled by React's data flow. | ||
5816 | * | ||
5817 | * @class ReactOwner | ||
5818 | */ | ||
5819 | var ReactOwner = { | ||
5820 | |||
5821 | /** | ||
5822 | * @param {?object} object | ||
5823 | * @return {boolean} True if `object` is a valid owner. | ||
5824 | * @final | ||
5825 | */ | ||
5826 | isValidOwner: function (object) { | ||
5827 | return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function'); | ||
5828 | }, | ||
5829 | |||
5830 | /** | ||
5831 | * Adds a component by ref to an owner component. | ||
5832 | * | ||
5833 | * @param {ReactComponent} component Component to reference. | ||
5834 | * @param {string} ref Name by which to refer to the component. | ||
5835 | * @param {ReactOwner} owner Component on which to record the ref. | ||
5836 | * @final | ||
5837 | * @internal | ||
5838 | */ | ||
5839 | addComponentAsRefTo: function (component, ref, owner) { | ||
5840 | !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined; | ||
5841 | owner.attachRef(ref, component); | ||
5842 | }, | ||
5843 | |||
5844 | /** | ||
5845 | * Removes a component by ref from an owner component. | ||
5846 | * | ||
5847 | * @param {ReactComponent} component Component to dereference. | ||
5848 | * @param {string} ref Name of the ref to remove. | ||
5849 | * @param {ReactOwner} owner Component on which the ref is recorded. | ||
5850 | * @final | ||
5851 | * @internal | ||
5852 | */ | ||
5853 | removeComponentAsRefFrom: function (component, ref, owner) { | ||
5854 | !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined; | ||
5855 | // Check that `component` is still the current ref because we do not want to | ||
5856 | // detach the ref if another component stole it. | ||
5857 | if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) { | ||
5858 | owner.detachRef(ref); | ||
5859 | } | ||
5860 | } | ||
5861 | |||
5862 | }; | ||
5863 | |||
5864 | module.exports = ReactOwner; | ||
5865 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
5866 | |||
5867 | /***/ }, | ||
5868 | /* 55 */ | ||
5869 | /***/ function(module, exports, __webpack_require__) { | ||
5870 | |||
5871 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
5872 | * Copyright 2015, Facebook, Inc. | ||
5873 | * All rights reserved. | ||
5874 | * | ||
5875 | * This source code is licensed under the BSD-style license found in the | ||
5876 | * LICENSE file in the root directory of this source tree. An additional grant | ||
5877 | * of patent rights can be found in the PATENTS file in the same directory. | ||
5878 | * | ||
5879 | * @providesModule ReactUpdateQueue | ||
5880 | */ | ||
5881 | |||
5882 | 'use strict'; | ||
5883 | |||
5884 | var ReactCurrentOwner = __webpack_require__(7); | ||
5885 | var ReactElement = __webpack_require__(44); | ||
5886 | var ReactInstanceMap = __webpack_require__(49); | ||
5887 | var ReactUpdates = __webpack_require__(56); | ||
5888 | |||
5889 | var assign = __webpack_require__(41); | ||
5890 | var invariant = __webpack_require__(15); | ||
5891 | var warning = __webpack_require__(27); | ||
5892 | |||
5893 | function enqueueUpdate(internalInstance) { | ||
5894 | ReactUpdates.enqueueUpdate(internalInstance); | ||
5895 | } | ||
5896 | |||
5897 | function getInternalInstanceReadyForUpdate(publicInstance, callerName) { | ||
5898 | var internalInstance = ReactInstanceMap.get(publicInstance); | ||
5899 | if (!internalInstance) { | ||
5900 | if (process.env.NODE_ENV !== 'production') { | ||
5901 | // Only warn when we have a callerName. Otherwise we should be silent. | ||
5902 | // We're probably calling from enqueueCallback. We don't want to warn | ||
5903 | // there because we already warned for the corresponding lifecycle method. | ||
5904 | process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : undefined; | ||
5905 | } | ||
5906 | return null; | ||
5907 | } | ||
5908 | |||
5909 | if (process.env.NODE_ENV !== 'production') { | ||
5910 | process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined; | ||
5911 | } | ||
5912 | |||
5913 | return internalInstance; | ||
5914 | } | ||
5915 | |||
5916 | /** | ||
5917 | * ReactUpdateQueue allows for state updates to be scheduled into a later | ||
5918 | * reconciliation step. | ||
5919 | */ | ||
5920 | var ReactUpdateQueue = { | ||
5921 | |||
5922 | /** | ||
5923 | * Checks whether or not this composite component is mounted. | ||
5924 | * @param {ReactClass} publicInstance The instance we want to test. | ||
5925 | * @return {boolean} True if mounted, false otherwise. | ||
5926 | * @protected | ||
5927 | * @final | ||
5928 | */ | ||
5929 | isMounted: function (publicInstance) { | ||
5930 | if (process.env.NODE_ENV !== 'production') { | ||
5931 | var owner = ReactCurrentOwner.current; | ||
5932 | if (owner !== null) { | ||
5933 | process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined; | ||
5934 | owner._warnedAboutRefsInRender = true; | ||
5935 | } | ||
5936 | } | ||
5937 | var internalInstance = ReactInstanceMap.get(publicInstance); | ||
5938 | if (internalInstance) { | ||
5939 | // During componentWillMount and render this will still be null but after | ||
5940 | // that will always render to something. At least for now. So we can use | ||
5941 | // this hack. | ||
5942 | return !!internalInstance._renderedComponent; | ||
5943 | } else { | ||
5944 | return false; | ||
5945 | } | ||
5946 | }, | ||
5947 | |||
5948 | /** | ||
5949 | * Enqueue a callback that will be executed after all the pending updates | ||
5950 | * have processed. | ||
5951 | * | ||
5952 | * @param {ReactClass} publicInstance The instance to use as `this` context. | ||
5953 | * @param {?function} callback Called after state is updated. | ||
5954 | * @internal | ||
5955 | */ | ||
5956 | enqueueCallback: function (publicInstance, callback) { | ||
5957 | !(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined; | ||
5958 | var internalInstance = getInternalInstanceReadyForUpdate(publicInstance); | ||
5959 | |||
5960 | // Previously we would throw an error if we didn't have an internal | ||
5961 | // instance. Since we want to make it a no-op instead, we mirror the same | ||
5962 | // behavior we have in other enqueue* methods. | ||
5963 | // We also need to ignore callbacks in componentWillMount. See | ||
5964 | // enqueueUpdates. | ||
5965 | if (!internalInstance) { | ||
5966 | return null; | ||
5967 | } | ||
5968 | |||
5969 | if (internalInstance._pendingCallbacks) { | ||
5970 | internalInstance._pendingCallbacks.push(callback); | ||
5971 | } else { | ||
5972 | internalInstance._pendingCallbacks = [callback]; | ||
5973 | } | ||
5974 | // TODO: The callback here is ignored when setState is called from | ||
5975 | // componentWillMount. Either fix it or disallow doing so completely in | ||
5976 | // favor of getInitialState. Alternatively, we can disallow | ||
5977 | // componentWillMount during server-side rendering. | ||
5978 | enqueueUpdate(internalInstance); | ||
5979 | }, | ||
5980 | |||
5981 | enqueueCallbackInternal: function (internalInstance, callback) { | ||
5982 | !(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined; | ||
5983 | if (internalInstance._pendingCallbacks) { | ||
5984 | internalInstance._pendingCallbacks.push(callback); | ||
5985 | } else { | ||
5986 | internalInstance._pendingCallbacks = [callback]; | ||
5987 | } | ||
5988 | enqueueUpdate(internalInstance); | ||
5989 | }, | ||
5990 | |||
5991 | /** | ||
5992 | * Forces an update. This should only be invoked when it is known with | ||
5993 | * certainty that we are **not** in a DOM transaction. | ||
5994 | * | ||
5995 | * You may want to call this when you know that some deeper aspect of the | ||
5996 | * component's state has changed but `setState` was not called. | ||
5997 | * | ||
5998 | * This will not invoke `shouldComponentUpdate`, but it will invoke | ||
5999 | * `componentWillUpdate` and `componentDidUpdate`. | ||
6000 | * | ||
6001 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
6002 | * @internal | ||
6003 | */ | ||
6004 | enqueueForceUpdate: function (publicInstance) { | ||
6005 | var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'forceUpdate'); | ||
6006 | |||
6007 | if (!internalInstance) { | ||
6008 | return; | ||
6009 | } | ||
6010 | |||
6011 | internalInstance._pendingForceUpdate = true; | ||
6012 | |||
6013 | enqueueUpdate(internalInstance); | ||
6014 | }, | ||
6015 | |||
6016 | /** | ||
6017 | * Replaces all of the state. Always use this or `setState` to mutate state. | ||
6018 | * You should treat `this.state` as immutable. | ||
6019 | * | ||
6020 | * There is no guarantee that `this.state` will be immediately updated, so | ||
6021 | * accessing `this.state` after calling this method may return the old value. | ||
6022 | * | ||
6023 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
6024 | * @param {object} completeState Next state. | ||
6025 | * @internal | ||
6026 | */ | ||
6027 | enqueueReplaceState: function (publicInstance, completeState) { | ||
6028 | var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState'); | ||
6029 | |||
6030 | if (!internalInstance) { | ||
6031 | return; | ||
6032 | } | ||
6033 | |||
6034 | internalInstance._pendingStateQueue = [completeState]; | ||
6035 | internalInstance._pendingReplaceState = true; | ||
6036 | |||
6037 | enqueueUpdate(internalInstance); | ||
6038 | }, | ||
6039 | |||
6040 | /** | ||
6041 | * Sets a subset of the state. This only exists because _pendingState is | ||
6042 | * internal. This provides a merging strategy that is not available to deep | ||
6043 | * properties which is confusing. TODO: Expose pendingState or don't use it | ||
6044 | * during the merge. | ||
6045 | * | ||
6046 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
6047 | * @param {object} partialState Next partial state to be merged with state. | ||
6048 | * @internal | ||
6049 | */ | ||
6050 | enqueueSetState: function (publicInstance, partialState) { | ||
6051 | var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setState'); | ||
6052 | |||
6053 | if (!internalInstance) { | ||
6054 | return; | ||
6055 | } | ||
6056 | |||
6057 | var queue = internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = []); | ||
6058 | queue.push(partialState); | ||
6059 | |||
6060 | enqueueUpdate(internalInstance); | ||
6061 | }, | ||
6062 | |||
6063 | /** | ||
6064 | * Sets a subset of the props. | ||
6065 | * | ||
6066 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
6067 | * @param {object} partialProps Subset of the next props. | ||
6068 | * @internal | ||
6069 | */ | ||
6070 | enqueueSetProps: function (publicInstance, partialProps) { | ||
6071 | var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setProps'); | ||
6072 | if (!internalInstance) { | ||
6073 | return; | ||
6074 | } | ||
6075 | ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps); | ||
6076 | }, | ||
6077 | |||
6078 | enqueueSetPropsInternal: function (internalInstance, partialProps) { | ||
6079 | var topLevelWrapper = internalInstance._topLevelWrapper; | ||
6080 | !topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setProps(...): You called `setProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined; | ||
6081 | |||
6082 | // Merge with the pending element if it exists, otherwise with existing | ||
6083 | // element props. | ||
6084 | var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement; | ||
6085 | var element = wrapElement.props; | ||
6086 | var props = assign({}, element.props, partialProps); | ||
6087 | topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props)); | ||
6088 | |||
6089 | enqueueUpdate(topLevelWrapper); | ||
6090 | }, | ||
6091 | |||
6092 | /** | ||
6093 | * Replaces all of the props. | ||
6094 | * | ||
6095 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
6096 | * @param {object} props New props. | ||
6097 | * @internal | ||
6098 | */ | ||
6099 | enqueueReplaceProps: function (publicInstance, props) { | ||
6100 | var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceProps'); | ||
6101 | if (!internalInstance) { | ||
6102 | return; | ||
6103 | } | ||
6104 | ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props); | ||
6105 | }, | ||
6106 | |||
6107 | enqueueReplacePropsInternal: function (internalInstance, props) { | ||
6108 | var topLevelWrapper = internalInstance._topLevelWrapper; | ||
6109 | !topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'replaceProps(...): You called `replaceProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined; | ||
6110 | |||
6111 | // Merge with the pending element if it exists, otherwise with existing | ||
6112 | // element props. | ||
6113 | var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement; | ||
6114 | var element = wrapElement.props; | ||
6115 | topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props)); | ||
6116 | |||
6117 | enqueueUpdate(topLevelWrapper); | ||
6118 | }, | ||
6119 | |||
6120 | enqueueElementInternal: function (internalInstance, newElement) { | ||
6121 | internalInstance._pendingElement = newElement; | ||
6122 | enqueueUpdate(internalInstance); | ||
6123 | } | ||
6124 | |||
6125 | }; | ||
6126 | |||
6127 | module.exports = ReactUpdateQueue; | ||
6128 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
6129 | |||
6130 | /***/ }, | ||
6131 | /* 56 */ | ||
6132 | /***/ function(module, exports, __webpack_require__) { | ||
6133 | |||
6134 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
6135 | * Copyright 2013-2015, Facebook, Inc. | ||
6136 | * All rights reserved. | ||
6137 | * | ||
6138 | * This source code is licensed under the BSD-style license found in the | ||
6139 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6140 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6141 | * | ||
6142 | * @providesModule ReactUpdates | ||
6143 | */ | ||
6144 | |||
6145 | 'use strict'; | ||
6146 | |||
6147 | var CallbackQueue = __webpack_require__(57); | ||
6148 | var PooledClass = __webpack_require__(58); | ||
6149 | var ReactPerf = __webpack_require__(20); | ||
6150 | var ReactReconciler = __webpack_require__(52); | ||
6151 | var Transaction = __webpack_require__(59); | ||
6152 | |||
6153 | var assign = __webpack_require__(41); | ||
6154 | var invariant = __webpack_require__(15); | ||
6155 | |||
6156 | var dirtyComponents = []; | ||
6157 | var asapCallbackQueue = CallbackQueue.getPooled(); | ||
6158 | var asapEnqueued = false; | ||
6159 | |||
6160 | var batchingStrategy = null; | ||
6161 | |||
6162 | function ensureInjected() { | ||
6163 | !(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must inject a reconcile transaction class and batching ' + 'strategy') : invariant(false) : undefined; | ||
6164 | } | ||
6165 | |||
6166 | var NESTED_UPDATES = { | ||
6167 | initialize: function () { | ||
6168 | this.dirtyComponentsLength = dirtyComponents.length; | ||
6169 | }, | ||
6170 | close: function () { | ||
6171 | if (this.dirtyComponentsLength !== dirtyComponents.length) { | ||
6172 | // Additional updates were enqueued by componentDidUpdate handlers or | ||
6173 | // similar; before our own UPDATE_QUEUEING wrapper closes, we want to run | ||
6174 | // these new updates so that if A's componentDidUpdate calls setState on | ||
6175 | // B, B will update before the callback A's updater provided when calling | ||
6176 | // setState. | ||
6177 | dirtyComponents.splice(0, this.dirtyComponentsLength); | ||
6178 | flushBatchedUpdates(); | ||
6179 | } else { | ||
6180 | dirtyComponents.length = 0; | ||
6181 | } | ||
6182 | } | ||
6183 | }; | ||
6184 | |||
6185 | var UPDATE_QUEUEING = { | ||
6186 | initialize: function () { | ||
6187 | this.callbackQueue.reset(); | ||
6188 | }, | ||
6189 | close: function () { | ||
6190 | this.callbackQueue.notifyAll(); | ||
6191 | } | ||
6192 | }; | ||
6193 | |||
6194 | var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING]; | ||
6195 | |||
6196 | function ReactUpdatesFlushTransaction() { | ||
6197 | this.reinitializeTransaction(); | ||
6198 | this.dirtyComponentsLength = null; | ||
6199 | this.callbackQueue = CallbackQueue.getPooled(); | ||
6200 | this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled( /* forceHTML */false); | ||
6201 | } | ||
6202 | |||
6203 | assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, { | ||
6204 | getTransactionWrappers: function () { | ||
6205 | return TRANSACTION_WRAPPERS; | ||
6206 | }, | ||
6207 | |||
6208 | destructor: function () { | ||
6209 | this.dirtyComponentsLength = null; | ||
6210 | CallbackQueue.release(this.callbackQueue); | ||
6211 | this.callbackQueue = null; | ||
6212 | ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction); | ||
6213 | this.reconcileTransaction = null; | ||
6214 | }, | ||
6215 | |||
6216 | perform: function (method, scope, a) { | ||
6217 | // Essentially calls `this.reconcileTransaction.perform(method, scope, a)` | ||
6218 | // with this transaction's wrappers around it. | ||
6219 | return Transaction.Mixin.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a); | ||
6220 | } | ||
6221 | }); | ||
6222 | |||
6223 | PooledClass.addPoolingTo(ReactUpdatesFlushTransaction); | ||
6224 | |||
6225 | function batchedUpdates(callback, a, b, c, d, e) { | ||
6226 | ensureInjected(); | ||
6227 | batchingStrategy.batchedUpdates(callback, a, b, c, d, e); | ||
6228 | } | ||
6229 | |||
6230 | /** | ||
6231 | * Array comparator for ReactComponents by mount ordering. | ||
6232 | * | ||
6233 | * @param {ReactComponent} c1 first component you're comparing | ||
6234 | * @param {ReactComponent} c2 second component you're comparing | ||
6235 | * @return {number} Return value usable by Array.prototype.sort(). | ||
6236 | */ | ||
6237 | function mountOrderComparator(c1, c2) { | ||
6238 | return c1._mountOrder - c2._mountOrder; | ||
6239 | } | ||
6240 | |||
6241 | function runBatchedUpdates(transaction) { | ||
6242 | var len = transaction.dirtyComponentsLength; | ||
6243 | !(len === dirtyComponents.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected flush transaction\'s stored dirty-components length (%s) to ' + 'match dirty-components array length (%s).', len, dirtyComponents.length) : invariant(false) : undefined; | ||
6244 | |||
6245 | // Since reconciling a component higher in the owner hierarchy usually (not | ||
6246 | // always -- see shouldComponentUpdate()) will reconcile children, reconcile | ||
6247 | // them before their children by sorting the array. | ||
6248 | dirtyComponents.sort(mountOrderComparator); | ||
6249 | |||
6250 | for (var i = 0; i < len; i++) { | ||
6251 | // If a component is unmounted before pending changes apply, it will still | ||
6252 | // be here, but we assume that it has cleared its _pendingCallbacks and | ||
6253 | // that performUpdateIfNecessary is a noop. | ||
6254 | var component = dirtyComponents[i]; | ||
6255 | |||
6256 | // If performUpdateIfNecessary happens to enqueue any new updates, we | ||
6257 | // shouldn't execute the callbacks until the next render happens, so | ||
6258 | // stash the callbacks first | ||
6259 | var callbacks = component._pendingCallbacks; | ||
6260 | component._pendingCallbacks = null; | ||
6261 | |||
6262 | ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction); | ||
6263 | |||
6264 | if (callbacks) { | ||
6265 | for (var j = 0; j < callbacks.length; j++) { | ||
6266 | transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance()); | ||
6267 | } | ||
6268 | } | ||
6269 | } | ||
6270 | } | ||
6271 | |||
6272 | var flushBatchedUpdates = function () { | ||
6273 | // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents | ||
6274 | // array and perform any updates enqueued by mount-ready handlers (i.e., | ||
6275 | // componentDidUpdate) but we need to check here too in order to catch | ||
6276 | // updates enqueued by setState callbacks and asap calls. | ||
6277 | while (dirtyComponents.length || asapEnqueued) { | ||
6278 | if (dirtyComponents.length) { | ||
6279 | var transaction = ReactUpdatesFlushTransaction.getPooled(); | ||
6280 | transaction.perform(runBatchedUpdates, null, transaction); | ||
6281 | ReactUpdatesFlushTransaction.release(transaction); | ||
6282 | } | ||
6283 | |||
6284 | if (asapEnqueued) { | ||
6285 | asapEnqueued = false; | ||
6286 | var queue = asapCallbackQueue; | ||
6287 | asapCallbackQueue = CallbackQueue.getPooled(); | ||
6288 | queue.notifyAll(); | ||
6289 | CallbackQueue.release(queue); | ||
6290 | } | ||
6291 | } | ||
6292 | }; | ||
6293 | flushBatchedUpdates = ReactPerf.measure('ReactUpdates', 'flushBatchedUpdates', flushBatchedUpdates); | ||
6294 | |||
6295 | /** | ||
6296 | * Mark a component as needing a rerender, adding an optional callback to a | ||
6297 | * list of functions which will be executed once the rerender occurs. | ||
6298 | */ | ||
6299 | function enqueueUpdate(component) { | ||
6300 | ensureInjected(); | ||
6301 | |||
6302 | // Various parts of our code (such as ReactCompositeComponent's | ||
6303 | // _renderValidatedComponent) assume that calls to render aren't nested; | ||
6304 | // verify that that's the case. (This is called by each top-level update | ||
6305 | // function, like setProps, setState, forceUpdate, etc.; creation and | ||
6306 | // destruction of top-level components is guarded in ReactMount.) | ||
6307 | |||
6308 | if (!batchingStrategy.isBatchingUpdates) { | ||
6309 | batchingStrategy.batchedUpdates(enqueueUpdate, component); | ||
6310 | return; | ||
6311 | } | ||
6312 | |||
6313 | dirtyComponents.push(component); | ||
6314 | } | ||
6315 | |||
6316 | /** | ||
6317 | * Enqueue a callback to be run at the end of the current batching cycle. Throws | ||
6318 | * if no updates are currently being performed. | ||
6319 | */ | ||
6320 | function asap(callback, context) { | ||
6321 | !batchingStrategy.isBatchingUpdates ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' + 'updates are not being batched.') : invariant(false) : undefined; | ||
6322 | asapCallbackQueue.enqueue(callback, context); | ||
6323 | asapEnqueued = true; | ||
6324 | } | ||
6325 | |||
6326 | var ReactUpdatesInjection = { | ||
6327 | injectReconcileTransaction: function (ReconcileTransaction) { | ||
6328 | !ReconcileTransaction ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a reconcile transaction class') : invariant(false) : undefined; | ||
6329 | ReactUpdates.ReactReconcileTransaction = ReconcileTransaction; | ||
6330 | }, | ||
6331 | |||
6332 | injectBatchingStrategy: function (_batchingStrategy) { | ||
6333 | !_batchingStrategy ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batching strategy') : invariant(false) : undefined; | ||
6334 | !(typeof _batchingStrategy.batchedUpdates === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batchedUpdates() function') : invariant(false) : undefined; | ||
6335 | !(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide an isBatchingUpdates boolean attribute') : invariant(false) : undefined; | ||
6336 | batchingStrategy = _batchingStrategy; | ||
6337 | } | ||
6338 | }; | ||
6339 | |||
6340 | var ReactUpdates = { | ||
6341 | /** | ||
6342 | * React references `ReactReconcileTransaction` using this property in order | ||
6343 | * to allow dependency injection. | ||
6344 | * | ||
6345 | * @internal | ||
6346 | */ | ||
6347 | ReactReconcileTransaction: null, | ||
6348 | |||
6349 | batchedUpdates: batchedUpdates, | ||
6350 | enqueueUpdate: enqueueUpdate, | ||
6351 | flushBatchedUpdates: flushBatchedUpdates, | ||
6352 | injection: ReactUpdatesInjection, | ||
6353 | asap: asap | ||
6354 | }; | ||
6355 | |||
6356 | module.exports = ReactUpdates; | ||
6357 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
6358 | |||
6359 | /***/ }, | ||
6360 | /* 57 */ | ||
6361 | /***/ function(module, exports, __webpack_require__) { | ||
6362 | |||
6363 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
6364 | * Copyright 2013-2015, Facebook, Inc. | ||
6365 | * All rights reserved. | ||
6366 | * | ||
6367 | * This source code is licensed under the BSD-style license found in the | ||
6368 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6369 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6370 | * | ||
6371 | * @providesModule CallbackQueue | ||
6372 | */ | ||
6373 | |||
6374 | 'use strict'; | ||
6375 | |||
6376 | var PooledClass = __webpack_require__(58); | ||
6377 | |||
6378 | var assign = __webpack_require__(41); | ||
6379 | var invariant = __webpack_require__(15); | ||
6380 | |||
6381 | /** | ||
6382 | * A specialized pseudo-event module to help keep track of components waiting to | ||
6383 | * be notified when their DOM representations are available for use. | ||
6384 | * | ||
6385 | * This implements `PooledClass`, so you should never need to instantiate this. | ||
6386 | * Instead, use `CallbackQueue.getPooled()`. | ||
6387 | * | ||
6388 | * @class ReactMountReady | ||
6389 | * @implements PooledClass | ||
6390 | * @internal | ||
6391 | */ | ||
6392 | function CallbackQueue() { | ||
6393 | this._callbacks = null; | ||
6394 | this._contexts = null; | ||
6395 | } | ||
6396 | |||
6397 | assign(CallbackQueue.prototype, { | ||
6398 | |||
6399 | /** | ||
6400 | * Enqueues a callback to be invoked when `notifyAll` is invoked. | ||
6401 | * | ||
6402 | * @param {function} callback Invoked when `notifyAll` is invoked. | ||
6403 | * @param {?object} context Context to call `callback` with. | ||
6404 | * @internal | ||
6405 | */ | ||
6406 | enqueue: function (callback, context) { | ||
6407 | this._callbacks = this._callbacks || []; | ||
6408 | this._contexts = this._contexts || []; | ||
6409 | this._callbacks.push(callback); | ||
6410 | this._contexts.push(context); | ||
6411 | }, | ||
6412 | |||
6413 | /** | ||
6414 | * Invokes all enqueued callbacks and clears the queue. This is invoked after | ||
6415 | * the DOM representation of a component has been created or updated. | ||
6416 | * | ||
6417 | * @internal | ||
6418 | */ | ||
6419 | notifyAll: function () { | ||
6420 | var callbacks = this._callbacks; | ||
6421 | var contexts = this._contexts; | ||
6422 | if (callbacks) { | ||
6423 | !(callbacks.length === contexts.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Mismatched list of contexts in callback queue') : invariant(false) : undefined; | ||
6424 | this._callbacks = null; | ||
6425 | this._contexts = null; | ||
6426 | for (var i = 0; i < callbacks.length; i++) { | ||
6427 | callbacks[i].call(contexts[i]); | ||
6428 | } | ||
6429 | callbacks.length = 0; | ||
6430 | contexts.length = 0; | ||
6431 | } | ||
6432 | }, | ||
6433 | |||
6434 | /** | ||
6435 | * Resets the internal queue. | ||
6436 | * | ||
6437 | * @internal | ||
6438 | */ | ||
6439 | reset: function () { | ||
6440 | this._callbacks = null; | ||
6441 | this._contexts = null; | ||
6442 | }, | ||
6443 | |||
6444 | /** | ||
6445 | * `PooledClass` looks for this. | ||
6446 | */ | ||
6447 | destructor: function () { | ||
6448 | this.reset(); | ||
6449 | } | ||
6450 | |||
6451 | }); | ||
6452 | |||
6453 | PooledClass.addPoolingTo(CallbackQueue); | ||
6454 | |||
6455 | module.exports = CallbackQueue; | ||
6456 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
6457 | |||
6458 | /***/ }, | ||
6459 | /* 58 */ | ||
6460 | /***/ function(module, exports, __webpack_require__) { | ||
6461 | |||
6462 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
6463 | * Copyright 2013-2015, Facebook, Inc. | ||
6464 | * All rights reserved. | ||
6465 | * | ||
6466 | * This source code is licensed under the BSD-style license found in the | ||
6467 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6468 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6469 | * | ||
6470 | * @providesModule PooledClass | ||
6471 | */ | ||
6472 | |||
6473 | 'use strict'; | ||
6474 | |||
6475 | var invariant = __webpack_require__(15); | ||
6476 | |||
6477 | /** | ||
6478 | * Static poolers. Several custom versions for each potential number of | ||
6479 | * arguments. A completely generic pooler is easy to implement, but would | ||
6480 | * require accessing the `arguments` object. In each of these, `this` refers to | ||
6481 | * the Class itself, not an instance. If any others are needed, simply add them | ||
6482 | * here, or in their own files. | ||
6483 | */ | ||
6484 | var oneArgumentPooler = function (copyFieldsFrom) { | ||
6485 | var Klass = this; | ||
6486 | if (Klass.instancePool.length) { | ||
6487 | var instance = Klass.instancePool.pop(); | ||
6488 | Klass.call(instance, copyFieldsFrom); | ||
6489 | return instance; | ||
6490 | } else { | ||
6491 | return new Klass(copyFieldsFrom); | ||
6492 | } | ||
6493 | }; | ||
6494 | |||
6495 | var twoArgumentPooler = function (a1, a2) { | ||
6496 | var Klass = this; | ||
6497 | if (Klass.instancePool.length) { | ||
6498 | var instance = Klass.instancePool.pop(); | ||
6499 | Klass.call(instance, a1, a2); | ||
6500 | return instance; | ||
6501 | } else { | ||
6502 | return new Klass(a1, a2); | ||
6503 | } | ||
6504 | }; | ||
6505 | |||
6506 | var threeArgumentPooler = function (a1, a2, a3) { | ||
6507 | var Klass = this; | ||
6508 | if (Klass.instancePool.length) { | ||
6509 | var instance = Klass.instancePool.pop(); | ||
6510 | Klass.call(instance, a1, a2, a3); | ||
6511 | return instance; | ||
6512 | } else { | ||
6513 | return new Klass(a1, a2, a3); | ||
6514 | } | ||
6515 | }; | ||
6516 | |||
6517 | var fourArgumentPooler = function (a1, a2, a3, a4) { | ||
6518 | var Klass = this; | ||
6519 | if (Klass.instancePool.length) { | ||
6520 | var instance = Klass.instancePool.pop(); | ||
6521 | Klass.call(instance, a1, a2, a3, a4); | ||
6522 | return instance; | ||
6523 | } else { | ||
6524 | return new Klass(a1, a2, a3, a4); | ||
6525 | } | ||
6526 | }; | ||
6527 | |||
6528 | var fiveArgumentPooler = function (a1, a2, a3, a4, a5) { | ||
6529 | var Klass = this; | ||
6530 | if (Klass.instancePool.length) { | ||
6531 | var instance = Klass.instancePool.pop(); | ||
6532 | Klass.call(instance, a1, a2, a3, a4, a5); | ||
6533 | return instance; | ||
6534 | } else { | ||
6535 | return new Klass(a1, a2, a3, a4, a5); | ||
6536 | } | ||
6537 | }; | ||
6538 | |||
6539 | var standardReleaser = function (instance) { | ||
6540 | var Klass = this; | ||
6541 | !(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : invariant(false) : undefined; | ||
6542 | instance.destructor(); | ||
6543 | if (Klass.instancePool.length < Klass.poolSize) { | ||
6544 | Klass.instancePool.push(instance); | ||
6545 | } | ||
6546 | }; | ||
6547 | |||
6548 | var DEFAULT_POOL_SIZE = 10; | ||
6549 | var DEFAULT_POOLER = oneArgumentPooler; | ||
6550 | |||
6551 | /** | ||
6552 | * Augments `CopyConstructor` to be a poolable class, augmenting only the class | ||
6553 | * itself (statically) not adding any prototypical fields. Any CopyConstructor | ||
6554 | * you give this may have a `poolSize` property, and will look for a | ||
6555 | * prototypical `destructor` on instances (optional). | ||
6556 | * | ||
6557 | * @param {Function} CopyConstructor Constructor that can be used to reset. | ||
6558 | * @param {Function} pooler Customizable pooler. | ||
6559 | */ | ||
6560 | var addPoolingTo = function (CopyConstructor, pooler) { | ||
6561 | var NewKlass = CopyConstructor; | ||
6562 | NewKlass.instancePool = []; | ||
6563 | NewKlass.getPooled = pooler || DEFAULT_POOLER; | ||
6564 | if (!NewKlass.poolSize) { | ||
6565 | NewKlass.poolSize = DEFAULT_POOL_SIZE; | ||
6566 | } | ||
6567 | NewKlass.release = standardReleaser; | ||
6568 | return NewKlass; | ||
6569 | }; | ||
6570 | |||
6571 | var PooledClass = { | ||
6572 | addPoolingTo: addPoolingTo, | ||
6573 | oneArgumentPooler: oneArgumentPooler, | ||
6574 | twoArgumentPooler: twoArgumentPooler, | ||
6575 | threeArgumentPooler: threeArgumentPooler, | ||
6576 | fourArgumentPooler: fourArgumentPooler, | ||
6577 | fiveArgumentPooler: fiveArgumentPooler | ||
6578 | }; | ||
6579 | |||
6580 | module.exports = PooledClass; | ||
6581 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
6582 | |||
6583 | /***/ }, | ||
6584 | /* 59 */ | ||
6585 | /***/ function(module, exports, __webpack_require__) { | ||
6586 | |||
6587 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
6588 | * Copyright 2013-2015, Facebook, Inc. | ||
6589 | * All rights reserved. | ||
6590 | * | ||
6591 | * This source code is licensed under the BSD-style license found in the | ||
6592 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6593 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6594 | * | ||
6595 | * @providesModule Transaction | ||
6596 | */ | ||
6597 | |||
6598 | 'use strict'; | ||
6599 | |||
6600 | var invariant = __webpack_require__(15); | ||
6601 | |||
6602 | /** | ||
6603 | * `Transaction` creates a black box that is able to wrap any method such that | ||
6604 | * certain invariants are maintained before and after the method is invoked | ||
6605 | * (Even if an exception is thrown while invoking the wrapped method). Whoever | ||
6606 | * instantiates a transaction can provide enforcers of the invariants at | ||
6607 | * creation time. The `Transaction` class itself will supply one additional | ||
6608 | * automatic invariant for you - the invariant that any transaction instance | ||
6609 | * should not be run while it is already being run. You would typically create a | ||
6610 | * single instance of a `Transaction` for reuse multiple times, that potentially | ||
6611 | * is used to wrap several different methods. Wrappers are extremely simple - | ||
6612 | * they only require implementing two methods. | ||
6613 | * | ||
6614 | * <pre> | ||
6615 | * wrappers (injected at creation time) | ||
6616 | * + + | ||
6617 | * | | | ||
6618 | * +-----------------|--------|--------------+ | ||
6619 | * | v | | | ||
6620 | * | +---------------+ | | | ||
6621 | * | +--| wrapper1 |---|----+ | | ||
6622 | * | | +---------------+ v | | | ||
6623 | * | | +-------------+ | | | ||
6624 | * | | +----| wrapper2 |--------+ | | ||
6625 | * | | | +-------------+ | | | | ||
6626 | * | | | | | | | ||
6627 | * | v v v v | wrapper | ||
6628 | * | +---+ +---+ +---------+ +---+ +---+ | invariants | ||
6629 | * perform(anyMethod) | | | | | | | | | | | | maintained | ||
6630 | * +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|--------> | ||
6631 | * | | | | | | | | | | | | | ||
6632 | * | | | | | | | | | | | | | ||
6633 | * | | | | | | | | | | | | | ||
6634 | * | +---+ +---+ +---------+ +---+ +---+ | | ||
6635 | * | initialize close | | ||
6636 | * +-----------------------------------------+ | ||
6637 | * </pre> | ||
6638 | * | ||
6639 | * Use cases: | ||
6640 | * - Preserving the input selection ranges before/after reconciliation. | ||
6641 | * Restoring selection even in the event of an unexpected error. | ||
6642 | * - Deactivating events while rearranging the DOM, preventing blurs/focuses, | ||
6643 | * while guaranteeing that afterwards, the event system is reactivated. | ||
6644 | * - Flushing a queue of collected DOM mutations to the main UI thread after a | ||
6645 | * reconciliation takes place in a worker thread. | ||
6646 | * - Invoking any collected `componentDidUpdate` callbacks after rendering new | ||
6647 | * content. | ||
6648 | * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue | ||
6649 | * to preserve the `scrollTop` (an automatic scroll aware DOM). | ||
6650 | * - (Future use case): Layout calculations before and after DOM updates. | ||
6651 | * | ||
6652 | * Transactional plugin API: | ||
6653 | * - A module that has an `initialize` method that returns any precomputation. | ||
6654 | * - and a `close` method that accepts the precomputation. `close` is invoked | ||
6655 | * when the wrapped process is completed, or has failed. | ||
6656 | * | ||
6657 | * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules | ||
6658 | * that implement `initialize` and `close`. | ||
6659 | * @return {Transaction} Single transaction for reuse in thread. | ||
6660 | * | ||
6661 | * @class Transaction | ||
6662 | */ | ||
6663 | var Mixin = { | ||
6664 | /** | ||
6665 | * Sets up this instance so that it is prepared for collecting metrics. Does | ||
6666 | * so such that this setup method may be used on an instance that is already | ||
6667 | * initialized, in a way that does not consume additional memory upon reuse. | ||
6668 | * That can be useful if you decide to make your subclass of this mixin a | ||
6669 | * "PooledClass". | ||
6670 | */ | ||
6671 | reinitializeTransaction: function () { | ||
6672 | this.transactionWrappers = this.getTransactionWrappers(); | ||
6673 | if (this.wrapperInitData) { | ||
6674 | this.wrapperInitData.length = 0; | ||
6675 | } else { | ||
6676 | this.wrapperInitData = []; | ||
6677 | } | ||
6678 | this._isInTransaction = false; | ||
6679 | }, | ||
6680 | |||
6681 | _isInTransaction: false, | ||
6682 | |||
6683 | /** | ||
6684 | * @abstract | ||
6685 | * @return {Array<TransactionWrapper>} Array of transaction wrappers. | ||
6686 | */ | ||
6687 | getTransactionWrappers: null, | ||
6688 | |||
6689 | isInTransaction: function () { | ||
6690 | return !!this._isInTransaction; | ||
6691 | }, | ||
6692 | |||
6693 | /** | ||
6694 | * Executes the function within a safety window. Use this for the top level | ||
6695 | * methods that result in large amounts of computation/mutations that would | ||
6696 | * need to be safety checked. The optional arguments helps prevent the need | ||
6697 | * to bind in many cases. | ||
6698 | * | ||
6699 | * @param {function} method Member of scope to call. | ||
6700 | * @param {Object} scope Scope to invoke from. | ||
6701 | * @param {Object?=} a Argument to pass to the method. | ||
6702 | * @param {Object?=} b Argument to pass to the method. | ||
6703 | * @param {Object?=} c Argument to pass to the method. | ||
6704 | * @param {Object?=} d Argument to pass to the method. | ||
6705 | * @param {Object?=} e Argument to pass to the method. | ||
6706 | * @param {Object?=} f Argument to pass to the method. | ||
6707 | * | ||
6708 | * @return {*} Return value from `method`. | ||
6709 | */ | ||
6710 | perform: function (method, scope, a, b, c, d, e, f) { | ||
6711 | !!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) : undefined; | ||
6712 | var errorThrown; | ||
6713 | var ret; | ||
6714 | try { | ||
6715 | this._isInTransaction = true; | ||
6716 | // Catching errors makes debugging more difficult, so we start with | ||
6717 | // errorThrown set to true before setting it to false after calling | ||
6718 | // close -- if it's still set to true in the finally block, it means | ||
6719 | // one of these calls threw. | ||
6720 | errorThrown = true; | ||
6721 | this.initializeAll(0); | ||
6722 | ret = method.call(scope, a, b, c, d, e, f); | ||
6723 | errorThrown = false; | ||
6724 | } finally { | ||
6725 | try { | ||
6726 | if (errorThrown) { | ||
6727 | // If `method` throws, prefer to show that stack trace over any thrown | ||
6728 | // by invoking `closeAll`. | ||
6729 | try { | ||
6730 | this.closeAll(0); | ||
6731 | } catch (err) {} | ||
6732 | } else { | ||
6733 | // Since `method` didn't throw, we don't want to silence the exception | ||
6734 | // here. | ||
6735 | this.closeAll(0); | ||
6736 | } | ||
6737 | } finally { | ||
6738 | this._isInTransaction = false; | ||
6739 | } | ||
6740 | } | ||
6741 | return ret; | ||
6742 | }, | ||
6743 | |||
6744 | initializeAll: function (startIndex) { | ||
6745 | var transactionWrappers = this.transactionWrappers; | ||
6746 | for (var i = startIndex; i < transactionWrappers.length; i++) { | ||
6747 | var wrapper = transactionWrappers[i]; | ||
6748 | try { | ||
6749 | // Catching errors makes debugging more difficult, so we start with the | ||
6750 | // OBSERVED_ERROR state before overwriting it with the real return value | ||
6751 | // of initialize -- if it's still set to OBSERVED_ERROR in the finally | ||
6752 | // block, it means wrapper.initialize threw. | ||
6753 | this.wrapperInitData[i] = Transaction.OBSERVED_ERROR; | ||
6754 | this.wrapperInitData[i] = wrapper.initialize ? wrapper.initialize.call(this) : null; | ||
6755 | } finally { | ||
6756 | if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) { | ||
6757 | // The initializer for wrapper i threw an error; initialize the | ||
6758 | // remaining wrappers but silence any exceptions from them to ensure | ||
6759 | // that the first error is the one to bubble up. | ||
6760 | try { | ||
6761 | this.initializeAll(i + 1); | ||
6762 | } catch (err) {} | ||
6763 | } | ||
6764 | } | ||
6765 | } | ||
6766 | }, | ||
6767 | |||
6768 | /** | ||
6769 | * Invokes each of `this.transactionWrappers.close[i]` functions, passing into | ||
6770 | * them the respective return values of `this.transactionWrappers.init[i]` | ||
6771 | * (`close`rs that correspond to initializers that failed will not be | ||
6772 | * invoked). | ||
6773 | */ | ||
6774 | closeAll: function (startIndex) { | ||
6775 | !this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) : undefined; | ||
6776 | var transactionWrappers = this.transactionWrappers; | ||
6777 | for (var i = startIndex; i < transactionWrappers.length; i++) { | ||
6778 | var wrapper = transactionWrappers[i]; | ||
6779 | var initData = this.wrapperInitData[i]; | ||
6780 | var errorThrown; | ||
6781 | try { | ||
6782 | // Catching errors makes debugging more difficult, so we start with | ||
6783 | // errorThrown set to true before setting it to false after calling | ||
6784 | // close -- if it's still set to true in the finally block, it means | ||
6785 | // wrapper.close threw. | ||
6786 | errorThrown = true; | ||
6787 | if (initData !== Transaction.OBSERVED_ERROR && wrapper.close) { | ||
6788 | wrapper.close.call(this, initData); | ||
6789 | } | ||
6790 | errorThrown = false; | ||
6791 | } finally { | ||
6792 | if (errorThrown) { | ||
6793 | // The closer for wrapper i threw an error; close the remaining | ||
6794 | // wrappers but silence any exceptions from them to ensure that the | ||
6795 | // first error is the one to bubble up. | ||
6796 | try { | ||
6797 | this.closeAll(i + 1); | ||
6798 | } catch (e) {} | ||
6799 | } | ||
6800 | } | ||
6801 | } | ||
6802 | this.wrapperInitData.length = 0; | ||
6803 | } | ||
6804 | }; | ||
6805 | |||
6806 | var Transaction = { | ||
6807 | |||
6808 | Mixin: Mixin, | ||
6809 | |||
6810 | /** | ||
6811 | * Token to look for to determine if an error occurred. | ||
6812 | */ | ||
6813 | OBSERVED_ERROR: {} | ||
6814 | |||
6815 | }; | ||
6816 | |||
6817 | module.exports = Transaction; | ||
6818 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
6819 | |||
6820 | /***/ }, | ||
6821 | /* 60 */ | ||
6822 | /***/ function(module, exports, __webpack_require__) { | ||
6823 | |||
6824 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
6825 | * Copyright 2013-2015, Facebook, Inc. | ||
6826 | * All rights reserved. | ||
6827 | * | ||
6828 | * This source code is licensed under the BSD-style license found in the | ||
6829 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6830 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6831 | * | ||
6832 | * @providesModule emptyObject | ||
6833 | */ | ||
6834 | |||
6835 | 'use strict'; | ||
6836 | |||
6837 | var emptyObject = {}; | ||
6838 | |||
6839 | if (process.env.NODE_ENV !== 'production') { | ||
6840 | Object.freeze(emptyObject); | ||
6841 | } | ||
6842 | |||
6843 | module.exports = emptyObject; | ||
6844 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
6845 | |||
6846 | /***/ }, | ||
6847 | /* 61 */ | ||
6848 | /***/ function(module, exports, __webpack_require__) { | ||
6849 | |||
6850 | /** | ||
6851 | * Copyright 2013-2015, Facebook, Inc. | ||
6852 | * All rights reserved. | ||
6853 | * | ||
6854 | * This source code is licensed under the BSD-style license found in the | ||
6855 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6856 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6857 | * | ||
6858 | * @providesModule containsNode | ||
6859 | * @typechecks | ||
6860 | */ | ||
6861 | |||
6862 | 'use strict'; | ||
6863 | |||
6864 | var isTextNode = __webpack_require__(62); | ||
6865 | |||
6866 | /*eslint-disable no-bitwise */ | ||
6867 | |||
6868 | /** | ||
6869 | * Checks if a given DOM node contains or is another DOM node. | ||
6870 | * | ||
6871 | * @param {?DOMNode} outerNode Outer DOM node. | ||
6872 | * @param {?DOMNode} innerNode Inner DOM node. | ||
6873 | * @return {boolean} True if `outerNode` contains or is `innerNode`. | ||
6874 | */ | ||
6875 | function containsNode(_x, _x2) { | ||
6876 | var _again = true; | ||
6877 | |||
6878 | _function: while (_again) { | ||
6879 | var outerNode = _x, | ||
6880 | innerNode = _x2; | ||
6881 | _again = false; | ||
6882 | |||
6883 | if (!outerNode || !innerNode) { | ||
6884 | return false; | ||
6885 | } else if (outerNode === innerNode) { | ||
6886 | return true; | ||
6887 | } else if (isTextNode(outerNode)) { | ||
6888 | return false; | ||
6889 | } else if (isTextNode(innerNode)) { | ||
6890 | _x = outerNode; | ||
6891 | _x2 = innerNode.parentNode; | ||
6892 | _again = true; | ||
6893 | continue _function; | ||
6894 | } else if (outerNode.contains) { | ||
6895 | return outerNode.contains(innerNode); | ||
6896 | } else if (outerNode.compareDocumentPosition) { | ||
6897 | return !!(outerNode.compareDocumentPosition(innerNode) & 16); | ||
6898 | } else { | ||
6899 | return false; | ||
6900 | } | ||
6901 | } | ||
6902 | } | ||
6903 | |||
6904 | module.exports = containsNode; | ||
6905 | |||
6906 | /***/ }, | ||
6907 | /* 62 */ | ||
6908 | /***/ function(module, exports, __webpack_require__) { | ||
6909 | |||
6910 | /** | ||
6911 | * Copyright 2013-2015, Facebook, Inc. | ||
6912 | * All rights reserved. | ||
6913 | * | ||
6914 | * This source code is licensed under the BSD-style license found in the | ||
6915 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6916 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6917 | * | ||
6918 | * @providesModule isTextNode | ||
6919 | * @typechecks | ||
6920 | */ | ||
6921 | |||
6922 | 'use strict'; | ||
6923 | |||
6924 | var isNode = __webpack_require__(63); | ||
6925 | |||
6926 | /** | ||
6927 | * @param {*} object The object to check. | ||
6928 | * @return {boolean} Whether or not the object is a DOM text node. | ||
6929 | */ | ||
6930 | function isTextNode(object) { | ||
6931 | return isNode(object) && object.nodeType == 3; | ||
6932 | } | ||
6933 | |||
6934 | module.exports = isTextNode; | ||
6935 | |||
6936 | /***/ }, | ||
6937 | /* 63 */ | ||
6938 | /***/ function(module, exports) { | ||
6939 | |||
6940 | /** | ||
6941 | * Copyright 2013-2015, Facebook, Inc. | ||
6942 | * All rights reserved. | ||
6943 | * | ||
6944 | * This source code is licensed under the BSD-style license found in the | ||
6945 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6946 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6947 | * | ||
6948 | * @providesModule isNode | ||
6949 | * @typechecks | ||
6950 | */ | ||
6951 | |||
6952 | /** | ||
6953 | * @param {*} object The object to check. | ||
6954 | * @return {boolean} Whether or not the object is a DOM node. | ||
6955 | */ | ||
6956 | 'use strict'; | ||
6957 | |||
6958 | function isNode(object) { | ||
6959 | return !!(object && (typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')); | ||
6960 | } | ||
6961 | |||
6962 | module.exports = isNode; | ||
6963 | |||
6964 | /***/ }, | ||
6965 | /* 64 */ | ||
6966 | /***/ function(module, exports, __webpack_require__) { | ||
6967 | |||
6968 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
6969 | * Copyright 2013-2015, Facebook, Inc. | ||
6970 | * All rights reserved. | ||
6971 | * | ||
6972 | * This source code is licensed under the BSD-style license found in the | ||
6973 | * LICENSE file in the root directory of this source tree. An additional grant | ||
6974 | * of patent rights can be found in the PATENTS file in the same directory. | ||
6975 | * | ||
6976 | * @providesModule instantiateReactComponent | ||
6977 | * @typechecks static-only | ||
6978 | */ | ||
6979 | |||
6980 | 'use strict'; | ||
6981 | |||
6982 | var ReactCompositeComponent = __webpack_require__(65); | ||
6983 | var ReactEmptyComponent = __webpack_require__(70); | ||
6984 | var ReactNativeComponent = __webpack_require__(71); | ||
6985 | |||
6986 | var assign = __webpack_require__(41); | ||
6987 | var invariant = __webpack_require__(15); | ||
6988 | var warning = __webpack_require__(27); | ||
6989 | |||
6990 | // To avoid a cyclic dependency, we create the final class in this module | ||
6991 | var ReactCompositeComponentWrapper = function () {}; | ||
6992 | assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, { | ||
6993 | _instantiateReactComponent: instantiateReactComponent | ||
6994 | }); | ||
6995 | |||
6996 | function getDeclarationErrorAddendum(owner) { | ||
6997 | if (owner) { | ||
6998 | var name = owner.getName(); | ||
6999 | if (name) { | ||
7000 | return ' Check the render method of `' + name + '`.'; | ||
7001 | } | ||
7002 | } | ||
7003 | return ''; | ||
7004 | } | ||
7005 | |||
7006 | /** | ||
7007 | * Check if the type reference is a known internal type. I.e. not a user | ||
7008 | * provided composite type. | ||
7009 | * | ||
7010 | * @param {function} type | ||
7011 | * @return {boolean} Returns true if this is a valid internal type. | ||
7012 | */ | ||
7013 | function isInternalComponentType(type) { | ||
7014 | return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function'; | ||
7015 | } | ||
7016 | |||
7017 | /** | ||
7018 | * Given a ReactNode, create an instance that will actually be mounted. | ||
7019 | * | ||
7020 | * @param {ReactNode} node | ||
7021 | * @return {object} A new instance of the element's constructor. | ||
7022 | * @protected | ||
7023 | */ | ||
7024 | function instantiateReactComponent(node) { | ||
7025 | var instance; | ||
7026 | |||
7027 | if (node === null || node === false) { | ||
7028 | instance = new ReactEmptyComponent(instantiateReactComponent); | ||
7029 | } else if (typeof node === 'object') { | ||
7030 | var element = node; | ||
7031 | !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : undefined; | ||
7032 | |||
7033 | // Special case string values | ||
7034 | if (typeof element.type === 'string') { | ||
7035 | instance = ReactNativeComponent.createInternalComponent(element); | ||
7036 | } else if (isInternalComponentType(element.type)) { | ||
7037 | // This is temporarily available for custom components that are not string | ||
7038 | // representations. I.e. ART. Once those are updated to use the string | ||
7039 | // representation, we can drop this code path. | ||
7040 | instance = new element.type(element); | ||
7041 | } else { | ||
7042 | instance = new ReactCompositeComponentWrapper(); | ||
7043 | } | ||
7044 | } else if (typeof node === 'string' || typeof node === 'number') { | ||
7045 | instance = ReactNativeComponent.createInstanceForText(node); | ||
7046 | } else { | ||
7047 | true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : undefined; | ||
7048 | } | ||
7049 | |||
7050 | if (process.env.NODE_ENV !== 'production') { | ||
7051 | process.env.NODE_ENV !== 'production' ? warning(typeof instance.construct === 'function' && typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : undefined; | ||
7052 | } | ||
7053 | |||
7054 | // Sets up the instance. This can probably just move into the constructor now. | ||
7055 | instance.construct(node); | ||
7056 | |||
7057 | // These two fields are used by the DOM and ART diffing algorithms | ||
7058 | // respectively. Instead of using expandos on components, we should be | ||
7059 | // storing the state needed by the diffing algorithms elsewhere. | ||
7060 | instance._mountIndex = 0; | ||
7061 | instance._mountImage = null; | ||
7062 | |||
7063 | if (process.env.NODE_ENV !== 'production') { | ||
7064 | instance._isOwnerNecessary = false; | ||
7065 | instance._warnedAboutRefsInRender = false; | ||
7066 | } | ||
7067 | |||
7068 | // Internal instances should fully constructed at this point, so they should | ||
7069 | // not get any new fields added to them at this point. | ||
7070 | if (process.env.NODE_ENV !== 'production') { | ||
7071 | if (Object.preventExtensions) { | ||
7072 | Object.preventExtensions(instance); | ||
7073 | } | ||
7074 | } | ||
7075 | |||
7076 | return instance; | ||
7077 | } | ||
7078 | |||
7079 | module.exports = instantiateReactComponent; | ||
7080 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
7081 | |||
7082 | /***/ }, | ||
7083 | /* 65 */ | ||
7084 | /***/ function(module, exports, __webpack_require__) { | ||
7085 | |||
7086 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
7087 | * Copyright 2013-2015, Facebook, Inc. | ||
7088 | * All rights reserved. | ||
7089 | * | ||
7090 | * This source code is licensed under the BSD-style license found in the | ||
7091 | * LICENSE file in the root directory of this source tree. An additional grant | ||
7092 | * of patent rights can be found in the PATENTS file in the same directory. | ||
7093 | * | ||
7094 | * @providesModule ReactCompositeComponent | ||
7095 | */ | ||
7096 | |||
7097 | 'use strict'; | ||
7098 | |||
7099 | var ReactComponentEnvironment = __webpack_require__(66); | ||
7100 | var ReactCurrentOwner = __webpack_require__(7); | ||
7101 | var ReactElement = __webpack_require__(44); | ||
7102 | var ReactInstanceMap = __webpack_require__(49); | ||
7103 | var ReactPerf = __webpack_require__(20); | ||
7104 | var ReactPropTypeLocations = __webpack_require__(67); | ||
7105 | var ReactPropTypeLocationNames = __webpack_require__(68); | ||
7106 | var ReactReconciler = __webpack_require__(52); | ||
7107 | var ReactUpdateQueue = __webpack_require__(55); | ||
7108 | |||
7109 | var assign = __webpack_require__(41); | ||
7110 | var emptyObject = __webpack_require__(60); | ||
7111 | var invariant = __webpack_require__(15); | ||
7112 | var shouldUpdateReactComponent = __webpack_require__(69); | ||
7113 | var warning = __webpack_require__(27); | ||
7114 | |||
7115 | function getDeclarationErrorAddendum(component) { | ||
7116 | var owner = component._currentElement._owner || null; | ||
7117 | if (owner) { | ||
7118 | var name = owner.getName(); | ||
7119 | if (name) { | ||
7120 | return ' Check the render method of `' + name + '`.'; | ||
7121 | } | ||
7122 | } | ||
7123 | return ''; | ||
7124 | } | ||
7125 | |||
7126 | function StatelessComponent(Component) {} | ||
7127 | StatelessComponent.prototype.render = function () { | ||
7128 | var Component = ReactInstanceMap.get(this)._currentElement.type; | ||
7129 | return Component(this.props, this.context, this.updater); | ||
7130 | }; | ||
7131 | |||
7132 | /** | ||
7133 | * ------------------ The Life-Cycle of a Composite Component ------------------ | ||
7134 | * | ||
7135 | * - constructor: Initialization of state. The instance is now retained. | ||
7136 | * - componentWillMount | ||
7137 | * - render | ||
7138 | * - [children's constructors] | ||
7139 | * - [children's componentWillMount and render] | ||
7140 | * - [children's componentDidMount] | ||
7141 | * - componentDidMount | ||
7142 | * | ||
7143 | * Update Phases: | ||
7144 | * - componentWillReceiveProps (only called if parent updated) | ||
7145 | * - shouldComponentUpdate | ||
7146 | * - componentWillUpdate | ||
7147 | * - render | ||
7148 | * - [children's constructors or receive props phases] | ||
7149 | * - componentDidUpdate | ||
7150 | * | ||
7151 | * - componentWillUnmount | ||
7152 | * - [children's componentWillUnmount] | ||
7153 | * - [children destroyed] | ||
7154 | * - (destroyed): The instance is now blank, released by React and ready for GC. | ||
7155 | * | ||
7156 | * ----------------------------------------------------------------------------- | ||
7157 | */ | ||
7158 | |||
7159 | /** | ||
7160 | * An incrementing ID assigned to each component when it is mounted. This is | ||
7161 | * used to enforce the order in which `ReactUpdates` updates dirty components. | ||
7162 | * | ||
7163 | * @private | ||
7164 | */ | ||
7165 | var nextMountID = 1; | ||
7166 | |||
7167 | /** | ||
7168 | * @lends {ReactCompositeComponent.prototype} | ||
7169 | */ | ||
7170 | var ReactCompositeComponentMixin = { | ||
7171 | |||
7172 | /** | ||
7173 | * Base constructor for all composite component. | ||
7174 | * | ||
7175 | * @param {ReactElement} element | ||
7176 | * @final | ||
7177 | * @internal | ||
7178 | */ | ||
7179 | construct: function (element) { | ||
7180 | this._currentElement = element; | ||
7181 | this._rootNodeID = null; | ||
7182 | this._instance = null; | ||
7183 | |||
7184 | // See ReactUpdateQueue | ||
7185 | this._pendingElement = null; | ||
7186 | this._pendingStateQueue = null; | ||
7187 | this._pendingReplaceState = false; | ||
7188 | this._pendingForceUpdate = false; | ||
7189 | |||
7190 | this._renderedComponent = null; | ||
7191 | |||
7192 | this._context = null; | ||
7193 | this._mountOrder = 0; | ||
7194 | this._topLevelWrapper = null; | ||
7195 | |||
7196 | // See ReactUpdates and ReactUpdateQueue. | ||
7197 | this._pendingCallbacks = null; | ||
7198 | }, | ||
7199 | |||
7200 | /** | ||
7201 | * Initializes the component, renders markup, and registers event listeners. | ||
7202 | * | ||
7203 | * @param {string} rootID DOM ID of the root node. | ||
7204 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
7205 | * @return {?string} Rendered markup to be inserted into the DOM. | ||
7206 | * @final | ||
7207 | * @internal | ||
7208 | */ | ||
7209 | mountComponent: function (rootID, transaction, context) { | ||
7210 | this._context = context; | ||
7211 | this._mountOrder = nextMountID++; | ||
7212 | this._rootNodeID = rootID; | ||
7213 | |||
7214 | var publicProps = this._processProps(this._currentElement.props); | ||
7215 | var publicContext = this._processContext(context); | ||
7216 | |||
7217 | var Component = this._currentElement.type; | ||
7218 | |||
7219 | // Initialize the public class | ||
7220 | var inst; | ||
7221 | var renderedElement; | ||
7222 | |||
7223 | // This is a way to detect if Component is a stateless arrow function | ||
7224 | // component, which is not newable. It might not be 100% reliable but is | ||
7225 | // something we can do until we start detecting that Component extends | ||
7226 | // React.Component. We already assume that typeof Component === 'function'. | ||
7227 | var canInstantiate = ('prototype' in Component); | ||
7228 | |||
7229 | if (canInstantiate) { | ||
7230 | if (process.env.NODE_ENV !== 'production') { | ||
7231 | ReactCurrentOwner.current = this; | ||
7232 | try { | ||
7233 | inst = new Component(publicProps, publicContext, ReactUpdateQueue); | ||
7234 | } finally { | ||
7235 | ReactCurrentOwner.current = null; | ||
7236 | } | ||
7237 | } else { | ||
7238 | inst = new Component(publicProps, publicContext, ReactUpdateQueue); | ||
7239 | } | ||
7240 | } | ||
7241 | |||
7242 | if (!canInstantiate || inst === null || inst === false || ReactElement.isValidElement(inst)) { | ||
7243 | renderedElement = inst; | ||
7244 | inst = new StatelessComponent(Component); | ||
7245 | } | ||
7246 | |||
7247 | if (process.env.NODE_ENV !== 'production') { | ||
7248 | // This will throw later in _renderValidatedComponent, but add an early | ||
7249 | // warning now to help debugging | ||
7250 | if (inst.render == null) { | ||
7251 | process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`, returned ' + 'null/false from a stateless component, or tried to render an ' + 'element whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : undefined; | ||
7252 | } else { | ||
7253 | // We support ES6 inheriting from React.Component, the module pattern, | ||
7254 | // and stateless components, but not ES6 classes that don't extend | ||
7255 | process.env.NODE_ENV !== 'production' ? warning(Component.prototype && Component.prototype.isReactComponent || !canInstantiate || !(inst instanceof Component), '%s(...): React component classes must extend React.Component.', Component.displayName || Component.name || 'Component') : undefined; | ||
7256 | } | ||
7257 | } | ||
7258 | |||
7259 | // These should be set up in the constructor, but as a convenience for | ||
7260 | // simpler class abstractions, we set them up after the fact. | ||
7261 | inst.props = publicProps; | ||
7262 | inst.context = publicContext; | ||
7263 | inst.refs = emptyObject; | ||
7264 | inst.updater = ReactUpdateQueue; | ||
7265 | |||
7266 | this._instance = inst; | ||
7267 | |||
7268 | // Store a reference from the instance back to the internal representation | ||
7269 | ReactInstanceMap.set(inst, this); | ||
7270 | |||
7271 | if (process.env.NODE_ENV !== 'production') { | ||
7272 | // Since plain JS classes are defined without any special initialization | ||
7273 | // logic, we can not catch common errors early. Therefore, we have to | ||
7274 | // catch them here, at initialization time, instead. | ||
7275 | process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : undefined; | ||
7276 | process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : undefined; | ||
7277 | process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : undefined; | ||
7278 | process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : undefined; | ||
7279 | process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', this.getName() || 'A component') : undefined; | ||
7280 | process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') : undefined; | ||
7281 | process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : undefined; | ||
7282 | } | ||
7283 | |||
7284 | var initialState = inst.state; | ||
7285 | if (initialState === undefined) { | ||
7286 | inst.state = initialState = null; | ||
7287 | } | ||
7288 | !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined; | ||
7289 | |||
7290 | this._pendingStateQueue = null; | ||
7291 | this._pendingReplaceState = false; | ||
7292 | this._pendingForceUpdate = false; | ||
7293 | |||
7294 | if (inst.componentWillMount) { | ||
7295 | inst.componentWillMount(); | ||
7296 | // When mounting, calls to `setState` by `componentWillMount` will set | ||
7297 | // `this._pendingStateQueue` without triggering a re-render. | ||
7298 | if (this._pendingStateQueue) { | ||
7299 | inst.state = this._processPendingState(inst.props, inst.context); | ||
7300 | } | ||
7301 | } | ||
7302 | |||
7303 | // If not a stateless component, we now render | ||
7304 | if (renderedElement === undefined) { | ||
7305 | renderedElement = this._renderValidatedComponent(); | ||
7306 | } | ||
7307 | |||
7308 | this._renderedComponent = this._instantiateReactComponent(renderedElement); | ||
7309 | |||
7310 | var markup = ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, this._processChildContext(context)); | ||
7311 | if (inst.componentDidMount) { | ||
7312 | transaction.getReactMountReady().enqueue(inst.componentDidMount, inst); | ||
7313 | } | ||
7314 | |||
7315 | return markup; | ||
7316 | }, | ||
7317 | |||
7318 | /** | ||
7319 | * Releases any resources allocated by `mountComponent`. | ||
7320 | * | ||
7321 | * @final | ||
7322 | * @internal | ||
7323 | */ | ||
7324 | unmountComponent: function () { | ||
7325 | var inst = this._instance; | ||
7326 | |||
7327 | if (inst.componentWillUnmount) { | ||
7328 | inst.componentWillUnmount(); | ||
7329 | } | ||
7330 | |||
7331 | ReactReconciler.unmountComponent(this._renderedComponent); | ||
7332 | this._renderedComponent = null; | ||
7333 | this._instance = null; | ||
7334 | |||
7335 | // Reset pending fields | ||
7336 | // Even if this component is scheduled for another update in ReactUpdates, | ||
7337 | // it would still be ignored because these fields are reset. | ||
7338 | this._pendingStateQueue = null; | ||
7339 | this._pendingReplaceState = false; | ||
7340 | this._pendingForceUpdate = false; | ||
7341 | this._pendingCallbacks = null; | ||
7342 | this._pendingElement = null; | ||
7343 | |||
7344 | // These fields do not really need to be reset since this object is no | ||
7345 | // longer accessible. | ||
7346 | this._context = null; | ||
7347 | this._rootNodeID = null; | ||
7348 | this._topLevelWrapper = null; | ||
7349 | |||
7350 | // Delete the reference from the instance to this internal representation | ||
7351 | // which allow the internals to be properly cleaned up even if the user | ||
7352 | // leaks a reference to the public instance. | ||
7353 | ReactInstanceMap.remove(inst); | ||
7354 | |||
7355 | // Some existing components rely on inst.props even after they've been | ||
7356 | // destroyed (in event handlers). | ||
7357 | // TODO: inst.props = null; | ||
7358 | // TODO: inst.state = null; | ||
7359 | // TODO: inst.context = null; | ||
7360 | }, | ||
7361 | |||
7362 | /** | ||
7363 | * Filters the context object to only contain keys specified in | ||
7364 | * `contextTypes` | ||
7365 | * | ||
7366 | * @param {object} context | ||
7367 | * @return {?object} | ||
7368 | * @private | ||
7369 | */ | ||
7370 | _maskContext: function (context) { | ||
7371 | var maskedContext = null; | ||
7372 | var Component = this._currentElement.type; | ||
7373 | var contextTypes = Component.contextTypes; | ||
7374 | if (!contextTypes) { | ||
7375 | return emptyObject; | ||
7376 | } | ||
7377 | maskedContext = {}; | ||
7378 | for (var contextName in contextTypes) { | ||
7379 | maskedContext[contextName] = context[contextName]; | ||
7380 | } | ||
7381 | return maskedContext; | ||
7382 | }, | ||
7383 | |||
7384 | /** | ||
7385 | * Filters the context object to only contain keys specified in | ||
7386 | * `contextTypes`, and asserts that they are valid. | ||
7387 | * | ||
7388 | * @param {object} context | ||
7389 | * @return {?object} | ||
7390 | * @private | ||
7391 | */ | ||
7392 | _processContext: function (context) { | ||
7393 | var maskedContext = this._maskContext(context); | ||
7394 | if (process.env.NODE_ENV !== 'production') { | ||
7395 | var Component = this._currentElement.type; | ||
7396 | if (Component.contextTypes) { | ||
7397 | this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context); | ||
7398 | } | ||
7399 | } | ||
7400 | return maskedContext; | ||
7401 | }, | ||
7402 | |||
7403 | /** | ||
7404 | * @param {object} currentContext | ||
7405 | * @return {object} | ||
7406 | * @private | ||
7407 | */ | ||
7408 | _processChildContext: function (currentContext) { | ||
7409 | var Component = this._currentElement.type; | ||
7410 | var inst = this._instance; | ||
7411 | var childContext = inst.getChildContext && inst.getChildContext(); | ||
7412 | if (childContext) { | ||
7413 | !(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined; | ||
7414 | if (process.env.NODE_ENV !== 'production') { | ||
7415 | this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext); | ||
7416 | } | ||
7417 | for (var name in childContext) { | ||
7418 | !(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : undefined; | ||
7419 | } | ||
7420 | return assign({}, currentContext, childContext); | ||
7421 | } | ||
7422 | return currentContext; | ||
7423 | }, | ||
7424 | |||
7425 | /** | ||
7426 | * Processes props by setting default values for unspecified props and | ||
7427 | * asserting that the props are valid. Does not mutate its argument; returns | ||
7428 | * a new props object with defaults merged in. | ||
7429 | * | ||
7430 | * @param {object} newProps | ||
7431 | * @return {object} | ||
7432 | * @private | ||
7433 | */ | ||
7434 | _processProps: function (newProps) { | ||
7435 | if (process.env.NODE_ENV !== 'production') { | ||
7436 | var Component = this._currentElement.type; | ||
7437 | if (Component.propTypes) { | ||
7438 | this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop); | ||
7439 | } | ||
7440 | } | ||
7441 | return newProps; | ||
7442 | }, | ||
7443 | |||
7444 | /** | ||
7445 | * Assert that the props are valid | ||
7446 | * | ||
7447 | * @param {object} propTypes Map of prop name to a ReactPropType | ||
7448 | * @param {object} props | ||
7449 | * @param {string} location e.g. "prop", "context", "child context" | ||
7450 | * @private | ||
7451 | */ | ||
7452 | _checkPropTypes: function (propTypes, props, location) { | ||
7453 | // TODO: Stop validating prop types here and only use the element | ||
7454 | // validation. | ||
7455 | var componentName = this.getName(); | ||
7456 | for (var propName in propTypes) { | ||
7457 | if (propTypes.hasOwnProperty(propName)) { | ||
7458 | var error; | ||
7459 | try { | ||
7460 | // This is intentionally an invariant that gets caught. It's the same | ||
7461 | // behavior as without this statement except with a better message. | ||
7462 | !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined; | ||
7463 | error = propTypes[propName](props, propName, componentName, location); | ||
7464 | } catch (ex) { | ||
7465 | error = ex; | ||
7466 | } | ||
7467 | if (error instanceof Error) { | ||
7468 | // We may want to extend this logic for similar errors in | ||
7469 | // top-level render calls, so I'm abstracting it away into | ||
7470 | // a function to minimize refactoring in the future | ||
7471 | var addendum = getDeclarationErrorAddendum(this); | ||
7472 | |||
7473 | if (location === ReactPropTypeLocations.prop) { | ||
7474 | // Preface gives us something to blacklist in warning module | ||
7475 | process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : undefined; | ||
7476 | } else { | ||
7477 | process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : undefined; | ||
7478 | } | ||
7479 | } | ||
7480 | } | ||
7481 | } | ||
7482 | }, | ||
7483 | |||
7484 | receiveComponent: function (nextElement, transaction, nextContext) { | ||
7485 | var prevElement = this._currentElement; | ||
7486 | var prevContext = this._context; | ||
7487 | |||
7488 | this._pendingElement = null; | ||
7489 | |||
7490 | this.updateComponent(transaction, prevElement, nextElement, prevContext, nextContext); | ||
7491 | }, | ||
7492 | |||
7493 | /** | ||
7494 | * If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate` | ||
7495 | * is set, update the component. | ||
7496 | * | ||
7497 | * @param {ReactReconcileTransaction} transaction | ||
7498 | * @internal | ||
7499 | */ | ||
7500 | performUpdateIfNecessary: function (transaction) { | ||
7501 | if (this._pendingElement != null) { | ||
7502 | ReactReconciler.receiveComponent(this, this._pendingElement || this._currentElement, transaction, this._context); | ||
7503 | } | ||
7504 | |||
7505 | if (this._pendingStateQueue !== null || this._pendingForceUpdate) { | ||
7506 | this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context); | ||
7507 | } | ||
7508 | }, | ||
7509 | |||
7510 | /** | ||
7511 | * Perform an update to a mounted component. The componentWillReceiveProps and | ||
7512 | * shouldComponentUpdate methods are called, then (assuming the update isn't | ||
7513 | * skipped) the remaining update lifecycle methods are called and the DOM | ||
7514 | * representation is updated. | ||
7515 | * | ||
7516 | * By default, this implements React's rendering and reconciliation algorithm. | ||
7517 | * Sophisticated clients may wish to override this. | ||
7518 | * | ||
7519 | * @param {ReactReconcileTransaction} transaction | ||
7520 | * @param {ReactElement} prevParentElement | ||
7521 | * @param {ReactElement} nextParentElement | ||
7522 | * @internal | ||
7523 | * @overridable | ||
7524 | */ | ||
7525 | updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) { | ||
7526 | var inst = this._instance; | ||
7527 | |||
7528 | var nextContext = this._context === nextUnmaskedContext ? inst.context : this._processContext(nextUnmaskedContext); | ||
7529 | var nextProps; | ||
7530 | |||
7531 | // Distinguish between a props update versus a simple state update | ||
7532 | if (prevParentElement === nextParentElement) { | ||
7533 | // Skip checking prop types again -- we don't read inst.props to avoid | ||
7534 | // warning for DOM component props in this upgrade | ||
7535 | nextProps = nextParentElement.props; | ||
7536 | } else { | ||
7537 | nextProps = this._processProps(nextParentElement.props); | ||
7538 | // An update here will schedule an update but immediately set | ||
7539 | // _pendingStateQueue which will ensure that any state updates gets | ||
7540 | // immediately reconciled instead of waiting for the next batch. | ||
7541 | |||
7542 | if (inst.componentWillReceiveProps) { | ||
7543 | inst.componentWillReceiveProps(nextProps, nextContext); | ||
7544 | } | ||
7545 | } | ||
7546 | |||
7547 | var nextState = this._processPendingState(nextProps, nextContext); | ||
7548 | |||
7549 | var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext); | ||
7550 | |||
7551 | if (process.env.NODE_ENV !== 'production') { | ||
7552 | process.env.NODE_ENV !== 'production' ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined; | ||
7553 | } | ||
7554 | |||
7555 | if (shouldUpdate) { | ||
7556 | this._pendingForceUpdate = false; | ||
7557 | // Will set `this.props`, `this.state` and `this.context`. | ||
7558 | this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext); | ||
7559 | } else { | ||
7560 | // If it's determined that a component should not update, we still want | ||
7561 | // to set props and state but we shortcut the rest of the update. | ||
7562 | this._currentElement = nextParentElement; | ||
7563 | this._context = nextUnmaskedContext; | ||
7564 | inst.props = nextProps; | ||
7565 | inst.state = nextState; | ||
7566 | inst.context = nextContext; | ||
7567 | } | ||
7568 | }, | ||
7569 | |||
7570 | _processPendingState: function (props, context) { | ||
7571 | var inst = this._instance; | ||
7572 | var queue = this._pendingStateQueue; | ||
7573 | var replace = this._pendingReplaceState; | ||
7574 | this._pendingReplaceState = false; | ||
7575 | this._pendingStateQueue = null; | ||
7576 | |||
7577 | if (!queue) { | ||
7578 | return inst.state; | ||
7579 | } | ||
7580 | |||
7581 | if (replace && queue.length === 1) { | ||
7582 | return queue[0]; | ||
7583 | } | ||
7584 | |||
7585 | var nextState = assign({}, replace ? queue[0] : inst.state); | ||
7586 | for (var i = replace ? 1 : 0; i < queue.length; i++) { | ||
7587 | var partial = queue[i]; | ||
7588 | assign(nextState, typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial); | ||
7589 | } | ||
7590 | |||
7591 | return nextState; | ||
7592 | }, | ||
7593 | |||
7594 | /** | ||
7595 | * Merges new props and state, notifies delegate methods of update and | ||
7596 | * performs update. | ||
7597 | * | ||
7598 | * @param {ReactElement} nextElement Next element | ||
7599 | * @param {object} nextProps Next public object to set as properties. | ||
7600 | * @param {?object} nextState Next object to set as state. | ||
7601 | * @param {?object} nextContext Next public object to set as context. | ||
7602 | * @param {ReactReconcileTransaction} transaction | ||
7603 | * @param {?object} unmaskedContext | ||
7604 | * @private | ||
7605 | */ | ||
7606 | _performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) { | ||
7607 | var inst = this._instance; | ||
7608 | |||
7609 | var hasComponentDidUpdate = Boolean(inst.componentDidUpdate); | ||
7610 | var prevProps; | ||
7611 | var prevState; | ||
7612 | var prevContext; | ||
7613 | if (hasComponentDidUpdate) { | ||
7614 | prevProps = inst.props; | ||
7615 | prevState = inst.state; | ||
7616 | prevContext = inst.context; | ||
7617 | } | ||
7618 | |||
7619 | if (inst.componentWillUpdate) { | ||
7620 | inst.componentWillUpdate(nextProps, nextState, nextContext); | ||
7621 | } | ||
7622 | |||
7623 | this._currentElement = nextElement; | ||
7624 | this._context = unmaskedContext; | ||
7625 | inst.props = nextProps; | ||
7626 | inst.state = nextState; | ||
7627 | inst.context = nextContext; | ||
7628 | |||
7629 | this._updateRenderedComponent(transaction, unmaskedContext); | ||
7630 | |||
7631 | if (hasComponentDidUpdate) { | ||
7632 | transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst); | ||
7633 | } | ||
7634 | }, | ||
7635 | |||
7636 | /** | ||
7637 | * Call the component's `render` method and update the DOM accordingly. | ||
7638 | * | ||
7639 | * @param {ReactReconcileTransaction} transaction | ||
7640 | * @internal | ||
7641 | */ | ||
7642 | _updateRenderedComponent: function (transaction, context) { | ||
7643 | var prevComponentInstance = this._renderedComponent; | ||
7644 | var prevRenderedElement = prevComponentInstance._currentElement; | ||
7645 | var nextRenderedElement = this._renderValidatedComponent(); | ||
7646 | if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) { | ||
7647 | ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context)); | ||
7648 | } else { | ||
7649 | // These two IDs are actually the same! But nothing should rely on that. | ||
7650 | var thisID = this._rootNodeID; | ||
7651 | var prevComponentID = prevComponentInstance._rootNodeID; | ||
7652 | ReactReconciler.unmountComponent(prevComponentInstance); | ||
7653 | |||
7654 | this._renderedComponent = this._instantiateReactComponent(nextRenderedElement); | ||
7655 | var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context)); | ||
7656 | this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup); | ||
7657 | } | ||
7658 | }, | ||
7659 | |||
7660 | /** | ||
7661 | * @protected | ||
7662 | */ | ||
7663 | _replaceNodeWithMarkupByID: function (prevComponentID, nextMarkup) { | ||
7664 | ReactComponentEnvironment.replaceNodeWithMarkupByID(prevComponentID, nextMarkup); | ||
7665 | }, | ||
7666 | |||
7667 | /** | ||
7668 | * @protected | ||
7669 | */ | ||
7670 | _renderValidatedComponentWithoutOwnerOrContext: function () { | ||
7671 | var inst = this._instance; | ||
7672 | var renderedComponent = inst.render(); | ||
7673 | if (process.env.NODE_ENV !== 'production') { | ||
7674 | // We allow auto-mocks to proceed as if they're returning null. | ||
7675 | if (typeof renderedComponent === 'undefined' && inst.render._isMockFunction) { | ||
7676 | // This is probably bad practice. Consider warning here and | ||
7677 | // deprecating this convenience. | ||
7678 | renderedComponent = null; | ||
7679 | } | ||
7680 | } | ||
7681 | |||
7682 | return renderedComponent; | ||
7683 | }, | ||
7684 | |||
7685 | /** | ||
7686 | * @private | ||
7687 | */ | ||
7688 | _renderValidatedComponent: function () { | ||
7689 | var renderedComponent; | ||
7690 | ReactCurrentOwner.current = this; | ||
7691 | try { | ||
7692 | renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext(); | ||
7693 | } finally { | ||
7694 | ReactCurrentOwner.current = null; | ||
7695 | } | ||
7696 | !( | ||
7697 | // TODO: An `isValidNode` function would probably be more appropriate | ||
7698 | renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined; | ||
7699 | return renderedComponent; | ||
7700 | }, | ||
7701 | |||
7702 | /** | ||
7703 | * Lazily allocates the refs object and stores `component` as `ref`. | ||
7704 | * | ||
7705 | * @param {string} ref Reference name. | ||
7706 | * @param {component} component Component to store as `ref`. | ||
7707 | * @final | ||
7708 | * @private | ||
7709 | */ | ||
7710 | attachRef: function (ref, component) { | ||
7711 | var inst = this.getPublicInstance(); | ||
7712 | !(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : invariant(false) : undefined; | ||
7713 | var publicComponentInstance = component.getPublicInstance(); | ||
7714 | if (process.env.NODE_ENV !== 'production') { | ||
7715 | var componentName = component && component.getName ? component.getName() : 'a component'; | ||
7716 | process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : undefined; | ||
7717 | } | ||
7718 | var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs; | ||
7719 | refs[ref] = publicComponentInstance; | ||
7720 | }, | ||
7721 | |||
7722 | /** | ||
7723 | * Detaches a reference name. | ||
7724 | * | ||
7725 | * @param {string} ref Name to dereference. | ||
7726 | * @final | ||
7727 | * @private | ||
7728 | */ | ||
7729 | detachRef: function (ref) { | ||
7730 | var refs = this.getPublicInstance().refs; | ||
7731 | delete refs[ref]; | ||
7732 | }, | ||
7733 | |||
7734 | /** | ||
7735 | * Get a text description of the component that can be used to identify it | ||
7736 | * in error messages. | ||
7737 | * @return {string} The name or null. | ||
7738 | * @internal | ||
7739 | */ | ||
7740 | getName: function () { | ||
7741 | var type = this._currentElement.type; | ||
7742 | var constructor = this._instance && this._instance.constructor; | ||
7743 | return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null; | ||
7744 | }, | ||
7745 | |||
7746 | /** | ||
7747 | * Get the publicly accessible representation of this component - i.e. what | ||
7748 | * is exposed by refs and returned by render. Can be null for stateless | ||
7749 | * components. | ||
7750 | * | ||
7751 | * @return {ReactComponent} the public component instance. | ||
7752 | * @internal | ||
7753 | */ | ||
7754 | getPublicInstance: function () { | ||
7755 | var inst = this._instance; | ||
7756 | if (inst instanceof StatelessComponent) { | ||
7757 | return null; | ||
7758 | } | ||
7759 | return inst; | ||
7760 | }, | ||
7761 | |||
7762 | // Stub | ||
7763 | _instantiateReactComponent: null | ||
7764 | |||
7765 | }; | ||
7766 | |||
7767 | ReactPerf.measureMethods(ReactCompositeComponentMixin, 'ReactCompositeComponent', { | ||
7768 | mountComponent: 'mountComponent', | ||
7769 | updateComponent: 'updateComponent', | ||
7770 | _renderValidatedComponent: '_renderValidatedComponent' | ||
7771 | }); | ||
7772 | |||
7773 | var ReactCompositeComponent = { | ||
7774 | |||
7775 | Mixin: ReactCompositeComponentMixin | ||
7776 | |||
7777 | }; | ||
7778 | |||
7779 | module.exports = ReactCompositeComponent; | ||
7780 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
7781 | |||
7782 | /***/ }, | ||
7783 | /* 66 */ | ||
7784 | /***/ function(module, exports, __webpack_require__) { | ||
7785 | |||
7786 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
7787 | * Copyright 2014-2015, Facebook, Inc. | ||
7788 | * All rights reserved. | ||
7789 | * | ||
7790 | * This source code is licensed under the BSD-style license found in the | ||
7791 | * LICENSE file in the root directory of this source tree. An additional grant | ||
7792 | * of patent rights can be found in the PATENTS file in the same directory. | ||
7793 | * | ||
7794 | * @providesModule ReactComponentEnvironment | ||
7795 | */ | ||
7796 | |||
7797 | 'use strict'; | ||
7798 | |||
7799 | var invariant = __webpack_require__(15); | ||
7800 | |||
7801 | var injected = false; | ||
7802 | |||
7803 | var ReactComponentEnvironment = { | ||
7804 | |||
7805 | /** | ||
7806 | * Optionally injectable environment dependent cleanup hook. (server vs. | ||
7807 | * browser etc). Example: A browser system caches DOM nodes based on component | ||
7808 | * ID and must remove that cache entry when this instance is unmounted. | ||
7809 | */ | ||
7810 | unmountIDFromEnvironment: null, | ||
7811 | |||
7812 | /** | ||
7813 | * Optionally injectable hook for swapping out mount images in the middle of | ||
7814 | * the tree. | ||
7815 | */ | ||
7816 | replaceNodeWithMarkupByID: null, | ||
7817 | |||
7818 | /** | ||
7819 | * Optionally injectable hook for processing a queue of child updates. Will | ||
7820 | * later move into MultiChildComponents. | ||
7821 | */ | ||
7822 | processChildrenUpdates: null, | ||
7823 | |||
7824 | injection: { | ||
7825 | injectEnvironment: function (environment) { | ||
7826 | !!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined; | ||
7827 | ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment; | ||
7828 | ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID; | ||
7829 | ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates; | ||
7830 | injected = true; | ||
7831 | } | ||
7832 | } | ||
7833 | |||
7834 | }; | ||
7835 | |||
7836 | module.exports = ReactComponentEnvironment; | ||
7837 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
7838 | |||
7839 | /***/ }, | ||
7840 | /* 67 */ | ||
7841 | /***/ function(module, exports, __webpack_require__) { | ||
7842 | |||
7843 | /** | ||
7844 | * Copyright 2013-2015, Facebook, Inc. | ||
7845 | * All rights reserved. | ||
7846 | * | ||
7847 | * This source code is licensed under the BSD-style license found in the | ||
7848 | * LICENSE file in the root directory of this source tree. An additional grant | ||
7849 | * of patent rights can be found in the PATENTS file in the same directory. | ||
7850 | * | ||
7851 | * @providesModule ReactPropTypeLocations | ||
7852 | */ | ||
7853 | |||
7854 | 'use strict'; | ||
7855 | |||
7856 | var keyMirror = __webpack_require__(19); | ||
7857 | |||
7858 | var ReactPropTypeLocations = keyMirror({ | ||
7859 | prop: null, | ||
7860 | context: null, | ||
7861 | childContext: null | ||
7862 | }); | ||
7863 | |||
7864 | module.exports = ReactPropTypeLocations; | ||
7865 | |||
7866 | /***/ }, | ||
7867 | /* 68 */ | ||
7868 | /***/ function(module, exports, __webpack_require__) { | ||
7869 | |||
7870 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
7871 | * Copyright 2013-2015, Facebook, Inc. | ||
7872 | * All rights reserved. | ||
7873 | * | ||
7874 | * This source code is licensed under the BSD-style license found in the | ||
7875 | * LICENSE file in the root directory of this source tree. An additional grant | ||
7876 | * of patent rights can be found in the PATENTS file in the same directory. | ||
7877 | * | ||
7878 | * @providesModule ReactPropTypeLocationNames | ||
7879 | */ | ||
7880 | |||
7881 | 'use strict'; | ||
7882 | |||
7883 | var ReactPropTypeLocationNames = {}; | ||
7884 | |||
7885 | if (process.env.NODE_ENV !== 'production') { | ||
7886 | ReactPropTypeLocationNames = { | ||
7887 | prop: 'prop', | ||
7888 | context: 'context', | ||
7889 | childContext: 'child context' | ||
7890 | }; | ||
7891 | } | ||
7892 | |||
7893 | module.exports = ReactPropTypeLocationNames; | ||
7894 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
7895 | |||
7896 | /***/ }, | ||
7897 | /* 69 */ | ||
7898 | /***/ function(module, exports) { | ||
7899 | |||
7900 | /** | ||
7901 | * Copyright 2013-2015, Facebook, Inc. | ||
7902 | * All rights reserved. | ||
7903 | * | ||
7904 | * This source code is licensed under the BSD-style license found in the | ||
7905 | * LICENSE file in the root directory of this source tree. An additional grant | ||
7906 | * of patent rights can be found in the PATENTS file in the same directory. | ||
7907 | * | ||
7908 | * @providesModule shouldUpdateReactComponent | ||
7909 | * @typechecks static-only | ||
7910 | */ | ||
7911 | |||
7912 | 'use strict'; | ||
7913 | |||
7914 | /** | ||
7915 | * Given a `prevElement` and `nextElement`, determines if the existing | ||
7916 | * instance should be updated as opposed to being destroyed or replaced by a new | ||
7917 | * instance. Both arguments are elements. This ensures that this logic can | ||
7918 | * operate on stateless trees without any backing instance. | ||
7919 | * | ||
7920 | * @param {?object} prevElement | ||
7921 | * @param {?object} nextElement | ||
7922 | * @return {boolean} True if the existing instance should be updated. | ||
7923 | * @protected | ||
7924 | */ | ||
7925 | function shouldUpdateReactComponent(prevElement, nextElement) { | ||
7926 | var prevEmpty = prevElement === null || prevElement === false; | ||
7927 | var nextEmpty = nextElement === null || nextElement === false; | ||
7928 | if (prevEmpty || nextEmpty) { | ||
7929 | return prevEmpty === nextEmpty; | ||
7930 | } | ||
7931 | |||
7932 | var prevType = typeof prevElement; | ||
7933 | var nextType = typeof nextElement; | ||
7934 | if (prevType === 'string' || prevType === 'number') { | ||
7935 | return nextType === 'string' || nextType === 'number'; | ||
7936 | } else { | ||
7937 | return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key; | ||
7938 | } | ||
7939 | return false; | ||
7940 | } | ||
7941 | |||
7942 | module.exports = shouldUpdateReactComponent; | ||
7943 | |||
7944 | /***/ }, | ||
7945 | /* 70 */ | ||
7946 | /***/ function(module, exports, __webpack_require__) { | ||
7947 | |||
7948 | /** | ||
7949 | * Copyright 2014-2015, Facebook, Inc. | ||
7950 | * All rights reserved. | ||
7951 | * | ||
7952 | * This source code is licensed under the BSD-style license found in the | ||
7953 | * LICENSE file in the root directory of this source tree. An additional grant | ||
7954 | * of patent rights can be found in the PATENTS file in the same directory. | ||
7955 | * | ||
7956 | * @providesModule ReactEmptyComponent | ||
7957 | */ | ||
7958 | |||
7959 | 'use strict'; | ||
7960 | |||
7961 | var ReactElement = __webpack_require__(44); | ||
7962 | var ReactEmptyComponentRegistry = __webpack_require__(46); | ||
7963 | var ReactReconciler = __webpack_require__(52); | ||
7964 | |||
7965 | var assign = __webpack_require__(41); | ||
7966 | |||
7967 | var placeholderElement; | ||
7968 | |||
7969 | var ReactEmptyComponentInjection = { | ||
7970 | injectEmptyComponent: function (component) { | ||
7971 | placeholderElement = ReactElement.createElement(component); | ||
7972 | } | ||
7973 | }; | ||
7974 | |||
7975 | var ReactEmptyComponent = function (instantiate) { | ||
7976 | this._currentElement = null; | ||
7977 | this._rootNodeID = null; | ||
7978 | this._renderedComponent = instantiate(placeholderElement); | ||
7979 | }; | ||
7980 | assign(ReactEmptyComponent.prototype, { | ||
7981 | construct: function (element) {}, | ||
7982 | mountComponent: function (rootID, transaction, context) { | ||
7983 | ReactEmptyComponentRegistry.registerNullComponentID(rootID); | ||
7984 | this._rootNodeID = rootID; | ||
7985 | return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context); | ||
7986 | }, | ||
7987 | receiveComponent: function () {}, | ||
7988 | unmountComponent: function (rootID, transaction, context) { | ||
7989 | ReactReconciler.unmountComponent(this._renderedComponent); | ||
7990 | ReactEmptyComponentRegistry.deregisterNullComponentID(this._rootNodeID); | ||
7991 | this._rootNodeID = null; | ||
7992 | this._renderedComponent = null; | ||
7993 | } | ||
7994 | }); | ||
7995 | |||
7996 | ReactEmptyComponent.injection = ReactEmptyComponentInjection; | ||
7997 | |||
7998 | module.exports = ReactEmptyComponent; | ||
7999 | |||
8000 | /***/ }, | ||
8001 | /* 71 */ | ||
8002 | /***/ function(module, exports, __webpack_require__) { | ||
8003 | |||
8004 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
8005 | * Copyright 2014-2015, Facebook, Inc. | ||
8006 | * All rights reserved. | ||
8007 | * | ||
8008 | * This source code is licensed under the BSD-style license found in the | ||
8009 | * LICENSE file in the root directory of this source tree. An additional grant | ||
8010 | * of patent rights can be found in the PATENTS file in the same directory. | ||
8011 | * | ||
8012 | * @providesModule ReactNativeComponent | ||
8013 | */ | ||
8014 | |||
8015 | 'use strict'; | ||
8016 | |||
8017 | var assign = __webpack_require__(41); | ||
8018 | var invariant = __webpack_require__(15); | ||
8019 | |||
8020 | var autoGenerateWrapperClass = null; | ||
8021 | var genericComponentClass = null; | ||
8022 | // This registry keeps track of wrapper classes around native tags. | ||
8023 | var tagToComponentClass = {}; | ||
8024 | var textComponentClass = null; | ||
8025 | |||
8026 | var ReactNativeComponentInjection = { | ||
8027 | // This accepts a class that receives the tag string. This is a catch all | ||
8028 | // that can render any kind of tag. | ||
8029 | injectGenericComponentClass: function (componentClass) { | ||
8030 | genericComponentClass = componentClass; | ||
8031 | }, | ||
8032 | // This accepts a text component class that takes the text string to be | ||
8033 | // rendered as props. | ||
8034 | injectTextComponentClass: function (componentClass) { | ||
8035 | textComponentClass = componentClass; | ||
8036 | }, | ||
8037 | // This accepts a keyed object with classes as values. Each key represents a | ||
8038 | // tag. That particular tag will use this class instead of the generic one. | ||
8039 | injectComponentClasses: function (componentClasses) { | ||
8040 | assign(tagToComponentClass, componentClasses); | ||
8041 | } | ||
8042 | }; | ||
8043 | |||
8044 | /** | ||
8045 | * Get a composite component wrapper class for a specific tag. | ||
8046 | * | ||
8047 | * @param {ReactElement} element The tag for which to get the class. | ||
8048 | * @return {function} The React class constructor function. | ||
8049 | */ | ||
8050 | function getComponentClassForElement(element) { | ||
8051 | if (typeof element.type === 'function') { | ||
8052 | return element.type; | ||
8053 | } | ||
8054 | var tag = element.type; | ||
8055 | var componentClass = tagToComponentClass[tag]; | ||
8056 | if (componentClass == null) { | ||
8057 | tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag); | ||
8058 | } | ||
8059 | return componentClass; | ||
8060 | } | ||
8061 | |||
8062 | /** | ||
8063 | * Get a native internal component class for a specific tag. | ||
8064 | * | ||
8065 | * @param {ReactElement} element The element to create. | ||
8066 | * @return {function} The internal class constructor function. | ||
8067 | */ | ||
8068 | function createInternalComponent(element) { | ||
8069 | !genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined; | ||
8070 | return new genericComponentClass(element.type, element.props); | ||
8071 | } | ||
8072 | |||
8073 | /** | ||
8074 | * @param {ReactText} text | ||
8075 | * @return {ReactComponent} | ||
8076 | */ | ||
8077 | function createInstanceForText(text) { | ||
8078 | return new textComponentClass(text); | ||
8079 | } | ||
8080 | |||
8081 | /** | ||
8082 | * @param {ReactComponent} component | ||
8083 | * @return {boolean} | ||
8084 | */ | ||
8085 | function isTextComponent(component) { | ||
8086 | return component instanceof textComponentClass; | ||
8087 | } | ||
8088 | |||
8089 | var ReactNativeComponent = { | ||
8090 | getComponentClassForElement: getComponentClassForElement, | ||
8091 | createInternalComponent: createInternalComponent, | ||
8092 | createInstanceForText: createInstanceForText, | ||
8093 | isTextComponent: isTextComponent, | ||
8094 | injection: ReactNativeComponentInjection | ||
8095 | }; | ||
8096 | |||
8097 | module.exports = ReactNativeComponent; | ||
8098 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
8099 | |||
8100 | /***/ }, | ||
8101 | /* 72 */ | ||
8102 | /***/ function(module, exports, __webpack_require__) { | ||
8103 | |||
8104 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
8105 | * Copyright 2015, Facebook, Inc. | ||
8106 | * All rights reserved. | ||
8107 | * | ||
8108 | * This source code is licensed under the BSD-style license found in the | ||
8109 | * LICENSE file in the root directory of this source tree. An additional grant | ||
8110 | * of patent rights can be found in the PATENTS file in the same directory. | ||
8111 | * | ||
8112 | * @providesModule validateDOMNesting | ||
8113 | */ | ||
8114 | |||
8115 | 'use strict'; | ||
8116 | |||
8117 | var assign = __webpack_require__(41); | ||
8118 | var emptyFunction = __webpack_require__(17); | ||
8119 | var warning = __webpack_require__(27); | ||
8120 | |||
8121 | var validateDOMNesting = emptyFunction; | ||
8122 | |||
8123 | if (process.env.NODE_ENV !== 'production') { | ||
8124 | // This validation code was written based on the HTML5 parsing spec: | ||
8125 | // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope | ||
8126 | // | ||
8127 | // Note: this does not catch all invalid nesting, nor does it try to (as it's | ||
8128 | // not clear what practical benefit doing so provides); instead, we warn only | ||
8129 | // for cases where the parser will give a parse tree differing from what React | ||
8130 | // intended. For example, <b><div></div></b> is invalid but we don't warn | ||
8131 | // because it still parses correctly; we do warn for other cases like nested | ||
8132 | // <p> tags where the beginning of the second element implicitly closes the | ||
8133 | // first, causing a confusing mess. | ||
8134 | |||
8135 | // https://html.spec.whatwg.org/multipage/syntax.html#special | ||
8136 | var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; | ||
8137 | |||
8138 | // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope | ||
8139 | var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', | ||
8140 | |||
8141 | // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point | ||
8142 | // TODO: Distinguish by namespace here -- for <title>, including it here | ||
8143 | // errs on the side of fewer warnings | ||
8144 | 'foreignObject', 'desc', 'title']; | ||
8145 | |||
8146 | // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope | ||
8147 | var buttonScopeTags = inScopeTags.concat(['button']); | ||
8148 | |||
8149 | // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags | ||
8150 | var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; | ||
8151 | |||
8152 | var emptyAncestorInfo = { | ||
8153 | parentTag: null, | ||
8154 | |||
8155 | formTag: null, | ||
8156 | aTagInScope: null, | ||
8157 | buttonTagInScope: null, | ||
8158 | nobrTagInScope: null, | ||
8159 | pTagInButtonScope: null, | ||
8160 | |||
8161 | listItemTagAutoclosing: null, | ||
8162 | dlItemTagAutoclosing: null | ||
8163 | }; | ||
8164 | |||
8165 | var updatedAncestorInfo = function (oldInfo, tag, instance) { | ||
8166 | var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo); | ||
8167 | var info = { tag: tag, instance: instance }; | ||
8168 | |||
8169 | if (inScopeTags.indexOf(tag) !== -1) { | ||
8170 | ancestorInfo.aTagInScope = null; | ||
8171 | ancestorInfo.buttonTagInScope = null; | ||
8172 | ancestorInfo.nobrTagInScope = null; | ||
8173 | } | ||
8174 | if (buttonScopeTags.indexOf(tag) !== -1) { | ||
8175 | ancestorInfo.pTagInButtonScope = null; | ||
8176 | } | ||
8177 | |||
8178 | // See rules for 'li', 'dd', 'dt' start tags in | ||
8179 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody | ||
8180 | if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { | ||
8181 | ancestorInfo.listItemTagAutoclosing = null; | ||
8182 | ancestorInfo.dlItemTagAutoclosing = null; | ||
8183 | } | ||
8184 | |||
8185 | ancestorInfo.parentTag = info; | ||
8186 | |||
8187 | if (tag === 'form') { | ||
8188 | ancestorInfo.formTag = info; | ||
8189 | } | ||
8190 | if (tag === 'a') { | ||
8191 | ancestorInfo.aTagInScope = info; | ||
8192 | } | ||
8193 | if (tag === 'button') { | ||
8194 | ancestorInfo.buttonTagInScope = info; | ||
8195 | } | ||
8196 | if (tag === 'nobr') { | ||
8197 | ancestorInfo.nobrTagInScope = info; | ||
8198 | } | ||
8199 | if (tag === 'p') { | ||
8200 | ancestorInfo.pTagInButtonScope = info; | ||
8201 | } | ||
8202 | if (tag === 'li') { | ||
8203 | ancestorInfo.listItemTagAutoclosing = info; | ||
8204 | } | ||
8205 | if (tag === 'dd' || tag === 'dt') { | ||
8206 | ancestorInfo.dlItemTagAutoclosing = info; | ||
8207 | } | ||
8208 | |||
8209 | return ancestorInfo; | ||
8210 | }; | ||
8211 | |||
8212 | /** | ||
8213 | * Returns whether | ||
8214 | */ | ||
8215 | var isTagValidWithParent = function (tag, parentTag) { | ||
8216 | // First, let's check if we're in an unusual parsing mode... | ||
8217 | switch (parentTag) { | ||
8218 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect | ||
8219 | case 'select': | ||
8220 | return tag === 'option' || tag === 'optgroup' || tag === '#text'; | ||
8221 | case 'optgroup': | ||
8222 | return tag === 'option' || tag === '#text'; | ||
8223 | // Strictly speaking, seeing an <option> doesn't mean we're in a <select> | ||
8224 | // but | ||
8225 | case 'option': | ||
8226 | return tag === '#text'; | ||
8227 | |||
8228 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd | ||
8229 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption | ||
8230 | // No special behavior since these rules fall back to "in body" mode for | ||
8231 | // all except special table nodes which cause bad parsing behavior anyway. | ||
8232 | |||
8233 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr | ||
8234 | case 'tr': | ||
8235 | return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; | ||
8236 | |||
8237 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody | ||
8238 | case 'tbody': | ||
8239 | case 'thead': | ||
8240 | case 'tfoot': | ||
8241 | return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; | ||
8242 | |||
8243 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup | ||
8244 | case 'colgroup': | ||
8245 | return tag === 'col' || tag === 'template'; | ||
8246 | |||
8247 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable | ||
8248 | case 'table': | ||
8249 | return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; | ||
8250 | |||
8251 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead | ||
8252 | case 'head': | ||
8253 | return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; | ||
8254 | |||
8255 | // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element | ||
8256 | case 'html': | ||
8257 | return tag === 'head' || tag === 'body'; | ||
8258 | } | ||
8259 | |||
8260 | // Probably in the "in body" parsing mode, so we outlaw only tag combos | ||
8261 | // where the parsing rules cause implicit opens or closes to be added. | ||
8262 | // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody | ||
8263 | switch (tag) { | ||
8264 | case 'h1': | ||
8265 | case 'h2': | ||
8266 | case 'h3': | ||
8267 | case 'h4': | ||
8268 | case 'h5': | ||
8269 | case 'h6': | ||
8270 | return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; | ||
8271 | |||
8272 | case 'rp': | ||
8273 | case 'rt': | ||
8274 | return impliedEndTags.indexOf(parentTag) === -1; | ||
8275 | |||
8276 | case 'caption': | ||
8277 | case 'col': | ||
8278 | case 'colgroup': | ||
8279 | case 'frame': | ||
8280 | case 'head': | ||
8281 | case 'tbody': | ||
8282 | case 'td': | ||
8283 | case 'tfoot': | ||
8284 | case 'th': | ||
8285 | case 'thead': | ||
8286 | case 'tr': | ||
8287 | // These tags are only valid with a few parents that have special child | ||
8288 | // parsing rules -- if we're down here, then none of those matched and | ||
8289 | // so we allow it only if we don't know what the parent is, as all other | ||
8290 | // cases are invalid. | ||
8291 | return parentTag == null; | ||
8292 | } | ||
8293 | |||
8294 | return true; | ||
8295 | }; | ||
8296 | |||
8297 | /** | ||
8298 | * Returns whether | ||
8299 | */ | ||
8300 | var findInvalidAncestorForTag = function (tag, ancestorInfo) { | ||
8301 | switch (tag) { | ||
8302 | case 'address': | ||
8303 | case 'article': | ||
8304 | case 'aside': | ||
8305 | case 'blockquote': | ||
8306 | case 'center': | ||
8307 | case 'details': | ||
8308 | case 'dialog': | ||
8309 | case 'dir': | ||
8310 | case 'div': | ||
8311 | case 'dl': | ||
8312 | case 'fieldset': | ||
8313 | case 'figcaption': | ||
8314 | case 'figure': | ||
8315 | case 'footer': | ||
8316 | case 'header': | ||
8317 | case 'hgroup': | ||
8318 | case 'main': | ||
8319 | case 'menu': | ||
8320 | case 'nav': | ||
8321 | case 'ol': | ||
8322 | case 'p': | ||
8323 | case 'section': | ||
8324 | case 'summary': | ||
8325 | case 'ul': | ||
8326 | |||
8327 | case 'pre': | ||
8328 | case 'listing': | ||
8329 | |||
8330 | case 'table': | ||
8331 | |||
8332 | case 'hr': | ||
8333 | |||
8334 | case 'xmp': | ||
8335 | |||
8336 | case 'h1': | ||
8337 | case 'h2': | ||
8338 | case 'h3': | ||
8339 | case 'h4': | ||
8340 | case 'h5': | ||
8341 | case 'h6': | ||
8342 | return ancestorInfo.pTagInButtonScope; | ||
8343 | |||
8344 | case 'form': | ||
8345 | return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; | ||
8346 | |||
8347 | case 'li': | ||
8348 | return ancestorInfo.listItemTagAutoclosing; | ||
8349 | |||
8350 | case 'dd': | ||
8351 | case 'dt': | ||
8352 | return ancestorInfo.dlItemTagAutoclosing; | ||
8353 | |||
8354 | case 'button': | ||
8355 | return ancestorInfo.buttonTagInScope; | ||
8356 | |||
8357 | case 'a': | ||
8358 | // Spec says something about storing a list of markers, but it sounds | ||
8359 | // equivalent to this check. | ||
8360 | return ancestorInfo.aTagInScope; | ||
8361 | |||
8362 | case 'nobr': | ||
8363 | return ancestorInfo.nobrTagInScope; | ||
8364 | } | ||
8365 | |||
8366 | return null; | ||
8367 | }; | ||
8368 | |||
8369 | /** | ||
8370 | * Given a ReactCompositeComponent instance, return a list of its recursive | ||
8371 | * owners, starting at the root and ending with the instance itself. | ||
8372 | */ | ||
8373 | var findOwnerStack = function (instance) { | ||
8374 | if (!instance) { | ||
8375 | return []; | ||
8376 | } | ||
8377 | |||
8378 | var stack = []; | ||
8379 | /*eslint-disable space-after-keywords */ | ||
8380 | do { | ||
8381 | /*eslint-enable space-after-keywords */ | ||
8382 | stack.push(instance); | ||
8383 | } while (instance = instance._currentElement._owner); | ||
8384 | stack.reverse(); | ||
8385 | return stack; | ||
8386 | }; | ||
8387 | |||
8388 | var didWarn = {}; | ||
8389 | |||
8390 | validateDOMNesting = function (childTag, childInstance, ancestorInfo) { | ||
8391 | ancestorInfo = ancestorInfo || emptyAncestorInfo; | ||
8392 | var parentInfo = ancestorInfo.parentTag; | ||
8393 | var parentTag = parentInfo && parentInfo.tag; | ||
8394 | |||
8395 | var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; | ||
8396 | var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); | ||
8397 | var problematic = invalidParent || invalidAncestor; | ||
8398 | |||
8399 | if (problematic) { | ||
8400 | var ancestorTag = problematic.tag; | ||
8401 | var ancestorInstance = problematic.instance; | ||
8402 | |||
8403 | var childOwner = childInstance && childInstance._currentElement._owner; | ||
8404 | var ancestorOwner = ancestorInstance && ancestorInstance._currentElement._owner; | ||
8405 | |||
8406 | var childOwners = findOwnerStack(childOwner); | ||
8407 | var ancestorOwners = findOwnerStack(ancestorOwner); | ||
8408 | |||
8409 | var minStackLen = Math.min(childOwners.length, ancestorOwners.length); | ||
8410 | var i; | ||
8411 | |||
8412 | var deepestCommon = -1; | ||
8413 | for (i = 0; i < minStackLen; i++) { | ||
8414 | if (childOwners[i] === ancestorOwners[i]) { | ||
8415 | deepestCommon = i; | ||
8416 | } else { | ||
8417 | break; | ||
8418 | } | ||
8419 | } | ||
8420 | |||
8421 | var UNKNOWN = '(unknown)'; | ||
8422 | var childOwnerNames = childOwners.slice(deepestCommon + 1).map(function (inst) { | ||
8423 | return inst.getName() || UNKNOWN; | ||
8424 | }); | ||
8425 | var ancestorOwnerNames = ancestorOwners.slice(deepestCommon + 1).map(function (inst) { | ||
8426 | return inst.getName() || UNKNOWN; | ||
8427 | }); | ||
8428 | var ownerInfo = [].concat( | ||
8429 | // If the parent and child instances have a common owner ancestor, start | ||
8430 | // with that -- otherwise we just start with the parent's owners. | ||
8431 | deepestCommon !== -1 ? childOwners[deepestCommon].getName() || UNKNOWN : [], ancestorOwnerNames, ancestorTag, | ||
8432 | // If we're warning about an invalid (non-parent) ancestry, add '...' | ||
8433 | invalidAncestor ? ['...'] : [], childOwnerNames, childTag).join(' > '); | ||
8434 | |||
8435 | var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + ownerInfo; | ||
8436 | if (didWarn[warnKey]) { | ||
8437 | return; | ||
8438 | } | ||
8439 | didWarn[warnKey] = true; | ||
8440 | |||
8441 | if (invalidParent) { | ||
8442 | var info = ''; | ||
8443 | if (ancestorTag === 'table' && childTag === 'tr') { | ||
8444 | info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.'; | ||
8445 | } | ||
8446 | process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a child of <%s>. ' + 'See %s.%s', childTag, ancestorTag, ownerInfo, info) : undefined; | ||
8447 | } else { | ||
8448 | process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a descendant of ' + '<%s>. See %s.', childTag, ancestorTag, ownerInfo) : undefined; | ||
8449 | } | ||
8450 | } | ||
8451 | }; | ||
8452 | |||
8453 | validateDOMNesting.ancestorInfoContextKey = '__validateDOMNesting_ancestorInfo$' + Math.random().toString(36).slice(2); | ||
8454 | |||
8455 | validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo; | ||
8456 | |||
8457 | // For testing | ||
8458 | validateDOMNesting.isTagValidInContext = function (tag, ancestorInfo) { | ||
8459 | ancestorInfo = ancestorInfo || emptyAncestorInfo; | ||
8460 | var parentInfo = ancestorInfo.parentTag; | ||
8461 | var parentTag = parentInfo && parentInfo.tag; | ||
8462 | return isTagValidWithParent(tag, parentTag) && !findInvalidAncestorForTag(tag, ancestorInfo); | ||
8463 | }; | ||
8464 | } | ||
8465 | |||
8466 | module.exports = validateDOMNesting; | ||
8467 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
8468 | |||
8469 | /***/ }, | ||
8470 | /* 73 */ | ||
8471 | /***/ function(module, exports, __webpack_require__) { | ||
8472 | |||
8473 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
8474 | * Copyright 2013-2015, Facebook, Inc. | ||
8475 | * All rights reserved. | ||
8476 | * | ||
8477 | * This source code is licensed under the BSD-style license found in the | ||
8478 | * LICENSE file in the root directory of this source tree. An additional grant | ||
8479 | * of patent rights can be found in the PATENTS file in the same directory. | ||
8480 | * | ||
8481 | * @providesModule ReactDefaultInjection | ||
8482 | */ | ||
8483 | |||
8484 | 'use strict'; | ||
8485 | |||
8486 | var BeforeInputEventPlugin = __webpack_require__(74); | ||
8487 | var ChangeEventPlugin = __webpack_require__(82); | ||
8488 | var ClientReactRootIndex = __webpack_require__(85); | ||
8489 | var DefaultEventPluginOrder = __webpack_require__(86); | ||
8490 | var EnterLeaveEventPlugin = __webpack_require__(87); | ||
8491 | var ExecutionEnvironment = __webpack_require__(11); | ||
8492 | var HTMLDOMPropertyConfig = __webpack_require__(91); | ||
8493 | var ReactBrowserComponentMixin = __webpack_require__(92); | ||
8494 | var ReactComponentBrowserEnvironment = __webpack_require__(28); | ||
8495 | var ReactDefaultBatchingStrategy = __webpack_require__(94); | ||
8496 | var ReactDOMComponent = __webpack_require__(95); | ||
8497 | var ReactDOMTextComponent = __webpack_require__(8); | ||
8498 | var ReactEventListener = __webpack_require__(120); | ||
8499 | var ReactInjection = __webpack_require__(123); | ||
8500 | var ReactInstanceHandles = __webpack_require__(47); | ||
8501 | var ReactMount = __webpack_require__(30); | ||
8502 | var ReactReconcileTransaction = __webpack_require__(127); | ||
8503 | var SelectEventPlugin = __webpack_require__(132); | ||
8504 | var ServerReactRootIndex = __webpack_require__(133); | ||
8505 | var SimpleEventPlugin = __webpack_require__(134); | ||
8506 | var SVGDOMPropertyConfig = __webpack_require__(143); | ||
8507 | |||
8508 | var alreadyInjected = false; | ||
8509 | |||
8510 | function inject() { | ||
8511 | if (alreadyInjected) { | ||
8512 | // TODO: This is currently true because these injections are shared between | ||
8513 | // the client and the server package. They should be built independently | ||
8514 | // and not share any injection state. Then this problem will be solved. | ||
8515 | return; | ||
8516 | } | ||
8517 | alreadyInjected = true; | ||
8518 | |||
8519 | ReactInjection.EventEmitter.injectReactEventListener(ReactEventListener); | ||
8520 | |||
8521 | /** | ||
8522 | * Inject modules for resolving DOM hierarchy and plugin ordering. | ||
8523 | */ | ||
8524 | ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder); | ||
8525 | ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles); | ||
8526 | ReactInjection.EventPluginHub.injectMount(ReactMount); | ||
8527 | |||
8528 | /** | ||
8529 | * Some important event plugins included by default (without having to require | ||
8530 | * them). | ||
8531 | */ | ||
8532 | ReactInjection.EventPluginHub.injectEventPluginsByName({ | ||
8533 | SimpleEventPlugin: SimpleEventPlugin, | ||
8534 | EnterLeaveEventPlugin: EnterLeaveEventPlugin, | ||
8535 | ChangeEventPlugin: ChangeEventPlugin, | ||
8536 | SelectEventPlugin: SelectEventPlugin, | ||
8537 | BeforeInputEventPlugin: BeforeInputEventPlugin | ||
8538 | }); | ||
8539 | |||
8540 | ReactInjection.NativeComponent.injectGenericComponentClass(ReactDOMComponent); | ||
8541 | |||
8542 | ReactInjection.NativeComponent.injectTextComponentClass(ReactDOMTextComponent); | ||
8543 | |||
8544 | ReactInjection.Class.injectMixin(ReactBrowserComponentMixin); | ||
8545 | |||
8546 | ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig); | ||
8547 | ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig); | ||
8548 | |||
8549 | ReactInjection.EmptyComponent.injectEmptyComponent('noscript'); | ||
8550 | |||
8551 | ReactInjection.Updates.injectReconcileTransaction(ReactReconcileTransaction); | ||
8552 | ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy); | ||
8553 | |||
8554 | ReactInjection.RootIndex.injectCreateReactRootIndex(ExecutionEnvironment.canUseDOM ? ClientReactRootIndex.createReactRootIndex : ServerReactRootIndex.createReactRootIndex); | ||
8555 | |||
8556 | ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment); | ||
8557 | |||
8558 | if (process.env.NODE_ENV !== 'production') { | ||
8559 | var url = ExecutionEnvironment.canUseDOM && window.location.href || ''; | ||
8560 | if (/[?&]react_perf\b/.test(url)) { | ||
8561 | var ReactDefaultPerf = __webpack_require__(144); | ||
8562 | ReactDefaultPerf.start(); | ||
8563 | } | ||
8564 | } | ||
8565 | } | ||
8566 | |||
8567 | module.exports = { | ||
8568 | inject: inject | ||
8569 | }; | ||
8570 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
8571 | |||
8572 | /***/ }, | ||
8573 | /* 74 */ | ||
8574 | /***/ function(module, exports, __webpack_require__) { | ||
8575 | |||
8576 | /** | ||
8577 | * Copyright 2013-2015 Facebook, Inc. | ||
8578 | * All rights reserved. | ||
8579 | * | ||
8580 | * This source code is licensed under the BSD-style license found in the | ||
8581 | * LICENSE file in the root directory of this source tree. An additional grant | ||
8582 | * of patent rights can be found in the PATENTS file in the same directory. | ||
8583 | * | ||
8584 | * @providesModule BeforeInputEventPlugin | ||
8585 | * @typechecks static-only | ||
8586 | */ | ||
8587 | |||
8588 | 'use strict'; | ||
8589 | |||
8590 | var EventConstants = __webpack_require__(32); | ||
8591 | var EventPropagators = __webpack_require__(75); | ||
8592 | var ExecutionEnvironment = __webpack_require__(11); | ||
8593 | var FallbackCompositionState = __webpack_require__(76); | ||
8594 | var SyntheticCompositionEvent = __webpack_require__(78); | ||
8595 | var SyntheticInputEvent = __webpack_require__(80); | ||
8596 | |||
8597 | var keyOf = __webpack_require__(81); | ||
8598 | |||
8599 | var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space | ||
8600 | var START_KEYCODE = 229; | ||
8601 | |||
8602 | var canUseCompositionEvent = ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window; | ||
8603 | |||
8604 | var documentMode = null; | ||
8605 | if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) { | ||
8606 | documentMode = document.documentMode; | ||
8607 | } | ||
8608 | |||
8609 | // Webkit offers a very useful `textInput` event that can be used to | ||
8610 | // directly represent `beforeInput`. The IE `textinput` event is not as | ||
8611 | // useful, so we don't use it. | ||
8612 | var canUseTextInputEvent = ExecutionEnvironment.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto(); | ||
8613 | |||
8614 | // In IE9+, we have access to composition events, but the data supplied | ||
8615 | // by the native compositionend event may be incorrect. Japanese ideographic | ||
8616 | // spaces, for instance (\u3000) are not recorded correctly. | ||
8617 | var useFallbackCompositionData = ExecutionEnvironment.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); | ||
8618 | |||
8619 | /** | ||
8620 | * Opera <= 12 includes TextEvent in window, but does not fire | ||
8621 | * text input events. Rely on keypress instead. | ||
8622 | */ | ||
8623 | function isPresto() { | ||
8624 | var opera = window.opera; | ||
8625 | return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12; | ||
8626 | } | ||
8627 | |||
8628 | var SPACEBAR_CODE = 32; | ||
8629 | var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); | ||
8630 | |||
8631 | var topLevelTypes = EventConstants.topLevelTypes; | ||
8632 | |||
8633 | // Events and their corresponding property names. | ||
8634 | var eventTypes = { | ||
8635 | beforeInput: { | ||
8636 | phasedRegistrationNames: { | ||
8637 | bubbled: keyOf({ onBeforeInput: null }), | ||
8638 | captured: keyOf({ onBeforeInputCapture: null }) | ||
8639 | }, | ||
8640 | dependencies: [topLevelTypes.topCompositionEnd, topLevelTypes.topKeyPress, topLevelTypes.topTextInput, topLevelTypes.topPaste] | ||
8641 | }, | ||
8642 | compositionEnd: { | ||
8643 | phasedRegistrationNames: { | ||
8644 | bubbled: keyOf({ onCompositionEnd: null }), | ||
8645 | captured: keyOf({ onCompositionEndCapture: null }) | ||
8646 | }, | ||
8647 | dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionEnd, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown] | ||
8648 | }, | ||
8649 | compositionStart: { | ||
8650 | phasedRegistrationNames: { | ||
8651 | bubbled: keyOf({ onCompositionStart: null }), | ||
8652 | captured: keyOf({ onCompositionStartCapture: null }) | ||
8653 | }, | ||
8654 | dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionStart, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown] | ||
8655 | }, | ||
8656 | compositionUpdate: { | ||
8657 | phasedRegistrationNames: { | ||
8658 | bubbled: keyOf({ onCompositionUpdate: null }), | ||
8659 | captured: keyOf({ onCompositionUpdateCapture: null }) | ||
8660 | }, | ||
8661 | dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionUpdate, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown] | ||
8662 | } | ||
8663 | }; | ||
8664 | |||
8665 | // Track whether we've ever handled a keypress on the space key. | ||
8666 | var hasSpaceKeypress = false; | ||
8667 | |||
8668 | /** | ||
8669 | * Return whether a native keypress event is assumed to be a command. | ||
8670 | * This is required because Firefox fires `keypress` events for key commands | ||
8671 | * (cut, copy, select-all, etc.) even though no character is inserted. | ||
8672 | */ | ||
8673 | function isKeypressCommand(nativeEvent) { | ||
8674 | return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && | ||
8675 | // ctrlKey && altKey is equivalent to AltGr, and is not a command. | ||
8676 | !(nativeEvent.ctrlKey && nativeEvent.altKey); | ||
8677 | } | ||
8678 | |||
8679 | /** | ||
8680 | * Translate native top level events into event types. | ||
8681 | * | ||
8682 | * @param {string} topLevelType | ||
8683 | * @return {object} | ||
8684 | */ | ||
8685 | function getCompositionEventType(topLevelType) { | ||
8686 | switch (topLevelType) { | ||
8687 | case topLevelTypes.topCompositionStart: | ||
8688 | return eventTypes.compositionStart; | ||
8689 | case topLevelTypes.topCompositionEnd: | ||
8690 | return eventTypes.compositionEnd; | ||
8691 | case topLevelTypes.topCompositionUpdate: | ||
8692 | return eventTypes.compositionUpdate; | ||
8693 | } | ||
8694 | } | ||
8695 | |||
8696 | /** | ||
8697 | * Does our fallback best-guess model think this event signifies that | ||
8698 | * composition has begun? | ||
8699 | * | ||
8700 | * @param {string} topLevelType | ||
8701 | * @param {object} nativeEvent | ||
8702 | * @return {boolean} | ||
8703 | */ | ||
8704 | function isFallbackCompositionStart(topLevelType, nativeEvent) { | ||
8705 | return topLevelType === topLevelTypes.topKeyDown && nativeEvent.keyCode === START_KEYCODE; | ||
8706 | } | ||
8707 | |||
8708 | /** | ||
8709 | * Does our fallback mode think that this event is the end of composition? | ||
8710 | * | ||
8711 | * @param {string} topLevelType | ||
8712 | * @param {object} nativeEvent | ||
8713 | * @return {boolean} | ||
8714 | */ | ||
8715 | function isFallbackCompositionEnd(topLevelType, nativeEvent) { | ||
8716 | switch (topLevelType) { | ||
8717 | case topLevelTypes.topKeyUp: | ||
8718 | // Command keys insert or clear IME input. | ||
8719 | return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; | ||
8720 | case topLevelTypes.topKeyDown: | ||
8721 | // Expect IME keyCode on each keydown. If we get any other | ||
8722 | // code we must have exited earlier. | ||
8723 | return nativeEvent.keyCode !== START_KEYCODE; | ||
8724 | case topLevelTypes.topKeyPress: | ||
8725 | case topLevelTypes.topMouseDown: | ||
8726 | case topLevelTypes.topBlur: | ||
8727 | // Events are not possible without cancelling IME. | ||
8728 | return true; | ||
8729 | default: | ||
8730 | return false; | ||
8731 | } | ||
8732 | } | ||
8733 | |||
8734 | /** | ||
8735 | * Google Input Tools provides composition data via a CustomEvent, | ||
8736 | * with the `data` property populated in the `detail` object. If this | ||
8737 | * is available on the event object, use it. If not, this is a plain | ||
8738 | * composition event and we have nothing special to extract. | ||
8739 | * | ||
8740 | * @param {object} nativeEvent | ||
8741 | * @return {?string} | ||
8742 | */ | ||
8743 | function getDataFromCustomEvent(nativeEvent) { | ||
8744 | var detail = nativeEvent.detail; | ||
8745 | if (typeof detail === 'object' && 'data' in detail) { | ||
8746 | return detail.data; | ||
8747 | } | ||
8748 | return null; | ||
8749 | } | ||
8750 | |||
8751 | // Track the current IME composition fallback object, if any. | ||
8752 | var currentComposition = null; | ||
8753 | |||
8754 | /** | ||
8755 | * @param {string} topLevelType Record from `EventConstants`. | ||
8756 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
8757 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
8758 | * @param {object} nativeEvent Native browser event. | ||
8759 | * @return {?object} A SyntheticCompositionEvent. | ||
8760 | */ | ||
8761 | function extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
8762 | var eventType; | ||
8763 | var fallbackData; | ||
8764 | |||
8765 | if (canUseCompositionEvent) { | ||
8766 | eventType = getCompositionEventType(topLevelType); | ||
8767 | } else if (!currentComposition) { | ||
8768 | if (isFallbackCompositionStart(topLevelType, nativeEvent)) { | ||
8769 | eventType = eventTypes.compositionStart; | ||
8770 | } | ||
8771 | } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { | ||
8772 | eventType = eventTypes.compositionEnd; | ||
8773 | } | ||
8774 | |||
8775 | if (!eventType) { | ||
8776 | return null; | ||
8777 | } | ||
8778 | |||
8779 | if (useFallbackCompositionData) { | ||
8780 | // The current composition is stored statically and must not be | ||
8781 | // overwritten while composition continues. | ||
8782 | if (!currentComposition && eventType === eventTypes.compositionStart) { | ||
8783 | currentComposition = FallbackCompositionState.getPooled(topLevelTarget); | ||
8784 | } else if (eventType === eventTypes.compositionEnd) { | ||
8785 | if (currentComposition) { | ||
8786 | fallbackData = currentComposition.getData(); | ||
8787 | } | ||
8788 | } | ||
8789 | } | ||
8790 | |||
8791 | var event = SyntheticCompositionEvent.getPooled(eventType, topLevelTargetID, nativeEvent, nativeEventTarget); | ||
8792 | |||
8793 | if (fallbackData) { | ||
8794 | // Inject data generated from fallback path into the synthetic event. | ||
8795 | // This matches the property of native CompositionEventInterface. | ||
8796 | event.data = fallbackData; | ||
8797 | } else { | ||
8798 | var customData = getDataFromCustomEvent(nativeEvent); | ||
8799 | if (customData !== null) { | ||
8800 | event.data = customData; | ||
8801 | } | ||
8802 | } | ||
8803 | |||
8804 | EventPropagators.accumulateTwoPhaseDispatches(event); | ||
8805 | return event; | ||
8806 | } | ||
8807 | |||
8808 | /** | ||
8809 | * @param {string} topLevelType Record from `EventConstants`. | ||
8810 | * @param {object} nativeEvent Native browser event. | ||
8811 | * @return {?string} The string corresponding to this `beforeInput` event. | ||
8812 | */ | ||
8813 | function getNativeBeforeInputChars(topLevelType, nativeEvent) { | ||
8814 | switch (topLevelType) { | ||
8815 | case topLevelTypes.topCompositionEnd: | ||
8816 | return getDataFromCustomEvent(nativeEvent); | ||
8817 | case topLevelTypes.topKeyPress: | ||
8818 | /** | ||
8819 | * If native `textInput` events are available, our goal is to make | ||
8820 | * use of them. However, there is a special case: the spacebar key. | ||
8821 | * In Webkit, preventing default on a spacebar `textInput` event | ||
8822 | * cancels character insertion, but it *also* causes the browser | ||
8823 | * to fall back to its default spacebar behavior of scrolling the | ||
8824 | * page. | ||
8825 | * | ||
8826 | * Tracking at: | ||
8827 | * https://code.google.com/p/chromium/issues/detail?id=355103 | ||
8828 | * | ||
8829 | * To avoid this issue, use the keypress event as if no `textInput` | ||
8830 | * event is available. | ||
8831 | */ | ||
8832 | var which = nativeEvent.which; | ||
8833 | if (which !== SPACEBAR_CODE) { | ||
8834 | return null; | ||
8835 | } | ||
8836 | |||
8837 | hasSpaceKeypress = true; | ||
8838 | return SPACEBAR_CHAR; | ||
8839 | |||
8840 | case topLevelTypes.topTextInput: | ||
8841 | // Record the characters to be added to the DOM. | ||
8842 | var chars = nativeEvent.data; | ||
8843 | |||
8844 | // If it's a spacebar character, assume that we have already handled | ||
8845 | // it at the keypress level and bail immediately. Android Chrome | ||
8846 | // doesn't give us keycodes, so we need to blacklist it. | ||
8847 | if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { | ||
8848 | return null; | ||
8849 | } | ||
8850 | |||
8851 | return chars; | ||
8852 | |||
8853 | default: | ||
8854 | // For other native event types, do nothing. | ||
8855 | return null; | ||
8856 | } | ||
8857 | } | ||
8858 | |||
8859 | /** | ||
8860 | * For browsers that do not provide the `textInput` event, extract the | ||
8861 | * appropriate string to use for SyntheticInputEvent. | ||
8862 | * | ||
8863 | * @param {string} topLevelType Record from `EventConstants`. | ||
8864 | * @param {object} nativeEvent Native browser event. | ||
8865 | * @return {?string} The fallback string for this `beforeInput` event. | ||
8866 | */ | ||
8867 | function getFallbackBeforeInputChars(topLevelType, nativeEvent) { | ||
8868 | // If we are currently composing (IME) and using a fallback to do so, | ||
8869 | // try to extract the composed characters from the fallback object. | ||
8870 | if (currentComposition) { | ||
8871 | if (topLevelType === topLevelTypes.topCompositionEnd || isFallbackCompositionEnd(topLevelType, nativeEvent)) { | ||
8872 | var chars = currentComposition.getData(); | ||
8873 | FallbackCompositionState.release(currentComposition); | ||
8874 | currentComposition = null; | ||
8875 | return chars; | ||
8876 | } | ||
8877 | return null; | ||
8878 | } | ||
8879 | |||
8880 | switch (topLevelType) { | ||
8881 | case topLevelTypes.topPaste: | ||
8882 | // If a paste event occurs after a keypress, throw out the input | ||
8883 | // chars. Paste events should not lead to BeforeInput events. | ||
8884 | return null; | ||
8885 | case topLevelTypes.topKeyPress: | ||
8886 | /** | ||
8887 | * As of v27, Firefox may fire keypress events even when no character | ||
8888 | * will be inserted. A few possibilities: | ||
8889 | * | ||
8890 | * - `which` is `0`. Arrow keys, Esc key, etc. | ||
8891 | * | ||
8892 | * - `which` is the pressed key code, but no char is available. | ||
8893 | * Ex: 'AltGr + d` in Polish. There is no modified character for | ||
8894 | * this key combination and no character is inserted into the | ||
8895 | * document, but FF fires the keypress for char code `100` anyway. | ||
8896 | * No `input` event will occur. | ||
8897 | * | ||
8898 | * - `which` is the pressed key code, but a command combination is | ||
8899 | * being used. Ex: `Cmd+C`. No character is inserted, and no | ||
8900 | * `input` event will occur. | ||
8901 | */ | ||
8902 | if (nativeEvent.which && !isKeypressCommand(nativeEvent)) { | ||
8903 | return String.fromCharCode(nativeEvent.which); | ||
8904 | } | ||
8905 | return null; | ||
8906 | case topLevelTypes.topCompositionEnd: | ||
8907 | return useFallbackCompositionData ? null : nativeEvent.data; | ||
8908 | default: | ||
8909 | return null; | ||
8910 | } | ||
8911 | } | ||
8912 | |||
8913 | /** | ||
8914 | * Extract a SyntheticInputEvent for `beforeInput`, based on either native | ||
8915 | * `textInput` or fallback behavior. | ||
8916 | * | ||
8917 | * @param {string} topLevelType Record from `EventConstants`. | ||
8918 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
8919 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
8920 | * @param {object} nativeEvent Native browser event. | ||
8921 | * @return {?object} A SyntheticInputEvent. | ||
8922 | */ | ||
8923 | function extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
8924 | var chars; | ||
8925 | |||
8926 | if (canUseTextInputEvent) { | ||
8927 | chars = getNativeBeforeInputChars(topLevelType, nativeEvent); | ||
8928 | } else { | ||
8929 | chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); | ||
8930 | } | ||
8931 | |||
8932 | // If no characters are being inserted, no BeforeInput event should | ||
8933 | // be fired. | ||
8934 | if (!chars) { | ||
8935 | return null; | ||
8936 | } | ||
8937 | |||
8938 | var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, topLevelTargetID, nativeEvent, nativeEventTarget); | ||
8939 | |||
8940 | event.data = chars; | ||
8941 | EventPropagators.accumulateTwoPhaseDispatches(event); | ||
8942 | return event; | ||
8943 | } | ||
8944 | |||
8945 | /** | ||
8946 | * Create an `onBeforeInput` event to match | ||
8947 | * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. | ||
8948 | * | ||
8949 | * This event plugin is based on the native `textInput` event | ||
8950 | * available in Chrome, Safari, Opera, and IE. This event fires after | ||
8951 | * `onKeyPress` and `onCompositionEnd`, but before `onInput`. | ||
8952 | * | ||
8953 | * `beforeInput` is spec'd but not implemented in any browsers, and | ||
8954 | * the `input` event does not provide any useful information about what has | ||
8955 | * actually been added, contrary to the spec. Thus, `textInput` is the best | ||
8956 | * available event to identify the characters that have actually been inserted | ||
8957 | * into the target node. | ||
8958 | * | ||
8959 | * This plugin is also responsible for emitting `composition` events, thus | ||
8960 | * allowing us to share composition fallback code for both `beforeInput` and | ||
8961 | * `composition` event types. | ||
8962 | */ | ||
8963 | var BeforeInputEventPlugin = { | ||
8964 | |||
8965 | eventTypes: eventTypes, | ||
8966 | |||
8967 | /** | ||
8968 | * @param {string} topLevelType Record from `EventConstants`. | ||
8969 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
8970 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
8971 | * @param {object} nativeEvent Native browser event. | ||
8972 | * @return {*} An accumulation of synthetic events. | ||
8973 | * @see {EventPluginHub.extractEvents} | ||
8974 | */ | ||
8975 | extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
8976 | return [extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget)]; | ||
8977 | } | ||
8978 | }; | ||
8979 | |||
8980 | module.exports = BeforeInputEventPlugin; | ||
8981 | |||
8982 | /***/ }, | ||
8983 | /* 75 */ | ||
8984 | /***/ function(module, exports, __webpack_require__) { | ||
8985 | |||
8986 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
8987 | * Copyright 2013-2015, Facebook, Inc. | ||
8988 | * All rights reserved. | ||
8989 | * | ||
8990 | * This source code is licensed under the BSD-style license found in the | ||
8991 | * LICENSE file in the root directory of this source tree. An additional grant | ||
8992 | * of patent rights can be found in the PATENTS file in the same directory. | ||
8993 | * | ||
8994 | * @providesModule EventPropagators | ||
8995 | */ | ||
8996 | |||
8997 | 'use strict'; | ||
8998 | |||
8999 | var EventConstants = __webpack_require__(32); | ||
9000 | var EventPluginHub = __webpack_require__(33); | ||
9001 | |||
9002 | var warning = __webpack_require__(27); | ||
9003 | |||
9004 | var accumulateInto = __webpack_require__(37); | ||
9005 | var forEachAccumulated = __webpack_require__(38); | ||
9006 | |||
9007 | var PropagationPhases = EventConstants.PropagationPhases; | ||
9008 | var getListener = EventPluginHub.getListener; | ||
9009 | |||
9010 | /** | ||
9011 | * Some event types have a notion of different registration names for different | ||
9012 | * "phases" of propagation. This finds listeners by a given phase. | ||
9013 | */ | ||
9014 | function listenerAtPhase(id, event, propagationPhase) { | ||
9015 | var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; | ||
9016 | return getListener(id, registrationName); | ||
9017 | } | ||
9018 | |||
9019 | /** | ||
9020 | * Tags a `SyntheticEvent` with dispatched listeners. Creating this function | ||
9021 | * here, allows us to not have to bind or create functions for each event. | ||
9022 | * Mutating the event's members allows us to not have to create a wrapping | ||
9023 | * "dispatch" object that pairs the event with the listener. | ||
9024 | */ | ||
9025 | function accumulateDirectionalDispatches(domID, upwards, event) { | ||
9026 | if (process.env.NODE_ENV !== 'production') { | ||
9027 | process.env.NODE_ENV !== 'production' ? warning(domID, 'Dispatching id must not be null') : undefined; | ||
9028 | } | ||
9029 | var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured; | ||
9030 | var listener = listenerAtPhase(domID, event, phase); | ||
9031 | if (listener) { | ||
9032 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); | ||
9033 | event._dispatchIDs = accumulateInto(event._dispatchIDs, domID); | ||
9034 | } | ||
9035 | } | ||
9036 | |||
9037 | /** | ||
9038 | * Collect dispatches (must be entirely collected before dispatching - see unit | ||
9039 | * tests). Lazily allocate the array to conserve memory. We must loop through | ||
9040 | * each event and perform the traversal for each one. We cannot perform a | ||
9041 | * single traversal for the entire collection of events because each event may | ||
9042 | * have a different target. | ||
9043 | */ | ||
9044 | function accumulateTwoPhaseDispatchesSingle(event) { | ||
9045 | if (event && event.dispatchConfig.phasedRegistrationNames) { | ||
9046 | EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(event.dispatchMarker, accumulateDirectionalDispatches, event); | ||
9047 | } | ||
9048 | } | ||
9049 | |||
9050 | /** | ||
9051 | * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. | ||
9052 | */ | ||
9053 | function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { | ||
9054 | if (event && event.dispatchConfig.phasedRegistrationNames) { | ||
9055 | EventPluginHub.injection.getInstanceHandle().traverseTwoPhaseSkipTarget(event.dispatchMarker, accumulateDirectionalDispatches, event); | ||
9056 | } | ||
9057 | } | ||
9058 | |||
9059 | /** | ||
9060 | * Accumulates without regard to direction, does not look for phased | ||
9061 | * registration names. Same as `accumulateDirectDispatchesSingle` but without | ||
9062 | * requiring that the `dispatchMarker` be the same as the dispatched ID. | ||
9063 | */ | ||
9064 | function accumulateDispatches(id, ignoredDirection, event) { | ||
9065 | if (event && event.dispatchConfig.registrationName) { | ||
9066 | var registrationName = event.dispatchConfig.registrationName; | ||
9067 | var listener = getListener(id, registrationName); | ||
9068 | if (listener) { | ||
9069 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); | ||
9070 | event._dispatchIDs = accumulateInto(event._dispatchIDs, id); | ||
9071 | } | ||
9072 | } | ||
9073 | } | ||
9074 | |||
9075 | /** | ||
9076 | * Accumulates dispatches on an `SyntheticEvent`, but only for the | ||
9077 | * `dispatchMarker`. | ||
9078 | * @param {SyntheticEvent} event | ||
9079 | */ | ||
9080 | function accumulateDirectDispatchesSingle(event) { | ||
9081 | if (event && event.dispatchConfig.registrationName) { | ||
9082 | accumulateDispatches(event.dispatchMarker, null, event); | ||
9083 | } | ||
9084 | } | ||
9085 | |||
9086 | function accumulateTwoPhaseDispatches(events) { | ||
9087 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); | ||
9088 | } | ||
9089 | |||
9090 | function accumulateTwoPhaseDispatchesSkipTarget(events) { | ||
9091 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); | ||
9092 | } | ||
9093 | |||
9094 | function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) { | ||
9095 | EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(fromID, toID, accumulateDispatches, leave, enter); | ||
9096 | } | ||
9097 | |||
9098 | function accumulateDirectDispatches(events) { | ||
9099 | forEachAccumulated(events, accumulateDirectDispatchesSingle); | ||
9100 | } | ||
9101 | |||
9102 | /** | ||
9103 | * A small set of propagation patterns, each of which will accept a small amount | ||
9104 | * of information, and generate a set of "dispatch ready event objects" - which | ||
9105 | * are sets of events that have already been annotated with a set of dispatched | ||
9106 | * listener functions/ids. The API is designed this way to discourage these | ||
9107 | * propagation strategies from actually executing the dispatches, since we | ||
9108 | * always want to collect the entire set of dispatches before executing event a | ||
9109 | * single one. | ||
9110 | * | ||
9111 | * @constructor EventPropagators | ||
9112 | */ | ||
9113 | var EventPropagators = { | ||
9114 | accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches, | ||
9115 | accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget, | ||
9116 | accumulateDirectDispatches: accumulateDirectDispatches, | ||
9117 | accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches | ||
9118 | }; | ||
9119 | |||
9120 | module.exports = EventPropagators; | ||
9121 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
9122 | |||
9123 | /***/ }, | ||
9124 | /* 76 */ | ||
9125 | /***/ function(module, exports, __webpack_require__) { | ||
9126 | |||
9127 | /** | ||
9128 | * Copyright 2013-2015, Facebook, Inc. | ||
9129 | * All rights reserved. | ||
9130 | * | ||
9131 | * This source code is licensed under the BSD-style license found in the | ||
9132 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9133 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9134 | * | ||
9135 | * @providesModule FallbackCompositionState | ||
9136 | * @typechecks static-only | ||
9137 | */ | ||
9138 | |||
9139 | 'use strict'; | ||
9140 | |||
9141 | var PooledClass = __webpack_require__(58); | ||
9142 | |||
9143 | var assign = __webpack_require__(41); | ||
9144 | var getTextContentAccessor = __webpack_require__(77); | ||
9145 | |||
9146 | /** | ||
9147 | * This helper class stores information about text content of a target node, | ||
9148 | * allowing comparison of content before and after a given event. | ||
9149 | * | ||
9150 | * Identify the node where selection currently begins, then observe | ||
9151 | * both its text content and its current position in the DOM. Since the | ||
9152 | * browser may natively replace the target node during composition, we can | ||
9153 | * use its position to find its replacement. | ||
9154 | * | ||
9155 | * @param {DOMEventTarget} root | ||
9156 | */ | ||
9157 | function FallbackCompositionState(root) { | ||
9158 | this._root = root; | ||
9159 | this._startText = this.getText(); | ||
9160 | this._fallbackText = null; | ||
9161 | } | ||
9162 | |||
9163 | assign(FallbackCompositionState.prototype, { | ||
9164 | destructor: function () { | ||
9165 | this._root = null; | ||
9166 | this._startText = null; | ||
9167 | this._fallbackText = null; | ||
9168 | }, | ||
9169 | |||
9170 | /** | ||
9171 | * Get current text of input. | ||
9172 | * | ||
9173 | * @return {string} | ||
9174 | */ | ||
9175 | getText: function () { | ||
9176 | if ('value' in this._root) { | ||
9177 | return this._root.value; | ||
9178 | } | ||
9179 | return this._root[getTextContentAccessor()]; | ||
9180 | }, | ||
9181 | |||
9182 | /** | ||
9183 | * Determine the differing substring between the initially stored | ||
9184 | * text content and the current content. | ||
9185 | * | ||
9186 | * @return {string} | ||
9187 | */ | ||
9188 | getData: function () { | ||
9189 | if (this._fallbackText) { | ||
9190 | return this._fallbackText; | ||
9191 | } | ||
9192 | |||
9193 | var start; | ||
9194 | var startValue = this._startText; | ||
9195 | var startLength = startValue.length; | ||
9196 | var end; | ||
9197 | var endValue = this.getText(); | ||
9198 | var endLength = endValue.length; | ||
9199 | |||
9200 | for (start = 0; start < startLength; start++) { | ||
9201 | if (startValue[start] !== endValue[start]) { | ||
9202 | break; | ||
9203 | } | ||
9204 | } | ||
9205 | |||
9206 | var minEnd = startLength - start; | ||
9207 | for (end = 1; end <= minEnd; end++) { | ||
9208 | if (startValue[startLength - end] !== endValue[endLength - end]) { | ||
9209 | break; | ||
9210 | } | ||
9211 | } | ||
9212 | |||
9213 | var sliceTail = end > 1 ? 1 - end : undefined; | ||
9214 | this._fallbackText = endValue.slice(start, sliceTail); | ||
9215 | return this._fallbackText; | ||
9216 | } | ||
9217 | }); | ||
9218 | |||
9219 | PooledClass.addPoolingTo(FallbackCompositionState); | ||
9220 | |||
9221 | module.exports = FallbackCompositionState; | ||
9222 | |||
9223 | /***/ }, | ||
9224 | /* 77 */ | ||
9225 | /***/ function(module, exports, __webpack_require__) { | ||
9226 | |||
9227 | /** | ||
9228 | * Copyright 2013-2015, Facebook, Inc. | ||
9229 | * All rights reserved. | ||
9230 | * | ||
9231 | * This source code is licensed under the BSD-style license found in the | ||
9232 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9233 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9234 | * | ||
9235 | * @providesModule getTextContentAccessor | ||
9236 | */ | ||
9237 | |||
9238 | 'use strict'; | ||
9239 | |||
9240 | var ExecutionEnvironment = __webpack_require__(11); | ||
9241 | |||
9242 | var contentKey = null; | ||
9243 | |||
9244 | /** | ||
9245 | * Gets the key used to access text content on a DOM node. | ||
9246 | * | ||
9247 | * @return {?string} Key used to access text content. | ||
9248 | * @internal | ||
9249 | */ | ||
9250 | function getTextContentAccessor() { | ||
9251 | if (!contentKey && ExecutionEnvironment.canUseDOM) { | ||
9252 | // Prefer textContent to innerText because many browsers support both but | ||
9253 | // SVG <text> elements don't support innerText even when <div> does. | ||
9254 | contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText'; | ||
9255 | } | ||
9256 | return contentKey; | ||
9257 | } | ||
9258 | |||
9259 | module.exports = getTextContentAccessor; | ||
9260 | |||
9261 | /***/ }, | ||
9262 | /* 78 */ | ||
9263 | /***/ function(module, exports, __webpack_require__) { | ||
9264 | |||
9265 | /** | ||
9266 | * Copyright 2013-2015, Facebook, Inc. | ||
9267 | * All rights reserved. | ||
9268 | * | ||
9269 | * This source code is licensed under the BSD-style license found in the | ||
9270 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9271 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9272 | * | ||
9273 | * @providesModule SyntheticCompositionEvent | ||
9274 | * @typechecks static-only | ||
9275 | */ | ||
9276 | |||
9277 | 'use strict'; | ||
9278 | |||
9279 | var SyntheticEvent = __webpack_require__(79); | ||
9280 | |||
9281 | /** | ||
9282 | * @interface Event | ||
9283 | * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents | ||
9284 | */ | ||
9285 | var CompositionEventInterface = { | ||
9286 | data: null | ||
9287 | }; | ||
9288 | |||
9289 | /** | ||
9290 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
9291 | * @param {string} dispatchMarker Marker identifying the event target. | ||
9292 | * @param {object} nativeEvent Native browser event. | ||
9293 | * @extends {SyntheticUIEvent} | ||
9294 | */ | ||
9295 | function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
9296 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
9297 | } | ||
9298 | |||
9299 | SyntheticEvent.augmentClass(SyntheticCompositionEvent, CompositionEventInterface); | ||
9300 | |||
9301 | module.exports = SyntheticCompositionEvent; | ||
9302 | |||
9303 | /***/ }, | ||
9304 | /* 79 */ | ||
9305 | /***/ function(module, exports, __webpack_require__) { | ||
9306 | |||
9307 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
9308 | * Copyright 2013-2015, Facebook, Inc. | ||
9309 | * All rights reserved. | ||
9310 | * | ||
9311 | * This source code is licensed under the BSD-style license found in the | ||
9312 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9313 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9314 | * | ||
9315 | * @providesModule SyntheticEvent | ||
9316 | * @typechecks static-only | ||
9317 | */ | ||
9318 | |||
9319 | 'use strict'; | ||
9320 | |||
9321 | var PooledClass = __webpack_require__(58); | ||
9322 | |||
9323 | var assign = __webpack_require__(41); | ||
9324 | var emptyFunction = __webpack_require__(17); | ||
9325 | var warning = __webpack_require__(27); | ||
9326 | |||
9327 | /** | ||
9328 | * @interface Event | ||
9329 | * @see http://www.w3.org/TR/DOM-Level-3-Events/ | ||
9330 | */ | ||
9331 | var EventInterface = { | ||
9332 | type: null, | ||
9333 | // currentTarget is set when dispatching; no use in copying it here | ||
9334 | currentTarget: emptyFunction.thatReturnsNull, | ||
9335 | eventPhase: null, | ||
9336 | bubbles: null, | ||
9337 | cancelable: null, | ||
9338 | timeStamp: function (event) { | ||
9339 | return event.timeStamp || Date.now(); | ||
9340 | }, | ||
9341 | defaultPrevented: null, | ||
9342 | isTrusted: null | ||
9343 | }; | ||
9344 | |||
9345 | /** | ||
9346 | * Synthetic events are dispatched by event plugins, typically in response to a | ||
9347 | * top-level event delegation handler. | ||
9348 | * | ||
9349 | * These systems should generally use pooling to reduce the frequency of garbage | ||
9350 | * collection. The system should check `isPersistent` to determine whether the | ||
9351 | * event should be released into the pool after being dispatched. Users that | ||
9352 | * need a persisted event should invoke `persist`. | ||
9353 | * | ||
9354 | * Synthetic events (and subclasses) implement the DOM Level 3 Events API by | ||
9355 | * normalizing browser quirks. Subclasses do not necessarily have to implement a | ||
9356 | * DOM interface; custom application-specific events can also subclass this. | ||
9357 | * | ||
9358 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
9359 | * @param {string} dispatchMarker Marker identifying the event target. | ||
9360 | * @param {object} nativeEvent Native browser event. | ||
9361 | */ | ||
9362 | function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
9363 | this.dispatchConfig = dispatchConfig; | ||
9364 | this.dispatchMarker = dispatchMarker; | ||
9365 | this.nativeEvent = nativeEvent; | ||
9366 | this.target = nativeEventTarget; | ||
9367 | this.currentTarget = nativeEventTarget; | ||
9368 | |||
9369 | var Interface = this.constructor.Interface; | ||
9370 | for (var propName in Interface) { | ||
9371 | if (!Interface.hasOwnProperty(propName)) { | ||
9372 | continue; | ||
9373 | } | ||
9374 | var normalize = Interface[propName]; | ||
9375 | if (normalize) { | ||
9376 | this[propName] = normalize(nativeEvent); | ||
9377 | } else { | ||
9378 | this[propName] = nativeEvent[propName]; | ||
9379 | } | ||
9380 | } | ||
9381 | |||
9382 | var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; | ||
9383 | if (defaultPrevented) { | ||
9384 | this.isDefaultPrevented = emptyFunction.thatReturnsTrue; | ||
9385 | } else { | ||
9386 | this.isDefaultPrevented = emptyFunction.thatReturnsFalse; | ||
9387 | } | ||
9388 | this.isPropagationStopped = emptyFunction.thatReturnsFalse; | ||
9389 | } | ||
9390 | |||
9391 | assign(SyntheticEvent.prototype, { | ||
9392 | |||
9393 | preventDefault: function () { | ||
9394 | this.defaultPrevented = true; | ||
9395 | var event = this.nativeEvent; | ||
9396 | if (process.env.NODE_ENV !== 'production') { | ||
9397 | process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `preventDefault` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined; | ||
9398 | } | ||
9399 | if (!event) { | ||
9400 | return; | ||
9401 | } | ||
9402 | |||
9403 | if (event.preventDefault) { | ||
9404 | event.preventDefault(); | ||
9405 | } else { | ||
9406 | event.returnValue = false; | ||
9407 | } | ||
9408 | this.isDefaultPrevented = emptyFunction.thatReturnsTrue; | ||
9409 | }, | ||
9410 | |||
9411 | stopPropagation: function () { | ||
9412 | var event = this.nativeEvent; | ||
9413 | if (process.env.NODE_ENV !== 'production') { | ||
9414 | process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `stopPropagation` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined; | ||
9415 | } | ||
9416 | if (!event) { | ||
9417 | return; | ||
9418 | } | ||
9419 | |||
9420 | if (event.stopPropagation) { | ||
9421 | event.stopPropagation(); | ||
9422 | } else { | ||
9423 | event.cancelBubble = true; | ||
9424 | } | ||
9425 | this.isPropagationStopped = emptyFunction.thatReturnsTrue; | ||
9426 | }, | ||
9427 | |||
9428 | /** | ||
9429 | * We release all dispatched `SyntheticEvent`s after each event loop, adding | ||
9430 | * them back into the pool. This allows a way to hold onto a reference that | ||
9431 | * won't be added back into the pool. | ||
9432 | */ | ||
9433 | persist: function () { | ||
9434 | this.isPersistent = emptyFunction.thatReturnsTrue; | ||
9435 | }, | ||
9436 | |||
9437 | /** | ||
9438 | * Checks if this event should be released back into the pool. | ||
9439 | * | ||
9440 | * @return {boolean} True if this should not be released, false otherwise. | ||
9441 | */ | ||
9442 | isPersistent: emptyFunction.thatReturnsFalse, | ||
9443 | |||
9444 | /** | ||
9445 | * `PooledClass` looks for `destructor` on each instance it releases. | ||
9446 | */ | ||
9447 | destructor: function () { | ||
9448 | var Interface = this.constructor.Interface; | ||
9449 | for (var propName in Interface) { | ||
9450 | this[propName] = null; | ||
9451 | } | ||
9452 | this.dispatchConfig = null; | ||
9453 | this.dispatchMarker = null; | ||
9454 | this.nativeEvent = null; | ||
9455 | } | ||
9456 | |||
9457 | }); | ||
9458 | |||
9459 | SyntheticEvent.Interface = EventInterface; | ||
9460 | |||
9461 | /** | ||
9462 | * Helper to reduce boilerplate when creating subclasses. | ||
9463 | * | ||
9464 | * @param {function} Class | ||
9465 | * @param {?object} Interface | ||
9466 | */ | ||
9467 | SyntheticEvent.augmentClass = function (Class, Interface) { | ||
9468 | var Super = this; | ||
9469 | |||
9470 | var prototype = Object.create(Super.prototype); | ||
9471 | assign(prototype, Class.prototype); | ||
9472 | Class.prototype = prototype; | ||
9473 | Class.prototype.constructor = Class; | ||
9474 | |||
9475 | Class.Interface = assign({}, Super.Interface, Interface); | ||
9476 | Class.augmentClass = Super.augmentClass; | ||
9477 | |||
9478 | PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler); | ||
9479 | }; | ||
9480 | |||
9481 | PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler); | ||
9482 | |||
9483 | module.exports = SyntheticEvent; | ||
9484 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
9485 | |||
9486 | /***/ }, | ||
9487 | /* 80 */ | ||
9488 | /***/ function(module, exports, __webpack_require__) { | ||
9489 | |||
9490 | /** | ||
9491 | * Copyright 2013-2015, Facebook, Inc. | ||
9492 | * All rights reserved. | ||
9493 | * | ||
9494 | * This source code is licensed under the BSD-style license found in the | ||
9495 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9496 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9497 | * | ||
9498 | * @providesModule SyntheticInputEvent | ||
9499 | * @typechecks static-only | ||
9500 | */ | ||
9501 | |||
9502 | 'use strict'; | ||
9503 | |||
9504 | var SyntheticEvent = __webpack_require__(79); | ||
9505 | |||
9506 | /** | ||
9507 | * @interface Event | ||
9508 | * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 | ||
9509 | * /#events-inputevents | ||
9510 | */ | ||
9511 | var InputEventInterface = { | ||
9512 | data: null | ||
9513 | }; | ||
9514 | |||
9515 | /** | ||
9516 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
9517 | * @param {string} dispatchMarker Marker identifying the event target. | ||
9518 | * @param {object} nativeEvent Native browser event. | ||
9519 | * @extends {SyntheticUIEvent} | ||
9520 | */ | ||
9521 | function SyntheticInputEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
9522 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
9523 | } | ||
9524 | |||
9525 | SyntheticEvent.augmentClass(SyntheticInputEvent, InputEventInterface); | ||
9526 | |||
9527 | module.exports = SyntheticInputEvent; | ||
9528 | |||
9529 | /***/ }, | ||
9530 | /* 81 */ | ||
9531 | /***/ function(module, exports) { | ||
9532 | |||
9533 | /** | ||
9534 | * Copyright 2013-2015, Facebook, Inc. | ||
9535 | * All rights reserved. | ||
9536 | * | ||
9537 | * This source code is licensed under the BSD-style license found in the | ||
9538 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9539 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9540 | * | ||
9541 | * @providesModule keyOf | ||
9542 | */ | ||
9543 | |||
9544 | /** | ||
9545 | * Allows extraction of a minified key. Let's the build system minify keys | ||
9546 | * without losing the ability to dynamically use key strings as values | ||
9547 | * themselves. Pass in an object with a single key/val pair and it will return | ||
9548 | * you the string key of that single record. Suppose you want to grab the | ||
9549 | * value for a key 'className' inside of an object. Key/val minification may | ||
9550 | * have aliased that key to be 'xa12'. keyOf({className: null}) will return | ||
9551 | * 'xa12' in that case. Resolve keys you want to use once at startup time, then | ||
9552 | * reuse those resolutions. | ||
9553 | */ | ||
9554 | "use strict"; | ||
9555 | |||
9556 | var keyOf = function (oneKeyObj) { | ||
9557 | var key; | ||
9558 | for (key in oneKeyObj) { | ||
9559 | if (!oneKeyObj.hasOwnProperty(key)) { | ||
9560 | continue; | ||
9561 | } | ||
9562 | return key; | ||
9563 | } | ||
9564 | return null; | ||
9565 | }; | ||
9566 | |||
9567 | module.exports = keyOf; | ||
9568 | |||
9569 | /***/ }, | ||
9570 | /* 82 */ | ||
9571 | /***/ function(module, exports, __webpack_require__) { | ||
9572 | |||
9573 | /** | ||
9574 | * Copyright 2013-2015, Facebook, Inc. | ||
9575 | * All rights reserved. | ||
9576 | * | ||
9577 | * This source code is licensed under the BSD-style license found in the | ||
9578 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9579 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9580 | * | ||
9581 | * @providesModule ChangeEventPlugin | ||
9582 | */ | ||
9583 | |||
9584 | 'use strict'; | ||
9585 | |||
9586 | var EventConstants = __webpack_require__(32); | ||
9587 | var EventPluginHub = __webpack_require__(33); | ||
9588 | var EventPropagators = __webpack_require__(75); | ||
9589 | var ExecutionEnvironment = __webpack_require__(11); | ||
9590 | var ReactUpdates = __webpack_require__(56); | ||
9591 | var SyntheticEvent = __webpack_require__(79); | ||
9592 | |||
9593 | var getEventTarget = __webpack_require__(83); | ||
9594 | var isEventSupported = __webpack_require__(42); | ||
9595 | var isTextInputElement = __webpack_require__(84); | ||
9596 | var keyOf = __webpack_require__(81); | ||
9597 | |||
9598 | var topLevelTypes = EventConstants.topLevelTypes; | ||
9599 | |||
9600 | var eventTypes = { | ||
9601 | change: { | ||
9602 | phasedRegistrationNames: { | ||
9603 | bubbled: keyOf({ onChange: null }), | ||
9604 | captured: keyOf({ onChangeCapture: null }) | ||
9605 | }, | ||
9606 | dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange] | ||
9607 | } | ||
9608 | }; | ||
9609 | |||
9610 | /** | ||
9611 | * For IE shims | ||
9612 | */ | ||
9613 | var activeElement = null; | ||
9614 | var activeElementID = null; | ||
9615 | var activeElementValue = null; | ||
9616 | var activeElementValueProp = null; | ||
9617 | |||
9618 | /** | ||
9619 | * SECTION: handle `change` event | ||
9620 | */ | ||
9621 | function shouldUseChangeEvent(elem) { | ||
9622 | var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); | ||
9623 | return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; | ||
9624 | } | ||
9625 | |||
9626 | var doesChangeEventBubble = false; | ||
9627 | if (ExecutionEnvironment.canUseDOM) { | ||
9628 | // See `handleChange` comment below | ||
9629 | doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8); | ||
9630 | } | ||
9631 | |||
9632 | function manualDispatchChangeEvent(nativeEvent) { | ||
9633 | var event = SyntheticEvent.getPooled(eventTypes.change, activeElementID, nativeEvent, getEventTarget(nativeEvent)); | ||
9634 | EventPropagators.accumulateTwoPhaseDispatches(event); | ||
9635 | |||
9636 | // If change and propertychange bubbled, we'd just bind to it like all the | ||
9637 | // other events and have it go through ReactBrowserEventEmitter. Since it | ||
9638 | // doesn't, we manually listen for the events and so we have to enqueue and | ||
9639 | // process the abstract event manually. | ||
9640 | // | ||
9641 | // Batching is necessary here in order to ensure that all event handlers run | ||
9642 | // before the next rerender (including event handlers attached to ancestor | ||
9643 | // elements instead of directly on the input). Without this, controlled | ||
9644 | // components don't work properly in conjunction with event bubbling because | ||
9645 | // the component is rerendered and the value reverted before all the event | ||
9646 | // handlers can run. See https://github.com/facebook/react/issues/708. | ||
9647 | ReactUpdates.batchedUpdates(runEventInBatch, event); | ||
9648 | } | ||
9649 | |||
9650 | function runEventInBatch(event) { | ||
9651 | EventPluginHub.enqueueEvents(event); | ||
9652 | EventPluginHub.processEventQueue(false); | ||
9653 | } | ||
9654 | |||
9655 | function startWatchingForChangeEventIE8(target, targetID) { | ||
9656 | activeElement = target; | ||
9657 | activeElementID = targetID; | ||
9658 | activeElement.attachEvent('onchange', manualDispatchChangeEvent); | ||
9659 | } | ||
9660 | |||
9661 | function stopWatchingForChangeEventIE8() { | ||
9662 | if (!activeElement) { | ||
9663 | return; | ||
9664 | } | ||
9665 | activeElement.detachEvent('onchange', manualDispatchChangeEvent); | ||
9666 | activeElement = null; | ||
9667 | activeElementID = null; | ||
9668 | } | ||
9669 | |||
9670 | function getTargetIDForChangeEvent(topLevelType, topLevelTarget, topLevelTargetID) { | ||
9671 | if (topLevelType === topLevelTypes.topChange) { | ||
9672 | return topLevelTargetID; | ||
9673 | } | ||
9674 | } | ||
9675 | function handleEventsForChangeEventIE8(topLevelType, topLevelTarget, topLevelTargetID) { | ||
9676 | if (topLevelType === topLevelTypes.topFocus) { | ||
9677 | // stopWatching() should be a noop here but we call it just in case we | ||
9678 | // missed a blur event somehow. | ||
9679 | stopWatchingForChangeEventIE8(); | ||
9680 | startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID); | ||
9681 | } else if (topLevelType === topLevelTypes.topBlur) { | ||
9682 | stopWatchingForChangeEventIE8(); | ||
9683 | } | ||
9684 | } | ||
9685 | |||
9686 | /** | ||
9687 | * SECTION: handle `input` event | ||
9688 | */ | ||
9689 | var isInputEventSupported = false; | ||
9690 | if (ExecutionEnvironment.canUseDOM) { | ||
9691 | // IE9 claims to support the input event but fails to trigger it when | ||
9692 | // deleting text, so we ignore its input events | ||
9693 | isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 9); | ||
9694 | } | ||
9695 | |||
9696 | /** | ||
9697 | * (For old IE.) Replacement getter/setter for the `value` property that gets | ||
9698 | * set on the active element. | ||
9699 | */ | ||
9700 | var newValueProp = { | ||
9701 | get: function () { | ||
9702 | return activeElementValueProp.get.call(this); | ||
9703 | }, | ||
9704 | set: function (val) { | ||
9705 | // Cast to a string so we can do equality checks. | ||
9706 | activeElementValue = '' + val; | ||
9707 | activeElementValueProp.set.call(this, val); | ||
9708 | } | ||
9709 | }; | ||
9710 | |||
9711 | /** | ||
9712 | * (For old IE.) Starts tracking propertychange events on the passed-in element | ||
9713 | * and override the value property so that we can distinguish user events from | ||
9714 | * value changes in JS. | ||
9715 | */ | ||
9716 | function startWatchingForValueChange(target, targetID) { | ||
9717 | activeElement = target; | ||
9718 | activeElementID = targetID; | ||
9719 | activeElementValue = target.value; | ||
9720 | activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value'); | ||
9721 | |||
9722 | // Not guarded in a canDefineProperty check: IE8 supports defineProperty only | ||
9723 | // on DOM elements | ||
9724 | Object.defineProperty(activeElement, 'value', newValueProp); | ||
9725 | activeElement.attachEvent('onpropertychange', handlePropertyChange); | ||
9726 | } | ||
9727 | |||
9728 | /** | ||
9729 | * (For old IE.) Removes the event listeners from the currently-tracked element, | ||
9730 | * if any exists. | ||
9731 | */ | ||
9732 | function stopWatchingForValueChange() { | ||
9733 | if (!activeElement) { | ||
9734 | return; | ||
9735 | } | ||
9736 | |||
9737 | // delete restores the original property definition | ||
9738 | delete activeElement.value; | ||
9739 | activeElement.detachEvent('onpropertychange', handlePropertyChange); | ||
9740 | |||
9741 | activeElement = null; | ||
9742 | activeElementID = null; | ||
9743 | activeElementValue = null; | ||
9744 | activeElementValueProp = null; | ||
9745 | } | ||
9746 | |||
9747 | /** | ||
9748 | * (For old IE.) Handles a propertychange event, sending a `change` event if | ||
9749 | * the value of the active element has changed. | ||
9750 | */ | ||
9751 | function handlePropertyChange(nativeEvent) { | ||
9752 | if (nativeEvent.propertyName !== 'value') { | ||
9753 | return; | ||
9754 | } | ||
9755 | var value = nativeEvent.srcElement.value; | ||
9756 | if (value === activeElementValue) { | ||
9757 | return; | ||
9758 | } | ||
9759 | activeElementValue = value; | ||
9760 | |||
9761 | manualDispatchChangeEvent(nativeEvent); | ||
9762 | } | ||
9763 | |||
9764 | /** | ||
9765 | * If a `change` event should be fired, returns the target's ID. | ||
9766 | */ | ||
9767 | function getTargetIDForInputEvent(topLevelType, topLevelTarget, topLevelTargetID) { | ||
9768 | if (topLevelType === topLevelTypes.topInput) { | ||
9769 | // In modern browsers (i.e., not IE8 or IE9), the input event is exactly | ||
9770 | // what we want so fall through here and trigger an abstract event | ||
9771 | return topLevelTargetID; | ||
9772 | } | ||
9773 | } | ||
9774 | |||
9775 | // For IE8 and IE9. | ||
9776 | function handleEventsForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) { | ||
9777 | if (topLevelType === topLevelTypes.topFocus) { | ||
9778 | // In IE8, we can capture almost all .value changes by adding a | ||
9779 | // propertychange handler and looking for events with propertyName | ||
9780 | // equal to 'value' | ||
9781 | // In IE9, propertychange fires for most input events but is buggy and | ||
9782 | // doesn't fire when text is deleted, but conveniently, selectionchange | ||
9783 | // appears to fire in all of the remaining cases so we catch those and | ||
9784 | // forward the event if the value has changed | ||
9785 | // In either case, we don't want to call the event handler if the value | ||
9786 | // is changed from JS so we redefine a setter for `.value` that updates | ||
9787 | // our activeElementValue variable, allowing us to ignore those changes | ||
9788 | // | ||
9789 | // stopWatching() should be a noop here but we call it just in case we | ||
9790 | // missed a blur event somehow. | ||
9791 | stopWatchingForValueChange(); | ||
9792 | startWatchingForValueChange(topLevelTarget, topLevelTargetID); | ||
9793 | } else if (topLevelType === topLevelTypes.topBlur) { | ||
9794 | stopWatchingForValueChange(); | ||
9795 | } | ||
9796 | } | ||
9797 | |||
9798 | // For IE8 and IE9. | ||
9799 | function getTargetIDForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) { | ||
9800 | if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) { | ||
9801 | // On the selectionchange event, the target is just document which isn't | ||
9802 | // helpful for us so just check activeElement instead. | ||
9803 | // | ||
9804 | // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire | ||
9805 | // propertychange on the first input event after setting `value` from a | ||
9806 | // script and fires only keydown, keypress, keyup. Catching keyup usually | ||
9807 | // gets it and catching keydown lets us fire an event for the first | ||
9808 | // keystroke if user does a key repeat (it'll be a little delayed: right | ||
9809 | // before the second keystroke). Other input methods (e.g., paste) seem to | ||
9810 | // fire selectionchange normally. | ||
9811 | if (activeElement && activeElement.value !== activeElementValue) { | ||
9812 | activeElementValue = activeElement.value; | ||
9813 | return activeElementID; | ||
9814 | } | ||
9815 | } | ||
9816 | } | ||
9817 | |||
9818 | /** | ||
9819 | * SECTION: handle `click` event | ||
9820 | */ | ||
9821 | function shouldUseClickEvent(elem) { | ||
9822 | // Use the `click` event to detect changes to checkbox and radio inputs. | ||
9823 | // This approach works across all browsers, whereas `change` does not fire | ||
9824 | // until `blur` in IE8. | ||
9825 | return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); | ||
9826 | } | ||
9827 | |||
9828 | function getTargetIDForClickEvent(topLevelType, topLevelTarget, topLevelTargetID) { | ||
9829 | if (topLevelType === topLevelTypes.topClick) { | ||
9830 | return topLevelTargetID; | ||
9831 | } | ||
9832 | } | ||
9833 | |||
9834 | /** | ||
9835 | * This plugin creates an `onChange` event that normalizes change events | ||
9836 | * across form elements. This event fires at a time when it's possible to | ||
9837 | * change the element's value without seeing a flicker. | ||
9838 | * | ||
9839 | * Supported elements are: | ||
9840 | * - input (see `isTextInputElement`) | ||
9841 | * - textarea | ||
9842 | * - select | ||
9843 | */ | ||
9844 | var ChangeEventPlugin = { | ||
9845 | |||
9846 | eventTypes: eventTypes, | ||
9847 | |||
9848 | /** | ||
9849 | * @param {string} topLevelType Record from `EventConstants`. | ||
9850 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
9851 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
9852 | * @param {object} nativeEvent Native browser event. | ||
9853 | * @return {*} An accumulation of synthetic events. | ||
9854 | * @see {EventPluginHub.extractEvents} | ||
9855 | */ | ||
9856 | extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
9857 | |||
9858 | var getTargetIDFunc, handleEventFunc; | ||
9859 | if (shouldUseChangeEvent(topLevelTarget)) { | ||
9860 | if (doesChangeEventBubble) { | ||
9861 | getTargetIDFunc = getTargetIDForChangeEvent; | ||
9862 | } else { | ||
9863 | handleEventFunc = handleEventsForChangeEventIE8; | ||
9864 | } | ||
9865 | } else if (isTextInputElement(topLevelTarget)) { | ||
9866 | if (isInputEventSupported) { | ||
9867 | getTargetIDFunc = getTargetIDForInputEvent; | ||
9868 | } else { | ||
9869 | getTargetIDFunc = getTargetIDForInputEventIE; | ||
9870 | handleEventFunc = handleEventsForInputEventIE; | ||
9871 | } | ||
9872 | } else if (shouldUseClickEvent(topLevelTarget)) { | ||
9873 | getTargetIDFunc = getTargetIDForClickEvent; | ||
9874 | } | ||
9875 | |||
9876 | if (getTargetIDFunc) { | ||
9877 | var targetID = getTargetIDFunc(topLevelType, topLevelTarget, topLevelTargetID); | ||
9878 | if (targetID) { | ||
9879 | var event = SyntheticEvent.getPooled(eventTypes.change, targetID, nativeEvent, nativeEventTarget); | ||
9880 | event.type = 'change'; | ||
9881 | EventPropagators.accumulateTwoPhaseDispatches(event); | ||
9882 | return event; | ||
9883 | } | ||
9884 | } | ||
9885 | |||
9886 | if (handleEventFunc) { | ||
9887 | handleEventFunc(topLevelType, topLevelTarget, topLevelTargetID); | ||
9888 | } | ||
9889 | } | ||
9890 | |||
9891 | }; | ||
9892 | |||
9893 | module.exports = ChangeEventPlugin; | ||
9894 | |||
9895 | /***/ }, | ||
9896 | /* 83 */ | ||
9897 | /***/ function(module, exports) { | ||
9898 | |||
9899 | /** | ||
9900 | * Copyright 2013-2015, Facebook, Inc. | ||
9901 | * All rights reserved. | ||
9902 | * | ||
9903 | * This source code is licensed under the BSD-style license found in the | ||
9904 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9905 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9906 | * | ||
9907 | * @providesModule getEventTarget | ||
9908 | * @typechecks static-only | ||
9909 | */ | ||
9910 | |||
9911 | 'use strict'; | ||
9912 | |||
9913 | /** | ||
9914 | * Gets the target node from a native browser event by accounting for | ||
9915 | * inconsistencies in browser DOM APIs. | ||
9916 | * | ||
9917 | * @param {object} nativeEvent Native browser event. | ||
9918 | * @return {DOMEventTarget} Target node. | ||
9919 | */ | ||
9920 | function getEventTarget(nativeEvent) { | ||
9921 | var target = nativeEvent.target || nativeEvent.srcElement || window; | ||
9922 | // Safari may fire events on text nodes (Node.TEXT_NODE is 3). | ||
9923 | // @see http://www.quirksmode.org/js/events_properties.html | ||
9924 | return target.nodeType === 3 ? target.parentNode : target; | ||
9925 | } | ||
9926 | |||
9927 | module.exports = getEventTarget; | ||
9928 | |||
9929 | /***/ }, | ||
9930 | /* 84 */ | ||
9931 | /***/ function(module, exports) { | ||
9932 | |||
9933 | /** | ||
9934 | * Copyright 2013-2015, Facebook, Inc. | ||
9935 | * All rights reserved. | ||
9936 | * | ||
9937 | * This source code is licensed under the BSD-style license found in the | ||
9938 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9939 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9940 | * | ||
9941 | * @providesModule isTextInputElement | ||
9942 | */ | ||
9943 | |||
9944 | 'use strict'; | ||
9945 | |||
9946 | /** | ||
9947 | * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary | ||
9948 | */ | ||
9949 | var supportedInputTypes = { | ||
9950 | 'color': true, | ||
9951 | 'date': true, | ||
9952 | 'datetime': true, | ||
9953 | 'datetime-local': true, | ||
9954 | 'email': true, | ||
9955 | 'month': true, | ||
9956 | 'number': true, | ||
9957 | 'password': true, | ||
9958 | 'range': true, | ||
9959 | 'search': true, | ||
9960 | 'tel': true, | ||
9961 | 'text': true, | ||
9962 | 'time': true, | ||
9963 | 'url': true, | ||
9964 | 'week': true | ||
9965 | }; | ||
9966 | |||
9967 | function isTextInputElement(elem) { | ||
9968 | var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | ||
9969 | return nodeName && (nodeName === 'input' && supportedInputTypes[elem.type] || nodeName === 'textarea'); | ||
9970 | } | ||
9971 | |||
9972 | module.exports = isTextInputElement; | ||
9973 | |||
9974 | /***/ }, | ||
9975 | /* 85 */ | ||
9976 | /***/ function(module, exports) { | ||
9977 | |||
9978 | /** | ||
9979 | * Copyright 2013-2015, Facebook, Inc. | ||
9980 | * All rights reserved. | ||
9981 | * | ||
9982 | * This source code is licensed under the BSD-style license found in the | ||
9983 | * LICENSE file in the root directory of this source tree. An additional grant | ||
9984 | * of patent rights can be found in the PATENTS file in the same directory. | ||
9985 | * | ||
9986 | * @providesModule ClientReactRootIndex | ||
9987 | * @typechecks | ||
9988 | */ | ||
9989 | |||
9990 | 'use strict'; | ||
9991 | |||
9992 | var nextReactRootIndex = 0; | ||
9993 | |||
9994 | var ClientReactRootIndex = { | ||
9995 | createReactRootIndex: function () { | ||
9996 | return nextReactRootIndex++; | ||
9997 | } | ||
9998 | }; | ||
9999 | |||
10000 | module.exports = ClientReactRootIndex; | ||
10001 | |||
10002 | /***/ }, | ||
10003 | /* 86 */ | ||
10004 | /***/ function(module, exports, __webpack_require__) { | ||
10005 | |||
10006 | /** | ||
10007 | * Copyright 2013-2015, Facebook, Inc. | ||
10008 | * All rights reserved. | ||
10009 | * | ||
10010 | * This source code is licensed under the BSD-style license found in the | ||
10011 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10012 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10013 | * | ||
10014 | * @providesModule DefaultEventPluginOrder | ||
10015 | */ | ||
10016 | |||
10017 | 'use strict'; | ||
10018 | |||
10019 | var keyOf = __webpack_require__(81); | ||
10020 | |||
10021 | /** | ||
10022 | * Module that is injectable into `EventPluginHub`, that specifies a | ||
10023 | * deterministic ordering of `EventPlugin`s. A convenient way to reason about | ||
10024 | * plugins, without having to package every one of them. This is better than | ||
10025 | * having plugins be ordered in the same order that they are injected because | ||
10026 | * that ordering would be influenced by the packaging order. | ||
10027 | * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that | ||
10028 | * preventing default on events is convenient in `SimpleEventPlugin` handlers. | ||
10029 | */ | ||
10030 | var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null })]; | ||
10031 | |||
10032 | module.exports = DefaultEventPluginOrder; | ||
10033 | |||
10034 | /***/ }, | ||
10035 | /* 87 */ | ||
10036 | /***/ function(module, exports, __webpack_require__) { | ||
10037 | |||
10038 | /** | ||
10039 | * Copyright 2013-2015, Facebook, Inc. | ||
10040 | * All rights reserved. | ||
10041 | * | ||
10042 | * This source code is licensed under the BSD-style license found in the | ||
10043 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10044 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10045 | * | ||
10046 | * @providesModule EnterLeaveEventPlugin | ||
10047 | * @typechecks static-only | ||
10048 | */ | ||
10049 | |||
10050 | 'use strict'; | ||
10051 | |||
10052 | var EventConstants = __webpack_require__(32); | ||
10053 | var EventPropagators = __webpack_require__(75); | ||
10054 | var SyntheticMouseEvent = __webpack_require__(88); | ||
10055 | |||
10056 | var ReactMount = __webpack_require__(30); | ||
10057 | var keyOf = __webpack_require__(81); | ||
10058 | |||
10059 | var topLevelTypes = EventConstants.topLevelTypes; | ||
10060 | var getFirstReactDOM = ReactMount.getFirstReactDOM; | ||
10061 | |||
10062 | var eventTypes = { | ||
10063 | mouseEnter: { | ||
10064 | registrationName: keyOf({ onMouseEnter: null }), | ||
10065 | dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver] | ||
10066 | }, | ||
10067 | mouseLeave: { | ||
10068 | registrationName: keyOf({ onMouseLeave: null }), | ||
10069 | dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver] | ||
10070 | } | ||
10071 | }; | ||
10072 | |||
10073 | var extractedEvents = [null, null]; | ||
10074 | |||
10075 | var EnterLeaveEventPlugin = { | ||
10076 | |||
10077 | eventTypes: eventTypes, | ||
10078 | |||
10079 | /** | ||
10080 | * For almost every interaction we care about, there will be both a top-level | ||
10081 | * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that | ||
10082 | * we do not extract duplicate events. However, moving the mouse into the | ||
10083 | * browser from outside will not fire a `mouseout` event. In this case, we use | ||
10084 | * the `mouseover` top-level event. | ||
10085 | * | ||
10086 | * @param {string} topLevelType Record from `EventConstants`. | ||
10087 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
10088 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
10089 | * @param {object} nativeEvent Native browser event. | ||
10090 | * @return {*} An accumulation of synthetic events. | ||
10091 | * @see {EventPluginHub.extractEvents} | ||
10092 | */ | ||
10093 | extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
10094 | if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { | ||
10095 | return null; | ||
10096 | } | ||
10097 | if (topLevelType !== topLevelTypes.topMouseOut && topLevelType !== topLevelTypes.topMouseOver) { | ||
10098 | // Must not be a mouse in or mouse out - ignoring. | ||
10099 | return null; | ||
10100 | } | ||
10101 | |||
10102 | var win; | ||
10103 | if (topLevelTarget.window === topLevelTarget) { | ||
10104 | // `topLevelTarget` is probably a window object. | ||
10105 | win = topLevelTarget; | ||
10106 | } else { | ||
10107 | // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. | ||
10108 | var doc = topLevelTarget.ownerDocument; | ||
10109 | if (doc) { | ||
10110 | win = doc.defaultView || doc.parentWindow; | ||
10111 | } else { | ||
10112 | win = window; | ||
10113 | } | ||
10114 | } | ||
10115 | |||
10116 | var from; | ||
10117 | var to; | ||
10118 | var fromID = ''; | ||
10119 | var toID = ''; | ||
10120 | if (topLevelType === topLevelTypes.topMouseOut) { | ||
10121 | from = topLevelTarget; | ||
10122 | fromID = topLevelTargetID; | ||
10123 | to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement); | ||
10124 | if (to) { | ||
10125 | toID = ReactMount.getID(to); | ||
10126 | } else { | ||
10127 | to = win; | ||
10128 | } | ||
10129 | to = to || win; | ||
10130 | } else { | ||
10131 | from = win; | ||
10132 | to = topLevelTarget; | ||
10133 | toID = topLevelTargetID; | ||
10134 | } | ||
10135 | |||
10136 | if (from === to) { | ||
10137 | // Nothing pertains to our managed components. | ||
10138 | return null; | ||
10139 | } | ||
10140 | |||
10141 | var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget); | ||
10142 | leave.type = 'mouseleave'; | ||
10143 | leave.target = from; | ||
10144 | leave.relatedTarget = to; | ||
10145 | |||
10146 | var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, toID, nativeEvent, nativeEventTarget); | ||
10147 | enter.type = 'mouseenter'; | ||
10148 | enter.target = to; | ||
10149 | enter.relatedTarget = from; | ||
10150 | |||
10151 | EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID); | ||
10152 | |||
10153 | extractedEvents[0] = leave; | ||
10154 | extractedEvents[1] = enter; | ||
10155 | |||
10156 | return extractedEvents; | ||
10157 | } | ||
10158 | |||
10159 | }; | ||
10160 | |||
10161 | module.exports = EnterLeaveEventPlugin; | ||
10162 | |||
10163 | /***/ }, | ||
10164 | /* 88 */ | ||
10165 | /***/ function(module, exports, __webpack_require__) { | ||
10166 | |||
10167 | /** | ||
10168 | * Copyright 2013-2015, Facebook, Inc. | ||
10169 | * All rights reserved. | ||
10170 | * | ||
10171 | * This source code is licensed under the BSD-style license found in the | ||
10172 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10173 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10174 | * | ||
10175 | * @providesModule SyntheticMouseEvent | ||
10176 | * @typechecks static-only | ||
10177 | */ | ||
10178 | |||
10179 | 'use strict'; | ||
10180 | |||
10181 | var SyntheticUIEvent = __webpack_require__(89); | ||
10182 | var ViewportMetrics = __webpack_require__(40); | ||
10183 | |||
10184 | var getEventModifierState = __webpack_require__(90); | ||
10185 | |||
10186 | /** | ||
10187 | * @interface MouseEvent | ||
10188 | * @see http://www.w3.org/TR/DOM-Level-3-Events/ | ||
10189 | */ | ||
10190 | var MouseEventInterface = { | ||
10191 | screenX: null, | ||
10192 | screenY: null, | ||
10193 | clientX: null, | ||
10194 | clientY: null, | ||
10195 | ctrlKey: null, | ||
10196 | shiftKey: null, | ||
10197 | altKey: null, | ||
10198 | metaKey: null, | ||
10199 | getModifierState: getEventModifierState, | ||
10200 | button: function (event) { | ||
10201 | // Webkit, Firefox, IE9+ | ||
10202 | // which: 1 2 3 | ||
10203 | // button: 0 1 2 (standard) | ||
10204 | var button = event.button; | ||
10205 | if ('which' in event) { | ||
10206 | return button; | ||
10207 | } | ||
10208 | // IE<9 | ||
10209 | // which: undefined | ||
10210 | // button: 0 0 0 | ||
10211 | // button: 1 4 2 (onmouseup) | ||
10212 | return button === 2 ? 2 : button === 4 ? 1 : 0; | ||
10213 | }, | ||
10214 | buttons: null, | ||
10215 | relatedTarget: function (event) { | ||
10216 | return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement); | ||
10217 | }, | ||
10218 | // "Proprietary" Interface. | ||
10219 | pageX: function (event) { | ||
10220 | return 'pageX' in event ? event.pageX : event.clientX + ViewportMetrics.currentScrollLeft; | ||
10221 | }, | ||
10222 | pageY: function (event) { | ||
10223 | return 'pageY' in event ? event.pageY : event.clientY + ViewportMetrics.currentScrollTop; | ||
10224 | } | ||
10225 | }; | ||
10226 | |||
10227 | /** | ||
10228 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
10229 | * @param {string} dispatchMarker Marker identifying the event target. | ||
10230 | * @param {object} nativeEvent Native browser event. | ||
10231 | * @extends {SyntheticUIEvent} | ||
10232 | */ | ||
10233 | function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
10234 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
10235 | } | ||
10236 | |||
10237 | SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface); | ||
10238 | |||
10239 | module.exports = SyntheticMouseEvent; | ||
10240 | |||
10241 | /***/ }, | ||
10242 | /* 89 */ | ||
10243 | /***/ function(module, exports, __webpack_require__) { | ||
10244 | |||
10245 | /** | ||
10246 | * Copyright 2013-2015, Facebook, Inc. | ||
10247 | * All rights reserved. | ||
10248 | * | ||
10249 | * This source code is licensed under the BSD-style license found in the | ||
10250 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10251 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10252 | * | ||
10253 | * @providesModule SyntheticUIEvent | ||
10254 | * @typechecks static-only | ||
10255 | */ | ||
10256 | |||
10257 | 'use strict'; | ||
10258 | |||
10259 | var SyntheticEvent = __webpack_require__(79); | ||
10260 | |||
10261 | var getEventTarget = __webpack_require__(83); | ||
10262 | |||
10263 | /** | ||
10264 | * @interface UIEvent | ||
10265 | * @see http://www.w3.org/TR/DOM-Level-3-Events/ | ||
10266 | */ | ||
10267 | var UIEventInterface = { | ||
10268 | view: function (event) { | ||
10269 | if (event.view) { | ||
10270 | return event.view; | ||
10271 | } | ||
10272 | |||
10273 | var target = getEventTarget(event); | ||
10274 | if (target != null && target.window === target) { | ||
10275 | // target is a window object | ||
10276 | return target; | ||
10277 | } | ||
10278 | |||
10279 | var doc = target.ownerDocument; | ||
10280 | // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. | ||
10281 | if (doc) { | ||
10282 | return doc.defaultView || doc.parentWindow; | ||
10283 | } else { | ||
10284 | return window; | ||
10285 | } | ||
10286 | }, | ||
10287 | detail: function (event) { | ||
10288 | return event.detail || 0; | ||
10289 | } | ||
10290 | }; | ||
10291 | |||
10292 | /** | ||
10293 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
10294 | * @param {string} dispatchMarker Marker identifying the event target. | ||
10295 | * @param {object} nativeEvent Native browser event. | ||
10296 | * @extends {SyntheticEvent} | ||
10297 | */ | ||
10298 | function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
10299 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
10300 | } | ||
10301 | |||
10302 | SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface); | ||
10303 | |||
10304 | module.exports = SyntheticUIEvent; | ||
10305 | |||
10306 | /***/ }, | ||
10307 | /* 90 */ | ||
10308 | /***/ function(module, exports) { | ||
10309 | |||
10310 | /** | ||
10311 | * Copyright 2013-2015, Facebook, Inc. | ||
10312 | * All rights reserved. | ||
10313 | * | ||
10314 | * This source code is licensed under the BSD-style license found in the | ||
10315 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10316 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10317 | * | ||
10318 | * @providesModule getEventModifierState | ||
10319 | * @typechecks static-only | ||
10320 | */ | ||
10321 | |||
10322 | 'use strict'; | ||
10323 | |||
10324 | /** | ||
10325 | * Translation from modifier key to the associated property in the event. | ||
10326 | * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers | ||
10327 | */ | ||
10328 | |||
10329 | var modifierKeyToProp = { | ||
10330 | 'Alt': 'altKey', | ||
10331 | 'Control': 'ctrlKey', | ||
10332 | 'Meta': 'metaKey', | ||
10333 | 'Shift': 'shiftKey' | ||
10334 | }; | ||
10335 | |||
10336 | // IE8 does not implement getModifierState so we simply map it to the only | ||
10337 | // modifier keys exposed by the event itself, does not support Lock-keys. | ||
10338 | // Currently, all major browsers except Chrome seems to support Lock-keys. | ||
10339 | function modifierStateGetter(keyArg) { | ||
10340 | var syntheticEvent = this; | ||
10341 | var nativeEvent = syntheticEvent.nativeEvent; | ||
10342 | if (nativeEvent.getModifierState) { | ||
10343 | return nativeEvent.getModifierState(keyArg); | ||
10344 | } | ||
10345 | var keyProp = modifierKeyToProp[keyArg]; | ||
10346 | return keyProp ? !!nativeEvent[keyProp] : false; | ||
10347 | } | ||
10348 | |||
10349 | function getEventModifierState(nativeEvent) { | ||
10350 | return modifierStateGetter; | ||
10351 | } | ||
10352 | |||
10353 | module.exports = getEventModifierState; | ||
10354 | |||
10355 | /***/ }, | ||
10356 | /* 91 */ | ||
10357 | /***/ function(module, exports, __webpack_require__) { | ||
10358 | |||
10359 | /** | ||
10360 | * Copyright 2013-2015, Facebook, Inc. | ||
10361 | * All rights reserved. | ||
10362 | * | ||
10363 | * This source code is licensed under the BSD-style license found in the | ||
10364 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10365 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10366 | * | ||
10367 | * @providesModule HTMLDOMPropertyConfig | ||
10368 | */ | ||
10369 | |||
10370 | 'use strict'; | ||
10371 | |||
10372 | var DOMProperty = __webpack_require__(25); | ||
10373 | var ExecutionEnvironment = __webpack_require__(11); | ||
10374 | |||
10375 | var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE; | ||
10376 | var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY; | ||
10377 | var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE; | ||
10378 | var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS; | ||
10379 | var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE; | ||
10380 | var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE; | ||
10381 | var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE; | ||
10382 | |||
10383 | var hasSVG; | ||
10384 | if (ExecutionEnvironment.canUseDOM) { | ||
10385 | var implementation = document.implementation; | ||
10386 | hasSVG = implementation && implementation.hasFeature && implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1'); | ||
10387 | } | ||
10388 | |||
10389 | var HTMLDOMPropertyConfig = { | ||
10390 | isCustomAttribute: RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/), | ||
10391 | Properties: { | ||
10392 | /** | ||
10393 | * Standard Properties | ||
10394 | */ | ||
10395 | accept: null, | ||
10396 | acceptCharset: null, | ||
10397 | accessKey: null, | ||
10398 | action: null, | ||
10399 | allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, | ||
10400 | allowTransparency: MUST_USE_ATTRIBUTE, | ||
10401 | alt: null, | ||
10402 | async: HAS_BOOLEAN_VALUE, | ||
10403 | autoComplete: null, | ||
10404 | // autoFocus is polyfilled/normalized by AutoFocusUtils | ||
10405 | // autoFocus: HAS_BOOLEAN_VALUE, | ||
10406 | autoPlay: HAS_BOOLEAN_VALUE, | ||
10407 | capture: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, | ||
10408 | cellPadding: null, | ||
10409 | cellSpacing: null, | ||
10410 | charSet: MUST_USE_ATTRIBUTE, | ||
10411 | challenge: MUST_USE_ATTRIBUTE, | ||
10412 | checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | ||
10413 | classID: MUST_USE_ATTRIBUTE, | ||
10414 | // To set className on SVG elements, it's necessary to use .setAttribute; | ||
10415 | // this works on HTML elements too in all browsers except IE8. Conveniently, | ||
10416 | // IE8 doesn't support SVG and so we can simply use the attribute in | ||
10417 | // browsers that support SVG and the property in browsers that don't, | ||
10418 | // regardless of whether the element is HTML or SVG. | ||
10419 | className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY, | ||
10420 | cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, | ||
10421 | colSpan: null, | ||
10422 | content: null, | ||
10423 | contentEditable: null, | ||
10424 | contextMenu: MUST_USE_ATTRIBUTE, | ||
10425 | controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | ||
10426 | coords: null, | ||
10427 | crossOrigin: null, | ||
10428 | data: null, // For `<object />` acts as `src`. | ||
10429 | dateTime: MUST_USE_ATTRIBUTE, | ||
10430 | 'default': HAS_BOOLEAN_VALUE, | ||
10431 | defer: HAS_BOOLEAN_VALUE, | ||
10432 | dir: null, | ||
10433 | disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, | ||
10434 | download: HAS_OVERLOADED_BOOLEAN_VALUE, | ||
10435 | draggable: null, | ||
10436 | encType: null, | ||
10437 | form: MUST_USE_ATTRIBUTE, | ||
10438 | formAction: MUST_USE_ATTRIBUTE, | ||
10439 | formEncType: MUST_USE_ATTRIBUTE, | ||
10440 | formMethod: MUST_USE_ATTRIBUTE, | ||
10441 | formNoValidate: HAS_BOOLEAN_VALUE, | ||
10442 | formTarget: MUST_USE_ATTRIBUTE, | ||
10443 | frameBorder: MUST_USE_ATTRIBUTE, | ||
10444 | headers: null, | ||
10445 | height: MUST_USE_ATTRIBUTE, | ||
10446 | hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, | ||
10447 | high: null, | ||
10448 | href: null, | ||
10449 | hrefLang: null, | ||
10450 | htmlFor: null, | ||
10451 | httpEquiv: null, | ||
10452 | icon: null, | ||
10453 | id: MUST_USE_PROPERTY, | ||
10454 | inputMode: MUST_USE_ATTRIBUTE, | ||
10455 | integrity: null, | ||
10456 | is: MUST_USE_ATTRIBUTE, | ||
10457 | keyParams: MUST_USE_ATTRIBUTE, | ||
10458 | keyType: MUST_USE_ATTRIBUTE, | ||
10459 | kind: null, | ||
10460 | label: null, | ||
10461 | lang: null, | ||
10462 | list: MUST_USE_ATTRIBUTE, | ||
10463 | loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | ||
10464 | low: null, | ||
10465 | manifest: MUST_USE_ATTRIBUTE, | ||
10466 | marginHeight: null, | ||
10467 | marginWidth: null, | ||
10468 | max: null, | ||
10469 | maxLength: MUST_USE_ATTRIBUTE, | ||
10470 | media: MUST_USE_ATTRIBUTE, | ||
10471 | mediaGroup: null, | ||
10472 | method: null, | ||
10473 | min: null, | ||
10474 | minLength: MUST_USE_ATTRIBUTE, | ||
10475 | multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | ||
10476 | muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | ||
10477 | name: null, | ||
10478 | noValidate: HAS_BOOLEAN_VALUE, | ||
10479 | open: HAS_BOOLEAN_VALUE, | ||
10480 | optimum: null, | ||
10481 | pattern: null, | ||
10482 | placeholder: null, | ||
10483 | poster: null, | ||
10484 | preload: null, | ||
10485 | radioGroup: null, | ||
10486 | readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | ||
10487 | rel: null, | ||
10488 | required: HAS_BOOLEAN_VALUE, | ||
10489 | role: MUST_USE_ATTRIBUTE, | ||
10490 | rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, | ||
10491 | rowSpan: null, | ||
10492 | sandbox: null, | ||
10493 | scope: null, | ||
10494 | scoped: HAS_BOOLEAN_VALUE, | ||
10495 | scrolling: null, | ||
10496 | seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, | ||
10497 | selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | ||
10498 | shape: null, | ||
10499 | size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, | ||
10500 | sizes: MUST_USE_ATTRIBUTE, | ||
10501 | span: HAS_POSITIVE_NUMERIC_VALUE, | ||
10502 | spellCheck: null, | ||
10503 | src: null, | ||
10504 | srcDoc: MUST_USE_PROPERTY, | ||
10505 | srcLang: null, | ||
10506 | srcSet: MUST_USE_ATTRIBUTE, | ||
10507 | start: HAS_NUMERIC_VALUE, | ||
10508 | step: null, | ||
10509 | style: null, | ||
10510 | summary: null, | ||
10511 | tabIndex: null, | ||
10512 | target: null, | ||
10513 | title: null, | ||
10514 | type: null, | ||
10515 | useMap: null, | ||
10516 | value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS, | ||
10517 | width: MUST_USE_ATTRIBUTE, | ||
10518 | wmode: MUST_USE_ATTRIBUTE, | ||
10519 | wrap: null, | ||
10520 | |||
10521 | /** | ||
10522 | * RDFa Properties | ||
10523 | */ | ||
10524 | about: MUST_USE_ATTRIBUTE, | ||
10525 | datatype: MUST_USE_ATTRIBUTE, | ||
10526 | inlist: MUST_USE_ATTRIBUTE, | ||
10527 | prefix: MUST_USE_ATTRIBUTE, | ||
10528 | // property is also supported for OpenGraph in meta tags. | ||
10529 | property: MUST_USE_ATTRIBUTE, | ||
10530 | resource: MUST_USE_ATTRIBUTE, | ||
10531 | 'typeof': MUST_USE_ATTRIBUTE, | ||
10532 | vocab: MUST_USE_ATTRIBUTE, | ||
10533 | |||
10534 | /** | ||
10535 | * Non-standard Properties | ||
10536 | */ | ||
10537 | // autoCapitalize and autoCorrect are supported in Mobile Safari for | ||
10538 | // keyboard hints. | ||
10539 | autoCapitalize: null, | ||
10540 | autoCorrect: null, | ||
10541 | // autoSave allows WebKit/Blink to persist values of input fields on page reloads | ||
10542 | autoSave: null, | ||
10543 | // color is for Safari mask-icon link | ||
10544 | color: null, | ||
10545 | // itemProp, itemScope, itemType are for | ||
10546 | // Microdata support. See http://schema.org/docs/gs.html | ||
10547 | itemProp: MUST_USE_ATTRIBUTE, | ||
10548 | itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, | ||
10549 | itemType: MUST_USE_ATTRIBUTE, | ||
10550 | // itemID and itemRef are for Microdata support as well but | ||
10551 | // only specified in the the WHATWG spec document. See | ||
10552 | // https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api | ||
10553 | itemID: MUST_USE_ATTRIBUTE, | ||
10554 | itemRef: MUST_USE_ATTRIBUTE, | ||
10555 | // results show looking glass icon and recent searches on input | ||
10556 | // search fields in WebKit/Blink | ||
10557 | results: null, | ||
10558 | // IE-only attribute that specifies security restrictions on an iframe | ||
10559 | // as an alternative to the sandbox attribute on IE<10 | ||
10560 | security: MUST_USE_ATTRIBUTE, | ||
10561 | // IE-only attribute that controls focus behavior | ||
10562 | unselectable: MUST_USE_ATTRIBUTE | ||
10563 | }, | ||
10564 | DOMAttributeNames: { | ||
10565 | acceptCharset: 'accept-charset', | ||
10566 | className: 'class', | ||
10567 | htmlFor: 'for', | ||
10568 | httpEquiv: 'http-equiv' | ||
10569 | }, | ||
10570 | DOMPropertyNames: { | ||
10571 | autoCapitalize: 'autocapitalize', | ||
10572 | autoComplete: 'autocomplete', | ||
10573 | autoCorrect: 'autocorrect', | ||
10574 | autoFocus: 'autofocus', | ||
10575 | autoPlay: 'autoplay', | ||
10576 | autoSave: 'autosave', | ||
10577 | // `encoding` is equivalent to `enctype`, IE8 lacks an `enctype` setter. | ||
10578 | // http://www.w3.org/TR/html5/forms.html#dom-fs-encoding | ||
10579 | encType: 'encoding', | ||
10580 | hrefLang: 'hreflang', | ||
10581 | radioGroup: 'radiogroup', | ||
10582 | spellCheck: 'spellcheck', | ||
10583 | srcDoc: 'srcdoc', | ||
10584 | srcSet: 'srcset' | ||
10585 | } | ||
10586 | }; | ||
10587 | |||
10588 | module.exports = HTMLDOMPropertyConfig; | ||
10589 | |||
10590 | /***/ }, | ||
10591 | /* 92 */ | ||
10592 | /***/ function(module, exports, __webpack_require__) { | ||
10593 | |||
10594 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
10595 | * Copyright 2013-2015, Facebook, Inc. | ||
10596 | * All rights reserved. | ||
10597 | * | ||
10598 | * This source code is licensed under the BSD-style license found in the | ||
10599 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10600 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10601 | * | ||
10602 | * @providesModule ReactBrowserComponentMixin | ||
10603 | */ | ||
10604 | |||
10605 | 'use strict'; | ||
10606 | |||
10607 | var ReactInstanceMap = __webpack_require__(49); | ||
10608 | |||
10609 | var findDOMNode = __webpack_require__(93); | ||
10610 | var warning = __webpack_require__(27); | ||
10611 | |||
10612 | var didWarnKey = '_getDOMNodeDidWarn'; | ||
10613 | |||
10614 | var ReactBrowserComponentMixin = { | ||
10615 | /** | ||
10616 | * Returns the DOM node rendered by this component. | ||
10617 | * | ||
10618 | * @return {DOMElement} The root node of this component. | ||
10619 | * @final | ||
10620 | * @protected | ||
10621 | */ | ||
10622 | getDOMNode: function () { | ||
10623 | process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + 'ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined; | ||
10624 | this.constructor[didWarnKey] = true; | ||
10625 | return findDOMNode(this); | ||
10626 | } | ||
10627 | }; | ||
10628 | |||
10629 | module.exports = ReactBrowserComponentMixin; | ||
10630 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
10631 | |||
10632 | /***/ }, | ||
10633 | /* 93 */ | ||
10634 | /***/ function(module, exports, __webpack_require__) { | ||
10635 | |||
10636 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
10637 | * Copyright 2013-2015, Facebook, Inc. | ||
10638 | * All rights reserved. | ||
10639 | * | ||
10640 | * This source code is licensed under the BSD-style license found in the | ||
10641 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10642 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10643 | * | ||
10644 | * @providesModule findDOMNode | ||
10645 | * @typechecks static-only | ||
10646 | */ | ||
10647 | |||
10648 | 'use strict'; | ||
10649 | |||
10650 | var ReactCurrentOwner = __webpack_require__(7); | ||
10651 | var ReactInstanceMap = __webpack_require__(49); | ||
10652 | var ReactMount = __webpack_require__(30); | ||
10653 | |||
10654 | var invariant = __webpack_require__(15); | ||
10655 | var warning = __webpack_require__(27); | ||
10656 | |||
10657 | /** | ||
10658 | * Returns the DOM node rendered by this element. | ||
10659 | * | ||
10660 | * @param {ReactComponent|DOMElement} componentOrElement | ||
10661 | * @return {?DOMElement} The root node of this element. | ||
10662 | */ | ||
10663 | function findDOMNode(componentOrElement) { | ||
10664 | if (process.env.NODE_ENV !== 'production') { | ||
10665 | var owner = ReactCurrentOwner.current; | ||
10666 | if (owner !== null) { | ||
10667 | process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing getDOMNode or findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined; | ||
10668 | owner._warnedAboutRefsInRender = true; | ||
10669 | } | ||
10670 | } | ||
10671 | if (componentOrElement == null) { | ||
10672 | return null; | ||
10673 | } | ||
10674 | if (componentOrElement.nodeType === 1) { | ||
10675 | return componentOrElement; | ||
10676 | } | ||
10677 | if (ReactInstanceMap.has(componentOrElement)) { | ||
10678 | return ReactMount.getNodeFromInstance(componentOrElement); | ||
10679 | } | ||
10680 | !(componentOrElement.render == null || typeof componentOrElement.render !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) : undefined; | ||
10681 | true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) : undefined; | ||
10682 | } | ||
10683 | |||
10684 | module.exports = findDOMNode; | ||
10685 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
10686 | |||
10687 | /***/ }, | ||
10688 | /* 94 */ | ||
10689 | /***/ function(module, exports, __webpack_require__) { | ||
10690 | |||
10691 | /** | ||
10692 | * Copyright 2013-2015, Facebook, Inc. | ||
10693 | * All rights reserved. | ||
10694 | * | ||
10695 | * This source code is licensed under the BSD-style license found in the | ||
10696 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10697 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10698 | * | ||
10699 | * @providesModule ReactDefaultBatchingStrategy | ||
10700 | */ | ||
10701 | |||
10702 | 'use strict'; | ||
10703 | |||
10704 | var ReactUpdates = __webpack_require__(56); | ||
10705 | var Transaction = __webpack_require__(59); | ||
10706 | |||
10707 | var assign = __webpack_require__(41); | ||
10708 | var emptyFunction = __webpack_require__(17); | ||
10709 | |||
10710 | var RESET_BATCHED_UPDATES = { | ||
10711 | initialize: emptyFunction, | ||
10712 | close: function () { | ||
10713 | ReactDefaultBatchingStrategy.isBatchingUpdates = false; | ||
10714 | } | ||
10715 | }; | ||
10716 | |||
10717 | var FLUSH_BATCHED_UPDATES = { | ||
10718 | initialize: emptyFunction, | ||
10719 | close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates) | ||
10720 | }; | ||
10721 | |||
10722 | var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES]; | ||
10723 | |||
10724 | function ReactDefaultBatchingStrategyTransaction() { | ||
10725 | this.reinitializeTransaction(); | ||
10726 | } | ||
10727 | |||
10728 | assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction.Mixin, { | ||
10729 | getTransactionWrappers: function () { | ||
10730 | return TRANSACTION_WRAPPERS; | ||
10731 | } | ||
10732 | }); | ||
10733 | |||
10734 | var transaction = new ReactDefaultBatchingStrategyTransaction(); | ||
10735 | |||
10736 | var ReactDefaultBatchingStrategy = { | ||
10737 | isBatchingUpdates: false, | ||
10738 | |||
10739 | /** | ||
10740 | * Call the provided function in a context within which calls to `setState` | ||
10741 | * and friends are batched such that components aren't updated unnecessarily. | ||
10742 | */ | ||
10743 | batchedUpdates: function (callback, a, b, c, d, e) { | ||
10744 | var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates; | ||
10745 | |||
10746 | ReactDefaultBatchingStrategy.isBatchingUpdates = true; | ||
10747 | |||
10748 | // The code is written this way to avoid extra allocations | ||
10749 | if (alreadyBatchingUpdates) { | ||
10750 | callback(a, b, c, d, e); | ||
10751 | } else { | ||
10752 | transaction.perform(callback, null, a, b, c, d, e); | ||
10753 | } | ||
10754 | } | ||
10755 | }; | ||
10756 | |||
10757 | module.exports = ReactDefaultBatchingStrategy; | ||
10758 | |||
10759 | /***/ }, | ||
10760 | /* 95 */ | ||
10761 | /***/ function(module, exports, __webpack_require__) { | ||
10762 | |||
10763 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
10764 | * Copyright 2013-2015, Facebook, Inc. | ||
10765 | * All rights reserved. | ||
10766 | * | ||
10767 | * This source code is licensed under the BSD-style license found in the | ||
10768 | * LICENSE file in the root directory of this source tree. An additional grant | ||
10769 | * of patent rights can be found in the PATENTS file in the same directory. | ||
10770 | * | ||
10771 | * @providesModule ReactDOMComponent | ||
10772 | * @typechecks static-only | ||
10773 | */ | ||
10774 | |||
10775 | /* global hasOwnProperty:true */ | ||
10776 | |||
10777 | 'use strict'; | ||
10778 | |||
10779 | var AutoFocusUtils = __webpack_require__(96); | ||
10780 | var CSSPropertyOperations = __webpack_require__(98); | ||
10781 | var DOMProperty = __webpack_require__(25); | ||
10782 | var DOMPropertyOperations = __webpack_require__(24); | ||
10783 | var EventConstants = __webpack_require__(32); | ||
10784 | var ReactBrowserEventEmitter = __webpack_require__(31); | ||
10785 | var ReactComponentBrowserEnvironment = __webpack_require__(28); | ||
10786 | var ReactDOMButton = __webpack_require__(106); | ||
10787 | var ReactDOMInput = __webpack_require__(107); | ||
10788 | var ReactDOMOption = __webpack_require__(111); | ||
10789 | var ReactDOMSelect = __webpack_require__(114); | ||
10790 | var ReactDOMTextarea = __webpack_require__(115); | ||
10791 | var ReactMount = __webpack_require__(30); | ||
10792 | var ReactMultiChild = __webpack_require__(116); | ||
10793 | var ReactPerf = __webpack_require__(20); | ||
10794 | var ReactUpdateQueue = __webpack_require__(55); | ||
10795 | |||
10796 | var assign = __webpack_require__(41); | ||
10797 | var canDefineProperty = __webpack_require__(45); | ||
10798 | var escapeTextContentForBrowser = __webpack_require__(23); | ||
10799 | var invariant = __webpack_require__(15); | ||
10800 | var isEventSupported = __webpack_require__(42); | ||
10801 | var keyOf = __webpack_require__(81); | ||
10802 | var setInnerHTML = __webpack_require__(21); | ||
10803 | var setTextContent = __webpack_require__(22); | ||
10804 | var shallowEqual = __webpack_require__(119); | ||
10805 | var validateDOMNesting = __webpack_require__(72); | ||
10806 | var warning = __webpack_require__(27); | ||
10807 | |||
10808 | var deleteListener = ReactBrowserEventEmitter.deleteListener; | ||
10809 | var listenTo = ReactBrowserEventEmitter.listenTo; | ||
10810 | var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules; | ||
10811 | |||
10812 | // For quickly matching children type, to test if can be treated as content. | ||
10813 | var CONTENT_TYPES = { 'string': true, 'number': true }; | ||
10814 | |||
10815 | var CHILDREN = keyOf({ children: null }); | ||
10816 | var STYLE = keyOf({ style: null }); | ||
10817 | var HTML = keyOf({ __html: null }); | ||
10818 | |||
10819 | var ELEMENT_NODE_TYPE = 1; | ||
10820 | |||
10821 | function getDeclarationErrorAddendum(internalInstance) { | ||
10822 | if (internalInstance) { | ||
10823 | var owner = internalInstance._currentElement._owner || null; | ||
10824 | if (owner) { | ||
10825 | var name = owner.getName(); | ||
10826 | if (name) { | ||
10827 | return ' This DOM node was rendered by `' + name + '`.'; | ||
10828 | } | ||
10829 | } | ||
10830 | } | ||
10831 | return ''; | ||
10832 | } | ||
10833 | |||
10834 | var legacyPropsDescriptor; | ||
10835 | if (process.env.NODE_ENV !== 'production') { | ||
10836 | legacyPropsDescriptor = { | ||
10837 | props: { | ||
10838 | enumerable: false, | ||
10839 | get: function () { | ||
10840 | var component = this._reactInternalComponent; | ||
10841 | process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .props of a DOM node; instead, ' + 'recreate the props as `render` did originally or read the DOM ' + 'properties/attributes directly from this node (e.g., ' + 'this.refs.box.className).%s', getDeclarationErrorAddendum(component)) : undefined; | ||
10842 | return component._currentElement.props; | ||
10843 | } | ||
10844 | } | ||
10845 | }; | ||
10846 | } | ||
10847 | |||
10848 | function legacyGetDOMNode() { | ||
10849 | if (process.env.NODE_ENV !== 'production') { | ||
10850 | var component = this._reactInternalComponent; | ||
10851 | process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .getDOMNode() of a DOM node; ' + 'instead, use the node directly.%s', getDeclarationErrorAddendum(component)) : undefined; | ||
10852 | } | ||
10853 | return this; | ||
10854 | } | ||
10855 | |||
10856 | function legacyIsMounted() { | ||
10857 | var component = this._reactInternalComponent; | ||
10858 | if (process.env.NODE_ENV !== 'production') { | ||
10859 | process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .isMounted() of a DOM node.%s', getDeclarationErrorAddendum(component)) : undefined; | ||
10860 | } | ||
10861 | return !!component; | ||
10862 | } | ||
10863 | |||
10864 | function legacySetStateEtc() { | ||
10865 | if (process.env.NODE_ENV !== 'production') { | ||
10866 | var component = this._reactInternalComponent; | ||
10867 | process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setState(), .replaceState(), or ' + '.forceUpdate() of a DOM node. This is a no-op.%s', getDeclarationErrorAddendum(component)) : undefined; | ||
10868 | } | ||
10869 | } | ||
10870 | |||
10871 | function legacySetProps(partialProps, callback) { | ||
10872 | var component = this._reactInternalComponent; | ||
10873 | if (process.env.NODE_ENV !== 'production') { | ||
10874 | process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined; | ||
10875 | } | ||
10876 | if (!component) { | ||
10877 | return; | ||
10878 | } | ||
10879 | ReactUpdateQueue.enqueueSetPropsInternal(component, partialProps); | ||
10880 | if (callback) { | ||
10881 | ReactUpdateQueue.enqueueCallbackInternal(component, callback); | ||
10882 | } | ||
10883 | } | ||
10884 | |||
10885 | function legacyReplaceProps(partialProps, callback) { | ||
10886 | var component = this._reactInternalComponent; | ||
10887 | if (process.env.NODE_ENV !== 'production') { | ||
10888 | process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .replaceProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined; | ||
10889 | } | ||
10890 | if (!component) { | ||
10891 | return; | ||
10892 | } | ||
10893 | ReactUpdateQueue.enqueueReplacePropsInternal(component, partialProps); | ||
10894 | if (callback) { | ||
10895 | ReactUpdateQueue.enqueueCallbackInternal(component, callback); | ||
10896 | } | ||
10897 | } | ||
10898 | |||
10899 | function friendlyStringify(obj) { | ||
10900 | if (typeof obj === 'object') { | ||
10901 | if (Array.isArray(obj)) { | ||
10902 | return '[' + obj.map(friendlyStringify).join(', ') + ']'; | ||
10903 | } else { | ||
10904 | var pairs = []; | ||
10905 | for (var key in obj) { | ||
10906 | if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
10907 | var keyEscaped = /^[a-z$_][\w$_]*$/i.test(key) ? key : JSON.stringify(key); | ||
10908 | pairs.push(keyEscaped + ': ' + friendlyStringify(obj[key])); | ||
10909 | } | ||
10910 | } | ||
10911 | return '{' + pairs.join(', ') + '}'; | ||
10912 | } | ||
10913 | } else if (typeof obj === 'string') { | ||
10914 | return JSON.stringify(obj); | ||
10915 | } else if (typeof obj === 'function') { | ||
10916 | return '[function object]'; | ||
10917 | } | ||
10918 | // Differs from JSON.stringify in that undefined becauses undefined and that | ||
10919 | // inf and nan don't become null | ||
10920 | return String(obj); | ||
10921 | } | ||
10922 | |||
10923 | var styleMutationWarning = {}; | ||
10924 | |||
10925 | function checkAndWarnForMutatedStyle(style1, style2, component) { | ||
10926 | if (style1 == null || style2 == null) { | ||
10927 | return; | ||
10928 | } | ||
10929 | if (shallowEqual(style1, style2)) { | ||
10930 | return; | ||
10931 | } | ||
10932 | |||
10933 | var componentName = component._tag; | ||
10934 | var owner = component._currentElement._owner; | ||
10935 | var ownerName; | ||
10936 | if (owner) { | ||
10937 | ownerName = owner.getName(); | ||
10938 | } | ||
10939 | |||
10940 | var hash = ownerName + '|' + componentName; | ||
10941 | |||
10942 | if (styleMutationWarning.hasOwnProperty(hash)) { | ||
10943 | return; | ||
10944 | } | ||
10945 | |||
10946 | styleMutationWarning[hash] = true; | ||
10947 | |||
10948 | process.env.NODE_ENV !== 'production' ? warning(false, '`%s` was passed a style object that has previously been mutated. ' + 'Mutating `style` is deprecated. Consider cloning it beforehand. Check ' + 'the `render` %s. Previous style: %s. Mutated style: %s.', componentName, owner ? 'of `' + ownerName + '`' : 'using <' + componentName + '>', friendlyStringify(style1), friendlyStringify(style2)) : undefined; | ||
10949 | } | ||
10950 | |||
10951 | /** | ||
10952 | * @param {object} component | ||
10953 | * @param {?object} props | ||
10954 | */ | ||
10955 | function assertValidProps(component, props) { | ||
10956 | if (!props) { | ||
10957 | return; | ||
10958 | } | ||
10959 | // Note the use of `==` which checks for null or undefined. | ||
10960 | if (process.env.NODE_ENV !== 'production') { | ||
10961 | if (voidElementTags[component._tag]) { | ||
10962 | process.env.NODE_ENV !== 'production' ? warning(props.children == null && props.dangerouslySetInnerHTML == null, '%s is a void element tag and must not have `children` or ' + 'use `props.dangerouslySetInnerHTML`.%s', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : undefined; | ||
10963 | } | ||
10964 | } | ||
10965 | if (props.dangerouslySetInnerHTML != null) { | ||
10966 | !(props.children == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : invariant(false) : undefined; | ||
10967 | !(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.') : invariant(false) : undefined; | ||
10968 | } | ||
10969 | if (process.env.NODE_ENV !== 'production') { | ||
10970 | process.env.NODE_ENV !== 'production' ? warning(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.') : undefined; | ||
10971 | process.env.NODE_ENV !== 'production' ? warning(!props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : undefined; | ||
10972 | } | ||
10973 | !(props.style == null || typeof props.style === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)) : invariant(false) : undefined; | ||
10974 | } | ||
10975 | |||
10976 | function enqueuePutListener(id, registrationName, listener, transaction) { | ||
10977 | if (process.env.NODE_ENV !== 'production') { | ||
10978 | // IE8 has no API for event capturing and the `onScroll` event doesn't | ||
10979 | // bubble. | ||
10980 | process.env.NODE_ENV !== 'production' ? warning(registrationName !== 'onScroll' || isEventSupported('scroll', true), 'This browser doesn\'t support the `onScroll` event') : undefined; | ||
10981 | } | ||
10982 | var container = ReactMount.findReactContainerForID(id); | ||
10983 | if (container) { | ||
10984 | var doc = container.nodeType === ELEMENT_NODE_TYPE ? container.ownerDocument : container; | ||
10985 | listenTo(registrationName, doc); | ||
10986 | } | ||
10987 | transaction.getReactMountReady().enqueue(putListener, { | ||
10988 | id: id, | ||
10989 | registrationName: registrationName, | ||
10990 | listener: listener | ||
10991 | }); | ||
10992 | } | ||
10993 | |||
10994 | function putListener() { | ||
10995 | var listenerToPut = this; | ||
10996 | ReactBrowserEventEmitter.putListener(listenerToPut.id, listenerToPut.registrationName, listenerToPut.listener); | ||
10997 | } | ||
10998 | |||
10999 | // There are so many media events, it makes sense to just | ||
11000 | // maintain a list rather than create a `trapBubbledEvent` for each | ||
11001 | var mediaEvents = { | ||
11002 | topAbort: 'abort', | ||
11003 | topCanPlay: 'canplay', | ||
11004 | topCanPlayThrough: 'canplaythrough', | ||
11005 | topDurationChange: 'durationchange', | ||
11006 | topEmptied: 'emptied', | ||
11007 | topEncrypted: 'encrypted', | ||
11008 | topEnded: 'ended', | ||
11009 | topError: 'error', | ||
11010 | topLoadedData: 'loadeddata', | ||
11011 | topLoadedMetadata: 'loadedmetadata', | ||
11012 | topLoadStart: 'loadstart', | ||
11013 | topPause: 'pause', | ||
11014 | topPlay: 'play', | ||
11015 | topPlaying: 'playing', | ||
11016 | topProgress: 'progress', | ||
11017 | topRateChange: 'ratechange', | ||
11018 | topSeeked: 'seeked', | ||
11019 | topSeeking: 'seeking', | ||
11020 | topStalled: 'stalled', | ||
11021 | topSuspend: 'suspend', | ||
11022 | topTimeUpdate: 'timeupdate', | ||
11023 | topVolumeChange: 'volumechange', | ||
11024 | topWaiting: 'waiting' | ||
11025 | }; | ||
11026 | |||
11027 | function trapBubbledEventsLocal() { | ||
11028 | var inst = this; | ||
11029 | // If a component renders to null or if another component fatals and causes | ||
11030 | // the state of the tree to be corrupted, `node` here can be null. | ||
11031 | !inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Must be mounted to trap events') : invariant(false) : undefined; | ||
11032 | var node = ReactMount.getNode(inst._rootNodeID); | ||
11033 | !node ? process.env.NODE_ENV !== 'production' ? invariant(false, 'trapBubbledEvent(...): Requires node to be rendered.') : invariant(false) : undefined; | ||
11034 | |||
11035 | switch (inst._tag) { | ||
11036 | case 'iframe': | ||
11037 | inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)]; | ||
11038 | break; | ||
11039 | case 'video': | ||
11040 | case 'audio': | ||
11041 | |||
11042 | inst._wrapperState.listeners = []; | ||
11043 | // create listener for each media event | ||
11044 | for (var event in mediaEvents) { | ||
11045 | if (mediaEvents.hasOwnProperty(event)) { | ||
11046 | inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes[event], mediaEvents[event], node)); | ||
11047 | } | ||
11048 | } | ||
11049 | |||
11050 | break; | ||
11051 | case 'img': | ||
11052 | inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)]; | ||
11053 | break; | ||
11054 | case 'form': | ||
11055 | inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit', node)]; | ||
11056 | break; | ||
11057 | } | ||
11058 | } | ||
11059 | |||
11060 | function mountReadyInputWrapper() { | ||
11061 | ReactDOMInput.mountReadyWrapper(this); | ||
11062 | } | ||
11063 | |||
11064 | function postUpdateSelectWrapper() { | ||
11065 | ReactDOMSelect.postUpdateWrapper(this); | ||
11066 | } | ||
11067 | |||
11068 | // For HTML, certain tags should omit their close tag. We keep a whitelist for | ||
11069 | // those special cased tags. | ||
11070 | |||
11071 | var omittedCloseTags = { | ||
11072 | 'area': true, | ||
11073 | 'base': true, | ||
11074 | 'br': true, | ||
11075 | 'col': true, | ||
11076 | 'embed': true, | ||
11077 | 'hr': true, | ||
11078 | 'img': true, | ||
11079 | 'input': true, | ||
11080 | 'keygen': true, | ||
11081 | 'link': true, | ||
11082 | 'meta': true, | ||
11083 | 'param': true, | ||
11084 | 'source': true, | ||
11085 | 'track': true, | ||
11086 | 'wbr': true | ||
11087 | }; | ||
11088 | |||
11089 | // NOTE: menuitem's close tag should be omitted, but that causes problems. | ||
11090 | var newlineEatingTags = { | ||
11091 | 'listing': true, | ||
11092 | 'pre': true, | ||
11093 | 'textarea': true | ||
11094 | }; | ||
11095 | |||
11096 | // For HTML, certain tags cannot have children. This has the same purpose as | ||
11097 | // `omittedCloseTags` except that `menuitem` should still have its closing tag. | ||
11098 | |||
11099 | var voidElementTags = assign({ | ||
11100 | 'menuitem': true | ||
11101 | }, omittedCloseTags); | ||
11102 | |||
11103 | // We accept any tag to be rendered but since this gets injected into arbitrary | ||
11104 | // HTML, we want to make sure that it's a safe tag. | ||
11105 | // http://www.w3.org/TR/REC-xml/#NT-Name | ||
11106 | |||
11107 | var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset | ||
11108 | var validatedTagCache = {}; | ||
11109 | var hasOwnProperty = ({}).hasOwnProperty; | ||
11110 | |||
11111 | function validateDangerousTag(tag) { | ||
11112 | if (!hasOwnProperty.call(validatedTagCache, tag)) { | ||
11113 | !VALID_TAG_REGEX.test(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Invalid tag: %s', tag) : invariant(false) : undefined; | ||
11114 | validatedTagCache[tag] = true; | ||
11115 | } | ||
11116 | } | ||
11117 | |||
11118 | function processChildContextDev(context, inst) { | ||
11119 | // Pass down our tag name to child components for validation purposes | ||
11120 | context = assign({}, context); | ||
11121 | var info = context[validateDOMNesting.ancestorInfoContextKey]; | ||
11122 | context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(info, inst._tag, inst); | ||
11123 | return context; | ||
11124 | } | ||
11125 | |||
11126 | function isCustomComponent(tagName, props) { | ||
11127 | return tagName.indexOf('-') >= 0 || props.is != null; | ||
11128 | } | ||
11129 | |||
11130 | /** | ||
11131 | * Creates a new React class that is idempotent and capable of containing other | ||
11132 | * React components. It accepts event listeners and DOM properties that are | ||
11133 | * valid according to `DOMProperty`. | ||
11134 | * | ||
11135 | * - Event listeners: `onClick`, `onMouseDown`, etc. | ||
11136 | * - DOM properties: `className`, `name`, `title`, etc. | ||
11137 | * | ||
11138 | * The `style` property functions differently from the DOM API. It accepts an | ||
11139 | * object mapping of style properties to values. | ||
11140 | * | ||
11141 | * @constructor ReactDOMComponent | ||
11142 | * @extends ReactMultiChild | ||
11143 | */ | ||
11144 | function ReactDOMComponent(tag) { | ||
11145 | validateDangerousTag(tag); | ||
11146 | this._tag = tag.toLowerCase(); | ||
11147 | this._renderedChildren = null; | ||
11148 | this._previousStyle = null; | ||
11149 | this._previousStyleCopy = null; | ||
11150 | this._rootNodeID = null; | ||
11151 | this._wrapperState = null; | ||
11152 | this._topLevelWrapper = null; | ||
11153 | this._nodeWithLegacyProperties = null; | ||
11154 | if (process.env.NODE_ENV !== 'production') { | ||
11155 | this._unprocessedContextDev = null; | ||
11156 | this._processedContextDev = null; | ||
11157 | } | ||
11158 | } | ||
11159 | |||
11160 | ReactDOMComponent.displayName = 'ReactDOMComponent'; | ||
11161 | |||
11162 | ReactDOMComponent.Mixin = { | ||
11163 | |||
11164 | construct: function (element) { | ||
11165 | this._currentElement = element; | ||
11166 | }, | ||
11167 | |||
11168 | /** | ||
11169 | * Generates root tag markup then recurses. This method has side effects and | ||
11170 | * is not idempotent. | ||
11171 | * | ||
11172 | * @internal | ||
11173 | * @param {string} rootID The root DOM ID for this node. | ||
11174 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
11175 | * @param {object} context | ||
11176 | * @return {string} The computed markup. | ||
11177 | */ | ||
11178 | mountComponent: function (rootID, transaction, context) { | ||
11179 | this._rootNodeID = rootID; | ||
11180 | |||
11181 | var props = this._currentElement.props; | ||
11182 | |||
11183 | switch (this._tag) { | ||
11184 | case 'iframe': | ||
11185 | case 'img': | ||
11186 | case 'form': | ||
11187 | case 'video': | ||
11188 | case 'audio': | ||
11189 | this._wrapperState = { | ||
11190 | listeners: null | ||
11191 | }; | ||
11192 | transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this); | ||
11193 | break; | ||
11194 | case 'button': | ||
11195 | props = ReactDOMButton.getNativeProps(this, props, context); | ||
11196 | break; | ||
11197 | case 'input': | ||
11198 | ReactDOMInput.mountWrapper(this, props, context); | ||
11199 | props = ReactDOMInput.getNativeProps(this, props, context); | ||
11200 | break; | ||
11201 | case 'option': | ||
11202 | ReactDOMOption.mountWrapper(this, props, context); | ||
11203 | props = ReactDOMOption.getNativeProps(this, props, context); | ||
11204 | break; | ||
11205 | case 'select': | ||
11206 | ReactDOMSelect.mountWrapper(this, props, context); | ||
11207 | props = ReactDOMSelect.getNativeProps(this, props, context); | ||
11208 | context = ReactDOMSelect.processChildContext(this, props, context); | ||
11209 | break; | ||
11210 | case 'textarea': | ||
11211 | ReactDOMTextarea.mountWrapper(this, props, context); | ||
11212 | props = ReactDOMTextarea.getNativeProps(this, props, context); | ||
11213 | break; | ||
11214 | } | ||
11215 | |||
11216 | assertValidProps(this, props); | ||
11217 | if (process.env.NODE_ENV !== 'production') { | ||
11218 | if (context[validateDOMNesting.ancestorInfoContextKey]) { | ||
11219 | validateDOMNesting(this._tag, this, context[validateDOMNesting.ancestorInfoContextKey]); | ||
11220 | } | ||
11221 | } | ||
11222 | |||
11223 | if (process.env.NODE_ENV !== 'production') { | ||
11224 | this._unprocessedContextDev = context; | ||
11225 | this._processedContextDev = processChildContextDev(context, this); | ||
11226 | context = this._processedContextDev; | ||
11227 | } | ||
11228 | |||
11229 | var mountImage; | ||
11230 | if (transaction.useCreateElement) { | ||
11231 | var ownerDocument = context[ReactMount.ownerDocumentContextKey]; | ||
11232 | var el = ownerDocument.createElement(this._currentElement.type); | ||
11233 | DOMPropertyOperations.setAttributeForID(el, this._rootNodeID); | ||
11234 | // Populate node cache | ||
11235 | ReactMount.getID(el); | ||
11236 | this._updateDOMProperties({}, props, transaction, el); | ||
11237 | this._createInitialChildren(transaction, props, context, el); | ||
11238 | mountImage = el; | ||
11239 | } else { | ||
11240 | var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props); | ||
11241 | var tagContent = this._createContentMarkup(transaction, props, context); | ||
11242 | if (!tagContent && omittedCloseTags[this._tag]) { | ||
11243 | mountImage = tagOpen + '/>'; | ||
11244 | } else { | ||
11245 | mountImage = tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>'; | ||
11246 | } | ||
11247 | } | ||
11248 | |||
11249 | switch (this._tag) { | ||
11250 | case 'input': | ||
11251 | transaction.getReactMountReady().enqueue(mountReadyInputWrapper, this); | ||
11252 | // falls through | ||
11253 | case 'button': | ||
11254 | case 'select': | ||
11255 | case 'textarea': | ||
11256 | if (props.autoFocus) { | ||
11257 | transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this); | ||
11258 | } | ||
11259 | break; | ||
11260 | } | ||
11261 | |||
11262 | return mountImage; | ||
11263 | }, | ||
11264 | |||
11265 | /** | ||
11266 | * Creates markup for the open tag and all attributes. | ||
11267 | * | ||
11268 | * This method has side effects because events get registered. | ||
11269 | * | ||
11270 | * Iterating over object properties is faster than iterating over arrays. | ||
11271 | * @see http://jsperf.com/obj-vs-arr-iteration | ||
11272 | * | ||
11273 | * @private | ||
11274 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
11275 | * @param {object} props | ||
11276 | * @return {string} Markup of opening tag. | ||
11277 | */ | ||
11278 | _createOpenTagMarkupAndPutListeners: function (transaction, props) { | ||
11279 | var ret = '<' + this._currentElement.type; | ||
11280 | |||
11281 | for (var propKey in props) { | ||
11282 | if (!props.hasOwnProperty(propKey)) { | ||
11283 | continue; | ||
11284 | } | ||
11285 | var propValue = props[propKey]; | ||
11286 | if (propValue == null) { | ||
11287 | continue; | ||
11288 | } | ||
11289 | if (registrationNameModules.hasOwnProperty(propKey)) { | ||
11290 | if (propValue) { | ||
11291 | enqueuePutListener(this._rootNodeID, propKey, propValue, transaction); | ||
11292 | } | ||
11293 | } else { | ||
11294 | if (propKey === STYLE) { | ||
11295 | if (propValue) { | ||
11296 | if (process.env.NODE_ENV !== 'production') { | ||
11297 | // See `_updateDOMProperties`. style block | ||
11298 | this._previousStyle = propValue; | ||
11299 | } | ||
11300 | propValue = this._previousStyleCopy = assign({}, props.style); | ||
11301 | } | ||
11302 | propValue = CSSPropertyOperations.createMarkupForStyles(propValue); | ||
11303 | } | ||
11304 | var markup = null; | ||
11305 | if (this._tag != null && isCustomComponent(this._tag, props)) { | ||
11306 | if (propKey !== CHILDREN) { | ||
11307 | markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); | ||
11308 | } | ||
11309 | } else { | ||
11310 | markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue); | ||
11311 | } | ||
11312 | if (markup) { | ||
11313 | ret += ' ' + markup; | ||
11314 | } | ||
11315 | } | ||
11316 | } | ||
11317 | |||
11318 | // For static pages, no need to put React ID and checksum. Saves lots of | ||
11319 | // bytes. | ||
11320 | if (transaction.renderToStaticMarkup) { | ||
11321 | return ret; | ||
11322 | } | ||
11323 | |||
11324 | var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID); | ||
11325 | return ret + ' ' + markupForID; | ||
11326 | }, | ||
11327 | |||
11328 | /** | ||
11329 | * Creates markup for the content between the tags. | ||
11330 | * | ||
11331 | * @private | ||
11332 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
11333 | * @param {object} props | ||
11334 | * @param {object} context | ||
11335 | * @return {string} Content markup. | ||
11336 | */ | ||
11337 | _createContentMarkup: function (transaction, props, context) { | ||
11338 | var ret = ''; | ||
11339 | |||
11340 | // Intentional use of != to avoid catching zero/false. | ||
11341 | var innerHTML = props.dangerouslySetInnerHTML; | ||
11342 | if (innerHTML != null) { | ||
11343 | if (innerHTML.__html != null) { | ||
11344 | ret = innerHTML.__html; | ||
11345 | } | ||
11346 | } else { | ||
11347 | var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null; | ||
11348 | var childrenToUse = contentToUse != null ? null : props.children; | ||
11349 | if (contentToUse != null) { | ||
11350 | // TODO: Validate that text is allowed as a child of this node | ||
11351 | ret = escapeTextContentForBrowser(contentToUse); | ||
11352 | } else if (childrenToUse != null) { | ||
11353 | var mountImages = this.mountChildren(childrenToUse, transaction, context); | ||
11354 | ret = mountImages.join(''); | ||
11355 | } | ||
11356 | } | ||
11357 | if (newlineEatingTags[this._tag] && ret.charAt(0) === '\n') { | ||
11358 | // text/html ignores the first character in these tags if it's a newline | ||
11359 | // Prefer to break application/xml over text/html (for now) by adding | ||
11360 | // a newline specifically to get eaten by the parser. (Alternately for | ||
11361 | // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first | ||
11362 | // \r is normalized out by HTMLTextAreaElement#value.) | ||
11363 | // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre> | ||
11364 | // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions> | ||
11365 | // See: <http://www.w3.org/TR/html5/syntax.html#newlines> | ||
11366 | // See: Parsing of "textarea" "listing" and "pre" elements | ||
11367 | // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody> | ||
11368 | return '\n' + ret; | ||
11369 | } else { | ||
11370 | return ret; | ||
11371 | } | ||
11372 | }, | ||
11373 | |||
11374 | _createInitialChildren: function (transaction, props, context, el) { | ||
11375 | // Intentional use of != to avoid catching zero/false. | ||
11376 | var innerHTML = props.dangerouslySetInnerHTML; | ||
11377 | if (innerHTML != null) { | ||
11378 | if (innerHTML.__html != null) { | ||
11379 | setInnerHTML(el, innerHTML.__html); | ||
11380 | } | ||
11381 | } else { | ||
11382 | var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null; | ||
11383 | var childrenToUse = contentToUse != null ? null : props.children; | ||
11384 | if (contentToUse != null) { | ||
11385 | // TODO: Validate that text is allowed as a child of this node | ||
11386 | setTextContent(el, contentToUse); | ||
11387 | } else if (childrenToUse != null) { | ||
11388 | var mountImages = this.mountChildren(childrenToUse, transaction, context); | ||
11389 | for (var i = 0; i < mountImages.length; i++) { | ||
11390 | el.appendChild(mountImages[i]); | ||
11391 | } | ||
11392 | } | ||
11393 | } | ||
11394 | }, | ||
11395 | |||
11396 | /** | ||
11397 | * Receives a next element and updates the component. | ||
11398 | * | ||
11399 | * @internal | ||
11400 | * @param {ReactElement} nextElement | ||
11401 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
11402 | * @param {object} context | ||
11403 | */ | ||
11404 | receiveComponent: function (nextElement, transaction, context) { | ||
11405 | var prevElement = this._currentElement; | ||
11406 | this._currentElement = nextElement; | ||
11407 | this.updateComponent(transaction, prevElement, nextElement, context); | ||
11408 | }, | ||
11409 | |||
11410 | /** | ||
11411 | * Updates a native DOM component after it has already been allocated and | ||
11412 | * attached to the DOM. Reconciles the root DOM node, then recurses. | ||
11413 | * | ||
11414 | * @param {ReactReconcileTransaction} transaction | ||
11415 | * @param {ReactElement} prevElement | ||
11416 | * @param {ReactElement} nextElement | ||
11417 | * @internal | ||
11418 | * @overridable | ||
11419 | */ | ||
11420 | updateComponent: function (transaction, prevElement, nextElement, context) { | ||
11421 | var lastProps = prevElement.props; | ||
11422 | var nextProps = this._currentElement.props; | ||
11423 | |||
11424 | switch (this._tag) { | ||
11425 | case 'button': | ||
11426 | lastProps = ReactDOMButton.getNativeProps(this, lastProps); | ||
11427 | nextProps = ReactDOMButton.getNativeProps(this, nextProps); | ||
11428 | break; | ||
11429 | case 'input': | ||
11430 | ReactDOMInput.updateWrapper(this); | ||
11431 | lastProps = ReactDOMInput.getNativeProps(this, lastProps); | ||
11432 | nextProps = ReactDOMInput.getNativeProps(this, nextProps); | ||
11433 | break; | ||
11434 | case 'option': | ||
11435 | lastProps = ReactDOMOption.getNativeProps(this, lastProps); | ||
11436 | nextProps = ReactDOMOption.getNativeProps(this, nextProps); | ||
11437 | break; | ||
11438 | case 'select': | ||
11439 | lastProps = ReactDOMSelect.getNativeProps(this, lastProps); | ||
11440 | nextProps = ReactDOMSelect.getNativeProps(this, nextProps); | ||
11441 | break; | ||
11442 | case 'textarea': | ||
11443 | ReactDOMTextarea.updateWrapper(this); | ||
11444 | lastProps = ReactDOMTextarea.getNativeProps(this, lastProps); | ||
11445 | nextProps = ReactDOMTextarea.getNativeProps(this, nextProps); | ||
11446 | break; | ||
11447 | } | ||
11448 | |||
11449 | if (process.env.NODE_ENV !== 'production') { | ||
11450 | // If the context is reference-equal to the old one, pass down the same | ||
11451 | // processed object so the update bailout in ReactReconciler behaves | ||
11452 | // correctly (and identically in dev and prod). See #5005. | ||
11453 | if (this._unprocessedContextDev !== context) { | ||
11454 | this._unprocessedContextDev = context; | ||
11455 | this._processedContextDev = processChildContextDev(context, this); | ||
11456 | } | ||
11457 | context = this._processedContextDev; | ||
11458 | } | ||
11459 | |||
11460 | assertValidProps(this, nextProps); | ||
11461 | this._updateDOMProperties(lastProps, nextProps, transaction, null); | ||
11462 | this._updateDOMChildren(lastProps, nextProps, transaction, context); | ||
11463 | |||
11464 | if (!canDefineProperty && this._nodeWithLegacyProperties) { | ||
11465 | this._nodeWithLegacyProperties.props = nextProps; | ||
11466 | } | ||
11467 | |||
11468 | if (this._tag === 'select') { | ||
11469 | // <select> value update needs to occur after <option> children | ||
11470 | // reconciliation | ||
11471 | transaction.getReactMountReady().enqueue(postUpdateSelectWrapper, this); | ||
11472 | } | ||
11473 | }, | ||
11474 | |||
11475 | /** | ||
11476 | * Reconciles the properties by detecting differences in property values and | ||
11477 | * updating the DOM as necessary. This function is probably the single most | ||
11478 | * critical path for performance optimization. | ||
11479 | * | ||
11480 | * TODO: Benchmark whether checking for changed values in memory actually | ||
11481 | * improves performance (especially statically positioned elements). | ||
11482 | * TODO: Benchmark the effects of putting this at the top since 99% of props | ||
11483 | * do not change for a given reconciliation. | ||
11484 | * TODO: Benchmark areas that can be improved with caching. | ||
11485 | * | ||
11486 | * @private | ||
11487 | * @param {object} lastProps | ||
11488 | * @param {object} nextProps | ||
11489 | * @param {ReactReconcileTransaction} transaction | ||
11490 | * @param {?DOMElement} node | ||
11491 | */ | ||
11492 | _updateDOMProperties: function (lastProps, nextProps, transaction, node) { | ||
11493 | var propKey; | ||
11494 | var styleName; | ||
11495 | var styleUpdates; | ||
11496 | for (propKey in lastProps) { | ||
11497 | if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey)) { | ||
11498 | continue; | ||
11499 | } | ||
11500 | if (propKey === STYLE) { | ||
11501 | var lastStyle = this._previousStyleCopy; | ||
11502 | for (styleName in lastStyle) { | ||
11503 | if (lastStyle.hasOwnProperty(styleName)) { | ||
11504 | styleUpdates = styleUpdates || {}; | ||
11505 | styleUpdates[styleName] = ''; | ||
11506 | } | ||
11507 | } | ||
11508 | this._previousStyleCopy = null; | ||
11509 | } else if (registrationNameModules.hasOwnProperty(propKey)) { | ||
11510 | if (lastProps[propKey]) { | ||
11511 | // Only call deleteListener if there was a listener previously or | ||
11512 | // else willDeleteListener gets called when there wasn't actually a | ||
11513 | // listener (e.g., onClick={null}) | ||
11514 | deleteListener(this._rootNodeID, propKey); | ||
11515 | } | ||
11516 | } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) { | ||
11517 | if (!node) { | ||
11518 | node = ReactMount.getNode(this._rootNodeID); | ||
11519 | } | ||
11520 | DOMPropertyOperations.deleteValueForProperty(node, propKey); | ||
11521 | } | ||
11522 | } | ||
11523 | for (propKey in nextProps) { | ||
11524 | var nextProp = nextProps[propKey]; | ||
11525 | var lastProp = propKey === STYLE ? this._previousStyleCopy : lastProps[propKey]; | ||
11526 | if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) { | ||
11527 | continue; | ||
11528 | } | ||
11529 | if (propKey === STYLE) { | ||
11530 | if (nextProp) { | ||
11531 | if (process.env.NODE_ENV !== 'production') { | ||
11532 | checkAndWarnForMutatedStyle(this._previousStyleCopy, this._previousStyle, this); | ||
11533 | this._previousStyle = nextProp; | ||
11534 | } | ||
11535 | nextProp = this._previousStyleCopy = assign({}, nextProp); | ||
11536 | } else { | ||
11537 | this._previousStyleCopy = null; | ||
11538 | } | ||
11539 | if (lastProp) { | ||
11540 | // Unset styles on `lastProp` but not on `nextProp`. | ||
11541 | for (styleName in lastProp) { | ||
11542 | if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { | ||
11543 | styleUpdates = styleUpdates || {}; | ||
11544 | styleUpdates[styleName] = ''; | ||
11545 | } | ||
11546 | } | ||
11547 | // Update styles that changed since `lastProp`. | ||
11548 | for (styleName in nextProp) { | ||
11549 | if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { | ||
11550 | styleUpdates = styleUpdates || {}; | ||
11551 | styleUpdates[styleName] = nextProp[styleName]; | ||
11552 | } | ||
11553 | } | ||
11554 | } else { | ||
11555 | // Relies on `updateStylesByID` not mutating `styleUpdates`. | ||
11556 | styleUpdates = nextProp; | ||
11557 | } | ||
11558 | } else if (registrationNameModules.hasOwnProperty(propKey)) { | ||
11559 | if (nextProp) { | ||
11560 | enqueuePutListener(this._rootNodeID, propKey, nextProp, transaction); | ||
11561 | } else if (lastProp) { | ||
11562 | deleteListener(this._rootNodeID, propKey); | ||
11563 | } | ||
11564 | } else if (isCustomComponent(this._tag, nextProps)) { | ||
11565 | if (!node) { | ||
11566 | node = ReactMount.getNode(this._rootNodeID); | ||
11567 | } | ||
11568 | if (propKey === CHILDREN) { | ||
11569 | nextProp = null; | ||
11570 | } | ||
11571 | DOMPropertyOperations.setValueForAttribute(node, propKey, nextProp); | ||
11572 | } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) { | ||
11573 | if (!node) { | ||
11574 | node = ReactMount.getNode(this._rootNodeID); | ||
11575 | } | ||
11576 | // If we're updating to null or undefined, we should remove the property | ||
11577 | // from the DOM node instead of inadvertantly setting to a string. This | ||
11578 | // brings us in line with the same behavior we have on initial render. | ||
11579 | if (nextProp != null) { | ||
11580 | DOMPropertyOperations.setValueForProperty(node, propKey, nextProp); | ||
11581 | } else { | ||
11582 | DOMPropertyOperations.deleteValueForProperty(node, propKey); | ||
11583 | } | ||
11584 | } | ||
11585 | } | ||
11586 | if (styleUpdates) { | ||
11587 | if (!node) { | ||
11588 | node = ReactMount.getNode(this._rootNodeID); | ||
11589 | } | ||
11590 | CSSPropertyOperations.setValueForStyles(node, styleUpdates); | ||
11591 | } | ||
11592 | }, | ||
11593 | |||
11594 | /** | ||
11595 | * Reconciles the children with the various properties that affect the | ||
11596 | * children content. | ||
11597 | * | ||
11598 | * @param {object} lastProps | ||
11599 | * @param {object} nextProps | ||
11600 | * @param {ReactReconcileTransaction} transaction | ||
11601 | * @param {object} context | ||
11602 | */ | ||
11603 | _updateDOMChildren: function (lastProps, nextProps, transaction, context) { | ||
11604 | var lastContent = CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null; | ||
11605 | var nextContent = CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null; | ||
11606 | |||
11607 | var lastHtml = lastProps.dangerouslySetInnerHTML && lastProps.dangerouslySetInnerHTML.__html; | ||
11608 | var nextHtml = nextProps.dangerouslySetInnerHTML && nextProps.dangerouslySetInnerHTML.__html; | ||
11609 | |||
11610 | // Note the use of `!=` which checks for null or undefined. | ||
11611 | var lastChildren = lastContent != null ? null : lastProps.children; | ||
11612 | var nextChildren = nextContent != null ? null : nextProps.children; | ||
11613 | |||
11614 | // If we're switching from children to content/html or vice versa, remove | ||
11615 | // the old content | ||
11616 | var lastHasContentOrHtml = lastContent != null || lastHtml != null; | ||
11617 | var nextHasContentOrHtml = nextContent != null || nextHtml != null; | ||
11618 | if (lastChildren != null && nextChildren == null) { | ||
11619 | this.updateChildren(null, transaction, context); | ||
11620 | } else if (lastHasContentOrHtml && !nextHasContentOrHtml) { | ||
11621 | this.updateTextContent(''); | ||
11622 | } | ||
11623 | |||
11624 | if (nextContent != null) { | ||
11625 | if (lastContent !== nextContent) { | ||
11626 | this.updateTextContent('' + nextContent); | ||
11627 | } | ||
11628 | } else if (nextHtml != null) { | ||
11629 | if (lastHtml !== nextHtml) { | ||
11630 | this.updateMarkup('' + nextHtml); | ||
11631 | } | ||
11632 | } else if (nextChildren != null) { | ||
11633 | this.updateChildren(nextChildren, transaction, context); | ||
11634 | } | ||
11635 | }, | ||
11636 | |||
11637 | /** | ||
11638 | * Destroys all event registrations for this instance. Does not remove from | ||
11639 | * the DOM. That must be done by the parent. | ||
11640 | * | ||
11641 | * @internal | ||
11642 | */ | ||
11643 | unmountComponent: function () { | ||
11644 | switch (this._tag) { | ||
11645 | case 'iframe': | ||
11646 | case 'img': | ||
11647 | case 'form': | ||
11648 | case 'video': | ||
11649 | case 'audio': | ||
11650 | var listeners = this._wrapperState.listeners; | ||
11651 | if (listeners) { | ||
11652 | for (var i = 0; i < listeners.length; i++) { | ||
11653 | listeners[i].remove(); | ||
11654 | } | ||
11655 | } | ||
11656 | break; | ||
11657 | case 'input': | ||
11658 | ReactDOMInput.unmountWrapper(this); | ||
11659 | break; | ||
11660 | case 'html': | ||
11661 | case 'head': | ||
11662 | case 'body': | ||
11663 | /** | ||
11664 | * Components like <html> <head> and <body> can't be removed or added | ||
11665 | * easily in a cross-browser way, however it's valuable to be able to | ||
11666 | * take advantage of React's reconciliation for styling and <title> | ||
11667 | * management. So we just document it and throw in dangerous cases. | ||
11668 | */ | ||
11669 | true ? process.env.NODE_ENV !== 'production' ? invariant(false, '<%s> tried to unmount. Because of cross-browser quirks it is ' + 'impossible to unmount some top-level components (eg <html>, ' + '<head>, and <body>) reliably and efficiently. To fix this, have a ' + 'single top-level component that never unmounts render these ' + 'elements.', this._tag) : invariant(false) : undefined; | ||
11670 | break; | ||
11671 | } | ||
11672 | |||
11673 | this.unmountChildren(); | ||
11674 | ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID); | ||
11675 | ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID); | ||
11676 | this._rootNodeID = null; | ||
11677 | this._wrapperState = null; | ||
11678 | if (this._nodeWithLegacyProperties) { | ||
11679 | var node = this._nodeWithLegacyProperties; | ||
11680 | node._reactInternalComponent = null; | ||
11681 | this._nodeWithLegacyProperties = null; | ||
11682 | } | ||
11683 | }, | ||
11684 | |||
11685 | getPublicInstance: function () { | ||
11686 | if (!this._nodeWithLegacyProperties) { | ||
11687 | var node = ReactMount.getNode(this._rootNodeID); | ||
11688 | |||
11689 | node._reactInternalComponent = this; | ||
11690 | node.getDOMNode = legacyGetDOMNode; | ||
11691 | node.isMounted = legacyIsMounted; | ||
11692 | node.setState = legacySetStateEtc; | ||
11693 | node.replaceState = legacySetStateEtc; | ||
11694 | node.forceUpdate = legacySetStateEtc; | ||
11695 | node.setProps = legacySetProps; | ||
11696 | node.replaceProps = legacyReplaceProps; | ||
11697 | |||
11698 | if (process.env.NODE_ENV !== 'production') { | ||
11699 | if (canDefineProperty) { | ||
11700 | Object.defineProperties(node, legacyPropsDescriptor); | ||
11701 | } else { | ||
11702 | // updateComponent will update this property on subsequent renders | ||
11703 | node.props = this._currentElement.props; | ||
11704 | } | ||
11705 | } else { | ||
11706 | // updateComponent will update this property on subsequent renders | ||
11707 | node.props = this._currentElement.props; | ||
11708 | } | ||
11709 | |||
11710 | this._nodeWithLegacyProperties = node; | ||
11711 | } | ||
11712 | return this._nodeWithLegacyProperties; | ||
11713 | } | ||
11714 | |||
11715 | }; | ||
11716 | |||
11717 | ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', { | ||
11718 | mountComponent: 'mountComponent', | ||
11719 | updateComponent: 'updateComponent' | ||
11720 | }); | ||
11721 | |||
11722 | assign(ReactDOMComponent.prototype, ReactDOMComponent.Mixin, ReactMultiChild.Mixin); | ||
11723 | |||
11724 | module.exports = ReactDOMComponent; | ||
11725 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
11726 | |||
11727 | /***/ }, | ||
11728 | /* 96 */ | ||
11729 | /***/ function(module, exports, __webpack_require__) { | ||
11730 | |||
11731 | /** | ||
11732 | * Copyright 2013-2015, Facebook, Inc. | ||
11733 | * All rights reserved. | ||
11734 | * | ||
11735 | * This source code is licensed under the BSD-style license found in the | ||
11736 | * LICENSE file in the root directory of this source tree. An additional grant | ||
11737 | * of patent rights can be found in the PATENTS file in the same directory. | ||
11738 | * | ||
11739 | * @providesModule AutoFocusUtils | ||
11740 | * @typechecks static-only | ||
11741 | */ | ||
11742 | |||
11743 | 'use strict'; | ||
11744 | |||
11745 | var ReactMount = __webpack_require__(30); | ||
11746 | |||
11747 | var findDOMNode = __webpack_require__(93); | ||
11748 | var focusNode = __webpack_require__(97); | ||
11749 | |||
11750 | var Mixin = { | ||
11751 | componentDidMount: function () { | ||
11752 | if (this.props.autoFocus) { | ||
11753 | focusNode(findDOMNode(this)); | ||
11754 | } | ||
11755 | } | ||
11756 | }; | ||
11757 | |||
11758 | var AutoFocusUtils = { | ||
11759 | Mixin: Mixin, | ||
11760 | |||
11761 | focusDOMComponent: function () { | ||
11762 | focusNode(ReactMount.getNode(this._rootNodeID)); | ||
11763 | } | ||
11764 | }; | ||
11765 | |||
11766 | module.exports = AutoFocusUtils; | ||
11767 | |||
11768 | /***/ }, | ||
11769 | /* 97 */ | ||
11770 | /***/ function(module, exports) { | ||
11771 | |||
11772 | /** | ||
11773 | * Copyright 2013-2015, Facebook, Inc. | ||
11774 | * All rights reserved. | ||
11775 | * | ||
11776 | * This source code is licensed under the BSD-style license found in the | ||
11777 | * LICENSE file in the root directory of this source tree. An additional grant | ||
11778 | * of patent rights can be found in the PATENTS file in the same directory. | ||
11779 | * | ||
11780 | * @providesModule focusNode | ||
11781 | */ | ||
11782 | |||
11783 | 'use strict'; | ||
11784 | |||
11785 | /** | ||
11786 | * @param {DOMElement} node input/textarea to focus | ||
11787 | */ | ||
11788 | function focusNode(node) { | ||
11789 | // IE8 can throw "Can't move focus to the control because it is invisible, | ||
11790 | // not enabled, or of a type that does not accept the focus." for all kinds of | ||
11791 | // reasons that are too expensive and fragile to test. | ||
11792 | try { | ||
11793 | node.focus(); | ||
11794 | } catch (e) {} | ||
11795 | } | ||
11796 | |||
11797 | module.exports = focusNode; | ||
11798 | |||
11799 | /***/ }, | ||
11800 | /* 98 */ | ||
11801 | /***/ function(module, exports, __webpack_require__) { | ||
11802 | |||
11803 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
11804 | * Copyright 2013-2015, Facebook, Inc. | ||
11805 | * All rights reserved. | ||
11806 | * | ||
11807 | * This source code is licensed under the BSD-style license found in the | ||
11808 | * LICENSE file in the root directory of this source tree. An additional grant | ||
11809 | * of patent rights can be found in the PATENTS file in the same directory. | ||
11810 | * | ||
11811 | * @providesModule CSSPropertyOperations | ||
11812 | * @typechecks static-only | ||
11813 | */ | ||
11814 | |||
11815 | 'use strict'; | ||
11816 | |||
11817 | var CSSProperty = __webpack_require__(99); | ||
11818 | var ExecutionEnvironment = __webpack_require__(11); | ||
11819 | var ReactPerf = __webpack_require__(20); | ||
11820 | |||
11821 | var camelizeStyleName = __webpack_require__(100); | ||
11822 | var dangerousStyleValue = __webpack_require__(102); | ||
11823 | var hyphenateStyleName = __webpack_require__(103); | ||
11824 | var memoizeStringOnly = __webpack_require__(105); | ||
11825 | var warning = __webpack_require__(27); | ||
11826 | |||
11827 | var processStyleName = memoizeStringOnly(function (styleName) { | ||
11828 | return hyphenateStyleName(styleName); | ||
11829 | }); | ||
11830 | |||
11831 | var hasShorthandPropertyBug = false; | ||
11832 | var styleFloatAccessor = 'cssFloat'; | ||
11833 | if (ExecutionEnvironment.canUseDOM) { | ||
11834 | var tempStyle = document.createElement('div').style; | ||
11835 | try { | ||
11836 | // IE8 throws "Invalid argument." if resetting shorthand style properties. | ||
11837 | tempStyle.font = ''; | ||
11838 | } catch (e) { | ||
11839 | hasShorthandPropertyBug = true; | ||
11840 | } | ||
11841 | // IE8 only supports accessing cssFloat (standard) as styleFloat | ||
11842 | if (document.documentElement.style.cssFloat === undefined) { | ||
11843 | styleFloatAccessor = 'styleFloat'; | ||
11844 | } | ||
11845 | } | ||
11846 | |||
11847 | if (process.env.NODE_ENV !== 'production') { | ||
11848 | // 'msTransform' is correct, but the other prefixes should be capitalized | ||
11849 | var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; | ||
11850 | |||
11851 | // style values shouldn't contain a semicolon | ||
11852 | var badStyleValueWithSemicolonPattern = /;\s*$/; | ||
11853 | |||
11854 | var warnedStyleNames = {}; | ||
11855 | var warnedStyleValues = {}; | ||
11856 | |||
11857 | var warnHyphenatedStyleName = function (name) { | ||
11858 | if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | ||
11859 | return; | ||
11860 | } | ||
11861 | |||
11862 | warnedStyleNames[name] = true; | ||
11863 | process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported style property %s. Did you mean %s?', name, camelizeStyleName(name)) : undefined; | ||
11864 | }; | ||
11865 | |||
11866 | var warnBadVendoredStyleName = function (name) { | ||
11867 | if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | ||
11868 | return; | ||
11869 | } | ||
11870 | |||
11871 | warnedStyleNames[name] = true; | ||
11872 | process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)) : undefined; | ||
11873 | }; | ||
11874 | |||
11875 | var warnStyleValueWithSemicolon = function (name, value) { | ||
11876 | if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { | ||
11877 | return; | ||
11878 | } | ||
11879 | |||
11880 | warnedStyleValues[value] = true; | ||
11881 | process.env.NODE_ENV !== 'production' ? warning(false, 'Style property values shouldn\'t contain a semicolon. ' + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')) : undefined; | ||
11882 | }; | ||
11883 | |||
11884 | /** | ||
11885 | * @param {string} name | ||
11886 | * @param {*} value | ||
11887 | */ | ||
11888 | var warnValidStyle = function (name, value) { | ||
11889 | if (name.indexOf('-') > -1) { | ||
11890 | warnHyphenatedStyleName(name); | ||
11891 | } else if (badVendoredStyleNamePattern.test(name)) { | ||
11892 | warnBadVendoredStyleName(name); | ||
11893 | } else if (badStyleValueWithSemicolonPattern.test(value)) { | ||
11894 | warnStyleValueWithSemicolon(name, value); | ||
11895 | } | ||
11896 | }; | ||
11897 | } | ||
11898 | |||
11899 | /** | ||
11900 | * Operations for dealing with CSS properties. | ||
11901 | */ | ||
11902 | var CSSPropertyOperations = { | ||
11903 | |||
11904 | /** | ||
11905 | * Serializes a mapping of style properties for use as inline styles: | ||
11906 | * | ||
11907 | * > createMarkupForStyles({width: '200px', height: 0}) | ||
11908 | * "width:200px;height:0;" | ||
11909 | * | ||
11910 | * Undefined values are ignored so that declarative programming is easier. | ||
11911 | * The result should be HTML-escaped before insertion into the DOM. | ||
11912 | * | ||
11913 | * @param {object} styles | ||
11914 | * @return {?string} | ||
11915 | */ | ||
11916 | createMarkupForStyles: function (styles) { | ||
11917 | var serialized = ''; | ||
11918 | for (var styleName in styles) { | ||
11919 | if (!styles.hasOwnProperty(styleName)) { | ||
11920 | continue; | ||
11921 | } | ||
11922 | var styleValue = styles[styleName]; | ||
11923 | if (process.env.NODE_ENV !== 'production') { | ||
11924 | warnValidStyle(styleName, styleValue); | ||
11925 | } | ||
11926 | if (styleValue != null) { | ||
11927 | serialized += processStyleName(styleName) + ':'; | ||
11928 | serialized += dangerousStyleValue(styleName, styleValue) + ';'; | ||
11929 | } | ||
11930 | } | ||
11931 | return serialized || null; | ||
11932 | }, | ||
11933 | |||
11934 | /** | ||
11935 | * Sets the value for multiple styles on a node. If a value is specified as | ||
11936 | * '' (empty string), the corresponding style property will be unset. | ||
11937 | * | ||
11938 | * @param {DOMElement} node | ||
11939 | * @param {object} styles | ||
11940 | */ | ||
11941 | setValueForStyles: function (node, styles) { | ||
11942 | var style = node.style; | ||
11943 | for (var styleName in styles) { | ||
11944 | if (!styles.hasOwnProperty(styleName)) { | ||
11945 | continue; | ||
11946 | } | ||
11947 | if (process.env.NODE_ENV !== 'production') { | ||
11948 | warnValidStyle(styleName, styles[styleName]); | ||
11949 | } | ||
11950 | var styleValue = dangerousStyleValue(styleName, styles[styleName]); | ||
11951 | if (styleName === 'float') { | ||
11952 | styleName = styleFloatAccessor; | ||
11953 | } | ||
11954 | if (styleValue) { | ||
11955 | style[styleName] = styleValue; | ||
11956 | } else { | ||
11957 | var expansion = hasShorthandPropertyBug && CSSProperty.shorthandPropertyExpansions[styleName]; | ||
11958 | if (expansion) { | ||
11959 | // Shorthand property that IE8 won't like unsetting, so unset each | ||
11960 | // component to placate it | ||
11961 | for (var individualStyleName in expansion) { | ||
11962 | style[individualStyleName] = ''; | ||
11963 | } | ||
11964 | } else { | ||
11965 | style[styleName] = ''; | ||
11966 | } | ||
11967 | } | ||
11968 | } | ||
11969 | } | ||
11970 | |||
11971 | }; | ||
11972 | |||
11973 | ReactPerf.measureMethods(CSSPropertyOperations, 'CSSPropertyOperations', { | ||
11974 | setValueForStyles: 'setValueForStyles' | ||
11975 | }); | ||
11976 | |||
11977 | module.exports = CSSPropertyOperations; | ||
11978 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
11979 | |||
11980 | /***/ }, | ||
11981 | /* 99 */ | ||
11982 | /***/ function(module, exports) { | ||
11983 | |||
11984 | /** | ||
11985 | * Copyright 2013-2015, Facebook, Inc. | ||
11986 | * All rights reserved. | ||
11987 | * | ||
11988 | * This source code is licensed under the BSD-style license found in the | ||
11989 | * LICENSE file in the root directory of this source tree. An additional grant | ||
11990 | * of patent rights can be found in the PATENTS file in the same directory. | ||
11991 | * | ||
11992 | * @providesModule CSSProperty | ||
11993 | */ | ||
11994 | |||
11995 | 'use strict'; | ||
11996 | |||
11997 | /** | ||
11998 | * CSS properties which accept numbers but are not in units of "px". | ||
11999 | */ | ||
12000 | var isUnitlessNumber = { | ||
12001 | animationIterationCount: true, | ||
12002 | boxFlex: true, | ||
12003 | boxFlexGroup: true, | ||
12004 | boxOrdinalGroup: true, | ||
12005 | columnCount: true, | ||
12006 | flex: true, | ||
12007 | flexGrow: true, | ||
12008 | flexPositive: true, | ||
12009 | flexShrink: true, | ||
12010 | flexNegative: true, | ||
12011 | flexOrder: true, | ||
12012 | fontWeight: true, | ||
12013 | lineClamp: true, | ||
12014 | lineHeight: true, | ||
12015 | opacity: true, | ||
12016 | order: true, | ||
12017 | orphans: true, | ||
12018 | tabSize: true, | ||
12019 | widows: true, | ||
12020 | zIndex: true, | ||
12021 | zoom: true, | ||
12022 | |||
12023 | // SVG-related properties | ||
12024 | fillOpacity: true, | ||
12025 | stopOpacity: true, | ||
12026 | strokeDashoffset: true, | ||
12027 | strokeOpacity: true, | ||
12028 | strokeWidth: true | ||
12029 | }; | ||
12030 | |||
12031 | /** | ||
12032 | * @param {string} prefix vendor-specific prefix, eg: Webkit | ||
12033 | * @param {string} key style name, eg: transitionDuration | ||
12034 | * @return {string} style name prefixed with `prefix`, properly camelCased, eg: | ||
12035 | * WebkitTransitionDuration | ||
12036 | */ | ||
12037 | function prefixKey(prefix, key) { | ||
12038 | return prefix + key.charAt(0).toUpperCase() + key.substring(1); | ||
12039 | } | ||
12040 | |||
12041 | /** | ||
12042 | * Support style names that may come passed in prefixed by adding permutations | ||
12043 | * of vendor prefixes. | ||
12044 | */ | ||
12045 | var prefixes = ['Webkit', 'ms', 'Moz', 'O']; | ||
12046 | |||
12047 | // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an | ||
12048 | // infinite loop, because it iterates over the newly added props too. | ||
12049 | Object.keys(isUnitlessNumber).forEach(function (prop) { | ||
12050 | prefixes.forEach(function (prefix) { | ||
12051 | isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; | ||
12052 | }); | ||
12053 | }); | ||
12054 | |||
12055 | /** | ||
12056 | * Most style properties can be unset by doing .style[prop] = '' but IE8 | ||
12057 | * doesn't like doing that with shorthand properties so for the properties that | ||
12058 | * IE8 breaks on, which are listed here, we instead unset each of the | ||
12059 | * individual properties. See http://bugs.jquery.com/ticket/12385. | ||
12060 | * The 4-value 'clock' properties like margin, padding, border-width seem to | ||
12061 | * behave without any problems. Curiously, list-style works too without any | ||
12062 | * special prodding. | ||
12063 | */ | ||
12064 | var shorthandPropertyExpansions = { | ||
12065 | background: { | ||
12066 | backgroundAttachment: true, | ||
12067 | backgroundColor: true, | ||
12068 | backgroundImage: true, | ||
12069 | backgroundPositionX: true, | ||
12070 | backgroundPositionY: true, | ||
12071 | backgroundRepeat: true | ||
12072 | }, | ||
12073 | backgroundPosition: { | ||
12074 | backgroundPositionX: true, | ||
12075 | backgroundPositionY: true | ||
12076 | }, | ||
12077 | border: { | ||
12078 | borderWidth: true, | ||
12079 | borderStyle: true, | ||
12080 | borderColor: true | ||
12081 | }, | ||
12082 | borderBottom: { | ||
12083 | borderBottomWidth: true, | ||
12084 | borderBottomStyle: true, | ||
12085 | borderBottomColor: true | ||
12086 | }, | ||
12087 | borderLeft: { | ||
12088 | borderLeftWidth: true, | ||
12089 | borderLeftStyle: true, | ||
12090 | borderLeftColor: true | ||
12091 | }, | ||
12092 | borderRight: { | ||
12093 | borderRightWidth: true, | ||
12094 | borderRightStyle: true, | ||
12095 | borderRightColor: true | ||
12096 | }, | ||
12097 | borderTop: { | ||
12098 | borderTopWidth: true, | ||
12099 | borderTopStyle: true, | ||
12100 | borderTopColor: true | ||
12101 | }, | ||
12102 | font: { | ||
12103 | fontStyle: true, | ||
12104 | fontVariant: true, | ||
12105 | fontWeight: true, | ||
12106 | fontSize: true, | ||
12107 | lineHeight: true, | ||
12108 | fontFamily: true | ||
12109 | }, | ||
12110 | outline: { | ||
12111 | outlineWidth: true, | ||
12112 | outlineStyle: true, | ||
12113 | outlineColor: true | ||
12114 | } | ||
12115 | }; | ||
12116 | |||
12117 | var CSSProperty = { | ||
12118 | isUnitlessNumber: isUnitlessNumber, | ||
12119 | shorthandPropertyExpansions: shorthandPropertyExpansions | ||
12120 | }; | ||
12121 | |||
12122 | module.exports = CSSProperty; | ||
12123 | |||
12124 | /***/ }, | ||
12125 | /* 100 */ | ||
12126 | /***/ function(module, exports, __webpack_require__) { | ||
12127 | |||
12128 | /** | ||
12129 | * Copyright 2013-2015, Facebook, Inc. | ||
12130 | * All rights reserved. | ||
12131 | * | ||
12132 | * This source code is licensed under the BSD-style license found in the | ||
12133 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12134 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12135 | * | ||
12136 | * @providesModule camelizeStyleName | ||
12137 | * @typechecks | ||
12138 | */ | ||
12139 | |||
12140 | 'use strict'; | ||
12141 | |||
12142 | var camelize = __webpack_require__(101); | ||
12143 | |||
12144 | var msPattern = /^-ms-/; | ||
12145 | |||
12146 | /** | ||
12147 | * Camelcases a hyphenated CSS property name, for example: | ||
12148 | * | ||
12149 | * > camelizeStyleName('background-color') | ||
12150 | * < "backgroundColor" | ||
12151 | * > camelizeStyleName('-moz-transition') | ||
12152 | * < "MozTransition" | ||
12153 | * > camelizeStyleName('-ms-transition') | ||
12154 | * < "msTransition" | ||
12155 | * | ||
12156 | * As Andi Smith suggests | ||
12157 | * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix | ||
12158 | * is converted to lowercase `ms`. | ||
12159 | * | ||
12160 | * @param {string} string | ||
12161 | * @return {string} | ||
12162 | */ | ||
12163 | function camelizeStyleName(string) { | ||
12164 | return camelize(string.replace(msPattern, 'ms-')); | ||
12165 | } | ||
12166 | |||
12167 | module.exports = camelizeStyleName; | ||
12168 | |||
12169 | /***/ }, | ||
12170 | /* 101 */ | ||
12171 | /***/ function(module, exports) { | ||
12172 | |||
12173 | /** | ||
12174 | * Copyright 2013-2015, Facebook, Inc. | ||
12175 | * All rights reserved. | ||
12176 | * | ||
12177 | * This source code is licensed under the BSD-style license found in the | ||
12178 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12179 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12180 | * | ||
12181 | * @providesModule camelize | ||
12182 | * @typechecks | ||
12183 | */ | ||
12184 | |||
12185 | "use strict"; | ||
12186 | |||
12187 | var _hyphenPattern = /-(.)/g; | ||
12188 | |||
12189 | /** | ||
12190 | * Camelcases a hyphenated string, for example: | ||
12191 | * | ||
12192 | * > camelize('background-color') | ||
12193 | * < "backgroundColor" | ||
12194 | * | ||
12195 | * @param {string} string | ||
12196 | * @return {string} | ||
12197 | */ | ||
12198 | function camelize(string) { | ||
12199 | return string.replace(_hyphenPattern, function (_, character) { | ||
12200 | return character.toUpperCase(); | ||
12201 | }); | ||
12202 | } | ||
12203 | |||
12204 | module.exports = camelize; | ||
12205 | |||
12206 | /***/ }, | ||
12207 | /* 102 */ | ||
12208 | /***/ function(module, exports, __webpack_require__) { | ||
12209 | |||
12210 | /** | ||
12211 | * Copyright 2013-2015, Facebook, Inc. | ||
12212 | * All rights reserved. | ||
12213 | * | ||
12214 | * This source code is licensed under the BSD-style license found in the | ||
12215 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12216 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12217 | * | ||
12218 | * @providesModule dangerousStyleValue | ||
12219 | * @typechecks static-only | ||
12220 | */ | ||
12221 | |||
12222 | 'use strict'; | ||
12223 | |||
12224 | var CSSProperty = __webpack_require__(99); | ||
12225 | |||
12226 | var isUnitlessNumber = CSSProperty.isUnitlessNumber; | ||
12227 | |||
12228 | /** | ||
12229 | * Convert a value into the proper css writable value. The style name `name` | ||
12230 | * should be logical (no hyphens), as specified | ||
12231 | * in `CSSProperty.isUnitlessNumber`. | ||
12232 | * | ||
12233 | * @param {string} name CSS property name such as `topMargin`. | ||
12234 | * @param {*} value CSS property value such as `10px`. | ||
12235 | * @return {string} Normalized style value with dimensions applied. | ||
12236 | */ | ||
12237 | function dangerousStyleValue(name, value) { | ||
12238 | // Note that we've removed escapeTextForBrowser() calls here since the | ||
12239 | // whole string will be escaped when the attribute is injected into | ||
12240 | // the markup. If you provide unsafe user data here they can inject | ||
12241 | // arbitrary CSS which may be problematic (I couldn't repro this): | ||
12242 | // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet | ||
12243 | // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ | ||
12244 | // This is not an XSS hole but instead a potential CSS injection issue | ||
12245 | // which has lead to a greater discussion about how we're going to | ||
12246 | // trust URLs moving forward. See #2115901 | ||
12247 | |||
12248 | var isEmpty = value == null || typeof value === 'boolean' || value === ''; | ||
12249 | if (isEmpty) { | ||
12250 | return ''; | ||
12251 | } | ||
12252 | |||
12253 | var isNonNumeric = isNaN(value); | ||
12254 | if (isNonNumeric || value === 0 || isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) { | ||
12255 | return '' + value; // cast to string | ||
12256 | } | ||
12257 | |||
12258 | if (typeof value === 'string') { | ||
12259 | value = value.trim(); | ||
12260 | } | ||
12261 | return value + 'px'; | ||
12262 | } | ||
12263 | |||
12264 | module.exports = dangerousStyleValue; | ||
12265 | |||
12266 | /***/ }, | ||
12267 | /* 103 */ | ||
12268 | /***/ function(module, exports, __webpack_require__) { | ||
12269 | |||
12270 | /** | ||
12271 | * Copyright 2013-2015, Facebook, Inc. | ||
12272 | * All rights reserved. | ||
12273 | * | ||
12274 | * This source code is licensed under the BSD-style license found in the | ||
12275 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12276 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12277 | * | ||
12278 | * @providesModule hyphenateStyleName | ||
12279 | * @typechecks | ||
12280 | */ | ||
12281 | |||
12282 | 'use strict'; | ||
12283 | |||
12284 | var hyphenate = __webpack_require__(104); | ||
12285 | |||
12286 | var msPattern = /^ms-/; | ||
12287 | |||
12288 | /** | ||
12289 | * Hyphenates a camelcased CSS property name, for example: | ||
12290 | * | ||
12291 | * > hyphenateStyleName('backgroundColor') | ||
12292 | * < "background-color" | ||
12293 | * > hyphenateStyleName('MozTransition') | ||
12294 | * < "-moz-transition" | ||
12295 | * > hyphenateStyleName('msTransition') | ||
12296 | * < "-ms-transition" | ||
12297 | * | ||
12298 | * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix | ||
12299 | * is converted to `-ms-`. | ||
12300 | * | ||
12301 | * @param {string} string | ||
12302 | * @return {string} | ||
12303 | */ | ||
12304 | function hyphenateStyleName(string) { | ||
12305 | return hyphenate(string).replace(msPattern, '-ms-'); | ||
12306 | } | ||
12307 | |||
12308 | module.exports = hyphenateStyleName; | ||
12309 | |||
12310 | /***/ }, | ||
12311 | /* 104 */ | ||
12312 | /***/ function(module, exports) { | ||
12313 | |||
12314 | /** | ||
12315 | * Copyright 2013-2015, Facebook, Inc. | ||
12316 | * All rights reserved. | ||
12317 | * | ||
12318 | * This source code is licensed under the BSD-style license found in the | ||
12319 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12320 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12321 | * | ||
12322 | * @providesModule hyphenate | ||
12323 | * @typechecks | ||
12324 | */ | ||
12325 | |||
12326 | 'use strict'; | ||
12327 | |||
12328 | var _uppercasePattern = /([A-Z])/g; | ||
12329 | |||
12330 | /** | ||
12331 | * Hyphenates a camelcased string, for example: | ||
12332 | * | ||
12333 | * > hyphenate('backgroundColor') | ||
12334 | * < "background-color" | ||
12335 | * | ||
12336 | * For CSS style names, use `hyphenateStyleName` instead which works properly | ||
12337 | * with all vendor prefixes, including `ms`. | ||
12338 | * | ||
12339 | * @param {string} string | ||
12340 | * @return {string} | ||
12341 | */ | ||
12342 | function hyphenate(string) { | ||
12343 | return string.replace(_uppercasePattern, '-$1').toLowerCase(); | ||
12344 | } | ||
12345 | |||
12346 | module.exports = hyphenate; | ||
12347 | |||
12348 | /***/ }, | ||
12349 | /* 105 */ | ||
12350 | /***/ function(module, exports) { | ||
12351 | |||
12352 | /** | ||
12353 | * Copyright 2013-2015, Facebook, Inc. | ||
12354 | * All rights reserved. | ||
12355 | * | ||
12356 | * This source code is licensed under the BSD-style license found in the | ||
12357 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12358 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12359 | * | ||
12360 | * @providesModule memoizeStringOnly | ||
12361 | * @typechecks static-only | ||
12362 | */ | ||
12363 | |||
12364 | 'use strict'; | ||
12365 | |||
12366 | /** | ||
12367 | * Memoizes the return value of a function that accepts one string argument. | ||
12368 | * | ||
12369 | * @param {function} callback | ||
12370 | * @return {function} | ||
12371 | */ | ||
12372 | function memoizeStringOnly(callback) { | ||
12373 | var cache = {}; | ||
12374 | return function (string) { | ||
12375 | if (!cache.hasOwnProperty(string)) { | ||
12376 | cache[string] = callback.call(this, string); | ||
12377 | } | ||
12378 | return cache[string]; | ||
12379 | }; | ||
12380 | } | ||
12381 | |||
12382 | module.exports = memoizeStringOnly; | ||
12383 | |||
12384 | /***/ }, | ||
12385 | /* 106 */ | ||
12386 | /***/ function(module, exports) { | ||
12387 | |||
12388 | /** | ||
12389 | * Copyright 2013-2015, Facebook, Inc. | ||
12390 | * All rights reserved. | ||
12391 | * | ||
12392 | * This source code is licensed under the BSD-style license found in the | ||
12393 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12394 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12395 | * | ||
12396 | * @providesModule ReactDOMButton | ||
12397 | */ | ||
12398 | |||
12399 | 'use strict'; | ||
12400 | |||
12401 | var mouseListenerNames = { | ||
12402 | onClick: true, | ||
12403 | onDoubleClick: true, | ||
12404 | onMouseDown: true, | ||
12405 | onMouseMove: true, | ||
12406 | onMouseUp: true, | ||
12407 | |||
12408 | onClickCapture: true, | ||
12409 | onDoubleClickCapture: true, | ||
12410 | onMouseDownCapture: true, | ||
12411 | onMouseMoveCapture: true, | ||
12412 | onMouseUpCapture: true | ||
12413 | }; | ||
12414 | |||
12415 | /** | ||
12416 | * Implements a <button> native component that does not receive mouse events | ||
12417 | * when `disabled` is set. | ||
12418 | */ | ||
12419 | var ReactDOMButton = { | ||
12420 | getNativeProps: function (inst, props, context) { | ||
12421 | if (!props.disabled) { | ||
12422 | return props; | ||
12423 | } | ||
12424 | |||
12425 | // Copy the props, except the mouse listeners | ||
12426 | var nativeProps = {}; | ||
12427 | for (var key in props) { | ||
12428 | if (props.hasOwnProperty(key) && !mouseListenerNames[key]) { | ||
12429 | nativeProps[key] = props[key]; | ||
12430 | } | ||
12431 | } | ||
12432 | |||
12433 | return nativeProps; | ||
12434 | } | ||
12435 | }; | ||
12436 | |||
12437 | module.exports = ReactDOMButton; | ||
12438 | |||
12439 | /***/ }, | ||
12440 | /* 107 */ | ||
12441 | /***/ function(module, exports, __webpack_require__) { | ||
12442 | |||
12443 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
12444 | * Copyright 2013-2015, Facebook, Inc. | ||
12445 | * All rights reserved. | ||
12446 | * | ||
12447 | * This source code is licensed under the BSD-style license found in the | ||
12448 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12449 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12450 | * | ||
12451 | * @providesModule ReactDOMInput | ||
12452 | */ | ||
12453 | |||
12454 | 'use strict'; | ||
12455 | |||
12456 | var ReactDOMIDOperations = __webpack_require__(29); | ||
12457 | var LinkedValueUtils = __webpack_require__(108); | ||
12458 | var ReactMount = __webpack_require__(30); | ||
12459 | var ReactUpdates = __webpack_require__(56); | ||
12460 | |||
12461 | var assign = __webpack_require__(41); | ||
12462 | var invariant = __webpack_require__(15); | ||
12463 | |||
12464 | var instancesByReactID = {}; | ||
12465 | |||
12466 | function forceUpdateIfMounted() { | ||
12467 | if (this._rootNodeID) { | ||
12468 | // DOM component is still mounted; update | ||
12469 | ReactDOMInput.updateWrapper(this); | ||
12470 | } | ||
12471 | } | ||
12472 | |||
12473 | /** | ||
12474 | * Implements an <input> native component that allows setting these optional | ||
12475 | * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. | ||
12476 | * | ||
12477 | * If `checked` or `value` are not supplied (or null/undefined), user actions | ||
12478 | * that affect the checked state or value will trigger updates to the element. | ||
12479 | * | ||
12480 | * If they are supplied (and not null/undefined), the rendered element will not | ||
12481 | * trigger updates to the element. Instead, the props must change in order for | ||
12482 | * the rendered element to be updated. | ||
12483 | * | ||
12484 | * The rendered element will be initialized as unchecked (or `defaultChecked`) | ||
12485 | * with an empty value (or `defaultValue`). | ||
12486 | * | ||
12487 | * @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html | ||
12488 | */ | ||
12489 | var ReactDOMInput = { | ||
12490 | getNativeProps: function (inst, props, context) { | ||
12491 | var value = LinkedValueUtils.getValue(props); | ||
12492 | var checked = LinkedValueUtils.getChecked(props); | ||
12493 | |||
12494 | var nativeProps = assign({}, props, { | ||
12495 | defaultChecked: undefined, | ||
12496 | defaultValue: undefined, | ||
12497 | value: value != null ? value : inst._wrapperState.initialValue, | ||
12498 | checked: checked != null ? checked : inst._wrapperState.initialChecked, | ||
12499 | onChange: inst._wrapperState.onChange | ||
12500 | }); | ||
12501 | |||
12502 | return nativeProps; | ||
12503 | }, | ||
12504 | |||
12505 | mountWrapper: function (inst, props) { | ||
12506 | if (process.env.NODE_ENV !== 'production') { | ||
12507 | LinkedValueUtils.checkPropTypes('input', props, inst._currentElement._owner); | ||
12508 | } | ||
12509 | |||
12510 | var defaultValue = props.defaultValue; | ||
12511 | inst._wrapperState = { | ||
12512 | initialChecked: props.defaultChecked || false, | ||
12513 | initialValue: defaultValue != null ? defaultValue : null, | ||
12514 | onChange: _handleChange.bind(inst) | ||
12515 | }; | ||
12516 | }, | ||
12517 | |||
12518 | mountReadyWrapper: function (inst) { | ||
12519 | // Can't be in mountWrapper or else server rendering leaks. | ||
12520 | instancesByReactID[inst._rootNodeID] = inst; | ||
12521 | }, | ||
12522 | |||
12523 | unmountWrapper: function (inst) { | ||
12524 | delete instancesByReactID[inst._rootNodeID]; | ||
12525 | }, | ||
12526 | |||
12527 | updateWrapper: function (inst) { | ||
12528 | var props = inst._currentElement.props; | ||
12529 | |||
12530 | // TODO: Shouldn't this be getChecked(props)? | ||
12531 | var checked = props.checked; | ||
12532 | if (checked != null) { | ||
12533 | ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'checked', checked || false); | ||
12534 | } | ||
12535 | |||
12536 | var value = LinkedValueUtils.getValue(props); | ||
12537 | if (value != null) { | ||
12538 | // Cast `value` to a string to ensure the value is set correctly. While | ||
12539 | // browsers typically do this as necessary, jsdom doesn't. | ||
12540 | ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value); | ||
12541 | } | ||
12542 | } | ||
12543 | }; | ||
12544 | |||
12545 | function _handleChange(event) { | ||
12546 | var props = this._currentElement.props; | ||
12547 | |||
12548 | var returnValue = LinkedValueUtils.executeOnChange(props, event); | ||
12549 | |||
12550 | // Here we use asap to wait until all updates have propagated, which | ||
12551 | // is important when using controlled components within layers: | ||
12552 | // https://github.com/facebook/react/issues/1698 | ||
12553 | ReactUpdates.asap(forceUpdateIfMounted, this); | ||
12554 | |||
12555 | var name = props.name; | ||
12556 | if (props.type === 'radio' && name != null) { | ||
12557 | var rootNode = ReactMount.getNode(this._rootNodeID); | ||
12558 | var queryRoot = rootNode; | ||
12559 | |||
12560 | while (queryRoot.parentNode) { | ||
12561 | queryRoot = queryRoot.parentNode; | ||
12562 | } | ||
12563 | |||
12564 | // If `rootNode.form` was non-null, then we could try `form.elements`, | ||
12565 | // but that sometimes behaves strangely in IE8. We could also try using | ||
12566 | // `form.getElementsByName`, but that will only return direct children | ||
12567 | // and won't include inputs that use the HTML5 `form=` attribute. Since | ||
12568 | // the input might not even be in a form, let's just use the global | ||
12569 | // `querySelectorAll` to ensure we don't miss anything. | ||
12570 | var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); | ||
12571 | |||
12572 | for (var i = 0; i < group.length; i++) { | ||
12573 | var otherNode = group[i]; | ||
12574 | if (otherNode === rootNode || otherNode.form !== rootNode.form) { | ||
12575 | continue; | ||
12576 | } | ||
12577 | // This will throw if radio buttons rendered by different copies of React | ||
12578 | // and the same name are rendered into the same form (same as #1939). | ||
12579 | // That's probably okay; we don't support it just as we don't support | ||
12580 | // mixing React with non-React. | ||
12581 | var otherID = ReactMount.getID(otherNode); | ||
12582 | !otherID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.') : invariant(false) : undefined; | ||
12583 | var otherInstance = instancesByReactID[otherID]; | ||
12584 | !otherInstance ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Unknown radio button ID %s.', otherID) : invariant(false) : undefined; | ||
12585 | // If this is a controlled radio button group, forcing the input that | ||
12586 | // was previously checked to update will cause it to be come re-checked | ||
12587 | // as appropriate. | ||
12588 | ReactUpdates.asap(forceUpdateIfMounted, otherInstance); | ||
12589 | } | ||
12590 | } | ||
12591 | |||
12592 | return returnValue; | ||
12593 | } | ||
12594 | |||
12595 | module.exports = ReactDOMInput; | ||
12596 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
12597 | |||
12598 | /***/ }, | ||
12599 | /* 108 */ | ||
12600 | /***/ function(module, exports, __webpack_require__) { | ||
12601 | |||
12602 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
12603 | * Copyright 2013-2015, Facebook, Inc. | ||
12604 | * All rights reserved. | ||
12605 | * | ||
12606 | * This source code is licensed under the BSD-style license found in the | ||
12607 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12608 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12609 | * | ||
12610 | * @providesModule LinkedValueUtils | ||
12611 | * @typechecks static-only | ||
12612 | */ | ||
12613 | |||
12614 | 'use strict'; | ||
12615 | |||
12616 | var ReactPropTypes = __webpack_require__(109); | ||
12617 | var ReactPropTypeLocations = __webpack_require__(67); | ||
12618 | |||
12619 | var invariant = __webpack_require__(15); | ||
12620 | var warning = __webpack_require__(27); | ||
12621 | |||
12622 | var hasReadOnlyValue = { | ||
12623 | 'button': true, | ||
12624 | 'checkbox': true, | ||
12625 | 'image': true, | ||
12626 | 'hidden': true, | ||
12627 | 'radio': true, | ||
12628 | 'reset': true, | ||
12629 | 'submit': true | ||
12630 | }; | ||
12631 | |||
12632 | function _assertSingleLink(inputProps) { | ||
12633 | !(inputProps.checkedLink == null || inputProps.valueLink == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a valueLink. If you want to use ' + 'checkedLink, you probably don\'t want to use valueLink and vice versa.') : invariant(false) : undefined; | ||
12634 | } | ||
12635 | function _assertValueLink(inputProps) { | ||
12636 | _assertSingleLink(inputProps); | ||
12637 | !(inputProps.value == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a valueLink and a value or onChange event. If you want ' + 'to use value or onChange, you probably don\'t want to use valueLink.') : invariant(false) : undefined; | ||
12638 | } | ||
12639 | |||
12640 | function _assertCheckedLink(inputProps) { | ||
12641 | _assertSingleLink(inputProps); | ||
12642 | !(inputProps.checked == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a checked property or onChange event. ' + 'If you want to use checked or onChange, you probably don\'t want to ' + 'use checkedLink') : invariant(false) : undefined; | ||
12643 | } | ||
12644 | |||
12645 | var propTypes = { | ||
12646 | value: function (props, propName, componentName) { | ||
12647 | if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) { | ||
12648 | return null; | ||
12649 | } | ||
12650 | return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); | ||
12651 | }, | ||
12652 | checked: function (props, propName, componentName) { | ||
12653 | if (!props[propName] || props.onChange || props.readOnly || props.disabled) { | ||
12654 | return null; | ||
12655 | } | ||
12656 | return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); | ||
12657 | }, | ||
12658 | onChange: ReactPropTypes.func | ||
12659 | }; | ||
12660 | |||
12661 | var loggedTypeFailures = {}; | ||
12662 | function getDeclarationErrorAddendum(owner) { | ||
12663 | if (owner) { | ||
12664 | var name = owner.getName(); | ||
12665 | if (name) { | ||
12666 | return ' Check the render method of `' + name + '`.'; | ||
12667 | } | ||
12668 | } | ||
12669 | return ''; | ||
12670 | } | ||
12671 | |||
12672 | /** | ||
12673 | * Provide a linked `value` attribute for controlled forms. You should not use | ||
12674 | * this outside of the ReactDOM controlled form components. | ||
12675 | */ | ||
12676 | var LinkedValueUtils = { | ||
12677 | checkPropTypes: function (tagName, props, owner) { | ||
12678 | for (var propName in propTypes) { | ||
12679 | if (propTypes.hasOwnProperty(propName)) { | ||
12680 | var error = propTypes[propName](props, propName, tagName, ReactPropTypeLocations.prop); | ||
12681 | } | ||
12682 | if (error instanceof Error && !(error.message in loggedTypeFailures)) { | ||
12683 | // Only monitor this failure once because there tends to be a lot of the | ||
12684 | // same error. | ||
12685 | loggedTypeFailures[error.message] = true; | ||
12686 | |||
12687 | var addendum = getDeclarationErrorAddendum(owner); | ||
12688 | process.env.NODE_ENV !== 'production' ? warning(false, 'Failed form propType: %s%s', error.message, addendum) : undefined; | ||
12689 | } | ||
12690 | } | ||
12691 | }, | ||
12692 | |||
12693 | /** | ||
12694 | * @param {object} inputProps Props for form component | ||
12695 | * @return {*} current value of the input either from value prop or link. | ||
12696 | */ | ||
12697 | getValue: function (inputProps) { | ||
12698 | if (inputProps.valueLink) { | ||
12699 | _assertValueLink(inputProps); | ||
12700 | return inputProps.valueLink.value; | ||
12701 | } | ||
12702 | return inputProps.value; | ||
12703 | }, | ||
12704 | |||
12705 | /** | ||
12706 | * @param {object} inputProps Props for form component | ||
12707 | * @return {*} current checked status of the input either from checked prop | ||
12708 | * or link. | ||
12709 | */ | ||
12710 | getChecked: function (inputProps) { | ||
12711 | if (inputProps.checkedLink) { | ||
12712 | _assertCheckedLink(inputProps); | ||
12713 | return inputProps.checkedLink.value; | ||
12714 | } | ||
12715 | return inputProps.checked; | ||
12716 | }, | ||
12717 | |||
12718 | /** | ||
12719 | * @param {object} inputProps Props for form component | ||
12720 | * @param {SyntheticEvent} event change event to handle | ||
12721 | */ | ||
12722 | executeOnChange: function (inputProps, event) { | ||
12723 | if (inputProps.valueLink) { | ||
12724 | _assertValueLink(inputProps); | ||
12725 | return inputProps.valueLink.requestChange(event.target.value); | ||
12726 | } else if (inputProps.checkedLink) { | ||
12727 | _assertCheckedLink(inputProps); | ||
12728 | return inputProps.checkedLink.requestChange(event.target.checked); | ||
12729 | } else if (inputProps.onChange) { | ||
12730 | return inputProps.onChange.call(undefined, event); | ||
12731 | } | ||
12732 | } | ||
12733 | }; | ||
12734 | |||
12735 | module.exports = LinkedValueUtils; | ||
12736 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
12737 | |||
12738 | /***/ }, | ||
12739 | /* 109 */ | ||
12740 | /***/ function(module, exports, __webpack_require__) { | ||
12741 | |||
12742 | /** | ||
12743 | * Copyright 2013-2015, Facebook, Inc. | ||
12744 | * All rights reserved. | ||
12745 | * | ||
12746 | * This source code is licensed under the BSD-style license found in the | ||
12747 | * LICENSE file in the root directory of this source tree. An additional grant | ||
12748 | * of patent rights can be found in the PATENTS file in the same directory. | ||
12749 | * | ||
12750 | * @providesModule ReactPropTypes | ||
12751 | */ | ||
12752 | |||
12753 | 'use strict'; | ||
12754 | |||
12755 | var ReactElement = __webpack_require__(44); | ||
12756 | var ReactPropTypeLocationNames = __webpack_require__(68); | ||
12757 | |||
12758 | var emptyFunction = __webpack_require__(17); | ||
12759 | var getIteratorFn = __webpack_require__(110); | ||
12760 | |||
12761 | /** | ||
12762 | * Collection of methods that allow declaration and validation of props that are | ||
12763 | * supplied to React components. Example usage: | ||
12764 | * | ||
12765 | * var Props = require('ReactPropTypes'); | ||
12766 | * var MyArticle = React.createClass({ | ||
12767 | * propTypes: { | ||
12768 | * // An optional string prop named "description". | ||
12769 | * description: Props.string, | ||
12770 | * | ||
12771 | * // A required enum prop named "category". | ||
12772 | * category: Props.oneOf(['News','Photos']).isRequired, | ||
12773 | * | ||
12774 | * // A prop named "dialog" that requires an instance of Dialog. | ||
12775 | * dialog: Props.instanceOf(Dialog).isRequired | ||
12776 | * }, | ||
12777 | * render: function() { ... } | ||
12778 | * }); | ||
12779 | * | ||
12780 | * A more formal specification of how these methods are used: | ||
12781 | * | ||
12782 | * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) | ||
12783 | * decl := ReactPropTypes.{type}(.isRequired)? | ||
12784 | * | ||
12785 | * Each and every declaration produces a function with the same signature. This | ||
12786 | * allows the creation of custom validation functions. For example: | ||
12787 | * | ||
12788 | * var MyLink = React.createClass({ | ||
12789 | * propTypes: { | ||
12790 | * // An optional string or URI prop named "href". | ||
12791 | * href: function(props, propName, componentName) { | ||
12792 | * var propValue = props[propName]; | ||
12793 | * if (propValue != null && typeof propValue !== 'string' && | ||
12794 | * !(propValue instanceof URI)) { | ||
12795 | * return new Error( | ||
12796 | * 'Expected a string or an URI for ' + propName + ' in ' + | ||
12797 | * componentName | ||
12798 | * ); | ||
12799 | * } | ||
12800 | * } | ||
12801 | * }, | ||
12802 | * render: function() {...} | ||
12803 | * }); | ||
12804 | * | ||
12805 | * @internal | ||
12806 | */ | ||
12807 | |||
12808 | var ANONYMOUS = '<<anonymous>>'; | ||
12809 | |||
12810 | var ReactPropTypes = { | ||
12811 | array: createPrimitiveTypeChecker('array'), | ||
12812 | bool: createPrimitiveTypeChecker('boolean'), | ||
12813 | func: createPrimitiveTypeChecker('function'), | ||
12814 | number: createPrimitiveTypeChecker('number'), | ||
12815 | object: createPrimitiveTypeChecker('object'), | ||
12816 | string: createPrimitiveTypeChecker('string'), | ||
12817 | |||
12818 | any: createAnyTypeChecker(), | ||
12819 | arrayOf: createArrayOfTypeChecker, | ||
12820 | element: createElementTypeChecker(), | ||
12821 | instanceOf: createInstanceTypeChecker, | ||
12822 | node: createNodeChecker(), | ||
12823 | objectOf: createObjectOfTypeChecker, | ||
12824 | oneOf: createEnumTypeChecker, | ||
12825 | oneOfType: createUnionTypeChecker, | ||
12826 | shape: createShapeTypeChecker | ||
12827 | }; | ||
12828 | |||
12829 | function createChainableTypeChecker(validate) { | ||
12830 | function checkType(isRequired, props, propName, componentName, location, propFullName) { | ||
12831 | componentName = componentName || ANONYMOUS; | ||
12832 | propFullName = propFullName || propName; | ||
12833 | if (props[propName] == null) { | ||
12834 | var locationName = ReactPropTypeLocationNames[location]; | ||
12835 | if (isRequired) { | ||
12836 | return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.')); | ||
12837 | } | ||
12838 | return null; | ||
12839 | } else { | ||
12840 | return validate(props, propName, componentName, location, propFullName); | ||
12841 | } | ||
12842 | } | ||
12843 | |||
12844 | var chainedCheckType = checkType.bind(null, false); | ||
12845 | chainedCheckType.isRequired = checkType.bind(null, true); | ||
12846 | |||
12847 | return chainedCheckType; | ||
12848 | } | ||
12849 | |||
12850 | function createPrimitiveTypeChecker(expectedType) { | ||
12851 | function validate(props, propName, componentName, location, propFullName) { | ||
12852 | var propValue = props[propName]; | ||
12853 | var propType = getPropType(propValue); | ||
12854 | if (propType !== expectedType) { | ||
12855 | var locationName = ReactPropTypeLocationNames[location]; | ||
12856 | // `propValue` being instance of, say, date/regexp, pass the 'object' | ||
12857 | // check, but we can offer a more precise error message here rather than | ||
12858 | // 'of type `object`'. | ||
12859 | var preciseType = getPreciseType(propValue); | ||
12860 | |||
12861 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); | ||
12862 | } | ||
12863 | return null; | ||
12864 | } | ||
12865 | return createChainableTypeChecker(validate); | ||
12866 | } | ||
12867 | |||
12868 | function createAnyTypeChecker() { | ||
12869 | return createChainableTypeChecker(emptyFunction.thatReturns(null)); | ||
12870 | } | ||
12871 | |||
12872 | function createArrayOfTypeChecker(typeChecker) { | ||
12873 | function validate(props, propName, componentName, location, propFullName) { | ||
12874 | var propValue = props[propName]; | ||
12875 | if (!Array.isArray(propValue)) { | ||
12876 | var locationName = ReactPropTypeLocationNames[location]; | ||
12877 | var propType = getPropType(propValue); | ||
12878 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); | ||
12879 | } | ||
12880 | for (var i = 0; i < propValue.length; i++) { | ||
12881 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']'); | ||
12882 | if (error instanceof Error) { | ||
12883 | return error; | ||
12884 | } | ||
12885 | } | ||
12886 | return null; | ||
12887 | } | ||
12888 | return createChainableTypeChecker(validate); | ||
12889 | } | ||
12890 | |||
12891 | function createElementTypeChecker() { | ||
12892 | function validate(props, propName, componentName, location, propFullName) { | ||
12893 | if (!ReactElement.isValidElement(props[propName])) { | ||
12894 | var locationName = ReactPropTypeLocationNames[location]; | ||
12895 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.')); | ||
12896 | } | ||
12897 | return null; | ||
12898 | } | ||
12899 | return createChainableTypeChecker(validate); | ||
12900 | } | ||
12901 | |||
12902 | function createInstanceTypeChecker(expectedClass) { | ||
12903 | function validate(props, propName, componentName, location, propFullName) { | ||
12904 | if (!(props[propName] instanceof expectedClass)) { | ||
12905 | var locationName = ReactPropTypeLocationNames[location]; | ||
12906 | var expectedClassName = expectedClass.name || ANONYMOUS; | ||
12907 | var actualClassName = getClassName(props[propName]); | ||
12908 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); | ||
12909 | } | ||
12910 | return null; | ||
12911 | } | ||
12912 | return createChainableTypeChecker(validate); | ||
12913 | } | ||
12914 | |||
12915 | function createEnumTypeChecker(expectedValues) { | ||
12916 | if (!Array.isArray(expectedValues)) { | ||
12917 | return createChainableTypeChecker(function () { | ||
12918 | return new Error('Invalid argument supplied to oneOf, expected an instance of array.'); | ||
12919 | }); | ||
12920 | } | ||
12921 | |||
12922 | function validate(props, propName, componentName, location, propFullName) { | ||
12923 | var propValue = props[propName]; | ||
12924 | for (var i = 0; i < expectedValues.length; i++) { | ||
12925 | if (propValue === expectedValues[i]) { | ||
12926 | return null; | ||
12927 | } | ||
12928 | } | ||
12929 | |||
12930 | var locationName = ReactPropTypeLocationNames[location]; | ||
12931 | var valuesString = JSON.stringify(expectedValues); | ||
12932 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); | ||
12933 | } | ||
12934 | return createChainableTypeChecker(validate); | ||
12935 | } | ||
12936 | |||
12937 | function createObjectOfTypeChecker(typeChecker) { | ||
12938 | function validate(props, propName, componentName, location, propFullName) { | ||
12939 | var propValue = props[propName]; | ||
12940 | var propType = getPropType(propValue); | ||
12941 | if (propType !== 'object') { | ||
12942 | var locationName = ReactPropTypeLocationNames[location]; | ||
12943 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); | ||
12944 | } | ||
12945 | for (var key in propValue) { | ||
12946 | if (propValue.hasOwnProperty(key)) { | ||
12947 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key); | ||
12948 | if (error instanceof Error) { | ||
12949 | return error; | ||
12950 | } | ||
12951 | } | ||
12952 | } | ||
12953 | return null; | ||
12954 | } | ||
12955 | return createChainableTypeChecker(validate); | ||
12956 | } | ||
12957 | |||
12958 | function createUnionTypeChecker(arrayOfTypeCheckers) { | ||
12959 | if (!Array.isArray(arrayOfTypeCheckers)) { | ||
12960 | return createChainableTypeChecker(function () { | ||
12961 | return new Error('Invalid argument supplied to oneOfType, expected an instance of array.'); | ||
12962 | }); | ||
12963 | } | ||
12964 | |||
12965 | function validate(props, propName, componentName, location, propFullName) { | ||
12966 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | ||
12967 | var checker = arrayOfTypeCheckers[i]; | ||
12968 | if (checker(props, propName, componentName, location, propFullName) == null) { | ||
12969 | return null; | ||
12970 | } | ||
12971 | } | ||
12972 | |||
12973 | var locationName = ReactPropTypeLocationNames[location]; | ||
12974 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); | ||
12975 | } | ||
12976 | return createChainableTypeChecker(validate); | ||
12977 | } | ||
12978 | |||
12979 | function createNodeChecker() { | ||
12980 | function validate(props, propName, componentName, location, propFullName) { | ||
12981 | if (!isNode(props[propName])) { | ||
12982 | var locationName = ReactPropTypeLocationNames[location]; | ||
12983 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); | ||
12984 | } | ||
12985 | return null; | ||
12986 | } | ||
12987 | return createChainableTypeChecker(validate); | ||
12988 | } | ||
12989 | |||
12990 | function createShapeTypeChecker(shapeTypes) { | ||
12991 | function validate(props, propName, componentName, location, propFullName) { | ||
12992 | var propValue = props[propName]; | ||
12993 | var propType = getPropType(propValue); | ||
12994 | if (propType !== 'object') { | ||
12995 | var locationName = ReactPropTypeLocationNames[location]; | ||
12996 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | ||
12997 | } | ||
12998 | for (var key in shapeTypes) { | ||
12999 | var checker = shapeTypes[key]; | ||
13000 | if (!checker) { | ||
13001 | continue; | ||
13002 | } | ||
13003 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key); | ||
13004 | if (error) { | ||
13005 | return error; | ||
13006 | } | ||
13007 | } | ||
13008 | return null; | ||
13009 | } | ||
13010 | return createChainableTypeChecker(validate); | ||
13011 | } | ||
13012 | |||
13013 | function isNode(propValue) { | ||
13014 | switch (typeof propValue) { | ||
13015 | case 'number': | ||
13016 | case 'string': | ||
13017 | case 'undefined': | ||
13018 | return true; | ||
13019 | case 'boolean': | ||
13020 | return !propValue; | ||
13021 | case 'object': | ||
13022 | if (Array.isArray(propValue)) { | ||
13023 | return propValue.every(isNode); | ||
13024 | } | ||
13025 | if (propValue === null || ReactElement.isValidElement(propValue)) { | ||
13026 | return true; | ||
13027 | } | ||
13028 | |||
13029 | var iteratorFn = getIteratorFn(propValue); | ||
13030 | if (iteratorFn) { | ||
13031 | var iterator = iteratorFn.call(propValue); | ||
13032 | var step; | ||
13033 | if (iteratorFn !== propValue.entries) { | ||
13034 | while (!(step = iterator.next()).done) { | ||
13035 | if (!isNode(step.value)) { | ||
13036 | return false; | ||
13037 | } | ||
13038 | } | ||
13039 | } else { | ||
13040 | // Iterator will provide entry [k,v] tuples rather than values. | ||
13041 | while (!(step = iterator.next()).done) { | ||
13042 | var entry = step.value; | ||
13043 | if (entry) { | ||
13044 | if (!isNode(entry[1])) { | ||
13045 | return false; | ||
13046 | } | ||
13047 | } | ||
13048 | } | ||
13049 | } | ||
13050 | } else { | ||
13051 | return false; | ||
13052 | } | ||
13053 | |||
13054 | return true; | ||
13055 | default: | ||
13056 | return false; | ||
13057 | } | ||
13058 | } | ||
13059 | |||
13060 | // Equivalent of `typeof` but with special handling for array and regexp. | ||
13061 | function getPropType(propValue) { | ||
13062 | var propType = typeof propValue; | ||
13063 | if (Array.isArray(propValue)) { | ||
13064 | return 'array'; | ||
13065 | } | ||
13066 | if (propValue instanceof RegExp) { | ||
13067 | // Old webkits (at least until Android 4.0) return 'function' rather than | ||
13068 | // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ | ||
13069 | // passes PropTypes.object. | ||
13070 | return 'object'; | ||
13071 | } | ||
13072 | return propType; | ||
13073 | } | ||
13074 | |||
13075 | // This handles more types than `getPropType`. Only used for error messages. | ||
13076 | // See `createPrimitiveTypeChecker`. | ||
13077 | function getPreciseType(propValue) { | ||
13078 | var propType = getPropType(propValue); | ||
13079 | if (propType === 'object') { | ||
13080 | if (propValue instanceof Date) { | ||
13081 | return 'date'; | ||
13082 | } else if (propValue instanceof RegExp) { | ||
13083 | return 'regexp'; | ||
13084 | } | ||
13085 | } | ||
13086 | return propType; | ||
13087 | } | ||
13088 | |||
13089 | // Returns class name of the object, if any. | ||
13090 | function getClassName(propValue) { | ||
13091 | if (!propValue.constructor || !propValue.constructor.name) { | ||
13092 | return '<<anonymous>>'; | ||
13093 | } | ||
13094 | return propValue.constructor.name; | ||
13095 | } | ||
13096 | |||
13097 | module.exports = ReactPropTypes; | ||
13098 | |||
13099 | /***/ }, | ||
13100 | /* 110 */ | ||
13101 | /***/ function(module, exports) { | ||
13102 | |||
13103 | /** | ||
13104 | * Copyright 2013-2015, Facebook, Inc. | ||
13105 | * All rights reserved. | ||
13106 | * | ||
13107 | * This source code is licensed under the BSD-style license found in the | ||
13108 | * LICENSE file in the root directory of this source tree. An additional grant | ||
13109 | * of patent rights can be found in the PATENTS file in the same directory. | ||
13110 | * | ||
13111 | * @providesModule getIteratorFn | ||
13112 | * @typechecks static-only | ||
13113 | */ | ||
13114 | |||
13115 | 'use strict'; | ||
13116 | |||
13117 | /* global Symbol */ | ||
13118 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | ||
13119 | var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. | ||
13120 | |||
13121 | /** | ||
13122 | * Returns the iterator method function contained on the iterable object. | ||
13123 | * | ||
13124 | * Be sure to invoke the function with the iterable as context: | ||
13125 | * | ||
13126 | * var iteratorFn = getIteratorFn(myIterable); | ||
13127 | * if (iteratorFn) { | ||
13128 | * var iterator = iteratorFn.call(myIterable); | ||
13129 | * ... | ||
13130 | * } | ||
13131 | * | ||
13132 | * @param {?object} maybeIterable | ||
13133 | * @return {?function} | ||
13134 | */ | ||
13135 | function getIteratorFn(maybeIterable) { | ||
13136 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); | ||
13137 | if (typeof iteratorFn === 'function') { | ||
13138 | return iteratorFn; | ||
13139 | } | ||
13140 | } | ||
13141 | |||
13142 | module.exports = getIteratorFn; | ||
13143 | |||
13144 | /***/ }, | ||
13145 | /* 111 */ | ||
13146 | /***/ function(module, exports, __webpack_require__) { | ||
13147 | |||
13148 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
13149 | * Copyright 2013-2015, Facebook, Inc. | ||
13150 | * All rights reserved. | ||
13151 | * | ||
13152 | * This source code is licensed under the BSD-style license found in the | ||
13153 | * LICENSE file in the root directory of this source tree. An additional grant | ||
13154 | * of patent rights can be found in the PATENTS file in the same directory. | ||
13155 | * | ||
13156 | * @providesModule ReactDOMOption | ||
13157 | */ | ||
13158 | |||
13159 | 'use strict'; | ||
13160 | |||
13161 | var ReactChildren = __webpack_require__(112); | ||
13162 | var ReactDOMSelect = __webpack_require__(114); | ||
13163 | |||
13164 | var assign = __webpack_require__(41); | ||
13165 | var warning = __webpack_require__(27); | ||
13166 | |||
13167 | var valueContextKey = ReactDOMSelect.valueContextKey; | ||
13168 | |||
13169 | /** | ||
13170 | * Implements an <option> native component that warns when `selected` is set. | ||
13171 | */ | ||
13172 | var ReactDOMOption = { | ||
13173 | mountWrapper: function (inst, props, context) { | ||
13174 | // TODO (yungsters): Remove support for `selected` in <option>. | ||
13175 | if (process.env.NODE_ENV !== 'production') { | ||
13176 | process.env.NODE_ENV !== 'production' ? warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : undefined; | ||
13177 | } | ||
13178 | |||
13179 | // Look up whether this option is 'selected' via context | ||
13180 | var selectValue = context[valueContextKey]; | ||
13181 | |||
13182 | // If context key is null (e.g., no specified value or after initial mount) | ||
13183 | // or missing (e.g., for <datalist>), we don't change props.selected | ||
13184 | var selected = null; | ||
13185 | if (selectValue != null) { | ||
13186 | selected = false; | ||
13187 | if (Array.isArray(selectValue)) { | ||
13188 | // multiple | ||
13189 | for (var i = 0; i < selectValue.length; i++) { | ||
13190 | if ('' + selectValue[i] === '' + props.value) { | ||
13191 | selected = true; | ||
13192 | break; | ||
13193 | } | ||
13194 | } | ||
13195 | } else { | ||
13196 | selected = '' + selectValue === '' + props.value; | ||
13197 | } | ||
13198 | } | ||
13199 | |||
13200 | inst._wrapperState = { selected: selected }; | ||
13201 | }, | ||
13202 | |||
13203 | getNativeProps: function (inst, props, context) { | ||
13204 | var nativeProps = assign({ selected: undefined, children: undefined }, props); | ||
13205 | |||
13206 | // Read state only from initial mount because <select> updates value | ||
13207 | // manually; we need the initial state only for server rendering | ||
13208 | if (inst._wrapperState.selected != null) { | ||
13209 | nativeProps.selected = inst._wrapperState.selected; | ||
13210 | } | ||
13211 | |||
13212 | var content = ''; | ||
13213 | |||
13214 | // Flatten children and warn if they aren't strings or numbers; | ||
13215 | // invalid types are ignored. | ||
13216 | ReactChildren.forEach(props.children, function (child) { | ||
13217 | if (child == null) { | ||
13218 | return; | ||
13219 | } | ||
13220 | if (typeof child === 'string' || typeof child === 'number') { | ||
13221 | content += child; | ||
13222 | } else { | ||
13223 | process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : undefined; | ||
13224 | } | ||
13225 | }); | ||
13226 | |||
13227 | nativeProps.children = content; | ||
13228 | return nativeProps; | ||
13229 | } | ||
13230 | |||
13231 | }; | ||
13232 | |||
13233 | module.exports = ReactDOMOption; | ||
13234 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
13235 | |||
13236 | /***/ }, | ||
13237 | /* 112 */ | ||
13238 | /***/ function(module, exports, __webpack_require__) { | ||
13239 | |||
13240 | /** | ||
13241 | * Copyright 2013-2015, Facebook, Inc. | ||
13242 | * All rights reserved. | ||
13243 | * | ||
13244 | * This source code is licensed under the BSD-style license found in the | ||
13245 | * LICENSE file in the root directory of this source tree. An additional grant | ||
13246 | * of patent rights can be found in the PATENTS file in the same directory. | ||
13247 | * | ||
13248 | * @providesModule ReactChildren | ||
13249 | */ | ||
13250 | |||
13251 | 'use strict'; | ||
13252 | |||
13253 | var PooledClass = __webpack_require__(58); | ||
13254 | var ReactElement = __webpack_require__(44); | ||
13255 | |||
13256 | var emptyFunction = __webpack_require__(17); | ||
13257 | var traverseAllChildren = __webpack_require__(113); | ||
13258 | |||
13259 | var twoArgumentPooler = PooledClass.twoArgumentPooler; | ||
13260 | var fourArgumentPooler = PooledClass.fourArgumentPooler; | ||
13261 | |||
13262 | var userProvidedKeyEscapeRegex = /\/(?!\/)/g; | ||
13263 | function escapeUserProvidedKey(text) { | ||
13264 | return ('' + text).replace(userProvidedKeyEscapeRegex, '//'); | ||
13265 | } | ||
13266 | |||
13267 | /** | ||
13268 | * PooledClass representing the bookkeeping associated with performing a child | ||
13269 | * traversal. Allows avoiding binding callbacks. | ||
13270 | * | ||
13271 | * @constructor ForEachBookKeeping | ||
13272 | * @param {!function} forEachFunction Function to perform traversal with. | ||
13273 | * @param {?*} forEachContext Context to perform context with. | ||
13274 | */ | ||
13275 | function ForEachBookKeeping(forEachFunction, forEachContext) { | ||
13276 | this.func = forEachFunction; | ||
13277 | this.context = forEachContext; | ||
13278 | this.count = 0; | ||
13279 | } | ||
13280 | ForEachBookKeeping.prototype.destructor = function () { | ||
13281 | this.func = null; | ||
13282 | this.context = null; | ||
13283 | this.count = 0; | ||
13284 | }; | ||
13285 | PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler); | ||
13286 | |||
13287 | function forEachSingleChild(bookKeeping, child, name) { | ||
13288 | var func = bookKeeping.func; | ||
13289 | var context = bookKeeping.context; | ||
13290 | |||
13291 | func.call(context, child, bookKeeping.count++); | ||
13292 | } | ||
13293 | |||
13294 | /** | ||
13295 | * Iterates through children that are typically specified as `props.children`. | ||
13296 | * | ||
13297 | * The provided forEachFunc(child, index) will be called for each | ||
13298 | * leaf child. | ||
13299 | * | ||
13300 | * @param {?*} children Children tree container. | ||
13301 | * @param {function(*, int)} forEachFunc | ||
13302 | * @param {*} forEachContext Context for forEachContext. | ||
13303 | */ | ||
13304 | function forEachChildren(children, forEachFunc, forEachContext) { | ||
13305 | if (children == null) { | ||
13306 | return children; | ||
13307 | } | ||
13308 | var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext); | ||
13309 | traverseAllChildren(children, forEachSingleChild, traverseContext); | ||
13310 | ForEachBookKeeping.release(traverseContext); | ||
13311 | } | ||
13312 | |||
13313 | /** | ||
13314 | * PooledClass representing the bookkeeping associated with performing a child | ||
13315 | * mapping. Allows avoiding binding callbacks. | ||
13316 | * | ||
13317 | * @constructor MapBookKeeping | ||
13318 | * @param {!*} mapResult Object containing the ordered map of results. | ||
13319 | * @param {!function} mapFunction Function to perform mapping with. | ||
13320 | * @param {?*} mapContext Context to perform mapping with. | ||
13321 | */ | ||
13322 | function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) { | ||
13323 | this.result = mapResult; | ||
13324 | this.keyPrefix = keyPrefix; | ||
13325 | this.func = mapFunction; | ||
13326 | this.context = mapContext; | ||
13327 | this.count = 0; | ||
13328 | } | ||
13329 | MapBookKeeping.prototype.destructor = function () { | ||
13330 | this.result = null; | ||
13331 | this.keyPrefix = null; | ||
13332 | this.func = null; | ||
13333 | this.context = null; | ||
13334 | this.count = 0; | ||
13335 | }; | ||
13336 | PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler); | ||
13337 | |||
13338 | function mapSingleChildIntoContext(bookKeeping, child, childKey) { | ||
13339 | var result = bookKeeping.result; | ||
13340 | var keyPrefix = bookKeeping.keyPrefix; | ||
13341 | var func = bookKeeping.func; | ||
13342 | var context = bookKeeping.context; | ||
13343 | |||
13344 | var mappedChild = func.call(context, child, bookKeeping.count++); | ||
13345 | if (Array.isArray(mappedChild)) { | ||
13346 | mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument); | ||
13347 | } else if (mappedChild != null) { | ||
13348 | if (ReactElement.isValidElement(mappedChild)) { | ||
13349 | mappedChild = ReactElement.cloneAndReplaceKey(mappedChild, | ||
13350 | // Keep both the (mapped) and old keys if they differ, just as | ||
13351 | // traverseAllChildren used to do for objects as children | ||
13352 | keyPrefix + (mappedChild !== child ? escapeUserProvidedKey(mappedChild.key || '') + '/' : '') + childKey); | ||
13353 | } | ||
13354 | result.push(mappedChild); | ||
13355 | } | ||
13356 | } | ||
13357 | |||
13358 | function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { | ||
13359 | var escapedPrefix = ''; | ||
13360 | if (prefix != null) { | ||
13361 | escapedPrefix = escapeUserProvidedKey(prefix) + '/'; | ||
13362 | } | ||
13363 | var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context); | ||
13364 | traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); | ||
13365 | MapBookKeeping.release(traverseContext); | ||
13366 | } | ||
13367 | |||
13368 | /** | ||
13369 | * Maps children that are typically specified as `props.children`. | ||
13370 | * | ||
13371 | * The provided mapFunction(child, key, index) will be called for each | ||
13372 | * leaf child. | ||
13373 | * | ||
13374 | * @param {?*} children Children tree container. | ||
13375 | * @param {function(*, int)} func The map function. | ||
13376 | * @param {*} context Context for mapFunction. | ||
13377 | * @return {object} Object containing the ordered map of results. | ||
13378 | */ | ||
13379 | function mapChildren(children, func, context) { | ||
13380 | if (children == null) { | ||
13381 | return children; | ||
13382 | } | ||
13383 | var result = []; | ||
13384 | mapIntoWithKeyPrefixInternal(children, result, null, func, context); | ||
13385 | return result; | ||
13386 | } | ||
13387 | |||
13388 | function forEachSingleChildDummy(traverseContext, child, name) { | ||
13389 | return null; | ||
13390 | } | ||
13391 | |||
13392 | /** | ||
13393 | * Count the number of children that are typically specified as | ||
13394 | * `props.children`. | ||
13395 | * | ||
13396 | * @param {?*} children Children tree container. | ||
13397 | * @return {number} The number of children. | ||
13398 | */ | ||
13399 | function countChildren(children, context) { | ||
13400 | return traverseAllChildren(children, forEachSingleChildDummy, null); | ||
13401 | } | ||
13402 | |||
13403 | /** | ||
13404 | * Flatten a children object (typically specified as `props.children`) and | ||
13405 | * return an array with appropriately re-keyed children. | ||
13406 | */ | ||
13407 | function toArray(children) { | ||
13408 | var result = []; | ||
13409 | mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument); | ||
13410 | return result; | ||
13411 | } | ||
13412 | |||
13413 | var ReactChildren = { | ||
13414 | forEach: forEachChildren, | ||
13415 | map: mapChildren, | ||
13416 | mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal, | ||
13417 | count: countChildren, | ||
13418 | toArray: toArray | ||
13419 | }; | ||
13420 | |||
13421 | module.exports = ReactChildren; | ||
13422 | |||
13423 | /***/ }, | ||
13424 | /* 113 */ | ||
13425 | /***/ function(module, exports, __webpack_require__) { | ||
13426 | |||
13427 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
13428 | * Copyright 2013-2015, Facebook, Inc. | ||
13429 | * All rights reserved. | ||
13430 | * | ||
13431 | * This source code is licensed under the BSD-style license found in the | ||
13432 | * LICENSE file in the root directory of this source tree. An additional grant | ||
13433 | * of patent rights can be found in the PATENTS file in the same directory. | ||
13434 | * | ||
13435 | * @providesModule traverseAllChildren | ||
13436 | */ | ||
13437 | |||
13438 | 'use strict'; | ||
13439 | |||
13440 | var ReactCurrentOwner = __webpack_require__(7); | ||
13441 | var ReactElement = __webpack_require__(44); | ||
13442 | var ReactInstanceHandles = __webpack_require__(47); | ||
13443 | |||
13444 | var getIteratorFn = __webpack_require__(110); | ||
13445 | var invariant = __webpack_require__(15); | ||
13446 | var warning = __webpack_require__(27); | ||
13447 | |||
13448 | var SEPARATOR = ReactInstanceHandles.SEPARATOR; | ||
13449 | var SUBSEPARATOR = ':'; | ||
13450 | |||
13451 | /** | ||
13452 | * TODO: Test that a single child and an array with one item have the same key | ||
13453 | * pattern. | ||
13454 | */ | ||
13455 | |||
13456 | var userProvidedKeyEscaperLookup = { | ||
13457 | '=': '=0', | ||
13458 | '.': '=1', | ||
13459 | ':': '=2' | ||
13460 | }; | ||
13461 | |||
13462 | var userProvidedKeyEscapeRegex = /[=.:]/g; | ||
13463 | |||
13464 | var didWarnAboutMaps = false; | ||
13465 | |||
13466 | function userProvidedKeyEscaper(match) { | ||
13467 | return userProvidedKeyEscaperLookup[match]; | ||
13468 | } | ||
13469 | |||
13470 | /** | ||
13471 | * Generate a key string that identifies a component within a set. | ||
13472 | * | ||
13473 | * @param {*} component A component that could contain a manual key. | ||
13474 | * @param {number} index Index that is used if a manual key is not provided. | ||
13475 | * @return {string} | ||
13476 | */ | ||
13477 | function getComponentKey(component, index) { | ||
13478 | if (component && component.key != null) { | ||
13479 | // Explicit key | ||
13480 | return wrapUserProvidedKey(component.key); | ||
13481 | } | ||
13482 | // Implicit key determined by the index in the set | ||
13483 | return index.toString(36); | ||
13484 | } | ||
13485 | |||
13486 | /** | ||
13487 | * Escape a component key so that it is safe to use in a reactid. | ||
13488 | * | ||
13489 | * @param {*} text Component key to be escaped. | ||
13490 | * @return {string} An escaped string. | ||
13491 | */ | ||
13492 | function escapeUserProvidedKey(text) { | ||
13493 | return ('' + text).replace(userProvidedKeyEscapeRegex, userProvidedKeyEscaper); | ||
13494 | } | ||
13495 | |||
13496 | /** | ||
13497 | * Wrap a `key` value explicitly provided by the user to distinguish it from | ||
13498 | * implicitly-generated keys generated by a component's index in its parent. | ||
13499 | * | ||
13500 | * @param {string} key Value of a user-provided `key` attribute | ||
13501 | * @return {string} | ||
13502 | */ | ||
13503 | function wrapUserProvidedKey(key) { | ||
13504 | return '$' + escapeUserProvidedKey(key); | ||
13505 | } | ||
13506 | |||
13507 | /** | ||
13508 | * @param {?*} children Children tree container. | ||
13509 | * @param {!string} nameSoFar Name of the key path so far. | ||
13510 | * @param {!function} callback Callback to invoke with each child found. | ||
13511 | * @param {?*} traverseContext Used to pass information throughout the traversal | ||
13512 | * process. | ||
13513 | * @return {!number} The number of children in this subtree. | ||
13514 | */ | ||
13515 | function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { | ||
13516 | var type = typeof children; | ||
13517 | |||
13518 | if (type === 'undefined' || type === 'boolean') { | ||
13519 | // All of the above are perceived as null. | ||
13520 | children = null; | ||
13521 | } | ||
13522 | |||
13523 | if (children === null || type === 'string' || type === 'number' || ReactElement.isValidElement(children)) { | ||
13524 | callback(traverseContext, children, | ||
13525 | // If it's the only child, treat the name as if it was wrapped in an array | ||
13526 | // so that it's consistent if the number of children grows. | ||
13527 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); | ||
13528 | return 1; | ||
13529 | } | ||
13530 | |||
13531 | var child; | ||
13532 | var nextName; | ||
13533 | var subtreeCount = 0; // Count of children found in the current subtree. | ||
13534 | var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; | ||
13535 | |||
13536 | if (Array.isArray(children)) { | ||
13537 | for (var i = 0; i < children.length; i++) { | ||
13538 | child = children[i]; | ||
13539 | nextName = nextNamePrefix + getComponentKey(child, i); | ||
13540 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); | ||
13541 | } | ||
13542 | } else { | ||
13543 | var iteratorFn = getIteratorFn(children); | ||
13544 | if (iteratorFn) { | ||
13545 | var iterator = iteratorFn.call(children); | ||
13546 | var step; | ||
13547 | if (iteratorFn !== children.entries) { | ||
13548 | var ii = 0; | ||
13549 | while (!(step = iterator.next()).done) { | ||
13550 | child = step.value; | ||
13551 | nextName = nextNamePrefix + getComponentKey(child, ii++); | ||
13552 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); | ||
13553 | } | ||
13554 | } else { | ||
13555 | if (process.env.NODE_ENV !== 'production') { | ||
13556 | process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : undefined; | ||
13557 | didWarnAboutMaps = true; | ||
13558 | } | ||
13559 | // Iterator will provide entry [k,v] tuples rather than values. | ||
13560 | while (!(step = iterator.next()).done) { | ||
13561 | var entry = step.value; | ||
13562 | if (entry) { | ||
13563 | child = entry[1]; | ||
13564 | nextName = nextNamePrefix + wrapUserProvidedKey(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0); | ||
13565 | subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); | ||
13566 | } | ||
13567 | } | ||
13568 | } | ||
13569 | } else if (type === 'object') { | ||
13570 | var addendum = ''; | ||
13571 | if (process.env.NODE_ENV !== 'production') { | ||
13572 | addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.'; | ||
13573 | if (children._isReactElement) { | ||
13574 | addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.'; | ||
13575 | } | ||
13576 | if (ReactCurrentOwner.current) { | ||
13577 | var name = ReactCurrentOwner.current.getName(); | ||
13578 | if (name) { | ||
13579 | addendum += ' Check the render method of `' + name + '`.'; | ||
13580 | } | ||
13581 | } | ||
13582 | } | ||
13583 | var childrenString = String(children); | ||
13584 | true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) : undefined; | ||
13585 | } | ||
13586 | } | ||
13587 | |||
13588 | return subtreeCount; | ||
13589 | } | ||
13590 | |||
13591 | /** | ||
13592 | * Traverses children that are typically specified as `props.children`, but | ||
13593 | * might also be specified through attributes: | ||
13594 | * | ||
13595 | * - `traverseAllChildren(this.props.children, ...)` | ||
13596 | * - `traverseAllChildren(this.props.leftPanelChildren, ...)` | ||
13597 | * | ||
13598 | * The `traverseContext` is an optional argument that is passed through the | ||
13599 | * entire traversal. It can be used to store accumulations or anything else that | ||
13600 | * the callback might find relevant. | ||
13601 | * | ||
13602 | * @param {?*} children Children tree object. | ||
13603 | * @param {!function} callback To invoke upon traversing each child. | ||
13604 | * @param {?*} traverseContext Context for traversal. | ||
13605 | * @return {!number} The number of children in this subtree. | ||
13606 | */ | ||
13607 | function traverseAllChildren(children, callback, traverseContext) { | ||
13608 | if (children == null) { | ||
13609 | return 0; | ||
13610 | } | ||
13611 | |||
13612 | return traverseAllChildrenImpl(children, '', callback, traverseContext); | ||
13613 | } | ||
13614 | |||
13615 | module.exports = traverseAllChildren; | ||
13616 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
13617 | |||
13618 | /***/ }, | ||
13619 | /* 114 */ | ||
13620 | /***/ function(module, exports, __webpack_require__) { | ||
13621 | |||
13622 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
13623 | * Copyright 2013-2015, Facebook, Inc. | ||
13624 | * All rights reserved. | ||
13625 | * | ||
13626 | * This source code is licensed under the BSD-style license found in the | ||
13627 | * LICENSE file in the root directory of this source tree. An additional grant | ||
13628 | * of patent rights can be found in the PATENTS file in the same directory. | ||
13629 | * | ||
13630 | * @providesModule ReactDOMSelect | ||
13631 | */ | ||
13632 | |||
13633 | 'use strict'; | ||
13634 | |||
13635 | var LinkedValueUtils = __webpack_require__(108); | ||
13636 | var ReactMount = __webpack_require__(30); | ||
13637 | var ReactUpdates = __webpack_require__(56); | ||
13638 | |||
13639 | var assign = __webpack_require__(41); | ||
13640 | var warning = __webpack_require__(27); | ||
13641 | |||
13642 | var valueContextKey = '__ReactDOMSelect_value$' + Math.random().toString(36).slice(2); | ||
13643 | |||
13644 | function updateOptionsIfPendingUpdateAndMounted() { | ||
13645 | if (this._rootNodeID && this._wrapperState.pendingUpdate) { | ||
13646 | this._wrapperState.pendingUpdate = false; | ||
13647 | |||
13648 | var props = this._currentElement.props; | ||
13649 | var value = LinkedValueUtils.getValue(props); | ||
13650 | |||
13651 | if (value != null) { | ||
13652 | updateOptions(this, props, value); | ||
13653 | } | ||
13654 | } | ||
13655 | } | ||
13656 | |||
13657 | function getDeclarationErrorAddendum(owner) { | ||
13658 | if (owner) { | ||
13659 | var name = owner.getName(); | ||
13660 | if (name) { | ||
13661 | return ' Check the render method of `' + name + '`.'; | ||
13662 | } | ||
13663 | } | ||
13664 | return ''; | ||
13665 | } | ||
13666 | |||
13667 | var valuePropNames = ['value', 'defaultValue']; | ||
13668 | |||
13669 | /** | ||
13670 | * Validation function for `value` and `defaultValue`. | ||
13671 | * @private | ||
13672 | */ | ||
13673 | function checkSelectPropTypes(inst, props) { | ||
13674 | var owner = inst._currentElement._owner; | ||
13675 | LinkedValueUtils.checkPropTypes('select', props, owner); | ||
13676 | |||
13677 | for (var i = 0; i < valuePropNames.length; i++) { | ||
13678 | var propName = valuePropNames[i]; | ||
13679 | if (props[propName] == null) { | ||
13680 | continue; | ||
13681 | } | ||
13682 | if (props.multiple) { | ||
13683 | process.env.NODE_ENV !== 'production' ? warning(Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : undefined; | ||
13684 | } else { | ||
13685 | process.env.NODE_ENV !== 'production' ? warning(!Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : undefined; | ||
13686 | } | ||
13687 | } | ||
13688 | } | ||
13689 | |||
13690 | /** | ||
13691 | * @param {ReactDOMComponent} inst | ||
13692 | * @param {boolean} multiple | ||
13693 | * @param {*} propValue A stringable (with `multiple`, a list of stringables). | ||
13694 | * @private | ||
13695 | */ | ||
13696 | function updateOptions(inst, multiple, propValue) { | ||
13697 | var selectedValue, i; | ||
13698 | var options = ReactMount.getNode(inst._rootNodeID).options; | ||
13699 | |||
13700 | if (multiple) { | ||
13701 | selectedValue = {}; | ||
13702 | for (i = 0; i < propValue.length; i++) { | ||
13703 | selectedValue['' + propValue[i]] = true; | ||
13704 | } | ||
13705 | for (i = 0; i < options.length; i++) { | ||
13706 | var selected = selectedValue.hasOwnProperty(options[i].value); | ||
13707 | if (options[i].selected !== selected) { | ||
13708 | options[i].selected = selected; | ||
13709 | } | ||
13710 | } | ||
13711 | } else { | ||
13712 | // Do not set `select.value` as exact behavior isn't consistent across all | ||
13713 | // browsers for all cases. | ||
13714 | selectedValue = '' + propValue; | ||
13715 | for (i = 0; i < options.length; i++) { | ||
13716 | if (options[i].value === selectedValue) { | ||
13717 | options[i].selected = true; | ||
13718 | return; | ||
13719 | } | ||
13720 | } | ||
13721 | if (options.length) { | ||
13722 | options[0].selected = true; | ||
13723 | } | ||
13724 | } | ||
13725 | } | ||
13726 | |||
13727 | /** | ||
13728 | * Implements a <select> native component that allows optionally setting the | ||
13729 | * props `value` and `defaultValue`. If `multiple` is false, the prop must be a | ||
13730 | * stringable. If `multiple` is true, the prop must be an array of stringables. | ||
13731 | * | ||
13732 | * If `value` is not supplied (or null/undefined), user actions that change the | ||
13733 | * selected option will trigger updates to the rendered options. | ||
13734 | * | ||
13735 | * If it is supplied (and not null/undefined), the rendered options will not | ||
13736 | * update in response to user actions. Instead, the `value` prop must change in | ||
13737 | * order for the rendered options to update. | ||
13738 | * | ||
13739 | * If `defaultValue` is provided, any options with the supplied values will be | ||
13740 | * selected. | ||
13741 | */ | ||
13742 | var ReactDOMSelect = { | ||
13743 | valueContextKey: valueContextKey, | ||
13744 | |||
13745 | getNativeProps: function (inst, props, context) { | ||
13746 | return assign({}, props, { | ||
13747 | onChange: inst._wrapperState.onChange, | ||
13748 | value: undefined | ||
13749 | }); | ||
13750 | }, | ||
13751 | |||
13752 | mountWrapper: function (inst, props) { | ||
13753 | if (process.env.NODE_ENV !== 'production') { | ||
13754 | checkSelectPropTypes(inst, props); | ||
13755 | } | ||
13756 | |||
13757 | var value = LinkedValueUtils.getValue(props); | ||
13758 | inst._wrapperState = { | ||
13759 | pendingUpdate: false, | ||
13760 | initialValue: value != null ? value : props.defaultValue, | ||
13761 | onChange: _handleChange.bind(inst), | ||
13762 | wasMultiple: Boolean(props.multiple) | ||
13763 | }; | ||
13764 | }, | ||
13765 | |||
13766 | processChildContext: function (inst, props, context) { | ||
13767 | // Pass down initial value so initial generated markup has correct | ||
13768 | // `selected` attributes | ||
13769 | var childContext = assign({}, context); | ||
13770 | childContext[valueContextKey] = inst._wrapperState.initialValue; | ||
13771 | return childContext; | ||
13772 | }, | ||
13773 | |||
13774 | postUpdateWrapper: function (inst) { | ||
13775 | var props = inst._currentElement.props; | ||
13776 | |||
13777 | // After the initial mount, we control selected-ness manually so don't pass | ||
13778 | // the context value down | ||
13779 | inst._wrapperState.initialValue = undefined; | ||
13780 | |||
13781 | var wasMultiple = inst._wrapperState.wasMultiple; | ||
13782 | inst._wrapperState.wasMultiple = Boolean(props.multiple); | ||
13783 | |||
13784 | var value = LinkedValueUtils.getValue(props); | ||
13785 | if (value != null) { | ||
13786 | inst._wrapperState.pendingUpdate = false; | ||
13787 | updateOptions(inst, Boolean(props.multiple), value); | ||
13788 | } else if (wasMultiple !== Boolean(props.multiple)) { | ||
13789 | // For simplicity, reapply `defaultValue` if `multiple` is toggled. | ||
13790 | if (props.defaultValue != null) { | ||
13791 | updateOptions(inst, Boolean(props.multiple), props.defaultValue); | ||
13792 | } else { | ||
13793 | // Revert the select back to its default unselected state. | ||
13794 | updateOptions(inst, Boolean(props.multiple), props.multiple ? [] : ''); | ||
13795 | } | ||
13796 | } | ||
13797 | } | ||
13798 | }; | ||
13799 | |||
13800 | function _handleChange(event) { | ||
13801 | var props = this._currentElement.props; | ||
13802 | var returnValue = LinkedValueUtils.executeOnChange(props, event); | ||
13803 | |||
13804 | this._wrapperState.pendingUpdate = true; | ||
13805 | ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this); | ||
13806 | return returnValue; | ||
13807 | } | ||
13808 | |||
13809 | module.exports = ReactDOMSelect; | ||
13810 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
13811 | |||
13812 | /***/ }, | ||
13813 | /* 115 */ | ||
13814 | /***/ function(module, exports, __webpack_require__) { | ||
13815 | |||
13816 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
13817 | * Copyright 2013-2015, Facebook, Inc. | ||
13818 | * All rights reserved. | ||
13819 | * | ||
13820 | * This source code is licensed under the BSD-style license found in the | ||
13821 | * LICENSE file in the root directory of this source tree. An additional grant | ||
13822 | * of patent rights can be found in the PATENTS file in the same directory. | ||
13823 | * | ||
13824 | * @providesModule ReactDOMTextarea | ||
13825 | */ | ||
13826 | |||
13827 | 'use strict'; | ||
13828 | |||
13829 | var LinkedValueUtils = __webpack_require__(108); | ||
13830 | var ReactDOMIDOperations = __webpack_require__(29); | ||
13831 | var ReactUpdates = __webpack_require__(56); | ||
13832 | |||
13833 | var assign = __webpack_require__(41); | ||
13834 | var invariant = __webpack_require__(15); | ||
13835 | var warning = __webpack_require__(27); | ||
13836 | |||
13837 | function forceUpdateIfMounted() { | ||
13838 | if (this._rootNodeID) { | ||
13839 | // DOM component is still mounted; update | ||
13840 | ReactDOMTextarea.updateWrapper(this); | ||
13841 | } | ||
13842 | } | ||
13843 | |||
13844 | /** | ||
13845 | * Implements a <textarea> native component that allows setting `value`, and | ||
13846 | * `defaultValue`. This differs from the traditional DOM API because value is | ||
13847 | * usually set as PCDATA children. | ||
13848 | * | ||
13849 | * If `value` is not supplied (or null/undefined), user actions that affect the | ||
13850 | * value will trigger updates to the element. | ||
13851 | * | ||
13852 | * If `value` is supplied (and not null/undefined), the rendered element will | ||
13853 | * not trigger updates to the element. Instead, the `value` prop must change in | ||
13854 | * order for the rendered element to be updated. | ||
13855 | * | ||
13856 | * The rendered element will be initialized with an empty value, the prop | ||
13857 | * `defaultValue` if specified, or the children content (deprecated). | ||
13858 | */ | ||
13859 | var ReactDOMTextarea = { | ||
13860 | getNativeProps: function (inst, props, context) { | ||
13861 | !(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined; | ||
13862 | |||
13863 | // Always set children to the same thing. In IE9, the selection range will | ||
13864 | // get reset if `textContent` is mutated. | ||
13865 | var nativeProps = assign({}, props, { | ||
13866 | defaultValue: undefined, | ||
13867 | value: undefined, | ||
13868 | children: inst._wrapperState.initialValue, | ||
13869 | onChange: inst._wrapperState.onChange | ||
13870 | }); | ||
13871 | |||
13872 | return nativeProps; | ||
13873 | }, | ||
13874 | |||
13875 | mountWrapper: function (inst, props) { | ||
13876 | if (process.env.NODE_ENV !== 'production') { | ||
13877 | LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner); | ||
13878 | } | ||
13879 | |||
13880 | var defaultValue = props.defaultValue; | ||
13881 | // TODO (yungsters): Remove support for children content in <textarea>. | ||
13882 | var children = props.children; | ||
13883 | if (children != null) { | ||
13884 | if (process.env.NODE_ENV !== 'production') { | ||
13885 | process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : undefined; | ||
13886 | } | ||
13887 | !(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : undefined; | ||
13888 | if (Array.isArray(children)) { | ||
13889 | !(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : undefined; | ||
13890 | children = children[0]; | ||
13891 | } | ||
13892 | |||
13893 | defaultValue = '' + children; | ||
13894 | } | ||
13895 | if (defaultValue == null) { | ||
13896 | defaultValue = ''; | ||
13897 | } | ||
13898 | var value = LinkedValueUtils.getValue(props); | ||
13899 | |||
13900 | inst._wrapperState = { | ||
13901 | // We save the initial value so that `ReactDOMComponent` doesn't update | ||
13902 | // `textContent` (unnecessary since we update value). | ||
13903 | // The initial value can be a boolean or object so that's why it's | ||
13904 | // forced to be a string. | ||
13905 | initialValue: '' + (value != null ? value : defaultValue), | ||
13906 | onChange: _handleChange.bind(inst) | ||
13907 | }; | ||
13908 | }, | ||
13909 | |||
13910 | updateWrapper: function (inst) { | ||
13911 | var props = inst._currentElement.props; | ||
13912 | var value = LinkedValueUtils.getValue(props); | ||
13913 | if (value != null) { | ||
13914 | // Cast `value` to a string to ensure the value is set correctly. While | ||
13915 | // browsers typically do this as necessary, jsdom doesn't. | ||
13916 | ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value); | ||
13917 | } | ||
13918 | } | ||
13919 | }; | ||
13920 | |||
13921 | function _handleChange(event) { | ||
13922 | var props = this._currentElement.props; | ||
13923 | var returnValue = LinkedValueUtils.executeOnChange(props, event); | ||
13924 | ReactUpdates.asap(forceUpdateIfMounted, this); | ||
13925 | return returnValue; | ||
13926 | } | ||
13927 | |||
13928 | module.exports = ReactDOMTextarea; | ||
13929 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
13930 | |||
13931 | /***/ }, | ||
13932 | /* 116 */ | ||
13933 | /***/ function(module, exports, __webpack_require__) { | ||
13934 | |||
13935 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
13936 | * Copyright 2013-2015, Facebook, Inc. | ||
13937 | * All rights reserved. | ||
13938 | * | ||
13939 | * This source code is licensed under the BSD-style license found in the | ||
13940 | * LICENSE file in the root directory of this source tree. An additional grant | ||
13941 | * of patent rights can be found in the PATENTS file in the same directory. | ||
13942 | * | ||
13943 | * @providesModule ReactMultiChild | ||
13944 | * @typechecks static-only | ||
13945 | */ | ||
13946 | |||
13947 | 'use strict'; | ||
13948 | |||
13949 | var ReactComponentEnvironment = __webpack_require__(66); | ||
13950 | var ReactMultiChildUpdateTypes = __webpack_require__(18); | ||
13951 | |||
13952 | var ReactCurrentOwner = __webpack_require__(7); | ||
13953 | var ReactReconciler = __webpack_require__(52); | ||
13954 | var ReactChildReconciler = __webpack_require__(117); | ||
13955 | |||
13956 | var flattenChildren = __webpack_require__(118); | ||
13957 | |||
13958 | /** | ||
13959 | * Updating children of a component may trigger recursive updates. The depth is | ||
13960 | * used to batch recursive updates to render markup more efficiently. | ||
13961 | * | ||
13962 | * @type {number} | ||
13963 | * @private | ||
13964 | */ | ||
13965 | var updateDepth = 0; | ||
13966 | |||
13967 | /** | ||
13968 | * Queue of update configuration objects. | ||
13969 | * | ||
13970 | * Each object has a `type` property that is in `ReactMultiChildUpdateTypes`. | ||
13971 | * | ||
13972 | * @type {array<object>} | ||
13973 | * @private | ||
13974 | */ | ||
13975 | var updateQueue = []; | ||
13976 | |||
13977 | /** | ||
13978 | * Queue of markup to be rendered. | ||
13979 | * | ||
13980 | * @type {array<string>} | ||
13981 | * @private | ||
13982 | */ | ||
13983 | var markupQueue = []; | ||
13984 | |||
13985 | /** | ||
13986 | * Enqueues markup to be rendered and inserted at a supplied index. | ||
13987 | * | ||
13988 | * @param {string} parentID ID of the parent component. | ||
13989 | * @param {string} markup Markup that renders into an element. | ||
13990 | * @param {number} toIndex Destination index. | ||
13991 | * @private | ||
13992 | */ | ||
13993 | function enqueueInsertMarkup(parentID, markup, toIndex) { | ||
13994 | // NOTE: Null values reduce hidden classes. | ||
13995 | updateQueue.push({ | ||
13996 | parentID: parentID, | ||
13997 | parentNode: null, | ||
13998 | type: ReactMultiChildUpdateTypes.INSERT_MARKUP, | ||
13999 | markupIndex: markupQueue.push(markup) - 1, | ||
14000 | content: null, | ||
14001 | fromIndex: null, | ||
14002 | toIndex: toIndex | ||
14003 | }); | ||
14004 | } | ||
14005 | |||
14006 | /** | ||
14007 | * Enqueues moving an existing element to another index. | ||
14008 | * | ||
14009 | * @param {string} parentID ID of the parent component. | ||
14010 | * @param {number} fromIndex Source index of the existing element. | ||
14011 | * @param {number} toIndex Destination index of the element. | ||
14012 | * @private | ||
14013 | */ | ||
14014 | function enqueueMove(parentID, fromIndex, toIndex) { | ||
14015 | // NOTE: Null values reduce hidden classes. | ||
14016 | updateQueue.push({ | ||
14017 | parentID: parentID, | ||
14018 | parentNode: null, | ||
14019 | type: ReactMultiChildUpdateTypes.MOVE_EXISTING, | ||
14020 | markupIndex: null, | ||
14021 | content: null, | ||
14022 | fromIndex: fromIndex, | ||
14023 | toIndex: toIndex | ||
14024 | }); | ||
14025 | } | ||
14026 | |||
14027 | /** | ||
14028 | * Enqueues removing an element at an index. | ||
14029 | * | ||
14030 | * @param {string} parentID ID of the parent component. | ||
14031 | * @param {number} fromIndex Index of the element to remove. | ||
14032 | * @private | ||
14033 | */ | ||
14034 | function enqueueRemove(parentID, fromIndex) { | ||
14035 | // NOTE: Null values reduce hidden classes. | ||
14036 | updateQueue.push({ | ||
14037 | parentID: parentID, | ||
14038 | parentNode: null, | ||
14039 | type: ReactMultiChildUpdateTypes.REMOVE_NODE, | ||
14040 | markupIndex: null, | ||
14041 | content: null, | ||
14042 | fromIndex: fromIndex, | ||
14043 | toIndex: null | ||
14044 | }); | ||
14045 | } | ||
14046 | |||
14047 | /** | ||
14048 | * Enqueues setting the markup of a node. | ||
14049 | * | ||
14050 | * @param {string} parentID ID of the parent component. | ||
14051 | * @param {string} markup Markup that renders into an element. | ||
14052 | * @private | ||
14053 | */ | ||
14054 | function enqueueSetMarkup(parentID, markup) { | ||
14055 | // NOTE: Null values reduce hidden classes. | ||
14056 | updateQueue.push({ | ||
14057 | parentID: parentID, | ||
14058 | parentNode: null, | ||
14059 | type: ReactMultiChildUpdateTypes.SET_MARKUP, | ||
14060 | markupIndex: null, | ||
14061 | content: markup, | ||
14062 | fromIndex: null, | ||
14063 | toIndex: null | ||
14064 | }); | ||
14065 | } | ||
14066 | |||
14067 | /** | ||
14068 | * Enqueues setting the text content. | ||
14069 | * | ||
14070 | * @param {string} parentID ID of the parent component. | ||
14071 | * @param {string} textContent Text content to set. | ||
14072 | * @private | ||
14073 | */ | ||
14074 | function enqueueTextContent(parentID, textContent) { | ||
14075 | // NOTE: Null values reduce hidden classes. | ||
14076 | updateQueue.push({ | ||
14077 | parentID: parentID, | ||
14078 | parentNode: null, | ||
14079 | type: ReactMultiChildUpdateTypes.TEXT_CONTENT, | ||
14080 | markupIndex: null, | ||
14081 | content: textContent, | ||
14082 | fromIndex: null, | ||
14083 | toIndex: null | ||
14084 | }); | ||
14085 | } | ||
14086 | |||
14087 | /** | ||
14088 | * Processes any enqueued updates. | ||
14089 | * | ||
14090 | * @private | ||
14091 | */ | ||
14092 | function processQueue() { | ||
14093 | if (updateQueue.length) { | ||
14094 | ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue); | ||
14095 | clearQueue(); | ||
14096 | } | ||
14097 | } | ||
14098 | |||
14099 | /** | ||
14100 | * Clears any enqueued updates. | ||
14101 | * | ||
14102 | * @private | ||
14103 | */ | ||
14104 | function clearQueue() { | ||
14105 | updateQueue.length = 0; | ||
14106 | markupQueue.length = 0; | ||
14107 | } | ||
14108 | |||
14109 | /** | ||
14110 | * ReactMultiChild are capable of reconciling multiple children. | ||
14111 | * | ||
14112 | * @class ReactMultiChild | ||
14113 | * @internal | ||
14114 | */ | ||
14115 | var ReactMultiChild = { | ||
14116 | |||
14117 | /** | ||
14118 | * Provides common functionality for components that must reconcile multiple | ||
14119 | * children. This is used by `ReactDOMComponent` to mount, update, and | ||
14120 | * unmount child components. | ||
14121 | * | ||
14122 | * @lends {ReactMultiChild.prototype} | ||
14123 | */ | ||
14124 | Mixin: { | ||
14125 | |||
14126 | _reconcilerInstantiateChildren: function (nestedChildren, transaction, context) { | ||
14127 | if (process.env.NODE_ENV !== 'production') { | ||
14128 | if (this._currentElement) { | ||
14129 | try { | ||
14130 | ReactCurrentOwner.current = this._currentElement._owner; | ||
14131 | return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context); | ||
14132 | } finally { | ||
14133 | ReactCurrentOwner.current = null; | ||
14134 | } | ||
14135 | } | ||
14136 | } | ||
14137 | return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context); | ||
14138 | }, | ||
14139 | |||
14140 | _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, transaction, context) { | ||
14141 | var nextChildren; | ||
14142 | if (process.env.NODE_ENV !== 'production') { | ||
14143 | if (this._currentElement) { | ||
14144 | try { | ||
14145 | ReactCurrentOwner.current = this._currentElement._owner; | ||
14146 | nextChildren = flattenChildren(nextNestedChildrenElements); | ||
14147 | } finally { | ||
14148 | ReactCurrentOwner.current = null; | ||
14149 | } | ||
14150 | return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context); | ||
14151 | } | ||
14152 | } | ||
14153 | nextChildren = flattenChildren(nextNestedChildrenElements); | ||
14154 | return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context); | ||
14155 | }, | ||
14156 | |||
14157 | /** | ||
14158 | * Generates a "mount image" for each of the supplied children. In the case | ||
14159 | * of `ReactDOMComponent`, a mount image is a string of markup. | ||
14160 | * | ||
14161 | * @param {?object} nestedChildren Nested child maps. | ||
14162 | * @return {array} An array of mounted representations. | ||
14163 | * @internal | ||
14164 | */ | ||
14165 | mountChildren: function (nestedChildren, transaction, context) { | ||
14166 | var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context); | ||
14167 | this._renderedChildren = children; | ||
14168 | var mountImages = []; | ||
14169 | var index = 0; | ||
14170 | for (var name in children) { | ||
14171 | if (children.hasOwnProperty(name)) { | ||
14172 | var child = children[name]; | ||
14173 | // Inlined for performance, see `ReactInstanceHandles.createReactID`. | ||
14174 | var rootID = this._rootNodeID + name; | ||
14175 | var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context); | ||
14176 | child._mountIndex = index++; | ||
14177 | mountImages.push(mountImage); | ||
14178 | } | ||
14179 | } | ||
14180 | return mountImages; | ||
14181 | }, | ||
14182 | |||
14183 | /** | ||
14184 | * Replaces any rendered children with a text content string. | ||
14185 | * | ||
14186 | * @param {string} nextContent String of content. | ||
14187 | * @internal | ||
14188 | */ | ||
14189 | updateTextContent: function (nextContent) { | ||
14190 | updateDepth++; | ||
14191 | var errorThrown = true; | ||
14192 | try { | ||
14193 | var prevChildren = this._renderedChildren; | ||
14194 | // Remove any rendered children. | ||
14195 | ReactChildReconciler.unmountChildren(prevChildren); | ||
14196 | // TODO: The setTextContent operation should be enough | ||
14197 | for (var name in prevChildren) { | ||
14198 | if (prevChildren.hasOwnProperty(name)) { | ||
14199 | this._unmountChild(prevChildren[name]); | ||
14200 | } | ||
14201 | } | ||
14202 | // Set new text content. | ||
14203 | this.setTextContent(nextContent); | ||
14204 | errorThrown = false; | ||
14205 | } finally { | ||
14206 | updateDepth--; | ||
14207 | if (!updateDepth) { | ||
14208 | if (errorThrown) { | ||
14209 | clearQueue(); | ||
14210 | } else { | ||
14211 | processQueue(); | ||
14212 | } | ||
14213 | } | ||
14214 | } | ||
14215 | }, | ||
14216 | |||
14217 | /** | ||
14218 | * Replaces any rendered children with a markup string. | ||
14219 | * | ||
14220 | * @param {string} nextMarkup String of markup. | ||
14221 | * @internal | ||
14222 | */ | ||
14223 | updateMarkup: function (nextMarkup) { | ||
14224 | updateDepth++; | ||
14225 | var errorThrown = true; | ||
14226 | try { | ||
14227 | var prevChildren = this._renderedChildren; | ||
14228 | // Remove any rendered children. | ||
14229 | ReactChildReconciler.unmountChildren(prevChildren); | ||
14230 | for (var name in prevChildren) { | ||
14231 | if (prevChildren.hasOwnProperty(name)) { | ||
14232 | this._unmountChildByName(prevChildren[name], name); | ||
14233 | } | ||
14234 | } | ||
14235 | this.setMarkup(nextMarkup); | ||
14236 | errorThrown = false; | ||
14237 | } finally { | ||
14238 | updateDepth--; | ||
14239 | if (!updateDepth) { | ||
14240 | if (errorThrown) { | ||
14241 | clearQueue(); | ||
14242 | } else { | ||
14243 | processQueue(); | ||
14244 | } | ||
14245 | } | ||
14246 | } | ||
14247 | }, | ||
14248 | |||
14249 | /** | ||
14250 | * Updates the rendered children with new children. | ||
14251 | * | ||
14252 | * @param {?object} nextNestedChildrenElements Nested child element maps. | ||
14253 | * @param {ReactReconcileTransaction} transaction | ||
14254 | * @internal | ||
14255 | */ | ||
14256 | updateChildren: function (nextNestedChildrenElements, transaction, context) { | ||
14257 | updateDepth++; | ||
14258 | var errorThrown = true; | ||
14259 | try { | ||
14260 | this._updateChildren(nextNestedChildrenElements, transaction, context); | ||
14261 | errorThrown = false; | ||
14262 | } finally { | ||
14263 | updateDepth--; | ||
14264 | if (!updateDepth) { | ||
14265 | if (errorThrown) { | ||
14266 | clearQueue(); | ||
14267 | } else { | ||
14268 | processQueue(); | ||
14269 | } | ||
14270 | } | ||
14271 | } | ||
14272 | }, | ||
14273 | |||
14274 | /** | ||
14275 | * Improve performance by isolating this hot code path from the try/catch | ||
14276 | * block in `updateChildren`. | ||
14277 | * | ||
14278 | * @param {?object} nextNestedChildrenElements Nested child element maps. | ||
14279 | * @param {ReactReconcileTransaction} transaction | ||
14280 | * @final | ||
14281 | * @protected | ||
14282 | */ | ||
14283 | _updateChildren: function (nextNestedChildrenElements, transaction, context) { | ||
14284 | var prevChildren = this._renderedChildren; | ||
14285 | var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, transaction, context); | ||
14286 | this._renderedChildren = nextChildren; | ||
14287 | if (!nextChildren && !prevChildren) { | ||
14288 | return; | ||
14289 | } | ||
14290 | var name; | ||
14291 | // `nextIndex` will increment for each child in `nextChildren`, but | ||
14292 | // `lastIndex` will be the last index visited in `prevChildren`. | ||
14293 | var lastIndex = 0; | ||
14294 | var nextIndex = 0; | ||
14295 | for (name in nextChildren) { | ||
14296 | if (!nextChildren.hasOwnProperty(name)) { | ||
14297 | continue; | ||
14298 | } | ||
14299 | var prevChild = prevChildren && prevChildren[name]; | ||
14300 | var nextChild = nextChildren[name]; | ||
14301 | if (prevChild === nextChild) { | ||
14302 | this.moveChild(prevChild, nextIndex, lastIndex); | ||
14303 | lastIndex = Math.max(prevChild._mountIndex, lastIndex); | ||
14304 | prevChild._mountIndex = nextIndex; | ||
14305 | } else { | ||
14306 | if (prevChild) { | ||
14307 | // Update `lastIndex` before `_mountIndex` gets unset by unmounting. | ||
14308 | lastIndex = Math.max(prevChild._mountIndex, lastIndex); | ||
14309 | this._unmountChild(prevChild); | ||
14310 | } | ||
14311 | // The child must be instantiated before it's mounted. | ||
14312 | this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context); | ||
14313 | } | ||
14314 | nextIndex++; | ||
14315 | } | ||
14316 | // Remove children that are no longer present. | ||
14317 | for (name in prevChildren) { | ||
14318 | if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) { | ||
14319 | this._unmountChild(prevChildren[name]); | ||
14320 | } | ||
14321 | } | ||
14322 | }, | ||
14323 | |||
14324 | /** | ||
14325 | * Unmounts all rendered children. This should be used to clean up children | ||
14326 | * when this component is unmounted. | ||
14327 | * | ||
14328 | * @internal | ||
14329 | */ | ||
14330 | unmountChildren: function () { | ||
14331 | var renderedChildren = this._renderedChildren; | ||
14332 | ReactChildReconciler.unmountChildren(renderedChildren); | ||
14333 | this._renderedChildren = null; | ||
14334 | }, | ||
14335 | |||
14336 | /** | ||
14337 | * Moves a child component to the supplied index. | ||
14338 | * | ||
14339 | * @param {ReactComponent} child Component to move. | ||
14340 | * @param {number} toIndex Destination index of the element. | ||
14341 | * @param {number} lastIndex Last index visited of the siblings of `child`. | ||
14342 | * @protected | ||
14343 | */ | ||
14344 | moveChild: function (child, toIndex, lastIndex) { | ||
14345 | // If the index of `child` is less than `lastIndex`, then it needs to | ||
14346 | // be moved. Otherwise, we do not need to move it because a child will be | ||
14347 | // inserted or moved before `child`. | ||
14348 | if (child._mountIndex < lastIndex) { | ||
14349 | enqueueMove(this._rootNodeID, child._mountIndex, toIndex); | ||
14350 | } | ||
14351 | }, | ||
14352 | |||
14353 | /** | ||
14354 | * Creates a child component. | ||
14355 | * | ||
14356 | * @param {ReactComponent} child Component to create. | ||
14357 | * @param {string} mountImage Markup to insert. | ||
14358 | * @protected | ||
14359 | */ | ||
14360 | createChild: function (child, mountImage) { | ||
14361 | enqueueInsertMarkup(this._rootNodeID, mountImage, child._mountIndex); | ||
14362 | }, | ||
14363 | |||
14364 | /** | ||
14365 | * Removes a child component. | ||
14366 | * | ||
14367 | * @param {ReactComponent} child Child to remove. | ||
14368 | * @protected | ||
14369 | */ | ||
14370 | removeChild: function (child) { | ||
14371 | enqueueRemove(this._rootNodeID, child._mountIndex); | ||
14372 | }, | ||
14373 | |||
14374 | /** | ||
14375 | * Sets this text content string. | ||
14376 | * | ||
14377 | * @param {string} textContent Text content to set. | ||
14378 | * @protected | ||
14379 | */ | ||
14380 | setTextContent: function (textContent) { | ||
14381 | enqueueTextContent(this._rootNodeID, textContent); | ||
14382 | }, | ||
14383 | |||
14384 | /** | ||
14385 | * Sets this markup string. | ||
14386 | * | ||
14387 | * @param {string} markup Markup to set. | ||
14388 | * @protected | ||
14389 | */ | ||
14390 | setMarkup: function (markup) { | ||
14391 | enqueueSetMarkup(this._rootNodeID, markup); | ||
14392 | }, | ||
14393 | |||
14394 | /** | ||
14395 | * Mounts a child with the supplied name. | ||
14396 | * | ||
14397 | * NOTE: This is part of `updateChildren` and is here for readability. | ||
14398 | * | ||
14399 | * @param {ReactComponent} child Component to mount. | ||
14400 | * @param {string} name Name of the child. | ||
14401 | * @param {number} index Index at which to insert the child. | ||
14402 | * @param {ReactReconcileTransaction} transaction | ||
14403 | * @private | ||
14404 | */ | ||
14405 | _mountChildByNameAtIndex: function (child, name, index, transaction, context) { | ||
14406 | // Inlined for performance, see `ReactInstanceHandles.createReactID`. | ||
14407 | var rootID = this._rootNodeID + name; | ||
14408 | var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context); | ||
14409 | child._mountIndex = index; | ||
14410 | this.createChild(child, mountImage); | ||
14411 | }, | ||
14412 | |||
14413 | /** | ||
14414 | * Unmounts a rendered child. | ||
14415 | * | ||
14416 | * NOTE: This is part of `updateChildren` and is here for readability. | ||
14417 | * | ||
14418 | * @param {ReactComponent} child Component to unmount. | ||
14419 | * @private | ||
14420 | */ | ||
14421 | _unmountChild: function (child) { | ||
14422 | this.removeChild(child); | ||
14423 | child._mountIndex = null; | ||
14424 | } | ||
14425 | |||
14426 | } | ||
14427 | |||
14428 | }; | ||
14429 | |||
14430 | module.exports = ReactMultiChild; | ||
14431 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
14432 | |||
14433 | /***/ }, | ||
14434 | /* 117 */ | ||
14435 | /***/ function(module, exports, __webpack_require__) { | ||
14436 | |||
14437 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
14438 | * Copyright 2014-2015, Facebook, Inc. | ||
14439 | * All rights reserved. | ||
14440 | * | ||
14441 | * This source code is licensed under the BSD-style license found in the | ||
14442 | * LICENSE file in the root directory of this source tree. An additional grant | ||
14443 | * of patent rights can be found in the PATENTS file in the same directory. | ||
14444 | * | ||
14445 | * @providesModule ReactChildReconciler | ||
14446 | * @typechecks static-only | ||
14447 | */ | ||
14448 | |||
14449 | 'use strict'; | ||
14450 | |||
14451 | var ReactReconciler = __webpack_require__(52); | ||
14452 | |||
14453 | var instantiateReactComponent = __webpack_require__(64); | ||
14454 | var shouldUpdateReactComponent = __webpack_require__(69); | ||
14455 | var traverseAllChildren = __webpack_require__(113); | ||
14456 | var warning = __webpack_require__(27); | ||
14457 | |||
14458 | function instantiateChild(childInstances, child, name) { | ||
14459 | // We found a component instance. | ||
14460 | var keyUnique = childInstances[name] === undefined; | ||
14461 | if (process.env.NODE_ENV !== 'production') { | ||
14462 | process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined; | ||
14463 | } | ||
14464 | if (child != null && keyUnique) { | ||
14465 | childInstances[name] = instantiateReactComponent(child, null); | ||
14466 | } | ||
14467 | } | ||
14468 | |||
14469 | /** | ||
14470 | * ReactChildReconciler provides helpers for initializing or updating a set of | ||
14471 | * children. Its output is suitable for passing it onto ReactMultiChild which | ||
14472 | * does diffed reordering and insertion. | ||
14473 | */ | ||
14474 | var ReactChildReconciler = { | ||
14475 | /** | ||
14476 | * Generates a "mount image" for each of the supplied children. In the case | ||
14477 | * of `ReactDOMComponent`, a mount image is a string of markup. | ||
14478 | * | ||
14479 | * @param {?object} nestedChildNodes Nested child maps. | ||
14480 | * @return {?object} A set of child instances. | ||
14481 | * @internal | ||
14482 | */ | ||
14483 | instantiateChildren: function (nestedChildNodes, transaction, context) { | ||
14484 | if (nestedChildNodes == null) { | ||
14485 | return null; | ||
14486 | } | ||
14487 | var childInstances = {}; | ||
14488 | traverseAllChildren(nestedChildNodes, instantiateChild, childInstances); | ||
14489 | return childInstances; | ||
14490 | }, | ||
14491 | |||
14492 | /** | ||
14493 | * Updates the rendered children and returns a new set of children. | ||
14494 | * | ||
14495 | * @param {?object} prevChildren Previously initialized set of children. | ||
14496 | * @param {?object} nextChildren Flat child element maps. | ||
14497 | * @param {ReactReconcileTransaction} transaction | ||
14498 | * @param {object} context | ||
14499 | * @return {?object} A new set of child instances. | ||
14500 | * @internal | ||
14501 | */ | ||
14502 | updateChildren: function (prevChildren, nextChildren, transaction, context) { | ||
14503 | // We currently don't have a way to track moves here but if we use iterators | ||
14504 | // instead of for..in we can zip the iterators and check if an item has | ||
14505 | // moved. | ||
14506 | // TODO: If nothing has changed, return the prevChildren object so that we | ||
14507 | // can quickly bailout if nothing has changed. | ||
14508 | if (!nextChildren && !prevChildren) { | ||
14509 | return null; | ||
14510 | } | ||
14511 | var name; | ||
14512 | for (name in nextChildren) { | ||
14513 | if (!nextChildren.hasOwnProperty(name)) { | ||
14514 | continue; | ||
14515 | } | ||
14516 | var prevChild = prevChildren && prevChildren[name]; | ||
14517 | var prevElement = prevChild && prevChild._currentElement; | ||
14518 | var nextElement = nextChildren[name]; | ||
14519 | if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) { | ||
14520 | ReactReconciler.receiveComponent(prevChild, nextElement, transaction, context); | ||
14521 | nextChildren[name] = prevChild; | ||
14522 | } else { | ||
14523 | if (prevChild) { | ||
14524 | ReactReconciler.unmountComponent(prevChild, name); | ||
14525 | } | ||
14526 | // The child must be instantiated before it's mounted. | ||
14527 | var nextChildInstance = instantiateReactComponent(nextElement, null); | ||
14528 | nextChildren[name] = nextChildInstance; | ||
14529 | } | ||
14530 | } | ||
14531 | // Unmount children that are no longer present. | ||
14532 | for (name in prevChildren) { | ||
14533 | if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) { | ||
14534 | ReactReconciler.unmountComponent(prevChildren[name]); | ||
14535 | } | ||
14536 | } | ||
14537 | return nextChildren; | ||
14538 | }, | ||
14539 | |||
14540 | /** | ||
14541 | * Unmounts all rendered children. This should be used to clean up children | ||
14542 | * when this component is unmounted. | ||
14543 | * | ||
14544 | * @param {?object} renderedChildren Previously initialized set of children. | ||
14545 | * @internal | ||
14546 | */ | ||
14547 | unmountChildren: function (renderedChildren) { | ||
14548 | for (var name in renderedChildren) { | ||
14549 | if (renderedChildren.hasOwnProperty(name)) { | ||
14550 | var renderedChild = renderedChildren[name]; | ||
14551 | ReactReconciler.unmountComponent(renderedChild); | ||
14552 | } | ||
14553 | } | ||
14554 | } | ||
14555 | |||
14556 | }; | ||
14557 | |||
14558 | module.exports = ReactChildReconciler; | ||
14559 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
14560 | |||
14561 | /***/ }, | ||
14562 | /* 118 */ | ||
14563 | /***/ function(module, exports, __webpack_require__) { | ||
14564 | |||
14565 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
14566 | * Copyright 2013-2015, Facebook, Inc. | ||
14567 | * All rights reserved. | ||
14568 | * | ||
14569 | * This source code is licensed under the BSD-style license found in the | ||
14570 | * LICENSE file in the root directory of this source tree. An additional grant | ||
14571 | * of patent rights can be found in the PATENTS file in the same directory. | ||
14572 | * | ||
14573 | * @providesModule flattenChildren | ||
14574 | */ | ||
14575 | |||
14576 | 'use strict'; | ||
14577 | |||
14578 | var traverseAllChildren = __webpack_require__(113); | ||
14579 | var warning = __webpack_require__(27); | ||
14580 | |||
14581 | /** | ||
14582 | * @param {function} traverseContext Context passed through traversal. | ||
14583 | * @param {?ReactComponent} child React child component. | ||
14584 | * @param {!string} name String name of key path to child. | ||
14585 | */ | ||
14586 | function flattenSingleChildIntoContext(traverseContext, child, name) { | ||
14587 | // We found a component instance. | ||
14588 | var result = traverseContext; | ||
14589 | var keyUnique = result[name] === undefined; | ||
14590 | if (process.env.NODE_ENV !== 'production') { | ||
14591 | process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined; | ||
14592 | } | ||
14593 | if (keyUnique && child != null) { | ||
14594 | result[name] = child; | ||
14595 | } | ||
14596 | } | ||
14597 | |||
14598 | /** | ||
14599 | * Flattens children that are typically specified as `props.children`. Any null | ||
14600 | * children will not be included in the resulting object. | ||
14601 | * @return {!object} flattened children keyed by name. | ||
14602 | */ | ||
14603 | function flattenChildren(children) { | ||
14604 | if (children == null) { | ||
14605 | return children; | ||
14606 | } | ||
14607 | var result = {}; | ||
14608 | traverseAllChildren(children, flattenSingleChildIntoContext, result); | ||
14609 | return result; | ||
14610 | } | ||
14611 | |||
14612 | module.exports = flattenChildren; | ||
14613 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
14614 | |||
14615 | /***/ }, | ||
14616 | /* 119 */ | ||
14617 | /***/ function(module, exports) { | ||
14618 | |||
14619 | /** | ||
14620 | * Copyright 2013-2015, Facebook, Inc. | ||
14621 | * All rights reserved. | ||
14622 | * | ||
14623 | * This source code is licensed under the BSD-style license found in the | ||
14624 | * LICENSE file in the root directory of this source tree. An additional grant | ||
14625 | * of patent rights can be found in the PATENTS file in the same directory. | ||
14626 | * | ||
14627 | * @providesModule shallowEqual | ||
14628 | * @typechecks | ||
14629 | * | ||
14630 | */ | ||
14631 | |||
14632 | 'use strict'; | ||
14633 | |||
14634 | var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
14635 | |||
14636 | /** | ||
14637 | * Performs equality by iterating through keys on an object and returning false | ||
14638 | * when any key has values which are not strictly equal between the arguments. | ||
14639 | * Returns true when the values of all keys are strictly equal. | ||
14640 | */ | ||
14641 | function shallowEqual(objA, objB) { | ||
14642 | if (objA === objB) { | ||
14643 | return true; | ||
14644 | } | ||
14645 | |||
14646 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | ||
14647 | return false; | ||
14648 | } | ||
14649 | |||
14650 | var keysA = Object.keys(objA); | ||
14651 | var keysB = Object.keys(objB); | ||
14652 | |||
14653 | if (keysA.length !== keysB.length) { | ||
14654 | return false; | ||
14655 | } | ||
14656 | |||
14657 | // Test for A's keys different from B. | ||
14658 | var bHasOwnProperty = hasOwnProperty.bind(objB); | ||
14659 | for (var i = 0; i < keysA.length; i++) { | ||
14660 | if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { | ||
14661 | return false; | ||
14662 | } | ||
14663 | } | ||
14664 | |||
14665 | return true; | ||
14666 | } | ||
14667 | |||
14668 | module.exports = shallowEqual; | ||
14669 | |||
14670 | /***/ }, | ||
14671 | /* 120 */ | ||
14672 | /***/ function(module, exports, __webpack_require__) { | ||
14673 | |||
14674 | /** | ||
14675 | * Copyright 2013-2015, Facebook, Inc. | ||
14676 | * All rights reserved. | ||
14677 | * | ||
14678 | * This source code is licensed under the BSD-style license found in the | ||
14679 | * LICENSE file in the root directory of this source tree. An additional grant | ||
14680 | * of patent rights can be found in the PATENTS file in the same directory. | ||
14681 | * | ||
14682 | * @providesModule ReactEventListener | ||
14683 | * @typechecks static-only | ||
14684 | */ | ||
14685 | |||
14686 | 'use strict'; | ||
14687 | |||
14688 | var EventListener = __webpack_require__(121); | ||
14689 | var ExecutionEnvironment = __webpack_require__(11); | ||
14690 | var PooledClass = __webpack_require__(58); | ||
14691 | var ReactInstanceHandles = __webpack_require__(47); | ||
14692 | var ReactMount = __webpack_require__(30); | ||
14693 | var ReactUpdates = __webpack_require__(56); | ||
14694 | |||
14695 | var assign = __webpack_require__(41); | ||
14696 | var getEventTarget = __webpack_require__(83); | ||
14697 | var getUnboundedScrollPosition = __webpack_require__(122); | ||
14698 | |||
14699 | var DOCUMENT_FRAGMENT_NODE_TYPE = 11; | ||
14700 | |||
14701 | /** | ||
14702 | * Finds the parent React component of `node`. | ||
14703 | * | ||
14704 | * @param {*} node | ||
14705 | * @return {?DOMEventTarget} Parent container, or `null` if the specified node | ||
14706 | * is not nested. | ||
14707 | */ | ||
14708 | function findParent(node) { | ||
14709 | // TODO: It may be a good idea to cache this to prevent unnecessary DOM | ||
14710 | // traversal, but caching is difficult to do correctly without using a | ||
14711 | // mutation observer to listen for all DOM changes. | ||
14712 | var nodeID = ReactMount.getID(node); | ||
14713 | var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID); | ||
14714 | var container = ReactMount.findReactContainerForID(rootID); | ||
14715 | var parent = ReactMount.getFirstReactDOM(container); | ||
14716 | return parent; | ||
14717 | } | ||
14718 | |||
14719 | // Used to store ancestor hierarchy in top level callback | ||
14720 | function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) { | ||
14721 | this.topLevelType = topLevelType; | ||
14722 | this.nativeEvent = nativeEvent; | ||
14723 | this.ancestors = []; | ||
14724 | } | ||
14725 | assign(TopLevelCallbackBookKeeping.prototype, { | ||
14726 | destructor: function () { | ||
14727 | this.topLevelType = null; | ||
14728 | this.nativeEvent = null; | ||
14729 | this.ancestors.length = 0; | ||
14730 | } | ||
14731 | }); | ||
14732 | PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler); | ||
14733 | |||
14734 | function handleTopLevelImpl(bookKeeping) { | ||
14735 | // TODO: Re-enable event.path handling | ||
14736 | // | ||
14737 | // if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) { | ||
14738 | // // New browsers have a path attribute on native events | ||
14739 | // handleTopLevelWithPath(bookKeeping); | ||
14740 | // } else { | ||
14741 | // // Legacy browsers don't have a path attribute on native events | ||
14742 | // handleTopLevelWithoutPath(bookKeeping); | ||
14743 | // } | ||
14744 | |||
14745 | void handleTopLevelWithPath; // temporarily unused | ||
14746 | handleTopLevelWithoutPath(bookKeeping); | ||
14747 | } | ||
14748 | |||
14749 | // Legacy browsers don't have a path attribute on native events | ||
14750 | function handleTopLevelWithoutPath(bookKeeping) { | ||
14751 | var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window; | ||
14752 | |||
14753 | // Loop through the hierarchy, in case there's any nested components. | ||
14754 | // It's important that we build the array of ancestors before calling any | ||
14755 | // event handlers, because event handlers can modify the DOM, leading to | ||
14756 | // inconsistencies with ReactMount's node cache. See #1105. | ||
14757 | var ancestor = topLevelTarget; | ||
14758 | while (ancestor) { | ||
14759 | bookKeeping.ancestors.push(ancestor); | ||
14760 | ancestor = findParent(ancestor); | ||
14761 | } | ||
14762 | |||
14763 | for (var i = 0; i < bookKeeping.ancestors.length; i++) { | ||
14764 | topLevelTarget = bookKeeping.ancestors[i]; | ||
14765 | var topLevelTargetID = ReactMount.getID(topLevelTarget) || ''; | ||
14766 | ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent)); | ||
14767 | } | ||
14768 | } | ||
14769 | |||
14770 | // New browsers have a path attribute on native events | ||
14771 | function handleTopLevelWithPath(bookKeeping) { | ||
14772 | var path = bookKeeping.nativeEvent.path; | ||
14773 | var currentNativeTarget = path[0]; | ||
14774 | var eventsFired = 0; | ||
14775 | for (var i = 0; i < path.length; i++) { | ||
14776 | var currentPathElement = path[i]; | ||
14777 | if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) { | ||
14778 | currentNativeTarget = path[i + 1]; | ||
14779 | } | ||
14780 | // TODO: slow | ||
14781 | var reactParent = ReactMount.getFirstReactDOM(currentPathElement); | ||
14782 | if (reactParent === currentPathElement) { | ||
14783 | var currentPathElementID = ReactMount.getID(currentPathElement); | ||
14784 | var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID); | ||
14785 | bookKeeping.ancestors.push(currentPathElement); | ||
14786 | |||
14787 | var topLevelTargetID = ReactMount.getID(currentPathElement) || ''; | ||
14788 | eventsFired++; | ||
14789 | ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget); | ||
14790 | |||
14791 | // Jump to the root of this React render tree | ||
14792 | while (currentPathElementID !== newRootID) { | ||
14793 | i++; | ||
14794 | currentPathElement = path[i]; | ||
14795 | currentPathElementID = ReactMount.getID(currentPathElement); | ||
14796 | } | ||
14797 | } | ||
14798 | } | ||
14799 | if (eventsFired === 0) { | ||
14800 | ReactEventListener._handleTopLevel(bookKeeping.topLevelType, window, '', bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent)); | ||
14801 | } | ||
14802 | } | ||
14803 | |||
14804 | function scrollValueMonitor(cb) { | ||
14805 | var scrollPosition = getUnboundedScrollPosition(window); | ||
14806 | cb(scrollPosition); | ||
14807 | } | ||
14808 | |||
14809 | var ReactEventListener = { | ||
14810 | _enabled: true, | ||
14811 | _handleTopLevel: null, | ||
14812 | |||
14813 | WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null, | ||
14814 | |||
14815 | setHandleTopLevel: function (handleTopLevel) { | ||
14816 | ReactEventListener._handleTopLevel = handleTopLevel; | ||
14817 | }, | ||
14818 | |||
14819 | setEnabled: function (enabled) { | ||
14820 | ReactEventListener._enabled = !!enabled; | ||
14821 | }, | ||
14822 | |||
14823 | isEnabled: function () { | ||
14824 | return ReactEventListener._enabled; | ||
14825 | }, | ||
14826 | |||
14827 | /** | ||
14828 | * Traps top-level events by using event bubbling. | ||
14829 | * | ||
14830 | * @param {string} topLevelType Record from `EventConstants`. | ||
14831 | * @param {string} handlerBaseName Event name (e.g. "click"). | ||
14832 | * @param {object} handle Element on which to attach listener. | ||
14833 | * @return {?object} An object with a remove function which will forcefully | ||
14834 | * remove the listener. | ||
14835 | * @internal | ||
14836 | */ | ||
14837 | trapBubbledEvent: function (topLevelType, handlerBaseName, handle) { | ||
14838 | var element = handle; | ||
14839 | if (!element) { | ||
14840 | return null; | ||
14841 | } | ||
14842 | return EventListener.listen(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType)); | ||
14843 | }, | ||
14844 | |||
14845 | /** | ||
14846 | * Traps a top-level event by using event capturing. | ||
14847 | * | ||
14848 | * @param {string} topLevelType Record from `EventConstants`. | ||
14849 | * @param {string} handlerBaseName Event name (e.g. "click"). | ||
14850 | * @param {object} handle Element on which to attach listener. | ||
14851 | * @return {?object} An object with a remove function which will forcefully | ||
14852 | * remove the listener. | ||
14853 | * @internal | ||
14854 | */ | ||
14855 | trapCapturedEvent: function (topLevelType, handlerBaseName, handle) { | ||
14856 | var element = handle; | ||
14857 | if (!element) { | ||
14858 | return null; | ||
14859 | } | ||
14860 | return EventListener.capture(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType)); | ||
14861 | }, | ||
14862 | |||
14863 | monitorScrollValue: function (refresh) { | ||
14864 | var callback = scrollValueMonitor.bind(null, refresh); | ||
14865 | EventListener.listen(window, 'scroll', callback); | ||
14866 | }, | ||
14867 | |||
14868 | dispatchEvent: function (topLevelType, nativeEvent) { | ||
14869 | if (!ReactEventListener._enabled) { | ||
14870 | return; | ||
14871 | } | ||
14872 | |||
14873 | var bookKeeping = TopLevelCallbackBookKeeping.getPooled(topLevelType, nativeEvent); | ||
14874 | try { | ||
14875 | // Event queue being processed in the same cycle allows | ||
14876 | // `preventDefault`. | ||
14877 | ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping); | ||
14878 | } finally { | ||
14879 | TopLevelCallbackBookKeeping.release(bookKeeping); | ||
14880 | } | ||
14881 | } | ||
14882 | }; | ||
14883 | |||
14884 | module.exports = ReactEventListener; | ||
14885 | |||
14886 | /***/ }, | ||
14887 | /* 121 */ | ||
14888 | /***/ function(module, exports, __webpack_require__) { | ||
14889 | |||
14890 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
14891 | * Copyright 2013-2015, Facebook, Inc. | ||
14892 | * | ||
14893 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
14894 | * you may not use this file except in compliance with the License. | ||
14895 | * You may obtain a copy of the License at | ||
14896 | * | ||
14897 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
14898 | * | ||
14899 | * Unless required by applicable law or agreed to in writing, software | ||
14900 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
14901 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14902 | * See the License for the specific language governing permissions and | ||
14903 | * limitations under the License. | ||
14904 | * | ||
14905 | * @providesModule EventListener | ||
14906 | * @typechecks | ||
14907 | */ | ||
14908 | |||
14909 | 'use strict'; | ||
14910 | |||
14911 | var emptyFunction = __webpack_require__(17); | ||
14912 | |||
14913 | /** | ||
14914 | * Upstream version of event listener. Does not take into account specific | ||
14915 | * nature of platform. | ||
14916 | */ | ||
14917 | var EventListener = { | ||
14918 | /** | ||
14919 | * Listen to DOM events during the bubble phase. | ||
14920 | * | ||
14921 | * @param {DOMEventTarget} target DOM element to register listener on. | ||
14922 | * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. | ||
14923 | * @param {function} callback Callback function. | ||
14924 | * @return {object} Object with a `remove` method. | ||
14925 | */ | ||
14926 | listen: function (target, eventType, callback) { | ||
14927 | if (target.addEventListener) { | ||
14928 | target.addEventListener(eventType, callback, false); | ||
14929 | return { | ||
14930 | remove: function () { | ||
14931 | target.removeEventListener(eventType, callback, false); | ||
14932 | } | ||
14933 | }; | ||
14934 | } else if (target.attachEvent) { | ||
14935 | target.attachEvent('on' + eventType, callback); | ||
14936 | return { | ||
14937 | remove: function () { | ||
14938 | target.detachEvent('on' + eventType, callback); | ||
14939 | } | ||
14940 | }; | ||
14941 | } | ||
14942 | }, | ||
14943 | |||
14944 | /** | ||
14945 | * Listen to DOM events during the capture phase. | ||
14946 | * | ||
14947 | * @param {DOMEventTarget} target DOM element to register listener on. | ||
14948 | * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. | ||
14949 | * @param {function} callback Callback function. | ||
14950 | * @return {object} Object with a `remove` method. | ||
14951 | */ | ||
14952 | capture: function (target, eventType, callback) { | ||
14953 | if (target.addEventListener) { | ||
14954 | target.addEventListener(eventType, callback, true); | ||
14955 | return { | ||
14956 | remove: function () { | ||
14957 | target.removeEventListener(eventType, callback, true); | ||
14958 | } | ||
14959 | }; | ||
14960 | } else { | ||
14961 | if (process.env.NODE_ENV !== 'production') { | ||
14962 | console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.'); | ||
14963 | } | ||
14964 | return { | ||
14965 | remove: emptyFunction | ||
14966 | }; | ||
14967 | } | ||
14968 | }, | ||
14969 | |||
14970 | registerDefault: function () {} | ||
14971 | }; | ||
14972 | |||
14973 | module.exports = EventListener; | ||
14974 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
14975 | |||
14976 | /***/ }, | ||
14977 | /* 122 */ | ||
14978 | /***/ function(module, exports) { | ||
14979 | |||
14980 | /** | ||
14981 | * Copyright 2013-2015, Facebook, Inc. | ||
14982 | * All rights reserved. | ||
14983 | * | ||
14984 | * This source code is licensed under the BSD-style license found in the | ||
14985 | * LICENSE file in the root directory of this source tree. An additional grant | ||
14986 | * of patent rights can be found in the PATENTS file in the same directory. | ||
14987 | * | ||
14988 | * @providesModule getUnboundedScrollPosition | ||
14989 | * @typechecks | ||
14990 | */ | ||
14991 | |||
14992 | 'use strict'; | ||
14993 | |||
14994 | /** | ||
14995 | * Gets the scroll position of the supplied element or window. | ||
14996 | * | ||
14997 | * The return values are unbounded, unlike `getScrollPosition`. This means they | ||
14998 | * may be negative or exceed the element boundaries (which is possible using | ||
14999 | * inertial scrolling). | ||
15000 | * | ||
15001 | * @param {DOMWindow|DOMElement} scrollable | ||
15002 | * @return {object} Map with `x` and `y` keys. | ||
15003 | */ | ||
15004 | function getUnboundedScrollPosition(scrollable) { | ||
15005 | if (scrollable === window) { | ||
15006 | return { | ||
15007 | x: window.pageXOffset || document.documentElement.scrollLeft, | ||
15008 | y: window.pageYOffset || document.documentElement.scrollTop | ||
15009 | }; | ||
15010 | } | ||
15011 | return { | ||
15012 | x: scrollable.scrollLeft, | ||
15013 | y: scrollable.scrollTop | ||
15014 | }; | ||
15015 | } | ||
15016 | |||
15017 | module.exports = getUnboundedScrollPosition; | ||
15018 | |||
15019 | /***/ }, | ||
15020 | /* 123 */ | ||
15021 | /***/ function(module, exports, __webpack_require__) { | ||
15022 | |||
15023 | /** | ||
15024 | * Copyright 2013-2015, Facebook, Inc. | ||
15025 | * All rights reserved. | ||
15026 | * | ||
15027 | * This source code is licensed under the BSD-style license found in the | ||
15028 | * LICENSE file in the root directory of this source tree. An additional grant | ||
15029 | * of patent rights can be found in the PATENTS file in the same directory. | ||
15030 | * | ||
15031 | * @providesModule ReactInjection | ||
15032 | */ | ||
15033 | |||
15034 | 'use strict'; | ||
15035 | |||
15036 | var DOMProperty = __webpack_require__(25); | ||
15037 | var EventPluginHub = __webpack_require__(33); | ||
15038 | var ReactComponentEnvironment = __webpack_require__(66); | ||
15039 | var ReactClass = __webpack_require__(124); | ||
15040 | var ReactEmptyComponent = __webpack_require__(70); | ||
15041 | var ReactBrowserEventEmitter = __webpack_require__(31); | ||
15042 | var ReactNativeComponent = __webpack_require__(71); | ||
15043 | var ReactPerf = __webpack_require__(20); | ||
15044 | var ReactRootIndex = __webpack_require__(48); | ||
15045 | var ReactUpdates = __webpack_require__(56); | ||
15046 | |||
15047 | var ReactInjection = { | ||
15048 | Component: ReactComponentEnvironment.injection, | ||
15049 | Class: ReactClass.injection, | ||
15050 | DOMProperty: DOMProperty.injection, | ||
15051 | EmptyComponent: ReactEmptyComponent.injection, | ||
15052 | EventPluginHub: EventPluginHub.injection, | ||
15053 | EventEmitter: ReactBrowserEventEmitter.injection, | ||
15054 | NativeComponent: ReactNativeComponent.injection, | ||
15055 | Perf: ReactPerf.injection, | ||
15056 | RootIndex: ReactRootIndex.injection, | ||
15057 | Updates: ReactUpdates.injection | ||
15058 | }; | ||
15059 | |||
15060 | module.exports = ReactInjection; | ||
15061 | |||
15062 | /***/ }, | ||
15063 | /* 124 */ | ||
15064 | /***/ function(module, exports, __webpack_require__) { | ||
15065 | |||
15066 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
15067 | * Copyright 2013-2015, Facebook, Inc. | ||
15068 | * All rights reserved. | ||
15069 | * | ||
15070 | * This source code is licensed under the BSD-style license found in the | ||
15071 | * LICENSE file in the root directory of this source tree. An additional grant | ||
15072 | * of patent rights can be found in the PATENTS file in the same directory. | ||
15073 | * | ||
15074 | * @providesModule ReactClass | ||
15075 | */ | ||
15076 | |||
15077 | 'use strict'; | ||
15078 | |||
15079 | var ReactComponent = __webpack_require__(125); | ||
15080 | var ReactElement = __webpack_require__(44); | ||
15081 | var ReactPropTypeLocations = __webpack_require__(67); | ||
15082 | var ReactPropTypeLocationNames = __webpack_require__(68); | ||
15083 | var ReactNoopUpdateQueue = __webpack_require__(126); | ||
15084 | |||
15085 | var assign = __webpack_require__(41); | ||
15086 | var emptyObject = __webpack_require__(60); | ||
15087 | var invariant = __webpack_require__(15); | ||
15088 | var keyMirror = __webpack_require__(19); | ||
15089 | var keyOf = __webpack_require__(81); | ||
15090 | var warning = __webpack_require__(27); | ||
15091 | |||
15092 | var MIXINS_KEY = keyOf({ mixins: null }); | ||
15093 | |||
15094 | /** | ||
15095 | * Policies that describe methods in `ReactClassInterface`. | ||
15096 | */ | ||
15097 | var SpecPolicy = keyMirror({ | ||
15098 | /** | ||
15099 | * These methods may be defined only once by the class specification or mixin. | ||
15100 | */ | ||
15101 | DEFINE_ONCE: null, | ||
15102 | /** | ||
15103 | * These methods may be defined by both the class specification and mixins. | ||
15104 | * Subsequent definitions will be chained. These methods must return void. | ||
15105 | */ | ||
15106 | DEFINE_MANY: null, | ||
15107 | /** | ||
15108 | * These methods are overriding the base class. | ||
15109 | */ | ||
15110 | OVERRIDE_BASE: null, | ||
15111 | /** | ||
15112 | * These methods are similar to DEFINE_MANY, except we assume they return | ||
15113 | * objects. We try to merge the keys of the return values of all the mixed in | ||
15114 | * functions. If there is a key conflict we throw. | ||
15115 | */ | ||
15116 | DEFINE_MANY_MERGED: null | ||
15117 | }); | ||
15118 | |||
15119 | var injectedMixins = []; | ||
15120 | |||
15121 | var warnedSetProps = false; | ||
15122 | function warnSetProps() { | ||
15123 | if (!warnedSetProps) { | ||
15124 | warnedSetProps = true; | ||
15125 | process.env.NODE_ENV !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call render again at the top level.') : undefined; | ||
15126 | } | ||
15127 | } | ||
15128 | |||
15129 | /** | ||
15130 | * Composite components are higher-level components that compose other composite | ||
15131 | * or native components. | ||
15132 | * | ||
15133 | * To create a new type of `ReactClass`, pass a specification of | ||
15134 | * your new class to `React.createClass`. The only requirement of your class | ||
15135 | * specification is that you implement a `render` method. | ||
15136 | * | ||
15137 | * var MyComponent = React.createClass({ | ||
15138 | * render: function() { | ||
15139 | * return <div>Hello World</div>; | ||
15140 | * } | ||
15141 | * }); | ||
15142 | * | ||
15143 | * The class specification supports a specific protocol of methods that have | ||
15144 | * special meaning (e.g. `render`). See `ReactClassInterface` for | ||
15145 | * more the comprehensive protocol. Any other properties and methods in the | ||
15146 | * class specification will be available on the prototype. | ||
15147 | * | ||
15148 | * @interface ReactClassInterface | ||
15149 | * @internal | ||
15150 | */ | ||
15151 | var ReactClassInterface = { | ||
15152 | |||
15153 | /** | ||
15154 | * An array of Mixin objects to include when defining your component. | ||
15155 | * | ||
15156 | * @type {array} | ||
15157 | * @optional | ||
15158 | */ | ||
15159 | mixins: SpecPolicy.DEFINE_MANY, | ||
15160 | |||
15161 | /** | ||
15162 | * An object containing properties and methods that should be defined on | ||
15163 | * the component's constructor instead of its prototype (static methods). | ||
15164 | * | ||
15165 | * @type {object} | ||
15166 | * @optional | ||
15167 | */ | ||
15168 | statics: SpecPolicy.DEFINE_MANY, | ||
15169 | |||
15170 | /** | ||
15171 | * Definition of prop types for this component. | ||
15172 | * | ||
15173 | * @type {object} | ||
15174 | * @optional | ||
15175 | */ | ||
15176 | propTypes: SpecPolicy.DEFINE_MANY, | ||
15177 | |||
15178 | /** | ||
15179 | * Definition of context types for this component. | ||
15180 | * | ||
15181 | * @type {object} | ||
15182 | * @optional | ||
15183 | */ | ||
15184 | contextTypes: SpecPolicy.DEFINE_MANY, | ||
15185 | |||
15186 | /** | ||
15187 | * Definition of context types this component sets for its children. | ||
15188 | * | ||
15189 | * @type {object} | ||
15190 | * @optional | ||
15191 | */ | ||
15192 | childContextTypes: SpecPolicy.DEFINE_MANY, | ||
15193 | |||
15194 | // ==== Definition methods ==== | ||
15195 | |||
15196 | /** | ||
15197 | * Invoked when the component is mounted. Values in the mapping will be set on | ||
15198 | * `this.props` if that prop is not specified (i.e. using an `in` check). | ||
15199 | * | ||
15200 | * This method is invoked before `getInitialState` and therefore cannot rely | ||
15201 | * on `this.state` or use `this.setState`. | ||
15202 | * | ||
15203 | * @return {object} | ||
15204 | * @optional | ||
15205 | */ | ||
15206 | getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED, | ||
15207 | |||
15208 | /** | ||
15209 | * Invoked once before the component is mounted. The return value will be used | ||
15210 | * as the initial value of `this.state`. | ||
15211 | * | ||
15212 | * getInitialState: function() { | ||
15213 | * return { | ||
15214 | * isOn: false, | ||
15215 | * fooBaz: new BazFoo() | ||
15216 | * } | ||
15217 | * } | ||
15218 | * | ||
15219 | * @return {object} | ||
15220 | * @optional | ||
15221 | */ | ||
15222 | getInitialState: SpecPolicy.DEFINE_MANY_MERGED, | ||
15223 | |||
15224 | /** | ||
15225 | * @return {object} | ||
15226 | * @optional | ||
15227 | */ | ||
15228 | getChildContext: SpecPolicy.DEFINE_MANY_MERGED, | ||
15229 | |||
15230 | /** | ||
15231 | * Uses props from `this.props` and state from `this.state` to render the | ||
15232 | * structure of the component. | ||
15233 | * | ||
15234 | * No guarantees are made about when or how often this method is invoked, so | ||
15235 | * it must not have side effects. | ||
15236 | * | ||
15237 | * render: function() { | ||
15238 | * var name = this.props.name; | ||
15239 | * return <div>Hello, {name}!</div>; | ||
15240 | * } | ||
15241 | * | ||
15242 | * @return {ReactComponent} | ||
15243 | * @nosideeffects | ||
15244 | * @required | ||
15245 | */ | ||
15246 | render: SpecPolicy.DEFINE_ONCE, | ||
15247 | |||
15248 | // ==== Delegate methods ==== | ||
15249 | |||
15250 | /** | ||
15251 | * Invoked when the component is initially created and about to be mounted. | ||
15252 | * This may have side effects, but any external subscriptions or data created | ||
15253 | * by this method must be cleaned up in `componentWillUnmount`. | ||
15254 | * | ||
15255 | * @optional | ||
15256 | */ | ||
15257 | componentWillMount: SpecPolicy.DEFINE_MANY, | ||
15258 | |||
15259 | /** | ||
15260 | * Invoked when the component has been mounted and has a DOM representation. | ||
15261 | * However, there is no guarantee that the DOM node is in the document. | ||
15262 | * | ||
15263 | * Use this as an opportunity to operate on the DOM when the component has | ||
15264 | * been mounted (initialized and rendered) for the first time. | ||
15265 | * | ||
15266 | * @param {DOMElement} rootNode DOM element representing the component. | ||
15267 | * @optional | ||
15268 | */ | ||
15269 | componentDidMount: SpecPolicy.DEFINE_MANY, | ||
15270 | |||
15271 | /** | ||
15272 | * Invoked before the component receives new props. | ||
15273 | * | ||
15274 | * Use this as an opportunity to react to a prop transition by updating the | ||
15275 | * state using `this.setState`. Current props are accessed via `this.props`. | ||
15276 | * | ||
15277 | * componentWillReceiveProps: function(nextProps, nextContext) { | ||
15278 | * this.setState({ | ||
15279 | * likesIncreasing: nextProps.likeCount > this.props.likeCount | ||
15280 | * }); | ||
15281 | * } | ||
15282 | * | ||
15283 | * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop | ||
15284 | * transition may cause a state change, but the opposite is not true. If you | ||
15285 | * need it, you are probably looking for `componentWillUpdate`. | ||
15286 | * | ||
15287 | * @param {object} nextProps | ||
15288 | * @optional | ||
15289 | */ | ||
15290 | componentWillReceiveProps: SpecPolicy.DEFINE_MANY, | ||
15291 | |||
15292 | /** | ||
15293 | * Invoked while deciding if the component should be updated as a result of | ||
15294 | * receiving new props, state and/or context. | ||
15295 | * | ||
15296 | * Use this as an opportunity to `return false` when you're certain that the | ||
15297 | * transition to the new props/state/context will not require a component | ||
15298 | * update. | ||
15299 | * | ||
15300 | * shouldComponentUpdate: function(nextProps, nextState, nextContext) { | ||
15301 | * return !equal(nextProps, this.props) || | ||
15302 | * !equal(nextState, this.state) || | ||
15303 | * !equal(nextContext, this.context); | ||
15304 | * } | ||
15305 | * | ||
15306 | * @param {object} nextProps | ||
15307 | * @param {?object} nextState | ||
15308 | * @param {?object} nextContext | ||
15309 | * @return {boolean} True if the component should update. | ||
15310 | * @optional | ||
15311 | */ | ||
15312 | shouldComponentUpdate: SpecPolicy.DEFINE_ONCE, | ||
15313 | |||
15314 | /** | ||
15315 | * Invoked when the component is about to update due to a transition from | ||
15316 | * `this.props`, `this.state` and `this.context` to `nextProps`, `nextState` | ||
15317 | * and `nextContext`. | ||
15318 | * | ||
15319 | * Use this as an opportunity to perform preparation before an update occurs. | ||
15320 | * | ||
15321 | * NOTE: You **cannot** use `this.setState()` in this method. | ||
15322 | * | ||
15323 | * @param {object} nextProps | ||
15324 | * @param {?object} nextState | ||
15325 | * @param {?object} nextContext | ||
15326 | * @param {ReactReconcileTransaction} transaction | ||
15327 | * @optional | ||
15328 | */ | ||
15329 | componentWillUpdate: SpecPolicy.DEFINE_MANY, | ||
15330 | |||
15331 | /** | ||
15332 | * Invoked when the component's DOM representation has been updated. | ||
15333 | * | ||
15334 | * Use this as an opportunity to operate on the DOM when the component has | ||
15335 | * been updated. | ||
15336 | * | ||
15337 | * @param {object} prevProps | ||
15338 | * @param {?object} prevState | ||
15339 | * @param {?object} prevContext | ||
15340 | * @param {DOMElement} rootNode DOM element representing the component. | ||
15341 | * @optional | ||
15342 | */ | ||
15343 | componentDidUpdate: SpecPolicy.DEFINE_MANY, | ||
15344 | |||
15345 | /** | ||
15346 | * Invoked when the component is about to be removed from its parent and have | ||
15347 | * its DOM representation destroyed. | ||
15348 | * | ||
15349 | * Use this as an opportunity to deallocate any external resources. | ||
15350 | * | ||
15351 | * NOTE: There is no `componentDidUnmount` since your component will have been | ||
15352 | * destroyed by that point. | ||
15353 | * | ||
15354 | * @optional | ||
15355 | */ | ||
15356 | componentWillUnmount: SpecPolicy.DEFINE_MANY, | ||
15357 | |||
15358 | // ==== Advanced methods ==== | ||
15359 | |||
15360 | /** | ||
15361 | * Updates the component's currently mounted DOM representation. | ||
15362 | * | ||
15363 | * By default, this implements React's rendering and reconciliation algorithm. | ||
15364 | * Sophisticated clients may wish to override this. | ||
15365 | * | ||
15366 | * @param {ReactReconcileTransaction} transaction | ||
15367 | * @internal | ||
15368 | * @overridable | ||
15369 | */ | ||
15370 | updateComponent: SpecPolicy.OVERRIDE_BASE | ||
15371 | |||
15372 | }; | ||
15373 | |||
15374 | /** | ||
15375 | * Mapping from class specification keys to special processing functions. | ||
15376 | * | ||
15377 | * Although these are declared like instance properties in the specification | ||
15378 | * when defining classes using `React.createClass`, they are actually static | ||
15379 | * and are accessible on the constructor instead of the prototype. Despite | ||
15380 | * being static, they must be defined outside of the "statics" key under | ||
15381 | * which all other static methods are defined. | ||
15382 | */ | ||
15383 | var RESERVED_SPEC_KEYS = { | ||
15384 | displayName: function (Constructor, displayName) { | ||
15385 | Constructor.displayName = displayName; | ||
15386 | }, | ||
15387 | mixins: function (Constructor, mixins) { | ||
15388 | if (mixins) { | ||
15389 | for (var i = 0; i < mixins.length; i++) { | ||
15390 | mixSpecIntoComponent(Constructor, mixins[i]); | ||
15391 | } | ||
15392 | } | ||
15393 | }, | ||
15394 | childContextTypes: function (Constructor, childContextTypes) { | ||
15395 | if (process.env.NODE_ENV !== 'production') { | ||
15396 | validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext); | ||
15397 | } | ||
15398 | Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes); | ||
15399 | }, | ||
15400 | contextTypes: function (Constructor, contextTypes) { | ||
15401 | if (process.env.NODE_ENV !== 'production') { | ||
15402 | validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context); | ||
15403 | } | ||
15404 | Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes); | ||
15405 | }, | ||
15406 | /** | ||
15407 | * Special case getDefaultProps which should move into statics but requires | ||
15408 | * automatic merging. | ||
15409 | */ | ||
15410 | getDefaultProps: function (Constructor, getDefaultProps) { | ||
15411 | if (Constructor.getDefaultProps) { | ||
15412 | Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps); | ||
15413 | } else { | ||
15414 | Constructor.getDefaultProps = getDefaultProps; | ||
15415 | } | ||
15416 | }, | ||
15417 | propTypes: function (Constructor, propTypes) { | ||
15418 | if (process.env.NODE_ENV !== 'production') { | ||
15419 | validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop); | ||
15420 | } | ||
15421 | Constructor.propTypes = assign({}, Constructor.propTypes, propTypes); | ||
15422 | }, | ||
15423 | statics: function (Constructor, statics) { | ||
15424 | mixStaticSpecIntoComponent(Constructor, statics); | ||
15425 | }, | ||
15426 | autobind: function () {} }; | ||
15427 | |||
15428 | // noop | ||
15429 | function validateTypeDef(Constructor, typeDef, location) { | ||
15430 | for (var propName in typeDef) { | ||
15431 | if (typeDef.hasOwnProperty(propName)) { | ||
15432 | // use a warning instead of an invariant so components | ||
15433 | // don't show up in prod but not in __DEV__ | ||
15434 | process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : undefined; | ||
15435 | } | ||
15436 | } | ||
15437 | } | ||
15438 | |||
15439 | function validateMethodOverride(proto, name) { | ||
15440 | var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null; | ||
15441 | |||
15442 | // Disallow overriding of base class methods unless explicitly allowed. | ||
15443 | if (ReactClassMixin.hasOwnProperty(name)) { | ||
15444 | !(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name) : invariant(false) : undefined; | ||
15445 | } | ||
15446 | |||
15447 | // Disallow defining methods more than once unless explicitly allowed. | ||
15448 | if (proto.hasOwnProperty(name)) { | ||
15449 | !(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) : undefined; | ||
15450 | } | ||
15451 | } | ||
15452 | |||
15453 | /** | ||
15454 | * Mixin helper which handles policy validation and reserved | ||
15455 | * specification keys when building React classses. | ||
15456 | */ | ||
15457 | function mixSpecIntoComponent(Constructor, spec) { | ||
15458 | if (!spec) { | ||
15459 | return; | ||
15460 | } | ||
15461 | |||
15462 | !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined; | ||
15463 | !!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : undefined; | ||
15464 | |||
15465 | var proto = Constructor.prototype; | ||
15466 | |||
15467 | // By handling mixins before any other properties, we ensure the same | ||
15468 | // chaining order is applied to methods with DEFINE_MANY policy, whether | ||
15469 | // mixins are listed before or after these methods in the spec. | ||
15470 | if (spec.hasOwnProperty(MIXINS_KEY)) { | ||
15471 | RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins); | ||
15472 | } | ||
15473 | |||
15474 | for (var name in spec) { | ||
15475 | if (!spec.hasOwnProperty(name)) { | ||
15476 | continue; | ||
15477 | } | ||
15478 | |||
15479 | if (name === MIXINS_KEY) { | ||
15480 | // We have already handled mixins in a special case above. | ||
15481 | continue; | ||
15482 | } | ||
15483 | |||
15484 | var property = spec[name]; | ||
15485 | validateMethodOverride(proto, name); | ||
15486 | |||
15487 | if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { | ||
15488 | RESERVED_SPEC_KEYS[name](Constructor, property); | ||
15489 | } else { | ||
15490 | // Setup methods on prototype: | ||
15491 | // The following member methods should not be automatically bound: | ||
15492 | // 1. Expected ReactClass methods (in the "interface"). | ||
15493 | // 2. Overridden methods (that were mixed in). | ||
15494 | var isReactClassMethod = ReactClassInterface.hasOwnProperty(name); | ||
15495 | var isAlreadyDefined = proto.hasOwnProperty(name); | ||
15496 | var isFunction = typeof property === 'function'; | ||
15497 | var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false; | ||
15498 | |||
15499 | if (shouldAutoBind) { | ||
15500 | if (!proto.__reactAutoBindMap) { | ||
15501 | proto.__reactAutoBindMap = {}; | ||
15502 | } | ||
15503 | proto.__reactAutoBindMap[name] = property; | ||
15504 | proto[name] = property; | ||
15505 | } else { | ||
15506 | if (isAlreadyDefined) { | ||
15507 | var specPolicy = ReactClassInterface[name]; | ||
15508 | |||
15509 | // These cases should already be caught by validateMethodOverride. | ||
15510 | !(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) : undefined; | ||
15511 | |||
15512 | // For methods which are defined more than once, call the existing | ||
15513 | // methods before calling the new property, merging if appropriate. | ||
15514 | if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) { | ||
15515 | proto[name] = createMergedResultFunction(proto[name], property); | ||
15516 | } else if (specPolicy === SpecPolicy.DEFINE_MANY) { | ||
15517 | proto[name] = createChainedFunction(proto[name], property); | ||
15518 | } | ||
15519 | } else { | ||
15520 | proto[name] = property; | ||
15521 | if (process.env.NODE_ENV !== 'production') { | ||
15522 | // Add verbose displayName to the function, which helps when looking | ||
15523 | // at profiling tools. | ||
15524 | if (typeof property === 'function' && spec.displayName) { | ||
15525 | proto[name].displayName = spec.displayName + '_' + name; | ||
15526 | } | ||
15527 | } | ||
15528 | } | ||
15529 | } | ||
15530 | } | ||
15531 | } | ||
15532 | } | ||
15533 | |||
15534 | function mixStaticSpecIntoComponent(Constructor, statics) { | ||
15535 | if (!statics) { | ||
15536 | return; | ||
15537 | } | ||
15538 | for (var name in statics) { | ||
15539 | var property = statics[name]; | ||
15540 | if (!statics.hasOwnProperty(name)) { | ||
15541 | continue; | ||
15542 | } | ||
15543 | |||
15544 | var isReserved = (name in RESERVED_SPEC_KEYS); | ||
15545 | !!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name) : invariant(false) : undefined; | ||
15546 | |||
15547 | var isInherited = (name in Constructor); | ||
15548 | !!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(false) : undefined; | ||
15549 | Constructor[name] = property; | ||
15550 | } | ||
15551 | } | ||
15552 | |||
15553 | /** | ||
15554 | * Merge two objects, but throw if both contain the same key. | ||
15555 | * | ||
15556 | * @param {object} one The first object, which is mutated. | ||
15557 | * @param {object} two The second object | ||
15558 | * @return {object} one after it has been mutated to contain everything in two. | ||
15559 | */ | ||
15560 | function mergeIntoWithNoDuplicateKeys(one, two) { | ||
15561 | !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined; | ||
15562 | |||
15563 | for (var key in two) { | ||
15564 | if (two.hasOwnProperty(key)) { | ||
15565 | !(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key) : invariant(false) : undefined; | ||
15566 | one[key] = two[key]; | ||
15567 | } | ||
15568 | } | ||
15569 | return one; | ||
15570 | } | ||
15571 | |||
15572 | /** | ||
15573 | * Creates a function that invokes two functions and merges their return values. | ||
15574 | * | ||
15575 | * @param {function} one Function to invoke first. | ||
15576 | * @param {function} two Function to invoke second. | ||
15577 | * @return {function} Function that invokes the two argument functions. | ||
15578 | * @private | ||
15579 | */ | ||
15580 | function createMergedResultFunction(one, two) { | ||
15581 | return function mergedResult() { | ||
15582 | var a = one.apply(this, arguments); | ||
15583 | var b = two.apply(this, arguments); | ||
15584 | if (a == null) { | ||
15585 | return b; | ||
15586 | } else if (b == null) { | ||
15587 | return a; | ||
15588 | } | ||
15589 | var c = {}; | ||
15590 | mergeIntoWithNoDuplicateKeys(c, a); | ||
15591 | mergeIntoWithNoDuplicateKeys(c, b); | ||
15592 | return c; | ||
15593 | }; | ||
15594 | } | ||
15595 | |||
15596 | /** | ||
15597 | * Creates a function that invokes two functions and ignores their return vales. | ||
15598 | * | ||
15599 | * @param {function} one Function to invoke first. | ||
15600 | * @param {function} two Function to invoke second. | ||
15601 | * @return {function} Function that invokes the two argument functions. | ||
15602 | * @private | ||
15603 | */ | ||
15604 | function createChainedFunction(one, two) { | ||
15605 | return function chainedFunction() { | ||
15606 | one.apply(this, arguments); | ||
15607 | two.apply(this, arguments); | ||
15608 | }; | ||
15609 | } | ||
15610 | |||
15611 | /** | ||
15612 | * Binds a method to the component. | ||
15613 | * | ||
15614 | * @param {object} component Component whose method is going to be bound. | ||
15615 | * @param {function} method Method to be bound. | ||
15616 | * @return {function} The bound method. | ||
15617 | */ | ||
15618 | function bindAutoBindMethod(component, method) { | ||
15619 | var boundMethod = method.bind(component); | ||
15620 | if (process.env.NODE_ENV !== 'production') { | ||
15621 | boundMethod.__reactBoundContext = component; | ||
15622 | boundMethod.__reactBoundMethod = method; | ||
15623 | boundMethod.__reactBoundArguments = null; | ||
15624 | var componentName = component.constructor.displayName; | ||
15625 | var _bind = boundMethod.bind; | ||
15626 | /* eslint-disable block-scoped-var, no-undef */ | ||
15627 | boundMethod.bind = function (newThis) { | ||
15628 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
15629 | args[_key - 1] = arguments[_key]; | ||
15630 | } | ||
15631 | |||
15632 | // User is trying to bind() an autobound method; we effectively will | ||
15633 | // ignore the value of "this" that the user is trying to use, so | ||
15634 | // let's warn. | ||
15635 | if (newThis !== component && newThis !== null) { | ||
15636 | process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined; | ||
15637 | } else if (!args.length) { | ||
15638 | process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : undefined; | ||
15639 | return boundMethod; | ||
15640 | } | ||
15641 | var reboundMethod = _bind.apply(boundMethod, arguments); | ||
15642 | reboundMethod.__reactBoundContext = component; | ||
15643 | reboundMethod.__reactBoundMethod = method; | ||
15644 | reboundMethod.__reactBoundArguments = args; | ||
15645 | return reboundMethod; | ||
15646 | /* eslint-enable */ | ||
15647 | }; | ||
15648 | } | ||
15649 | return boundMethod; | ||
15650 | } | ||
15651 | |||
15652 | /** | ||
15653 | * Binds all auto-bound methods in a component. | ||
15654 | * | ||
15655 | * @param {object} component Component whose method is going to be bound. | ||
15656 | */ | ||
15657 | function bindAutoBindMethods(component) { | ||
15658 | for (var autoBindKey in component.__reactAutoBindMap) { | ||
15659 | if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) { | ||
15660 | var method = component.__reactAutoBindMap[autoBindKey]; | ||
15661 | component[autoBindKey] = bindAutoBindMethod(component, method); | ||
15662 | } | ||
15663 | } | ||
15664 | } | ||
15665 | |||
15666 | /** | ||
15667 | * Add more to the ReactClass base class. These are all legacy features and | ||
15668 | * therefore not already part of the modern ReactComponent. | ||
15669 | */ | ||
15670 | var ReactClassMixin = { | ||
15671 | |||
15672 | /** | ||
15673 | * TODO: This will be deprecated because state should always keep a consistent | ||
15674 | * type signature and the only use case for this, is to avoid that. | ||
15675 | */ | ||
15676 | replaceState: function (newState, callback) { | ||
15677 | this.updater.enqueueReplaceState(this, newState); | ||
15678 | if (callback) { | ||
15679 | this.updater.enqueueCallback(this, callback); | ||
15680 | } | ||
15681 | }, | ||
15682 | |||
15683 | /** | ||
15684 | * Checks whether or not this composite component is mounted. | ||
15685 | * @return {boolean} True if mounted, false otherwise. | ||
15686 | * @protected | ||
15687 | * @final | ||
15688 | */ | ||
15689 | isMounted: function () { | ||
15690 | return this.updater.isMounted(this); | ||
15691 | }, | ||
15692 | |||
15693 | /** | ||
15694 | * Sets a subset of the props. | ||
15695 | * | ||
15696 | * @param {object} partialProps Subset of the next props. | ||
15697 | * @param {?function} callback Called after props are updated. | ||
15698 | * @final | ||
15699 | * @public | ||
15700 | * @deprecated | ||
15701 | */ | ||
15702 | setProps: function (partialProps, callback) { | ||
15703 | if (process.env.NODE_ENV !== 'production') { | ||
15704 | warnSetProps(); | ||
15705 | } | ||
15706 | this.updater.enqueueSetProps(this, partialProps); | ||
15707 | if (callback) { | ||
15708 | this.updater.enqueueCallback(this, callback); | ||
15709 | } | ||
15710 | }, | ||
15711 | |||
15712 | /** | ||
15713 | * Replace all the props. | ||
15714 | * | ||
15715 | * @param {object} newProps Subset of the next props. | ||
15716 | * @param {?function} callback Called after props are updated. | ||
15717 | * @final | ||
15718 | * @public | ||
15719 | * @deprecated | ||
15720 | */ | ||
15721 | replaceProps: function (newProps, callback) { | ||
15722 | if (process.env.NODE_ENV !== 'production') { | ||
15723 | warnSetProps(); | ||
15724 | } | ||
15725 | this.updater.enqueueReplaceProps(this, newProps); | ||
15726 | if (callback) { | ||
15727 | this.updater.enqueueCallback(this, callback); | ||
15728 | } | ||
15729 | } | ||
15730 | }; | ||
15731 | |||
15732 | var ReactClassComponent = function () {}; | ||
15733 | assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin); | ||
15734 | |||
15735 | /** | ||
15736 | * Module for creating composite components. | ||
15737 | * | ||
15738 | * @class ReactClass | ||
15739 | */ | ||
15740 | var ReactClass = { | ||
15741 | |||
15742 | /** | ||
15743 | * Creates a composite component class given a class specification. | ||
15744 | * | ||
15745 | * @param {object} spec Class specification (which must define `render`). | ||
15746 | * @return {function} Component constructor function. | ||
15747 | * @public | ||
15748 | */ | ||
15749 | createClass: function (spec) { | ||
15750 | var Constructor = function (props, context, updater) { | ||
15751 | // This constructor is overridden by mocks. The argument is used | ||
15752 | // by mocks to assert on what gets mounted. | ||
15753 | |||
15754 | if (process.env.NODE_ENV !== 'production') { | ||
15755 | process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined; | ||
15756 | } | ||
15757 | |||
15758 | // Wire up auto-binding | ||
15759 | if (this.__reactAutoBindMap) { | ||
15760 | bindAutoBindMethods(this); | ||
15761 | } | ||
15762 | |||
15763 | this.props = props; | ||
15764 | this.context = context; | ||
15765 | this.refs = emptyObject; | ||
15766 | this.updater = updater || ReactNoopUpdateQueue; | ||
15767 | |||
15768 | this.state = null; | ||
15769 | |||
15770 | // ReactClasses doesn't have constructors. Instead, they use the | ||
15771 | // getInitialState and componentWillMount methods for initialization. | ||
15772 | |||
15773 | var initialState = this.getInitialState ? this.getInitialState() : null; | ||
15774 | if (process.env.NODE_ENV !== 'production') { | ||
15775 | // We allow auto-mocks to proceed as if they're returning null. | ||
15776 | if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) { | ||
15777 | // This is probably bad practice. Consider warning here and | ||
15778 | // deprecating this convenience. | ||
15779 | initialState = null; | ||
15780 | } | ||
15781 | } | ||
15782 | !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined; | ||
15783 | |||
15784 | this.state = initialState; | ||
15785 | }; | ||
15786 | Constructor.prototype = new ReactClassComponent(); | ||
15787 | Constructor.prototype.constructor = Constructor; | ||
15788 | |||
15789 | injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor)); | ||
15790 | |||
15791 | mixSpecIntoComponent(Constructor, spec); | ||
15792 | |||
15793 | // Initialize the defaultProps property after all mixins have been merged. | ||
15794 | if (Constructor.getDefaultProps) { | ||
15795 | Constructor.defaultProps = Constructor.getDefaultProps(); | ||
15796 | } | ||
15797 | |||
15798 | if (process.env.NODE_ENV !== 'production') { | ||
15799 | // This is a tag to indicate that the use of these method names is ok, | ||
15800 | // since it's used with createClass. If it's not, then it's likely a | ||
15801 | // mistake so we'll warn you to use the static property, property | ||
15802 | // initializer or constructor respectively. | ||
15803 | if (Constructor.getDefaultProps) { | ||
15804 | Constructor.getDefaultProps.isReactClassApproved = {}; | ||
15805 | } | ||
15806 | if (Constructor.prototype.getInitialState) { | ||
15807 | Constructor.prototype.getInitialState.isReactClassApproved = {}; | ||
15808 | } | ||
15809 | } | ||
15810 | |||
15811 | !Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined; | ||
15812 | |||
15813 | if (process.env.NODE_ENV !== 'production') { | ||
15814 | process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : undefined; | ||
15815 | process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : undefined; | ||
15816 | } | ||
15817 | |||
15818 | // Reduce time spent doing lookups by setting these on the prototype. | ||
15819 | for (var methodName in ReactClassInterface) { | ||
15820 | if (!Constructor.prototype[methodName]) { | ||
15821 | Constructor.prototype[methodName] = null; | ||
15822 | } | ||
15823 | } | ||
15824 | |||
15825 | return Constructor; | ||
15826 | }, | ||
15827 | |||
15828 | injection: { | ||
15829 | injectMixin: function (mixin) { | ||
15830 | injectedMixins.push(mixin); | ||
15831 | } | ||
15832 | } | ||
15833 | |||
15834 | }; | ||
15835 | |||
15836 | module.exports = ReactClass; | ||
15837 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
15838 | |||
15839 | /***/ }, | ||
15840 | /* 125 */ | ||
15841 | /***/ function(module, exports, __webpack_require__) { | ||
15842 | |||
15843 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
15844 | * Copyright 2013-2015, Facebook, Inc. | ||
15845 | * All rights reserved. | ||
15846 | * | ||
15847 | * This source code is licensed under the BSD-style license found in the | ||
15848 | * LICENSE file in the root directory of this source tree. An additional grant | ||
15849 | * of patent rights can be found in the PATENTS file in the same directory. | ||
15850 | * | ||
15851 | * @providesModule ReactComponent | ||
15852 | */ | ||
15853 | |||
15854 | 'use strict'; | ||
15855 | |||
15856 | var ReactNoopUpdateQueue = __webpack_require__(126); | ||
15857 | |||
15858 | var canDefineProperty = __webpack_require__(45); | ||
15859 | var emptyObject = __webpack_require__(60); | ||
15860 | var invariant = __webpack_require__(15); | ||
15861 | var warning = __webpack_require__(27); | ||
15862 | |||
15863 | /** | ||
15864 | * Base class helpers for the updating state of a component. | ||
15865 | */ | ||
15866 | function ReactComponent(props, context, updater) { | ||
15867 | this.props = props; | ||
15868 | this.context = context; | ||
15869 | this.refs = emptyObject; | ||
15870 | // We initialize the default updater but the real one gets injected by the | ||
15871 | // renderer. | ||
15872 | this.updater = updater || ReactNoopUpdateQueue; | ||
15873 | } | ||
15874 | |||
15875 | ReactComponent.prototype.isReactComponent = {}; | ||
15876 | |||
15877 | /** | ||
15878 | * Sets a subset of the state. Always use this to mutate | ||
15879 | * state. You should treat `this.state` as immutable. | ||
15880 | * | ||
15881 | * There is no guarantee that `this.state` will be immediately updated, so | ||
15882 | * accessing `this.state` after calling this method may return the old value. | ||
15883 | * | ||
15884 | * There is no guarantee that calls to `setState` will run synchronously, | ||
15885 | * as they may eventually be batched together. You can provide an optional | ||
15886 | * callback that will be executed when the call to setState is actually | ||
15887 | * completed. | ||
15888 | * | ||
15889 | * When a function is provided to setState, it will be called at some point in | ||
15890 | * the future (not synchronously). It will be called with the up to date | ||
15891 | * component arguments (state, props, context). These values can be different | ||
15892 | * from this.* because your function may be called after receiveProps but before | ||
15893 | * shouldComponentUpdate, and this new state, props, and context will not yet be | ||
15894 | * assigned to this. | ||
15895 | * | ||
15896 | * @param {object|function} partialState Next partial state or function to | ||
15897 | * produce next partial state to be merged with current state. | ||
15898 | * @param {?function} callback Called after state is updated. | ||
15899 | * @final | ||
15900 | * @protected | ||
15901 | */ | ||
15902 | ReactComponent.prototype.setState = function (partialState, callback) { | ||
15903 | !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(false) : undefined; | ||
15904 | if (process.env.NODE_ENV !== 'production') { | ||
15905 | process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : undefined; | ||
15906 | } | ||
15907 | this.updater.enqueueSetState(this, partialState); | ||
15908 | if (callback) { | ||
15909 | this.updater.enqueueCallback(this, callback); | ||
15910 | } | ||
15911 | }; | ||
15912 | |||
15913 | /** | ||
15914 | * Forces an update. This should only be invoked when it is known with | ||
15915 | * certainty that we are **not** in a DOM transaction. | ||
15916 | * | ||
15917 | * You may want to call this when you know that some deeper aspect of the | ||
15918 | * component's state has changed but `setState` was not called. | ||
15919 | * | ||
15920 | * This will not invoke `shouldComponentUpdate`, but it will invoke | ||
15921 | * `componentWillUpdate` and `componentDidUpdate`. | ||
15922 | * | ||
15923 | * @param {?function} callback Called after update is complete. | ||
15924 | * @final | ||
15925 | * @protected | ||
15926 | */ | ||
15927 | ReactComponent.prototype.forceUpdate = function (callback) { | ||
15928 | this.updater.enqueueForceUpdate(this); | ||
15929 | if (callback) { | ||
15930 | this.updater.enqueueCallback(this, callback); | ||
15931 | } | ||
15932 | }; | ||
15933 | |||
15934 | /** | ||
15935 | * Deprecated APIs. These APIs used to exist on classic React classes but since | ||
15936 | * we would like to deprecate them, we're not going to move them over to this | ||
15937 | * modern base class. Instead, we define a getter that warns if it's accessed. | ||
15938 | */ | ||
15939 | if (process.env.NODE_ENV !== 'production') { | ||
15940 | var deprecatedAPIs = { | ||
15941 | getDOMNode: ['getDOMNode', 'Use ReactDOM.findDOMNode(component) instead.'], | ||
15942 | isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], | ||
15943 | replaceProps: ['replaceProps', 'Instead, call render again at the top level.'], | ||
15944 | replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'], | ||
15945 | setProps: ['setProps', 'Instead, call render again at the top level.'] | ||
15946 | }; | ||
15947 | var defineDeprecationWarning = function (methodName, info) { | ||
15948 | if (canDefineProperty) { | ||
15949 | Object.defineProperty(ReactComponent.prototype, methodName, { | ||
15950 | get: function () { | ||
15951 | process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : undefined; | ||
15952 | return undefined; | ||
15953 | } | ||
15954 | }); | ||
15955 | } | ||
15956 | }; | ||
15957 | for (var fnName in deprecatedAPIs) { | ||
15958 | if (deprecatedAPIs.hasOwnProperty(fnName)) { | ||
15959 | defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); | ||
15960 | } | ||
15961 | } | ||
15962 | } | ||
15963 | |||
15964 | module.exports = ReactComponent; | ||
15965 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
15966 | |||
15967 | /***/ }, | ||
15968 | /* 126 */ | ||
15969 | /***/ function(module, exports, __webpack_require__) { | ||
15970 | |||
15971 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
15972 | * Copyright 2015, Facebook, Inc. | ||
15973 | * All rights reserved. | ||
15974 | * | ||
15975 | * This source code is licensed under the BSD-style license found in the | ||
15976 | * LICENSE file in the root directory of this source tree. An additional grant | ||
15977 | * of patent rights can be found in the PATENTS file in the same directory. | ||
15978 | * | ||
15979 | * @providesModule ReactNoopUpdateQueue | ||
15980 | */ | ||
15981 | |||
15982 | 'use strict'; | ||
15983 | |||
15984 | var warning = __webpack_require__(27); | ||
15985 | |||
15986 | function warnTDZ(publicInstance, callerName) { | ||
15987 | if (process.env.NODE_ENV !== 'production') { | ||
15988 | process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined; | ||
15989 | } | ||
15990 | } | ||
15991 | |||
15992 | /** | ||
15993 | * This is the abstract API for an update queue. | ||
15994 | */ | ||
15995 | var ReactNoopUpdateQueue = { | ||
15996 | |||
15997 | /** | ||
15998 | * Checks whether or not this composite component is mounted. | ||
15999 | * @param {ReactClass} publicInstance The instance we want to test. | ||
16000 | * @return {boolean} True if mounted, false otherwise. | ||
16001 | * @protected | ||
16002 | * @final | ||
16003 | */ | ||
16004 | isMounted: function (publicInstance) { | ||
16005 | return false; | ||
16006 | }, | ||
16007 | |||
16008 | /** | ||
16009 | * Enqueue a callback that will be executed after all the pending updates | ||
16010 | * have processed. | ||
16011 | * | ||
16012 | * @param {ReactClass} publicInstance The instance to use as `this` context. | ||
16013 | * @param {?function} callback Called after state is updated. | ||
16014 | * @internal | ||
16015 | */ | ||
16016 | enqueueCallback: function (publicInstance, callback) {}, | ||
16017 | |||
16018 | /** | ||
16019 | * Forces an update. This should only be invoked when it is known with | ||
16020 | * certainty that we are **not** in a DOM transaction. | ||
16021 | * | ||
16022 | * You may want to call this when you know that some deeper aspect of the | ||
16023 | * component's state has changed but `setState` was not called. | ||
16024 | * | ||
16025 | * This will not invoke `shouldComponentUpdate`, but it will invoke | ||
16026 | * `componentWillUpdate` and `componentDidUpdate`. | ||
16027 | * | ||
16028 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
16029 | * @internal | ||
16030 | */ | ||
16031 | enqueueForceUpdate: function (publicInstance) { | ||
16032 | warnTDZ(publicInstance, 'forceUpdate'); | ||
16033 | }, | ||
16034 | |||
16035 | /** | ||
16036 | * Replaces all of the state. Always use this or `setState` to mutate state. | ||
16037 | * You should treat `this.state` as immutable. | ||
16038 | * | ||
16039 | * There is no guarantee that `this.state` will be immediately updated, so | ||
16040 | * accessing `this.state` after calling this method may return the old value. | ||
16041 | * | ||
16042 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
16043 | * @param {object} completeState Next state. | ||
16044 | * @internal | ||
16045 | */ | ||
16046 | enqueueReplaceState: function (publicInstance, completeState) { | ||
16047 | warnTDZ(publicInstance, 'replaceState'); | ||
16048 | }, | ||
16049 | |||
16050 | /** | ||
16051 | * Sets a subset of the state. This only exists because _pendingState is | ||
16052 | * internal. This provides a merging strategy that is not available to deep | ||
16053 | * properties which is confusing. TODO: Expose pendingState or don't use it | ||
16054 | * during the merge. | ||
16055 | * | ||
16056 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
16057 | * @param {object} partialState Next partial state to be merged with state. | ||
16058 | * @internal | ||
16059 | */ | ||
16060 | enqueueSetState: function (publicInstance, partialState) { | ||
16061 | warnTDZ(publicInstance, 'setState'); | ||
16062 | }, | ||
16063 | |||
16064 | /** | ||
16065 | * Sets a subset of the props. | ||
16066 | * | ||
16067 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
16068 | * @param {object} partialProps Subset of the next props. | ||
16069 | * @internal | ||
16070 | */ | ||
16071 | enqueueSetProps: function (publicInstance, partialProps) { | ||
16072 | warnTDZ(publicInstance, 'setProps'); | ||
16073 | }, | ||
16074 | |||
16075 | /** | ||
16076 | * Replaces all of the props. | ||
16077 | * | ||
16078 | * @param {ReactClass} publicInstance The instance that should rerender. | ||
16079 | * @param {object} props New props. | ||
16080 | * @internal | ||
16081 | */ | ||
16082 | enqueueReplaceProps: function (publicInstance, props) { | ||
16083 | warnTDZ(publicInstance, 'replaceProps'); | ||
16084 | } | ||
16085 | |||
16086 | }; | ||
16087 | |||
16088 | module.exports = ReactNoopUpdateQueue; | ||
16089 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
16090 | |||
16091 | /***/ }, | ||
16092 | /* 127 */ | ||
16093 | /***/ function(module, exports, __webpack_require__) { | ||
16094 | |||
16095 | /** | ||
16096 | * Copyright 2013-2015, Facebook, Inc. | ||
16097 | * All rights reserved. | ||
16098 | * | ||
16099 | * This source code is licensed under the BSD-style license found in the | ||
16100 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16101 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16102 | * | ||
16103 | * @providesModule ReactReconcileTransaction | ||
16104 | * @typechecks static-only | ||
16105 | */ | ||
16106 | |||
16107 | 'use strict'; | ||
16108 | |||
16109 | var CallbackQueue = __webpack_require__(57); | ||
16110 | var PooledClass = __webpack_require__(58); | ||
16111 | var ReactBrowserEventEmitter = __webpack_require__(31); | ||
16112 | var ReactDOMFeatureFlags = __webpack_require__(43); | ||
16113 | var ReactInputSelection = __webpack_require__(128); | ||
16114 | var Transaction = __webpack_require__(59); | ||
16115 | |||
16116 | var assign = __webpack_require__(41); | ||
16117 | |||
16118 | /** | ||
16119 | * Ensures that, when possible, the selection range (currently selected text | ||
16120 | * input) is not disturbed by performing the transaction. | ||
16121 | */ | ||
16122 | var SELECTION_RESTORATION = { | ||
16123 | /** | ||
16124 | * @return {Selection} Selection information. | ||
16125 | */ | ||
16126 | initialize: ReactInputSelection.getSelectionInformation, | ||
16127 | /** | ||
16128 | * @param {Selection} sel Selection information returned from `initialize`. | ||
16129 | */ | ||
16130 | close: ReactInputSelection.restoreSelection | ||
16131 | }; | ||
16132 | |||
16133 | /** | ||
16134 | * Suppresses events (blur/focus) that could be inadvertently dispatched due to | ||
16135 | * high level DOM manipulations (like temporarily removing a text input from the | ||
16136 | * DOM). | ||
16137 | */ | ||
16138 | var EVENT_SUPPRESSION = { | ||
16139 | /** | ||
16140 | * @return {boolean} The enabled status of `ReactBrowserEventEmitter` before | ||
16141 | * the reconciliation. | ||
16142 | */ | ||
16143 | initialize: function () { | ||
16144 | var currentlyEnabled = ReactBrowserEventEmitter.isEnabled(); | ||
16145 | ReactBrowserEventEmitter.setEnabled(false); | ||
16146 | return currentlyEnabled; | ||
16147 | }, | ||
16148 | |||
16149 | /** | ||
16150 | * @param {boolean} previouslyEnabled Enabled status of | ||
16151 | * `ReactBrowserEventEmitter` before the reconciliation occurred. `close` | ||
16152 | * restores the previous value. | ||
16153 | */ | ||
16154 | close: function (previouslyEnabled) { | ||
16155 | ReactBrowserEventEmitter.setEnabled(previouslyEnabled); | ||
16156 | } | ||
16157 | }; | ||
16158 | |||
16159 | /** | ||
16160 | * Provides a queue for collecting `componentDidMount` and | ||
16161 | * `componentDidUpdate` callbacks during the the transaction. | ||
16162 | */ | ||
16163 | var ON_DOM_READY_QUEUEING = { | ||
16164 | /** | ||
16165 | * Initializes the internal `onDOMReady` queue. | ||
16166 | */ | ||
16167 | initialize: function () { | ||
16168 | this.reactMountReady.reset(); | ||
16169 | }, | ||
16170 | |||
16171 | /** | ||
16172 | * After DOM is flushed, invoke all registered `onDOMReady` callbacks. | ||
16173 | */ | ||
16174 | close: function () { | ||
16175 | this.reactMountReady.notifyAll(); | ||
16176 | } | ||
16177 | }; | ||
16178 | |||
16179 | /** | ||
16180 | * Executed within the scope of the `Transaction` instance. Consider these as | ||
16181 | * being member methods, but with an implied ordering while being isolated from | ||
16182 | * each other. | ||
16183 | */ | ||
16184 | var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_READY_QUEUEING]; | ||
16185 | |||
16186 | /** | ||
16187 | * Currently: | ||
16188 | * - The order that these are listed in the transaction is critical: | ||
16189 | * - Suppresses events. | ||
16190 | * - Restores selection range. | ||
16191 | * | ||
16192 | * Future: | ||
16193 | * - Restore document/overflow scroll positions that were unintentionally | ||
16194 | * modified via DOM insertions above the top viewport boundary. | ||
16195 | * - Implement/integrate with customized constraint based layout system and keep | ||
16196 | * track of which dimensions must be remeasured. | ||
16197 | * | ||
16198 | * @class ReactReconcileTransaction | ||
16199 | */ | ||
16200 | function ReactReconcileTransaction(forceHTML) { | ||
16201 | this.reinitializeTransaction(); | ||
16202 | // Only server-side rendering really needs this option (see | ||
16203 | // `ReactServerRendering`), but server-side uses | ||
16204 | // `ReactServerRenderingTransaction` instead. This option is here so that it's | ||
16205 | // accessible and defaults to false when `ReactDOMComponent` and | ||
16206 | // `ReactTextComponent` checks it in `mountComponent`.` | ||
16207 | this.renderToStaticMarkup = false; | ||
16208 | this.reactMountReady = CallbackQueue.getPooled(null); | ||
16209 | this.useCreateElement = !forceHTML && ReactDOMFeatureFlags.useCreateElement; | ||
16210 | } | ||
16211 | |||
16212 | var Mixin = { | ||
16213 | /** | ||
16214 | * @see Transaction | ||
16215 | * @abstract | ||
16216 | * @final | ||
16217 | * @return {array<object>} List of operation wrap procedures. | ||
16218 | * TODO: convert to array<TransactionWrapper> | ||
16219 | */ | ||
16220 | getTransactionWrappers: function () { | ||
16221 | return TRANSACTION_WRAPPERS; | ||
16222 | }, | ||
16223 | |||
16224 | /** | ||
16225 | * @return {object} The queue to collect `onDOMReady` callbacks with. | ||
16226 | */ | ||
16227 | getReactMountReady: function () { | ||
16228 | return this.reactMountReady; | ||
16229 | }, | ||
16230 | |||
16231 | /** | ||
16232 | * `PooledClass` looks for this, and will invoke this before allowing this | ||
16233 | * instance to be reused. | ||
16234 | */ | ||
16235 | destructor: function () { | ||
16236 | CallbackQueue.release(this.reactMountReady); | ||
16237 | this.reactMountReady = null; | ||
16238 | } | ||
16239 | }; | ||
16240 | |||
16241 | assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin); | ||
16242 | |||
16243 | PooledClass.addPoolingTo(ReactReconcileTransaction); | ||
16244 | |||
16245 | module.exports = ReactReconcileTransaction; | ||
16246 | |||
16247 | /***/ }, | ||
16248 | /* 128 */ | ||
16249 | /***/ function(module, exports, __webpack_require__) { | ||
16250 | |||
16251 | /** | ||
16252 | * Copyright 2013-2015, Facebook, Inc. | ||
16253 | * All rights reserved. | ||
16254 | * | ||
16255 | * This source code is licensed under the BSD-style license found in the | ||
16256 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16257 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16258 | * | ||
16259 | * @providesModule ReactInputSelection | ||
16260 | */ | ||
16261 | |||
16262 | 'use strict'; | ||
16263 | |||
16264 | var ReactDOMSelection = __webpack_require__(129); | ||
16265 | |||
16266 | var containsNode = __webpack_require__(61); | ||
16267 | var focusNode = __webpack_require__(97); | ||
16268 | var getActiveElement = __webpack_require__(131); | ||
16269 | |||
16270 | function isInDocument(node) { | ||
16271 | return containsNode(document.documentElement, node); | ||
16272 | } | ||
16273 | |||
16274 | /** | ||
16275 | * @ReactInputSelection: React input selection module. Based on Selection.js, | ||
16276 | * but modified to be suitable for react and has a couple of bug fixes (doesn't | ||
16277 | * assume buttons have range selections allowed). | ||
16278 | * Input selection module for React. | ||
16279 | */ | ||
16280 | var ReactInputSelection = { | ||
16281 | |||
16282 | hasSelectionCapabilities: function (elem) { | ||
16283 | var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | ||
16284 | return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true'); | ||
16285 | }, | ||
16286 | |||
16287 | getSelectionInformation: function () { | ||
16288 | var focusedElem = getActiveElement(); | ||
16289 | return { | ||
16290 | focusedElem: focusedElem, | ||
16291 | selectionRange: ReactInputSelection.hasSelectionCapabilities(focusedElem) ? ReactInputSelection.getSelection(focusedElem) : null | ||
16292 | }; | ||
16293 | }, | ||
16294 | |||
16295 | /** | ||
16296 | * @restoreSelection: If any selection information was potentially lost, | ||
16297 | * restore it. This is useful when performing operations that could remove dom | ||
16298 | * nodes and place them back in, resulting in focus being lost. | ||
16299 | */ | ||
16300 | restoreSelection: function (priorSelectionInformation) { | ||
16301 | var curFocusedElem = getActiveElement(); | ||
16302 | var priorFocusedElem = priorSelectionInformation.focusedElem; | ||
16303 | var priorSelectionRange = priorSelectionInformation.selectionRange; | ||
16304 | if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { | ||
16305 | if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) { | ||
16306 | ReactInputSelection.setSelection(priorFocusedElem, priorSelectionRange); | ||
16307 | } | ||
16308 | focusNode(priorFocusedElem); | ||
16309 | } | ||
16310 | }, | ||
16311 | |||
16312 | /** | ||
16313 | * @getSelection: Gets the selection bounds of a focused textarea, input or | ||
16314 | * contentEditable node. | ||
16315 | * -@input: Look up selection bounds of this input | ||
16316 | * -@return {start: selectionStart, end: selectionEnd} | ||
16317 | */ | ||
16318 | getSelection: function (input) { | ||
16319 | var selection; | ||
16320 | |||
16321 | if ('selectionStart' in input) { | ||
16322 | // Modern browser with input or textarea. | ||
16323 | selection = { | ||
16324 | start: input.selectionStart, | ||
16325 | end: input.selectionEnd | ||
16326 | }; | ||
16327 | } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) { | ||
16328 | // IE8 input. | ||
16329 | var range = document.selection.createRange(); | ||
16330 | // There can only be one selection per document in IE, so it must | ||
16331 | // be in our element. | ||
16332 | if (range.parentElement() === input) { | ||
16333 | selection = { | ||
16334 | start: -range.moveStart('character', -input.value.length), | ||
16335 | end: -range.moveEnd('character', -input.value.length) | ||
16336 | }; | ||
16337 | } | ||
16338 | } else { | ||
16339 | // Content editable or old IE textarea. | ||
16340 | selection = ReactDOMSelection.getOffsets(input); | ||
16341 | } | ||
16342 | |||
16343 | return selection || { start: 0, end: 0 }; | ||
16344 | }, | ||
16345 | |||
16346 | /** | ||
16347 | * @setSelection: Sets the selection bounds of a textarea or input and focuses | ||
16348 | * the input. | ||
16349 | * -@input Set selection bounds of this input or textarea | ||
16350 | * -@offsets Object of same form that is returned from get* | ||
16351 | */ | ||
16352 | setSelection: function (input, offsets) { | ||
16353 | var start = offsets.start; | ||
16354 | var end = offsets.end; | ||
16355 | if (typeof end === 'undefined') { | ||
16356 | end = start; | ||
16357 | } | ||
16358 | |||
16359 | if ('selectionStart' in input) { | ||
16360 | input.selectionStart = start; | ||
16361 | input.selectionEnd = Math.min(end, input.value.length); | ||
16362 | } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) { | ||
16363 | var range = input.createTextRange(); | ||
16364 | range.collapse(true); | ||
16365 | range.moveStart('character', start); | ||
16366 | range.moveEnd('character', end - start); | ||
16367 | range.select(); | ||
16368 | } else { | ||
16369 | ReactDOMSelection.setOffsets(input, offsets); | ||
16370 | } | ||
16371 | } | ||
16372 | }; | ||
16373 | |||
16374 | module.exports = ReactInputSelection; | ||
16375 | |||
16376 | /***/ }, | ||
16377 | /* 129 */ | ||
16378 | /***/ function(module, exports, __webpack_require__) { | ||
16379 | |||
16380 | /** | ||
16381 | * Copyright 2013-2015, Facebook, Inc. | ||
16382 | * All rights reserved. | ||
16383 | * | ||
16384 | * This source code is licensed under the BSD-style license found in the | ||
16385 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16386 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16387 | * | ||
16388 | * @providesModule ReactDOMSelection | ||
16389 | */ | ||
16390 | |||
16391 | 'use strict'; | ||
16392 | |||
16393 | var ExecutionEnvironment = __webpack_require__(11); | ||
16394 | |||
16395 | var getNodeForCharacterOffset = __webpack_require__(130); | ||
16396 | var getTextContentAccessor = __webpack_require__(77); | ||
16397 | |||
16398 | /** | ||
16399 | * While `isCollapsed` is available on the Selection object and `collapsed` | ||
16400 | * is available on the Range object, IE11 sometimes gets them wrong. | ||
16401 | * If the anchor/focus nodes and offsets are the same, the range is collapsed. | ||
16402 | */ | ||
16403 | function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) { | ||
16404 | return anchorNode === focusNode && anchorOffset === focusOffset; | ||
16405 | } | ||
16406 | |||
16407 | /** | ||
16408 | * Get the appropriate anchor and focus node/offset pairs for IE. | ||
16409 | * | ||
16410 | * The catch here is that IE's selection API doesn't provide information | ||
16411 | * about whether the selection is forward or backward, so we have to | ||
16412 | * behave as though it's always forward. | ||
16413 | * | ||
16414 | * IE text differs from modern selection in that it behaves as though | ||
16415 | * block elements end with a new line. This means character offsets will | ||
16416 | * differ between the two APIs. | ||
16417 | * | ||
16418 | * @param {DOMElement} node | ||
16419 | * @return {object} | ||
16420 | */ | ||
16421 | function getIEOffsets(node) { | ||
16422 | var selection = document.selection; | ||
16423 | var selectedRange = selection.createRange(); | ||
16424 | var selectedLength = selectedRange.text.length; | ||
16425 | |||
16426 | // Duplicate selection so we can move range without breaking user selection. | ||
16427 | var fromStart = selectedRange.duplicate(); | ||
16428 | fromStart.moveToElementText(node); | ||
16429 | fromStart.setEndPoint('EndToStart', selectedRange); | ||
16430 | |||
16431 | var startOffset = fromStart.text.length; | ||
16432 | var endOffset = startOffset + selectedLength; | ||
16433 | |||
16434 | return { | ||
16435 | start: startOffset, | ||
16436 | end: endOffset | ||
16437 | }; | ||
16438 | } | ||
16439 | |||
16440 | /** | ||
16441 | * @param {DOMElement} node | ||
16442 | * @return {?object} | ||
16443 | */ | ||
16444 | function getModernOffsets(node) { | ||
16445 | var selection = window.getSelection && window.getSelection(); | ||
16446 | |||
16447 | if (!selection || selection.rangeCount === 0) { | ||
16448 | return null; | ||
16449 | } | ||
16450 | |||
16451 | var anchorNode = selection.anchorNode; | ||
16452 | var anchorOffset = selection.anchorOffset; | ||
16453 | var focusNode = selection.focusNode; | ||
16454 | var focusOffset = selection.focusOffset; | ||
16455 | |||
16456 | var currentRange = selection.getRangeAt(0); | ||
16457 | |||
16458 | // In Firefox, range.startContainer and range.endContainer can be "anonymous | ||
16459 | // divs", e.g. the up/down buttons on an <input type="number">. Anonymous | ||
16460 | // divs do not seem to expose properties, triggering a "Permission denied | ||
16461 | // error" if any of its properties are accessed. The only seemingly possible | ||
16462 | // way to avoid erroring is to access a property that typically works for | ||
16463 | // non-anonymous divs and catch any error that may otherwise arise. See | ||
16464 | // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 | ||
16465 | try { | ||
16466 | /* eslint-disable no-unused-expressions */ | ||
16467 | currentRange.startContainer.nodeType; | ||
16468 | currentRange.endContainer.nodeType; | ||
16469 | /* eslint-enable no-unused-expressions */ | ||
16470 | } catch (e) { | ||
16471 | return null; | ||
16472 | } | ||
16473 | |||
16474 | // If the node and offset values are the same, the selection is collapsed. | ||
16475 | // `Selection.isCollapsed` is available natively, but IE sometimes gets | ||
16476 | // this value wrong. | ||
16477 | var isSelectionCollapsed = isCollapsed(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset); | ||
16478 | |||
16479 | var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length; | ||
16480 | |||
16481 | var tempRange = currentRange.cloneRange(); | ||
16482 | tempRange.selectNodeContents(node); | ||
16483 | tempRange.setEnd(currentRange.startContainer, currentRange.startOffset); | ||
16484 | |||
16485 | var isTempRangeCollapsed = isCollapsed(tempRange.startContainer, tempRange.startOffset, tempRange.endContainer, tempRange.endOffset); | ||
16486 | |||
16487 | var start = isTempRangeCollapsed ? 0 : tempRange.toString().length; | ||
16488 | var end = start + rangeLength; | ||
16489 | |||
16490 | // Detect whether the selection is backward. | ||
16491 | var detectionRange = document.createRange(); | ||
16492 | detectionRange.setStart(anchorNode, anchorOffset); | ||
16493 | detectionRange.setEnd(focusNode, focusOffset); | ||
16494 | var isBackward = detectionRange.collapsed; | ||
16495 | |||
16496 | return { | ||
16497 | start: isBackward ? end : start, | ||
16498 | end: isBackward ? start : end | ||
16499 | }; | ||
16500 | } | ||
16501 | |||
16502 | /** | ||
16503 | * @param {DOMElement|DOMTextNode} node | ||
16504 | * @param {object} offsets | ||
16505 | */ | ||
16506 | function setIEOffsets(node, offsets) { | ||
16507 | var range = document.selection.createRange().duplicate(); | ||
16508 | var start, end; | ||
16509 | |||
16510 | if (typeof offsets.end === 'undefined') { | ||
16511 | start = offsets.start; | ||
16512 | end = start; | ||
16513 | } else if (offsets.start > offsets.end) { | ||
16514 | start = offsets.end; | ||
16515 | end = offsets.start; | ||
16516 | } else { | ||
16517 | start = offsets.start; | ||
16518 | end = offsets.end; | ||
16519 | } | ||
16520 | |||
16521 | range.moveToElementText(node); | ||
16522 | range.moveStart('character', start); | ||
16523 | range.setEndPoint('EndToStart', range); | ||
16524 | range.moveEnd('character', end - start); | ||
16525 | range.select(); | ||
16526 | } | ||
16527 | |||
16528 | /** | ||
16529 | * In modern non-IE browsers, we can support both forward and backward | ||
16530 | * selections. | ||
16531 | * | ||
16532 | * Note: IE10+ supports the Selection object, but it does not support | ||
16533 | * the `extend` method, which means that even in modern IE, it's not possible | ||
16534 | * to programatically create a backward selection. Thus, for all IE | ||
16535 | * versions, we use the old IE API to create our selections. | ||
16536 | * | ||
16537 | * @param {DOMElement|DOMTextNode} node | ||
16538 | * @param {object} offsets | ||
16539 | */ | ||
16540 | function setModernOffsets(node, offsets) { | ||
16541 | if (!window.getSelection) { | ||
16542 | return; | ||
16543 | } | ||
16544 | |||
16545 | var selection = window.getSelection(); | ||
16546 | var length = node[getTextContentAccessor()].length; | ||
16547 | var start = Math.min(offsets.start, length); | ||
16548 | var end = typeof offsets.end === 'undefined' ? start : Math.min(offsets.end, length); | ||
16549 | |||
16550 | // IE 11 uses modern selection, but doesn't support the extend method. | ||
16551 | // Flip backward selections, so we can set with a single range. | ||
16552 | if (!selection.extend && start > end) { | ||
16553 | var temp = end; | ||
16554 | end = start; | ||
16555 | start = temp; | ||
16556 | } | ||
16557 | |||
16558 | var startMarker = getNodeForCharacterOffset(node, start); | ||
16559 | var endMarker = getNodeForCharacterOffset(node, end); | ||
16560 | |||
16561 | if (startMarker && endMarker) { | ||
16562 | var range = document.createRange(); | ||
16563 | range.setStart(startMarker.node, startMarker.offset); | ||
16564 | selection.removeAllRanges(); | ||
16565 | |||
16566 | if (start > end) { | ||
16567 | selection.addRange(range); | ||
16568 | selection.extend(endMarker.node, endMarker.offset); | ||
16569 | } else { | ||
16570 | range.setEnd(endMarker.node, endMarker.offset); | ||
16571 | selection.addRange(range); | ||
16572 | } | ||
16573 | } | ||
16574 | } | ||
16575 | |||
16576 | var useIEOffsets = ExecutionEnvironment.canUseDOM && 'selection' in document && !('getSelection' in window); | ||
16577 | |||
16578 | var ReactDOMSelection = { | ||
16579 | /** | ||
16580 | * @param {DOMElement} node | ||
16581 | */ | ||
16582 | getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets, | ||
16583 | |||
16584 | /** | ||
16585 | * @param {DOMElement|DOMTextNode} node | ||
16586 | * @param {object} offsets | ||
16587 | */ | ||
16588 | setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets | ||
16589 | }; | ||
16590 | |||
16591 | module.exports = ReactDOMSelection; | ||
16592 | |||
16593 | /***/ }, | ||
16594 | /* 130 */ | ||
16595 | /***/ function(module, exports) { | ||
16596 | |||
16597 | /** | ||
16598 | * Copyright 2013-2015, Facebook, Inc. | ||
16599 | * All rights reserved. | ||
16600 | * | ||
16601 | * This source code is licensed under the BSD-style license found in the | ||
16602 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16603 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16604 | * | ||
16605 | * @providesModule getNodeForCharacterOffset | ||
16606 | */ | ||
16607 | |||
16608 | 'use strict'; | ||
16609 | |||
16610 | /** | ||
16611 | * Given any node return the first leaf node without children. | ||
16612 | * | ||
16613 | * @param {DOMElement|DOMTextNode} node | ||
16614 | * @return {DOMElement|DOMTextNode} | ||
16615 | */ | ||
16616 | function getLeafNode(node) { | ||
16617 | while (node && node.firstChild) { | ||
16618 | node = node.firstChild; | ||
16619 | } | ||
16620 | return node; | ||
16621 | } | ||
16622 | |||
16623 | /** | ||
16624 | * Get the next sibling within a container. This will walk up the | ||
16625 | * DOM if a node's siblings have been exhausted. | ||
16626 | * | ||
16627 | * @param {DOMElement|DOMTextNode} node | ||
16628 | * @return {?DOMElement|DOMTextNode} | ||
16629 | */ | ||
16630 | function getSiblingNode(node) { | ||
16631 | while (node) { | ||
16632 | if (node.nextSibling) { | ||
16633 | return node.nextSibling; | ||
16634 | } | ||
16635 | node = node.parentNode; | ||
16636 | } | ||
16637 | } | ||
16638 | |||
16639 | /** | ||
16640 | * Get object describing the nodes which contain characters at offset. | ||
16641 | * | ||
16642 | * @param {DOMElement|DOMTextNode} root | ||
16643 | * @param {number} offset | ||
16644 | * @return {?object} | ||
16645 | */ | ||
16646 | function getNodeForCharacterOffset(root, offset) { | ||
16647 | var node = getLeafNode(root); | ||
16648 | var nodeStart = 0; | ||
16649 | var nodeEnd = 0; | ||
16650 | |||
16651 | while (node) { | ||
16652 | if (node.nodeType === 3) { | ||
16653 | nodeEnd = nodeStart + node.textContent.length; | ||
16654 | |||
16655 | if (nodeStart <= offset && nodeEnd >= offset) { | ||
16656 | return { | ||
16657 | node: node, | ||
16658 | offset: offset - nodeStart | ||
16659 | }; | ||
16660 | } | ||
16661 | |||
16662 | nodeStart = nodeEnd; | ||
16663 | } | ||
16664 | |||
16665 | node = getLeafNode(getSiblingNode(node)); | ||
16666 | } | ||
16667 | } | ||
16668 | |||
16669 | module.exports = getNodeForCharacterOffset; | ||
16670 | |||
16671 | /***/ }, | ||
16672 | /* 131 */ | ||
16673 | /***/ function(module, exports) { | ||
16674 | |||
16675 | /** | ||
16676 | * Copyright 2013-2015, Facebook, Inc. | ||
16677 | * All rights reserved. | ||
16678 | * | ||
16679 | * This source code is licensed under the BSD-style license found in the | ||
16680 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16681 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16682 | * | ||
16683 | * @providesModule getActiveElement | ||
16684 | * @typechecks | ||
16685 | */ | ||
16686 | |||
16687 | /** | ||
16688 | * Same as document.activeElement but wraps in a try-catch block. In IE it is | ||
16689 | * not safe to call document.activeElement if there is nothing focused. | ||
16690 | * | ||
16691 | * The activeElement will be null only if the document or document body is not yet defined. | ||
16692 | */ | ||
16693 | 'use strict'; | ||
16694 | |||
16695 | function getActiveElement() /*?DOMElement*/{ | ||
16696 | if (typeof document === 'undefined') { | ||
16697 | return null; | ||
16698 | } | ||
16699 | |||
16700 | try { | ||
16701 | return document.activeElement || document.body; | ||
16702 | } catch (e) { | ||
16703 | return document.body; | ||
16704 | } | ||
16705 | } | ||
16706 | |||
16707 | module.exports = getActiveElement; | ||
16708 | |||
16709 | /***/ }, | ||
16710 | /* 132 */ | ||
16711 | /***/ function(module, exports, __webpack_require__) { | ||
16712 | |||
16713 | /** | ||
16714 | * Copyright 2013-2015, Facebook, Inc. | ||
16715 | * All rights reserved. | ||
16716 | * | ||
16717 | * This source code is licensed under the BSD-style license found in the | ||
16718 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16719 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16720 | * | ||
16721 | * @providesModule SelectEventPlugin | ||
16722 | */ | ||
16723 | |||
16724 | 'use strict'; | ||
16725 | |||
16726 | var EventConstants = __webpack_require__(32); | ||
16727 | var EventPropagators = __webpack_require__(75); | ||
16728 | var ExecutionEnvironment = __webpack_require__(11); | ||
16729 | var ReactInputSelection = __webpack_require__(128); | ||
16730 | var SyntheticEvent = __webpack_require__(79); | ||
16731 | |||
16732 | var getActiveElement = __webpack_require__(131); | ||
16733 | var isTextInputElement = __webpack_require__(84); | ||
16734 | var keyOf = __webpack_require__(81); | ||
16735 | var shallowEqual = __webpack_require__(119); | ||
16736 | |||
16737 | var topLevelTypes = EventConstants.topLevelTypes; | ||
16738 | |||
16739 | var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11; | ||
16740 | |||
16741 | var eventTypes = { | ||
16742 | select: { | ||
16743 | phasedRegistrationNames: { | ||
16744 | bubbled: keyOf({ onSelect: null }), | ||
16745 | captured: keyOf({ onSelectCapture: null }) | ||
16746 | }, | ||
16747 | dependencies: [topLevelTypes.topBlur, topLevelTypes.topContextMenu, topLevelTypes.topFocus, topLevelTypes.topKeyDown, topLevelTypes.topMouseDown, topLevelTypes.topMouseUp, topLevelTypes.topSelectionChange] | ||
16748 | } | ||
16749 | }; | ||
16750 | |||
16751 | var activeElement = null; | ||
16752 | var activeElementID = null; | ||
16753 | var lastSelection = null; | ||
16754 | var mouseDown = false; | ||
16755 | |||
16756 | // Track whether a listener exists for this plugin. If none exist, we do | ||
16757 | // not extract events. | ||
16758 | var hasListener = false; | ||
16759 | var ON_SELECT_KEY = keyOf({ onSelect: null }); | ||
16760 | |||
16761 | /** | ||
16762 | * Get an object which is a unique representation of the current selection. | ||
16763 | * | ||
16764 | * The return value will not be consistent across nodes or browsers, but | ||
16765 | * two identical selections on the same node will return identical objects. | ||
16766 | * | ||
16767 | * @param {DOMElement} node | ||
16768 | * @return {object} | ||
16769 | */ | ||
16770 | function getSelection(node) { | ||
16771 | if ('selectionStart' in node && ReactInputSelection.hasSelectionCapabilities(node)) { | ||
16772 | return { | ||
16773 | start: node.selectionStart, | ||
16774 | end: node.selectionEnd | ||
16775 | }; | ||
16776 | } else if (window.getSelection) { | ||
16777 | var selection = window.getSelection(); | ||
16778 | return { | ||
16779 | anchorNode: selection.anchorNode, | ||
16780 | anchorOffset: selection.anchorOffset, | ||
16781 | focusNode: selection.focusNode, | ||
16782 | focusOffset: selection.focusOffset | ||
16783 | }; | ||
16784 | } else if (document.selection) { | ||
16785 | var range = document.selection.createRange(); | ||
16786 | return { | ||
16787 | parentElement: range.parentElement(), | ||
16788 | text: range.text, | ||
16789 | top: range.boundingTop, | ||
16790 | left: range.boundingLeft | ||
16791 | }; | ||
16792 | } | ||
16793 | } | ||
16794 | |||
16795 | /** | ||
16796 | * Poll selection to see whether it's changed. | ||
16797 | * | ||
16798 | * @param {object} nativeEvent | ||
16799 | * @return {?SyntheticEvent} | ||
16800 | */ | ||
16801 | function constructSelectEvent(nativeEvent, nativeEventTarget) { | ||
16802 | // Ensure we have the right element, and that the user is not dragging a | ||
16803 | // selection (this matches native `select` event behavior). In HTML5, select | ||
16804 | // fires only on input and textarea thus if there's no focused element we | ||
16805 | // won't dispatch. | ||
16806 | if (mouseDown || activeElement == null || activeElement !== getActiveElement()) { | ||
16807 | return null; | ||
16808 | } | ||
16809 | |||
16810 | // Only fire when selection has actually changed. | ||
16811 | var currentSelection = getSelection(activeElement); | ||
16812 | if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { | ||
16813 | lastSelection = currentSelection; | ||
16814 | |||
16815 | var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementID, nativeEvent, nativeEventTarget); | ||
16816 | |||
16817 | syntheticEvent.type = 'select'; | ||
16818 | syntheticEvent.target = activeElement; | ||
16819 | |||
16820 | EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent); | ||
16821 | |||
16822 | return syntheticEvent; | ||
16823 | } | ||
16824 | |||
16825 | return null; | ||
16826 | } | ||
16827 | |||
16828 | /** | ||
16829 | * This plugin creates an `onSelect` event that normalizes select events | ||
16830 | * across form elements. | ||
16831 | * | ||
16832 | * Supported elements are: | ||
16833 | * - input (see `isTextInputElement`) | ||
16834 | * - textarea | ||
16835 | * - contentEditable | ||
16836 | * | ||
16837 | * This differs from native browser implementations in the following ways: | ||
16838 | * - Fires on contentEditable fields as well as inputs. | ||
16839 | * - Fires for collapsed selection. | ||
16840 | * - Fires after user input. | ||
16841 | */ | ||
16842 | var SelectEventPlugin = { | ||
16843 | |||
16844 | eventTypes: eventTypes, | ||
16845 | |||
16846 | /** | ||
16847 | * @param {string} topLevelType Record from `EventConstants`. | ||
16848 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
16849 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
16850 | * @param {object} nativeEvent Native browser event. | ||
16851 | * @return {*} An accumulation of synthetic events. | ||
16852 | * @see {EventPluginHub.extractEvents} | ||
16853 | */ | ||
16854 | extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
16855 | if (!hasListener) { | ||
16856 | return null; | ||
16857 | } | ||
16858 | |||
16859 | switch (topLevelType) { | ||
16860 | // Track the input node that has focus. | ||
16861 | case topLevelTypes.topFocus: | ||
16862 | if (isTextInputElement(topLevelTarget) || topLevelTarget.contentEditable === 'true') { | ||
16863 | activeElement = topLevelTarget; | ||
16864 | activeElementID = topLevelTargetID; | ||
16865 | lastSelection = null; | ||
16866 | } | ||
16867 | break; | ||
16868 | case topLevelTypes.topBlur: | ||
16869 | activeElement = null; | ||
16870 | activeElementID = null; | ||
16871 | lastSelection = null; | ||
16872 | break; | ||
16873 | |||
16874 | // Don't fire the event while the user is dragging. This matches the | ||
16875 | // semantics of the native select event. | ||
16876 | case topLevelTypes.topMouseDown: | ||
16877 | mouseDown = true; | ||
16878 | break; | ||
16879 | case topLevelTypes.topContextMenu: | ||
16880 | case topLevelTypes.topMouseUp: | ||
16881 | mouseDown = false; | ||
16882 | return constructSelectEvent(nativeEvent, nativeEventTarget); | ||
16883 | |||
16884 | // Chrome and IE fire non-standard event when selection is changed (and | ||
16885 | // sometimes when it hasn't). IE's event fires out of order with respect | ||
16886 | // to key and input events on deletion, so we discard it. | ||
16887 | // | ||
16888 | // Firefox doesn't support selectionchange, so check selection status | ||
16889 | // after each key entry. The selection changes after keydown and before | ||
16890 | // keyup, but we check on keydown as well in the case of holding down a | ||
16891 | // key, when multiple keydown events are fired but only one keyup is. | ||
16892 | // This is also our approach for IE handling, for the reason above. | ||
16893 | case topLevelTypes.topSelectionChange: | ||
16894 | if (skipSelectionChangeEvent) { | ||
16895 | break; | ||
16896 | } | ||
16897 | // falls through | ||
16898 | case topLevelTypes.topKeyDown: | ||
16899 | case topLevelTypes.topKeyUp: | ||
16900 | return constructSelectEvent(nativeEvent, nativeEventTarget); | ||
16901 | } | ||
16902 | |||
16903 | return null; | ||
16904 | }, | ||
16905 | |||
16906 | didPutListener: function (id, registrationName, listener) { | ||
16907 | if (registrationName === ON_SELECT_KEY) { | ||
16908 | hasListener = true; | ||
16909 | } | ||
16910 | } | ||
16911 | }; | ||
16912 | |||
16913 | module.exports = SelectEventPlugin; | ||
16914 | |||
16915 | /***/ }, | ||
16916 | /* 133 */ | ||
16917 | /***/ function(module, exports) { | ||
16918 | |||
16919 | /** | ||
16920 | * Copyright 2013-2015, Facebook, Inc. | ||
16921 | * All rights reserved. | ||
16922 | * | ||
16923 | * This source code is licensed under the BSD-style license found in the | ||
16924 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16925 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16926 | * | ||
16927 | * @providesModule ServerReactRootIndex | ||
16928 | * @typechecks | ||
16929 | */ | ||
16930 | |||
16931 | 'use strict'; | ||
16932 | |||
16933 | /** | ||
16934 | * Size of the reactRoot ID space. We generate random numbers for React root | ||
16935 | * IDs and if there's a collision the events and DOM update system will | ||
16936 | * get confused. In the future we need a way to generate GUIDs but for | ||
16937 | * now this will work on a smaller scale. | ||
16938 | */ | ||
16939 | var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53); | ||
16940 | |||
16941 | var ServerReactRootIndex = { | ||
16942 | createReactRootIndex: function () { | ||
16943 | return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX); | ||
16944 | } | ||
16945 | }; | ||
16946 | |||
16947 | module.exports = ServerReactRootIndex; | ||
16948 | |||
16949 | /***/ }, | ||
16950 | /* 134 */ | ||
16951 | /***/ function(module, exports, __webpack_require__) { | ||
16952 | |||
16953 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
16954 | * Copyright 2013-2015, Facebook, Inc. | ||
16955 | * All rights reserved. | ||
16956 | * | ||
16957 | * This source code is licensed under the BSD-style license found in the | ||
16958 | * LICENSE file in the root directory of this source tree. An additional grant | ||
16959 | * of patent rights can be found in the PATENTS file in the same directory. | ||
16960 | * | ||
16961 | * @providesModule SimpleEventPlugin | ||
16962 | */ | ||
16963 | |||
16964 | 'use strict'; | ||
16965 | |||
16966 | var EventConstants = __webpack_require__(32); | ||
16967 | var EventListener = __webpack_require__(121); | ||
16968 | var EventPropagators = __webpack_require__(75); | ||
16969 | var ReactMount = __webpack_require__(30); | ||
16970 | var SyntheticClipboardEvent = __webpack_require__(135); | ||
16971 | var SyntheticEvent = __webpack_require__(79); | ||
16972 | var SyntheticFocusEvent = __webpack_require__(136); | ||
16973 | var SyntheticKeyboardEvent = __webpack_require__(137); | ||
16974 | var SyntheticMouseEvent = __webpack_require__(88); | ||
16975 | var SyntheticDragEvent = __webpack_require__(140); | ||
16976 | var SyntheticTouchEvent = __webpack_require__(141); | ||
16977 | var SyntheticUIEvent = __webpack_require__(89); | ||
16978 | var SyntheticWheelEvent = __webpack_require__(142); | ||
16979 | |||
16980 | var emptyFunction = __webpack_require__(17); | ||
16981 | var getEventCharCode = __webpack_require__(138); | ||
16982 | var invariant = __webpack_require__(15); | ||
16983 | var keyOf = __webpack_require__(81); | ||
16984 | |||
16985 | var topLevelTypes = EventConstants.topLevelTypes; | ||
16986 | |||
16987 | var eventTypes = { | ||
16988 | abort: { | ||
16989 | phasedRegistrationNames: { | ||
16990 | bubbled: keyOf({ onAbort: true }), | ||
16991 | captured: keyOf({ onAbortCapture: true }) | ||
16992 | } | ||
16993 | }, | ||
16994 | blur: { | ||
16995 | phasedRegistrationNames: { | ||
16996 | bubbled: keyOf({ onBlur: true }), | ||
16997 | captured: keyOf({ onBlurCapture: true }) | ||
16998 | } | ||
16999 | }, | ||
17000 | canPlay: { | ||
17001 | phasedRegistrationNames: { | ||
17002 | bubbled: keyOf({ onCanPlay: true }), | ||
17003 | captured: keyOf({ onCanPlayCapture: true }) | ||
17004 | } | ||
17005 | }, | ||
17006 | canPlayThrough: { | ||
17007 | phasedRegistrationNames: { | ||
17008 | bubbled: keyOf({ onCanPlayThrough: true }), | ||
17009 | captured: keyOf({ onCanPlayThroughCapture: true }) | ||
17010 | } | ||
17011 | }, | ||
17012 | click: { | ||
17013 | phasedRegistrationNames: { | ||
17014 | bubbled: keyOf({ onClick: true }), | ||
17015 | captured: keyOf({ onClickCapture: true }) | ||
17016 | } | ||
17017 | }, | ||
17018 | contextMenu: { | ||
17019 | phasedRegistrationNames: { | ||
17020 | bubbled: keyOf({ onContextMenu: true }), | ||
17021 | captured: keyOf({ onContextMenuCapture: true }) | ||
17022 | } | ||
17023 | }, | ||
17024 | copy: { | ||
17025 | phasedRegistrationNames: { | ||
17026 | bubbled: keyOf({ onCopy: true }), | ||
17027 | captured: keyOf({ onCopyCapture: true }) | ||
17028 | } | ||
17029 | }, | ||
17030 | cut: { | ||
17031 | phasedRegistrationNames: { | ||
17032 | bubbled: keyOf({ onCut: true }), | ||
17033 | captured: keyOf({ onCutCapture: true }) | ||
17034 | } | ||
17035 | }, | ||
17036 | doubleClick: { | ||
17037 | phasedRegistrationNames: { | ||
17038 | bubbled: keyOf({ onDoubleClick: true }), | ||
17039 | captured: keyOf({ onDoubleClickCapture: true }) | ||
17040 | } | ||
17041 | }, | ||
17042 | drag: { | ||
17043 | phasedRegistrationNames: { | ||
17044 | bubbled: keyOf({ onDrag: true }), | ||
17045 | captured: keyOf({ onDragCapture: true }) | ||
17046 | } | ||
17047 | }, | ||
17048 | dragEnd: { | ||
17049 | phasedRegistrationNames: { | ||
17050 | bubbled: keyOf({ onDragEnd: true }), | ||
17051 | captured: keyOf({ onDragEndCapture: true }) | ||
17052 | } | ||
17053 | }, | ||
17054 | dragEnter: { | ||
17055 | phasedRegistrationNames: { | ||
17056 | bubbled: keyOf({ onDragEnter: true }), | ||
17057 | captured: keyOf({ onDragEnterCapture: true }) | ||
17058 | } | ||
17059 | }, | ||
17060 | dragExit: { | ||
17061 | phasedRegistrationNames: { | ||
17062 | bubbled: keyOf({ onDragExit: true }), | ||
17063 | captured: keyOf({ onDragExitCapture: true }) | ||
17064 | } | ||
17065 | }, | ||
17066 | dragLeave: { | ||
17067 | phasedRegistrationNames: { | ||
17068 | bubbled: keyOf({ onDragLeave: true }), | ||
17069 | captured: keyOf({ onDragLeaveCapture: true }) | ||
17070 | } | ||
17071 | }, | ||
17072 | dragOver: { | ||
17073 | phasedRegistrationNames: { | ||
17074 | bubbled: keyOf({ onDragOver: true }), | ||
17075 | captured: keyOf({ onDragOverCapture: true }) | ||
17076 | } | ||
17077 | }, | ||
17078 | dragStart: { | ||
17079 | phasedRegistrationNames: { | ||
17080 | bubbled: keyOf({ onDragStart: true }), | ||
17081 | captured: keyOf({ onDragStartCapture: true }) | ||
17082 | } | ||
17083 | }, | ||
17084 | drop: { | ||
17085 | phasedRegistrationNames: { | ||
17086 | bubbled: keyOf({ onDrop: true }), | ||
17087 | captured: keyOf({ onDropCapture: true }) | ||
17088 | } | ||
17089 | }, | ||
17090 | durationChange: { | ||
17091 | phasedRegistrationNames: { | ||
17092 | bubbled: keyOf({ onDurationChange: true }), | ||
17093 | captured: keyOf({ onDurationChangeCapture: true }) | ||
17094 | } | ||
17095 | }, | ||
17096 | emptied: { | ||
17097 | phasedRegistrationNames: { | ||
17098 | bubbled: keyOf({ onEmptied: true }), | ||
17099 | captured: keyOf({ onEmptiedCapture: true }) | ||
17100 | } | ||
17101 | }, | ||
17102 | encrypted: { | ||
17103 | phasedRegistrationNames: { | ||
17104 | bubbled: keyOf({ onEncrypted: true }), | ||
17105 | captured: keyOf({ onEncryptedCapture: true }) | ||
17106 | } | ||
17107 | }, | ||
17108 | ended: { | ||
17109 | phasedRegistrationNames: { | ||
17110 | bubbled: keyOf({ onEnded: true }), | ||
17111 | captured: keyOf({ onEndedCapture: true }) | ||
17112 | } | ||
17113 | }, | ||
17114 | error: { | ||
17115 | phasedRegistrationNames: { | ||
17116 | bubbled: keyOf({ onError: true }), | ||
17117 | captured: keyOf({ onErrorCapture: true }) | ||
17118 | } | ||
17119 | }, | ||
17120 | focus: { | ||
17121 | phasedRegistrationNames: { | ||
17122 | bubbled: keyOf({ onFocus: true }), | ||
17123 | captured: keyOf({ onFocusCapture: true }) | ||
17124 | } | ||
17125 | }, | ||
17126 | input: { | ||
17127 | phasedRegistrationNames: { | ||
17128 | bubbled: keyOf({ onInput: true }), | ||
17129 | captured: keyOf({ onInputCapture: true }) | ||
17130 | } | ||
17131 | }, | ||
17132 | keyDown: { | ||
17133 | phasedRegistrationNames: { | ||
17134 | bubbled: keyOf({ onKeyDown: true }), | ||
17135 | captured: keyOf({ onKeyDownCapture: true }) | ||
17136 | } | ||
17137 | }, | ||
17138 | keyPress: { | ||
17139 | phasedRegistrationNames: { | ||
17140 | bubbled: keyOf({ onKeyPress: true }), | ||
17141 | captured: keyOf({ onKeyPressCapture: true }) | ||
17142 | } | ||
17143 | }, | ||
17144 | keyUp: { | ||
17145 | phasedRegistrationNames: { | ||
17146 | bubbled: keyOf({ onKeyUp: true }), | ||
17147 | captured: keyOf({ onKeyUpCapture: true }) | ||
17148 | } | ||
17149 | }, | ||
17150 | load: { | ||
17151 | phasedRegistrationNames: { | ||
17152 | bubbled: keyOf({ onLoad: true }), | ||
17153 | captured: keyOf({ onLoadCapture: true }) | ||
17154 | } | ||
17155 | }, | ||
17156 | loadedData: { | ||
17157 | phasedRegistrationNames: { | ||
17158 | bubbled: keyOf({ onLoadedData: true }), | ||
17159 | captured: keyOf({ onLoadedDataCapture: true }) | ||
17160 | } | ||
17161 | }, | ||
17162 | loadedMetadata: { | ||
17163 | phasedRegistrationNames: { | ||
17164 | bubbled: keyOf({ onLoadedMetadata: true }), | ||
17165 | captured: keyOf({ onLoadedMetadataCapture: true }) | ||
17166 | } | ||
17167 | }, | ||
17168 | loadStart: { | ||
17169 | phasedRegistrationNames: { | ||
17170 | bubbled: keyOf({ onLoadStart: true }), | ||
17171 | captured: keyOf({ onLoadStartCapture: true }) | ||
17172 | } | ||
17173 | }, | ||
17174 | // Note: We do not allow listening to mouseOver events. Instead, use the | ||
17175 | // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`. | ||
17176 | mouseDown: { | ||
17177 | phasedRegistrationNames: { | ||
17178 | bubbled: keyOf({ onMouseDown: true }), | ||
17179 | captured: keyOf({ onMouseDownCapture: true }) | ||
17180 | } | ||
17181 | }, | ||
17182 | mouseMove: { | ||
17183 | phasedRegistrationNames: { | ||
17184 | bubbled: keyOf({ onMouseMove: true }), | ||
17185 | captured: keyOf({ onMouseMoveCapture: true }) | ||
17186 | } | ||
17187 | }, | ||
17188 | mouseOut: { | ||
17189 | phasedRegistrationNames: { | ||
17190 | bubbled: keyOf({ onMouseOut: true }), | ||
17191 | captured: keyOf({ onMouseOutCapture: true }) | ||
17192 | } | ||
17193 | }, | ||
17194 | mouseOver: { | ||
17195 | phasedRegistrationNames: { | ||
17196 | bubbled: keyOf({ onMouseOver: true }), | ||
17197 | captured: keyOf({ onMouseOverCapture: true }) | ||
17198 | } | ||
17199 | }, | ||
17200 | mouseUp: { | ||
17201 | phasedRegistrationNames: { | ||
17202 | bubbled: keyOf({ onMouseUp: true }), | ||
17203 | captured: keyOf({ onMouseUpCapture: true }) | ||
17204 | } | ||
17205 | }, | ||
17206 | paste: { | ||
17207 | phasedRegistrationNames: { | ||
17208 | bubbled: keyOf({ onPaste: true }), | ||
17209 | captured: keyOf({ onPasteCapture: true }) | ||
17210 | } | ||
17211 | }, | ||
17212 | pause: { | ||
17213 | phasedRegistrationNames: { | ||
17214 | bubbled: keyOf({ onPause: true }), | ||
17215 | captured: keyOf({ onPauseCapture: true }) | ||
17216 | } | ||
17217 | }, | ||
17218 | play: { | ||
17219 | phasedRegistrationNames: { | ||
17220 | bubbled: keyOf({ onPlay: true }), | ||
17221 | captured: keyOf({ onPlayCapture: true }) | ||
17222 | } | ||
17223 | }, | ||
17224 | playing: { | ||
17225 | phasedRegistrationNames: { | ||
17226 | bubbled: keyOf({ onPlaying: true }), | ||
17227 | captured: keyOf({ onPlayingCapture: true }) | ||
17228 | } | ||
17229 | }, | ||
17230 | progress: { | ||
17231 | phasedRegistrationNames: { | ||
17232 | bubbled: keyOf({ onProgress: true }), | ||
17233 | captured: keyOf({ onProgressCapture: true }) | ||
17234 | } | ||
17235 | }, | ||
17236 | rateChange: { | ||
17237 | phasedRegistrationNames: { | ||
17238 | bubbled: keyOf({ onRateChange: true }), | ||
17239 | captured: keyOf({ onRateChangeCapture: true }) | ||
17240 | } | ||
17241 | }, | ||
17242 | reset: { | ||
17243 | phasedRegistrationNames: { | ||
17244 | bubbled: keyOf({ onReset: true }), | ||
17245 | captured: keyOf({ onResetCapture: true }) | ||
17246 | } | ||
17247 | }, | ||
17248 | scroll: { | ||
17249 | phasedRegistrationNames: { | ||
17250 | bubbled: keyOf({ onScroll: true }), | ||
17251 | captured: keyOf({ onScrollCapture: true }) | ||
17252 | } | ||
17253 | }, | ||
17254 | seeked: { | ||
17255 | phasedRegistrationNames: { | ||
17256 | bubbled: keyOf({ onSeeked: true }), | ||
17257 | captured: keyOf({ onSeekedCapture: true }) | ||
17258 | } | ||
17259 | }, | ||
17260 | seeking: { | ||
17261 | phasedRegistrationNames: { | ||
17262 | bubbled: keyOf({ onSeeking: true }), | ||
17263 | captured: keyOf({ onSeekingCapture: true }) | ||
17264 | } | ||
17265 | }, | ||
17266 | stalled: { | ||
17267 | phasedRegistrationNames: { | ||
17268 | bubbled: keyOf({ onStalled: true }), | ||
17269 | captured: keyOf({ onStalledCapture: true }) | ||
17270 | } | ||
17271 | }, | ||
17272 | submit: { | ||
17273 | phasedRegistrationNames: { | ||
17274 | bubbled: keyOf({ onSubmit: true }), | ||
17275 | captured: keyOf({ onSubmitCapture: true }) | ||
17276 | } | ||
17277 | }, | ||
17278 | suspend: { | ||
17279 | phasedRegistrationNames: { | ||
17280 | bubbled: keyOf({ onSuspend: true }), | ||
17281 | captured: keyOf({ onSuspendCapture: true }) | ||
17282 | } | ||
17283 | }, | ||
17284 | timeUpdate: { | ||
17285 | phasedRegistrationNames: { | ||
17286 | bubbled: keyOf({ onTimeUpdate: true }), | ||
17287 | captured: keyOf({ onTimeUpdateCapture: true }) | ||
17288 | } | ||
17289 | }, | ||
17290 | touchCancel: { | ||
17291 | phasedRegistrationNames: { | ||
17292 | bubbled: keyOf({ onTouchCancel: true }), | ||
17293 | captured: keyOf({ onTouchCancelCapture: true }) | ||
17294 | } | ||
17295 | }, | ||
17296 | touchEnd: { | ||
17297 | phasedRegistrationNames: { | ||
17298 | bubbled: keyOf({ onTouchEnd: true }), | ||
17299 | captured: keyOf({ onTouchEndCapture: true }) | ||
17300 | } | ||
17301 | }, | ||
17302 | touchMove: { | ||
17303 | phasedRegistrationNames: { | ||
17304 | bubbled: keyOf({ onTouchMove: true }), | ||
17305 | captured: keyOf({ onTouchMoveCapture: true }) | ||
17306 | } | ||
17307 | }, | ||
17308 | touchStart: { | ||
17309 | phasedRegistrationNames: { | ||
17310 | bubbled: keyOf({ onTouchStart: true }), | ||
17311 | captured: keyOf({ onTouchStartCapture: true }) | ||
17312 | } | ||
17313 | }, | ||
17314 | volumeChange: { | ||
17315 | phasedRegistrationNames: { | ||
17316 | bubbled: keyOf({ onVolumeChange: true }), | ||
17317 | captured: keyOf({ onVolumeChangeCapture: true }) | ||
17318 | } | ||
17319 | }, | ||
17320 | waiting: { | ||
17321 | phasedRegistrationNames: { | ||
17322 | bubbled: keyOf({ onWaiting: true }), | ||
17323 | captured: keyOf({ onWaitingCapture: true }) | ||
17324 | } | ||
17325 | }, | ||
17326 | wheel: { | ||
17327 | phasedRegistrationNames: { | ||
17328 | bubbled: keyOf({ onWheel: true }), | ||
17329 | captured: keyOf({ onWheelCapture: true }) | ||
17330 | } | ||
17331 | } | ||
17332 | }; | ||
17333 | |||
17334 | var topLevelEventsToDispatchConfig = { | ||
17335 | topAbort: eventTypes.abort, | ||
17336 | topBlur: eventTypes.blur, | ||
17337 | topCanPlay: eventTypes.canPlay, | ||
17338 | topCanPlayThrough: eventTypes.canPlayThrough, | ||
17339 | topClick: eventTypes.click, | ||
17340 | topContextMenu: eventTypes.contextMenu, | ||
17341 | topCopy: eventTypes.copy, | ||
17342 | topCut: eventTypes.cut, | ||
17343 | topDoubleClick: eventTypes.doubleClick, | ||
17344 | topDrag: eventTypes.drag, | ||
17345 | topDragEnd: eventTypes.dragEnd, | ||
17346 | topDragEnter: eventTypes.dragEnter, | ||
17347 | topDragExit: eventTypes.dragExit, | ||
17348 | topDragLeave: eventTypes.dragLeave, | ||
17349 | topDragOver: eventTypes.dragOver, | ||
17350 | topDragStart: eventTypes.dragStart, | ||
17351 | topDrop: eventTypes.drop, | ||
17352 | topDurationChange: eventTypes.durationChange, | ||
17353 | topEmptied: eventTypes.emptied, | ||
17354 | topEncrypted: eventTypes.encrypted, | ||
17355 | topEnded: eventTypes.ended, | ||
17356 | topError: eventTypes.error, | ||
17357 | topFocus: eventTypes.focus, | ||
17358 | topInput: eventTypes.input, | ||
17359 | topKeyDown: eventTypes.keyDown, | ||
17360 | topKeyPress: eventTypes.keyPress, | ||
17361 | topKeyUp: eventTypes.keyUp, | ||
17362 | topLoad: eventTypes.load, | ||
17363 | topLoadedData: eventTypes.loadedData, | ||
17364 | topLoadedMetadata: eventTypes.loadedMetadata, | ||
17365 | topLoadStart: eventTypes.loadStart, | ||
17366 | topMouseDown: eventTypes.mouseDown, | ||
17367 | topMouseMove: eventTypes.mouseMove, | ||
17368 | topMouseOut: eventTypes.mouseOut, | ||
17369 | topMouseOver: eventTypes.mouseOver, | ||
17370 | topMouseUp: eventTypes.mouseUp, | ||
17371 | topPaste: eventTypes.paste, | ||
17372 | topPause: eventTypes.pause, | ||
17373 | topPlay: eventTypes.play, | ||
17374 | topPlaying: eventTypes.playing, | ||
17375 | topProgress: eventTypes.progress, | ||
17376 | topRateChange: eventTypes.rateChange, | ||
17377 | topReset: eventTypes.reset, | ||
17378 | topScroll: eventTypes.scroll, | ||
17379 | topSeeked: eventTypes.seeked, | ||
17380 | topSeeking: eventTypes.seeking, | ||
17381 | topStalled: eventTypes.stalled, | ||
17382 | topSubmit: eventTypes.submit, | ||
17383 | topSuspend: eventTypes.suspend, | ||
17384 | topTimeUpdate: eventTypes.timeUpdate, | ||
17385 | topTouchCancel: eventTypes.touchCancel, | ||
17386 | topTouchEnd: eventTypes.touchEnd, | ||
17387 | topTouchMove: eventTypes.touchMove, | ||
17388 | topTouchStart: eventTypes.touchStart, | ||
17389 | topVolumeChange: eventTypes.volumeChange, | ||
17390 | topWaiting: eventTypes.waiting, | ||
17391 | topWheel: eventTypes.wheel | ||
17392 | }; | ||
17393 | |||
17394 | for (var type in topLevelEventsToDispatchConfig) { | ||
17395 | topLevelEventsToDispatchConfig[type].dependencies = [type]; | ||
17396 | } | ||
17397 | |||
17398 | var ON_CLICK_KEY = keyOf({ onClick: null }); | ||
17399 | var onClickListeners = {}; | ||
17400 | |||
17401 | var SimpleEventPlugin = { | ||
17402 | |||
17403 | eventTypes: eventTypes, | ||
17404 | |||
17405 | /** | ||
17406 | * @param {string} topLevelType Record from `EventConstants`. | ||
17407 | * @param {DOMEventTarget} topLevelTarget The listening component root node. | ||
17408 | * @param {string} topLevelTargetID ID of `topLevelTarget`. | ||
17409 | * @param {object} nativeEvent Native browser event. | ||
17410 | * @return {*} An accumulation of synthetic events. | ||
17411 | * @see {EventPluginHub.extractEvents} | ||
17412 | */ | ||
17413 | extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) { | ||
17414 | var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType]; | ||
17415 | if (!dispatchConfig) { | ||
17416 | return null; | ||
17417 | } | ||
17418 | var EventConstructor; | ||
17419 | switch (topLevelType) { | ||
17420 | case topLevelTypes.topAbort: | ||
17421 | case topLevelTypes.topCanPlay: | ||
17422 | case topLevelTypes.topCanPlayThrough: | ||
17423 | case topLevelTypes.topDurationChange: | ||
17424 | case topLevelTypes.topEmptied: | ||
17425 | case topLevelTypes.topEncrypted: | ||
17426 | case topLevelTypes.topEnded: | ||
17427 | case topLevelTypes.topError: | ||
17428 | case topLevelTypes.topInput: | ||
17429 | case topLevelTypes.topLoad: | ||
17430 | case topLevelTypes.topLoadedData: | ||
17431 | case topLevelTypes.topLoadedMetadata: | ||
17432 | case topLevelTypes.topLoadStart: | ||
17433 | case topLevelTypes.topPause: | ||
17434 | case topLevelTypes.topPlay: | ||
17435 | case topLevelTypes.topPlaying: | ||
17436 | case topLevelTypes.topProgress: | ||
17437 | case topLevelTypes.topRateChange: | ||
17438 | case topLevelTypes.topReset: | ||
17439 | case topLevelTypes.topSeeked: | ||
17440 | case topLevelTypes.topSeeking: | ||
17441 | case topLevelTypes.topStalled: | ||
17442 | case topLevelTypes.topSubmit: | ||
17443 | case topLevelTypes.topSuspend: | ||
17444 | case topLevelTypes.topTimeUpdate: | ||
17445 | case topLevelTypes.topVolumeChange: | ||
17446 | case topLevelTypes.topWaiting: | ||
17447 | // HTML Events | ||
17448 | // @see http://www.w3.org/TR/html5/index.html#events-0 | ||
17449 | EventConstructor = SyntheticEvent; | ||
17450 | break; | ||
17451 | case topLevelTypes.topKeyPress: | ||
17452 | // FireFox creates a keypress event for function keys too. This removes | ||
17453 | // the unwanted keypress events. Enter is however both printable and | ||
17454 | // non-printable. One would expect Tab to be as well (but it isn't). | ||
17455 | if (getEventCharCode(nativeEvent) === 0) { | ||
17456 | return null; | ||
17457 | } | ||
17458 | /* falls through */ | ||
17459 | case topLevelTypes.topKeyDown: | ||
17460 | case topLevelTypes.topKeyUp: | ||
17461 | EventConstructor = SyntheticKeyboardEvent; | ||
17462 | break; | ||
17463 | case topLevelTypes.topBlur: | ||
17464 | case topLevelTypes.topFocus: | ||
17465 | EventConstructor = SyntheticFocusEvent; | ||
17466 | break; | ||
17467 | case topLevelTypes.topClick: | ||
17468 | // Firefox creates a click event on right mouse clicks. This removes the | ||
17469 | // unwanted click events. | ||
17470 | if (nativeEvent.button === 2) { | ||
17471 | return null; | ||
17472 | } | ||
17473 | /* falls through */ | ||
17474 | case topLevelTypes.topContextMenu: | ||
17475 | case topLevelTypes.topDoubleClick: | ||
17476 | case topLevelTypes.topMouseDown: | ||
17477 | case topLevelTypes.topMouseMove: | ||
17478 | case topLevelTypes.topMouseOut: | ||
17479 | case topLevelTypes.topMouseOver: | ||
17480 | case topLevelTypes.topMouseUp: | ||
17481 | EventConstructor = SyntheticMouseEvent; | ||
17482 | break; | ||
17483 | case topLevelTypes.topDrag: | ||
17484 | case topLevelTypes.topDragEnd: | ||
17485 | case topLevelTypes.topDragEnter: | ||
17486 | case topLevelTypes.topDragExit: | ||
17487 | case topLevelTypes.topDragLeave: | ||
17488 | case topLevelTypes.topDragOver: | ||
17489 | case topLevelTypes.topDragStart: | ||
17490 | case topLevelTypes.topDrop: | ||
17491 | EventConstructor = SyntheticDragEvent; | ||
17492 | break; | ||
17493 | case topLevelTypes.topTouchCancel: | ||
17494 | case topLevelTypes.topTouchEnd: | ||
17495 | case topLevelTypes.topTouchMove: | ||
17496 | case topLevelTypes.topTouchStart: | ||
17497 | EventConstructor = SyntheticTouchEvent; | ||
17498 | break; | ||
17499 | case topLevelTypes.topScroll: | ||
17500 | EventConstructor = SyntheticUIEvent; | ||
17501 | break; | ||
17502 | case topLevelTypes.topWheel: | ||
17503 | EventConstructor = SyntheticWheelEvent; | ||
17504 | break; | ||
17505 | case topLevelTypes.topCopy: | ||
17506 | case topLevelTypes.topCut: | ||
17507 | case topLevelTypes.topPaste: | ||
17508 | EventConstructor = SyntheticClipboardEvent; | ||
17509 | break; | ||
17510 | } | ||
17511 | !EventConstructor ? process.env.NODE_ENV !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : invariant(false) : undefined; | ||
17512 | var event = EventConstructor.getPooled(dispatchConfig, topLevelTargetID, nativeEvent, nativeEventTarget); | ||
17513 | EventPropagators.accumulateTwoPhaseDispatches(event); | ||
17514 | return event; | ||
17515 | }, | ||
17516 | |||
17517 | didPutListener: function (id, registrationName, listener) { | ||
17518 | // Mobile Safari does not fire properly bubble click events on | ||
17519 | // non-interactive elements, which means delegated click listeners do not | ||
17520 | // fire. The workaround for this bug involves attaching an empty click | ||
17521 | // listener on the target node. | ||
17522 | if (registrationName === ON_CLICK_KEY) { | ||
17523 | var node = ReactMount.getNode(id); | ||
17524 | if (!onClickListeners[id]) { | ||
17525 | onClickListeners[id] = EventListener.listen(node, 'click', emptyFunction); | ||
17526 | } | ||
17527 | } | ||
17528 | }, | ||
17529 | |||
17530 | willDeleteListener: function (id, registrationName) { | ||
17531 | if (registrationName === ON_CLICK_KEY) { | ||
17532 | onClickListeners[id].remove(); | ||
17533 | delete onClickListeners[id]; | ||
17534 | } | ||
17535 | } | ||
17536 | |||
17537 | }; | ||
17538 | |||
17539 | module.exports = SimpleEventPlugin; | ||
17540 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
17541 | |||
17542 | /***/ }, | ||
17543 | /* 135 */ | ||
17544 | /***/ function(module, exports, __webpack_require__) { | ||
17545 | |||
17546 | /** | ||
17547 | * Copyright 2013-2015, Facebook, Inc. | ||
17548 | * All rights reserved. | ||
17549 | * | ||
17550 | * This source code is licensed under the BSD-style license found in the | ||
17551 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17552 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17553 | * | ||
17554 | * @providesModule SyntheticClipboardEvent | ||
17555 | * @typechecks static-only | ||
17556 | */ | ||
17557 | |||
17558 | 'use strict'; | ||
17559 | |||
17560 | var SyntheticEvent = __webpack_require__(79); | ||
17561 | |||
17562 | /** | ||
17563 | * @interface Event | ||
17564 | * @see http://www.w3.org/TR/clipboard-apis/ | ||
17565 | */ | ||
17566 | var ClipboardEventInterface = { | ||
17567 | clipboardData: function (event) { | ||
17568 | return 'clipboardData' in event ? event.clipboardData : window.clipboardData; | ||
17569 | } | ||
17570 | }; | ||
17571 | |||
17572 | /** | ||
17573 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
17574 | * @param {string} dispatchMarker Marker identifying the event target. | ||
17575 | * @param {object} nativeEvent Native browser event. | ||
17576 | * @extends {SyntheticUIEvent} | ||
17577 | */ | ||
17578 | function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
17579 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
17580 | } | ||
17581 | |||
17582 | SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface); | ||
17583 | |||
17584 | module.exports = SyntheticClipboardEvent; | ||
17585 | |||
17586 | /***/ }, | ||
17587 | /* 136 */ | ||
17588 | /***/ function(module, exports, __webpack_require__) { | ||
17589 | |||
17590 | /** | ||
17591 | * Copyright 2013-2015, Facebook, Inc. | ||
17592 | * All rights reserved. | ||
17593 | * | ||
17594 | * This source code is licensed under the BSD-style license found in the | ||
17595 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17596 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17597 | * | ||
17598 | * @providesModule SyntheticFocusEvent | ||
17599 | * @typechecks static-only | ||
17600 | */ | ||
17601 | |||
17602 | 'use strict'; | ||
17603 | |||
17604 | var SyntheticUIEvent = __webpack_require__(89); | ||
17605 | |||
17606 | /** | ||
17607 | * @interface FocusEvent | ||
17608 | * @see http://www.w3.org/TR/DOM-Level-3-Events/ | ||
17609 | */ | ||
17610 | var FocusEventInterface = { | ||
17611 | relatedTarget: null | ||
17612 | }; | ||
17613 | |||
17614 | /** | ||
17615 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
17616 | * @param {string} dispatchMarker Marker identifying the event target. | ||
17617 | * @param {object} nativeEvent Native browser event. | ||
17618 | * @extends {SyntheticUIEvent} | ||
17619 | */ | ||
17620 | function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
17621 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
17622 | } | ||
17623 | |||
17624 | SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface); | ||
17625 | |||
17626 | module.exports = SyntheticFocusEvent; | ||
17627 | |||
17628 | /***/ }, | ||
17629 | /* 137 */ | ||
17630 | /***/ function(module, exports, __webpack_require__) { | ||
17631 | |||
17632 | /** | ||
17633 | * Copyright 2013-2015, Facebook, Inc. | ||
17634 | * All rights reserved. | ||
17635 | * | ||
17636 | * This source code is licensed under the BSD-style license found in the | ||
17637 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17638 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17639 | * | ||
17640 | * @providesModule SyntheticKeyboardEvent | ||
17641 | * @typechecks static-only | ||
17642 | */ | ||
17643 | |||
17644 | 'use strict'; | ||
17645 | |||
17646 | var SyntheticUIEvent = __webpack_require__(89); | ||
17647 | |||
17648 | var getEventCharCode = __webpack_require__(138); | ||
17649 | var getEventKey = __webpack_require__(139); | ||
17650 | var getEventModifierState = __webpack_require__(90); | ||
17651 | |||
17652 | /** | ||
17653 | * @interface KeyboardEvent | ||
17654 | * @see http://www.w3.org/TR/DOM-Level-3-Events/ | ||
17655 | */ | ||
17656 | var KeyboardEventInterface = { | ||
17657 | key: getEventKey, | ||
17658 | location: null, | ||
17659 | ctrlKey: null, | ||
17660 | shiftKey: null, | ||
17661 | altKey: null, | ||
17662 | metaKey: null, | ||
17663 | repeat: null, | ||
17664 | locale: null, | ||
17665 | getModifierState: getEventModifierState, | ||
17666 | // Legacy Interface | ||
17667 | charCode: function (event) { | ||
17668 | // `charCode` is the result of a KeyPress event and represents the value of | ||
17669 | // the actual printable character. | ||
17670 | |||
17671 | // KeyPress is deprecated, but its replacement is not yet final and not | ||
17672 | // implemented in any major browser. Only KeyPress has charCode. | ||
17673 | if (event.type === 'keypress') { | ||
17674 | return getEventCharCode(event); | ||
17675 | } | ||
17676 | return 0; | ||
17677 | }, | ||
17678 | keyCode: function (event) { | ||
17679 | // `keyCode` is the result of a KeyDown/Up event and represents the value of | ||
17680 | // physical keyboard key. | ||
17681 | |||
17682 | // The actual meaning of the value depends on the users' keyboard layout | ||
17683 | // which cannot be detected. Assuming that it is a US keyboard layout | ||
17684 | // provides a surprisingly accurate mapping for US and European users. | ||
17685 | // Due to this, it is left to the user to implement at this time. | ||
17686 | if (event.type === 'keydown' || event.type === 'keyup') { | ||
17687 | return event.keyCode; | ||
17688 | } | ||
17689 | return 0; | ||
17690 | }, | ||
17691 | which: function (event) { | ||
17692 | // `which` is an alias for either `keyCode` or `charCode` depending on the | ||
17693 | // type of the event. | ||
17694 | if (event.type === 'keypress') { | ||
17695 | return getEventCharCode(event); | ||
17696 | } | ||
17697 | if (event.type === 'keydown' || event.type === 'keyup') { | ||
17698 | return event.keyCode; | ||
17699 | } | ||
17700 | return 0; | ||
17701 | } | ||
17702 | }; | ||
17703 | |||
17704 | /** | ||
17705 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
17706 | * @param {string} dispatchMarker Marker identifying the event target. | ||
17707 | * @param {object} nativeEvent Native browser event. | ||
17708 | * @extends {SyntheticUIEvent} | ||
17709 | */ | ||
17710 | function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
17711 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
17712 | } | ||
17713 | |||
17714 | SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface); | ||
17715 | |||
17716 | module.exports = SyntheticKeyboardEvent; | ||
17717 | |||
17718 | /***/ }, | ||
17719 | /* 138 */ | ||
17720 | /***/ function(module, exports) { | ||
17721 | |||
17722 | /** | ||
17723 | * Copyright 2013-2015, Facebook, Inc. | ||
17724 | * All rights reserved. | ||
17725 | * | ||
17726 | * This source code is licensed under the BSD-style license found in the | ||
17727 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17728 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17729 | * | ||
17730 | * @providesModule getEventCharCode | ||
17731 | * @typechecks static-only | ||
17732 | */ | ||
17733 | |||
17734 | 'use strict'; | ||
17735 | |||
17736 | /** | ||
17737 | * `charCode` represents the actual "character code" and is safe to use with | ||
17738 | * `String.fromCharCode`. As such, only keys that correspond to printable | ||
17739 | * characters produce a valid `charCode`, the only exception to this is Enter. | ||
17740 | * The Tab-key is considered non-printable and does not have a `charCode`, | ||
17741 | * presumably because it does not produce a tab-character in browsers. | ||
17742 | * | ||
17743 | * @param {object} nativeEvent Native browser event. | ||
17744 | * @return {number} Normalized `charCode` property. | ||
17745 | */ | ||
17746 | function getEventCharCode(nativeEvent) { | ||
17747 | var charCode; | ||
17748 | var keyCode = nativeEvent.keyCode; | ||
17749 | |||
17750 | if ('charCode' in nativeEvent) { | ||
17751 | charCode = nativeEvent.charCode; | ||
17752 | |||
17753 | // FF does not set `charCode` for the Enter-key, check against `keyCode`. | ||
17754 | if (charCode === 0 && keyCode === 13) { | ||
17755 | charCode = 13; | ||
17756 | } | ||
17757 | } else { | ||
17758 | // IE8 does not implement `charCode`, but `keyCode` has the correct value. | ||
17759 | charCode = keyCode; | ||
17760 | } | ||
17761 | |||
17762 | // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. | ||
17763 | // Must not discard the (non-)printable Enter-key. | ||
17764 | if (charCode >= 32 || charCode === 13) { | ||
17765 | return charCode; | ||
17766 | } | ||
17767 | |||
17768 | return 0; | ||
17769 | } | ||
17770 | |||
17771 | module.exports = getEventCharCode; | ||
17772 | |||
17773 | /***/ }, | ||
17774 | /* 139 */ | ||
17775 | /***/ function(module, exports, __webpack_require__) { | ||
17776 | |||
17777 | /** | ||
17778 | * Copyright 2013-2015, Facebook, Inc. | ||
17779 | * All rights reserved. | ||
17780 | * | ||
17781 | * This source code is licensed under the BSD-style license found in the | ||
17782 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17783 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17784 | * | ||
17785 | * @providesModule getEventKey | ||
17786 | * @typechecks static-only | ||
17787 | */ | ||
17788 | |||
17789 | 'use strict'; | ||
17790 | |||
17791 | var getEventCharCode = __webpack_require__(138); | ||
17792 | |||
17793 | /** | ||
17794 | * Normalization of deprecated HTML5 `key` values | ||
17795 | * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names | ||
17796 | */ | ||
17797 | var normalizeKey = { | ||
17798 | 'Esc': 'Escape', | ||
17799 | 'Spacebar': ' ', | ||
17800 | 'Left': 'ArrowLeft', | ||
17801 | 'Up': 'ArrowUp', | ||
17802 | 'Right': 'ArrowRight', | ||
17803 | 'Down': 'ArrowDown', | ||
17804 | 'Del': 'Delete', | ||
17805 | 'Win': 'OS', | ||
17806 | 'Menu': 'ContextMenu', | ||
17807 | 'Apps': 'ContextMenu', | ||
17808 | 'Scroll': 'ScrollLock', | ||
17809 | 'MozPrintableKey': 'Unidentified' | ||
17810 | }; | ||
17811 | |||
17812 | /** | ||
17813 | * Translation from legacy `keyCode` to HTML5 `key` | ||
17814 | * Only special keys supported, all others depend on keyboard layout or browser | ||
17815 | * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names | ||
17816 | */ | ||
17817 | var translateToKey = { | ||
17818 | 8: 'Backspace', | ||
17819 | 9: 'Tab', | ||
17820 | 12: 'Clear', | ||
17821 | 13: 'Enter', | ||
17822 | 16: 'Shift', | ||
17823 | 17: 'Control', | ||
17824 | 18: 'Alt', | ||
17825 | 19: 'Pause', | ||
17826 | 20: 'CapsLock', | ||
17827 | 27: 'Escape', | ||
17828 | 32: ' ', | ||
17829 | 33: 'PageUp', | ||
17830 | 34: 'PageDown', | ||
17831 | 35: 'End', | ||
17832 | 36: 'Home', | ||
17833 | 37: 'ArrowLeft', | ||
17834 | 38: 'ArrowUp', | ||
17835 | 39: 'ArrowRight', | ||
17836 | 40: 'ArrowDown', | ||
17837 | 45: 'Insert', | ||
17838 | 46: 'Delete', | ||
17839 | 112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6', | ||
17840 | 118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12', | ||
17841 | 144: 'NumLock', | ||
17842 | 145: 'ScrollLock', | ||
17843 | 224: 'Meta' | ||
17844 | }; | ||
17845 | |||
17846 | /** | ||
17847 | * @param {object} nativeEvent Native browser event. | ||
17848 | * @return {string} Normalized `key` property. | ||
17849 | */ | ||
17850 | function getEventKey(nativeEvent) { | ||
17851 | if (nativeEvent.key) { | ||
17852 | // Normalize inconsistent values reported by browsers due to | ||
17853 | // implementations of a working draft specification. | ||
17854 | |||
17855 | // FireFox implements `key` but returns `MozPrintableKey` for all | ||
17856 | // printable characters (normalized to `Unidentified`), ignore it. | ||
17857 | var key = normalizeKey[nativeEvent.key] || nativeEvent.key; | ||
17858 | if (key !== 'Unidentified') { | ||
17859 | return key; | ||
17860 | } | ||
17861 | } | ||
17862 | |||
17863 | // Browser does not implement `key`, polyfill as much of it as we can. | ||
17864 | if (nativeEvent.type === 'keypress') { | ||
17865 | var charCode = getEventCharCode(nativeEvent); | ||
17866 | |||
17867 | // The enter-key is technically both printable and non-printable and can | ||
17868 | // thus be captured by `keypress`, no other non-printable key should. | ||
17869 | return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); | ||
17870 | } | ||
17871 | if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { | ||
17872 | // While user keyboard layout determines the actual meaning of each | ||
17873 | // `keyCode` value, almost all function keys have a universal value. | ||
17874 | return translateToKey[nativeEvent.keyCode] || 'Unidentified'; | ||
17875 | } | ||
17876 | return ''; | ||
17877 | } | ||
17878 | |||
17879 | module.exports = getEventKey; | ||
17880 | |||
17881 | /***/ }, | ||
17882 | /* 140 */ | ||
17883 | /***/ function(module, exports, __webpack_require__) { | ||
17884 | |||
17885 | /** | ||
17886 | * Copyright 2013-2015, Facebook, Inc. | ||
17887 | * All rights reserved. | ||
17888 | * | ||
17889 | * This source code is licensed under the BSD-style license found in the | ||
17890 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17891 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17892 | * | ||
17893 | * @providesModule SyntheticDragEvent | ||
17894 | * @typechecks static-only | ||
17895 | */ | ||
17896 | |||
17897 | 'use strict'; | ||
17898 | |||
17899 | var SyntheticMouseEvent = __webpack_require__(88); | ||
17900 | |||
17901 | /** | ||
17902 | * @interface DragEvent | ||
17903 | * @see http://www.w3.org/TR/DOM-Level-3-Events/ | ||
17904 | */ | ||
17905 | var DragEventInterface = { | ||
17906 | dataTransfer: null | ||
17907 | }; | ||
17908 | |||
17909 | /** | ||
17910 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
17911 | * @param {string} dispatchMarker Marker identifying the event target. | ||
17912 | * @param {object} nativeEvent Native browser event. | ||
17913 | * @extends {SyntheticUIEvent} | ||
17914 | */ | ||
17915 | function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
17916 | SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
17917 | } | ||
17918 | |||
17919 | SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface); | ||
17920 | |||
17921 | module.exports = SyntheticDragEvent; | ||
17922 | |||
17923 | /***/ }, | ||
17924 | /* 141 */ | ||
17925 | /***/ function(module, exports, __webpack_require__) { | ||
17926 | |||
17927 | /** | ||
17928 | * Copyright 2013-2015, Facebook, Inc. | ||
17929 | * All rights reserved. | ||
17930 | * | ||
17931 | * This source code is licensed under the BSD-style license found in the | ||
17932 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17933 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17934 | * | ||
17935 | * @providesModule SyntheticTouchEvent | ||
17936 | * @typechecks static-only | ||
17937 | */ | ||
17938 | |||
17939 | 'use strict'; | ||
17940 | |||
17941 | var SyntheticUIEvent = __webpack_require__(89); | ||
17942 | |||
17943 | var getEventModifierState = __webpack_require__(90); | ||
17944 | |||
17945 | /** | ||
17946 | * @interface TouchEvent | ||
17947 | * @see http://www.w3.org/TR/touch-events/ | ||
17948 | */ | ||
17949 | var TouchEventInterface = { | ||
17950 | touches: null, | ||
17951 | targetTouches: null, | ||
17952 | changedTouches: null, | ||
17953 | altKey: null, | ||
17954 | metaKey: null, | ||
17955 | ctrlKey: null, | ||
17956 | shiftKey: null, | ||
17957 | getModifierState: getEventModifierState | ||
17958 | }; | ||
17959 | |||
17960 | /** | ||
17961 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
17962 | * @param {string} dispatchMarker Marker identifying the event target. | ||
17963 | * @param {object} nativeEvent Native browser event. | ||
17964 | * @extends {SyntheticUIEvent} | ||
17965 | */ | ||
17966 | function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
17967 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
17968 | } | ||
17969 | |||
17970 | SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface); | ||
17971 | |||
17972 | module.exports = SyntheticTouchEvent; | ||
17973 | |||
17974 | /***/ }, | ||
17975 | /* 142 */ | ||
17976 | /***/ function(module, exports, __webpack_require__) { | ||
17977 | |||
17978 | /** | ||
17979 | * Copyright 2013-2015, Facebook, Inc. | ||
17980 | * All rights reserved. | ||
17981 | * | ||
17982 | * This source code is licensed under the BSD-style license found in the | ||
17983 | * LICENSE file in the root directory of this source tree. An additional grant | ||
17984 | * of patent rights can be found in the PATENTS file in the same directory. | ||
17985 | * | ||
17986 | * @providesModule SyntheticWheelEvent | ||
17987 | * @typechecks static-only | ||
17988 | */ | ||
17989 | |||
17990 | 'use strict'; | ||
17991 | |||
17992 | var SyntheticMouseEvent = __webpack_require__(88); | ||
17993 | |||
17994 | /** | ||
17995 | * @interface WheelEvent | ||
17996 | * @see http://www.w3.org/TR/DOM-Level-3-Events/ | ||
17997 | */ | ||
17998 | var WheelEventInterface = { | ||
17999 | deltaX: function (event) { | ||
18000 | return 'deltaX' in event ? event.deltaX : | ||
18001 | // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). | ||
18002 | 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; | ||
18003 | }, | ||
18004 | deltaY: function (event) { | ||
18005 | return 'deltaY' in event ? event.deltaY : | ||
18006 | // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). | ||
18007 | 'wheelDeltaY' in event ? -event.wheelDeltaY : | ||
18008 | // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). | ||
18009 | 'wheelDelta' in event ? -event.wheelDelta : 0; | ||
18010 | }, | ||
18011 | deltaZ: null, | ||
18012 | |||
18013 | // Browsers without "deltaMode" is reporting in raw wheel delta where one | ||
18014 | // notch on the scroll is always +/- 120, roughly equivalent to pixels. | ||
18015 | // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or | ||
18016 | // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. | ||
18017 | deltaMode: null | ||
18018 | }; | ||
18019 | |||
18020 | /** | ||
18021 | * @param {object} dispatchConfig Configuration used to dispatch this event. | ||
18022 | * @param {string} dispatchMarker Marker identifying the event target. | ||
18023 | * @param {object} nativeEvent Native browser event. | ||
18024 | * @extends {SyntheticMouseEvent} | ||
18025 | */ | ||
18026 | function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | ||
18027 | SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | ||
18028 | } | ||
18029 | |||
18030 | SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface); | ||
18031 | |||
18032 | module.exports = SyntheticWheelEvent; | ||
18033 | |||
18034 | /***/ }, | ||
18035 | /* 143 */ | ||
18036 | /***/ function(module, exports, __webpack_require__) { | ||
18037 | |||
18038 | /** | ||
18039 | * Copyright 2013-2015, Facebook, Inc. | ||
18040 | * All rights reserved. | ||
18041 | * | ||
18042 | * This source code is licensed under the BSD-style license found in the | ||
18043 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18044 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18045 | * | ||
18046 | * @providesModule SVGDOMPropertyConfig | ||
18047 | */ | ||
18048 | |||
18049 | 'use strict'; | ||
18050 | |||
18051 | var DOMProperty = __webpack_require__(25); | ||
18052 | |||
18053 | var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE; | ||
18054 | |||
18055 | var NS = { | ||
18056 | xlink: 'http://www.w3.org/1999/xlink', | ||
18057 | xml: 'http://www.w3.org/XML/1998/namespace' | ||
18058 | }; | ||
18059 | |||
18060 | var SVGDOMPropertyConfig = { | ||
18061 | Properties: { | ||
18062 | clipPath: MUST_USE_ATTRIBUTE, | ||
18063 | cx: MUST_USE_ATTRIBUTE, | ||
18064 | cy: MUST_USE_ATTRIBUTE, | ||
18065 | d: MUST_USE_ATTRIBUTE, | ||
18066 | dx: MUST_USE_ATTRIBUTE, | ||
18067 | dy: MUST_USE_ATTRIBUTE, | ||
18068 | fill: MUST_USE_ATTRIBUTE, | ||
18069 | fillOpacity: MUST_USE_ATTRIBUTE, | ||
18070 | fontFamily: MUST_USE_ATTRIBUTE, | ||
18071 | fontSize: MUST_USE_ATTRIBUTE, | ||
18072 | fx: MUST_USE_ATTRIBUTE, | ||
18073 | fy: MUST_USE_ATTRIBUTE, | ||
18074 | gradientTransform: MUST_USE_ATTRIBUTE, | ||
18075 | gradientUnits: MUST_USE_ATTRIBUTE, | ||
18076 | markerEnd: MUST_USE_ATTRIBUTE, | ||
18077 | markerMid: MUST_USE_ATTRIBUTE, | ||
18078 | markerStart: MUST_USE_ATTRIBUTE, | ||
18079 | offset: MUST_USE_ATTRIBUTE, | ||
18080 | opacity: MUST_USE_ATTRIBUTE, | ||
18081 | patternContentUnits: MUST_USE_ATTRIBUTE, | ||
18082 | patternUnits: MUST_USE_ATTRIBUTE, | ||
18083 | points: MUST_USE_ATTRIBUTE, | ||
18084 | preserveAspectRatio: MUST_USE_ATTRIBUTE, | ||
18085 | r: MUST_USE_ATTRIBUTE, | ||
18086 | rx: MUST_USE_ATTRIBUTE, | ||
18087 | ry: MUST_USE_ATTRIBUTE, | ||
18088 | spreadMethod: MUST_USE_ATTRIBUTE, | ||
18089 | stopColor: MUST_USE_ATTRIBUTE, | ||
18090 | stopOpacity: MUST_USE_ATTRIBUTE, | ||
18091 | stroke: MUST_USE_ATTRIBUTE, | ||
18092 | strokeDasharray: MUST_USE_ATTRIBUTE, | ||
18093 | strokeLinecap: MUST_USE_ATTRIBUTE, | ||
18094 | strokeOpacity: MUST_USE_ATTRIBUTE, | ||
18095 | strokeWidth: MUST_USE_ATTRIBUTE, | ||
18096 | textAnchor: MUST_USE_ATTRIBUTE, | ||
18097 | transform: MUST_USE_ATTRIBUTE, | ||
18098 | version: MUST_USE_ATTRIBUTE, | ||
18099 | viewBox: MUST_USE_ATTRIBUTE, | ||
18100 | x1: MUST_USE_ATTRIBUTE, | ||
18101 | x2: MUST_USE_ATTRIBUTE, | ||
18102 | x: MUST_USE_ATTRIBUTE, | ||
18103 | xlinkActuate: MUST_USE_ATTRIBUTE, | ||
18104 | xlinkArcrole: MUST_USE_ATTRIBUTE, | ||
18105 | xlinkHref: MUST_USE_ATTRIBUTE, | ||
18106 | xlinkRole: MUST_USE_ATTRIBUTE, | ||
18107 | xlinkShow: MUST_USE_ATTRIBUTE, | ||
18108 | xlinkTitle: MUST_USE_ATTRIBUTE, | ||
18109 | xlinkType: MUST_USE_ATTRIBUTE, | ||
18110 | xmlBase: MUST_USE_ATTRIBUTE, | ||
18111 | xmlLang: MUST_USE_ATTRIBUTE, | ||
18112 | xmlSpace: MUST_USE_ATTRIBUTE, | ||
18113 | y1: MUST_USE_ATTRIBUTE, | ||
18114 | y2: MUST_USE_ATTRIBUTE, | ||
18115 | y: MUST_USE_ATTRIBUTE | ||
18116 | }, | ||
18117 | DOMAttributeNamespaces: { | ||
18118 | xlinkActuate: NS.xlink, | ||
18119 | xlinkArcrole: NS.xlink, | ||
18120 | xlinkHref: NS.xlink, | ||
18121 | xlinkRole: NS.xlink, | ||
18122 | xlinkShow: NS.xlink, | ||
18123 | xlinkTitle: NS.xlink, | ||
18124 | xlinkType: NS.xlink, | ||
18125 | xmlBase: NS.xml, | ||
18126 | xmlLang: NS.xml, | ||
18127 | xmlSpace: NS.xml | ||
18128 | }, | ||
18129 | DOMAttributeNames: { | ||
18130 | clipPath: 'clip-path', | ||
18131 | fillOpacity: 'fill-opacity', | ||
18132 | fontFamily: 'font-family', | ||
18133 | fontSize: 'font-size', | ||
18134 | gradientTransform: 'gradientTransform', | ||
18135 | gradientUnits: 'gradientUnits', | ||
18136 | markerEnd: 'marker-end', | ||
18137 | markerMid: 'marker-mid', | ||
18138 | markerStart: 'marker-start', | ||
18139 | patternContentUnits: 'patternContentUnits', | ||
18140 | patternUnits: 'patternUnits', | ||
18141 | preserveAspectRatio: 'preserveAspectRatio', | ||
18142 | spreadMethod: 'spreadMethod', | ||
18143 | stopColor: 'stop-color', | ||
18144 | stopOpacity: 'stop-opacity', | ||
18145 | strokeDasharray: 'stroke-dasharray', | ||
18146 | strokeLinecap: 'stroke-linecap', | ||
18147 | strokeOpacity: 'stroke-opacity', | ||
18148 | strokeWidth: 'stroke-width', | ||
18149 | textAnchor: 'text-anchor', | ||
18150 | viewBox: 'viewBox', | ||
18151 | xlinkActuate: 'xlink:actuate', | ||
18152 | xlinkArcrole: 'xlink:arcrole', | ||
18153 | xlinkHref: 'xlink:href', | ||
18154 | xlinkRole: 'xlink:role', | ||
18155 | xlinkShow: 'xlink:show', | ||
18156 | xlinkTitle: 'xlink:title', | ||
18157 | xlinkType: 'xlink:type', | ||
18158 | xmlBase: 'xml:base', | ||
18159 | xmlLang: 'xml:lang', | ||
18160 | xmlSpace: 'xml:space' | ||
18161 | } | ||
18162 | }; | ||
18163 | |||
18164 | module.exports = SVGDOMPropertyConfig; | ||
18165 | |||
18166 | /***/ }, | ||
18167 | /* 144 */ | ||
18168 | /***/ function(module, exports, __webpack_require__) { | ||
18169 | |||
18170 | /** | ||
18171 | * Copyright 2013-2015, Facebook, Inc. | ||
18172 | * All rights reserved. | ||
18173 | * | ||
18174 | * This source code is licensed under the BSD-style license found in the | ||
18175 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18176 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18177 | * | ||
18178 | * @providesModule ReactDefaultPerf | ||
18179 | * @typechecks static-only | ||
18180 | */ | ||
18181 | |||
18182 | 'use strict'; | ||
18183 | |||
18184 | var DOMProperty = __webpack_require__(25); | ||
18185 | var ReactDefaultPerfAnalysis = __webpack_require__(145); | ||
18186 | var ReactMount = __webpack_require__(30); | ||
18187 | var ReactPerf = __webpack_require__(20); | ||
18188 | |||
18189 | var performanceNow = __webpack_require__(146); | ||
18190 | |||
18191 | function roundFloat(val) { | ||
18192 | return Math.floor(val * 100) / 100; | ||
18193 | } | ||
18194 | |||
18195 | function addValue(obj, key, val) { | ||
18196 | obj[key] = (obj[key] || 0) + val; | ||
18197 | } | ||
18198 | |||
18199 | var ReactDefaultPerf = { | ||
18200 | _allMeasurements: [], // last item in the list is the current one | ||
18201 | _mountStack: [0], | ||
18202 | _injected: false, | ||
18203 | |||
18204 | start: function () { | ||
18205 | if (!ReactDefaultPerf._injected) { | ||
18206 | ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure); | ||
18207 | } | ||
18208 | |||
18209 | ReactDefaultPerf._allMeasurements.length = 0; | ||
18210 | ReactPerf.enableMeasure = true; | ||
18211 | }, | ||
18212 | |||
18213 | stop: function () { | ||
18214 | ReactPerf.enableMeasure = false; | ||
18215 | }, | ||
18216 | |||
18217 | getLastMeasurements: function () { | ||
18218 | return ReactDefaultPerf._allMeasurements; | ||
18219 | }, | ||
18220 | |||
18221 | printExclusive: function (measurements) { | ||
18222 | measurements = measurements || ReactDefaultPerf._allMeasurements; | ||
18223 | var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements); | ||
18224 | console.table(summary.map(function (item) { | ||
18225 | return { | ||
18226 | 'Component class name': item.componentName, | ||
18227 | 'Total inclusive time (ms)': roundFloat(item.inclusive), | ||
18228 | 'Exclusive mount time (ms)': roundFloat(item.exclusive), | ||
18229 | 'Exclusive render time (ms)': roundFloat(item.render), | ||
18230 | 'Mount time per instance (ms)': roundFloat(item.exclusive / item.count), | ||
18231 | 'Render time per instance (ms)': roundFloat(item.render / item.count), | ||
18232 | 'Instances': item.count | ||
18233 | }; | ||
18234 | })); | ||
18235 | // TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct | ||
18236 | // number. | ||
18237 | }, | ||
18238 | |||
18239 | printInclusive: function (measurements) { | ||
18240 | measurements = measurements || ReactDefaultPerf._allMeasurements; | ||
18241 | var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements); | ||
18242 | console.table(summary.map(function (item) { | ||
18243 | return { | ||
18244 | 'Owner > component': item.componentName, | ||
18245 | 'Inclusive time (ms)': roundFloat(item.time), | ||
18246 | 'Instances': item.count | ||
18247 | }; | ||
18248 | })); | ||
18249 | console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'); | ||
18250 | }, | ||
18251 | |||
18252 | getMeasurementsSummaryMap: function (measurements) { | ||
18253 | var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements, true); | ||
18254 | return summary.map(function (item) { | ||
18255 | return { | ||
18256 | 'Owner > component': item.componentName, | ||
18257 | 'Wasted time (ms)': item.time, | ||
18258 | 'Instances': item.count | ||
18259 | }; | ||
18260 | }); | ||
18261 | }, | ||
18262 | |||
18263 | printWasted: function (measurements) { | ||
18264 | measurements = measurements || ReactDefaultPerf._allMeasurements; | ||
18265 | console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements)); | ||
18266 | console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'); | ||
18267 | }, | ||
18268 | |||
18269 | printDOM: function (measurements) { | ||
18270 | measurements = measurements || ReactDefaultPerf._allMeasurements; | ||
18271 | var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements); | ||
18272 | console.table(summary.map(function (item) { | ||
18273 | var result = {}; | ||
18274 | result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id; | ||
18275 | result.type = item.type; | ||
18276 | result.args = JSON.stringify(item.args); | ||
18277 | return result; | ||
18278 | })); | ||
18279 | console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'); | ||
18280 | }, | ||
18281 | |||
18282 | _recordWrite: function (id, fnName, totalTime, args) { | ||
18283 | // TODO: totalTime isn't that useful since it doesn't count paints/reflows | ||
18284 | var writes = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].writes; | ||
18285 | writes[id] = writes[id] || []; | ||
18286 | writes[id].push({ | ||
18287 | type: fnName, | ||
18288 | time: totalTime, | ||
18289 | args: args | ||
18290 | }); | ||
18291 | }, | ||
18292 | |||
18293 | measure: function (moduleName, fnName, func) { | ||
18294 | return function () { | ||
18295 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
18296 | args[_key] = arguments[_key]; | ||
18297 | } | ||
18298 | |||
18299 | var totalTime; | ||
18300 | var rv; | ||
18301 | var start; | ||
18302 | |||
18303 | if (fnName === '_renderNewRootComponent' || fnName === 'flushBatchedUpdates') { | ||
18304 | // A "measurement" is a set of metrics recorded for each flush. We want | ||
18305 | // to group the metrics for a given flush together so we can look at the | ||
18306 | // components that rendered and the DOM operations that actually | ||
18307 | // happened to determine the amount of "wasted work" performed. | ||
18308 | ReactDefaultPerf._allMeasurements.push({ | ||
18309 | exclusive: {}, | ||
18310 | inclusive: {}, | ||
18311 | render: {}, | ||
18312 | counts: {}, | ||
18313 | writes: {}, | ||
18314 | displayNames: {}, | ||
18315 | totalTime: 0, | ||
18316 | created: {} | ||
18317 | }); | ||
18318 | start = performanceNow(); | ||
18319 | rv = func.apply(this, args); | ||
18320 | ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].totalTime = performanceNow() - start; | ||
18321 | return rv; | ||
18322 | } else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactBrowserEventEmitter' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations') { | ||
18323 | start = performanceNow(); | ||
18324 | rv = func.apply(this, args); | ||
18325 | totalTime = performanceNow() - start; | ||
18326 | |||
18327 | if (fnName === '_mountImageIntoNode') { | ||
18328 | var mountID = ReactMount.getID(args[1]); | ||
18329 | ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]); | ||
18330 | } else if (fnName === 'dangerouslyProcessChildrenUpdates') { | ||
18331 | // special format | ||
18332 | args[0].forEach(function (update) { | ||
18333 | var writeArgs = {}; | ||
18334 | if (update.fromIndex !== null) { | ||
18335 | writeArgs.fromIndex = update.fromIndex; | ||
18336 | } | ||
18337 | if (update.toIndex !== null) { | ||
18338 | writeArgs.toIndex = update.toIndex; | ||
18339 | } | ||
18340 | if (update.textContent !== null) { | ||
18341 | writeArgs.textContent = update.textContent; | ||
18342 | } | ||
18343 | if (update.markupIndex !== null) { | ||
18344 | writeArgs.markup = args[1][update.markupIndex]; | ||
18345 | } | ||
18346 | ReactDefaultPerf._recordWrite(update.parentID, update.type, totalTime, writeArgs); | ||
18347 | }); | ||
18348 | } else { | ||
18349 | // basic format | ||
18350 | var id = args[0]; | ||
18351 | if (typeof id === 'object') { | ||
18352 | id = ReactMount.getID(args[0]); | ||
18353 | } | ||
18354 | ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1)); | ||
18355 | } | ||
18356 | return rv; | ||
18357 | } else if (moduleName === 'ReactCompositeComponent' && (fnName === 'mountComponent' || fnName === 'updateComponent' || // TODO: receiveComponent()? | ||
18358 | fnName === '_renderValidatedComponent')) { | ||
18359 | |||
18360 | if (this._currentElement.type === ReactMount.TopLevelWrapper) { | ||
18361 | return func.apply(this, args); | ||
18362 | } | ||
18363 | |||
18364 | var rootNodeID = fnName === 'mountComponent' ? args[0] : this._rootNodeID; | ||
18365 | var isRender = fnName === '_renderValidatedComponent'; | ||
18366 | var isMount = fnName === 'mountComponent'; | ||
18367 | |||
18368 | var mountStack = ReactDefaultPerf._mountStack; | ||
18369 | var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1]; | ||
18370 | |||
18371 | if (isRender) { | ||
18372 | addValue(entry.counts, rootNodeID, 1); | ||
18373 | } else if (isMount) { | ||
18374 | entry.created[rootNodeID] = true; | ||
18375 | mountStack.push(0); | ||
18376 | } | ||
18377 | |||
18378 | start = performanceNow(); | ||
18379 | rv = func.apply(this, args); | ||
18380 | totalTime = performanceNow() - start; | ||
18381 | |||
18382 | if (isRender) { | ||
18383 | addValue(entry.render, rootNodeID, totalTime); | ||
18384 | } else if (isMount) { | ||
18385 | var subMountTime = mountStack.pop(); | ||
18386 | mountStack[mountStack.length - 1] += totalTime; | ||
18387 | addValue(entry.exclusive, rootNodeID, totalTime - subMountTime); | ||
18388 | addValue(entry.inclusive, rootNodeID, totalTime); | ||
18389 | } else { | ||
18390 | addValue(entry.inclusive, rootNodeID, totalTime); | ||
18391 | } | ||
18392 | |||
18393 | entry.displayNames[rootNodeID] = { | ||
18394 | current: this.getName(), | ||
18395 | owner: this._currentElement._owner ? this._currentElement._owner.getName() : '<root>' | ||
18396 | }; | ||
18397 | |||
18398 | return rv; | ||
18399 | } else { | ||
18400 | return func.apply(this, args); | ||
18401 | } | ||
18402 | }; | ||
18403 | } | ||
18404 | }; | ||
18405 | |||
18406 | module.exports = ReactDefaultPerf; | ||
18407 | |||
18408 | /***/ }, | ||
18409 | /* 145 */ | ||
18410 | /***/ function(module, exports, __webpack_require__) { | ||
18411 | |||
18412 | /** | ||
18413 | * Copyright 2013-2015, Facebook, Inc. | ||
18414 | * All rights reserved. | ||
18415 | * | ||
18416 | * This source code is licensed under the BSD-style license found in the | ||
18417 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18418 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18419 | * | ||
18420 | * @providesModule ReactDefaultPerfAnalysis | ||
18421 | */ | ||
18422 | |||
18423 | 'use strict'; | ||
18424 | |||
18425 | var assign = __webpack_require__(41); | ||
18426 | |||
18427 | // Don't try to save users less than 1.2ms (a number I made up) | ||
18428 | var DONT_CARE_THRESHOLD = 1.2; | ||
18429 | var DOM_OPERATION_TYPES = { | ||
18430 | '_mountImageIntoNode': 'set innerHTML', | ||
18431 | INSERT_MARKUP: 'set innerHTML', | ||
18432 | MOVE_EXISTING: 'move', | ||
18433 | REMOVE_NODE: 'remove', | ||
18434 | SET_MARKUP: 'set innerHTML', | ||
18435 | TEXT_CONTENT: 'set textContent', | ||
18436 | 'setValueForProperty': 'update attribute', | ||
18437 | 'setValueForAttribute': 'update attribute', | ||
18438 | 'deleteValueForProperty': 'remove attribute', | ||
18439 | 'dangerouslyReplaceNodeWithMarkupByID': 'replace' | ||
18440 | }; | ||
18441 | |||
18442 | function getTotalTime(measurements) { | ||
18443 | // TODO: return number of DOM ops? could be misleading. | ||
18444 | // TODO: measure dropped frames after reconcile? | ||
18445 | // TODO: log total time of each reconcile and the top-level component | ||
18446 | // class that triggered it. | ||
18447 | var totalTime = 0; | ||
18448 | for (var i = 0; i < measurements.length; i++) { | ||
18449 | var measurement = measurements[i]; | ||
18450 | totalTime += measurement.totalTime; | ||
18451 | } | ||
18452 | return totalTime; | ||
18453 | } | ||
18454 | |||
18455 | function getDOMSummary(measurements) { | ||
18456 | var items = []; | ||
18457 | measurements.forEach(function (measurement) { | ||
18458 | Object.keys(measurement.writes).forEach(function (id) { | ||
18459 | measurement.writes[id].forEach(function (write) { | ||
18460 | items.push({ | ||
18461 | id: id, | ||
18462 | type: DOM_OPERATION_TYPES[write.type] || write.type, | ||
18463 | args: write.args | ||
18464 | }); | ||
18465 | }); | ||
18466 | }); | ||
18467 | }); | ||
18468 | return items; | ||
18469 | } | ||
18470 | |||
18471 | function getExclusiveSummary(measurements) { | ||
18472 | var candidates = {}; | ||
18473 | var displayName; | ||
18474 | |||
18475 | for (var i = 0; i < measurements.length; i++) { | ||
18476 | var measurement = measurements[i]; | ||
18477 | var allIDs = assign({}, measurement.exclusive, measurement.inclusive); | ||
18478 | |||
18479 | for (var id in allIDs) { | ||
18480 | displayName = measurement.displayNames[id].current; | ||
18481 | |||
18482 | candidates[displayName] = candidates[displayName] || { | ||
18483 | componentName: displayName, | ||
18484 | inclusive: 0, | ||
18485 | exclusive: 0, | ||
18486 | render: 0, | ||
18487 | count: 0 | ||
18488 | }; | ||
18489 | if (measurement.render[id]) { | ||
18490 | candidates[displayName].render += measurement.render[id]; | ||
18491 | } | ||
18492 | if (measurement.exclusive[id]) { | ||
18493 | candidates[displayName].exclusive += measurement.exclusive[id]; | ||
18494 | } | ||
18495 | if (measurement.inclusive[id]) { | ||
18496 | candidates[displayName].inclusive += measurement.inclusive[id]; | ||
18497 | } | ||
18498 | if (measurement.counts[id]) { | ||
18499 | candidates[displayName].count += measurement.counts[id]; | ||
18500 | } | ||
18501 | } | ||
18502 | } | ||
18503 | |||
18504 | // Now make a sorted array with the results. | ||
18505 | var arr = []; | ||
18506 | for (displayName in candidates) { | ||
18507 | if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) { | ||
18508 | arr.push(candidates[displayName]); | ||
18509 | } | ||
18510 | } | ||
18511 | |||
18512 | arr.sort(function (a, b) { | ||
18513 | return b.exclusive - a.exclusive; | ||
18514 | }); | ||
18515 | |||
18516 | return arr; | ||
18517 | } | ||
18518 | |||
18519 | function getInclusiveSummary(measurements, onlyClean) { | ||
18520 | var candidates = {}; | ||
18521 | var inclusiveKey; | ||
18522 | |||
18523 | for (var i = 0; i < measurements.length; i++) { | ||
18524 | var measurement = measurements[i]; | ||
18525 | var allIDs = assign({}, measurement.exclusive, measurement.inclusive); | ||
18526 | var cleanComponents; | ||
18527 | |||
18528 | if (onlyClean) { | ||
18529 | cleanComponents = getUnchangedComponents(measurement); | ||
18530 | } | ||
18531 | |||
18532 | for (var id in allIDs) { | ||
18533 | if (onlyClean && !cleanComponents[id]) { | ||
18534 | continue; | ||
18535 | } | ||
18536 | |||
18537 | var displayName = measurement.displayNames[id]; | ||
18538 | |||
18539 | // Inclusive time is not useful for many components without knowing where | ||
18540 | // they are instantiated. So we aggregate inclusive time with both the | ||
18541 | // owner and current displayName as the key. | ||
18542 | inclusiveKey = displayName.owner + ' > ' + displayName.current; | ||
18543 | |||
18544 | candidates[inclusiveKey] = candidates[inclusiveKey] || { | ||
18545 | componentName: inclusiveKey, | ||
18546 | time: 0, | ||
18547 | count: 0 | ||
18548 | }; | ||
18549 | |||
18550 | if (measurement.inclusive[id]) { | ||
18551 | candidates[inclusiveKey].time += measurement.inclusive[id]; | ||
18552 | } | ||
18553 | if (measurement.counts[id]) { | ||
18554 | candidates[inclusiveKey].count += measurement.counts[id]; | ||
18555 | } | ||
18556 | } | ||
18557 | } | ||
18558 | |||
18559 | // Now make a sorted array with the results. | ||
18560 | var arr = []; | ||
18561 | for (inclusiveKey in candidates) { | ||
18562 | if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) { | ||
18563 | arr.push(candidates[inclusiveKey]); | ||
18564 | } | ||
18565 | } | ||
18566 | |||
18567 | arr.sort(function (a, b) { | ||
18568 | return b.time - a.time; | ||
18569 | }); | ||
18570 | |||
18571 | return arr; | ||
18572 | } | ||
18573 | |||
18574 | function getUnchangedComponents(measurement) { | ||
18575 | // For a given reconcile, look at which components did not actually | ||
18576 | // render anything to the DOM and return a mapping of their ID to | ||
18577 | // the amount of time it took to render the entire subtree. | ||
18578 | var cleanComponents = {}; | ||
18579 | var dirtyLeafIDs = Object.keys(measurement.writes); | ||
18580 | var allIDs = assign({}, measurement.exclusive, measurement.inclusive); | ||
18581 | |||
18582 | for (var id in allIDs) { | ||
18583 | var isDirty = false; | ||
18584 | // For each component that rendered, see if a component that triggered | ||
18585 | // a DOM op is in its subtree. | ||
18586 | for (var i = 0; i < dirtyLeafIDs.length; i++) { | ||
18587 | if (dirtyLeafIDs[i].indexOf(id) === 0) { | ||
18588 | isDirty = true; | ||
18589 | break; | ||
18590 | } | ||
18591 | } | ||
18592 | // check if component newly created | ||
18593 | if (measurement.created[id]) { | ||
18594 | isDirty = true; | ||
18595 | } | ||
18596 | if (!isDirty && measurement.counts[id] > 0) { | ||
18597 | cleanComponents[id] = true; | ||
18598 | } | ||
18599 | } | ||
18600 | return cleanComponents; | ||
18601 | } | ||
18602 | |||
18603 | var ReactDefaultPerfAnalysis = { | ||
18604 | getExclusiveSummary: getExclusiveSummary, | ||
18605 | getInclusiveSummary: getInclusiveSummary, | ||
18606 | getDOMSummary: getDOMSummary, | ||
18607 | getTotalTime: getTotalTime | ||
18608 | }; | ||
18609 | |||
18610 | module.exports = ReactDefaultPerfAnalysis; | ||
18611 | |||
18612 | /***/ }, | ||
18613 | /* 146 */ | ||
18614 | /***/ function(module, exports, __webpack_require__) { | ||
18615 | |||
18616 | /** | ||
18617 | * Copyright 2013-2015, Facebook, Inc. | ||
18618 | * All rights reserved. | ||
18619 | * | ||
18620 | * This source code is licensed under the BSD-style license found in the | ||
18621 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18622 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18623 | * | ||
18624 | * @providesModule performanceNow | ||
18625 | * @typechecks | ||
18626 | */ | ||
18627 | |||
18628 | 'use strict'; | ||
18629 | |||
18630 | var performance = __webpack_require__(147); | ||
18631 | var curPerformance = performance; | ||
18632 | |||
18633 | /** | ||
18634 | * Detect if we can use `window.performance.now()` and gracefully fallback to | ||
18635 | * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now | ||
18636 | * because of Facebook's testing infrastructure. | ||
18637 | */ | ||
18638 | if (!curPerformance || !curPerformance.now) { | ||
18639 | curPerformance = Date; | ||
18640 | } | ||
18641 | |||
18642 | var performanceNow = curPerformance.now.bind(curPerformance); | ||
18643 | |||
18644 | module.exports = performanceNow; | ||
18645 | |||
18646 | /***/ }, | ||
18647 | /* 147 */ | ||
18648 | /***/ function(module, exports, __webpack_require__) { | ||
18649 | |||
18650 | /** | ||
18651 | * Copyright 2013-2015, Facebook, Inc. | ||
18652 | * All rights reserved. | ||
18653 | * | ||
18654 | * This source code is licensed under the BSD-style license found in the | ||
18655 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18656 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18657 | * | ||
18658 | * @providesModule performance | ||
18659 | * @typechecks | ||
18660 | */ | ||
18661 | |||
18662 | 'use strict'; | ||
18663 | |||
18664 | var ExecutionEnvironment = __webpack_require__(11); | ||
18665 | |||
18666 | var performance; | ||
18667 | |||
18668 | if (ExecutionEnvironment.canUseDOM) { | ||
18669 | performance = window.performance || window.msPerformance || window.webkitPerformance; | ||
18670 | } | ||
18671 | |||
18672 | module.exports = performance || {}; | ||
18673 | |||
18674 | /***/ }, | ||
18675 | /* 148 */ | ||
18676 | /***/ function(module, exports) { | ||
18677 | |||
18678 | /** | ||
18679 | * Copyright 2013-2015, Facebook, Inc. | ||
18680 | * All rights reserved. | ||
18681 | * | ||
18682 | * This source code is licensed under the BSD-style license found in the | ||
18683 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18684 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18685 | * | ||
18686 | * @providesModule ReactVersion | ||
18687 | */ | ||
18688 | |||
18689 | 'use strict'; | ||
18690 | |||
18691 | module.exports = '0.14.2'; | ||
18692 | |||
18693 | /***/ }, | ||
18694 | /* 149 */ | ||
18695 | /***/ function(module, exports, __webpack_require__) { | ||
18696 | |||
18697 | /** | ||
18698 | * Copyright 2013-2015, Facebook, Inc. | ||
18699 | * All rights reserved. | ||
18700 | * | ||
18701 | * This source code is licensed under the BSD-style license found in the | ||
18702 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18703 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18704 | * | ||
18705 | * @providesModule renderSubtreeIntoContainer | ||
18706 | */ | ||
18707 | |||
18708 | 'use strict'; | ||
18709 | |||
18710 | var ReactMount = __webpack_require__(30); | ||
18711 | |||
18712 | module.exports = ReactMount.renderSubtreeIntoContainer; | ||
18713 | |||
18714 | /***/ }, | ||
18715 | /* 150 */ | ||
18716 | /***/ function(module, exports, __webpack_require__) { | ||
18717 | |||
18718 | /** | ||
18719 | * Copyright 2013-2015, Facebook, Inc. | ||
18720 | * All rights reserved. | ||
18721 | * | ||
18722 | * This source code is licensed under the BSD-style license found in the | ||
18723 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18724 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18725 | * | ||
18726 | * @providesModule ReactDOMServer | ||
18727 | */ | ||
18728 | |||
18729 | 'use strict'; | ||
18730 | |||
18731 | var ReactDefaultInjection = __webpack_require__(73); | ||
18732 | var ReactServerRendering = __webpack_require__(151); | ||
18733 | var ReactVersion = __webpack_require__(148); | ||
18734 | |||
18735 | ReactDefaultInjection.inject(); | ||
18736 | |||
18737 | var ReactDOMServer = { | ||
18738 | renderToString: ReactServerRendering.renderToString, | ||
18739 | renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup, | ||
18740 | version: ReactVersion | ||
18741 | }; | ||
18742 | |||
18743 | module.exports = ReactDOMServer; | ||
18744 | |||
18745 | /***/ }, | ||
18746 | /* 151 */ | ||
18747 | /***/ function(module, exports, __webpack_require__) { | ||
18748 | |||
18749 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
18750 | * Copyright 2013-2015, Facebook, Inc. | ||
18751 | * All rights reserved. | ||
18752 | * | ||
18753 | * This source code is licensed under the BSD-style license found in the | ||
18754 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18755 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18756 | * | ||
18757 | * @typechecks static-only | ||
18758 | * @providesModule ReactServerRendering | ||
18759 | */ | ||
18760 | 'use strict'; | ||
18761 | |||
18762 | var ReactDefaultBatchingStrategy = __webpack_require__(94); | ||
18763 | var ReactElement = __webpack_require__(44); | ||
18764 | var ReactInstanceHandles = __webpack_require__(47); | ||
18765 | var ReactMarkupChecksum = __webpack_require__(50); | ||
18766 | var ReactServerBatchingStrategy = __webpack_require__(152); | ||
18767 | var ReactServerRenderingTransaction = __webpack_require__(153); | ||
18768 | var ReactUpdates = __webpack_require__(56); | ||
18769 | |||
18770 | var emptyObject = __webpack_require__(60); | ||
18771 | var instantiateReactComponent = __webpack_require__(64); | ||
18772 | var invariant = __webpack_require__(15); | ||
18773 | |||
18774 | /** | ||
18775 | * @param {ReactElement} element | ||
18776 | * @return {string} the HTML markup | ||
18777 | */ | ||
18778 | function renderToString(element) { | ||
18779 | !ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined; | ||
18780 | |||
18781 | var transaction; | ||
18782 | try { | ||
18783 | ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy); | ||
18784 | |||
18785 | var id = ReactInstanceHandles.createReactRootID(); | ||
18786 | transaction = ReactServerRenderingTransaction.getPooled(false); | ||
18787 | |||
18788 | return transaction.perform(function () { | ||
18789 | var componentInstance = instantiateReactComponent(element, null); | ||
18790 | var markup = componentInstance.mountComponent(id, transaction, emptyObject); | ||
18791 | return ReactMarkupChecksum.addChecksumToMarkup(markup); | ||
18792 | }, null); | ||
18793 | } finally { | ||
18794 | ReactServerRenderingTransaction.release(transaction); | ||
18795 | // Revert to the DOM batching strategy since these two renderers | ||
18796 | // currently share these stateful modules. | ||
18797 | ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy); | ||
18798 | } | ||
18799 | } | ||
18800 | |||
18801 | /** | ||
18802 | * @param {ReactElement} element | ||
18803 | * @return {string} the HTML markup, without the extra React ID and checksum | ||
18804 | * (for generating static pages) | ||
18805 | */ | ||
18806 | function renderToStaticMarkup(element) { | ||
18807 | !ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined; | ||
18808 | |||
18809 | var transaction; | ||
18810 | try { | ||
18811 | ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy); | ||
18812 | |||
18813 | var id = ReactInstanceHandles.createReactRootID(); | ||
18814 | transaction = ReactServerRenderingTransaction.getPooled(true); | ||
18815 | |||
18816 | return transaction.perform(function () { | ||
18817 | var componentInstance = instantiateReactComponent(element, null); | ||
18818 | return componentInstance.mountComponent(id, transaction, emptyObject); | ||
18819 | }, null); | ||
18820 | } finally { | ||
18821 | ReactServerRenderingTransaction.release(transaction); | ||
18822 | // Revert to the DOM batching strategy since these two renderers | ||
18823 | // currently share these stateful modules. | ||
18824 | ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy); | ||
18825 | } | ||
18826 | } | ||
18827 | |||
18828 | module.exports = { | ||
18829 | renderToString: renderToString, | ||
18830 | renderToStaticMarkup: renderToStaticMarkup | ||
18831 | }; | ||
18832 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
18833 | |||
18834 | /***/ }, | ||
18835 | /* 152 */ | ||
18836 | /***/ function(module, exports) { | ||
18837 | |||
18838 | /** | ||
18839 | * Copyright 2014-2015, Facebook, Inc. | ||
18840 | * All rights reserved. | ||
18841 | * | ||
18842 | * This source code is licensed under the BSD-style license found in the | ||
18843 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18844 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18845 | * | ||
18846 | * @providesModule ReactServerBatchingStrategy | ||
18847 | * @typechecks | ||
18848 | */ | ||
18849 | |||
18850 | 'use strict'; | ||
18851 | |||
18852 | var ReactServerBatchingStrategy = { | ||
18853 | isBatchingUpdates: false, | ||
18854 | batchedUpdates: function (callback) { | ||
18855 | // Don't do anything here. During the server rendering we don't want to | ||
18856 | // schedule any updates. We will simply ignore them. | ||
18857 | } | ||
18858 | }; | ||
18859 | |||
18860 | module.exports = ReactServerBatchingStrategy; | ||
18861 | |||
18862 | /***/ }, | ||
18863 | /* 153 */ | ||
18864 | /***/ function(module, exports, __webpack_require__) { | ||
18865 | |||
18866 | /** | ||
18867 | * Copyright 2014-2015, Facebook, Inc. | ||
18868 | * All rights reserved. | ||
18869 | * | ||
18870 | * This source code is licensed under the BSD-style license found in the | ||
18871 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18872 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18873 | * | ||
18874 | * @providesModule ReactServerRenderingTransaction | ||
18875 | * @typechecks | ||
18876 | */ | ||
18877 | |||
18878 | 'use strict'; | ||
18879 | |||
18880 | var PooledClass = __webpack_require__(58); | ||
18881 | var CallbackQueue = __webpack_require__(57); | ||
18882 | var Transaction = __webpack_require__(59); | ||
18883 | |||
18884 | var assign = __webpack_require__(41); | ||
18885 | var emptyFunction = __webpack_require__(17); | ||
18886 | |||
18887 | /** | ||
18888 | * Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks | ||
18889 | * during the performing of the transaction. | ||
18890 | */ | ||
18891 | var ON_DOM_READY_QUEUEING = { | ||
18892 | /** | ||
18893 | * Initializes the internal `onDOMReady` queue. | ||
18894 | */ | ||
18895 | initialize: function () { | ||
18896 | this.reactMountReady.reset(); | ||
18897 | }, | ||
18898 | |||
18899 | close: emptyFunction | ||
18900 | }; | ||
18901 | |||
18902 | /** | ||
18903 | * Executed within the scope of the `Transaction` instance. Consider these as | ||
18904 | * being member methods, but with an implied ordering while being isolated from | ||
18905 | * each other. | ||
18906 | */ | ||
18907 | var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING]; | ||
18908 | |||
18909 | /** | ||
18910 | * @class ReactServerRenderingTransaction | ||
18911 | * @param {boolean} renderToStaticMarkup | ||
18912 | */ | ||
18913 | function ReactServerRenderingTransaction(renderToStaticMarkup) { | ||
18914 | this.reinitializeTransaction(); | ||
18915 | this.renderToStaticMarkup = renderToStaticMarkup; | ||
18916 | this.reactMountReady = CallbackQueue.getPooled(null); | ||
18917 | this.useCreateElement = false; | ||
18918 | } | ||
18919 | |||
18920 | var Mixin = { | ||
18921 | /** | ||
18922 | * @see Transaction | ||
18923 | * @abstract | ||
18924 | * @final | ||
18925 | * @return {array} Empty list of operation wrap procedures. | ||
18926 | */ | ||
18927 | getTransactionWrappers: function () { | ||
18928 | return TRANSACTION_WRAPPERS; | ||
18929 | }, | ||
18930 | |||
18931 | /** | ||
18932 | * @return {object} The queue to collect `onDOMReady` callbacks with. | ||
18933 | */ | ||
18934 | getReactMountReady: function () { | ||
18935 | return this.reactMountReady; | ||
18936 | }, | ||
18937 | |||
18938 | /** | ||
18939 | * `PooledClass` looks for this, and will invoke this before allowing this | ||
18940 | * instance to be reused. | ||
18941 | */ | ||
18942 | destructor: function () { | ||
18943 | CallbackQueue.release(this.reactMountReady); | ||
18944 | this.reactMountReady = null; | ||
18945 | } | ||
18946 | }; | ||
18947 | |||
18948 | assign(ReactServerRenderingTransaction.prototype, Transaction.Mixin, Mixin); | ||
18949 | |||
18950 | PooledClass.addPoolingTo(ReactServerRenderingTransaction); | ||
18951 | |||
18952 | module.exports = ReactServerRenderingTransaction; | ||
18953 | |||
18954 | /***/ }, | ||
18955 | /* 154 */ | ||
18956 | /***/ function(module, exports, __webpack_require__) { | ||
18957 | |||
18958 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
18959 | * Copyright 2013-2015, Facebook, Inc. | ||
18960 | * All rights reserved. | ||
18961 | * | ||
18962 | * This source code is licensed under the BSD-style license found in the | ||
18963 | * LICENSE file in the root directory of this source tree. An additional grant | ||
18964 | * of patent rights can be found in the PATENTS file in the same directory. | ||
18965 | * | ||
18966 | * @providesModule ReactIsomorphic | ||
18967 | */ | ||
18968 | |||
18969 | 'use strict'; | ||
18970 | |||
18971 | var ReactChildren = __webpack_require__(112); | ||
18972 | var ReactComponent = __webpack_require__(125); | ||
18973 | var ReactClass = __webpack_require__(124); | ||
18974 | var ReactDOMFactories = __webpack_require__(155); | ||
18975 | var ReactElement = __webpack_require__(44); | ||
18976 | var ReactElementValidator = __webpack_require__(156); | ||
18977 | var ReactPropTypes = __webpack_require__(109); | ||
18978 | var ReactVersion = __webpack_require__(148); | ||
18979 | |||
18980 | var assign = __webpack_require__(41); | ||
18981 | var onlyChild = __webpack_require__(158); | ||
18982 | |||
18983 | var createElement = ReactElement.createElement; | ||
18984 | var createFactory = ReactElement.createFactory; | ||
18985 | var cloneElement = ReactElement.cloneElement; | ||
18986 | |||
18987 | if (process.env.NODE_ENV !== 'production') { | ||
18988 | createElement = ReactElementValidator.createElement; | ||
18989 | createFactory = ReactElementValidator.createFactory; | ||
18990 | cloneElement = ReactElementValidator.cloneElement; | ||
18991 | } | ||
18992 | |||
18993 | var React = { | ||
18994 | |||
18995 | // Modern | ||
18996 | |||
18997 | Children: { | ||
18998 | map: ReactChildren.map, | ||
18999 | forEach: ReactChildren.forEach, | ||
19000 | count: ReactChildren.count, | ||
19001 | toArray: ReactChildren.toArray, | ||
19002 | only: onlyChild | ||
19003 | }, | ||
19004 | |||
19005 | Component: ReactComponent, | ||
19006 | |||
19007 | createElement: createElement, | ||
19008 | cloneElement: cloneElement, | ||
19009 | isValidElement: ReactElement.isValidElement, | ||
19010 | |||
19011 | // Classic | ||
19012 | |||
19013 | PropTypes: ReactPropTypes, | ||
19014 | createClass: ReactClass.createClass, | ||
19015 | createFactory: createFactory, | ||
19016 | createMixin: function (mixin) { | ||
19017 | // Currently a noop. Will be used to validate and trace mixins. | ||
19018 | return mixin; | ||
19019 | }, | ||
19020 | |||
19021 | // This looks DOM specific but these are actually isomorphic helpers | ||
19022 | // since they are just generating DOM strings. | ||
19023 | DOM: ReactDOMFactories, | ||
19024 | |||
19025 | version: ReactVersion, | ||
19026 | |||
19027 | // Hook for JSX spread, don't use this for anything else. | ||
19028 | __spread: assign | ||
19029 | }; | ||
19030 | |||
19031 | module.exports = React; | ||
19032 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
19033 | |||
19034 | /***/ }, | ||
19035 | /* 155 */ | ||
19036 | /***/ function(module, exports, __webpack_require__) { | ||
19037 | |||
19038 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
19039 | * Copyright 2013-2015, Facebook, Inc. | ||
19040 | * All rights reserved. | ||
19041 | * | ||
19042 | * This source code is licensed under the BSD-style license found in the | ||
19043 | * LICENSE file in the root directory of this source tree. An additional grant | ||
19044 | * of patent rights can be found in the PATENTS file in the same directory. | ||
19045 | * | ||
19046 | * @providesModule ReactDOMFactories | ||
19047 | * @typechecks static-only | ||
19048 | */ | ||
19049 | |||
19050 | 'use strict'; | ||
19051 | |||
19052 | var ReactElement = __webpack_require__(44); | ||
19053 | var ReactElementValidator = __webpack_require__(156); | ||
19054 | |||
19055 | var mapObject = __webpack_require__(157); | ||
19056 | |||
19057 | /** | ||
19058 | * Create a factory that creates HTML tag elements. | ||
19059 | * | ||
19060 | * @param {string} tag Tag name (e.g. `div`). | ||
19061 | * @private | ||
19062 | */ | ||
19063 | function createDOMFactory(tag) { | ||
19064 | if (process.env.NODE_ENV !== 'production') { | ||
19065 | return ReactElementValidator.createFactory(tag); | ||
19066 | } | ||
19067 | return ReactElement.createFactory(tag); | ||
19068 | } | ||
19069 | |||
19070 | /** | ||
19071 | * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes. | ||
19072 | * This is also accessible via `React.DOM`. | ||
19073 | * | ||
19074 | * @public | ||
19075 | */ | ||
19076 | var ReactDOMFactories = mapObject({ | ||
19077 | a: 'a', | ||
19078 | abbr: 'abbr', | ||
19079 | address: 'address', | ||
19080 | area: 'area', | ||
19081 | article: 'article', | ||
19082 | aside: 'aside', | ||
19083 | audio: 'audio', | ||
19084 | b: 'b', | ||
19085 | base: 'base', | ||
19086 | bdi: 'bdi', | ||
19087 | bdo: 'bdo', | ||
19088 | big: 'big', | ||
19089 | blockquote: 'blockquote', | ||
19090 | body: 'body', | ||
19091 | br: 'br', | ||
19092 | button: 'button', | ||
19093 | canvas: 'canvas', | ||
19094 | caption: 'caption', | ||
19095 | cite: 'cite', | ||
19096 | code: 'code', | ||
19097 | col: 'col', | ||
19098 | colgroup: 'colgroup', | ||
19099 | data: 'data', | ||
19100 | datalist: 'datalist', | ||
19101 | dd: 'dd', | ||
19102 | del: 'del', | ||
19103 | details: 'details', | ||
19104 | dfn: 'dfn', | ||
19105 | dialog: 'dialog', | ||
19106 | div: 'div', | ||
19107 | dl: 'dl', | ||
19108 | dt: 'dt', | ||
19109 | em: 'em', | ||
19110 | embed: 'embed', | ||
19111 | fieldset: 'fieldset', | ||
19112 | figcaption: 'figcaption', | ||
19113 | figure: 'figure', | ||
19114 | footer: 'footer', | ||
19115 | form: 'form', | ||
19116 | h1: 'h1', | ||
19117 | h2: 'h2', | ||
19118 | h3: 'h3', | ||
19119 | h4: 'h4', | ||
19120 | h5: 'h5', | ||
19121 | h6: 'h6', | ||
19122 | head: 'head', | ||
19123 | header: 'header', | ||
19124 | hgroup: 'hgroup', | ||
19125 | hr: 'hr', | ||
19126 | html: 'html', | ||
19127 | i: 'i', | ||
19128 | iframe: 'iframe', | ||
19129 | img: 'img', | ||
19130 | input: 'input', | ||
19131 | ins: 'ins', | ||
19132 | kbd: 'kbd', | ||
19133 | keygen: 'keygen', | ||
19134 | label: 'label', | ||
19135 | legend: 'legend', | ||
19136 | li: 'li', | ||
19137 | link: 'link', | ||
19138 | main: 'main', | ||
19139 | map: 'map', | ||
19140 | mark: 'mark', | ||
19141 | menu: 'menu', | ||
19142 | menuitem: 'menuitem', | ||
19143 | meta: 'meta', | ||
19144 | meter: 'meter', | ||
19145 | nav: 'nav', | ||
19146 | noscript: 'noscript', | ||
19147 | object: 'object', | ||
19148 | ol: 'ol', | ||
19149 | optgroup: 'optgroup', | ||
19150 | option: 'option', | ||
19151 | output: 'output', | ||
19152 | p: 'p', | ||
19153 | param: 'param', | ||
19154 | picture: 'picture', | ||
19155 | pre: 'pre', | ||
19156 | progress: 'progress', | ||
19157 | q: 'q', | ||
19158 | rp: 'rp', | ||
19159 | rt: 'rt', | ||
19160 | ruby: 'ruby', | ||
19161 | s: 's', | ||
19162 | samp: 'samp', | ||
19163 | script: 'script', | ||
19164 | section: 'section', | ||
19165 | select: 'select', | ||
19166 | small: 'small', | ||
19167 | source: 'source', | ||
19168 | span: 'span', | ||
19169 | strong: 'strong', | ||
19170 | style: 'style', | ||
19171 | sub: 'sub', | ||
19172 | summary: 'summary', | ||
19173 | sup: 'sup', | ||
19174 | table: 'table', | ||
19175 | tbody: 'tbody', | ||
19176 | td: 'td', | ||
19177 | textarea: 'textarea', | ||
19178 | tfoot: 'tfoot', | ||
19179 | th: 'th', | ||
19180 | thead: 'thead', | ||
19181 | time: 'time', | ||
19182 | title: 'title', | ||
19183 | tr: 'tr', | ||
19184 | track: 'track', | ||
19185 | u: 'u', | ||
19186 | ul: 'ul', | ||
19187 | 'var': 'var', | ||
19188 | video: 'video', | ||
19189 | wbr: 'wbr', | ||
19190 | |||
19191 | // SVG | ||
19192 | circle: 'circle', | ||
19193 | clipPath: 'clipPath', | ||
19194 | defs: 'defs', | ||
19195 | ellipse: 'ellipse', | ||
19196 | g: 'g', | ||
19197 | image: 'image', | ||
19198 | line: 'line', | ||
19199 | linearGradient: 'linearGradient', | ||
19200 | mask: 'mask', | ||
19201 | path: 'path', | ||
19202 | pattern: 'pattern', | ||
19203 | polygon: 'polygon', | ||
19204 | polyline: 'polyline', | ||
19205 | radialGradient: 'radialGradient', | ||
19206 | rect: 'rect', | ||
19207 | stop: 'stop', | ||
19208 | svg: 'svg', | ||
19209 | text: 'text', | ||
19210 | tspan: 'tspan' | ||
19211 | |||
19212 | }, createDOMFactory); | ||
19213 | |||
19214 | module.exports = ReactDOMFactories; | ||
19215 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
19216 | |||
19217 | /***/ }, | ||
19218 | /* 156 */ | ||
19219 | /***/ function(module, exports, __webpack_require__) { | ||
19220 | |||
19221 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
19222 | * Copyright 2014-2015, Facebook, Inc. | ||
19223 | * All rights reserved. | ||
19224 | * | ||
19225 | * This source code is licensed under the BSD-style license found in the | ||
19226 | * LICENSE file in the root directory of this source tree. An additional grant | ||
19227 | * of patent rights can be found in the PATENTS file in the same directory. | ||
19228 | * | ||
19229 | * @providesModule ReactElementValidator | ||
19230 | */ | ||
19231 | |||
19232 | /** | ||
19233 | * ReactElementValidator provides a wrapper around a element factory | ||
19234 | * which validates the props passed to the element. This is intended to be | ||
19235 | * used only in DEV and could be replaced by a static type checker for languages | ||
19236 | * that support it. | ||
19237 | */ | ||
19238 | |||
19239 | 'use strict'; | ||
19240 | |||
19241 | var ReactElement = __webpack_require__(44); | ||
19242 | var ReactPropTypeLocations = __webpack_require__(67); | ||
19243 | var ReactPropTypeLocationNames = __webpack_require__(68); | ||
19244 | var ReactCurrentOwner = __webpack_require__(7); | ||
19245 | |||
19246 | var canDefineProperty = __webpack_require__(45); | ||
19247 | var getIteratorFn = __webpack_require__(110); | ||
19248 | var invariant = __webpack_require__(15); | ||
19249 | var warning = __webpack_require__(27); | ||
19250 | |||
19251 | function getDeclarationErrorAddendum() { | ||
19252 | if (ReactCurrentOwner.current) { | ||
19253 | var name = ReactCurrentOwner.current.getName(); | ||
19254 | if (name) { | ||
19255 | return ' Check the render method of `' + name + '`.'; | ||
19256 | } | ||
19257 | } | ||
19258 | return ''; | ||
19259 | } | ||
19260 | |||
19261 | /** | ||
19262 | * Warn if there's no key explicitly set on dynamic arrays of children or | ||
19263 | * object keys are not valid. This allows us to keep track of children between | ||
19264 | * updates. | ||
19265 | */ | ||
19266 | var ownerHasKeyUseWarning = {}; | ||
19267 | |||
19268 | var loggedTypeFailures = {}; | ||
19269 | |||
19270 | /** | ||
19271 | * Warn if the element doesn't have an explicit key assigned to it. | ||
19272 | * This element is in an array. The array could grow and shrink or be | ||
19273 | * reordered. All children that haven't already been validated are required to | ||
19274 | * have a "key" property assigned to it. | ||
19275 | * | ||
19276 | * @internal | ||
19277 | * @param {ReactElement} element Element that requires a key. | ||
19278 | * @param {*} parentType element's parent's type. | ||
19279 | */ | ||
19280 | function validateExplicitKey(element, parentType) { | ||
19281 | if (!element._store || element._store.validated || element.key != null) { | ||
19282 | return; | ||
19283 | } | ||
19284 | element._store.validated = true; | ||
19285 | |||
19286 | var addenda = getAddendaForKeyUse('uniqueKey', element, parentType); | ||
19287 | if (addenda === null) { | ||
19288 | // we already showed the warning | ||
19289 | return; | ||
19290 | } | ||
19291 | process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined; | ||
19292 | } | ||
19293 | |||
19294 | /** | ||
19295 | * Shared warning and monitoring code for the key warnings. | ||
19296 | * | ||
19297 | * @internal | ||
19298 | * @param {string} messageType A key used for de-duping warnings. | ||
19299 | * @param {ReactElement} element Component that requires a key. | ||
19300 | * @param {*} parentType element's parent's type. | ||
19301 | * @returns {?object} A set of addenda to use in the warning message, or null | ||
19302 | * if the warning has already been shown before (and shouldn't be shown again). | ||
19303 | */ | ||
19304 | function getAddendaForKeyUse(messageType, element, parentType) { | ||
19305 | var addendum = getDeclarationErrorAddendum(); | ||
19306 | if (!addendum) { | ||
19307 | var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; | ||
19308 | if (parentName) { | ||
19309 | addendum = ' Check the top-level render call using <' + parentName + '>.'; | ||
19310 | } | ||
19311 | } | ||
19312 | |||
19313 | var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {}); | ||
19314 | if (memoizer[addendum]) { | ||
19315 | return null; | ||
19316 | } | ||
19317 | memoizer[addendum] = true; | ||
19318 | |||
19319 | var addenda = { | ||
19320 | parentOrOwner: addendum, | ||
19321 | url: ' See https://fb.me/react-warning-keys for more information.', | ||
19322 | childOwner: null | ||
19323 | }; | ||
19324 | |||
19325 | // Usually the current owner is the offender, but if it accepts children as a | ||
19326 | // property, it may be the creator of the child that's responsible for | ||
19327 | // assigning it a key. | ||
19328 | if (element && element._owner && element._owner !== ReactCurrentOwner.current) { | ||
19329 | // Give the component that originally created this child. | ||
19330 | addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.'; | ||
19331 | } | ||
19332 | |||
19333 | return addenda; | ||
19334 | } | ||
19335 | |||
19336 | /** | ||
19337 | * Ensure that every element either is passed in a static location, in an | ||
19338 | * array with an explicit keys property defined, or in an object literal | ||
19339 | * with valid key property. | ||
19340 | * | ||
19341 | * @internal | ||
19342 | * @param {ReactNode} node Statically passed child of any type. | ||
19343 | * @param {*} parentType node's parent's type. | ||
19344 | */ | ||
19345 | function validateChildKeys(node, parentType) { | ||
19346 | if (typeof node !== 'object') { | ||
19347 | return; | ||
19348 | } | ||
19349 | if (Array.isArray(node)) { | ||
19350 | for (var i = 0; i < node.length; i++) { | ||
19351 | var child = node[i]; | ||
19352 | if (ReactElement.isValidElement(child)) { | ||
19353 | validateExplicitKey(child, parentType); | ||
19354 | } | ||
19355 | } | ||
19356 | } else if (ReactElement.isValidElement(node)) { | ||
19357 | // This element was passed in a valid location. | ||
19358 | if (node._store) { | ||
19359 | node._store.validated = true; | ||
19360 | } | ||
19361 | } else if (node) { | ||
19362 | var iteratorFn = getIteratorFn(node); | ||
19363 | // Entry iterators provide implicit keys. | ||
19364 | if (iteratorFn) { | ||
19365 | if (iteratorFn !== node.entries) { | ||
19366 | var iterator = iteratorFn.call(node); | ||
19367 | var step; | ||
19368 | while (!(step = iterator.next()).done) { | ||
19369 | if (ReactElement.isValidElement(step.value)) { | ||
19370 | validateExplicitKey(step.value, parentType); | ||
19371 | } | ||
19372 | } | ||
19373 | } | ||
19374 | } | ||
19375 | } | ||
19376 | } | ||
19377 | |||
19378 | /** | ||
19379 | * Assert that the props are valid | ||
19380 | * | ||
19381 | * @param {string} componentName Name of the component for error messages. | ||
19382 | * @param {object} propTypes Map of prop name to a ReactPropType | ||
19383 | * @param {object} props | ||
19384 | * @param {string} location e.g. "prop", "context", "child context" | ||
19385 | * @private | ||
19386 | */ | ||
19387 | function checkPropTypes(componentName, propTypes, props, location) { | ||
19388 | for (var propName in propTypes) { | ||
19389 | if (propTypes.hasOwnProperty(propName)) { | ||
19390 | var error; | ||
19391 | // Prop type validation may throw. In case they do, we don't want to | ||
19392 | // fail the render phase where it didn't fail before. So we log it. | ||
19393 | // After these have been cleaned up, we'll let them throw. | ||
19394 | try { | ||
19395 | // This is intentionally an invariant that gets caught. It's the same | ||
19396 | // behavior as without this statement except with a better message. | ||
19397 | !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined; | ||
19398 | error = propTypes[propName](props, propName, componentName, location); | ||
19399 | } catch (ex) { | ||
19400 | error = ex; | ||
19401 | } | ||
19402 | process.env.NODE_ENV !== 'production' ? 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', ReactPropTypeLocationNames[location], propName, typeof error) : undefined; | ||
19403 | if (error instanceof Error && !(error.message in loggedTypeFailures)) { | ||
19404 | // Only monitor this failure once because there tends to be a lot of the | ||
19405 | // same error. | ||
19406 | loggedTypeFailures[error.message] = true; | ||
19407 | |||
19408 | var addendum = getDeclarationErrorAddendum(); | ||
19409 | process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined; | ||
19410 | } | ||
19411 | } | ||
19412 | } | ||
19413 | } | ||
19414 | |||
19415 | /** | ||
19416 | * Given an element, validate that its props follow the propTypes definition, | ||
19417 | * provided by the type. | ||
19418 | * | ||
19419 | * @param {ReactElement} element | ||
19420 | */ | ||
19421 | function validatePropTypes(element) { | ||
19422 | var componentClass = element.type; | ||
19423 | if (typeof componentClass !== 'function') { | ||
19424 | return; | ||
19425 | } | ||
19426 | var name = componentClass.displayName || componentClass.name; | ||
19427 | if (componentClass.propTypes) { | ||
19428 | checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop); | ||
19429 | } | ||
19430 | if (typeof componentClass.getDefaultProps === 'function') { | ||
19431 | process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined; | ||
19432 | } | ||
19433 | } | ||
19434 | |||
19435 | var ReactElementValidator = { | ||
19436 | |||
19437 | createElement: function (type, props, children) { | ||
19438 | var validType = typeof type === 'string' || typeof type === 'function'; | ||
19439 | // We warn in this case but don't throw. We expect the element creation to | ||
19440 | // succeed and there will likely be errors in render. | ||
19441 | process.env.NODE_ENV !== 'production' ? warning(validType, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined; | ||
19442 | |||
19443 | var element = ReactElement.createElement.apply(this, arguments); | ||
19444 | |||
19445 | // The result can be nullish if a mock or a custom function is used. | ||
19446 | // TODO: Drop this when these are no longer allowed as the type argument. | ||
19447 | if (element == null) { | ||
19448 | return element; | ||
19449 | } | ||
19450 | |||
19451 | // Skip key warning if the type isn't valid since our key validation logic | ||
19452 | // doesn't expect a non-string/function type and can throw confusing errors. | ||
19453 | // We don't want exception behavior to differ between dev and prod. | ||
19454 | // (Rendering will throw with a helpful message and as soon as the type is | ||
19455 | // fixed, the key warnings will appear.) | ||
19456 | if (validType) { | ||
19457 | for (var i = 2; i < arguments.length; i++) { | ||
19458 | validateChildKeys(arguments[i], type); | ||
19459 | } | ||
19460 | } | ||
19461 | |||
19462 | validatePropTypes(element); | ||
19463 | |||
19464 | return element; | ||
19465 | }, | ||
19466 | |||
19467 | createFactory: function (type) { | ||
19468 | var validatedFactory = ReactElementValidator.createElement.bind(null, type); | ||
19469 | // Legacy hook TODO: Warn if this is accessed | ||
19470 | validatedFactory.type = type; | ||
19471 | |||
19472 | if (process.env.NODE_ENV !== 'production') { | ||
19473 | if (canDefineProperty) { | ||
19474 | Object.defineProperty(validatedFactory, 'type', { | ||
19475 | enumerable: false, | ||
19476 | get: function () { | ||
19477 | process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined; | ||
19478 | Object.defineProperty(this, 'type', { | ||
19479 | value: type | ||
19480 | }); | ||
19481 | return type; | ||
19482 | } | ||
19483 | }); | ||
19484 | } | ||
19485 | } | ||
19486 | |||
19487 | return validatedFactory; | ||
19488 | }, | ||
19489 | |||
19490 | cloneElement: function (element, props, children) { | ||
19491 | var newElement = ReactElement.cloneElement.apply(this, arguments); | ||
19492 | for (var i = 2; i < arguments.length; i++) { | ||
19493 | validateChildKeys(arguments[i], newElement.type); | ||
19494 | } | ||
19495 | validatePropTypes(newElement); | ||
19496 | return newElement; | ||
19497 | } | ||
19498 | |||
19499 | }; | ||
19500 | |||
19501 | module.exports = ReactElementValidator; | ||
19502 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
19503 | |||
19504 | /***/ }, | ||
19505 | /* 157 */ | ||
19506 | /***/ function(module, exports) { | ||
19507 | |||
19508 | /** | ||
19509 | * Copyright 2013-2015, Facebook, Inc. | ||
19510 | * All rights reserved. | ||
19511 | * | ||
19512 | * This source code is licensed under the BSD-style license found in the | ||
19513 | * LICENSE file in the root directory of this source tree. An additional grant | ||
19514 | * of patent rights can be found in the PATENTS file in the same directory. | ||
19515 | * | ||
19516 | * @providesModule mapObject | ||
19517 | */ | ||
19518 | |||
19519 | 'use strict'; | ||
19520 | |||
19521 | var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
19522 | |||
19523 | /** | ||
19524 | * Executes the provided `callback` once for each enumerable own property in the | ||
19525 | * object and constructs a new object from the results. The `callback` is | ||
19526 | * invoked with three arguments: | ||
19527 | * | ||
19528 | * - the property value | ||
19529 | * - the property name | ||
19530 | * - the object being traversed | ||
19531 | * | ||
19532 | * Properties that are added after the call to `mapObject` will not be visited | ||
19533 | * by `callback`. If the values of existing properties are changed, the value | ||
19534 | * passed to `callback` will be the value at the time `mapObject` visits them. | ||
19535 | * Properties that are deleted before being visited are not visited. | ||
19536 | * | ||
19537 | * @grep function objectMap() | ||
19538 | * @grep function objMap() | ||
19539 | * | ||
19540 | * @param {?object} object | ||
19541 | * @param {function} callback | ||
19542 | * @param {*} context | ||
19543 | * @return {?object} | ||
19544 | */ | ||
19545 | function mapObject(object, callback, context) { | ||
19546 | if (!object) { | ||
19547 | return null; | ||
19548 | } | ||
19549 | var result = {}; | ||
19550 | for (var name in object) { | ||
19551 | if (hasOwnProperty.call(object, name)) { | ||
19552 | result[name] = callback.call(context, object[name], name, object); | ||
19553 | } | ||
19554 | } | ||
19555 | return result; | ||
19556 | } | ||
19557 | |||
19558 | module.exports = mapObject; | ||
19559 | |||
19560 | /***/ }, | ||
19561 | /* 158 */ | ||
19562 | /***/ function(module, exports, __webpack_require__) { | ||
19563 | |||
19564 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
19565 | * Copyright 2013-2015, Facebook, Inc. | ||
19566 | * All rights reserved. | ||
19567 | * | ||
19568 | * This source code is licensed under the BSD-style license found in the | ||
19569 | * LICENSE file in the root directory of this source tree. An additional grant | ||
19570 | * of patent rights can be found in the PATENTS file in the same directory. | ||
19571 | * | ||
19572 | * @providesModule onlyChild | ||
19573 | */ | ||
19574 | 'use strict'; | ||
19575 | |||
19576 | var ReactElement = __webpack_require__(44); | ||
19577 | |||
19578 | var invariant = __webpack_require__(15); | ||
19579 | |||
19580 | /** | ||
19581 | * Returns the first child in a collection of children and verifies that there | ||
19582 | * is only one child in the collection. The current implementation of this | ||
19583 | * function assumes that a single child gets passed without a wrapper, but the | ||
19584 | * purpose of this helper function is to abstract away the particular structure | ||
19585 | * of children. | ||
19586 | * | ||
19587 | * @param {?object} children Child collection structure. | ||
19588 | * @return {ReactComponent} The first and only `ReactComponent` contained in the | ||
19589 | * structure. | ||
19590 | */ | ||
19591 | function onlyChild(children) { | ||
19592 | !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : undefined; | ||
19593 | return children; | ||
19594 | } | ||
19595 | |||
19596 | module.exports = onlyChild; | ||
19597 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
19598 | |||
19599 | /***/ }, | ||
19600 | /* 159 */ | ||
19601 | /***/ function(module, exports, __webpack_require__) { | ||
19602 | |||
19603 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
19604 | * Copyright 2013-2015, Facebook, Inc. | ||
19605 | * All rights reserved. | ||
19606 | * | ||
19607 | * This source code is licensed under the BSD-style license found in the | ||
19608 | * LICENSE file in the root directory of this source tree. An additional grant | ||
19609 | * of patent rights can be found in the PATENTS file in the same directory. | ||
19610 | * | ||
19611 | * @providesModule deprecated | ||
19612 | */ | ||
19613 | |||
19614 | 'use strict'; | ||
19615 | |||
19616 | var assign = __webpack_require__(41); | ||
19617 | var warning = __webpack_require__(27); | ||
19618 | |||
19619 | /** | ||
19620 | * This will log a single deprecation notice per function and forward the call | ||
19621 | * on to the new API. | ||
19622 | * | ||
19623 | * @param {string} fnName The name of the function | ||
19624 | * @param {string} newModule The module that fn will exist in | ||
19625 | * @param {string} newPackage The module that fn will exist in | ||
19626 | * @param {*} ctx The context this forwarded call should run in | ||
19627 | * @param {function} fn The function to forward on to | ||
19628 | * @return {function} The function that will warn once and then call fn | ||
19629 | */ | ||
19630 | function deprecated(fnName, newModule, newPackage, ctx, fn) { | ||
19631 | var warned = false; | ||
19632 | if (process.env.NODE_ENV !== 'production') { | ||
19633 | var newFn = function () { | ||
19634 | process.env.NODE_ENV !== 'production' ? warning(warned, | ||
19635 | // Require examples in this string must be split to prevent React's | ||
19636 | // build tools from mistaking them for real requires. | ||
19637 | // Otherwise the build tools will attempt to build a '%s' module. | ||
19638 | 'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : undefined; | ||
19639 | warned = true; | ||
19640 | return fn.apply(ctx, arguments); | ||
19641 | }; | ||
19642 | // We need to make sure all properties of the original fn are copied over. | ||
19643 | // In particular, this is needed to support PropTypes | ||
19644 | return assign(newFn, fn); | ||
19645 | } | ||
19646 | |||
19647 | return fn; | ||
19648 | } | ||
19649 | |||
19650 | module.exports = deprecated; | ||
19651 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
19652 | |||
19653 | /***/ }, | ||
19654 | /* 160 */ | ||
19655 | /***/ function(module, exports, __webpack_require__) { | ||
19656 | |||
19657 | 'use strict'; | ||
19658 | |||
19659 | module.exports = __webpack_require__(5); | ||
19660 | |||
19661 | |||
19662 | /***/ }, | ||
19663 | /* 161 */ | ||
19664 | /***/ function(module, exports, __webpack_require__) { | ||
19665 | |||
19666 | /* | ||
19667 | * GregorianCalendar class | ||
19668 | * @ignore | ||
19669 | * @author yiminghe@gmail.com | ||
19670 | */ | ||
19671 | 'use strict'; | ||
19672 | |||
19673 | var toInt = parseInt; | ||
19674 | var Utils = __webpack_require__(162); | ||
19675 | var defaultLocale = __webpack_require__(164); | ||
19676 | var Const = __webpack_require__(163); | ||
19677 | |||
19678 | /* | ||
19679 | * GregorianCalendar class. | ||
19680 | * | ||
19681 | * - no arguments: | ||
19682 | * Constructs a default GregorianCalendar using the current time | ||
19683 | * in the default time zone with the default locale. | ||
19684 | * - one argument locale: | ||
19685 | * Constructs a GregorianCalendar | ||
19686 | * based on the current time in the default time zone with the given locale. | ||
19687 | * | ||
19688 | * @class Date.Gregorian | ||
19689 | */ | ||
19690 | function GregorianCalendar(loc) { | ||
19691 | var locale = loc || defaultLocale; | ||
19692 | |||
19693 | this.locale = locale; | ||
19694 | |||
19695 | this.fields = []; | ||
19696 | |||
19697 | /* | ||
19698 | * The currently set time for this date. | ||
19699 | * @protected | ||
19700 | * @type Number|undefined | ||
19701 | */ | ||
19702 | this.time = undefined; | ||
19703 | /* | ||
19704 | * The timezoneOffset in minutes used by this date. | ||
19705 | * @type Number | ||
19706 | * @protected | ||
19707 | */ | ||
19708 | |||
19709 | this.timezoneOffset = locale.timezoneOffset; | ||
19710 | |||
19711 | /* | ||
19712 | * The first day of the week | ||
19713 | * @type Number | ||
19714 | * @protected | ||
19715 | */ | ||
19716 | this.firstDayOfWeek = locale.firstDayOfWeek; | ||
19717 | |||
19718 | /* | ||
19719 | * The number of days required for the first week in a month or year, | ||
19720 | * with possible values from 1 to 7. | ||
19721 | * @@protected | ||
19722 | * @type Number | ||
19723 | */ | ||
19724 | this.minimalDaysInFirstWeek = locale.minimalDaysInFirstWeek; | ||
19725 | |||
19726 | this.fieldsComputed = false; | ||
19727 | } | ||
19728 | |||
19729 | Utils.mix(GregorianCalendar, Const); | ||
19730 | |||
19731 | Utils.mix(GregorianCalendar, { | ||
19732 | Utils: Utils, | ||
19733 | |||
19734 | defaultLocale: defaultLocale, | ||
19735 | |||
19736 | /* | ||
19737 | * Determines if the given year is a leap year. | ||
19738 | * Returns true if the given year is a leap year. To specify BC year numbers, | ||
19739 | * 1 - year number must be given. For example, year BC 4 is specified as -3. | ||
19740 | * @param {Number} year the given year. | ||
19741 | * @returns {Boolean} true if the given year is a leap year; false otherwise. | ||
19742 | * @static | ||
19743 | * @method | ||
19744 | */ | ||
19745 | isLeapYear: Utils.isLeapYear, | ||
19746 | |||
19747 | /* | ||
19748 | * Enum indicating year field of date | ||
19749 | * @type Number | ||
19750 | */ | ||
19751 | YEAR: 1, | ||
19752 | /* | ||
19753 | * Enum indicating month field of date | ||
19754 | * @type Number | ||
19755 | */ | ||
19756 | MONTH: 2, | ||
19757 | /* | ||
19758 | * Enum indicating the day of the month | ||
19759 | * @type Number | ||
19760 | */ | ||
19761 | DAY_OF_MONTH: 3, | ||
19762 | /* | ||
19763 | * Enum indicating the hour (24). | ||
19764 | * @type Number | ||
19765 | */ | ||
19766 | HOUR_OF_DAY: 4, | ||
19767 | /* | ||
19768 | * Enum indicating the minute of the day | ||
19769 | * @type Number | ||
19770 | */ | ||
19771 | MINUTES: 5, | ||
19772 | /* | ||
19773 | * Enum indicating the second of the day | ||
19774 | * @type Number | ||
19775 | */ | ||
19776 | SECONDS: 6, | ||
19777 | /* | ||
19778 | * Enum indicating the millisecond of the day | ||
19779 | * @type Number | ||
19780 | */ | ||
19781 | MILLISECONDS: 7, | ||
19782 | /* | ||
19783 | * Enum indicating the week number within the current year | ||
19784 | * @type Number | ||
19785 | */ | ||
19786 | WEEK_OF_YEAR: 8, | ||
19787 | /* | ||
19788 | * Enum indicating the week number within the current month | ||
19789 | * @type Number | ||
19790 | */ | ||
19791 | WEEK_OF_MONTH: 9, | ||
19792 | |||
19793 | /* | ||
19794 | * Enum indicating the day of the day number within the current year | ||
19795 | * @type Number | ||
19796 | */ | ||
19797 | DAY_OF_YEAR: 10, | ||
19798 | /* | ||
19799 | * Enum indicating the day of the week | ||
19800 | * @type Number | ||
19801 | */ | ||
19802 | DAY_OF_WEEK: 11, | ||
19803 | /* | ||
19804 | * Enum indicating the day of the ordinal number of the day of the week | ||
19805 | * @type Number | ||
19806 | */ | ||
19807 | DAY_OF_WEEK_IN_MONTH: 12, | ||
19808 | |||
19809 | /* | ||
19810 | * Enum indicating am | ||
19811 | * @type Number | ||
19812 | */ | ||
19813 | AM: 0, | ||
19814 | /* | ||
19815 | * Enum indicating pm | ||
19816 | * @type Number | ||
19817 | */ | ||
19818 | PM: 1 | ||
19819 | }); | ||
19820 | |||
19821 | var FIELDS = ['', 'Year', 'Month', 'DayOfMonth', 'HourOfDay', 'Minutes', 'Seconds', 'Milliseconds', 'WeekOfYear', 'WeekOfMonth', 'DayOfYear', 'DayOfWeek', 'DayOfWeekInMonth']; | ||
19822 | |||
19823 | var YEAR = GregorianCalendar.YEAR; | ||
19824 | var MONTH = GregorianCalendar.MONTH; | ||
19825 | var DAY_OF_MONTH = GregorianCalendar.DAY_OF_MONTH; | ||
19826 | var HOUR_OF_DAY = GregorianCalendar.HOUR_OF_DAY; | ||
19827 | var MINUTE = GregorianCalendar.MINUTES; | ||
19828 | var SECONDS = GregorianCalendar.SECONDS; | ||
19829 | |||
19830 | var MILLISECONDS = GregorianCalendar.MILLISECONDS; | ||
19831 | var DAY_OF_WEEK_IN_MONTH = GregorianCalendar.DAY_OF_WEEK_IN_MONTH; | ||
19832 | var DAY_OF_YEAR = GregorianCalendar.DAY_OF_YEAR; | ||
19833 | var DAY_OF_WEEK = GregorianCalendar.DAY_OF_WEEK; | ||
19834 | |||
19835 | var WEEK_OF_MONTH = GregorianCalendar.WEEK_OF_MONTH; | ||
19836 | var WEEK_OF_YEAR = GregorianCalendar.WEEK_OF_YEAR; | ||
19837 | |||
19838 | var MONTH_LENGTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // 0-based | ||
19839 | var LEAP_MONTH_LENGTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // 0-based | ||
19840 | |||
19841 | var ONE_SECOND = 1000; | ||
19842 | var ONE_MINUTE = 60 * ONE_SECOND; | ||
19843 | var ONE_HOUR = 60 * ONE_MINUTE; | ||
19844 | var ONE_DAY = 24 * ONE_HOUR; | ||
19845 | var ONE_WEEK = ONE_DAY * 7; | ||
19846 | |||
19847 | var EPOCH_OFFSET = 719163; // Fixed date of January 1, 1970 (Gregorian) | ||
19848 | |||
19849 | var mod = Utils.mod; | ||
19850 | var _isLeapYear = Utils.isLeapYear; | ||
19851 | var floorDivide = Math.floor; | ||
19852 | |||
19853 | var MIN_VALUES = [undefined, 1, // YEAR | ||
19854 | GregorianCalendar.JANUARY, // MONTH | ||
19855 | 1, // DAY_OF_MONTH | ||
19856 | 0, // HOUR_OF_DAY | ||
19857 | 0, // MINUTE | ||
19858 | 0, // SECONDS | ||
19859 | 0, // MILLISECONDS | ||
19860 | |||
19861 | 1, // WEEK_OF_YEAR | ||
19862 | undefined, // WEEK_OF_MONTH | ||
19863 | |||
19864 | 1, // DAY_OF_YEAR | ||
19865 | GregorianCalendar.SUNDAY, // DAY_OF_WEEK | ||
19866 | 1]; | ||
19867 | |||
19868 | // DAY_OF_WEEK_IN_MONTH | ||
19869 | var MAX_VALUES = [undefined, 292278994, // YEAR | ||
19870 | GregorianCalendar.DECEMBER, // MONTH | ||
19871 | undefined, // DAY_OF_MONTH | ||
19872 | 23, // HOUR_OF_DAY | ||
19873 | 59, // MINUTE | ||
19874 | 59, // SECONDS | ||
19875 | 999, // MILLISECONDS | ||
19876 | undefined, // WEEK_OF_YEAR | ||
19877 | undefined, // WEEK_OF_MONTH | ||
19878 | undefined, // DAY_OF_YEAR | ||
19879 | GregorianCalendar.SATURDAY, // DAY_OF_WEEK | ||
19880 | undefined]; | ||
19881 | |||
19882 | // ------------------- private start | ||
19883 | |||
19884 | // DAY_OF_WEEK_IN_MONTH | ||
19885 | function getMonthLength(year, month) { | ||
19886 | return _isLeapYear(year) ? LEAP_MONTH_LENGTH[month] : MONTH_LENGTH[month]; | ||
19887 | } | ||
19888 | |||
19889 | function getYearLength(year) { | ||
19890 | return _isLeapYear(year) ? 366 : 365; | ||
19891 | } | ||
19892 | |||
19893 | function adjustDayOfMonth(self) { | ||
19894 | var fields = self.fields; | ||
19895 | var year = fields[YEAR]; | ||
19896 | var month = fields[MONTH]; | ||
19897 | var monthLen = getMonthLength(year, month); | ||
19898 | var dayOfMonth = fields[DAY_OF_MONTH]; | ||
19899 | if (dayOfMonth > monthLen) { | ||
19900 | self.set(DAY_OF_MONTH, monthLen); | ||
19901 | } | ||
19902 | } | ||
19903 | |||
19904 | function getDayOfWeekDateOnOrBefore(fixedDate, dayOfWeek) { | ||
19905 | // 1.1.1 is monday | ||
19906 | // one week has 7 days | ||
19907 | return fixedDate - mod(fixedDate - dayOfWeek, 7); | ||
19908 | } | ||
19909 | |||
19910 | function getWeekNumber(self, fixedDay1, fixedDate) { | ||
19911 | var fixedDay1st = getDayOfWeekDateOnOrBefore(fixedDay1 + 6, self.firstDayOfWeek); | ||
19912 | var nDays = fixedDay1st - fixedDay1; | ||
19913 | if (nDays >= self.minimalDaysInFirstWeek) { | ||
19914 | fixedDay1st -= 7; | ||
19915 | } | ||
19916 | var normalizedDayOfPeriod = fixedDate - fixedDay1st; | ||
19917 | return floorDivide(normalizedDayOfPeriod / 7) + 1; | ||
19918 | } | ||
19919 | |||
19920 | // ------------------- private end | ||
19921 | |||
19922 | GregorianCalendar.prototype = { | ||
19923 | constructor: GregorianCalendar, | ||
19924 | |||
19925 | isGregorianCalendar: 1, | ||
19926 | |||
19927 | /* | ||
19928 | * Determines if current year is a leap year. | ||
19929 | * Returns true if the given year is a leap year. To specify BC year numbers, | ||
19930 | * 1 - year number must be given. For example, year BC 4 is specified as -3. | ||
19931 | * @returns {Boolean} true if the given year is a leap year; false otherwise. | ||
19932 | * @method | ||
19933 | * @member Date.Gregorian | ||
19934 | */ | ||
19935 | isLeapYear: function isLeapYear() { | ||
19936 | return _isLeapYear(this.getYear()); | ||
19937 | }, | ||
19938 | |||
19939 | /* | ||
19940 | * Return local info for current date instance | ||
19941 | * @returns {Object} | ||
19942 | */ | ||
19943 | getLocale: function getLocale() { | ||
19944 | return this.locale; | ||
19945 | }, | ||
19946 | |||
19947 | /* | ||
19948 | * Returns the minimum value for | ||
19949 | * the given calendar field of this GregorianCalendar instance. | ||
19950 | * The minimum value is defined as the smallest value | ||
19951 | * returned by the get method for any possible time value, | ||
19952 | * taking into consideration the current values of the getFirstDayOfWeek, | ||
19953 | * getMinimalDaysInFirstWeek. | ||
19954 | * @param field the calendar field. | ||
19955 | * @returns {Number} the minimum value for the given calendar field. | ||
19956 | */ | ||
19957 | getActualMinimum: function getActualMinimum(field) { | ||
19958 | if (MIN_VALUES[field] !== undefined) { | ||
19959 | return MIN_VALUES[field]; | ||
19960 | } | ||
19961 | if (field === WEEK_OF_MONTH) { | ||
19962 | var cal = this.clone(); | ||
19963 | cal.clear(); | ||
19964 | cal.set(this.fields[YEAR], this.fields[MONTH], 1); | ||
19965 | return cal.get(WEEK_OF_MONTH); | ||
19966 | } | ||
19967 | |||
19968 | throw new Error('minimum value not defined!'); | ||
19969 | }, | ||
19970 | |||
19971 | /* | ||
19972 | * Returns the maximum value for the given calendar field | ||
19973 | * of this GregorianCalendar instance. | ||
19974 | * The maximum value is defined as the largest value returned | ||
19975 | * by the get method for any possible time value, taking into consideration | ||
19976 | * the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek methods. | ||
19977 | * @param field the calendar field. | ||
19978 | * @returns {Number} the maximum value for the given calendar field. | ||
19979 | */ | ||
19980 | getActualMaximum: function getActualMaximum(field) { | ||
19981 | if (MAX_VALUES[field] !== undefined) { | ||
19982 | return MAX_VALUES[field]; | ||
19983 | } | ||
19984 | var value = undefined; | ||
19985 | var fields = this.fields; | ||
19986 | switch (field) { | ||
19987 | case DAY_OF_MONTH: | ||
19988 | value = getMonthLength(fields[YEAR], fields[MONTH]); | ||
19989 | break; | ||
19990 | |||
19991 | case WEEK_OF_YEAR: | ||
19992 | var endOfYear = this.clone(); | ||
19993 | endOfYear.clear(); | ||
19994 | endOfYear.set(fields[YEAR], GregorianCalendar.DECEMBER, 31); | ||
19995 | value = endOfYear.get(WEEK_OF_YEAR); | ||
19996 | if (value === 1) { | ||
19997 | value = 52; | ||
19998 | } | ||
19999 | break; | ||
20000 | |||
20001 | case WEEK_OF_MONTH: | ||
20002 | var endOfMonth = this.clone(); | ||
20003 | endOfMonth.clear(); | ||
20004 | endOfMonth.set(fields[YEAR], fields[MONTH], getMonthLength(fields[YEAR], fields[MONTH])); | ||
20005 | value = endOfMonth.get(WEEK_OF_MONTH); | ||
20006 | break; | ||
20007 | |||
20008 | case DAY_OF_YEAR: | ||
20009 | value = getYearLength(fields[YEAR]); | ||
20010 | break; | ||
20011 | |||
20012 | case DAY_OF_WEEK_IN_MONTH: | ||
20013 | value = toInt((getMonthLength(fields[YEAR], fields[MONTH]) - 1) / 7) + 1; | ||
20014 | break; | ||
20015 | default: | ||
20016 | break; | ||
20017 | } | ||
20018 | if (value === undefined) { | ||
20019 | throw new Error('maximum value not defined!'); | ||
20020 | } | ||
20021 | return value; | ||
20022 | }, | ||
20023 | |||
20024 | /* | ||
20025 | * Determines if the given calendar field has a value set, | ||
20026 | * including cases that the value has been set by internal fields calculations | ||
20027 | * triggered by a get method call. | ||
20028 | * @param field the calendar field to be cleared. | ||
20029 | * @returns {boolean} true if the given calendar field has a value set; false otherwise. | ||
20030 | */ | ||
20031 | isSet: function isSet(field) { | ||
20032 | return this.fields[field] !== undefined; | ||
20033 | }, | ||
20034 | |||
20035 | /* | ||
20036 | * Converts the time value (millisecond offset from the Epoch) | ||
20037 | * to calendar field values. | ||
20038 | * @protected | ||
20039 | */ | ||
20040 | computeFields: function computeFields() { | ||
20041 | var time = this.time; | ||
20042 | var timezoneOffset = this.timezoneOffset * ONE_MINUTE; | ||
20043 | var fixedDate = toInt(timezoneOffset / ONE_DAY); | ||
20044 | var timeOfDay = timezoneOffset % ONE_DAY; | ||
20045 | fixedDate += toInt(time / ONE_DAY); | ||
20046 | timeOfDay += time % ONE_DAY; | ||
20047 | if (timeOfDay >= ONE_DAY) { | ||
20048 | timeOfDay -= ONE_DAY; | ||
20049 | fixedDate++; | ||
20050 | } else { | ||
20051 | while (timeOfDay < 0) { | ||
20052 | timeOfDay += ONE_DAY; | ||
20053 | fixedDate--; | ||
20054 | } | ||
20055 | } | ||
20056 | |||
20057 | fixedDate += EPOCH_OFFSET; | ||
20058 | |||
20059 | var date = Utils.getGregorianDateFromFixedDate(fixedDate); | ||
20060 | |||
20061 | var year = date.year; | ||
20062 | |||
20063 | var fields = this.fields; | ||
20064 | fields[YEAR] = year; | ||
20065 | fields[MONTH] = date.month; | ||
20066 | fields[DAY_OF_MONTH] = date.dayOfMonth; | ||
20067 | fields[DAY_OF_WEEK] = date.dayOfWeek; | ||
20068 | |||
20069 | if (timeOfDay !== 0) { | ||
20070 | fields[HOUR_OF_DAY] = toInt(timeOfDay / ONE_HOUR); | ||
20071 | var r = timeOfDay % ONE_HOUR; | ||
20072 | fields[MINUTE] = toInt(r / ONE_MINUTE); | ||
20073 | r %= ONE_MINUTE; | ||
20074 | fields[SECONDS] = toInt(r / ONE_SECOND); | ||
20075 | fields[MILLISECONDS] = r % ONE_SECOND; | ||
20076 | } else { | ||
20077 | fields[HOUR_OF_DAY] = fields[MINUTE] = fields[SECONDS] = fields[MILLISECONDS] = 0; | ||
20078 | } | ||
20079 | |||
20080 | var fixedDateJan1 = Utils.getFixedDate(year, GregorianCalendar.JANUARY, 1); | ||
20081 | var dayOfYear = fixedDate - fixedDateJan1 + 1; | ||
20082 | var fixDateMonth1 = fixedDate - date.dayOfMonth + 1; | ||
20083 | |||
20084 | fields[DAY_OF_YEAR] = dayOfYear; | ||
20085 | fields[DAY_OF_WEEK_IN_MONTH] = toInt((date.dayOfMonth - 1) / 7) + 1; | ||
20086 | |||
20087 | var weekOfYear = getWeekNumber(this, fixedDateJan1, fixedDate); | ||
20088 | |||
20089 | // 本周没有足够的时间在当前年 | ||
20090 | if (weekOfYear === 0) { | ||
20091 | // If the date belongs to the last week of the | ||
20092 | // previous year, use the week number of "12/31" of | ||
20093 | // the "previous" year. | ||
20094 | var fixedDec31 = fixedDateJan1 - 1; | ||
20095 | var prevJan1 = fixedDateJan1 - getYearLength(year - 1); | ||
20096 | weekOfYear = getWeekNumber(this, prevJan1, fixedDec31); | ||
20097 | } else | ||
20098 | // 本周是年末最后一周,可能有足够的时间在新的一年 | ||
20099 | if (weekOfYear >= 52) { | ||
20100 | var nextJan1 = fixedDateJan1 + getYearLength(year); | ||
20101 | var nextJan1st = getDayOfWeekDateOnOrBefore(nextJan1 + 6, this.firstDayOfWeek); | ||
20102 | var nDays = nextJan1st - nextJan1; | ||
20103 | // 本周有足够天数在新的一年 | ||
20104 | if (nDays >= this.minimalDaysInFirstWeek && | ||
20105 | // 当天确实在本周,weekOfYear === 53 时是不需要这个判断 | ||
20106 | fixedDate >= nextJan1st - 7) { | ||
20107 | weekOfYear = 1; | ||
20108 | } | ||
20109 | } | ||
20110 | |||
20111 | fields[WEEK_OF_YEAR] = weekOfYear; | ||
20112 | fields[WEEK_OF_MONTH] = getWeekNumber(this, fixDateMonth1, fixedDate); | ||
20113 | |||
20114 | this.fieldsComputed = true; | ||
20115 | }, | ||
20116 | |||
20117 | /* | ||
20118 | * Converts calendar field values to the time value | ||
20119 | * (millisecond offset from the Epoch). | ||
20120 | * @protected | ||
20121 | */ | ||
20122 | computeTime: function computeTime() { | ||
20123 | var year = undefined; | ||
20124 | var fields = this.fields; | ||
20125 | if (this.isSet(YEAR)) { | ||
20126 | year = fields[YEAR]; | ||
20127 | } else { | ||
20128 | year = new Date().getFullYear(); | ||
20129 | } | ||
20130 | var timeOfDay = 0; | ||
20131 | if (this.isSet(HOUR_OF_DAY)) { | ||
20132 | timeOfDay += fields[HOUR_OF_DAY]; | ||
20133 | } | ||
20134 | timeOfDay *= 60; | ||
20135 | timeOfDay += fields[MINUTE] || 0; | ||
20136 | timeOfDay *= 60; | ||
20137 | timeOfDay += fields[SECONDS] || 0; | ||
20138 | timeOfDay *= 1000; | ||
20139 | timeOfDay += fields[MILLISECONDS] || 0; | ||
20140 | var fixedDate = 0; | ||
20141 | fields[YEAR] = year; | ||
20142 | fixedDate = fixedDate + this.getFixedDate(); | ||
20143 | // millis represents local wall-clock time in milliseconds. | ||
20144 | var millis = (fixedDate - EPOCH_OFFSET) * ONE_DAY + timeOfDay; | ||
20145 | millis -= this.timezoneOffset * ONE_MINUTE; | ||
20146 | this.time = millis; | ||
20147 | this.computeFields(); | ||
20148 | }, | ||
20149 | |||
20150 | /* | ||
20151 | * Fills in any unset fields in the calendar fields. First, | ||
20152 | * the computeTime() method is called if the time value (millisecond offset from the Epoch) | ||
20153 | * has not been calculated from calendar field values. | ||
20154 | * Then, the computeFields() method is called to calculate all calendar field values. | ||
20155 | * @protected | ||
20156 | */ | ||
20157 | complete: function complete() { | ||
20158 | if (this.time === undefined) { | ||
20159 | this.computeTime(); | ||
20160 | } | ||
20161 | if (!this.fieldsComputed) { | ||
20162 | this.computeFields(); | ||
20163 | } | ||
20164 | }, | ||
20165 | |||
20166 | getFixedDate: function getFixedDate() { | ||
20167 | var self = this; | ||
20168 | |||
20169 | var fields = self.fields; | ||
20170 | |||
20171 | var firstDayOfWeekCfg = self.firstDayOfWeek; | ||
20172 | |||
20173 | var year = fields[YEAR]; | ||
20174 | |||
20175 | var month = GregorianCalendar.JANUARY; | ||
20176 | |||
20177 | if (self.isSet(MONTH)) { | ||
20178 | month = fields[MONTH]; | ||
20179 | if (month > GregorianCalendar.DECEMBER) { | ||
20180 | year += toInt(month / 12); | ||
20181 | month %= 12; | ||
20182 | } else if (month < GregorianCalendar.JANUARY) { | ||
20183 | year += floorDivide(month / 12); | ||
20184 | month = mod(month, 12); | ||
20185 | } | ||
20186 | } | ||
20187 | |||
20188 | // Get the fixed date since Jan 1, 1 (Gregorian). We are on | ||
20189 | // the first day of either `month' or January in 'year'. | ||
20190 | var fixedDate = Utils.getFixedDate(year, month, 1); | ||
20191 | var firstDayOfWeek = undefined; | ||
20192 | var dayOfWeek = self.firstDayOfWeek; | ||
20193 | |||
20194 | if (self.isSet(DAY_OF_WEEK)) { | ||
20195 | dayOfWeek = fields[DAY_OF_WEEK]; | ||
20196 | } | ||
20197 | |||
20198 | if (self.isSet(MONTH)) { | ||
20199 | if (self.isSet(DAY_OF_MONTH)) { | ||
20200 | fixedDate += fields[DAY_OF_MONTH] - 1; | ||
20201 | } else { | ||
20202 | if (self.isSet(WEEK_OF_MONTH)) { | ||
20203 | firstDayOfWeek = getDayOfWeekDateOnOrBefore(fixedDate + 6, firstDayOfWeekCfg); | ||
20204 | |||
20205 | // If we have enough days in the first week, then | ||
20206 | // move to the previous week. | ||
20207 | if (firstDayOfWeek - fixedDate >= self.minimalDaysInFirstWeek) { | ||
20208 | firstDayOfWeek -= 7; | ||
20209 | } | ||
20210 | |||
20211 | if (dayOfWeek !== firstDayOfWeekCfg) { | ||
20212 | firstDayOfWeek = getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6, dayOfWeek); | ||
20213 | } | ||
20214 | |||
20215 | fixedDate = firstDayOfWeek + 7 * (fields[WEEK_OF_MONTH] - 1); | ||
20216 | } else { | ||
20217 | var dowim = undefined; | ||
20218 | if (self.isSet(DAY_OF_WEEK_IN_MONTH)) { | ||
20219 | dowim = fields[DAY_OF_WEEK_IN_MONTH]; | ||
20220 | } else { | ||
20221 | dowim = 1; | ||
20222 | } | ||
20223 | var lastDate = 7 * dowim; | ||
20224 | if (dowim < 0) { | ||
20225 | lastDate = getMonthLength(year, month) + 7 * (dowim + 1); | ||
20226 | } | ||
20227 | fixedDate = getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1, dayOfWeek); | ||
20228 | } | ||
20229 | } | ||
20230 | } else { | ||
20231 | // We are on the first day of the year. | ||
20232 | if (self.isSet(DAY_OF_YEAR)) { | ||
20233 | fixedDate += fields[DAY_OF_YEAR] - 1; | ||
20234 | } else if (self.isSet(WEEK_OF_YEAR)) { | ||
20235 | firstDayOfWeek = getDayOfWeekDateOnOrBefore(fixedDate + 6, firstDayOfWeekCfg); | ||
20236 | // If we have enough days in the first week, then move | ||
20237 | // to the previous week. | ||
20238 | if (firstDayOfWeek - fixedDate >= self.minimalDaysInFirstWeek) { | ||
20239 | firstDayOfWeek -= 7; | ||
20240 | } | ||
20241 | if (dayOfWeek !== firstDayOfWeekCfg) { | ||
20242 | firstDayOfWeek = getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6, dayOfWeek); | ||
20243 | } | ||
20244 | fixedDate = firstDayOfWeek + 7 * (fields[WEEK_OF_YEAR] - 1); | ||
20245 | } | ||
20246 | } | ||
20247 | |||
20248 | return fixedDate; | ||
20249 | }, | ||
20250 | |||
20251 | /* | ||
20252 | * Returns this Calendar's time value in milliseconds | ||
20253 | * @member Date.Gregorian | ||
20254 | * @returns {Number} the current time as UTC milliseconds from the epoch. | ||
20255 | */ | ||
20256 | getTime: function getTime() { | ||
20257 | if (this.time === undefined) { | ||
20258 | this.computeTime(); | ||
20259 | } | ||
20260 | return this.time; | ||
20261 | }, | ||
20262 | |||
20263 | /* | ||
20264 | * Sets this Calendar's current time from the given long value. | ||
20265 | * @param time the new time in UTC milliseconds from the epoch. | ||
20266 | */ | ||
20267 | setTime: function setTime(time) { | ||
20268 | this.time = time; | ||
20269 | this.fieldsComputed = false; | ||
20270 | this.complete(); | ||
20271 | }, | ||
20272 | |||
20273 | /* | ||
20274 | * Returns the value of the given calendar field. | ||
20275 | * @param field the given calendar field. | ||
20276 | * @returns {Number} the value for the given calendar field. | ||
20277 | */ | ||
20278 | get: function get(field) { | ||
20279 | this.complete(); | ||
20280 | return this.fields[field]; | ||
20281 | }, | ||
20282 | |||
20283 | /* | ||
20284 | * Returns the year of the given calendar field. | ||
20285 | * @method getYear | ||
20286 | * @returns {Number} the year for the given calendar field. | ||
20287 | */ | ||
20288 | |||
20289 | /* | ||
20290 | * Returns the month of the given calendar field. | ||
20291 | * @method getMonth | ||
20292 | * @returns {Number} the month for the given calendar field. | ||
20293 | */ | ||
20294 | |||
20295 | /* | ||
20296 | * Returns the day of month of the given calendar field. | ||
20297 | * @method getDayOfMonth | ||
20298 | * @returns {Number} the day of month for the given calendar field. | ||
20299 | */ | ||
20300 | |||
20301 | /* | ||
20302 | * Returns the hour of day of the given calendar field. | ||
20303 | * @method getHourOfDay | ||
20304 | * @returns {Number} the hour of day for the given calendar field. | ||
20305 | */ | ||
20306 | |||
20307 | /* | ||
20308 | * Returns the minute of the given calendar field. | ||
20309 | * @method getMinute | ||
20310 | * @returns {Number} the minute for the given calendar field. | ||
20311 | */ | ||
20312 | |||
20313 | /* | ||
20314 | * Returns the second of the given calendar field. | ||
20315 | * @method getSecond | ||
20316 | * @returns {Number} the second for the given calendar field. | ||
20317 | */ | ||
20318 | |||
20319 | /* | ||
20320 | * Returns the millisecond of the given calendar field. | ||
20321 | * @method getMilliSecond | ||
20322 | * @returns {Number} the millisecond for the given calendar field. | ||
20323 | */ | ||
20324 | |||
20325 | /* | ||
20326 | * Returns the week of year of the given calendar field. | ||
20327 | * @method getWeekOfYear | ||
20328 | * @returns {Number} the week of year for the given calendar field. | ||
20329 | */ | ||
20330 | |||
20331 | /* | ||
20332 | * Returns the week of month of the given calendar field. | ||
20333 | * @method getWeekOfMonth | ||
20334 | * @returns {Number} the week of month for the given calendar field. | ||
20335 | */ | ||
20336 | |||
20337 | /* | ||
20338 | * Returns the day of year of the given calendar field. | ||
20339 | * @method getDayOfYear | ||
20340 | * @returns {Number} the day of year for the given calendar field. | ||
20341 | */ | ||
20342 | |||
20343 | /* | ||
20344 | * Returns the day of week of the given calendar field. | ||
20345 | * @method getDayOfWeek | ||
20346 | * @returns {Number} the day of week for the given calendar field. | ||
20347 | */ | ||
20348 | |||
20349 | /* | ||
20350 | * Returns the day of week in month of the given calendar field. | ||
20351 | * @method getDayOfWeekInMonth | ||
20352 | * @returns {Number} the day of week in month for the given calendar field. | ||
20353 | */ | ||
20354 | |||
20355 | /* | ||
20356 | * Sets the given calendar field to the given value. | ||
20357 | * @param field the given calendar field. | ||
20358 | * @param v the value to be set for the given calendar field. | ||
20359 | */ | ||
20360 | set: function set(field, v) { | ||
20361 | var len = arguments.length; | ||
20362 | if (len === 2) { | ||
20363 | this.fields[field] = v; | ||
20364 | } else if (len < MILLISECONDS + 1) { | ||
20365 | for (var i = 0; i < len; i++) { | ||
20366 | this.fields[YEAR + i] = arguments[i]; | ||
20367 | } | ||
20368 | } else { | ||
20369 | throw new Error('illegal arguments for GregorianCalendar set'); | ||
20370 | } | ||
20371 | this.time = undefined; | ||
20372 | }, | ||
20373 | |||
20374 | /* | ||
20375 | * Set the year of the given calendar field. | ||
20376 | * @method setYear | ||
20377 | */ | ||
20378 | |||
20379 | /* | ||
20380 | * Set the month of the given calendar field. | ||
20381 | * @method setMonth | ||
20382 | */ | ||
20383 | |||
20384 | /* | ||
20385 | * Set the day of month of the given calendar field. | ||
20386 | * @method setDayOfMonth | ||
20387 | */ | ||
20388 | |||
20389 | /* | ||
20390 | * Set the hour of day of the given calendar field. | ||
20391 | * @method setHourOfDay | ||
20392 | */ | ||
20393 | |||
20394 | /* | ||
20395 | * Set the minute of the given calendar field. | ||
20396 | * @method setMinute | ||
20397 | */ | ||
20398 | |||
20399 | /* | ||
20400 | * Set the second of the given calendar field. | ||
20401 | * @method setSecond | ||
20402 | */ | ||
20403 | |||
20404 | /* | ||
20405 | * Set the millisecond of the given calendar field. | ||
20406 | * @method setMilliSecond | ||
20407 | */ | ||
20408 | |||
20409 | /* | ||
20410 | * Set the week of year of the given calendar field. | ||
20411 | * @method setWeekOfYear | ||
20412 | */ | ||
20413 | |||
20414 | /* | ||
20415 | * Set the week of month of the given calendar field. | ||
20416 | * @method setWeekOfMonth | ||
20417 | */ | ||
20418 | |||
20419 | /* | ||
20420 | * Set the day of year of the given calendar field. | ||
20421 | * @method setDayOfYear | ||
20422 | */ | ||
20423 | |||
20424 | /* | ||
20425 | * Set the day of week of the given calendar field. | ||
20426 | * @method setDayOfWeek | ||
20427 | */ | ||
20428 | |||
20429 | /* | ||
20430 | * Set the day of week in month of the given calendar field. | ||
20431 | * @method setDayOfWeekInMonth | ||
20432 | */ | ||
20433 | |||
20434 | /* | ||
20435 | * add for specified field based on two rules: | ||
20436 | * | ||
20437 | * - Add rule 1. The value of field after the call minus the value of field before the | ||
20438 | * call is amount, modulo any overflow that has occurred in field | ||
20439 | * Overflow occurs when a field value exceeds its range and, | ||
20440 | * as a result, the next larger field is incremented or | ||
20441 | * decremented and the field value is adjusted back into its range. | ||
20442 | * | ||
20443 | * - Add rule 2. If a smaller field is expected to be invariant, | ||
20444 | * but it is impossible for it to be equal to its | ||
20445 | * prior value because of changes in its minimum or maximum after | ||
20446 | * field is changed, then its value is adjusted to be as close | ||
20447 | * as possible to its expected value. A smaller field represents a | ||
20448 | * smaller unit of time. HOUR_OF_DAY is a smaller field than | ||
20449 | * DAY_OF_MONTH. No adjustment is made to smaller fields | ||
20450 | * that are not expected to be invariant. The calendar system | ||
20451 | * determines what fields are expected to be invariant. | ||
20452 | * | ||
20453 | * | ||
20454 | * @example | ||
20455 | * use('date/gregorian',function(S, GregorianCalendar){ | ||
20456 | * const d = new GregorianCalendar(); | ||
20457 | * d.set(2012, GregorianCalendar.JANUARY, 31); | ||
20458 | * d.add(Gregorian.MONTH,1); | ||
20459 | * // 2012-2-29 | ||
20460 | * document.writeln('<p>'+d.getYear()+'-'+d.getMonth()+'-'+d.getDayOfWeek()) | ||
20461 | * d.add(Gregorian.MONTH,12); | ||
20462 | * // 2013-2-28 | ||
20463 | * document.writeln('<p>'+d.getYear()+'-'+d.getMonth()+'-'+d.getDayOfWeek()) | ||
20464 | * }); | ||
20465 | * | ||
20466 | * @param field the calendar field. | ||
20467 | * @param {Number} amount he amount of date or time to be added to the field. | ||
20468 | */ | ||
20469 | add: function add(field, a) { | ||
20470 | if (!a) { | ||
20471 | return; | ||
20472 | } | ||
20473 | var amount = a; | ||
20474 | var self = this; | ||
20475 | var fields = self.fields; | ||
20476 | // computer and retrieve original value | ||
20477 | var value = self.get(field); | ||
20478 | if (field === YEAR) { | ||
20479 | value += amount; | ||
20480 | self.set(YEAR, value); | ||
20481 | adjustDayOfMonth(self); | ||
20482 | } else if (field === MONTH) { | ||
20483 | value += amount; | ||
20484 | var yearAmount = floorDivide(value / 12); | ||
20485 | value = mod(value, 12); | ||
20486 | if (yearAmount) { | ||
20487 | self.set(YEAR, fields[YEAR] + yearAmount); | ||
20488 | } | ||
20489 | self.set(MONTH, value); | ||
20490 | adjustDayOfMonth(self); | ||
20491 | } else { | ||
20492 | switch (field) { | ||
20493 | case HOUR_OF_DAY: | ||
20494 | amount *= ONE_HOUR; | ||
20495 | break; | ||
20496 | case MINUTE: | ||
20497 | amount *= ONE_MINUTE; | ||
20498 | break; | ||
20499 | case SECONDS: | ||
20500 | amount *= ONE_SECOND; | ||
20501 | break; | ||
20502 | case MILLISECONDS: | ||
20503 | break; | ||
20504 | case WEEK_OF_MONTH: | ||
20505 | case WEEK_OF_YEAR: | ||
20506 | case DAY_OF_WEEK_IN_MONTH: | ||
20507 | amount *= ONE_WEEK; | ||
20508 | break; | ||
20509 | case DAY_OF_WEEK: | ||
20510 | case DAY_OF_YEAR: | ||
20511 | case DAY_OF_MONTH: | ||
20512 | amount *= ONE_DAY; | ||
20513 | break; | ||
20514 | default: | ||
20515 | throw new Error('illegal field for add'); | ||
20516 | } | ||
20517 | self.setTime(self.time + amount); | ||
20518 | } | ||
20519 | }, | ||
20520 | |||
20521 | /* | ||
20522 | * add the year of the given calendar field. | ||
20523 | * @method addYear | ||
20524 | * @param {Number} amount the signed amount to add to field. | ||
20525 | */ | ||
20526 | |||
20527 | /* | ||
20528 | * add the month of the given calendar field. | ||
20529 | * @method addMonth | ||
20530 | * @param {Number} amount the signed amount to add to field. | ||
20531 | */ | ||
20532 | |||
20533 | /* | ||
20534 | * add the day of month of the given calendar field. | ||
20535 | * @method addDayOfMonth | ||
20536 | * @param {Number} amount the signed amount to add to field. | ||
20537 | */ | ||
20538 | |||
20539 | /* | ||
20540 | * add the hour of day of the given calendar field. | ||
20541 | * @method addHourOfDay | ||
20542 | * @param {Number} amount the signed amount to add to field. | ||
20543 | */ | ||
20544 | |||
20545 | /* | ||
20546 | * add the minute of the given calendar field. | ||
20547 | * @method addMinute | ||
20548 | * @param {Number} amount the signed amount to add to field. | ||
20549 | */ | ||
20550 | |||
20551 | /* | ||
20552 | * add the second of the given calendar field. | ||
20553 | * @method addSecond | ||
20554 | * @param {Number} amount the signed amount to add to field. | ||
20555 | */ | ||
20556 | |||
20557 | /* | ||
20558 | * add the millisecond of the given calendar field. | ||
20559 | * @method addMilliSecond | ||
20560 | * @param {Number} amount the signed amount to add to field. | ||
20561 | */ | ||
20562 | |||
20563 | /* | ||
20564 | * add the week of year of the given calendar field. | ||
20565 | * @method addWeekOfYear | ||
20566 | * @param {Number} amount the signed amount to add to field. | ||
20567 | */ | ||
20568 | |||
20569 | /* | ||
20570 | * add the week of month of the given calendar field. | ||
20571 | * @method addWeekOfMonth | ||
20572 | * @param {Number} amount the signed amount to add to field. | ||
20573 | */ | ||
20574 | |||
20575 | /* | ||
20576 | * add the day of year of the given calendar field. | ||
20577 | * @method addDayOfYear | ||
20578 | * @param {Number} amount the signed amount to add to field. | ||
20579 | */ | ||
20580 | |||
20581 | /* | ||
20582 | * add the day of week of the given calendar field. | ||
20583 | * @method addDayOfWeek | ||
20584 | * @param {Number} amount the signed amount to add to field. | ||
20585 | */ | ||
20586 | |||
20587 | /* | ||
20588 | * add the day of week in month of the given calendar field. | ||
20589 | * @method addDayOfWeekInMonth | ||
20590 | * @param {Number} amount the signed amount to add to field. | ||
20591 | */ | ||
20592 | |||
20593 | /* | ||
20594 | * Get rolled value for the field | ||
20595 | * @protected | ||
20596 | */ | ||
20597 | getRolledValue: function getRolledValue(value, a, min, max) { | ||
20598 | var amount = a; | ||
20599 | var diff = value - min; | ||
20600 | var range = max - min + 1; | ||
20601 | amount %= range; | ||
20602 | return min + (diff + amount + range) % range; | ||
20603 | }, | ||
20604 | |||
20605 | /* | ||
20606 | * Adds a signed amount to the specified calendar field without changing larger fields. | ||
20607 | * A negative roll amount means to subtract from field without changing | ||
20608 | * larger fields. If the specified amount is 0, this method performs nothing. | ||
20609 | * | ||
20610 | * | ||
20611 | * | ||
20612 | * @example | ||
20613 | * const d = new GregorianCalendar(); | ||
20614 | * d.set(1999, GregorianCalendar.AUGUST, 31); | ||
20615 | * // 1999-4-30 | ||
20616 | * // Tuesday June 1, 1999 | ||
20617 | * d.set(1999, GregorianCalendar.JUNE, 1); | ||
20618 | * d.add(Gregorian.WEEK_OF_MONTH,-1); // === d.add(Gregorian.WEEK_OF_MONTH, | ||
20619 | * d.get(Gregorian.WEEK_OF_MONTH)); | ||
20620 | * // 1999-06-29 | ||
20621 | * | ||
20622 | * | ||
20623 | * @param field the calendar field. | ||
20624 | * @param {Number} amount the signed amount to add to field. | ||
20625 | */ | ||
20626 | roll: function roll(field, amount) { | ||
20627 | if (!amount) { | ||
20628 | return; | ||
20629 | } | ||
20630 | var self = this; | ||
20631 | // computer and retrieve original value | ||
20632 | var value = self.get(field); | ||
20633 | var min = self.getActualMinimum(field); | ||
20634 | var max = self.getActualMaximum(field); | ||
20635 | value = self.getRolledValue(value, amount, min, max); | ||
20636 | |||
20637 | self.set(field, value); | ||
20638 | |||
20639 | // consider compute time priority | ||
20640 | switch (field) { | ||
20641 | case MONTH: | ||
20642 | adjustDayOfMonth(self); | ||
20643 | break; | ||
20644 | default: | ||
20645 | // other fields are set already when get | ||
20646 | self.updateFieldsBySet(field); | ||
20647 | break; | ||
20648 | } | ||
20649 | }, | ||
20650 | |||
20651 | /* | ||
20652 | * keep field stable. | ||
20653 | * | ||
20654 | * 2015-09-29 setMonth 2 vs rollSetMonth 2 | ||
20655 | * | ||
20656 | */ | ||
20657 | rollSet: function rollSet(field, v) { | ||
20658 | this.set(field, v); | ||
20659 | switch (field) { | ||
20660 | case MONTH: | ||
20661 | adjustDayOfMonth(this); | ||
20662 | break; | ||
20663 | default: | ||
20664 | // other fields are set already when get | ||
20665 | this.updateFieldsBySet(field); | ||
20666 | break; | ||
20667 | } | ||
20668 | }, | ||
20669 | |||
20670 | /* | ||
20671 | * roll the year of the given calendar field. | ||
20672 | * @method rollYear | ||
20673 | * @param {Number} amount the signed amount to add to field. | ||
20674 | */ | ||
20675 | |||
20676 | /* | ||
20677 | * roll the month of the given calendar field. | ||
20678 | * @param {Number} amount the signed amount to add to field. | ||
20679 | * @method rollMonth | ||
20680 | */ | ||
20681 | |||
20682 | /* | ||
20683 | * roll the day of month of the given calendar field. | ||
20684 | * @method rollDayOfMonth | ||
20685 | * @param {Number} amount the signed amount to add to field. | ||
20686 | */ | ||
20687 | |||
20688 | /* | ||
20689 | * roll the hour of day of the given calendar field. | ||
20690 | * @method rollHourOfDay | ||
20691 | * @param {Number} amount the signed amount to add to field. | ||
20692 | */ | ||
20693 | |||
20694 | /* | ||
20695 | * roll the minute of the given calendar field. | ||
20696 | * @method rollMinute | ||
20697 | * @param {Number} amount the signed amount to add to field. | ||
20698 | */ | ||
20699 | |||
20700 | /* | ||
20701 | * roll the second of the given calendar field. | ||
20702 | * @method rollSecond | ||
20703 | * @param {Number} amount the signed amount to add to field. | ||
20704 | */ | ||
20705 | |||
20706 | /* | ||
20707 | * roll the millisecond of the given calendar field. | ||
20708 | * @method rollMilliSecond | ||
20709 | * @param {Number} amount the signed amount to add to field. | ||
20710 | */ | ||
20711 | |||
20712 | /* | ||
20713 | * roll the week of year of the given calendar field. | ||
20714 | * @method rollWeekOfYear | ||
20715 | * @param {Number} amount the signed amount to add to field. | ||
20716 | */ | ||
20717 | |||
20718 | /* | ||
20719 | * roll the week of month of the given calendar field. | ||
20720 | * @method rollWeekOfMonth | ||
20721 | * @param {Number} amount the signed amount to add to field. | ||
20722 | */ | ||
20723 | |||
20724 | /* | ||
20725 | * roll the day of year of the given calendar field. | ||
20726 | * @method rollDayOfYear | ||
20727 | * @param {Number} amount the signed amount to add to field. | ||
20728 | */ | ||
20729 | |||
20730 | /* | ||
20731 | * roll the day of week of the given calendar field. | ||
20732 | * @method rollDayOfWeek | ||
20733 | * @param {Number} amount the signed amount to add to field. | ||
20734 | */ | ||
20735 | |||
20736 | /* | ||
20737 | * remove other priority fields when call getFixedDate | ||
20738 | * precondition: other fields are all set or computed | ||
20739 | * @protected | ||
20740 | */ | ||
20741 | updateFieldsBySet: function updateFieldsBySet(field) { | ||
20742 | var fields = this.fields; | ||
20743 | switch (field) { | ||
20744 | case WEEK_OF_MONTH: | ||
20745 | fields[DAY_OF_MONTH] = undefined; | ||
20746 | break; | ||
20747 | case DAY_OF_YEAR: | ||
20748 | fields[MONTH] = undefined; | ||
20749 | break; | ||
20750 | case DAY_OF_WEEK: | ||
20751 | fields[DAY_OF_MONTH] = undefined; | ||
20752 | break; | ||
20753 | case WEEK_OF_YEAR: | ||
20754 | fields[DAY_OF_YEAR] = undefined; | ||
20755 | fields[MONTH] = undefined; | ||
20756 | break; | ||
20757 | default: | ||
20758 | break; | ||
20759 | } | ||
20760 | }, | ||
20761 | |||
20762 | /* | ||
20763 | * get current date instance's timezone offset | ||
20764 | * @returns {Number} | ||
20765 | */ | ||
20766 | getTimezoneOffset: function getTimezoneOffset() { | ||
20767 | return this.timezoneOffset; | ||
20768 | }, | ||
20769 | |||
20770 | /* | ||
20771 | * set current date instance's timezone offset | ||
20772 | */ | ||
20773 | setTimezoneOffset: function setTimezoneOffset(timezoneOffset) { | ||
20774 | if (this.timezoneOffset !== timezoneOffset) { | ||
20775 | this.fieldsComputed = undefined; | ||
20776 | this.timezoneOffset = timezoneOffset; | ||
20777 | } | ||
20778 | }, | ||
20779 | |||
20780 | /* | ||
20781 | * set first day of week for current date instance | ||
20782 | */ | ||
20783 | setFirstDayOfWeek: function setFirstDayOfWeek(firstDayOfWeek) { | ||
20784 | if (this.firstDayOfWeek !== firstDayOfWeek) { | ||
20785 | this.firstDayOfWeek = firstDayOfWeek; | ||
20786 | this.fieldsComputed = false; | ||
20787 | } | ||
20788 | }, | ||
20789 | |||
20790 | /* | ||
20791 | * Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France. | ||
20792 | * @returns {Number} the first day of the week. | ||
20793 | */ | ||
20794 | getFirstDayOfWeek: function getFirstDayOfWeek() { | ||
20795 | return this.firstDayOfWeek; | ||
20796 | }, | ||
20797 | |||
20798 | /* | ||
20799 | * Sets what the minimal days required in the first week of the year are; For example, | ||
20800 | * if the first week is defined as one that contains the first day of the first month of a year, | ||
20801 | * call this method with value 1. | ||
20802 | * If it must be a full week, use value 7. | ||
20803 | * @param minimalDaysInFirstWeek the given minimal days required in the first week of the year. | ||
20804 | */ | ||
20805 | setMinimalDaysInFirstWeek: function setMinimalDaysInFirstWeek(minimalDaysInFirstWeek) { | ||
20806 | if (this.minimalDaysInFirstWeek !== minimalDaysInFirstWeek) { | ||
20807 | this.minimalDaysInFirstWeek = minimalDaysInFirstWeek; | ||
20808 | this.fieldsComputed = false; | ||
20809 | } | ||
20810 | }, | ||
20811 | |||
20812 | /* | ||
20813 | * Gets what the minimal days required in the first week of the year are; e.g., | ||
20814 | * if the first week is defined as one that contains the first day of the first month of a year, | ||
20815 | * this method returns 1. | ||
20816 | * If the minimal days required must be a full week, this method returns 7. | ||
20817 | * @returns {Number} the minimal days required in the first week of the year. | ||
20818 | */ | ||
20819 | getMinimalDaysInFirstWeek: function getMinimalDaysInFirstWeek() { | ||
20820 | return this.minimalDaysInFirstWeek; | ||
20821 | }, | ||
20822 | |||
20823 | /* | ||
20824 | * Returns the number of weeks in the week year | ||
20825 | * represented by this GregorianCalendar. | ||
20826 | * | ||
20827 | * For example, if this GregorianCalendar's date is | ||
20828 | * December 31, 2008 with the ISO | ||
20829 | * 8601 compatible setting, this method will return 53 for the | ||
20830 | * period: December 29, 2008 to January 3, 2010 | ||
20831 | * while getActualMaximum(WEEK_OF_YEAR) will return | ||
20832 | * 52 for the period: December 31, 2007 to December 28, 2008. | ||
20833 | * | ||
20834 | * @return {Number} the number of weeks in the week year. | ||
20835 | */ | ||
20836 | getWeeksInWeekYear: function getWeeksInWeekYear() { | ||
20837 | var weekYear = this.getWeekYear(); | ||
20838 | if (weekYear === this.get(YEAR)) { | ||
20839 | return this.getActualMaximum(WEEK_OF_YEAR); | ||
20840 | } | ||
20841 | // Use the 2nd week for calculating the max of WEEK_OF_YEAR | ||
20842 | var gc = this.clone(); | ||
20843 | gc.clear(); | ||
20844 | gc.setWeekDate(weekYear, 2, this.get(DAY_OF_WEEK)); | ||
20845 | return gc.getActualMaximum(WEEK_OF_YEAR); | ||
20846 | }, | ||
20847 | |||
20848 | /* | ||
20849 | * Returns the week year represented by this GregorianCalendar. | ||
20850 | * The dates in the weeks between 1 and the | ||
20851 | * maximum week number of the week year have the same week year value | ||
20852 | * that may be one year before or after the calendar year value. | ||
20853 | * | ||
20854 | * @return {Number} the week year represented by this GregorianCalendar. | ||
20855 | */ | ||
20856 | getWeekYear: function getWeekYear() { | ||
20857 | var year = this.get(YEAR); // implicitly complete | ||
20858 | var weekOfYear = this.get(WEEK_OF_YEAR); | ||
20859 | var month = this.get(MONTH); | ||
20860 | if (month === GregorianCalendar.JANUARY) { | ||
20861 | if (weekOfYear >= 52) { | ||
20862 | --year; | ||
20863 | } | ||
20864 | } else if (month === GregorianCalendar.DECEMBER) { | ||
20865 | if (weekOfYear === 1) { | ||
20866 | ++year; | ||
20867 | } | ||
20868 | } | ||
20869 | return year; | ||
20870 | }, | ||
20871 | /* | ||
20872 | * Sets this GregorianCalendar to the date given by the date specifiers - weekYear, | ||
20873 | * weekOfYear, and dayOfWeek. weekOfYear follows the WEEK_OF_YEAR numbering. | ||
20874 | * The dayOfWeek value must be one of the DAY_OF_WEEK values: SUNDAY to SATURDAY. | ||
20875 | * | ||
20876 | * @param weekYear the week year | ||
20877 | * @param weekOfYear the week number based on weekYear | ||
20878 | * @param dayOfWeek the day of week value | ||
20879 | */ | ||
20880 | setWeekDate: function setWeekDate(weekYear, weekOfYear, dayOfWeek) { | ||
20881 | if (dayOfWeek < GregorianCalendar.SUNDAY || dayOfWeek > GregorianCalendar.SATURDAY) { | ||
20882 | throw new Error('invalid dayOfWeek: ' + dayOfWeek); | ||
20883 | } | ||
20884 | var fields = this.fields; | ||
20885 | // To avoid changing the time of day fields by date | ||
20886 | // calculations, use a clone with the GMT time zone. | ||
20887 | var gc = this.clone(); | ||
20888 | gc.clear(); | ||
20889 | gc.setTimezoneOffset(0); | ||
20890 | gc.set(YEAR, weekYear); | ||
20891 | gc.set(WEEK_OF_YEAR, 1); | ||
20892 | gc.set(DAY_OF_WEEK, this.getFirstDayOfWeek()); | ||
20893 | var days = dayOfWeek - this.getFirstDayOfWeek(); | ||
20894 | if (days < 0) { | ||
20895 | days += 7; | ||
20896 | } | ||
20897 | days += 7 * (weekOfYear - 1); | ||
20898 | if (days !== 0) { | ||
20899 | gc.add(DAY_OF_YEAR, days); | ||
20900 | } else { | ||
20901 | gc.complete(); | ||
20902 | } | ||
20903 | fields[YEAR] = gc.get(YEAR); | ||
20904 | fields[MONTH] = gc.get(MONTH); | ||
20905 | fields[DAY_OF_MONTH] = gc.get(DAY_OF_MONTH); | ||
20906 | this.complete(); | ||
20907 | }, | ||
20908 | /* | ||
20909 | * Creates and returns a copy of this object. | ||
20910 | * @returns {Date.Gregorian} | ||
20911 | */ | ||
20912 | clone: function clone() { | ||
20913 | if (this.time === undefined) { | ||
20914 | this.computeTime(); | ||
20915 | } | ||
20916 | var cal = new GregorianCalendar(this.locale); | ||
20917 | cal.setTimezoneOffset(cal.getTimezoneOffset()); | ||
20918 | cal.setFirstDayOfWeek(cal.getFirstDayOfWeek()); | ||
20919 | cal.setMinimalDaysInFirstWeek(cal.getMinimalDaysInFirstWeek()); | ||
20920 | cal.setTime(this.time); | ||
20921 | return cal; | ||
20922 | }, | ||
20923 | |||
20924 | /* | ||
20925 | * Compares this GregorianCalendar to the specified Object. | ||
20926 | * The result is true if and only if the argument is a GregorianCalendar object | ||
20927 | * that represents the same time value (millisecond offset from the Epoch) | ||
20928 | * under the same Calendar parameters and Gregorian change date as this object. | ||
20929 | * @param {Date.Gregorian} obj the object to compare with. | ||
20930 | * @returns {boolean} true if this object is equal to obj; false otherwise. | ||
20931 | */ | ||
20932 | equals: function equals(obj) { | ||
20933 | return this.getTime() === obj.getTime() && this.firstDayOfWeek === obj.firstDayOfWeek && this.timezoneOffset === obj.timezoneOffset && this.minimalDaysInFirstWeek === obj.minimalDaysInFirstWeek; | ||
20934 | }, | ||
20935 | |||
20936 | /* | ||
20937 | * Sets all the calendar field values or specified field and the time value | ||
20938 | * (millisecond offset from the Epoch) of this Calendar undefined. | ||
20939 | * This means that isSet() will return false for all the calendar fields, | ||
20940 | * and the date and time calculations will treat the fields as if they had never been set. | ||
20941 | * @param [field] the calendar field to be cleared. | ||
20942 | */ | ||
20943 | clear: function clear(field) { | ||
20944 | if (field === undefined) { | ||
20945 | this.field = []; | ||
20946 | } else { | ||
20947 | this.fields[field] = undefined; | ||
20948 | } | ||
20949 | this.time = undefined; | ||
20950 | this.fieldsComputed = false; | ||
20951 | } | ||
20952 | }; | ||
20953 | |||
20954 | var GregorianCalendarProto = GregorianCalendar.prototype; | ||
20955 | |||
20956 | Utils.each(FIELDS, function (f, index) { | ||
20957 | if (f) { | ||
20958 | GregorianCalendarProto['get' + f] = function get() { | ||
20959 | return this.get(index); | ||
20960 | }; | ||
20961 | |||
20962 | GregorianCalendarProto['isSet' + f] = function isSet() { | ||
20963 | return this.isSet(index); | ||
20964 | }; | ||
20965 | |||
20966 | GregorianCalendarProto['set' + f] = function set(v) { | ||
20967 | return this.set(index, v); | ||
20968 | }; | ||
20969 | |||
20970 | GregorianCalendarProto['add' + f] = function add(v) { | ||
20971 | return this.add(index, v); | ||
20972 | }; | ||
20973 | |||
20974 | GregorianCalendarProto['roll' + f] = function roll(v) { | ||
20975 | return this.roll(index, v); | ||
20976 | }; | ||
20977 | |||
20978 | GregorianCalendarProto['rollSet' + f] = function rollSet(v) { | ||
20979 | return this.rollSet(index, v); | ||
20980 | }; | ||
20981 | } | ||
20982 | }); | ||
20983 | |||
20984 | module.exports = GregorianCalendar; | ||
20985 | /* | ||
20986 | http://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html | ||
20987 | |||
20988 | TODO | ||
20989 | - day saving time | ||
20990 | - i18n | ||
20991 | - julian calendar | ||
20992 | */ | ||
20993 | |||
20994 | /***/ }, | ||
20995 | /* 162 */ | ||
20996 | /***/ function(module, exports, __webpack_require__) { | ||
20997 | |||
20998 | /* | ||
20999 | * utils for gregorian date | ||
21000 | * @ignore | ||
21001 | * @author yiminghe@gmail.com | ||
21002 | */ | ||
21003 | |||
21004 | 'use strict'; | ||
21005 | |||
21006 | var Const = __webpack_require__(163); | ||
21007 | var floor = Math.floor; | ||
21008 | var ACCUMULATED_DAYS_IN_MONTH | ||
21009 | // 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 10/1 11/1 12/1 | ||
21010 | = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; | ||
21011 | |||
21012 | var ACCUMULATED_DAYS_IN_MONTH_LEAP | ||
21013 | // 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 | ||
21014 | // 10/1 11/1 12/1 | ||
21015 | = [0, 31, 59 + 1, 90 + 1, 120 + 1, 151 + 1, 181 + 1, 212 + 1, 243 + 1, 273 + 1, 304 + 1, 334 + 1]; | ||
21016 | |||
21017 | var DAYS_OF_YEAR = 365; | ||
21018 | var DAYS_OF_4YEAR = 365 * 4 + 1; | ||
21019 | var DAYS_OF_100YEAR = DAYS_OF_4YEAR * 25 - 1; | ||
21020 | var DAYS_OF_400YEAR = DAYS_OF_100YEAR * 4 + 1; | ||
21021 | var _exports = {}; | ||
21022 | |||
21023 | function getDayOfYear(year, month, dayOfMonth) { | ||
21024 | return dayOfMonth + (_exports.isLeapYear(year) ? ACCUMULATED_DAYS_IN_MONTH_LEAP[month] : ACCUMULATED_DAYS_IN_MONTH[month]); | ||
21025 | } | ||
21026 | |||
21027 | function getDayOfWeekFromFixedDate(fixedDate) { | ||
21028 | // The fixed day 1 (January 1, 1 Gregorian) is Monday. | ||
21029 | if (fixedDate >= 0) { | ||
21030 | return fixedDate % 7; | ||
21031 | } | ||
21032 | return _exports.mod(fixedDate, 7); | ||
21033 | } | ||
21034 | |||
21035 | function getGregorianYearFromFixedDate(fixedDate) { | ||
21036 | var d0 = undefined; | ||
21037 | var d1 = undefined; | ||
21038 | var d2 = undefined; | ||
21039 | var d3 = undefined; | ||
21040 | var n400 = undefined; | ||
21041 | var n100 = undefined; | ||
21042 | var n4 = undefined; | ||
21043 | var n1 = undefined; | ||
21044 | var year = undefined; | ||
21045 | d0 = fixedDate - 1; | ||
21046 | |||
21047 | n400 = floor(d0 / DAYS_OF_400YEAR); | ||
21048 | d1 = _exports.mod(d0, DAYS_OF_400YEAR); | ||
21049 | n100 = floor(d1 / DAYS_OF_100YEAR); | ||
21050 | d2 = _exports.mod(d1, DAYS_OF_100YEAR); | ||
21051 | n4 = floor(d2 / DAYS_OF_4YEAR); | ||
21052 | d3 = _exports.mod(d2, DAYS_OF_4YEAR); | ||
21053 | n1 = floor(d3 / DAYS_OF_YEAR); | ||
21054 | |||
21055 | year = 400 * n400 + 100 * n100 + 4 * n4 + n1; | ||
21056 | |||
21057 | // ? | ||
21058 | if (!(n100 === 4 || n1 === 4)) { | ||
21059 | ++year; | ||
21060 | } | ||
21061 | |||
21062 | return year; | ||
21063 | } | ||
21064 | |||
21065 | _exports = module.exports = { | ||
21066 | each: function each(arr, fn) { | ||
21067 | for (var i = 0, len = arr.length; i < len; i++) { | ||
21068 | if (fn(arr[i], i, arr) === false) { | ||
21069 | break; | ||
21070 | } | ||
21071 | } | ||
21072 | }, | ||
21073 | |||
21074 | mix: function mix(t, s) { | ||
21075 | for (var p in s) { | ||
21076 | if (s.hasOwnProperty(p)) { | ||
21077 | t[p] = s[p]; | ||
21078 | } | ||
21079 | } | ||
21080 | }, | ||
21081 | |||
21082 | isLeapYear: function isLeapYear(year) { | ||
21083 | if ((year & 3) !== 0) { | ||
21084 | return false; | ||
21085 | } | ||
21086 | return year % 100 !== 0 || year % 400 === 0; | ||
21087 | }, | ||
21088 | |||
21089 | mod: function mod(x, y) { | ||
21090 | // 负数时不是镜像关系 | ||
21091 | return x - y * floor(x / y); | ||
21092 | }, | ||
21093 | |||
21094 | // month: 0 based | ||
21095 | getFixedDate: function getFixedDate(year, month, dayOfMonth) { | ||
21096 | var prevYear = year - 1; | ||
21097 | // 考虑公元前 | ||
21098 | return DAYS_OF_YEAR * prevYear + floor(prevYear / 4) - floor(prevYear / 100) + floor(prevYear / 400) + getDayOfYear(year, month, dayOfMonth); | ||
21099 | }, | ||
21100 | |||
21101 | getGregorianDateFromFixedDate: function getGregorianDateFromFixedDate(fixedDate) { | ||
21102 | var year = getGregorianYearFromFixedDate(fixedDate); | ||
21103 | var jan1 = _exports.getFixedDate(year, Const.JANUARY, 1); | ||
21104 | var isLeap = _exports.isLeapYear(year); | ||
21105 | var ACCUMULATED_DAYS = isLeap ? ACCUMULATED_DAYS_IN_MONTH_LEAP : ACCUMULATED_DAYS_IN_MONTH; | ||
21106 | var daysDiff = fixedDate - jan1; | ||
21107 | var month = undefined; | ||
21108 | |||
21109 | for (var i = 0; i < ACCUMULATED_DAYS.length; i++) { | ||
21110 | if (ACCUMULATED_DAYS[i] <= daysDiff) { | ||
21111 | month = i; | ||
21112 | } else { | ||
21113 | break; | ||
21114 | } | ||
21115 | } | ||
21116 | |||
21117 | var dayOfMonth = fixedDate - jan1 - ACCUMULATED_DAYS[month] + 1; | ||
21118 | var dayOfWeek = getDayOfWeekFromFixedDate(fixedDate); | ||
21119 | |||
21120 | return { | ||
21121 | year: year, | ||
21122 | month: month, | ||
21123 | dayOfMonth: dayOfMonth, | ||
21124 | dayOfWeek: dayOfWeek, | ||
21125 | isLeap: isLeap | ||
21126 | }; | ||
21127 | } | ||
21128 | }; | ||
21129 | |||
21130 | /***/ }, | ||
21131 | /* 163 */ | ||
21132 | /***/ function(module, exports) { | ||
21133 | |||
21134 | /* | ||
21135 | * @ignore | ||
21136 | * const for gregorian date | ||
21137 | * @author yiminghe@gmail.com | ||
21138 | */ | ||
21139 | |||
21140 | "use strict"; | ||
21141 | |||
21142 | module.exports = { | ||
21143 | /* | ||
21144 | * Enum indicating sunday | ||
21145 | * @type Number | ||
21146 | * @member Date.Gregorian | ||
21147 | */ | ||
21148 | SUNDAY: 0, | ||
21149 | /* | ||
21150 | * Enum indicating monday | ||
21151 | * @type Number | ||
21152 | * @member Date.Gregorian | ||
21153 | */ | ||
21154 | MONDAY: 1, | ||
21155 | /* | ||
21156 | * Enum indicating tuesday | ||
21157 | * @type Number | ||
21158 | * @member Date.Gregorian | ||
21159 | */ | ||
21160 | TUESDAY: 2, | ||
21161 | /* | ||
21162 | * Enum indicating wednesday | ||
21163 | * @type Number | ||
21164 | * @member Date.Gregorian | ||
21165 | */ | ||
21166 | WEDNESDAY: 3, | ||
21167 | /* | ||
21168 | * Enum indicating thursday | ||
21169 | * @type Number | ||
21170 | * @member Date.Gregorian | ||
21171 | */ | ||
21172 | THURSDAY: 4, | ||
21173 | /* | ||
21174 | * Enum indicating friday | ||
21175 | * @type Number | ||
21176 | * @member Date.Gregorian | ||
21177 | */ | ||
21178 | FRIDAY: 5, | ||
21179 | /* | ||
21180 | * Enum indicating saturday | ||
21181 | * @type Number | ||
21182 | * @member Date.Gregorian | ||
21183 | */ | ||
21184 | SATURDAY: 6, | ||
21185 | /* | ||
21186 | * Enum indicating january | ||
21187 | * @type Number | ||
21188 | * @member Date.Gregorian | ||
21189 | */ | ||
21190 | JANUARY: 0, | ||
21191 | /* | ||
21192 | * Enum indicating february | ||
21193 | * @type Number | ||
21194 | * @member Date.Gregorian | ||
21195 | */ | ||
21196 | FEBRUARY: 1, | ||
21197 | /* | ||
21198 | * Enum indicating march | ||
21199 | * @type Number | ||
21200 | * @member Date.Gregorian | ||
21201 | */ | ||
21202 | MARCH: 2, | ||
21203 | /* | ||
21204 | * Enum indicating april | ||
21205 | * @type Number | ||
21206 | * @member Date.Gregorian | ||
21207 | */ | ||
21208 | APRIL: 3, | ||
21209 | /* | ||
21210 | * Enum indicating may | ||
21211 | * @type Number | ||
21212 | * @member Date.Gregorian | ||
21213 | */ | ||
21214 | MAY: 4, | ||
21215 | /* | ||
21216 | * Enum indicating june | ||
21217 | * @type Number | ||
21218 | * @member Date.Gregorian | ||
21219 | */ | ||
21220 | JUNE: 5, | ||
21221 | /* | ||
21222 | * Enum indicating july | ||
21223 | * @type Number | ||
21224 | * @member Date.Gregorian | ||
21225 | */ | ||
21226 | JULY: 6, | ||
21227 | /* | ||
21228 | * Enum indicating august | ||
21229 | * @type Number | ||
21230 | * @member Date.Gregorian | ||
21231 | */ | ||
21232 | AUGUST: 7, | ||
21233 | /* | ||
21234 | * Enum indicating september | ||
21235 | * @type Number | ||
21236 | * @member Date.Gregorian | ||
21237 | */ | ||
21238 | SEPTEMBER: 8, | ||
21239 | /* | ||
21240 | * Enum indicating october | ||
21241 | * @type Number | ||
21242 | * @member Date.Gregorian | ||
21243 | */ | ||
21244 | OCTOBER: 9, | ||
21245 | /* | ||
21246 | * Enum indicating november | ||
21247 | * @type Number | ||
21248 | * @member Date.Gregorian | ||
21249 | */ | ||
21250 | NOVEMBER: 10, | ||
21251 | /* | ||
21252 | * Enum indicating december | ||
21253 | * @type Number | ||
21254 | * @member Date.Gregorian | ||
21255 | */ | ||
21256 | DECEMBER: 11 | ||
21257 | }; | ||
21258 | |||
21259 | /***/ }, | ||
21260 | /* 164 */ | ||
21261 | /***/ function(module, exports) { | ||
21262 | |||
21263 | /* | ||
21264 | * en-us locale | ||
21265 | * @ignore | ||
21266 | * @author yiminghe@gmail.com | ||
21267 | */ | ||
21268 | "use strict"; | ||
21269 | |||
21270 | module.exports = { | ||
21271 | // in minutes | ||
21272 | timezoneOffset: -8 * 60, | ||
21273 | firstDayOfWeek: 0, | ||
21274 | minimalDaysInFirstWeek: 1 | ||
21275 | }; | ||
21276 | |||
21277 | /***/ }, | ||
21278 | /* 165 */ | ||
21279 | /***/ function(module, exports, __webpack_require__) { | ||
21280 | |||
21281 | /** | ||
21282 | * @ignore | ||
21283 | * DateTimeFormat for | ||
21284 | * Inspired by DateTimeFormat from JDK. | ||
21285 | * @author yiminghe@gmail.com | ||
21286 | */ | ||
21287 | |||
21288 | 'use strict'; | ||
21289 | |||
21290 | var GregorianCalendar = __webpack_require__(161); | ||
21291 | var enUsLocale = __webpack_require__(166); | ||
21292 | var MAX_VALUE = Number.MAX_VALUE; | ||
21293 | var warning = __webpack_require__(167); | ||
21294 | |||
21295 | /** | ||
21296 | * date or time style enum | ||
21297 | * @enum {Number} Date.Formatter.Style | ||
21298 | */ | ||
21299 | var DateTimeStyle = { | ||
21300 | /** | ||
21301 | * full style | ||
21302 | */ | ||
21303 | FULL: 0, | ||
21304 | /** | ||
21305 | * long style | ||
21306 | */ | ||
21307 | LONG: 1, | ||
21308 | /** | ||
21309 | * medium style | ||
21310 | */ | ||
21311 | MEDIUM: 2, | ||
21312 | /** | ||
21313 | * short style | ||
21314 | */ | ||
21315 | SHORT: 3 | ||
21316 | }; | ||
21317 | |||
21318 | /* | ||
21319 | Letter Date or Time Component Presentation Examples | ||
21320 | G Era designator Text AD | ||
21321 | y Year Year 1996; 96 | ||
21322 | M Month in year Month July; Jul; 07 | ||
21323 | w Week in year Number 27 | ||
21324 | W Week in month Number 2 | ||
21325 | D Day in year Number 189 | ||
21326 | d Day in month Number 10 | ||
21327 | F Day of week in month Number 2 | ||
21328 | E Day in week Text Tuesday; Tue | ||
21329 | a Am/pm marker Text PM | ||
21330 | H Hour in day (0-23) Number 0 | ||
21331 | k Hour in day (1-24) Number 24 | ||
21332 | K Hour in am/pm (0-11) Number 0 | ||
21333 | h Hour in am/pm (1-12) Number 12 | ||
21334 | m Minute in hour Number 30 | ||
21335 | s Second in minute Number 55 | ||
21336 | S Millisecond Number 978 | ||
21337 | x z Time zone General time zone Pacific Standard Time; PST; GMT-08:00 | ||
21338 | Z Time zone RFC 822 time zone -0800 | ||
21339 | */ | ||
21340 | |||
21341 | var patternChars = new Array(GregorianCalendar.DAY_OF_WEEK_IN_MONTH + 2).join('1'); | ||
21342 | var ERA = 0; | ||
21343 | var calendarIndexMap = {}; | ||
21344 | |||
21345 | patternChars = patternChars.split(''); | ||
21346 | patternChars[ERA] = 'G'; | ||
21347 | patternChars[GregorianCalendar.YEAR] = 'y'; | ||
21348 | patternChars[GregorianCalendar.MONTH] = 'M'; | ||
21349 | patternChars[GregorianCalendar.DAY_OF_MONTH] = 'd'; | ||
21350 | patternChars[GregorianCalendar.HOUR_OF_DAY] = 'H'; | ||
21351 | patternChars[GregorianCalendar.MINUTES] = 'm'; | ||
21352 | patternChars[GregorianCalendar.SECONDS] = 's'; | ||
21353 | patternChars[GregorianCalendar.MILLISECONDS] = 'S'; | ||
21354 | patternChars[GregorianCalendar.WEEK_OF_YEAR] = 'w'; | ||
21355 | patternChars[GregorianCalendar.WEEK_OF_MONTH] = 'W'; | ||
21356 | patternChars[GregorianCalendar.DAY_OF_YEAR] = 'D'; | ||
21357 | patternChars[GregorianCalendar.DAY_OF_WEEK_IN_MONTH] = 'F'; | ||
21358 | |||
21359 | (function init() { | ||
21360 | for (var index in patternChars) { | ||
21361 | if (patternChars.hasOwnProperty(index)) { | ||
21362 | calendarIndexMap[patternChars[index]] = index; | ||
21363 | } | ||
21364 | } | ||
21365 | })(); | ||
21366 | |||
21367 | function mix(t, s) { | ||
21368 | for (var p in s) { | ||
21369 | if (s.hasOwnProperty(p)) { | ||
21370 | t[p] = s[p]; | ||
21371 | } | ||
21372 | } | ||
21373 | } | ||
21374 | |||
21375 | var SUBSTITUTE_REG = /\\?\{([^{}]+)\}/g; | ||
21376 | var EMPTY = ''; | ||
21377 | |||
21378 | function substitute(str, o, regexp) { | ||
21379 | if (typeof str !== 'string' || !o) { | ||
21380 | return str; | ||
21381 | } | ||
21382 | |||
21383 | return str.replace(regexp || SUBSTITUTE_REG, function (match, name) { | ||
21384 | if (match.charAt(0) === '\\') { | ||
21385 | return match.slice(1); | ||
21386 | } | ||
21387 | return o[name] === undefined ? EMPTY : o[name]; | ||
21388 | }); | ||
21389 | } | ||
21390 | |||
21391 | patternChars = patternChars.join('') + 'ahkKZE'; | ||
21392 | |||
21393 | function encode(lastField, count, compiledPattern) { | ||
21394 | compiledPattern.push({ | ||
21395 | field: lastField, | ||
21396 | count: count | ||
21397 | }); | ||
21398 | } | ||
21399 | |||
21400 | function compile(pattern) { | ||
21401 | var length = pattern.length; | ||
21402 | var inQuote = false; | ||
21403 | var compiledPattern = []; | ||
21404 | var tmpBuffer = null; | ||
21405 | var count = 0; | ||
21406 | var lastField = -1; | ||
21407 | |||
21408 | for (var i = 0; i < length; i++) { | ||
21409 | var c = pattern.charAt(i); | ||
21410 | |||
21411 | if (c === '\'') { | ||
21412 | // '' is treated as a single quote regardless of being | ||
21413 | // in a quoted section. | ||
21414 | if (i + 1 < length) { | ||
21415 | c = pattern.charAt(i + 1); | ||
21416 | if (c === '\'') { | ||
21417 | i++; | ||
21418 | if (count !== 0) { | ||
21419 | encode(lastField, count, compiledPattern); | ||
21420 | lastField = -1; | ||
21421 | count = 0; | ||
21422 | } | ||
21423 | if (inQuote) { | ||
21424 | tmpBuffer += c; | ||
21425 | } | ||
21426 | continue; | ||
21427 | } | ||
21428 | } | ||
21429 | if (!inQuote) { | ||
21430 | if (count !== 0) { | ||
21431 | encode(lastField, count, compiledPattern); | ||
21432 | lastField = -1; | ||
21433 | count = 0; | ||
21434 | } | ||
21435 | tmpBuffer = ''; | ||
21436 | inQuote = true; | ||
21437 | } else { | ||
21438 | compiledPattern.push({ | ||
21439 | text: tmpBuffer | ||
21440 | }); | ||
21441 | inQuote = false; | ||
21442 | } | ||
21443 | continue; | ||
21444 | } | ||
21445 | if (inQuote) { | ||
21446 | tmpBuffer += c; | ||
21447 | continue; | ||
21448 | } | ||
21449 | if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) { | ||
21450 | if (count !== 0) { | ||
21451 | encode(lastField, count, compiledPattern); | ||
21452 | lastField = -1; | ||
21453 | count = 0; | ||
21454 | } | ||
21455 | compiledPattern.push({ | ||
21456 | text: c | ||
21457 | }); | ||
21458 | continue; | ||
21459 | } | ||
21460 | |||
21461 | if (patternChars.indexOf(c) === -1) { | ||
21462 | throw new Error('Illegal pattern character "' + c + '"'); | ||
21463 | } | ||
21464 | |||
21465 | if (lastField === -1 || lastField === c) { | ||
21466 | lastField = c; | ||
21467 | count++; | ||
21468 | continue; | ||
21469 | } | ||
21470 | encode(lastField, count, compiledPattern); | ||
21471 | lastField = c; | ||
21472 | count = 1; | ||
21473 | } | ||
21474 | |||
21475 | if (inQuote) { | ||
21476 | throw new Error('Unterminated quote'); | ||
21477 | } | ||
21478 | |||
21479 | if (count !== 0) { | ||
21480 | encode(lastField, count, compiledPattern); | ||
21481 | } | ||
21482 | |||
21483 | return compiledPattern; | ||
21484 | } | ||
21485 | |||
21486 | var zeroDigit = '0'; | ||
21487 | |||
21488 | // TODO zeroDigit localization?? | ||
21489 | function zeroPaddingNumber(_x, _x2, _x3, _x4) { | ||
21490 | var _again = true; | ||
21491 | |||
21492 | _function: while (_again) { | ||
21493 | var value = _x, | ||
21494 | minDigits = _x2, | ||
21495 | maxDigits_ = _x3, | ||
21496 | b = _x4; | ||
21497 | _again = false; | ||
21498 | |||
21499 | // Optimization for 1, 2 and 4 digit numbers. This should | ||
21500 | // cover most cases of formatting date/time related items. | ||
21501 | // Note: This optimization code assumes that maxDigits is | ||
21502 | // either 2 or Integer.MAX_VALUE (maxIntCount in format()). | ||
21503 | var buffer = b || []; | ||
21504 | var maxDigits = maxDigits_ || MAX_VALUE; | ||
21505 | if (value >= 0) { | ||
21506 | if (value < 100 && minDigits >= 1 && minDigits <= 2) { | ||
21507 | if (value < 10 && minDigits === 2) { | ||
21508 | buffer.push(zeroDigit); | ||
21509 | } | ||
21510 | buffer.push(value); | ||
21511 | return buffer.join(''); | ||
21512 | } else if (value >= 1000 && value < 10000) { | ||
21513 | if (minDigits === 4) { | ||
21514 | buffer.push(value); | ||
21515 | return buffer.join(''); | ||
21516 | } | ||
21517 | if (minDigits === 2 && maxDigits === 2) { | ||
21518 | _x = value % 100; | ||
21519 | _x2 = 2; | ||
21520 | _x3 = 2; | ||
21521 | _x4 = buffer; | ||
21522 | _again = true; | ||
21523 | buffer = maxDigits = undefined; | ||
21524 | continue _function; | ||
21525 | } | ||
21526 | } | ||
21527 | } | ||
21528 | buffer.push(value + ''); | ||
21529 | return buffer.join(''); | ||
21530 | } | ||
21531 | } | ||
21532 | |||
21533 | /** | ||
21534 | * | ||
21535 | * date time formatter for GregorianCalendar | ||
21536 | * | ||
21537 | * @example | ||
21538 | * | ||
21539 | * const calendar = new GregorianCalendar(2013,9,24); | ||
21540 | * // ' to escape | ||
21541 | * const formatter = new GregorianCalendarFormat("'today is' ''yyyy/MM/dd a''"); | ||
21542 | * document.write(formatter.format(calendar)); | ||
21543 | * | ||
21544 | * @class GregorianCalendarFormat | ||
21545 | * @param {String} pattern patter string of date formatter | ||
21546 | * | ||
21547 | * <table border="1"> | ||
21548 | * <thead valign="bottom"> | ||
21549 | * <tr><th class="head">Letter</th> | ||
21550 | * <th class="head">Date or Time Component</th> | ||
21551 | * <th class="head">Presentation</th> | ||
21552 | * <th class="head">Examples</th> | ||
21553 | * </tr> | ||
21554 | * </thead> | ||
21555 | * <tbody valign="top"> | ||
21556 | * <tr><td>G</td> | ||
21557 | * <td>Era designator</td> | ||
21558 | * <td>Text</td> | ||
21559 | * <td>AD</td> | ||
21560 | * </tr> | ||
21561 | * <tr><td>y</td> | ||
21562 | * <td>Year</td> | ||
21563 | * <td>Year</td> | ||
21564 | * <td>1996; 96</td> | ||
21565 | * </tr> | ||
21566 | * <tr><td>M</td> | ||
21567 | * <td>Month in year</td> | ||
21568 | * <td>Month</td> | ||
21569 | * <td>July; Jul; 07</td> | ||
21570 | * </tr> | ||
21571 | * <tr><td>w</td> | ||
21572 | * <td>Week in year</td> | ||
21573 | * <td>Number</td> | ||
21574 | * <td>27</td> | ||
21575 | * </tr> | ||
21576 | * <tr><td>W</td> | ||
21577 | * <td>Week in month</td> | ||
21578 | * <td>Number</td> | ||
21579 | * <td>2</td> | ||
21580 | * </tr> | ||
21581 | * <tr><td>D</td> | ||
21582 | * <td>Day in year</td> | ||
21583 | * <td>Number</td> | ||
21584 | * <td>189</td> | ||
21585 | * </tr> | ||
21586 | * <tr><td>d</td> | ||
21587 | * <td>Day in month</td> | ||
21588 | * <td>Number</td> | ||
21589 | * <td>10</td> | ||
21590 | * </tr> | ||
21591 | * <tr><td>F</td> | ||
21592 | * <td>Day of week in month</td> | ||
21593 | * <td>Number</td> | ||
21594 | * <td>2</td> | ||
21595 | * </tr> | ||
21596 | * <tr><td>E</td> | ||
21597 | * <td>Day in week</td> | ||
21598 | * <td>Text</td> | ||
21599 | * <td>Tuesday; Tue</td> | ||
21600 | * </tr> | ||
21601 | * <tr><td>a</td> | ||
21602 | * <td>Am/pm marker</td> | ||
21603 | * <td>Text</td> | ||
21604 | * <td>PM</td> | ||
21605 | * </tr> | ||
21606 | * <tr><td>H</td> | ||
21607 | * <td>Hour in day (0-23)</td> | ||
21608 | * <td>Number</td> | ||
21609 | * <td>0</td> | ||
21610 | * </tr> | ||
21611 | * <tr><td>k</td> | ||
21612 | * <td>Hour in day (1-24)</td> | ||
21613 | * <td>Number</td> | ||
21614 | * <td>24</td> | ||
21615 | * </tr> | ||
21616 | * <tr><td>K</td> | ||
21617 | * <td>Hour in am/pm (0-11)</td> | ||
21618 | * <td>Number</td> | ||
21619 | * <td>0</td> | ||
21620 | * </tr> | ||
21621 | * <tr><td>h</td> | ||
21622 | * <td>Hour in am/pm (1-12)</td> | ||
21623 | * <td>Number</td> | ||
21624 | * <td>12</td> | ||
21625 | * </tr> | ||
21626 | * <tr><td>m</td> | ||
21627 | * <td>Minute in hour</td> | ||
21628 | * <td>Number</td> | ||
21629 | * <td>30</td> | ||
21630 | * </tr> | ||
21631 | * <tr><td>s</td> | ||
21632 | * <td>Second in minute</td> | ||
21633 | * <td>Number</td> | ||
21634 | * <td>55</td> | ||
21635 | * </tr> | ||
21636 | * <tr><td>S</td> | ||
21637 | * <td>Millisecond</td> | ||
21638 | * <td>Number</td> | ||
21639 | * <td>978</td> | ||
21640 | * </tr> | ||
21641 | * <tr><td>x/z</td> | ||
21642 | * <td>Time zone</td> | ||
21643 | * <td>General time zone</td> | ||
21644 | * <td>Pacific Standard Time; PST; GMT-08:00</td> | ||
21645 | * </tr> | ||
21646 | * <tr><td>Z</td> | ||
21647 | * <td>Time zone</td> | ||
21648 | * <td>RFC 822 time zone</td> | ||
21649 | * <td>-0800</td> | ||
21650 | * </tr> | ||
21651 | * </tbody> | ||
21652 | * </table> | ||
21653 | |||
21654 | * @param {Object} locale format locale | ||
21655 | */ | ||
21656 | function DateTimeFormat(pattern, locale) { | ||
21657 | this.locale = locale || enUsLocale; | ||
21658 | this.originalPattern = pattern; | ||
21659 | this.pattern = compile(pattern); | ||
21660 | } | ||
21661 | |||
21662 | function formatField(field, count, locale, calendar) { | ||
21663 | var current = undefined; | ||
21664 | var value = undefined; | ||
21665 | switch (field) { | ||
21666 | case 'G': | ||
21667 | value = calendar.getYear() > 0 ? 1 : 0; | ||
21668 | current = locale.eras[value]; | ||
21669 | break; | ||
21670 | case 'y': | ||
21671 | value = calendar.getYear(); | ||
21672 | if (value <= 0) { | ||
21673 | value = 1 - value; | ||
21674 | } | ||
21675 | current = zeroPaddingNumber(value, 2, count !== 2 ? MAX_VALUE : 2); | ||
21676 | break; | ||
21677 | case 'M': | ||
21678 | value = calendar.getMonth(); | ||
21679 | if (count >= 4) { | ||
21680 | current = locale.months[value]; | ||
21681 | } else if (count === 3) { | ||
21682 | current = locale.shortMonths[value]; | ||
21683 | } else { | ||
21684 | current = zeroPaddingNumber(value + 1, count); | ||
21685 | } | ||
21686 | break; | ||
21687 | case 'k': | ||
21688 | current = zeroPaddingNumber(calendar.getHourOfDay() || 24, count); | ||
21689 | break; | ||
21690 | case 'E': | ||
21691 | value = calendar.getDayOfWeek(); | ||
21692 | current = count >= 4 ? locale.weekdays[value] : locale.shortWeekdays[value]; | ||
21693 | break; | ||
21694 | case 'a': | ||
21695 | current = locale.ampms[calendar.getHourOfDay() >= 12 ? 1 : 0]; | ||
21696 | break; | ||
21697 | case 'h': | ||
21698 | current = zeroPaddingNumber(calendar.getHourOfDay() % 12 || 12, count); | ||
21699 | break; | ||
21700 | case 'K': | ||
21701 | current = zeroPaddingNumber(calendar.getHourOfDay() % 12, count); | ||
21702 | break; | ||
21703 | case 'Z': | ||
21704 | var offset = calendar.getTimezoneOffset(); | ||
21705 | var parts = [offset < 0 ? '-' : '+']; | ||
21706 | offset = Math.abs(offset); | ||
21707 | parts.push(zeroPaddingNumber(Math.floor(offset / 60) % 100, 2), zeroPaddingNumber(offset % 60, 2)); | ||
21708 | current = parts.join(''); | ||
21709 | break; | ||
21710 | default: | ||
21711 | // case 'd': | ||
21712 | // case 'H': | ||
21713 | // case 'm': | ||
21714 | // case 's': | ||
21715 | // case 'S': | ||
21716 | // case 'D': | ||
21717 | // case 'F': | ||
21718 | // case 'w': | ||
21719 | // case 'W': | ||
21720 | var index = calendarIndexMap[field]; | ||
21721 | value = calendar.get(index); | ||
21722 | current = zeroPaddingNumber(value, count); | ||
21723 | } | ||
21724 | return current; | ||
21725 | } | ||
21726 | |||
21727 | function matchPartString(dateStr, startIndex, match, mLen) { | ||
21728 | for (var i = 0; i < mLen; i++) { | ||
21729 | if (dateStr.charAt(startIndex + i) !== match.charAt(i)) { | ||
21730 | return false; | ||
21731 | } | ||
21732 | } | ||
21733 | return true; | ||
21734 | } | ||
21735 | |||
21736 | function matchField(dateStr, startIndex, matches) { | ||
21737 | var matchedLen = -1; | ||
21738 | var index = -1; | ||
21739 | var i = undefined; | ||
21740 | var len = matches.length; | ||
21741 | for (i = 0; i < len; i++) { | ||
21742 | var m = matches[i]; | ||
21743 | var mLen = m.length; | ||
21744 | if (mLen > matchedLen && matchPartString(dateStr, startIndex, m, mLen)) { | ||
21745 | matchedLen = mLen; | ||
21746 | index = i; | ||
21747 | } | ||
21748 | } | ||
21749 | return index >= 0 ? { | ||
21750 | value: index, | ||
21751 | startIndex: startIndex + matchedLen | ||
21752 | } : null; | ||
21753 | } | ||
21754 | |||
21755 | function getLeadingNumberLen(str) { | ||
21756 | var i = undefined; | ||
21757 | var c = undefined; | ||
21758 | var len = str.length; | ||
21759 | for (i = 0; i < len; i++) { | ||
21760 | c = str.charAt(i); | ||
21761 | if (c < '0' || c > '9') { | ||
21762 | break; | ||
21763 | } | ||
21764 | } | ||
21765 | return i; | ||
21766 | } | ||
21767 | |||
21768 | function matchNumber(dateStr, startIndex, count, obeyCount) { | ||
21769 | var str = dateStr; | ||
21770 | var n = undefined; | ||
21771 | if (obeyCount) { | ||
21772 | if (dateStr.length < startIndex + count) { | ||
21773 | return null; | ||
21774 | } | ||
21775 | str = dateStr.slice(startIndex, startIndex + count); | ||
21776 | if (!str.match(/^\d+$/)) { | ||
21777 | throw new Error('GregorianCalendarFormat parse error, dateStr: ' + dateStr + ', patter: ' + this.originalPattern); | ||
21778 | } | ||
21779 | } else { | ||
21780 | str = str.slice(startIndex); | ||
21781 | } | ||
21782 | n = parseInt(str, 10); | ||
21783 | if (isNaN(n)) { | ||
21784 | throw new Error('GregorianCalendarFormat parse error, dateStr: ' + dateStr + ', patter: ' + this.originalPattern); | ||
21785 | } | ||
21786 | return { | ||
21787 | value: n, | ||
21788 | startIndex: startIndex + getLeadingNumberLen(str) | ||
21789 | }; | ||
21790 | } | ||
21791 | |||
21792 | function parseField(calendar, dateStr, startIndex_, field, count, obeyCount, tmp) { | ||
21793 | var match = undefined; | ||
21794 | var year = undefined; | ||
21795 | var hour = undefined; | ||
21796 | var startIndex = startIndex_; | ||
21797 | if (dateStr.length <= startIndex) { | ||
21798 | return startIndex; | ||
21799 | } | ||
21800 | var locale = this.locale; | ||
21801 | switch (field) { | ||
21802 | case 'G': | ||
21803 | match = matchField(dateStr, startIndex, locale.eras); | ||
21804 | if (match) { | ||
21805 | if (calendar.isSetYear()) { | ||
21806 | if (match.value === 0) { | ||
21807 | year = calendar.getYear(); | ||
21808 | calendar.setYear(1 - year); | ||
21809 | } | ||
21810 | } else { | ||
21811 | tmp.era = match.value; | ||
21812 | } | ||
21813 | } | ||
21814 | break; | ||
21815 | case 'y': | ||
21816 | match = matchNumber.call(this, dateStr, startIndex, count, obeyCount); | ||
21817 | if (match) { | ||
21818 | year = match.value; | ||
21819 | if ('era' in tmp) { | ||
21820 | if (tmp.era === 0) { | ||
21821 | year = 1 - year; | ||
21822 | } | ||
21823 | } | ||
21824 | calendar.setYear(year); | ||
21825 | } | ||
21826 | break; | ||
21827 | case 'M': | ||
21828 | var month = undefined; | ||
21829 | if (count >= 3) { | ||
21830 | match = matchField(dateStr, startIndex, locale[count === 3 ? 'shortMonths' : 'months']); | ||
21831 | if (match) { | ||
21832 | month = match.value; | ||
21833 | } | ||
21834 | } else { | ||
21835 | match = matchNumber.call(this, dateStr, startIndex, count, obeyCount); | ||
21836 | if (match) { | ||
21837 | month = match.value - 1; | ||
21838 | } | ||
21839 | } | ||
21840 | if (match) { | ||
21841 | calendar.setMonth(month); | ||
21842 | } | ||
21843 | break; | ||
21844 | case 'k': | ||
21845 | match = matchNumber.call(this, dateStr, startIndex, count, obeyCount); | ||
21846 | if (match) { | ||
21847 | calendar.setHourOfDay(match.value % 24); | ||
21848 | } | ||
21849 | break; | ||
21850 | case 'E': | ||
21851 | match = matchField(dateStr, startIndex, locale[count > 3 ? 'weekdays' : 'shortWeekdays']); | ||
21852 | if (match) { | ||
21853 | calendar.setDayOfWeek(match.value); | ||
21854 | } | ||
21855 | break; | ||
21856 | case 'a': | ||
21857 | match = matchField(dateStr, startIndex, locale.ampms); | ||
21858 | if (match) { | ||
21859 | if (calendar.isSetHourOfDay()) { | ||
21860 | if (match.value) { | ||
21861 | hour = calendar.getHourOfDay(); | ||
21862 | if (hour < 12) { | ||
21863 | calendar.setHourOfDay((hour + 12) % 24); | ||
21864 | } | ||
21865 | } | ||
21866 | } else { | ||
21867 | tmp.ampm = match.value; | ||
21868 | } | ||
21869 | } | ||
21870 | break; | ||
21871 | case 'h': | ||
21872 | match = matchNumber.call(this, dateStr, startIndex, count, obeyCount); | ||
21873 | if (match) { | ||
21874 | hour = match.value %= 12; | ||
21875 | if (tmp.ampm) { | ||
21876 | hour += 12; | ||
21877 | } | ||
21878 | calendar.setHourOfDay(hour); | ||
21879 | } | ||
21880 | break; | ||
21881 | case 'K': | ||
21882 | match = matchNumber.call(this, dateStr, startIndex, count, obeyCount); | ||
21883 | if (match) { | ||
21884 | hour = match.value; | ||
21885 | if (tmp.ampm) { | ||
21886 | hour += 12; | ||
21887 | } | ||
21888 | calendar.setHourOfDay(hour); | ||
21889 | } | ||
21890 | break; | ||
21891 | case 'Z': | ||
21892 | // let sign = 1; | ||
21893 | var zoneChar = dateStr.charAt(startIndex); | ||
21894 | if (zoneChar === '-') { | ||
21895 | // sign = -1; | ||
21896 | startIndex++; | ||
21897 | } else if (zoneChar === '+') { | ||
21898 | startIndex++; | ||
21899 | } else { | ||
21900 | break; | ||
21901 | } | ||
21902 | match = matchNumber.call(this, dateStr, startIndex, 2, true); | ||
21903 | if (match) { | ||
21904 | var zoneOffset = match.value * 60; | ||
21905 | startIndex = match.startIndex; | ||
21906 | match = matchNumber.call(this, dateStr, startIndex, 2, true); | ||
21907 | if (match) { | ||
21908 | zoneOffset += match.value; | ||
21909 | } | ||
21910 | calendar.setTimezoneOffset(zoneOffset); | ||
21911 | } | ||
21912 | break; | ||
21913 | default: | ||
21914 | // case 'd': | ||
21915 | // case 'H': | ||
21916 | // case 'm': | ||
21917 | // case 's': | ||
21918 | // case 'S': | ||
21919 | // case 'D': | ||
21920 | // case 'F': | ||
21921 | // case 'w': | ||
21922 | // case 'W' | ||
21923 | match = matchNumber.call(this, dateStr, startIndex, count, obeyCount); | ||
21924 | if (match) { | ||
21925 | var index = calendarIndexMap[field]; | ||
21926 | calendar.set(index, match.value); | ||
21927 | } | ||
21928 | } | ||
21929 | if (match) { | ||
21930 | startIndex = match.startIndex; | ||
21931 | } | ||
21932 | return startIndex; | ||
21933 | } | ||
21934 | |||
21935 | mix(DateTimeFormat.prototype, { | ||
21936 | /* | ||
21937 | * format a GregorianDate instance according to specified pattern | ||
21938 | * @param {GregorianCalendar} calendar GregorianDate instance | ||
21939 | * @returns {string} formatted string of GregorianDate instance | ||
21940 | */ | ||
21941 | format: function format(calendar) { | ||
21942 | if (!calendar.isGregorianCalendar) { | ||
21943 | throw new Error('calendar must be type of GregorianCalendar'); | ||
21944 | } | ||
21945 | var i = undefined; | ||
21946 | var ret = []; | ||
21947 | var pattern = this.pattern; | ||
21948 | var len = pattern.length; | ||
21949 | for (i = 0; i < len; i++) { | ||
21950 | var comp = pattern[i]; | ||
21951 | if (comp.text) { | ||
21952 | ret.push(comp.text); | ||
21953 | } else if ('field' in comp) { | ||
21954 | ret.push(formatField(comp.field, comp.count, this.locale, calendar)); | ||
21955 | } | ||
21956 | } | ||
21957 | return ret.join(''); | ||
21958 | }, | ||
21959 | |||
21960 | /* | ||
21961 | * parse a formatted string of GregorianDate instance according to specified pattern | ||
21962 | * @param {String} dateStr formatted string of GregorianDate | ||
21963 | * @returns {GregorianCalendar} | ||
21964 | */ | ||
21965 | parse: function parse(dateStr, option_) { | ||
21966 | var option = option_ || {}; | ||
21967 | var calendarLocale = option.locale; | ||
21968 | var calendar = new GregorianCalendar(calendarLocale); | ||
21969 | var i = undefined; | ||
21970 | var j = undefined; | ||
21971 | var tmp = {}; | ||
21972 | var obeyCount = option.obeyCount || false; | ||
21973 | var dateStrLen = dateStr.length; | ||
21974 | var errorIndex = -1; | ||
21975 | var startIndex = 0; | ||
21976 | var oldStartIndex = 0; | ||
21977 | var pattern = this.pattern; | ||
21978 | var len = pattern.length; | ||
21979 | /* eslint no-labels: 0 no-empty-label:0 */ | ||
21980 | loopPattern: { | ||
21981 | for (i = 0; errorIndex < 0 && i < len; i++) { | ||
21982 | var comp = pattern[i]; | ||
21983 | var text = undefined; | ||
21984 | var textLen = undefined; | ||
21985 | oldStartIndex = startIndex; | ||
21986 | text = comp.text; | ||
21987 | if (text) { | ||
21988 | textLen = text.length; | ||
21989 | if (textLen + startIndex > dateStrLen) { | ||
21990 | errorIndex = startIndex; | ||
21991 | } else { | ||
21992 | for (j = 0; j < textLen; j++) { | ||
21993 | if (text.charAt(j) !== dateStr.charAt(j + startIndex)) { | ||
21994 | errorIndex = startIndex; | ||
21995 | break loopPattern; | ||
21996 | } | ||
21997 | } | ||
21998 | startIndex += textLen; | ||
21999 | } | ||
22000 | } else if ('field' in comp) { | ||
22001 | if (!option.obeyCount) { | ||
22002 | var nextComp = pattern[i + 1]; | ||
22003 | obeyCount = false; | ||
22004 | if (nextComp) { | ||
22005 | if ('field' in nextComp) { | ||
22006 | obeyCount = true; | ||
22007 | } else { | ||
22008 | var c = nextComp.text.charAt(0); | ||
22009 | if (c >= '0' && c <= '9') { | ||
22010 | obeyCount = true; | ||
22011 | } | ||
22012 | } | ||
22013 | } | ||
22014 | } | ||
22015 | startIndex = parseField.call(this, calendar, dateStr, startIndex, comp.field, comp.count, obeyCount, tmp); | ||
22016 | if (startIndex === oldStartIndex) { | ||
22017 | errorIndex = startIndex; | ||
22018 | } | ||
22019 | } | ||
22020 | } | ||
22021 | } | ||
22022 | |||
22023 | if (errorIndex >= 0) { | ||
22024 | warning(false, 'error when parsing date: ' + dateStr + ', position: ' + dateStr.slice(0, errorIndex) + '^'); | ||
22025 | return undefined; | ||
22026 | } | ||
22027 | return calendar; | ||
22028 | } | ||
22029 | }); | ||
22030 | |||
22031 | mix(DateTimeFormat, { | ||
22032 | Style: DateTimeStyle, | ||
22033 | |||
22034 | /* | ||
22035 | * get a formatter instance of short style pattern. | ||
22036 | * en-us: M/d/yy h:mm a | ||
22037 | * zh-cn: yy-M-d ah:mm | ||
22038 | * @param {Object} locale locale object | ||
22039 | * @returns {GregorianCalendar} | ||
22040 | * @static | ||
22041 | */ | ||
22042 | getInstance: function getInstance(locale) { | ||
22043 | return this.getDateTimeInstance(DateTimeStyle.SHORT, DateTimeStyle.SHORT, locale); | ||
22044 | }, | ||
22045 | |||
22046 | /* | ||
22047 | * get a formatter instance of specified date style. | ||
22048 | * @param {Date.Formatter.Style} dateStyle date format style | ||
22049 | * @param {Object} locale | ||
22050 | * @returns {GregorianCalendar} | ||
22051 | * @static | ||
22052 | */ | ||
22053 | getDateInstance: function getDateInstance(dateStyle, locale) { | ||
22054 | return this.getDateTimeInstance(dateStyle, undefined, locale); | ||
22055 | }, | ||
22056 | |||
22057 | /* | ||
22058 | * get a formatter instance of specified date style and time style. | ||
22059 | * @param {Date.Formatter.Style} dateStyle date format style | ||
22060 | * @param {Date.Formatter.Style} timeStyle time format style | ||
22061 | * @param {Object} locale | ||
22062 | * @returns {GregorianCalendar} | ||
22063 | * @static | ||
22064 | */ | ||
22065 | getDateTimeInstance: function getDateTimeInstance(dateStyle, timeStyle, locale_) { | ||
22066 | var locale = locale_ || enUsLocale; | ||
22067 | var datePattern = ''; | ||
22068 | if (dateStyle !== undefined) { | ||
22069 | datePattern = locale.datePatterns[dateStyle]; | ||
22070 | } | ||
22071 | var timePattern = ''; | ||
22072 | if (timeStyle !== undefined) { | ||
22073 | timePattern = locale.timePatterns[timeStyle]; | ||
22074 | } | ||
22075 | var pattern = datePattern; | ||
22076 | if (timePattern) { | ||
22077 | if (datePattern) { | ||
22078 | pattern = substitute(locale.dateTimePattern, { | ||
22079 | date: datePattern, | ||
22080 | time: timePattern | ||
22081 | }); | ||
22082 | } else { | ||
22083 | pattern = timePattern; | ||
22084 | } | ||
22085 | } | ||
22086 | return new DateTimeFormat(pattern, locale); | ||
22087 | }, | ||
22088 | |||
22089 | /* | ||
22090 | * get a formatter instance of specified time style. | ||
22091 | * @param {Date.Formatter.Style} timeStyle time format style | ||
22092 | * @param {Object} locale | ||
22093 | * @returns {GregorianCalendar} | ||
22094 | * @static | ||
22095 | */ | ||
22096 | getTimeInstance: function getTimeInstance(timeStyle, locale) { | ||
22097 | return this.getDateTimeInstance(undefined, timeStyle, locale); | ||
22098 | } | ||
22099 | }); | ||
22100 | |||
22101 | module.exports = DateTimeFormat; | ||
22102 | |||
22103 | DateTimeFormat.version = '@VERSION@'; | ||
22104 | |||
22105 | // gc_format@163.com | ||
22106 | |||
22107 | /***/ }, | ||
22108 | /* 166 */ | ||
22109 | /***/ function(module, exports) { | ||
22110 | |||
22111 | 'use strict'; | ||
22112 | |||
22113 | module.exports = { | ||
22114 | eras: ['BC', 'AD'], | ||
22115 | months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], | ||
22116 | shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], | ||
22117 | weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], | ||
22118 | shortWeekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], | ||
22119 | veryShortWeekdays: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], | ||
22120 | ampms: ['AM', 'PM'], | ||
22121 | datePatterns: ['EEEE, MMMM d, yyyy', 'MMMM d, yyyy', 'MMM d, yyyy', 'M/d/yy'], | ||
22122 | timePatterns: ['h:mm:ss a \'GMT\'Z', 'h:mm:ss a', 'h:mm:ss a', 'h:mm a'], | ||
22123 | dateTimePattern: '{date} {time}' | ||
22124 | }; | ||
22125 | |||
22126 | /***/ }, | ||
22127 | /* 167 */ | ||
22128 | /***/ function(module, exports, __webpack_require__) { | ||
22129 | |||
22130 | /* WEBPACK VAR INJECTION */(function(process) {/** | ||
22131 | * Copyright 2014-2015, Facebook, Inc. | ||
22132 | * All rights reserved. | ||
22133 | * | ||
22134 | * This source code is licensed under the BSD-style license found in the | ||
22135 | * LICENSE file in the root directory of this source tree. An additional grant | ||
22136 | * of patent rights can be found in the PATENTS file in the same directory. | ||
22137 | */ | ||
22138 | |||
22139 | 'use strict'; | ||
22140 | |||
22141 | /** | ||
22142 | * Similar to invariant but only logs a warning if the condition is not met. | ||
22143 | * This can be used to log issues in development environments in critical | ||
22144 | * paths. Removing the logging code for production environments will keep the | ||
22145 | * same logic and follow the same code paths. | ||
22146 | */ | ||
22147 | |||
22148 | var warning = function() {}; | ||
22149 | |||
22150 | if (process.env.NODE_ENV !== 'production') { | ||
22151 | warning = function(condition, format, args) { | ||
22152 | var len = arguments.length; | ||
22153 | args = new Array(len > 2 ? len - 2 : 0); | ||
22154 | for (var key = 2; key < len; key++) { | ||
22155 | args[key - 2] = arguments[key]; | ||
22156 | } | ||
22157 | if (format === undefined) { | ||
22158 | throw new Error( | ||
22159 | '`warning(condition, format, ...args)` requires a warning ' + | ||
22160 | 'message argument' | ||
22161 | ); | ||
22162 | } | ||
22163 | |||
22164 | if (format.length < 10 || (/^[s\W]*$/).test(format)) { | ||
22165 | throw new Error( | ||
22166 | 'The warning format should be able to uniquely identify this ' + | ||
22167 | 'warning. Please, use a more descriptive format than: ' + format | ||
22168 | ); | ||
22169 | } | ||
22170 | |||
22171 | if (!condition) { | ||
22172 | var argIndex = 0; | ||
22173 | var message = 'Warning: ' + | ||
22174 | format.replace(/%s/g, function() { | ||
22175 | return args[argIndex++]; | ||
22176 | }); | ||
22177 | if (typeof console !== 'undefined') { | ||
22178 | console.error(message); | ||
22179 | } | ||
22180 | try { | ||
22181 | // This error was thrown as a convenience so that you can use this stack | ||
22182 | // to find the callsite that caused this warning to fire. | ||
22183 | throw new Error(message); | ||
22184 | } catch(x) {} | ||
22185 | } | ||
22186 | }; | ||
22187 | } | ||
22188 | |||
22189 | module.exports = warning; | ||
22190 | |||
22191 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) | ||
22192 | |||
22193 | /***/ }, | ||
22194 | /* 168 */ | ||
22195 | /***/ function(module, exports) { | ||
22196 | |||
22197 | /* | ||
22198 | * zh-cn locale | ||
22199 | * @ignore | ||
22200 | * @author yiminghe@gmail.com | ||
22201 | */ | ||
22202 | "use strict"; | ||
22203 | |||
22204 | module.exports = { | ||
22205 | // in minutes | ||
22206 | timezoneOffset: 8 * 60, | ||
22207 | firstDayOfWeek: 1, | ||
22208 | minimalDaysInFirstWeek: 1 | ||
22209 | }; | ||
22210 | |||
22211 | /***/ }, | ||
22212 | /* 169 */ | ||
22213 | /***/ function(module, exports, __webpack_require__) { | ||
22214 | |||
22215 | 'use strict'; | ||
22216 | |||
22217 | Object.defineProperty(exports, '__esModule', { | ||
22218 | value: true | ||
22219 | }); | ||
22220 | |||
22221 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
22222 | |||
22223 | var _react = __webpack_require__(3); | ||
22224 | |||
22225 | var _react2 = _interopRequireDefault(_react); | ||
22226 | |||
22227 | var _reactDom = __webpack_require__(160); | ||
22228 | |||
22229 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
22230 | |||
22231 | var _rcTrigger = __webpack_require__(170); | ||
22232 | |||
22233 | var _rcTrigger2 = _interopRequireDefault(_rcTrigger); | ||
22234 | |||
22235 | var _rcUtil = __webpack_require__(211); | ||
22236 | |||
22237 | var _utilPlacements = __webpack_require__(226); | ||
22238 | |||
22239 | var _utilPlacements2 = _interopRequireDefault(_utilPlacements); | ||
22240 | |||
22241 | var _mixinCommonMixin = __webpack_require__(227); | ||
22242 | |||
22243 | var _mixinCommonMixin2 = _interopRequireDefault(_mixinCommonMixin); | ||
22244 | |||
22245 | function noop() {} | ||
22246 | |||
22247 | function refFn(field, component) { | ||
22248 | this[field] = component; | ||
22249 | } | ||
22250 | |||
22251 | var Picker = _react2['default'].createClass({ | ||
22252 | displayName: 'Picker', | ||
22253 | |||
22254 | propTypes: { | ||
22255 | prefixCls: _react.PropTypes.string, | ||
22256 | panel: _react.PropTypes.element, | ||
22257 | children: _react.PropTypes.func, | ||
22258 | disabled: _react.PropTypes.bool, | ||
22259 | value: _react.PropTypes.object, | ||
22260 | open: _react.PropTypes.bool, | ||
22261 | align: _react.PropTypes.object, | ||
22262 | placement: _react.PropTypes.any, | ||
22263 | transitionName: _react.PropTypes.string, | ||
22264 | onChange: _react.PropTypes.func, | ||
22265 | onOpen: _react.PropTypes.func, | ||
22266 | onClose: _react.PropTypes.func | ||
22267 | }, | ||
22268 | |||
22269 | mixins: [_mixinCommonMixin2['default']], | ||
22270 | |||
22271 | getDefaultProps: function getDefaultProps() { | ||
22272 | return { | ||
22273 | open: false, | ||
22274 | align: {}, | ||
22275 | placement: 'bottomLeft', | ||
22276 | onChange: noop, | ||
22277 | onOpen: noop, | ||
22278 | onClose: noop | ||
22279 | }; | ||
22280 | }, | ||
22281 | |||
22282 | getInitialState: function getInitialState() { | ||
22283 | this.savePanelRef = refFn.bind(this, 'panelInstance'); | ||
22284 | var _props = this.props; | ||
22285 | var open = _props.open; | ||
22286 | var value = _props.value; | ||
22287 | |||
22288 | return { open: open, value: value }; | ||
22289 | }, | ||
22290 | |||
22291 | componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
22292 | var value = nextProps.value; | ||
22293 | var open = nextProps.open; | ||
22294 | |||
22295 | if (value !== undefined) { | ||
22296 | this.setState({ value: value }); | ||
22297 | } | ||
22298 | if (open !== undefined) { | ||
22299 | this.setState({ open: open }); | ||
22300 | } | ||
22301 | }, | ||
22302 | |||
22303 | onPanelChange: function onPanelChange(value) { | ||
22304 | var props = this.props; | ||
22305 | this.setState({ | ||
22306 | value: value | ||
22307 | }); | ||
22308 | props.onChange(value); | ||
22309 | }, | ||
22310 | |||
22311 | onPanelClear: function onPanelClear() { | ||
22312 | this.setOpen(false, this.focus); | ||
22313 | }, | ||
22314 | |||
22315 | onVisibleChange: function onVisibleChange(open) { | ||
22316 | var _this = this; | ||
22317 | |||
22318 | this.setOpen(open, function () { | ||
22319 | if (open) { | ||
22320 | _reactDom2['default'].findDOMNode(_this.panelInstance).focus(); | ||
22321 | } | ||
22322 | }); | ||
22323 | }, | ||
22324 | |||
22325 | getPanelElement: function getPanelElement() { | ||
22326 | var panel = this.props.panel; | ||
22327 | var extraProps = { | ||
22328 | ref: this.savePanelRef, | ||
22329 | defaultValue: this.state.value || panel.props.defaultValue, | ||
22330 | onChange: (0, _rcUtil.createChainedFunction)(panel.props.onChange, this.onPanelChange), | ||
22331 | onClear: (0, _rcUtil.createChainedFunction)(panel.props.onClear, this.onPanelClear) | ||
22332 | }; | ||
22333 | |||
22334 | return _react2['default'].cloneElement(panel, extraProps); | ||
22335 | }, | ||
22336 | |||
22337 | setOpen: function setOpen(open, callback) { | ||
22338 | var _props2 = this.props; | ||
22339 | var onOpen = _props2.onOpen; | ||
22340 | var onClose = _props2.onClose; | ||
22341 | |||
22342 | if (this.state.open !== open) { | ||
22343 | this.setState({ | ||
22344 | open: open | ||
22345 | }, callback); | ||
22346 | var _event = { | ||
22347 | open: open | ||
22348 | }; | ||
22349 | if (open) { | ||
22350 | onOpen(_event); | ||
22351 | } else { | ||
22352 | onClose(_event); | ||
22353 | } | ||
22354 | } | ||
22355 | }, | ||
22356 | |||
22357 | focus: function focus() { | ||
22358 | if (!this.state.open) { | ||
22359 | _reactDom2['default'].findDOMNode(this).focus(); | ||
22360 | } | ||
22361 | }, | ||
22362 | |||
22363 | render: function render() { | ||
22364 | var state = this.state; | ||
22365 | var props = this.props; | ||
22366 | var prefixCls = props.prefixCls; | ||
22367 | var placement = props.placement; | ||
22368 | var align = props.align; | ||
22369 | var disabled = props.disabled; | ||
22370 | var transitionName = props.transitionName; | ||
22371 | var children = props.children; | ||
22372 | |||
22373 | return _react2['default'].createElement( | ||
22374 | _rcTrigger2['default'], | ||
22375 | { | ||
22376 | prefixCls: prefixCls, | ||
22377 | popup: this.getPanelElement(), | ||
22378 | popupAlign: align, | ||
22379 | builtinPlacements: _utilPlacements2['default'], | ||
22380 | popupPlacement: placement, | ||
22381 | action: disabled ? [] : ['click'], | ||
22382 | destroyPopupOnHide: true, | ||
22383 | popupTransitionName: transitionName, | ||
22384 | popupVisible: state.open, | ||
22385 | onPopupVisibleChange: this.onVisibleChange | ||
22386 | }, | ||
22387 | _react2['default'].createElement( | ||
22388 | 'span', | ||
22389 | { className: prefixCls + '-picker' }, | ||
22390 | children(state, props) | ||
22391 | ) | ||
22392 | ); | ||
22393 | } | ||
22394 | }); | ||
22395 | |||
22396 | exports['default'] = Picker; | ||
22397 | module.exports = exports['default']; | ||
22398 | |||
22399 | /***/ }, | ||
22400 | /* 170 */ | ||
22401 | /***/ function(module, exports, __webpack_require__) { | ||
22402 | |||
22403 | 'use strict'; | ||
22404 | |||
22405 | module.exports = __webpack_require__(171); | ||
22406 | |||
22407 | /***/ }, | ||
22408 | /* 171 */ | ||
22409 | /***/ function(module, exports, __webpack_require__) { | ||
22410 | |||
22411 | 'use strict'; | ||
22412 | |||
22413 | Object.defineProperty(exports, '__esModule', { | ||
22414 | value: true | ||
22415 | }); | ||
22416 | |||
22417 | 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; }; | ||
22418 | |||
22419 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
22420 | |||
22421 | var _react = __webpack_require__(3); | ||
22422 | |||
22423 | var _react2 = _interopRequireDefault(_react); | ||
22424 | |||
22425 | var _reactDom = __webpack_require__(160); | ||
22426 | |||
22427 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
22428 | |||
22429 | var _rcUtil = __webpack_require__(172); | ||
22430 | |||
22431 | var _Popup = __webpack_require__(189); | ||
22432 | |||
22433 | var _Popup2 = _interopRequireDefault(_Popup); | ||
22434 | |||
22435 | var _utils = __webpack_require__(210); | ||
22436 | |||
22437 | function noop() {} | ||
22438 | |||
22439 | function returnEmptyString() { | ||
22440 | return ''; | ||
22441 | } | ||
22442 | |||
22443 | var Trigger = _react2['default'].createClass({ | ||
22444 | displayName: 'Trigger', | ||
22445 | |||
22446 | propTypes: { | ||
22447 | action: _react.PropTypes.any, | ||
22448 | getPopupClassNameFromAlign: _react.PropTypes.any, | ||
22449 | onPopupVisibleChange: _react.PropTypes.func, | ||
22450 | afterPopupVisibleChange: _react.PropTypes.func, | ||
22451 | popup: _react.PropTypes.node.isRequired, | ||
22452 | popupStyle: _react.PropTypes.object, | ||
22453 | popupClassName: _react.PropTypes.string, | ||
22454 | popupPlacement: _react.PropTypes.string, | ||
22455 | builtinPlacements: _react.PropTypes.object, | ||
22456 | popupTransitionName: _react.PropTypes.string, | ||
22457 | popupAnimation: _react.PropTypes.any, | ||
22458 | mouseEnterDelay: _react.PropTypes.number, | ||
22459 | mouseLeaveDelay: _react.PropTypes.number, | ||
22460 | getPopupContainer: _react.PropTypes.func, | ||
22461 | destroyPopupOnHide: _react.PropTypes.bool, | ||
22462 | popupAlign: _react.PropTypes.object, | ||
22463 | popupVisible: _react.PropTypes.bool | ||
22464 | }, | ||
22465 | |||
22466 | getDefaultProps: function getDefaultProps() { | ||
22467 | return { | ||
22468 | prefixCls: 'rc-trigger-popup', | ||
22469 | getPopupClassNameFromAlign: returnEmptyString, | ||
22470 | onPopupVisibleChange: noop, | ||
22471 | afterPopupVisibleChange: noop, | ||
22472 | popupClassName: '', | ||
22473 | mouseEnterDelay: 0, | ||
22474 | mouseLeaveDelay: 0.1, | ||
22475 | popupStyle: {}, | ||
22476 | destroyPopupOnHide: false, | ||
22477 | popupAlign: {}, | ||
22478 | defaultPopupVisible: false, | ||
22479 | action: [] | ||
22480 | }; | ||
22481 | }, | ||
22482 | |||
22483 | getInitialState: function getInitialState() { | ||
22484 | var props = this.props; | ||
22485 | var popupVisible = undefined; | ||
22486 | if ('popupVisible' in props) { | ||
22487 | popupVisible = !!props.popupVisible; | ||
22488 | } else { | ||
22489 | popupVisible = !!props.defaultPopupVisible; | ||
22490 | } | ||
22491 | return { popupVisible: popupVisible }; | ||
22492 | }, | ||
22493 | |||
22494 | componentDidMount: function componentDidMount() { | ||
22495 | this.componentDidUpdate({}, { | ||
22496 | popupVisible: this.state.popupVisible | ||
22497 | }); | ||
22498 | }, | ||
22499 | |||
22500 | componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
22501 | if ('popupVisible' in nextProps) { | ||
22502 | this.setState({ | ||
22503 | popupVisible: !!nextProps.popupVisible | ||
22504 | }); | ||
22505 | } | ||
22506 | }, | ||
22507 | |||
22508 | componentDidUpdate: function componentDidUpdate(prevProps, prevState) { | ||
22509 | var _this = this; | ||
22510 | |||
22511 | var props = this.props; | ||
22512 | var state = this.state; | ||
22513 | if (this.popupRendered) { | ||
22514 | var _ret = (function () { | ||
22515 | var self = _this; | ||
22516 | _reactDom2['default'].unstable_renderSubtreeIntoContainer(_this, _this.getPopupElement(), _this.getPopupContainer(), function renderPopup() { | ||
22517 | if (this.isMounted()) { | ||
22518 | self.popupDomNode = _reactDom2['default'].findDOMNode(this); | ||
22519 | } else { | ||
22520 | self.popupDomNode = null; | ||
22521 | } | ||
22522 | if (prevState.popupVisible !== state.popupVisible) { | ||
22523 | props.afterPopupVisibleChange(state.popupVisible); | ||
22524 | } | ||
22525 | }); | ||
22526 | if (props.action.indexOf('click') !== -1) { | ||
22527 | if (state.popupVisible) { | ||
22528 | if (!_this.clickOutsideHandler) { | ||
22529 | _this.clickOutsideHandler = _rcUtil.Dom.addEventListener(document, 'mousedown', _this.onDocumentClick); | ||
22530 | _this.touchOutsideHandler = _rcUtil.Dom.addEventListener(document, 'touchstart', _this.onDocumentClick); | ||
22531 | } | ||
22532 | return { | ||
22533 | v: undefined | ||
22534 | }; | ||
22535 | } | ||
22536 | } | ||
22537 | if (_this.clickOutsideHandler) { | ||
22538 | _this.clickOutsideHandler.remove(); | ||
22539 | _this.touchOutsideHandler.remove(); | ||
22540 | _this.clickOutsideHandler = null; | ||
22541 | _this.touchOutsideHandler = null; | ||
22542 | } | ||
22543 | })(); | ||
22544 | |||
22545 | if (typeof _ret === 'object') return _ret.v; | ||
22546 | } | ||
22547 | }, | ||
22548 | |||
22549 | componentWillUnmount: function componentWillUnmount() { | ||
22550 | var popupContainer = this.popupContainer; | ||
22551 | if (popupContainer) { | ||
22552 | _reactDom2['default'].unmountComponentAtNode(popupContainer); | ||
22553 | if (this.props.getPopupContainer) { | ||
22554 | var mountNode = this.props.getPopupContainer(); | ||
22555 | mountNode.removeChild(popupContainer); | ||
22556 | } else { | ||
22557 | document.body.removeChild(popupContainer); | ||
22558 | } | ||
22559 | this.popupContainer = null; | ||
22560 | } | ||
22561 | if (this.delayTimer) { | ||
22562 | clearTimeout(this.delayTimer); | ||
22563 | this.delayTimer = null; | ||
22564 | } | ||
22565 | if (this.clickOutsideHandler) { | ||
22566 | this.clickOutsideHandler.remove(); | ||
22567 | this.touchOutsideHandler.remove(); | ||
22568 | this.clickOutsideHandler = null; | ||
22569 | this.touchOutsideHandler = null; | ||
22570 | } | ||
22571 | }, | ||
22572 | |||
22573 | onMouseEnter: function onMouseEnter() { | ||
22574 | this.delaySetPopupVisible(true, this.props.mouseEnterDelay); | ||
22575 | }, | ||
22576 | |||
22577 | onMouseLeave: function onMouseLeave() { | ||
22578 | this.delaySetPopupVisible(false, this.props.mouseLeaveDelay); | ||
22579 | }, | ||
22580 | |||
22581 | onFocus: function onFocus() { | ||
22582 | this.focusTime = Date.now(); | ||
22583 | this.setPopupVisible(true); | ||
22584 | }, | ||
22585 | |||
22586 | onMouseDown: function onMouseDown() { | ||
22587 | this.preClickTime = Date.now(); | ||
22588 | }, | ||
22589 | |||
22590 | onTouchStart: function onTouchStart() { | ||
22591 | this.preTouchTime = Date.now(); | ||
22592 | }, | ||
22593 | |||
22594 | onBlur: function onBlur() { | ||
22595 | this.setPopupVisible(false); | ||
22596 | }, | ||
22597 | |||
22598 | onClick: function onClick(event) { | ||
22599 | // focus will trigger click | ||
22600 | if (this.focusTime) { | ||
22601 | var preTime = undefined; | ||
22602 | if (this.preClickTime && this.preTouchTime) { | ||
22603 | preTime = Math.min(this.preClickTime, this.preTouchTime); | ||
22604 | } else if (this.preClickTime) { | ||
22605 | preTime = this.preClickTime; | ||
22606 | } else if (this.preTouchTime) { | ||
22607 | preTime = this.preTouchTime; | ||
22608 | } | ||
22609 | if (Math.abs(preTime - this.focusTime) < 20) { | ||
22610 | return; | ||
22611 | } | ||
22612 | this.focusTime = 0; | ||
22613 | } | ||
22614 | this.preClickTime = 0; | ||
22615 | this.preTouchTime = 0; | ||
22616 | event.preventDefault(); | ||
22617 | this.setPopupVisible(!this.state.popupVisible); | ||
22618 | }, | ||
22619 | |||
22620 | onDocumentClick: function onDocumentClick(event) { | ||
22621 | var target = event.target; | ||
22622 | var root = _reactDom2['default'].findDOMNode(this); | ||
22623 | var popupNode = this.getPopupDomNode(); | ||
22624 | if (!_rcUtil.Dom.contains(root, target) && !_rcUtil.Dom.contains(popupNode, target)) { | ||
22625 | this.setPopupVisible(false); | ||
22626 | } | ||
22627 | }, | ||
22628 | |||
22629 | getPopupDomNode: function getPopupDomNode() { | ||
22630 | // for test | ||
22631 | return this.popupDomNode; | ||
22632 | }, | ||
22633 | |||
22634 | getPopupContainer: function getPopupContainer() { | ||
22635 | if (!this.popupContainer) { | ||
22636 | this.popupContainer = document.createElement('div'); | ||
22637 | if (this.props.getPopupContainer) { | ||
22638 | var mountNode = this.props.getPopupContainer(); | ||
22639 | mountNode.appendChild(this.popupContainer); | ||
22640 | } else { | ||
22641 | document.body.appendChild(this.popupContainer); | ||
22642 | } | ||
22643 | } | ||
22644 | return this.popupContainer; | ||
22645 | }, | ||
22646 | |||
22647 | getPopupClassNameFromAlign: function getPopupClassNameFromAlign(align) { | ||
22648 | var className = []; | ||
22649 | var props = this.props; | ||
22650 | var popupPlacement = props.popupPlacement; | ||
22651 | var builtinPlacements = props.builtinPlacements; | ||
22652 | var prefixCls = props.prefixCls; | ||
22653 | |||
22654 | if (popupPlacement && builtinPlacements) { | ||
22655 | className.push((0, _utils.getPopupClassNameFromAlign)(builtinPlacements, prefixCls, align)); | ||
22656 | } | ||
22657 | if (props.getPopupClassNameFromAlign) { | ||
22658 | className.push(props.getPopupClassNameFromAlign(align)); | ||
22659 | } | ||
22660 | return className.join(' '); | ||
22661 | }, | ||
22662 | |||
22663 | getPopupAlign: function getPopupAlign() { | ||
22664 | var props = this.props; | ||
22665 | var popupPlacement = props.popupPlacement; | ||
22666 | var popupAlign = props.popupAlign; | ||
22667 | var builtinPlacements = props.builtinPlacements; | ||
22668 | |||
22669 | if (popupPlacement && builtinPlacements) { | ||
22670 | return (0, _utils.getAlignFromPlacement)(builtinPlacements, popupPlacement, popupAlign); | ||
22671 | } | ||
22672 | return popupAlign; | ||
22673 | }, | ||
22674 | |||
22675 | getPopupElement: function getPopupElement() { | ||
22676 | var props = this.props; | ||
22677 | var state = this.state; | ||
22678 | var mouseProps = {}; | ||
22679 | if (props.action.indexOf('hover') !== -1) { | ||
22680 | mouseProps.onMouseEnter = this.onMouseEnter; | ||
22681 | mouseProps.onMouseLeave = this.onMouseLeave; | ||
22682 | } | ||
22683 | return _react2['default'].createElement( | ||
22684 | _Popup2['default'], | ||
22685 | _extends({ prefixCls: props.prefixCls, | ||
22686 | destroyPopupOnHide: props.destroyPopupOnHide, | ||
22687 | visible: state.popupVisible, | ||
22688 | className: props.popupClassName, | ||
22689 | action: props.action, | ||
22690 | align: this.getPopupAlign(), | ||
22691 | animation: props.popupAnimation, | ||
22692 | getClassNameFromAlign: this.getPopupClassNameFromAlign | ||
22693 | }, mouseProps, { | ||
22694 | wrap: this, | ||
22695 | style: props.popupStyle, | ||
22696 | transitionName: props.popupTransitionName }), | ||
22697 | props.popup | ||
22698 | ); | ||
22699 | }, | ||
22700 | |||
22701 | setPopupVisible: function setPopupVisible(popupVisible) { | ||
22702 | if (this.state.popupVisible !== popupVisible) { | ||
22703 | if (!('popupVisible' in this.props)) { | ||
22704 | this.setState({ | ||
22705 | popupVisible: popupVisible | ||
22706 | }); | ||
22707 | } | ||
22708 | this.props.onPopupVisibleChange(popupVisible); | ||
22709 | } | ||
22710 | }, | ||
22711 | |||
22712 | delaySetPopupVisible: function delaySetPopupVisible(visible, delayS) { | ||
22713 | var _this2 = this; | ||
22714 | |||
22715 | var delay = delayS * 1000; | ||
22716 | if (this.delayTimer) { | ||
22717 | clearTimeout(this.delayTimer); | ||
22718 | this.delayTimer = null; | ||
22719 | } | ||
22720 | if (delay) { | ||
22721 | this.delayTimer = setTimeout(function () { | ||
22722 | _this2.setPopupVisible(visible); | ||
22723 | _this2.delayTimer = null; | ||
22724 | }, delay); | ||
22725 | } else { | ||
22726 | this.setPopupVisible(visible); | ||
22727 | } | ||
22728 | }, | ||
22729 | |||
22730 | render: function render() { | ||
22731 | this.popupRendered = this.popupRendered || this.state.popupVisible; | ||
22732 | var props = this.props; | ||
22733 | var children = props.children; | ||
22734 | var child = _react2['default'].Children.only(children); | ||
22735 | var childProps = child.props || {}; | ||
22736 | var newChildProps = {}; | ||
22737 | var trigger = props.action; | ||
22738 | if (trigger.indexOf('click') !== -1) { | ||
22739 | newChildProps.onClick = (0, _rcUtil.createChainedFunction)(this.onClick, childProps.onClick); | ||
22740 | newChildProps.onMouseDown = (0, _rcUtil.createChainedFunction)(this.onMouseDown, childProps.onMouseDown); | ||
22741 | newChildProps.onTouchStart = (0, _rcUtil.createChainedFunction)(this.onTouchStart, childProps.onTouchStart); | ||
22742 | } | ||
22743 | if (trigger.indexOf('hover') !== -1) { | ||
22744 | newChildProps.onMouseEnter = (0, _rcUtil.createChainedFunction)(this.onMouseEnter, childProps.onMouseEnter); | ||
22745 | newChildProps.onMouseLeave = (0, _rcUtil.createChainedFunction)(this.onMouseLeave, childProps.onMouseLeave); | ||
22746 | } | ||
22747 | if (trigger.indexOf('focus') !== -1) { | ||
22748 | newChildProps.onFocus = (0, _rcUtil.createChainedFunction)(this.onFocus, childProps.onFocus); | ||
22749 | newChildProps.onBlur = (0, _rcUtil.createChainedFunction)(this.onBlur, childProps.onBlur); | ||
22750 | } | ||
22751 | |||
22752 | return _react2['default'].cloneElement(child, newChildProps); | ||
22753 | } | ||
22754 | }); | ||
22755 | |||
22756 | exports['default'] = Trigger; | ||
22757 | module.exports = exports['default']; | ||
22758 | |||
22759 | /***/ }, | ||
22760 | /* 172 */ | ||
22761 | /***/ function(module, exports, __webpack_require__) { | ||
22762 | |||
22763 | 'use strict'; | ||
22764 | |||
22765 | module.exports = { | ||
22766 | guid: __webpack_require__(173), | ||
22767 | classSet: __webpack_require__(174), | ||
22768 | joinClasses: __webpack_require__(176), | ||
22769 | KeyCode: __webpack_require__(177), | ||
22770 | PureRenderMixin: __webpack_require__(178), | ||
22771 | shallowEqual: __webpack_require__(179), | ||
22772 | createChainedFunction: __webpack_require__(180), | ||
22773 | Dom: { | ||
22774 | addEventListener: __webpack_require__(181), | ||
22775 | contains: __webpack_require__(186) | ||
22776 | }, | ||
22777 | Children: { | ||
22778 | toArray: __webpack_require__(187), | ||
22779 | mapSelf: __webpack_require__(188) | ||
22780 | } | ||
22781 | }; | ||
22782 | |||
22783 | /***/ }, | ||
22784 | /* 173 */ | ||
22785 | /***/ function(module, exports) { | ||
22786 | |||
22787 | 'use strict'; | ||
22788 | |||
22789 | var seed = 0; | ||
22790 | module.exports = function guid() { | ||
22791 | return Date.now() + '_' + seed++; | ||
22792 | }; | ||
22793 | |||
22794 | /***/ }, | ||
22795 | /* 174 */ | ||
22796 | /***/ function(module, exports, __webpack_require__) { | ||
22797 | |||
22798 | 'use strict'; | ||
22799 | |||
22800 | module.exports = __webpack_require__(175); | ||
22801 | |||
22802 | /***/ }, | ||
22803 | /* 175 */ | ||
22804 | /***/ function(module, exports, __webpack_require__) { | ||
22805 | |||
22806 | var __WEBPACK_AMD_DEFINE_RESULT__;/*! | ||
22807 | Copyright (c) 2015 Jed Watson. | ||
22808 | Licensed under the MIT License (MIT), see | ||
22809 | http://jedwatson.github.io/classnames | ||
22810 | */ | ||
22811 | /* global define */ | ||
22812 | |||
22813 | (function () { | ||
22814 | 'use strict'; | ||
22815 | |||
22816 | var hasOwn = {}.hasOwnProperty; | ||
22817 | |||
22818 | function classNames () { | ||
22819 | var classes = ''; | ||
22820 | |||
22821 | for (var i = 0; i < arguments.length; i++) { | ||
22822 | var arg = arguments[i]; | ||
22823 | if (!arg) continue; | ||
22824 | |||
22825 | var argType = typeof arg; | ||
22826 | |||
22827 | if (argType === 'string' || argType === 'number') { | ||
22828 | classes += ' ' + arg; | ||
22829 | } else if (Array.isArray(arg)) { | ||
22830 | classes += ' ' + classNames.apply(null, arg); | ||
22831 | } else if (argType === 'object') { | ||
22832 | for (var key in arg) { | ||
22833 | if (hasOwn.call(arg, key) && arg[key]) { | ||
22834 | classes += ' ' + key; | ||
22835 | } | ||
22836 | } | ||
22837 | } | ||
22838 | } | ||
22839 | |||
22840 | return classes.substr(1); | ||
22841 | } | ||
22842 | |||
22843 | if (typeof module !== 'undefined' && module.exports) { | ||
22844 | module.exports = classNames; | ||
22845 | } else if (true) { | ||
22846 | // register as 'classnames', consistent with npm package name | ||
22847 | !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { | ||
22848 | return classNames; | ||
22849 | }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
22850 | } else { | ||
22851 | window.classNames = classNames; | ||
22852 | } | ||
22853 | }()); | ||
22854 | |||
22855 | |||
22856 | /***/ }, | ||
22857 | /* 176 */ | ||
22858 | /***/ function(module, exports) { | ||
22859 | |||
22860 | /** | ||
22861 | * Combines multiple className strings into one. | ||
22862 | * http://jsperf.com/joinclasses-args-vs-array | ||
22863 | * | ||
22864 | * @param {...?string} classes | ||
22865 | * @return {string} | ||
22866 | */ | ||
22867 | |||
22868 | 'use strict'; | ||
22869 | |||
22870 | function joinClasses(cn) { | ||
22871 | var className = cn; | ||
22872 | if (!className) { | ||
22873 | className = ''; | ||
22874 | } | ||
22875 | var nextClass = undefined; | ||
22876 | var argLength = arguments.length; | ||
22877 | if (argLength > 1) { | ||
22878 | for (var ii = 1; ii < argLength; ii++) { | ||
22879 | nextClass = arguments[ii]; | ||
22880 | if (nextClass) { | ||
22881 | className = (className ? className + ' ' : '') + nextClass; | ||
22882 | } | ||
22883 | } | ||
22884 | } | ||
22885 | return className; | ||
22886 | } | ||
22887 | |||
22888 | module.exports = joinClasses; | ||
22889 | |||
22890 | /***/ }, | ||
22891 | /* 177 */ | ||
22892 | /***/ function(module, exports) { | ||
22893 | |||
22894 | /** | ||
22895 | * @ignore | ||
22896 | * some key-codes definition and utils from closure-library | ||
22897 | * @author yiminghe@gmail.com | ||
22898 | */ | ||
22899 | |||
22900 | 'use strict'; | ||
22901 | |||
22902 | var KeyCode = { | ||
22903 | /** | ||
22904 | * MAC_ENTER | ||
22905 | */ | ||
22906 | MAC_ENTER: 3, | ||
22907 | /** | ||
22908 | * BACKSPACE | ||
22909 | */ | ||
22910 | BACKSPACE: 8, | ||
22911 | /** | ||
22912 | * TAB | ||
22913 | */ | ||
22914 | TAB: 9, | ||
22915 | /** | ||
22916 | * NUMLOCK on FF/Safari Mac | ||
22917 | */ | ||
22918 | NUM_CENTER: 12, // NUMLOCK on FF/Safari Mac | ||
22919 | /** | ||
22920 | * ENTER | ||
22921 | */ | ||
22922 | ENTER: 13, | ||
22923 | /** | ||
22924 | * SHIFT | ||
22925 | */ | ||
22926 | SHIFT: 16, | ||
22927 | /** | ||
22928 | * CTRL | ||
22929 | */ | ||
22930 | CTRL: 17, | ||
22931 | /** | ||
22932 | * ALT | ||
22933 | */ | ||
22934 | ALT: 18, | ||
22935 | /** | ||
22936 | * PAUSE | ||
22937 | */ | ||
22938 | PAUSE: 19, | ||
22939 | /** | ||
22940 | * CAPS_LOCK | ||
22941 | */ | ||
22942 | CAPS_LOCK: 20, | ||
22943 | /** | ||
22944 | * ESC | ||
22945 | */ | ||
22946 | ESC: 27, | ||
22947 | /** | ||
22948 | * SPACE | ||
22949 | */ | ||
22950 | SPACE: 32, | ||
22951 | /** | ||
22952 | * PAGE_UP | ||
22953 | */ | ||
22954 | PAGE_UP: 33, // also NUM_NORTH_EAST | ||
22955 | /** | ||
22956 | * PAGE_DOWN | ||
22957 | */ | ||
22958 | PAGE_DOWN: 34, // also NUM_SOUTH_EAST | ||
22959 | /** | ||
22960 | * END | ||
22961 | */ | ||
22962 | END: 35, // also NUM_SOUTH_WEST | ||
22963 | /** | ||
22964 | * HOME | ||
22965 | */ | ||
22966 | HOME: 36, // also NUM_NORTH_WEST | ||
22967 | /** | ||
22968 | * LEFT | ||
22969 | */ | ||
22970 | LEFT: 37, // also NUM_WEST | ||
22971 | /** | ||
22972 | * UP | ||
22973 | */ | ||
22974 | UP: 38, // also NUM_NORTH | ||
22975 | /** | ||
22976 | * RIGHT | ||
22977 | */ | ||
22978 | RIGHT: 39, // also NUM_EAST | ||
22979 | /** | ||
22980 | * DOWN | ||
22981 | */ | ||
22982 | DOWN: 40, // also NUM_SOUTH | ||
22983 | /** | ||
22984 | * PRINT_SCREEN | ||
22985 | */ | ||
22986 | PRINT_SCREEN: 44, | ||
22987 | /** | ||
22988 | * INSERT | ||
22989 | */ | ||
22990 | INSERT: 45, // also NUM_INSERT | ||
22991 | /** | ||
22992 | * DELETE | ||
22993 | */ | ||
22994 | DELETE: 46, // also NUM_DELETE | ||
22995 | /** | ||
22996 | * ZERO | ||
22997 | */ | ||
22998 | ZERO: 48, | ||
22999 | /** | ||
23000 | * ONE | ||
23001 | */ | ||
23002 | ONE: 49, | ||
23003 | /** | ||
23004 | * TWO | ||
23005 | */ | ||
23006 | TWO: 50, | ||
23007 | /** | ||
23008 | * THREE | ||
23009 | */ | ||
23010 | THREE: 51, | ||
23011 | /** | ||
23012 | * FOUR | ||
23013 | */ | ||
23014 | FOUR: 52, | ||
23015 | /** | ||
23016 | * FIVE | ||
23017 | */ | ||
23018 | FIVE: 53, | ||
23019 | /** | ||
23020 | * SIX | ||
23021 | */ | ||
23022 | SIX: 54, | ||
23023 | /** | ||
23024 | * SEVEN | ||
23025 | */ | ||
23026 | SEVEN: 55, | ||
23027 | /** | ||
23028 | * EIGHT | ||
23029 | */ | ||
23030 | EIGHT: 56, | ||
23031 | /** | ||
23032 | * NINE | ||
23033 | */ | ||
23034 | NINE: 57, | ||
23035 | /** | ||
23036 | * QUESTION_MARK | ||
23037 | */ | ||
23038 | QUESTION_MARK: 63, // needs localization | ||
23039 | /** | ||
23040 | * A | ||
23041 | */ | ||
23042 | A: 65, | ||
23043 | /** | ||
23044 | * B | ||
23045 | */ | ||
23046 | B: 66, | ||
23047 | /** | ||
23048 | * C | ||
23049 | */ | ||
23050 | C: 67, | ||
23051 | /** | ||
23052 | * D | ||
23053 | */ | ||
23054 | D: 68, | ||
23055 | /** | ||
23056 | * E | ||
23057 | */ | ||
23058 | E: 69, | ||
23059 | /** | ||
23060 | * F | ||
23061 | */ | ||
23062 | F: 70, | ||
23063 | /** | ||
23064 | * G | ||
23065 | */ | ||
23066 | G: 71, | ||
23067 | /** | ||
23068 | * H | ||
23069 | */ | ||
23070 | H: 72, | ||
23071 | /** | ||
23072 | * I | ||
23073 | */ | ||
23074 | I: 73, | ||
23075 | /** | ||
23076 | * J | ||
23077 | */ | ||
23078 | J: 74, | ||
23079 | /** | ||
23080 | * K | ||
23081 | */ | ||
23082 | K: 75, | ||
23083 | /** | ||
23084 | * L | ||
23085 | */ | ||
23086 | L: 76, | ||
23087 | /** | ||
23088 | * M | ||
23089 | */ | ||
23090 | M: 77, | ||
23091 | /** | ||
23092 | * N | ||
23093 | */ | ||
23094 | N: 78, | ||
23095 | /** | ||
23096 | * O | ||
23097 | */ | ||
23098 | O: 79, | ||
23099 | /** | ||
23100 | * P | ||
23101 | */ | ||
23102 | P: 80, | ||
23103 | /** | ||
23104 | * Q | ||
23105 | */ | ||
23106 | Q: 81, | ||
23107 | /** | ||
23108 | * R | ||
23109 | */ | ||
23110 | R: 82, | ||
23111 | /** | ||
23112 | * S | ||
23113 | */ | ||
23114 | S: 83, | ||
23115 | /** | ||
23116 | * T | ||
23117 | */ | ||
23118 | T: 84, | ||
23119 | /** | ||
23120 | * U | ||
23121 | */ | ||
23122 | U: 85, | ||
23123 | /** | ||
23124 | * V | ||
23125 | */ | ||
23126 | V: 86, | ||
23127 | /** | ||
23128 | * W | ||
23129 | */ | ||
23130 | W: 87, | ||
23131 | /** | ||
23132 | * X | ||
23133 | */ | ||
23134 | X: 88, | ||
23135 | /** | ||
23136 | * Y | ||
23137 | */ | ||
23138 | Y: 89, | ||
23139 | /** | ||
23140 | * Z | ||
23141 | */ | ||
23142 | Z: 90, | ||
23143 | /** | ||
23144 | * META | ||
23145 | */ | ||
23146 | META: 91, // WIN_KEY_LEFT | ||
23147 | /** | ||
23148 | * WIN_KEY_RIGHT | ||
23149 | */ | ||
23150 | WIN_KEY_RIGHT: 92, | ||
23151 | /** | ||
23152 | * CONTEXT_MENU | ||
23153 | */ | ||
23154 | CONTEXT_MENU: 93, | ||
23155 | /** | ||
23156 | * NUM_ZERO | ||
23157 | */ | ||
23158 | NUM_ZERO: 96, | ||
23159 | /** | ||
23160 | * NUM_ONE | ||
23161 | */ | ||
23162 | NUM_ONE: 97, | ||
23163 | /** | ||
23164 | * NUM_TWO | ||
23165 | */ | ||
23166 | NUM_TWO: 98, | ||
23167 | /** | ||
23168 | * NUM_THREE | ||
23169 | */ | ||
23170 | NUM_THREE: 99, | ||
23171 | /** | ||
23172 | * NUM_FOUR | ||
23173 | */ | ||
23174 | NUM_FOUR: 100, | ||
23175 | /** | ||
23176 | * NUM_FIVE | ||
23177 | */ | ||
23178 | NUM_FIVE: 101, | ||
23179 | /** | ||
23180 | * NUM_SIX | ||
23181 | */ | ||
23182 | NUM_SIX: 102, | ||
23183 | /** | ||
23184 | * NUM_SEVEN | ||
23185 | */ | ||
23186 | NUM_SEVEN: 103, | ||
23187 | /** | ||
23188 | * NUM_EIGHT | ||
23189 | */ | ||
23190 | NUM_EIGHT: 104, | ||
23191 | /** | ||
23192 | * NUM_NINE | ||
23193 | */ | ||
23194 | NUM_NINE: 105, | ||
23195 | /** | ||
23196 | * NUM_MULTIPLY | ||
23197 | */ | ||
23198 | NUM_MULTIPLY: 106, | ||
23199 | /** | ||
23200 | * NUM_PLUS | ||
23201 | */ | ||
23202 | NUM_PLUS: 107, | ||
23203 | /** | ||
23204 | * NUM_MINUS | ||
23205 | */ | ||
23206 | NUM_MINUS: 109, | ||
23207 | /** | ||
23208 | * NUM_PERIOD | ||
23209 | */ | ||
23210 | NUM_PERIOD: 110, | ||
23211 | /** | ||
23212 | * NUM_DIVISION | ||
23213 | */ | ||
23214 | NUM_DIVISION: 111, | ||
23215 | /** | ||
23216 | * F1 | ||
23217 | */ | ||
23218 | F1: 112, | ||
23219 | /** | ||
23220 | * F2 | ||
23221 | */ | ||
23222 | F2: 113, | ||
23223 | /** | ||
23224 | * F3 | ||
23225 | */ | ||
23226 | F3: 114, | ||
23227 | /** | ||
23228 | * F4 | ||
23229 | */ | ||
23230 | F4: 115, | ||
23231 | /** | ||
23232 | * F5 | ||
23233 | */ | ||
23234 | F5: 116, | ||
23235 | /** | ||
23236 | * F6 | ||
23237 | */ | ||
23238 | F6: 117, | ||
23239 | /** | ||
23240 | * F7 | ||
23241 | */ | ||
23242 | F7: 118, | ||
23243 | /** | ||
23244 | * F8 | ||
23245 | */ | ||
23246 | F8: 119, | ||
23247 | /** | ||
23248 | * F9 | ||
23249 | */ | ||
23250 | F9: 120, | ||
23251 | /** | ||
23252 | * F10 | ||
23253 | */ | ||
23254 | F10: 121, | ||
23255 | /** | ||
23256 | * F11 | ||
23257 | */ | ||
23258 | F11: 122, | ||
23259 | /** | ||
23260 | * F12 | ||
23261 | */ | ||
23262 | F12: 123, | ||
23263 | /** | ||
23264 | * NUMLOCK | ||
23265 | */ | ||
23266 | NUMLOCK: 144, | ||
23267 | /** | ||
23268 | * SEMICOLON | ||
23269 | */ | ||
23270 | SEMICOLON: 186, // needs localization | ||
23271 | /** | ||
23272 | * DASH | ||
23273 | */ | ||
23274 | DASH: 189, // needs localization | ||
23275 | /** | ||
23276 | * EQUALS | ||
23277 | */ | ||
23278 | EQUALS: 187, // needs localization | ||
23279 | /** | ||
23280 | * COMMA | ||
23281 | */ | ||
23282 | COMMA: 188, // needs localization | ||
23283 | /** | ||
23284 | * PERIOD | ||
23285 | */ | ||
23286 | PERIOD: 190, // needs localization | ||
23287 | /** | ||
23288 | * SLASH | ||
23289 | */ | ||
23290 | SLASH: 191, // needs localization | ||
23291 | /** | ||
23292 | * APOSTROPHE | ||
23293 | */ | ||
23294 | APOSTROPHE: 192, // needs localization | ||
23295 | /** | ||
23296 | * SINGLE_QUOTE | ||
23297 | */ | ||
23298 | SINGLE_QUOTE: 222, // needs localization | ||
23299 | /** | ||
23300 | * OPEN_SQUARE_BRACKET | ||
23301 | */ | ||
23302 | OPEN_SQUARE_BRACKET: 219, // needs localization | ||
23303 | /** | ||
23304 | * BACKSLASH | ||
23305 | */ | ||
23306 | BACKSLASH: 220, // needs localization | ||
23307 | /** | ||
23308 | * CLOSE_SQUARE_BRACKET | ||
23309 | */ | ||
23310 | CLOSE_SQUARE_BRACKET: 221, // needs localization | ||
23311 | /** | ||
23312 | * WIN_KEY | ||
23313 | */ | ||
23314 | WIN_KEY: 224, | ||
23315 | /** | ||
23316 | * MAC_FF_META | ||
23317 | */ | ||
23318 | MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91 | ||
23319 | /** | ||
23320 | * WIN_IME | ||
23321 | */ | ||
23322 | WIN_IME: 229 | ||
23323 | }; | ||
23324 | |||
23325 | /* | ||
23326 | whether text and modified key is entered at the same time. | ||
23327 | */ | ||
23328 | KeyCode.isTextModifyingKeyEvent = function isTextModifyingKeyEvent(e) { | ||
23329 | var keyCode = e.keyCode; | ||
23330 | if (e.altKey && !e.ctrlKey || e.metaKey || | ||
23331 | // Function keys don't generate text | ||
23332 | keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) { | ||
23333 | return false; | ||
23334 | } | ||
23335 | |||
23336 | // The following keys are quite harmless, even in combination with | ||
23337 | // CTRL, ALT or SHIFT. | ||
23338 | switch (keyCode) { | ||
23339 | case KeyCode.ALT: | ||
23340 | case KeyCode.CAPS_LOCK: | ||
23341 | case KeyCode.CONTEXT_MENU: | ||
23342 | case KeyCode.CTRL: | ||
23343 | case KeyCode.DOWN: | ||
23344 | case KeyCode.END: | ||
23345 | case KeyCode.ESC: | ||
23346 | case KeyCode.HOME: | ||
23347 | case KeyCode.INSERT: | ||
23348 | case KeyCode.LEFT: | ||
23349 | case KeyCode.MAC_FF_META: | ||
23350 | case KeyCode.META: | ||
23351 | case KeyCode.NUMLOCK: | ||
23352 | case KeyCode.NUM_CENTER: | ||
23353 | case KeyCode.PAGE_DOWN: | ||
23354 | case KeyCode.PAGE_UP: | ||
23355 | case KeyCode.PAUSE: | ||
23356 | case KeyCode.PRINT_SCREEN: | ||
23357 | case KeyCode.RIGHT: | ||
23358 | case KeyCode.SHIFT: | ||
23359 | case KeyCode.UP: | ||
23360 | case KeyCode.WIN_KEY: | ||
23361 | case KeyCode.WIN_KEY_RIGHT: | ||
23362 | return false; | ||
23363 | default: | ||
23364 | return true; | ||
23365 | } | ||
23366 | }; | ||
23367 | |||
23368 | /* | ||
23369 | whether character is entered. | ||
23370 | */ | ||
23371 | KeyCode.isCharacterKey = function isCharacterKey(keyCode) { | ||
23372 | if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) { | ||
23373 | return true; | ||
23374 | } | ||
23375 | |||
23376 | if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) { | ||
23377 | return true; | ||
23378 | } | ||
23379 | |||
23380 | if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) { | ||
23381 | return true; | ||
23382 | } | ||
23383 | |||
23384 | // Safari sends zero key code for non-latin characters. | ||
23385 | if (window.navigation.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) { | ||
23386 | return true; | ||
23387 | } | ||
23388 | |||
23389 | switch (keyCode) { | ||
23390 | case KeyCode.SPACE: | ||
23391 | case KeyCode.QUESTION_MARK: | ||
23392 | case KeyCode.NUM_PLUS: | ||
23393 | case KeyCode.NUM_MINUS: | ||
23394 | case KeyCode.NUM_PERIOD: | ||
23395 | case KeyCode.NUM_DIVISION: | ||
23396 | case KeyCode.SEMICOLON: | ||
23397 | case KeyCode.DASH: | ||
23398 | case KeyCode.EQUALS: | ||
23399 | case KeyCode.COMMA: | ||
23400 | case KeyCode.PERIOD: | ||
23401 | case KeyCode.SLASH: | ||
23402 | case KeyCode.APOSTROPHE: | ||
23403 | case KeyCode.SINGLE_QUOTE: | ||
23404 | case KeyCode.OPEN_SQUARE_BRACKET: | ||
23405 | case KeyCode.BACKSLASH: | ||
23406 | case KeyCode.CLOSE_SQUARE_BRACKET: | ||
23407 | return true; | ||
23408 | default: | ||
23409 | return false; | ||
23410 | } | ||
23411 | }; | ||
23412 | |||
23413 | module.exports = KeyCode; | ||
23414 | |||
23415 | /***/ }, | ||
23416 | /* 178 */ | ||
23417 | /***/ function(module, exports, __webpack_require__) { | ||
23418 | |||
23419 | 'use strict'; | ||
23420 | |||
23421 | var shallowEqual = __webpack_require__(179); | ||
23422 | |||
23423 | /** | ||
23424 | * If your React component's render function is "pure", e.g. it will render the | ||
23425 | * same result given the same props and state, provide this Mixin for a | ||
23426 | * considerable performance boost. | ||
23427 | * | ||
23428 | * Most React components have pure render functions. | ||
23429 | * | ||
23430 | * Example: | ||
23431 | * | ||
23432 | * const ReactComponentWithPureRenderMixin = | ||
23433 | * require('ReactComponentWithPureRenderMixin'); | ||
23434 | * React.createClass({ | ||
23435 | * mixins: [ReactComponentWithPureRenderMixin], | ||
23436 | * | ||
23437 | * render: function() { | ||
23438 | * return <div className={this.props.className}>foo</div>; | ||
23439 | * } | ||
23440 | * }); | ||
23441 | * | ||
23442 | * Note: This only checks shallow equality for props and state. If these contain | ||
23443 | * complex data structures this mixin may have false-negatives for deeper | ||
23444 | * differences. Only mixin to components which have simple props and state, or | ||
23445 | * use `forceUpdate()` when you know deep data structures have changed. | ||
23446 | */ | ||
23447 | var ReactComponentWithPureRenderMixin = { | ||
23448 | shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { | ||
23449 | return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState); | ||
23450 | } | ||
23451 | }; | ||
23452 | |||
23453 | module.exports = ReactComponentWithPureRenderMixin; | ||
23454 | |||
23455 | /***/ }, | ||
23456 | /* 179 */ | ||
23457 | /***/ function(module, exports) { | ||
23458 | |||
23459 | "use strict"; | ||
23460 | |||
23461 | function shallowEqual(objA, objB) { | ||
23462 | if (objA === objB) { | ||
23463 | return true; | ||
23464 | } | ||
23465 | var key = undefined; | ||
23466 | // Test for A's keys different from B. | ||
23467 | for (key in objA) { | ||
23468 | if (objA.hasOwnProperty(key) && (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) { | ||
23469 | return false; | ||
23470 | } | ||
23471 | } | ||
23472 | // Test for B's keys missing from A. | ||
23473 | for (key in objB) { | ||
23474 | if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) { | ||
23475 | return false; | ||
23476 | } | ||
23477 | } | ||
23478 | return true; | ||
23479 | } | ||
23480 | |||
23481 | module.exports = shallowEqual; | ||
23482 | |||
23483 | /***/ }, | ||
23484 | /* 180 */ | ||
23485 | /***/ function(module, exports) { | ||
23486 | |||
23487 | /** | ||
23488 | * Safe chained function | ||
23489 | * | ||
23490 | * Will only create a new function if needed, | ||
23491 | * otherwise will pass back existing functions or null. | ||
23492 | * | ||
23493 | * @returns {function|null} | ||
23494 | */ | ||
23495 | "use strict"; | ||
23496 | |||
23497 | function createChainedFunction() { | ||
23498 | var args = arguments; | ||
23499 | return function chainedFunction() { | ||
23500 | for (var i = 0; i < args.length; i++) { | ||
23501 | if (args[i] && args[i].apply) { | ||
23502 | args[i].apply(this, arguments); | ||
23503 | } | ||
23504 | } | ||
23505 | }; | ||
23506 | } | ||
23507 | |||
23508 | module.exports = createChainedFunction; | ||
23509 | |||
23510 | /***/ }, | ||
23511 | /* 181 */ | ||
23512 | /***/ function(module, exports, __webpack_require__) { | ||
23513 | |||
23514 | 'use strict'; | ||
23515 | |||
23516 | Object.defineProperty(exports, '__esModule', { | ||
23517 | value: true | ||
23518 | }); | ||
23519 | exports['default'] = addEventListenerWrap; | ||
23520 | |||
23521 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
23522 | |||
23523 | var _addDomEventListener = __webpack_require__(182); | ||
23524 | |||
23525 | var _addDomEventListener2 = _interopRequireDefault(_addDomEventListener); | ||
23526 | |||
23527 | var _reactDom = __webpack_require__(160); | ||
23528 | |||
23529 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
23530 | |||
23531 | function addEventListenerWrap(target, eventType, cb) { | ||
23532 | /* eslint camelcase: 2 */ | ||
23533 | var callback = _reactDom2['default'].unstable_batchedUpdates ? function run(e) { | ||
23534 | _reactDom2['default'].unstable_batchedUpdates(cb, e); | ||
23535 | } : cb; | ||
23536 | return (0, _addDomEventListener2['default'])(target, eventType, callback); | ||
23537 | } | ||
23538 | |||
23539 | module.exports = exports['default']; | ||
23540 | |||
23541 | /***/ }, | ||
23542 | /* 182 */ | ||
23543 | /***/ function(module, exports, __webpack_require__) { | ||
23544 | |||
23545 | 'use strict'; | ||
23546 | |||
23547 | Object.defineProperty(exports, '__esModule', { | ||
23548 | value: true | ||
23549 | }); | ||
23550 | exports['default'] = addEventListener; | ||
23551 | |||
23552 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
23553 | |||
23554 | var _EventObject = __webpack_require__(183); | ||
23555 | |||
23556 | var _EventObject2 = _interopRequireDefault(_EventObject); | ||
23557 | |||
23558 | function addEventListener(target, eventType, callback) { | ||
23559 | function wrapCallback(e) { | ||
23560 | var ne = new _EventObject2['default'](e); | ||
23561 | callback.call(target, ne); | ||
23562 | } | ||
23563 | |||
23564 | if (target.addEventListener) { | ||
23565 | target.addEventListener(eventType, wrapCallback, false); | ||
23566 | return { | ||
23567 | remove: function remove() { | ||
23568 | target.removeEventListener(eventType, wrapCallback, false); | ||
23569 | } | ||
23570 | }; | ||
23571 | } else if (target.attachEvent) { | ||
23572 | target.attachEvent('on' + eventType, wrapCallback); | ||
23573 | return { | ||
23574 | remove: function remove() { | ||
23575 | target.detachEvent('on' + eventType, wrapCallback); | ||
23576 | } | ||
23577 | }; | ||
23578 | } | ||
23579 | } | ||
23580 | |||
23581 | module.exports = exports['default']; | ||
23582 | |||
23583 | /***/ }, | ||
23584 | /* 183 */ | ||
23585 | /***/ function(module, exports, __webpack_require__) { | ||
23586 | |||
23587 | /** | ||
23588 | * @ignore | ||
23589 | * event object for dom | ||
23590 | * @author yiminghe@gmail.com | ||
23591 | */ | ||
23592 | |||
23593 | 'use strict'; | ||
23594 | |||
23595 | Object.defineProperty(exports, '__esModule', { | ||
23596 | value: true | ||
23597 | }); | ||
23598 | |||
23599 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
23600 | |||
23601 | var _EventBaseObject = __webpack_require__(184); | ||
23602 | |||
23603 | var _EventBaseObject2 = _interopRequireDefault(_EventBaseObject); | ||
23604 | |||
23605 | var _objectAssign = __webpack_require__(185); | ||
23606 | |||
23607 | var _objectAssign2 = _interopRequireDefault(_objectAssign); | ||
23608 | |||
23609 | var TRUE = true; | ||
23610 | var FALSE = false; | ||
23611 | var commonProps = ['altKey', 'bubbles', 'cancelable', 'ctrlKey', 'currentTarget', 'eventPhase', 'metaKey', 'shiftKey', 'target', 'timeStamp', 'view', 'type']; | ||
23612 | |||
23613 | function isNullOrUndefined(w) { | ||
23614 | return w === null || w === undefined; | ||
23615 | } | ||
23616 | |||
23617 | var eventNormalizers = [{ | ||
23618 | reg: /^key/, | ||
23619 | props: ['char', 'charCode', 'key', 'keyCode', 'which'], | ||
23620 | fix: function fix(event, nativeEvent) { | ||
23621 | if (isNullOrUndefined(event.which)) { | ||
23622 | event.which = !isNullOrUndefined(nativeEvent.charCode) ? nativeEvent.charCode : nativeEvent.keyCode; | ||
23623 | } | ||
23624 | |||
23625 | // add metaKey to non-Mac browsers (use ctrl for PC 's and Meta for Macs) | ||
23626 | if (event.metaKey === undefined) { | ||
23627 | event.metaKey = event.ctrlKey; | ||
23628 | } | ||
23629 | } | ||
23630 | }, { | ||
23631 | reg: /^touch/, | ||
23632 | props: ['touches', 'changedTouches', 'targetTouches'] | ||
23633 | }, { | ||
23634 | reg: /^hashchange$/, | ||
23635 | props: ['newURL', 'oldURL'] | ||
23636 | }, { | ||
23637 | reg: /^gesturechange$/i, | ||
23638 | props: ['rotation', 'scale'] | ||
23639 | }, { | ||
23640 | reg: /^(mousewheel|DOMMouseScroll)$/, | ||
23641 | props: [], | ||
23642 | fix: function fix(event, nativeEvent) { | ||
23643 | var deltaX = undefined; | ||
23644 | var deltaY = undefined; | ||
23645 | var delta = undefined; | ||
23646 | var wheelDelta = nativeEvent.wheelDelta; | ||
23647 | var axis = nativeEvent.axis; | ||
23648 | var wheelDeltaY = nativeEvent.wheelDeltaY; | ||
23649 | var wheelDeltaX = nativeEvent.wheelDeltaX; | ||
23650 | var detail = nativeEvent.detail; | ||
23651 | |||
23652 | // ie/webkit | ||
23653 | if (wheelDelta) { | ||
23654 | delta = wheelDelta / 120; | ||
23655 | } | ||
23656 | |||
23657 | // gecko | ||
23658 | if (detail) { | ||
23659 | // press control e.detail == 1 else e.detail == 3 | ||
23660 | delta = 0 - (detail % 3 === 0 ? detail / 3 : detail); | ||
23661 | } | ||
23662 | |||
23663 | // Gecko | ||
23664 | if (axis !== undefined) { | ||
23665 | if (axis === event.HORIZONTAL_AXIS) { | ||
23666 | deltaY = 0; | ||
23667 | deltaX = 0 - delta; | ||
23668 | } else if (axis === event.VERTICAL_AXIS) { | ||
23669 | deltaX = 0; | ||
23670 | deltaY = delta; | ||
23671 | } | ||
23672 | } | ||
23673 | |||
23674 | // Webkit | ||
23675 | if (wheelDeltaY !== undefined) { | ||
23676 | deltaY = wheelDeltaY / 120; | ||
23677 | } | ||
23678 | if (wheelDeltaX !== undefined) { | ||
23679 | deltaX = -1 * wheelDeltaX / 120; | ||
23680 | } | ||
23681 | |||
23682 | // 默认 deltaY (ie) | ||
23683 | if (!deltaX && !deltaY) { | ||
23684 | deltaY = delta; | ||
23685 | } | ||
23686 | |||
23687 | if (deltaX !== undefined) { | ||
23688 | /** | ||
23689 | * deltaX of mousewheel event | ||
23690 | * @property deltaX | ||
23691 | * @member Event.DomEvent.Object | ||
23692 | */ | ||
23693 | event.deltaX = deltaX; | ||
23694 | } | ||
23695 | |||
23696 | if (deltaY !== undefined) { | ||
23697 | /** | ||
23698 | * deltaY of mousewheel event | ||
23699 | * @property deltaY | ||
23700 | * @member Event.DomEvent.Object | ||
23701 | */ | ||
23702 | event.deltaY = deltaY; | ||
23703 | } | ||
23704 | |||
23705 | if (delta !== undefined) { | ||
23706 | /** | ||
23707 | * delta of mousewheel event | ||
23708 | * @property delta | ||
23709 | * @member Event.DomEvent.Object | ||
23710 | */ | ||
23711 | event.delta = delta; | ||
23712 | } | ||
23713 | } | ||
23714 | }, { | ||
23715 | reg: /^mouse|contextmenu|click|mspointer|(^DOMMouseScroll$)/i, | ||
23716 | props: ['buttons', 'clientX', 'clientY', 'button', 'offsetX', 'relatedTarget', 'which', 'fromElement', 'toElement', 'offsetY', 'pageX', 'pageY', 'screenX', 'screenY'], | ||
23717 | fix: function fix(event, nativeEvent) { | ||
23718 | var eventDoc = undefined; | ||
23719 | var doc = undefined; | ||
23720 | var body = undefined; | ||
23721 | var target = event.target; | ||
23722 | var button = nativeEvent.button; | ||
23723 | |||
23724 | // Calculate pageX/Y if missing and clientX/Y available | ||
23725 | if (target && isNullOrUndefined(event.pageX) && !isNullOrUndefined(nativeEvent.clientX)) { | ||
23726 | eventDoc = target.ownerDocument || document; | ||
23727 | doc = eventDoc.documentElement; | ||
23728 | body = eventDoc.body; | ||
23729 | event.pageX = nativeEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); | ||
23730 | event.pageY = nativeEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); | ||
23731 | } | ||
23732 | |||
23733 | // which for click: 1 === left; 2 === middle; 3 === right | ||
23734 | // do not use button | ||
23735 | if (!event.which && button !== undefined) { | ||
23736 | if (button & 1) { | ||
23737 | event.which = 1; | ||
23738 | } else if (button & 2) { | ||
23739 | event.which = 3; | ||
23740 | } else if (button & 4) { | ||
23741 | event.which = 2; | ||
23742 | } else { | ||
23743 | event.which = 0; | ||
23744 | } | ||
23745 | } | ||
23746 | |||
23747 | // add relatedTarget, if necessary | ||
23748 | if (!event.relatedTarget && event.fromElement) { | ||
23749 | event.relatedTarget = event.fromElement === target ? event.toElement : event.fromElement; | ||
23750 | } | ||
23751 | |||
23752 | return event; | ||
23753 | } | ||
23754 | }]; | ||
23755 | |||
23756 | function retTrue() { | ||
23757 | return TRUE; | ||
23758 | } | ||
23759 | |||
23760 | function retFalse() { | ||
23761 | return FALSE; | ||
23762 | } | ||
23763 | |||
23764 | function DomEventObject(nativeEvent) { | ||
23765 | var type = nativeEvent.type; | ||
23766 | |||
23767 | var isNative = typeof nativeEvent.stopPropagation === 'function' || typeof nativeEvent.cancelBubble === 'boolean'; | ||
23768 | |||
23769 | _EventBaseObject2['default'].call(this); | ||
23770 | |||
23771 | this.nativeEvent = nativeEvent; | ||
23772 | |||
23773 | // in case dom event has been mark as default prevented by lower dom node | ||
23774 | var isDefaultPrevented = retFalse; | ||
23775 | if ('defaultPrevented' in nativeEvent) { | ||
23776 | isDefaultPrevented = nativeEvent.defaultPrevented ? retTrue : retFalse; | ||
23777 | } else if ('getPreventDefault' in nativeEvent) { | ||
23778 | // https://bugzilla.mozilla.org/show_bug.cgi?id=691151 | ||
23779 | isDefaultPrevented = nativeEvent.getPreventDefault() ? retTrue : retFalse; | ||
23780 | } else if ('returnValue' in nativeEvent) { | ||
23781 | isDefaultPrevented = nativeEvent.returnValue === FALSE ? retTrue : retFalse; | ||
23782 | } | ||
23783 | |||
23784 | this.isDefaultPrevented = isDefaultPrevented; | ||
23785 | |||
23786 | var fixFns = []; | ||
23787 | var fixFn = undefined; | ||
23788 | var l = undefined; | ||
23789 | var prop = undefined; | ||
23790 | var props = commonProps.concat(); | ||
23791 | |||
23792 | eventNormalizers.forEach(function (normalizer) { | ||
23793 | if (type.match(normalizer.reg)) { | ||
23794 | props = props.concat(normalizer.props); | ||
23795 | if (normalizer.fix) { | ||
23796 | fixFns.push(normalizer.fix); | ||
23797 | } | ||
23798 | } | ||
23799 | }); | ||
23800 | |||
23801 | l = props.length; | ||
23802 | |||
23803 | // clone properties of the original event object | ||
23804 | while (l) { | ||
23805 | prop = props[--l]; | ||
23806 | this[prop] = nativeEvent[prop]; | ||
23807 | } | ||
23808 | |||
23809 | // fix target property, if necessary | ||
23810 | if (!this.target && isNative) { | ||
23811 | this.target = nativeEvent.srcElement || document; // srcElement might not be defined either | ||
23812 | } | ||
23813 | |||
23814 | // check if target is a text node (safari) | ||
23815 | if (this.target && this.target.nodeType === 3) { | ||
23816 | this.target = this.target.parentNode; | ||
23817 | } | ||
23818 | |||
23819 | l = fixFns.length; | ||
23820 | |||
23821 | while (l) { | ||
23822 | fixFn = fixFns[--l]; | ||
23823 | fixFn(this, nativeEvent); | ||
23824 | } | ||
23825 | |||
23826 | this.timeStamp = nativeEvent.timeStamp || Date.now(); | ||
23827 | } | ||
23828 | |||
23829 | var EventBaseObjectProto = _EventBaseObject2['default'].prototype; | ||
23830 | |||
23831 | (0, _objectAssign2['default'])(DomEventObject.prototype, EventBaseObjectProto, { | ||
23832 | constructor: DomEventObject, | ||
23833 | |||
23834 | preventDefault: function preventDefault() { | ||
23835 | var e = this.nativeEvent; | ||
23836 | |||
23837 | // if preventDefault exists run it on the original event | ||
23838 | if (e.preventDefault) { | ||
23839 | e.preventDefault(); | ||
23840 | } else { | ||
23841 | // otherwise set the returnValue property of the original event to FALSE (IE) | ||
23842 | e.returnValue = FALSE; | ||
23843 | } | ||
23844 | |||
23845 | EventBaseObjectProto.preventDefault.call(this); | ||
23846 | }, | ||
23847 | |||
23848 | stopPropagation: function stopPropagation() { | ||
23849 | var e = this.nativeEvent; | ||
23850 | |||
23851 | // if stopPropagation exists run it on the original event | ||
23852 | if (e.stopPropagation) { | ||
23853 | e.stopPropagation(); | ||
23854 | } else { | ||
23855 | // otherwise set the cancelBubble property of the original event to TRUE (IE) | ||
23856 | e.cancelBubble = TRUE; | ||
23857 | } | ||
23858 | |||
23859 | EventBaseObjectProto.stopPropagation.call(this); | ||
23860 | } | ||
23861 | }); | ||
23862 | |||
23863 | exports['default'] = DomEventObject; | ||
23864 | module.exports = exports['default']; | ||
23865 | |||
23866 | /***/ }, | ||
23867 | /* 184 */ | ||
23868 | /***/ function(module, exports) { | ||
23869 | |||
23870 | /** | ||
23871 | * @ignore | ||
23872 | * base event object for custom and dom event. | ||
23873 | * @author yiminghe@gmail.com | ||
23874 | */ | ||
23875 | |||
23876 | "use strict"; | ||
23877 | |||
23878 | Object.defineProperty(exports, "__esModule", { | ||
23879 | value: true | ||
23880 | }); | ||
23881 | function returnFalse() { | ||
23882 | return false; | ||
23883 | } | ||
23884 | |||
23885 | function returnTrue() { | ||
23886 | return true; | ||
23887 | } | ||
23888 | |||
23889 | function EventBaseObject() { | ||
23890 | this.timeStamp = Date.now(); | ||
23891 | this.target = undefined; | ||
23892 | this.currentTarget = undefined; | ||
23893 | } | ||
23894 | |||
23895 | EventBaseObject.prototype = { | ||
23896 | isEventObject: 1, | ||
23897 | |||
23898 | constructor: EventBaseObject, | ||
23899 | |||
23900 | isDefaultPrevented: returnFalse, | ||
23901 | |||
23902 | isPropagationStopped: returnFalse, | ||
23903 | |||
23904 | isImmediatePropagationStopped: returnFalse, | ||
23905 | |||
23906 | preventDefault: function preventDefault() { | ||
23907 | this.isDefaultPrevented = returnTrue; | ||
23908 | }, | ||
23909 | |||
23910 | stopPropagation: function stopPropagation() { | ||
23911 | this.isPropagationStopped = returnTrue; | ||
23912 | }, | ||
23913 | |||
23914 | stopImmediatePropagation: function stopImmediatePropagation() { | ||
23915 | this.isImmediatePropagationStopped = returnTrue; | ||
23916 | // fixed 1.2 | ||
23917 | // call stopPropagation implicitly | ||
23918 | this.stopPropagation(); | ||
23919 | }, | ||
23920 | |||
23921 | halt: function halt(immediate) { | ||
23922 | if (immediate) { | ||
23923 | this.stopImmediatePropagation(); | ||
23924 | } else { | ||
23925 | this.stopPropagation(); | ||
23926 | } | ||
23927 | this.preventDefault(); | ||
23928 | } | ||
23929 | }; | ||
23930 | |||
23931 | exports["default"] = EventBaseObject; | ||
23932 | module.exports = exports["default"]; | ||
23933 | |||
23934 | /***/ }, | ||
23935 | /* 185 */ | ||
23936 | /***/ function(module, exports) { | ||
23937 | |||
23938 | /* eslint-disable no-unused-vars */ | ||
23939 | 'use strict'; | ||
23940 | var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
23941 | var propIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
23942 | |||
23943 | function toObject(val) { | ||
23944 | if (val === null || val === undefined) { | ||
23945 | throw new TypeError('Object.assign cannot be called with null or undefined'); | ||
23946 | } | ||
23947 | |||
23948 | return Object(val); | ||
23949 | } | ||
23950 | |||
23951 | module.exports = Object.assign || function (target, source) { | ||
23952 | var from; | ||
23953 | var to = toObject(target); | ||
23954 | var symbols; | ||
23955 | |||
23956 | for (var s = 1; s < arguments.length; s++) { | ||
23957 | from = Object(arguments[s]); | ||
23958 | |||
23959 | for (var key in from) { | ||
23960 | if (hasOwnProperty.call(from, key)) { | ||
23961 | to[key] = from[key]; | ||
23962 | } | ||
23963 | } | ||
23964 | |||
23965 | if (Object.getOwnPropertySymbols) { | ||
23966 | symbols = Object.getOwnPropertySymbols(from); | ||
23967 | for (var i = 0; i < symbols.length; i++) { | ||
23968 | if (propIsEnumerable.call(from, symbols[i])) { | ||
23969 | to[symbols[i]] = from[symbols[i]]; | ||
23970 | } | ||
23971 | } | ||
23972 | } | ||
23973 | } | ||
23974 | |||
23975 | return to; | ||
23976 | }; | ||
23977 | |||
23978 | |||
23979 | /***/ }, | ||
23980 | /* 186 */ | ||
23981 | /***/ function(module, exports) { | ||
23982 | |||
23983 | "use strict"; | ||
23984 | |||
23985 | module.exports = function contains(root, n) { | ||
23986 | var node = n; | ||
23987 | while (node) { | ||
23988 | if (node === root) { | ||
23989 | return true; | ||
23990 | } | ||
23991 | node = node.parentNode; | ||
23992 | } | ||
23993 | |||
23994 | return false; | ||
23995 | }; | ||
23996 | |||
23997 | /***/ }, | ||
23998 | /* 187 */ | ||
23999 | /***/ function(module, exports, __webpack_require__) { | ||
24000 | |||
24001 | 'use strict'; | ||
24002 | |||
24003 | var React = __webpack_require__(3); | ||
24004 | |||
24005 | module.exports = function toArray(children) { | ||
24006 | var ret = []; | ||
24007 | React.Children.forEach(children, function each(c) { | ||
24008 | ret.push(c); | ||
24009 | }); | ||
24010 | return ret; | ||
24011 | }; | ||
24012 | |||
24013 | /***/ }, | ||
24014 | /* 188 */ | ||
24015 | /***/ function(module, exports, __webpack_require__) { | ||
24016 | |||
24017 | 'use strict'; | ||
24018 | |||
24019 | var React = __webpack_require__(3); | ||
24020 | |||
24021 | function mirror(o) { | ||
24022 | return o; | ||
24023 | } | ||
24024 | |||
24025 | module.exports = function mapSelf(children) { | ||
24026 | // return ReactFragment | ||
24027 | return React.Children.map(children, mirror); | ||
24028 | }; | ||
24029 | |||
24030 | /***/ }, | ||
24031 | /* 189 */ | ||
24032 | /***/ function(module, exports, __webpack_require__) { | ||
24033 | |||
24034 | 'use strict'; | ||
24035 | |||
24036 | Object.defineProperty(exports, '__esModule', { | ||
24037 | value: true | ||
24038 | }); | ||
24039 | |||
24040 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
24041 | |||
24042 | var _react = __webpack_require__(3); | ||
24043 | |||
24044 | var _react2 = _interopRequireDefault(_react); | ||
24045 | |||
24046 | var _reactDom = __webpack_require__(160); | ||
24047 | |||
24048 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
24049 | |||
24050 | var _rcAlign = __webpack_require__(190); | ||
24051 | |||
24052 | var _rcAlign2 = _interopRequireDefault(_rcAlign); | ||
24053 | |||
24054 | var _rcAnimate = __webpack_require__(201); | ||
24055 | |||
24056 | var _rcAnimate2 = _interopRequireDefault(_rcAnimate); | ||
24057 | |||
24058 | var _PopupInner = __webpack_require__(209); | ||
24059 | |||
24060 | var _PopupInner2 = _interopRequireDefault(_PopupInner); | ||
24061 | |||
24062 | var Popup = _react2['default'].createClass({ | ||
24063 | displayName: 'Popup', | ||
24064 | |||
24065 | propTypes: { | ||
24066 | visible: _react.PropTypes.bool, | ||
24067 | wrap: _react.PropTypes.object, | ||
24068 | style: _react.PropTypes.object, | ||
24069 | getClassNameFromAlign: _react.PropTypes.func, | ||
24070 | onMouseEnter: _react.PropTypes.func, | ||
24071 | className: _react.PropTypes.string, | ||
24072 | onMouseLeave: _react.PropTypes.func | ||
24073 | }, | ||
24074 | |||
24075 | componentDidMount: function componentDidMount() { | ||
24076 | this.rootNode = this.getPopupDomNode(); | ||
24077 | }, | ||
24078 | |||
24079 | onAlign: function onAlign(popupDomNode, align) { | ||
24080 | var props = this.props; | ||
24081 | var alignClassName = props.getClassNameFromAlign(props.align); | ||
24082 | var currentAlignClassName = props.getClassNameFromAlign(align); | ||
24083 | if (alignClassName !== currentAlignClassName) { | ||
24084 | this.currentAlignClassName = currentAlignClassName; | ||
24085 | popupDomNode.className = this.getClassName(currentAlignClassName); | ||
24086 | } | ||
24087 | }, | ||
24088 | |||
24089 | getPopupDomNode: function getPopupDomNode() { | ||
24090 | return _reactDom2['default'].findDOMNode(this); | ||
24091 | }, | ||
24092 | |||
24093 | getTarget: function getTarget() { | ||
24094 | return _reactDom2['default'].findDOMNode(this.props.wrap); | ||
24095 | }, | ||
24096 | |||
24097 | getTransitionName: function getTransitionName() { | ||
24098 | var props = this.props; | ||
24099 | var transitionName = props.transitionName; | ||
24100 | if (!transitionName && props.animation) { | ||
24101 | transitionName = props.prefixCls + '-' + props.animation; | ||
24102 | } | ||
24103 | return transitionName; | ||
24104 | }, | ||
24105 | |||
24106 | getClassName: function getClassName(currentAlignClassName) { | ||
24107 | var props = this.props; | ||
24108 | var prefixCls = props.prefixCls; | ||
24109 | |||
24110 | var className = prefixCls + ' ' + props.className + ' '; | ||
24111 | className += currentAlignClassName; | ||
24112 | return className; | ||
24113 | }, | ||
24114 | |||
24115 | render: function render() { | ||
24116 | var props = this.props; | ||
24117 | var align = props.align; | ||
24118 | var style = props.style; | ||
24119 | var visible = props.visible; | ||
24120 | var prefixCls = props.prefixCls; | ||
24121 | var destroyPopupOnHide = props.destroyPopupOnHide; | ||
24122 | |||
24123 | var className = this.getClassName(this.currentAlignClassName || props.getClassNameFromAlign(align)); | ||
24124 | var hiddenClassName = prefixCls + '-hidden'; | ||
24125 | if (!visible) { | ||
24126 | this.currentAlignClassName = null; | ||
24127 | } | ||
24128 | if (destroyPopupOnHide) { | ||
24129 | return _react2['default'].createElement( | ||
24130 | _rcAnimate2['default'], | ||
24131 | { component: '', | ||
24132 | exclusive: true, | ||
24133 | transitionAppear: true, | ||
24134 | transitionName: this.getTransitionName() }, | ||
24135 | visible ? _react2['default'].createElement( | ||
24136 | _rcAlign2['default'], | ||
24137 | { target: this.getTarget, | ||
24138 | key: 'popup', | ||
24139 | monitorWindowResize: true, | ||
24140 | align: align, | ||
24141 | onAlign: this.onAlign }, | ||
24142 | _react2['default'].createElement( | ||
24143 | _PopupInner2['default'], | ||
24144 | { className: className, | ||
24145 | visible: true, | ||
24146 | onMouseEnter: props.onMouseEnter, | ||
24147 | onMouseLeave: props.onMouseLeave, | ||
24148 | style: style }, | ||
24149 | props.children | ||
24150 | ) | ||
24151 | ) : null | ||
24152 | ); | ||
24153 | } | ||
24154 | return _react2['default'].createElement( | ||
24155 | _rcAnimate2['default'], | ||
24156 | { component: '', | ||
24157 | exclusive: true, | ||
24158 | transitionAppear: true, | ||
24159 | transitionName: this.getTransitionName(), | ||
24160 | showProp: 'xVisible' }, | ||
24161 | _react2['default'].createElement( | ||
24162 | _rcAlign2['default'], | ||
24163 | { target: this.getTarget, | ||
24164 | key: 'popup', | ||
24165 | monitorWindowResize: true, | ||
24166 | xVisible: visible, | ||
24167 | childrenProps: { | ||
24168 | visible: 'xVisible' | ||
24169 | }, | ||
24170 | disabled: !visible, | ||
24171 | align: align, | ||
24172 | onAlign: this.onAlign }, | ||
24173 | _react2['default'].createElement( | ||
24174 | _PopupInner2['default'], | ||
24175 | { className: className, | ||
24176 | hiddenClassName: hiddenClassName, | ||
24177 | onMouseEnter: props.onMouseEnter, | ||
24178 | onMouseLeave: props.onMouseLeave, | ||
24179 | style: style }, | ||
24180 | props.children | ||
24181 | ) | ||
24182 | ) | ||
24183 | ); | ||
24184 | } | ||
24185 | }); | ||
24186 | |||
24187 | exports['default'] = Popup; | ||
24188 | module.exports = exports['default']; | ||
24189 | |||
24190 | /***/ }, | ||
24191 | /* 190 */ | ||
24192 | /***/ function(module, exports, __webpack_require__) { | ||
24193 | |||
24194 | // export this package's api | ||
24195 | 'use strict'; | ||
24196 | |||
24197 | Object.defineProperty(exports, '__esModule', { | ||
24198 | value: true | ||
24199 | }); | ||
24200 | |||
24201 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
24202 | |||
24203 | var _Align = __webpack_require__(191); | ||
24204 | |||
24205 | var _Align2 = _interopRequireDefault(_Align); | ||
24206 | |||
24207 | exports['default'] = _Align2['default']; | ||
24208 | module.exports = exports['default']; | ||
24209 | |||
24210 | /***/ }, | ||
24211 | /* 191 */ | ||
24212 | /***/ function(module, exports, __webpack_require__) { | ||
24213 | |||
24214 | 'use strict'; | ||
24215 | |||
24216 | Object.defineProperty(exports, '__esModule', { | ||
24217 | value: true | ||
24218 | }); | ||
24219 | |||
24220 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
24221 | |||
24222 | var _react = __webpack_require__(3); | ||
24223 | |||
24224 | var _react2 = _interopRequireDefault(_react); | ||
24225 | |||
24226 | var _reactDom = __webpack_require__(160); | ||
24227 | |||
24228 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
24229 | |||
24230 | var _domAlign = __webpack_require__(192); | ||
24231 | |||
24232 | var _domAlign2 = _interopRequireDefault(_domAlign); | ||
24233 | |||
24234 | var _rcUtil = __webpack_require__(172); | ||
24235 | |||
24236 | var _isWindow = __webpack_require__(200); | ||
24237 | |||
24238 | var _isWindow2 = _interopRequireDefault(_isWindow); | ||
24239 | |||
24240 | function buffer(fn, ms) { | ||
24241 | var timer = undefined; | ||
24242 | return function bufferFn() { | ||
24243 | if (timer) { | ||
24244 | clearTimeout(timer); | ||
24245 | } | ||
24246 | timer = setTimeout(fn, ms); | ||
24247 | }; | ||
24248 | } | ||
24249 | |||
24250 | var Align = _react2['default'].createClass({ | ||
24251 | displayName: 'Align', | ||
24252 | |||
24253 | propTypes: { | ||
24254 | childrenProps: _react.PropTypes.object, | ||
24255 | align: _react.PropTypes.object.isRequired, | ||
24256 | target: _react.PropTypes.func, | ||
24257 | onAlign: _react.PropTypes.func, | ||
24258 | monitorBufferTime: _react.PropTypes.number, | ||
24259 | monitorWindowResize: _react.PropTypes.bool, | ||
24260 | disabled: _react.PropTypes.bool, | ||
24261 | children: _react.PropTypes.any | ||
24262 | }, | ||
24263 | |||
24264 | getDefaultProps: function getDefaultProps() { | ||
24265 | return { | ||
24266 | target: function target() { | ||
24267 | return window; | ||
24268 | }, | ||
24269 | onAlign: function onAlign() {}, | ||
24270 | monitorBufferTime: 50, | ||
24271 | monitorWindowResize: false, | ||
24272 | disabled: false | ||
24273 | }; | ||
24274 | }, | ||
24275 | |||
24276 | componentDidMount: function componentDidMount() { | ||
24277 | var props = this.props; | ||
24278 | // if parent ref not attached .... use document.getElementById | ||
24279 | if (!props.disabled) { | ||
24280 | var source = _reactDom2['default'].findDOMNode(this); | ||
24281 | props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); | ||
24282 | if (props.monitorWindowResize) { | ||
24283 | this.startMonitorWindowResize(); | ||
24284 | } | ||
24285 | } | ||
24286 | }, | ||
24287 | |||
24288 | componentDidUpdate: function componentDidUpdate(prevProps) { | ||
24289 | var reAlign = false; | ||
24290 | var props = this.props; | ||
24291 | var currentTarget = undefined; | ||
24292 | |||
24293 | if (!props.disabled) { | ||
24294 | if (prevProps.disabled || prevProps.align !== props.align) { | ||
24295 | reAlign = true; | ||
24296 | currentTarget = props.target(); | ||
24297 | } else { | ||
24298 | var lastTarget = prevProps.target(); | ||
24299 | currentTarget = props.target(); | ||
24300 | if ((0, _isWindow2['default'])(lastTarget) && (0, _isWindow2['default'])(currentTarget)) { | ||
24301 | reAlign = false; | ||
24302 | } else if (lastTarget !== currentTarget) { | ||
24303 | reAlign = true; | ||
24304 | } | ||
24305 | } | ||
24306 | } | ||
24307 | |||
24308 | if (reAlign) { | ||
24309 | var source = _reactDom2['default'].findDOMNode(this); | ||
24310 | props.onAlign(source, (0, _domAlign2['default'])(source, currentTarget, props.align)); | ||
24311 | } | ||
24312 | |||
24313 | if (props.monitorWindowResize && !props.disabled) { | ||
24314 | this.startMonitorWindowResize(); | ||
24315 | } else { | ||
24316 | this.stopMonitorWindowResize(); | ||
24317 | } | ||
24318 | }, | ||
24319 | |||
24320 | componentWillUnmount: function componentWillUnmount() { | ||
24321 | this.stopMonitorWindowResize(); | ||
24322 | }, | ||
24323 | |||
24324 | onWindowResize: function onWindowResize() { | ||
24325 | var props = this.props; | ||
24326 | if (!props.disabled) { | ||
24327 | var source = _reactDom2['default'].findDOMNode(this); | ||
24328 | props.onAlign(source, (0, _domAlign2['default'])(source, props.target(), props.align)); | ||
24329 | } | ||
24330 | }, | ||
24331 | |||
24332 | startMonitorWindowResize: function startMonitorWindowResize() { | ||
24333 | if (!this.resizeHandler) { | ||
24334 | this.resizeHandler = _rcUtil.Dom.addEventListener(window, 'resize', buffer(this.onWindowResize, this.props.monitorBufferTime)); | ||
24335 | } | ||
24336 | }, | ||
24337 | |||
24338 | stopMonitorWindowResize: function stopMonitorWindowResize() { | ||
24339 | if (this.resizeHandler) { | ||
24340 | this.resizeHandler.remove(); | ||
24341 | this.resizeHandler = null; | ||
24342 | } | ||
24343 | }, | ||
24344 | |||
24345 | render: function render() { | ||
24346 | var _props = this.props; | ||
24347 | var childrenProps = _props.childrenProps; | ||
24348 | var children = _props.children; | ||
24349 | |||
24350 | var child = _react2['default'].Children.only(children); | ||
24351 | if (childrenProps) { | ||
24352 | var newProps = {}; | ||
24353 | for (var prop in childrenProps) { | ||
24354 | if (childrenProps.hasOwnProperty(prop)) { | ||
24355 | newProps[prop] = this.props[childrenProps[prop]]; | ||
24356 | } | ||
24357 | } | ||
24358 | return _react2['default'].cloneElement(child, newProps); | ||
24359 | } | ||
24360 | return child; | ||
24361 | } | ||
24362 | }); | ||
24363 | |||
24364 | exports['default'] = Align; | ||
24365 | module.exports = exports['default']; | ||
24366 | |||
24367 | /***/ }, | ||
24368 | /* 192 */ | ||
24369 | /***/ function(module, exports, __webpack_require__) { | ||
24370 | |||
24371 | /** | ||
24372 | * align dom node flexibly | ||
24373 | * @author yiminghe@gmail.com | ||
24374 | */ | ||
24375 | |||
24376 | 'use strict'; | ||
24377 | |||
24378 | Object.defineProperty(exports, '__esModule', { | ||
24379 | value: true | ||
24380 | }); | ||
24381 | |||
24382 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
24383 | |||
24384 | var _utils = __webpack_require__(193); | ||
24385 | |||
24386 | var _utils2 = _interopRequireDefault(_utils); | ||
24387 | |||
24388 | var _getOffsetParent = __webpack_require__(194); | ||
24389 | |||
24390 | var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); | ||
24391 | |||
24392 | var _getVisibleRectForElement = __webpack_require__(195); | ||
24393 | |||
24394 | var _getVisibleRectForElement2 = _interopRequireDefault(_getVisibleRectForElement); | ||
24395 | |||
24396 | var _adjustForViewport = __webpack_require__(196); | ||
24397 | |||
24398 | var _adjustForViewport2 = _interopRequireDefault(_adjustForViewport); | ||
24399 | |||
24400 | var _getRegion = __webpack_require__(197); | ||
24401 | |||
24402 | var _getRegion2 = _interopRequireDefault(_getRegion); | ||
24403 | |||
24404 | var _getElFuturePos = __webpack_require__(198); | ||
24405 | |||
24406 | var _getElFuturePos2 = _interopRequireDefault(_getElFuturePos); | ||
24407 | |||
24408 | // http://yiminghe.iteye.com/blog/1124720 | ||
24409 | |||
24410 | function isFailX(elFuturePos, elRegion, visibleRect) { | ||
24411 | return elFuturePos.left < visibleRect.left || elFuturePos.left + elRegion.width > visibleRect.right; | ||
24412 | } | ||
24413 | |||
24414 | function isFailY(elFuturePos, elRegion, visibleRect) { | ||
24415 | return elFuturePos.top < visibleRect.top || elFuturePos.top + elRegion.height > visibleRect.bottom; | ||
24416 | } | ||
24417 | |||
24418 | function flip(points, reg, map) { | ||
24419 | var ret = []; | ||
24420 | _utils2['default'].each(points, function (p) { | ||
24421 | ret.push(p.replace(reg, function (m) { | ||
24422 | return map[m]; | ||
24423 | })); | ||
24424 | }); | ||
24425 | return ret; | ||
24426 | } | ||
24427 | |||
24428 | function flipOffset(offset, index) { | ||
24429 | offset[index] = -offset[index]; | ||
24430 | return offset; | ||
24431 | } | ||
24432 | |||
24433 | function convertOffset(str, offsetLen) { | ||
24434 | var n = undefined; | ||
24435 | if (/%$/.test(str)) { | ||
24436 | n = parseInt(str.substring(0, str.length - 1), 10) / 100 * offsetLen; | ||
24437 | } else { | ||
24438 | n = parseInt(str, 10); | ||
24439 | } | ||
24440 | return n || 0; | ||
24441 | } | ||
24442 | |||
24443 | function normalizeOffset(offset, el) { | ||
24444 | offset[0] = convertOffset(offset[0], el.width); | ||
24445 | offset[1] = convertOffset(offset[1], el.height); | ||
24446 | } | ||
24447 | |||
24448 | /* | ||
24449 | * align node | ||
24450 | * @param {Element} node current dom node | ||
24451 | * @param {Object} align align config | ||
24452 | * | ||
24453 | * @example | ||
24454 | * { | ||
24455 | * node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 | ||
24456 | * points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tr 与参考节点的 tl 对齐 | ||
24457 | * offset: [0, 0] // 有效值为 [n, m] | ||
24458 | * } | ||
24459 | */ | ||
24460 | function domAlign(el, refNode, align) { | ||
24461 | var points = align.points; | ||
24462 | var offset = align.offset || [0, 0]; | ||
24463 | var targetOffset = align.targetOffset || [0, 0]; | ||
24464 | var overflow = align.overflow; | ||
24465 | offset = [].concat(offset); | ||
24466 | targetOffset = [].concat(targetOffset); | ||
24467 | overflow = overflow || {}; | ||
24468 | var newOverflowCfg = {}; | ||
24469 | |||
24470 | var fail = 0; | ||
24471 | // 当前节点可以被放置的显示区域 | ||
24472 | var visibleRect = (0, _getVisibleRectForElement2['default'])(el); | ||
24473 | // 当前节点所占的区域, left/top/width/height | ||
24474 | var elRegion = (0, _getRegion2['default'])(el); | ||
24475 | // 参照节点所占的区域, left/top/width/height | ||
24476 | var refNodeRegion = (0, _getRegion2['default'])(refNode); | ||
24477 | // 将 offset 转换成数值,支持百分比 | ||
24478 | normalizeOffset(offset, elRegion); | ||
24479 | normalizeOffset(targetOffset, refNodeRegion); | ||
24480 | // 当前节点将要被放置的位置 | ||
24481 | var elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); | ||
24482 | // 当前节点将要所处的区域 | ||
24483 | var newElRegion = _utils2['default'].merge(elRegion, elFuturePos); | ||
24484 | |||
24485 | // 如果可视区域不能完全放置当前节点时允许调整 | ||
24486 | if (visibleRect && (overflow.adjustX || overflow.adjustY)) { | ||
24487 | if (overflow.adjustX) { | ||
24488 | // 如果横向不能放下 | ||
24489 | if (isFailX(elFuturePos, elRegion, visibleRect)) { | ||
24490 | fail = 1; | ||
24491 | // 对齐位置反下 | ||
24492 | points = flip(points, /[lr]/ig, { | ||
24493 | l: 'r', | ||
24494 | r: 'l' | ||
24495 | }); | ||
24496 | // 偏移量也反下 | ||
24497 | offset = flipOffset(offset, 0); | ||
24498 | targetOffset = flipOffset(targetOffset, 0); | ||
24499 | } | ||
24500 | } | ||
24501 | |||
24502 | if (overflow.adjustY) { | ||
24503 | // 如果纵向不能放下 | ||
24504 | if (isFailY(elFuturePos, elRegion, visibleRect)) { | ||
24505 | fail = 1; | ||
24506 | // 对齐位置反下 | ||
24507 | points = flip(points, /[tb]/ig, { | ||
24508 | t: 'b', | ||
24509 | b: 't' | ||
24510 | }); | ||
24511 | // 偏移量也反下 | ||
24512 | offset = flipOffset(offset, 1); | ||
24513 | targetOffset = flipOffset(targetOffset, 1); | ||
24514 | } | ||
24515 | } | ||
24516 | |||
24517 | // 如果失败,重新计算当前节点将要被放置的位置 | ||
24518 | if (fail) { | ||
24519 | elFuturePos = (0, _getElFuturePos2['default'])(elRegion, refNodeRegion, points, offset, targetOffset); | ||
24520 | _utils2['default'].mix(newElRegion, elFuturePos); | ||
24521 | } | ||
24522 | |||
24523 | // 检查反下后的位置是否可以放下了 | ||
24524 | // 如果仍然放不下只有指定了可以调整当前方向才调整 | ||
24525 | newOverflowCfg.adjustX = overflow.adjustX && isFailX(elFuturePos, elRegion, visibleRect); | ||
24526 | |||
24527 | newOverflowCfg.adjustY = overflow.adjustY && isFailY(elFuturePos, elRegion, visibleRect); | ||
24528 | |||
24529 | // 确实要调整,甚至可能会调整高度宽度 | ||
24530 | if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) { | ||
24531 | newElRegion = (0, _adjustForViewport2['default'])(elFuturePos, elRegion, visibleRect, newOverflowCfg); | ||
24532 | } | ||
24533 | } | ||
24534 | |||
24535 | // need judge to in case set fixed with in css on height auto element | ||
24536 | if (newElRegion.width !== elRegion.width) { | ||
24537 | _utils2['default'].css(el, 'width', el.width() + newElRegion.width - elRegion.width); | ||
24538 | } | ||
24539 | |||
24540 | if (newElRegion.height !== elRegion.height) { | ||
24541 | _utils2['default'].css(el, 'height', el.height() + newElRegion.height - elRegion.height); | ||
24542 | } | ||
24543 | |||
24544 | // https://github.com/kissyteam/kissy/issues/190 | ||
24545 | // http://localhost:8888/kissy/src/overlay/demo/other/relative_align/align.html | ||
24546 | // 相对于屏幕位置没变,而 left/top 变了 | ||
24547 | // 例如 <div 'relative'><el absolute></div> | ||
24548 | _utils2['default'].offset(el, { | ||
24549 | left: newElRegion.left, | ||
24550 | top: newElRegion.top | ||
24551 | }, { | ||
24552 | useCssRight: align.useCssRight, | ||
24553 | useCssBottom: align.useCssBottom | ||
24554 | }); | ||
24555 | |||
24556 | return { | ||
24557 | points: points, | ||
24558 | offset: offset, | ||
24559 | targetOffset: targetOffset, | ||
24560 | overflow: newOverflowCfg | ||
24561 | }; | ||
24562 | } | ||
24563 | |||
24564 | domAlign.__getOffsetParent = _getOffsetParent2['default']; | ||
24565 | |||
24566 | domAlign.__getVisibleRectForElement = _getVisibleRectForElement2['default']; | ||
24567 | |||
24568 | exports['default'] = domAlign; | ||
24569 | |||
24570 | /** | ||
24571 | * 2012-04-26 yiminghe@gmail.com | ||
24572 | * - 优化智能对齐算法 | ||
24573 | * - 慎用 resizeXX | ||
24574 | * | ||
24575 | * 2011-07-13 yiminghe@gmail.com note: | ||
24576 | * - 增加智能对齐,以及大小调整选项 | ||
24577 | **/ | ||
24578 | module.exports = exports['default']; | ||
24579 | |||
24580 | /***/ }, | ||
24581 | /* 193 */ | ||
24582 | /***/ function(module, exports) { | ||
24583 | |||
24584 | 'use strict'; | ||
24585 | |||
24586 | Object.defineProperty(exports, '__esModule', { | ||
24587 | value: true | ||
24588 | }); | ||
24589 | var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; | ||
24590 | |||
24591 | var getComputedStyleX = undefined; | ||
24592 | |||
24593 | function css(el, name, v) { | ||
24594 | var value = v; | ||
24595 | if (typeof name === 'object') { | ||
24596 | for (var i in name) { | ||
24597 | if (name.hasOwnProperty(i)) { | ||
24598 | css(el, i, name[i]); | ||
24599 | } | ||
24600 | } | ||
24601 | return undefined; | ||
24602 | } | ||
24603 | if (typeof value !== 'undefined') { | ||
24604 | if (typeof value === 'number') { | ||
24605 | value = value + 'px'; | ||
24606 | } | ||
24607 | el.style[name] = value; | ||
24608 | return undefined; | ||
24609 | } | ||
24610 | return getComputedStyleX(el, name); | ||
24611 | } | ||
24612 | |||
24613 | function getClientPosition(elem) { | ||
24614 | var box = undefined; | ||
24615 | var x = undefined; | ||
24616 | var y = undefined; | ||
24617 | var doc = elem.ownerDocument; | ||
24618 | var body = doc.body; | ||
24619 | var docElem = doc && doc.documentElement; | ||
24620 | // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 | ||
24621 | box = elem.getBoundingClientRect(); | ||
24622 | |||
24623 | // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop | ||
24624 | // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 | ||
24625 | // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin | ||
24626 | |||
24627 | x = box.left; | ||
24628 | y = box.top; | ||
24629 | |||
24630 | // In IE, most of the time, 2 extra pixels are added to the top and left | ||
24631 | // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and | ||
24632 | // IE6 standards mode, this border can be overridden by setting the | ||
24633 | // document element's border to zero -- thus, we cannot rely on the | ||
24634 | // offset always being 2 pixels. | ||
24635 | |||
24636 | // In quirks mode, the offset can be determined by querying the body's | ||
24637 | // clientLeft/clientTop, but in standards mode, it is found by querying | ||
24638 | // the document element's clientLeft/clientTop. Since we already called | ||
24639 | // getClientBoundingRect we have already forced a reflow, so it is not | ||
24640 | // too expensive just to query them all. | ||
24641 | |||
24642 | // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 | ||
24643 | // 窗口边框标准是设 documentElement ,quirks 时设置 body | ||
24644 | // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 | ||
24645 | // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 | ||
24646 | // 标准 ie 下 docElem.clientTop 就是 border-top | ||
24647 | // ie7 html 即窗口边框改变不了。永远为 2 | ||
24648 | // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 | ||
24649 | |||
24650 | x -= docElem.clientLeft || body.clientLeft || 0; | ||
24651 | y -= docElem.clientTop || body.clientTop || 0; | ||
24652 | |||
24653 | return { left: x, top: y }; | ||
24654 | } | ||
24655 | |||
24656 | function getScroll(w, top) { | ||
24657 | var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; | ||
24658 | var method = 'scroll' + (top ? 'Top' : 'Left'); | ||
24659 | if (typeof ret !== 'number') { | ||
24660 | var d = w.document; | ||
24661 | // ie6,7,8 standard mode | ||
24662 | ret = d.documentElement[method]; | ||
24663 | if (typeof ret !== 'number') { | ||
24664 | // quirks mode | ||
24665 | ret = d.body[method]; | ||
24666 | } | ||
24667 | } | ||
24668 | return ret; | ||
24669 | } | ||
24670 | |||
24671 | function getScrollLeft(w) { | ||
24672 | return getScroll(w); | ||
24673 | } | ||
24674 | |||
24675 | function getScrollTop(w) { | ||
24676 | return getScroll(w, true); | ||
24677 | } | ||
24678 | |||
24679 | function getOffset(el) { | ||
24680 | var pos = getClientPosition(el); | ||
24681 | var doc = el.ownerDocument; | ||
24682 | var w = doc.defaultView || doc.parentWindow; | ||
24683 | pos.left += getScrollLeft(w); | ||
24684 | pos.top += getScrollTop(w); | ||
24685 | return pos; | ||
24686 | } | ||
24687 | function _getComputedStyle(elem, name, cs) { | ||
24688 | var computedStyle = cs; | ||
24689 | var val = ''; | ||
24690 | var d = elem.ownerDocument; | ||
24691 | computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null); | ||
24692 | |||
24693 | // https://github.com/kissyteam/kissy/issues/61 | ||
24694 | if (computedStyle) { | ||
24695 | val = computedStyle.getPropertyValue(name) || computedStyle[name]; | ||
24696 | } | ||
24697 | |||
24698 | return val; | ||
24699 | } | ||
24700 | |||
24701 | var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); | ||
24702 | var RE_POS = /^(top|right|bottom|left)$/; | ||
24703 | var CURRENT_STYLE = 'currentStyle'; | ||
24704 | var RUNTIME_STYLE = 'runtimeStyle'; | ||
24705 | var LEFT = 'left'; | ||
24706 | var PX = 'px'; | ||
24707 | |||
24708 | function _getComputedStyleIE(elem, name) { | ||
24709 | // currentStyle maybe null | ||
24710 | // http://msdn.microsoft.com/en-us/library/ms535231.aspx | ||
24711 | var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; | ||
24712 | |||
24713 | // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 | ||
24714 | // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 | ||
24715 | // 在 ie 下不对,需要直接用 offset 方式 | ||
24716 | // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 | ||
24717 | |||
24718 | // From the awesome hack by Dean Edwards | ||
24719 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 | ||
24720 | // If we're not dealing with a regular pixel number | ||
24721 | // but a number that has a weird ending, we need to convert it to pixels | ||
24722 | // exclude left right for relativity | ||
24723 | if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { | ||
24724 | // Remember the original values | ||
24725 | var style = elem.style; | ||
24726 | var left = style[LEFT]; | ||
24727 | var rsLeft = elem[RUNTIME_STYLE][LEFT]; | ||
24728 | |||
24729 | // prevent flashing of content | ||
24730 | elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; | ||
24731 | |||
24732 | // Put in the new values to get a computed value out | ||
24733 | style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; | ||
24734 | ret = style.pixelLeft + PX; | ||
24735 | |||
24736 | // Revert the changed values | ||
24737 | style[LEFT] = left; | ||
24738 | |||
24739 | elem[RUNTIME_STYLE][LEFT] = rsLeft; | ||
24740 | } | ||
24741 | return ret === '' ? 'auto' : ret; | ||
24742 | } | ||
24743 | |||
24744 | if (typeof window !== 'undefined') { | ||
24745 | getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; | ||
24746 | } | ||
24747 | |||
24748 | function getOffsetDirection(dir, option) { | ||
24749 | if (dir === 'left') { | ||
24750 | return option.useCssRight ? 'right' : dir; | ||
24751 | } | ||
24752 | return option.useCssBottom ? 'bottom' : dir; | ||
24753 | } | ||
24754 | |||
24755 | function oppositeOffsetDirection(dir) { | ||
24756 | if (dir === 'left') { | ||
24757 | return 'right'; | ||
24758 | } else if (dir === 'right') { | ||
24759 | return 'left'; | ||
24760 | } else if (dir === 'top') { | ||
24761 | return 'bottom'; | ||
24762 | } else if (dir === 'bottom') { | ||
24763 | return 'top'; | ||
24764 | } | ||
24765 | } | ||
24766 | |||
24767 | // 设置 elem 相对 elem.ownerDocument 的坐标 | ||
24768 | function setOffset(elem, offset, option) { | ||
24769 | // set position first, in-case top/left are set even on static elem | ||
24770 | if (css(elem, 'position') === 'static') { | ||
24771 | elem.style.position = 'relative'; | ||
24772 | } | ||
24773 | var presetH = -999; | ||
24774 | var presetV = -999; | ||
24775 | var horizontalProperty = getOffsetDirection('left', option); | ||
24776 | var verticalProperty = getOffsetDirection('top', option); | ||
24777 | var oppositeHorizontalProperty = oppositeOffsetDirection(horizontalProperty); | ||
24778 | var oppositeVerticalProperty = oppositeOffsetDirection(verticalProperty); | ||
24779 | |||
24780 | if (horizontalProperty !== 'left') { | ||
24781 | presetH = 999; | ||
24782 | } | ||
24783 | |||
24784 | if (verticalProperty !== 'top') { | ||
24785 | presetV = 999; | ||
24786 | } | ||
24787 | |||
24788 | if ('left' in offset) { | ||
24789 | elem.style[oppositeHorizontalProperty] = ''; | ||
24790 | elem.style[horizontalProperty] = presetH + 'px'; | ||
24791 | } | ||
24792 | if ('top' in offset) { | ||
24793 | elem.style[oppositeVerticalProperty] = ''; | ||
24794 | elem.style[verticalProperty] = presetV + 'px'; | ||
24795 | } | ||
24796 | var old = getOffset(elem); | ||
24797 | var ret = {}; | ||
24798 | var key = undefined; | ||
24799 | for (key in offset) { | ||
24800 | if (offset.hasOwnProperty(key)) { | ||
24801 | var dir = getOffsetDirection(key, option); | ||
24802 | var preset = key === 'left' ? presetH : presetV; | ||
24803 | if (dir === key) { | ||
24804 | ret[dir] = preset + offset[key] - old[key]; | ||
24805 | } else { | ||
24806 | ret[dir] = preset + old[key] - offset[key]; | ||
24807 | } | ||
24808 | } | ||
24809 | } | ||
24810 | css(elem, ret); | ||
24811 | } | ||
24812 | |||
24813 | function each(arr, fn) { | ||
24814 | for (var i = 0; i < arr.length; i++) { | ||
24815 | fn(arr[i]); | ||
24816 | } | ||
24817 | } | ||
24818 | |||
24819 | function isBorderBoxFn(elem) { | ||
24820 | return getComputedStyleX(elem, 'boxSizing') === 'border-box'; | ||
24821 | } | ||
24822 | |||
24823 | var BOX_MODELS = ['margin', 'border', 'padding']; | ||
24824 | var CONTENT_INDEX = -1; | ||
24825 | var PADDING_INDEX = 2; | ||
24826 | var BORDER_INDEX = 1; | ||
24827 | var MARGIN_INDEX = 0; | ||
24828 | |||
24829 | function swap(elem, options, callback) { | ||
24830 | var old = {}; | ||
24831 | var style = elem.style; | ||
24832 | var name = undefined; | ||
24833 | |||
24834 | // Remember the old values, and insert the new ones | ||
24835 | for (name in options) { | ||
24836 | if (options.hasOwnProperty(name)) { | ||
24837 | old[name] = style[name]; | ||
24838 | style[name] = options[name]; | ||
24839 | } | ||
24840 | } | ||
24841 | |||
24842 | callback.call(elem); | ||
24843 | |||
24844 | // Revert the old values | ||
24845 | for (name in options) { | ||
24846 | if (options.hasOwnProperty(name)) { | ||
24847 | style[name] = old[name]; | ||
24848 | } | ||
24849 | } | ||
24850 | } | ||
24851 | |||
24852 | function getPBMWidth(elem, props, which) { | ||
24853 | var value = 0; | ||
24854 | var prop = undefined; | ||
24855 | var j = undefined; | ||
24856 | var i = undefined; | ||
24857 | for (j = 0; j < props.length; j++) { | ||
24858 | prop = props[j]; | ||
24859 | if (prop) { | ||
24860 | for (i = 0; i < which.length; i++) { | ||
24861 | var cssProp = undefined; | ||
24862 | if (prop === 'border') { | ||
24863 | cssProp = prop + which[i] + 'Width'; | ||
24864 | } else { | ||
24865 | cssProp = prop + which[i]; | ||
24866 | } | ||
24867 | value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; | ||
24868 | } | ||
24869 | } | ||
24870 | } | ||
24871 | return value; | ||
24872 | } | ||
24873 | |||
24874 | /** | ||
24875 | * A crude way of determining if an object is a window | ||
24876 | * @member util | ||
24877 | */ | ||
24878 | function isWindow(obj) { | ||
24879 | // must use == for ie8 | ||
24880 | /* eslint eqeqeq:0 */ | ||
24881 | return obj !== null && obj !== undefined && obj == obj.window; | ||
24882 | } | ||
24883 | |||
24884 | var domUtils = {}; | ||
24885 | |||
24886 | each(['Width', 'Height'], function (name) { | ||
24887 | domUtils['doc' + name] = function (refWin) { | ||
24888 | var d = refWin.document; | ||
24889 | return Math.max( | ||
24890 | // firefox chrome documentElement.scrollHeight< body.scrollHeight | ||
24891 | // ie standard mode : documentElement.scrollHeight> body.scrollHeight | ||
24892 | d.documentElement['scroll' + name], | ||
24893 | // quirks : documentElement.scrollHeight 最大等于可视窗口多一点? | ||
24894 | d.body['scroll' + name], domUtils['viewport' + name](d)); | ||
24895 | }; | ||
24896 | |||
24897 | domUtils['viewport' + name] = function (win) { | ||
24898 | // pc browser includes scrollbar in window.innerWidth | ||
24899 | var prop = 'client' + name; | ||
24900 | var doc = win.document; | ||
24901 | var body = doc.body; | ||
24902 | var documentElement = doc.documentElement; | ||
24903 | var documentElementProp = documentElement[prop]; | ||
24904 | // 标准模式取 documentElement | ||
24905 | // backcompat 取 body | ||
24906 | return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; | ||
24907 | }; | ||
24908 | }); | ||
24909 | |||
24910 | /* | ||
24911 | 得到元素的大小信息 | ||
24912 | @param elem | ||
24913 | @param name | ||
24914 | @param {String} [extra] 'padding' : (css width) + padding | ||
24915 | 'border' : (css width) + padding + border | ||
24916 | 'margin' : (css width) + padding + border + margin | ||
24917 | */ | ||
24918 | function getWH(elem, name, ex) { | ||
24919 | var extra = ex; | ||
24920 | if (isWindow(elem)) { | ||
24921 | return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); | ||
24922 | } else if (elem.nodeType === 9) { | ||
24923 | return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); | ||
24924 | } | ||
24925 | var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; | ||
24926 | var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; | ||
24927 | var computedStyle = getComputedStyleX(elem); | ||
24928 | var isBorderBox = isBorderBoxFn(elem, computedStyle); | ||
24929 | var cssBoxValue = 0; | ||
24930 | if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) { | ||
24931 | borderBoxValue = undefined; | ||
24932 | // Fall back to computed then un computed css if necessary | ||
24933 | cssBoxValue = getComputedStyleX(elem, name); | ||
24934 | if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) { | ||
24935 | cssBoxValue = elem.style[name] || 0; | ||
24936 | } | ||
24937 | // Normalize '', auto, and prepare for extra | ||
24938 | cssBoxValue = parseFloat(cssBoxValue) || 0; | ||
24939 | } | ||
24940 | if (extra === undefined) { | ||
24941 | extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; | ||
24942 | } | ||
24943 | var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; | ||
24944 | var val = borderBoxValue || cssBoxValue; | ||
24945 | if (extra === CONTENT_INDEX) { | ||
24946 | if (borderBoxValueOrIsBorderBox) { | ||
24947 | return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); | ||
24948 | } | ||
24949 | return cssBoxValue; | ||
24950 | } else if (borderBoxValueOrIsBorderBox) { | ||
24951 | if (extra === BORDER_INDEX) { | ||
24952 | return val; | ||
24953 | } | ||
24954 | return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle)); | ||
24955 | } | ||
24956 | return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); | ||
24957 | } | ||
24958 | |||
24959 | var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' }; | ||
24960 | |||
24961 | // fix #119 : https://github.com/kissyteam/kissy/issues/119 | ||
24962 | function getWHIgnoreDisplay() { | ||
24963 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
24964 | args[_key] = arguments[_key]; | ||
24965 | } | ||
24966 | |||
24967 | var val = undefined; | ||
24968 | var elem = args[0]; | ||
24969 | // in case elem is window | ||
24970 | // elem.offsetWidth === undefined | ||
24971 | if (elem.offsetWidth !== 0) { | ||
24972 | val = getWH.apply(undefined, args); | ||
24973 | } else { | ||
24974 | swap(elem, cssShow, function () { | ||
24975 | val = getWH.apply(undefined, args); | ||
24976 | }); | ||
24977 | } | ||
24978 | return val; | ||
24979 | } | ||
24980 | |||
24981 | each(['width', 'height'], function (name) { | ||
24982 | var first = name.charAt(0).toUpperCase() + name.slice(1); | ||
24983 | domUtils['outer' + first] = function (el, includeMargin) { | ||
24984 | return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); | ||
24985 | }; | ||
24986 | var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; | ||
24987 | |||
24988 | domUtils[name] = function (elem, v) { | ||
24989 | var val = v; | ||
24990 | if (val !== undefined) { | ||
24991 | if (elem) { | ||
24992 | var computedStyle = getComputedStyleX(elem); | ||
24993 | var isBorderBox = isBorderBoxFn(elem); | ||
24994 | if (isBorderBox) { | ||
24995 | val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); | ||
24996 | } | ||
24997 | return css(elem, name, val); | ||
24998 | } | ||
24999 | return undefined; | ||
25000 | } | ||
25001 | return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); | ||
25002 | }; | ||
25003 | }); | ||
25004 | |||
25005 | function mix(to, from) { | ||
25006 | for (var i in from) { | ||
25007 | if (from.hasOwnProperty(i)) { | ||
25008 | to[i] = from[i]; | ||
25009 | } | ||
25010 | } | ||
25011 | return to; | ||
25012 | } | ||
25013 | |||
25014 | var utils = { | ||
25015 | getWindow: function getWindow(node) { | ||
25016 | if (node && node.document && node.setTimeout) { | ||
25017 | return node; | ||
25018 | } | ||
25019 | var doc = node.ownerDocument || node; | ||
25020 | return doc.defaultView || doc.parentWindow; | ||
25021 | }, | ||
25022 | offset: function offset(el, value, option) { | ||
25023 | if (typeof value !== 'undefined') { | ||
25024 | setOffset(el, value, option || {}); | ||
25025 | } else { | ||
25026 | return getOffset(el); | ||
25027 | } | ||
25028 | }, | ||
25029 | isWindow: isWindow, | ||
25030 | each: each, | ||
25031 | css: css, | ||
25032 | clone: function clone(obj) { | ||
25033 | var i = undefined; | ||
25034 | var ret = {}; | ||
25035 | for (i in obj) { | ||
25036 | if (obj.hasOwnProperty(i)) { | ||
25037 | ret[i] = obj[i]; | ||
25038 | } | ||
25039 | } | ||
25040 | var overflow = obj.overflow; | ||
25041 | if (overflow) { | ||
25042 | for (i in obj) { | ||
25043 | if (obj.hasOwnProperty(i)) { | ||
25044 | ret.overflow[i] = obj.overflow[i]; | ||
25045 | } | ||
25046 | } | ||
25047 | } | ||
25048 | return ret; | ||
25049 | }, | ||
25050 | mix: mix, | ||
25051 | getWindowScrollLeft: function getWindowScrollLeft(w) { | ||
25052 | return getScrollLeft(w); | ||
25053 | }, | ||
25054 | getWindowScrollTop: function getWindowScrollTop(w) { | ||
25055 | return getScrollTop(w); | ||
25056 | }, | ||
25057 | merge: function merge() { | ||
25058 | var ret = {}; | ||
25059 | |||
25060 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
25061 | args[_key2] = arguments[_key2]; | ||
25062 | } | ||
25063 | |||
25064 | for (var i = 0; i < args.length; i++) { | ||
25065 | utils.mix(ret, args[i]); | ||
25066 | } | ||
25067 | return ret; | ||
25068 | }, | ||
25069 | viewportWidth: 0, | ||
25070 | viewportHeight: 0 | ||
25071 | }; | ||
25072 | |||
25073 | mix(utils, domUtils); | ||
25074 | |||
25075 | exports['default'] = utils; | ||
25076 | module.exports = exports['default']; | ||
25077 | |||
25078 | /***/ }, | ||
25079 | /* 194 */ | ||
25080 | /***/ function(module, exports, __webpack_require__) { | ||
25081 | |||
25082 | 'use strict'; | ||
25083 | |||
25084 | Object.defineProperty(exports, '__esModule', { | ||
25085 | value: true | ||
25086 | }); | ||
25087 | |||
25088 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25089 | |||
25090 | var _utils = __webpack_require__(193); | ||
25091 | |||
25092 | var _utils2 = _interopRequireDefault(_utils); | ||
25093 | |||
25094 | /** | ||
25095 | * 得到会导致元素显示不全的祖先元素 | ||
25096 | */ | ||
25097 | |||
25098 | function getOffsetParent(element) { | ||
25099 | // ie 这个也不是完全可行 | ||
25100 | /* | ||
25101 | <div style="width: 50px;height: 100px;overflow: hidden"> | ||
25102 | <div style="width: 50px;height: 100px;position: relative;" id="d6"> | ||
25103 | 元素 6 高 100px 宽 50px<br/> | ||
25104 | </div> | ||
25105 | </div> | ||
25106 | */ | ||
25107 | // element.offsetParent does the right thing in ie7 and below. Return parent with layout! | ||
25108 | // In other browsers it only includes elements with position absolute, relative or | ||
25109 | // fixed, not elements with overflow set to auto or scroll. | ||
25110 | // if (UA.ie && ieMode < 8) { | ||
25111 | // return element.offsetParent; | ||
25112 | // } | ||
25113 | // 统一的 offsetParent 方法 | ||
25114 | var doc = element.ownerDocument; | ||
25115 | var body = doc.body; | ||
25116 | var parent = undefined; | ||
25117 | var positionStyle = _utils2['default'].css(element, 'position'); | ||
25118 | var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute'; | ||
25119 | |||
25120 | if (!skipStatic) { | ||
25121 | return element.nodeName.toLowerCase() === 'html' ? null : element.parentNode; | ||
25122 | } | ||
25123 | |||
25124 | for (parent = element.parentNode; parent && parent !== body; parent = parent.parentNode) { | ||
25125 | positionStyle = _utils2['default'].css(parent, 'position'); | ||
25126 | if (positionStyle !== 'static') { | ||
25127 | return parent; | ||
25128 | } | ||
25129 | } | ||
25130 | return null; | ||
25131 | } | ||
25132 | |||
25133 | exports['default'] = getOffsetParent; | ||
25134 | module.exports = exports['default']; | ||
25135 | |||
25136 | /***/ }, | ||
25137 | /* 195 */ | ||
25138 | /***/ function(module, exports, __webpack_require__) { | ||
25139 | |||
25140 | 'use strict'; | ||
25141 | |||
25142 | Object.defineProperty(exports, '__esModule', { | ||
25143 | value: true | ||
25144 | }); | ||
25145 | |||
25146 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25147 | |||
25148 | var _utils = __webpack_require__(193); | ||
25149 | |||
25150 | var _utils2 = _interopRequireDefault(_utils); | ||
25151 | |||
25152 | var _getOffsetParent = __webpack_require__(194); | ||
25153 | |||
25154 | var _getOffsetParent2 = _interopRequireDefault(_getOffsetParent); | ||
25155 | |||
25156 | /** | ||
25157 | * 获得元素的显示部分的区域 | ||
25158 | */ | ||
25159 | function getVisibleRectForElement(element) { | ||
25160 | var visibleRect = { | ||
25161 | left: 0, | ||
25162 | right: Infinity, | ||
25163 | top: 0, | ||
25164 | bottom: Infinity | ||
25165 | }; | ||
25166 | var el = (0, _getOffsetParent2['default'])(element); | ||
25167 | var scrollX = undefined; | ||
25168 | var scrollY = undefined; | ||
25169 | var winSize = undefined; | ||
25170 | var doc = element.ownerDocument; | ||
25171 | var win = doc.defaultView || doc.parentWindow; | ||
25172 | var body = doc.body; | ||
25173 | var documentElement = doc.documentElement; | ||
25174 | |||
25175 | // Determine the size of the visible rect by climbing the dom accounting for | ||
25176 | // all scrollable containers. | ||
25177 | while (el) { | ||
25178 | // clientWidth is zero for inline block elements in ie. | ||
25179 | if ((navigator.userAgent.indexOf('MSIE') === -1 || el.clientWidth !== 0) && | ||
25180 | // body may have overflow set on it, yet we still get the entire | ||
25181 | // viewport. In some browsers, el.offsetParent may be | ||
25182 | // document.documentElement, so check for that too. | ||
25183 | el !== body && el !== documentElement && _utils2['default'].css(el, 'overflow') !== 'visible') { | ||
25184 | var pos = _utils2['default'].offset(el); | ||
25185 | // add border | ||
25186 | pos.left += el.clientLeft; | ||
25187 | pos.top += el.clientTop; | ||
25188 | visibleRect.top = Math.max(visibleRect.top, pos.top); | ||
25189 | visibleRect.right = Math.min(visibleRect.right, | ||
25190 | // consider area without scrollBar | ||
25191 | pos.left + el.clientWidth); | ||
25192 | visibleRect.bottom = Math.min(visibleRect.bottom, pos.top + el.clientHeight); | ||
25193 | visibleRect.left = Math.max(visibleRect.left, pos.left); | ||
25194 | } else if (el === body || el === documentElement) { | ||
25195 | break; | ||
25196 | } | ||
25197 | el = (0, _getOffsetParent2['default'])(el); | ||
25198 | } | ||
25199 | |||
25200 | // Clip by window's viewport. | ||
25201 | scrollX = _utils2['default'].getWindowScrollLeft(win); | ||
25202 | scrollY = _utils2['default'].getWindowScrollTop(win); | ||
25203 | visibleRect.left = Math.max(visibleRect.left, scrollX); | ||
25204 | visibleRect.top = Math.max(visibleRect.top, scrollY); | ||
25205 | winSize = { | ||
25206 | width: _utils2['default'].viewportWidth(win), | ||
25207 | height: _utils2['default'].viewportHeight(win) | ||
25208 | }; | ||
25209 | visibleRect.right = Math.min(visibleRect.right, scrollX + winSize.width); | ||
25210 | visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + winSize.height); | ||
25211 | return visibleRect.top >= 0 && visibleRect.left >= 0 && visibleRect.bottom > visibleRect.top && visibleRect.right > visibleRect.left ? visibleRect : null; | ||
25212 | } | ||
25213 | |||
25214 | exports['default'] = getVisibleRectForElement; | ||
25215 | module.exports = exports['default']; | ||
25216 | |||
25217 | /***/ }, | ||
25218 | /* 196 */ | ||
25219 | /***/ function(module, exports, __webpack_require__) { | ||
25220 | |||
25221 | 'use strict'; | ||
25222 | |||
25223 | Object.defineProperty(exports, '__esModule', { | ||
25224 | value: true | ||
25225 | }); | ||
25226 | |||
25227 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25228 | |||
25229 | var _utils = __webpack_require__(193); | ||
25230 | |||
25231 | var _utils2 = _interopRequireDefault(_utils); | ||
25232 | |||
25233 | function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) { | ||
25234 | var pos = _utils2['default'].clone(elFuturePos); | ||
25235 | var size = { | ||
25236 | width: elRegion.width, | ||
25237 | height: elRegion.height | ||
25238 | }; | ||
25239 | |||
25240 | if (overflow.adjustX && pos.left < visibleRect.left) { | ||
25241 | pos.left = visibleRect.left; | ||
25242 | } | ||
25243 | |||
25244 | // Left edge inside and right edge outside viewport, try to resize it. | ||
25245 | if (overflow.resizeWidth && pos.left >= visibleRect.left && pos.left + size.width > visibleRect.right) { | ||
25246 | size.width -= pos.left + size.width - visibleRect.right; | ||
25247 | } | ||
25248 | |||
25249 | // Right edge outside viewport, try to move it. | ||
25250 | if (overflow.adjustX && pos.left + size.width > visibleRect.right) { | ||
25251 | // 保证左边界和可视区域左边界对齐 | ||
25252 | pos.left = Math.max(visibleRect.right - size.width, visibleRect.left); | ||
25253 | } | ||
25254 | |||
25255 | // Top edge outside viewport, try to move it. | ||
25256 | if (overflow.adjustY && pos.top < visibleRect.top) { | ||
25257 | pos.top = visibleRect.top; | ||
25258 | } | ||
25259 | |||
25260 | // Top edge inside and bottom edge outside viewport, try to resize it. | ||
25261 | if (overflow.resizeHeight && pos.top >= visibleRect.top && pos.top + size.height > visibleRect.bottom) { | ||
25262 | size.height -= pos.top + size.height - visibleRect.bottom; | ||
25263 | } | ||
25264 | |||
25265 | // Bottom edge outside viewport, try to move it. | ||
25266 | if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) { | ||
25267 | // 保证上边界和可视区域上边界对齐 | ||
25268 | pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top); | ||
25269 | } | ||
25270 | |||
25271 | return _utils2['default'].mix(pos, size); | ||
25272 | } | ||
25273 | |||
25274 | exports['default'] = adjustForViewport; | ||
25275 | module.exports = exports['default']; | ||
25276 | |||
25277 | /***/ }, | ||
25278 | /* 197 */ | ||
25279 | /***/ function(module, exports, __webpack_require__) { | ||
25280 | |||
25281 | 'use strict'; | ||
25282 | |||
25283 | Object.defineProperty(exports, '__esModule', { | ||
25284 | value: true | ||
25285 | }); | ||
25286 | |||
25287 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25288 | |||
25289 | var _utils = __webpack_require__(193); | ||
25290 | |||
25291 | var _utils2 = _interopRequireDefault(_utils); | ||
25292 | |||
25293 | function getRegion(node) { | ||
25294 | var offset = undefined; | ||
25295 | var w = undefined; | ||
25296 | var h = undefined; | ||
25297 | if (!_utils2['default'].isWindow(node) && node.nodeType !== 9) { | ||
25298 | offset = _utils2['default'].offset(node); | ||
25299 | w = _utils2['default'].outerWidth(node); | ||
25300 | h = _utils2['default'].outerHeight(node); | ||
25301 | } else { | ||
25302 | var win = _utils2['default'].getWindow(node); | ||
25303 | offset = { | ||
25304 | left: _utils2['default'].getWindowScrollLeft(win), | ||
25305 | top: _utils2['default'].getWindowScrollTop(win) | ||
25306 | }; | ||
25307 | w = _utils2['default'].viewportWidth(win); | ||
25308 | h = _utils2['default'].viewportHeight(win); | ||
25309 | } | ||
25310 | offset.width = w; | ||
25311 | offset.height = h; | ||
25312 | return offset; | ||
25313 | } | ||
25314 | |||
25315 | exports['default'] = getRegion; | ||
25316 | module.exports = exports['default']; | ||
25317 | |||
25318 | /***/ }, | ||
25319 | /* 198 */ | ||
25320 | /***/ function(module, exports, __webpack_require__) { | ||
25321 | |||
25322 | 'use strict'; | ||
25323 | |||
25324 | Object.defineProperty(exports, '__esModule', { | ||
25325 | value: true | ||
25326 | }); | ||
25327 | |||
25328 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25329 | |||
25330 | var _getAlignOffset = __webpack_require__(199); | ||
25331 | |||
25332 | var _getAlignOffset2 = _interopRequireDefault(_getAlignOffset); | ||
25333 | |||
25334 | function getElFuturePos(elRegion, refNodeRegion, points, offset, targetOffset) { | ||
25335 | var xy = undefined; | ||
25336 | var diff = undefined; | ||
25337 | var p1 = undefined; | ||
25338 | var p2 = undefined; | ||
25339 | |||
25340 | xy = { | ||
25341 | left: elRegion.left, | ||
25342 | top: elRegion.top | ||
25343 | }; | ||
25344 | |||
25345 | p1 = (0, _getAlignOffset2['default'])(refNodeRegion, points[1]); | ||
25346 | p2 = (0, _getAlignOffset2['default'])(elRegion, points[0]); | ||
25347 | |||
25348 | diff = [p2.left - p1.left, p2.top - p1.top]; | ||
25349 | |||
25350 | return { | ||
25351 | left: xy.left - diff[0] + offset[0] - targetOffset[0], | ||
25352 | top: xy.top - diff[1] + offset[1] - targetOffset[1] | ||
25353 | }; | ||
25354 | } | ||
25355 | |||
25356 | exports['default'] = getElFuturePos; | ||
25357 | module.exports = exports['default']; | ||
25358 | |||
25359 | /***/ }, | ||
25360 | /* 199 */ | ||
25361 | /***/ function(module, exports) { | ||
25362 | |||
25363 | /** | ||
25364 | * 获取 node 上的 align 对齐点 相对于页面的坐标 | ||
25365 | */ | ||
25366 | |||
25367 | 'use strict'; | ||
25368 | |||
25369 | Object.defineProperty(exports, '__esModule', { | ||
25370 | value: true | ||
25371 | }); | ||
25372 | function getAlignOffset(region, align) { | ||
25373 | var V = align.charAt(0); | ||
25374 | var H = align.charAt(1); | ||
25375 | var w = region.width; | ||
25376 | var h = region.height; | ||
25377 | var x = undefined; | ||
25378 | var y = undefined; | ||
25379 | |||
25380 | x = region.left; | ||
25381 | y = region.top; | ||
25382 | |||
25383 | if (V === 'c') { | ||
25384 | y += h / 2; | ||
25385 | } else if (V === 'b') { | ||
25386 | y += h; | ||
25387 | } | ||
25388 | |||
25389 | if (H === 'c') { | ||
25390 | x += w / 2; | ||
25391 | } else if (H === 'r') { | ||
25392 | x += w; | ||
25393 | } | ||
25394 | |||
25395 | return { | ||
25396 | left: x, | ||
25397 | top: y | ||
25398 | }; | ||
25399 | } | ||
25400 | |||
25401 | exports['default'] = getAlignOffset; | ||
25402 | module.exports = exports['default']; | ||
25403 | |||
25404 | /***/ }, | ||
25405 | /* 200 */ | ||
25406 | /***/ function(module, exports) { | ||
25407 | |||
25408 | "use strict"; | ||
25409 | |||
25410 | Object.defineProperty(exports, "__esModule", { | ||
25411 | value: true | ||
25412 | }); | ||
25413 | exports["default"] = isWindow; | ||
25414 | |||
25415 | function isWindow(obj) { | ||
25416 | /* eslint no-eq-null: 0 */ | ||
25417 | /* eslint eqeqeq: 0 */ | ||
25418 | return obj != null && obj == obj.window; | ||
25419 | } | ||
25420 | |||
25421 | module.exports = exports["default"]; | ||
25422 | |||
25423 | /***/ }, | ||
25424 | /* 201 */ | ||
25425 | /***/ function(module, exports, __webpack_require__) { | ||
25426 | |||
25427 | // export this package's api | ||
25428 | 'use strict'; | ||
25429 | |||
25430 | module.exports = __webpack_require__(202); | ||
25431 | |||
25432 | /***/ }, | ||
25433 | /* 202 */ | ||
25434 | /***/ function(module, exports, __webpack_require__) { | ||
25435 | |||
25436 | 'use strict'; | ||
25437 | |||
25438 | Object.defineProperty(exports, '__esModule', { | ||
25439 | value: true | ||
25440 | }); | ||
25441 | |||
25442 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25443 | |||
25444 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
25445 | |||
25446 | var _react = __webpack_require__(3); | ||
25447 | |||
25448 | var _react2 = _interopRequireDefault(_react); | ||
25449 | |||
25450 | var _ChildrenUtils = __webpack_require__(203); | ||
25451 | |||
25452 | var _AnimateChild = __webpack_require__(204); | ||
25453 | |||
25454 | var _AnimateChild2 = _interopRequireDefault(_AnimateChild); | ||
25455 | |||
25456 | var _util = __webpack_require__(208); | ||
25457 | |||
25458 | var _util2 = _interopRequireDefault(_util); | ||
25459 | |||
25460 | var defaultKey = 'rc_animate_' + Date.now(); | ||
25461 | |||
25462 | function getChildrenFromProps(props) { | ||
25463 | var children = props.children; | ||
25464 | if (_react2['default'].isValidElement(children)) { | ||
25465 | if (!children.key) { | ||
25466 | return _react2['default'].cloneElement(children, { | ||
25467 | key: defaultKey | ||
25468 | }); | ||
25469 | } | ||
25470 | } | ||
25471 | return children; | ||
25472 | } | ||
25473 | |||
25474 | function noop() {} | ||
25475 | |||
25476 | var Animate = _react2['default'].createClass({ | ||
25477 | displayName: 'Animate', | ||
25478 | |||
25479 | propTypes: { | ||
25480 | component: _react2['default'].PropTypes.any, | ||
25481 | animation: _react2['default'].PropTypes.object, | ||
25482 | transitionName: _react2['default'].PropTypes.string, | ||
25483 | transitionEnter: _react2['default'].PropTypes.bool, | ||
25484 | transitionAppear: _react2['default'].PropTypes.bool, | ||
25485 | exclusive: _react2['default'].PropTypes.bool, | ||
25486 | transitionLeave: _react2['default'].PropTypes.bool, | ||
25487 | onEnd: _react2['default'].PropTypes.func, | ||
25488 | onEnter: _react2['default'].PropTypes.func, | ||
25489 | onLeave: _react2['default'].PropTypes.func, | ||
25490 | onAppear: _react2['default'].PropTypes.func, | ||
25491 | showProp: _react2['default'].PropTypes.string | ||
25492 | }, | ||
25493 | |||
25494 | getDefaultProps: function getDefaultProps() { | ||
25495 | return { | ||
25496 | animation: {}, | ||
25497 | component: 'span', | ||
25498 | transitionEnter: true, | ||
25499 | transitionLeave: true, | ||
25500 | transitionAppear: false, | ||
25501 | onEnd: noop, | ||
25502 | onEnter: noop, | ||
25503 | onLeave: noop, | ||
25504 | onAppear: noop | ||
25505 | }; | ||
25506 | }, | ||
25507 | |||
25508 | getInitialState: function getInitialState() { | ||
25509 | this.currentlyAnimatingKeys = {}; | ||
25510 | this.keysToEnter = []; | ||
25511 | this.keysToLeave = []; | ||
25512 | return { | ||
25513 | children: (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(this.props)) | ||
25514 | }; | ||
25515 | }, | ||
25516 | |||
25517 | componentDidMount: function componentDidMount() { | ||
25518 | var _this = this; | ||
25519 | |||
25520 | var showProp = this.props.showProp; | ||
25521 | var children = this.state.children; | ||
25522 | if (showProp) { | ||
25523 | children = children.filter(function (child) { | ||
25524 | return !!child.props[showProp]; | ||
25525 | }); | ||
25526 | } | ||
25527 | children.forEach(function (child) { | ||
25528 | _this.performAppear(child.key); | ||
25529 | }); | ||
25530 | }, | ||
25531 | |||
25532 | componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
25533 | var _this2 = this; | ||
25534 | |||
25535 | var nextChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(nextProps)); | ||
25536 | var props = this.props; | ||
25537 | var showProp = props.showProp; | ||
25538 | var currentlyAnimatingKeys = this.currentlyAnimatingKeys; | ||
25539 | // last props children if exclusive | ||
25540 | // exclusive needs immediate response | ||
25541 | var currentChildren = this.state.children; | ||
25542 | // in case destroy in showProp mode | ||
25543 | var newChildren = []; | ||
25544 | if (showProp) { | ||
25545 | currentChildren.forEach(function (currentChild) { | ||
25546 | var nextChild = (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, currentChild.key); | ||
25547 | var newChild = undefined; | ||
25548 | if ((!nextChild || !nextChild.props[showProp]) && currentChild.props[showProp]) { | ||
25549 | newChild = _react2['default'].cloneElement(nextChild || currentChild, _defineProperty({}, showProp, true)); | ||
25550 | } else { | ||
25551 | newChild = nextChild; | ||
25552 | } | ||
25553 | if (newChild) { | ||
25554 | newChildren.push(newChild); | ||
25555 | } | ||
25556 | }); | ||
25557 | nextChildren.forEach(function (nextChild) { | ||
25558 | if (!(0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, nextChild.key)) { | ||
25559 | newChildren.push(nextChild); | ||
25560 | } | ||
25561 | }); | ||
25562 | } else { | ||
25563 | newChildren = (0, _ChildrenUtils.mergeChildren)(currentChildren, nextChildren); | ||
25564 | } | ||
25565 | |||
25566 | // need render to avoid update | ||
25567 | this.setState({ | ||
25568 | children: newChildren | ||
25569 | }); | ||
25570 | |||
25571 | nextChildren.forEach(function (child) { | ||
25572 | var key = child.key; | ||
25573 | if (currentlyAnimatingKeys[key]) { | ||
25574 | return; | ||
25575 | } | ||
25576 | var hasPrev = (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key); | ||
25577 | if (showProp) { | ||
25578 | var showInNext = child.props[showProp]; | ||
25579 | if (hasPrev) { | ||
25580 | var showInNow = (0, _ChildrenUtils.findShownChildInChildrenByKey)(currentChildren, key, showProp); | ||
25581 | if (!showInNow && showInNext) { | ||
25582 | _this2.keysToEnter.push(key); | ||
25583 | } | ||
25584 | } else if (showInNext) { | ||
25585 | _this2.keysToEnter.push(key); | ||
25586 | } | ||
25587 | } else if (!hasPrev) { | ||
25588 | _this2.keysToEnter.push(key); | ||
25589 | } | ||
25590 | }); | ||
25591 | |||
25592 | currentChildren.forEach(function (child) { | ||
25593 | var key = child.key; | ||
25594 | if (currentlyAnimatingKeys[key]) { | ||
25595 | return; | ||
25596 | } | ||
25597 | var hasNext = (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, key); | ||
25598 | if (showProp) { | ||
25599 | var showInNow = child.props[showProp]; | ||
25600 | if (hasNext) { | ||
25601 | var showInNext = (0, _ChildrenUtils.findShownChildInChildrenByKey)(nextChildren, key, showProp); | ||
25602 | if (!showInNext && showInNow) { | ||
25603 | _this2.keysToLeave.push(key); | ||
25604 | } | ||
25605 | } else if (showInNow) { | ||
25606 | _this2.keysToLeave.push(key); | ||
25607 | } | ||
25608 | } else if (!hasNext) { | ||
25609 | _this2.keysToLeave.push(key); | ||
25610 | } | ||
25611 | }); | ||
25612 | }, | ||
25613 | |||
25614 | componentDidUpdate: function componentDidUpdate(prevProps) { | ||
25615 | var _this3 = this; | ||
25616 | |||
25617 | // exclusive needs immediate response | ||
25618 | if (this.props.exclusive && this.props !== prevProps) { | ||
25619 | Object.keys(this.currentlyAnimatingKeys).forEach(function (key) { | ||
25620 | _this3.stop(key); | ||
25621 | }); | ||
25622 | } | ||
25623 | if (this.isMounted()) { | ||
25624 | var keysToEnter = this.keysToEnter; | ||
25625 | this.keysToEnter = []; | ||
25626 | keysToEnter.forEach(this.performEnter); | ||
25627 | var keysToLeave = this.keysToLeave; | ||
25628 | this.keysToLeave = []; | ||
25629 | keysToLeave.forEach(this.performLeave); | ||
25630 | } | ||
25631 | }, | ||
25632 | |||
25633 | performEnter: function performEnter(key) { | ||
25634 | // may already remove by exclusive | ||
25635 | if (this.refs[key]) { | ||
25636 | this.currentlyAnimatingKeys[key] = true; | ||
25637 | this.refs[key].componentWillEnter(this.handleDoneAdding.bind(this, key, 'enter')); | ||
25638 | } | ||
25639 | }, | ||
25640 | |||
25641 | performAppear: function performAppear(key) { | ||
25642 | if (this.refs[key]) { | ||
25643 | this.currentlyAnimatingKeys[key] = true; | ||
25644 | this.refs[key].componentWillAppear(this.handleDoneAdding.bind(this, key, 'appear')); | ||
25645 | } | ||
25646 | }, | ||
25647 | |||
25648 | handleDoneAdding: function handleDoneAdding(key, type) { | ||
25649 | var props = this.props; | ||
25650 | delete this.currentlyAnimatingKeys[key]; | ||
25651 | var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); | ||
25652 | if (!this.isValidChildByKey(currentChildren, key)) { | ||
25653 | // exclusive will not need this | ||
25654 | this.performLeave(key); | ||
25655 | } else { | ||
25656 | if (type === 'appear') { | ||
25657 | if (_util2['default'].allowAppearCallback(props)) { | ||
25658 | props.onAppear(key); | ||
25659 | props.onEnd(key, true); | ||
25660 | } | ||
25661 | } else { | ||
25662 | if (_util2['default'].allowEnterCallback(props)) { | ||
25663 | props.onEnter(key); | ||
25664 | props.onEnd(key, true); | ||
25665 | } | ||
25666 | } | ||
25667 | } | ||
25668 | }, | ||
25669 | |||
25670 | performLeave: function performLeave(key) { | ||
25671 | // may already remove by exclusive | ||
25672 | if (this.refs[key]) { | ||
25673 | this.currentlyAnimatingKeys[key] = true; | ||
25674 | this.refs[key].componentWillLeave(this.handleDoneLeaving.bind(this, key)); | ||
25675 | } | ||
25676 | }, | ||
25677 | |||
25678 | handleDoneLeaving: function handleDoneLeaving(key) { | ||
25679 | var props = this.props; | ||
25680 | delete this.currentlyAnimatingKeys[key]; | ||
25681 | var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); | ||
25682 | // in case state change is too fast | ||
25683 | if (this.isValidChildByKey(currentChildren, key)) { | ||
25684 | this.performEnter(key); | ||
25685 | } else { | ||
25686 | if (_util2['default'].allowLeaveCallback(props)) { | ||
25687 | props.onLeave(key); | ||
25688 | props.onEnd(key, false); | ||
25689 | } | ||
25690 | if (this.isMounted() && !(0, _ChildrenUtils.isSameChildren)(this.state.children, currentChildren, props.showProp)) { | ||
25691 | this.setState({ | ||
25692 | children: currentChildren | ||
25693 | }); | ||
25694 | } | ||
25695 | } | ||
25696 | }, | ||
25697 | |||
25698 | isValidChildByKey: function isValidChildByKey(currentChildren, key) { | ||
25699 | var showProp = this.props.showProp; | ||
25700 | if (showProp) { | ||
25701 | return (0, _ChildrenUtils.findShownChildInChildrenByKey)(currentChildren, key, showProp); | ||
25702 | } | ||
25703 | return (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key); | ||
25704 | }, | ||
25705 | |||
25706 | stop: function stop(key) { | ||
25707 | delete this.currentlyAnimatingKeys[key]; | ||
25708 | var component = this.refs[key]; | ||
25709 | if (component) { | ||
25710 | component.stop(); | ||
25711 | } | ||
25712 | }, | ||
25713 | |||
25714 | render: function render() { | ||
25715 | var props = this.props; | ||
25716 | var stateChildren = this.state.children; | ||
25717 | var children = null; | ||
25718 | if (stateChildren) { | ||
25719 | children = stateChildren.map(function (child) { | ||
25720 | if (!child.key) { | ||
25721 | throw new Error('must set key for <rc-animate> children'); | ||
25722 | } | ||
25723 | return _react2['default'].createElement( | ||
25724 | _AnimateChild2['default'], | ||
25725 | { | ||
25726 | key: child.key, | ||
25727 | ref: child.key, | ||
25728 | animation: props.animation, | ||
25729 | transitionName: props.transitionName, | ||
25730 | transitionEnter: props.transitionEnter, | ||
25731 | transitionAppear: props.transitionAppear, | ||
25732 | transitionLeave: props.transitionLeave }, | ||
25733 | child | ||
25734 | ); | ||
25735 | }); | ||
25736 | } | ||
25737 | var Component = props.component; | ||
25738 | if (Component) { | ||
25739 | return _react2['default'].createElement( | ||
25740 | Component, | ||
25741 | this.props, | ||
25742 | children | ||
25743 | ); | ||
25744 | } | ||
25745 | return children[0] || null; | ||
25746 | } | ||
25747 | }); | ||
25748 | |||
25749 | exports['default'] = Animate; | ||
25750 | module.exports = exports['default']; | ||
25751 | |||
25752 | /***/ }, | ||
25753 | /* 203 */ | ||
25754 | /***/ function(module, exports, __webpack_require__) { | ||
25755 | |||
25756 | 'use strict'; | ||
25757 | |||
25758 | Object.defineProperty(exports, '__esModule', { | ||
25759 | value: true | ||
25760 | }); | ||
25761 | exports.toArrayChildren = toArrayChildren; | ||
25762 | exports.findChildInChildrenByKey = findChildInChildrenByKey; | ||
25763 | exports.findShownChildInChildrenByKey = findShownChildInChildrenByKey; | ||
25764 | exports.findHiddenChildInChildrenByKey = findHiddenChildInChildrenByKey; | ||
25765 | exports.isSameChildren = isSameChildren; | ||
25766 | exports.mergeChildren = mergeChildren; | ||
25767 | |||
25768 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25769 | |||
25770 | var _react = __webpack_require__(3); | ||
25771 | |||
25772 | var _react2 = _interopRequireDefault(_react); | ||
25773 | |||
25774 | function toArrayChildren(children) { | ||
25775 | var ret = []; | ||
25776 | _react2['default'].Children.forEach(children, function (child) { | ||
25777 | ret.push(child); | ||
25778 | }); | ||
25779 | return ret; | ||
25780 | } | ||
25781 | |||
25782 | function findChildInChildrenByKey(children, key) { | ||
25783 | var ret = null; | ||
25784 | if (children) { | ||
25785 | children.forEach(function (child) { | ||
25786 | if (ret) { | ||
25787 | return; | ||
25788 | } | ||
25789 | if (child.key === key) { | ||
25790 | ret = child; | ||
25791 | } | ||
25792 | }); | ||
25793 | } | ||
25794 | return ret; | ||
25795 | } | ||
25796 | |||
25797 | function findShownChildInChildrenByKey(children, key, showProp) { | ||
25798 | var ret = null; | ||
25799 | if (children) { | ||
25800 | children.forEach(function (child) { | ||
25801 | if (child.key === key && child.props[showProp]) { | ||
25802 | if (ret) { | ||
25803 | throw new Error('two child with same key for <rc-animate> children'); | ||
25804 | } | ||
25805 | ret = child; | ||
25806 | } | ||
25807 | }); | ||
25808 | } | ||
25809 | return ret; | ||
25810 | } | ||
25811 | |||
25812 | function findHiddenChildInChildrenByKey(children, key, showProp) { | ||
25813 | var found = 0; | ||
25814 | if (children) { | ||
25815 | children.forEach(function (child) { | ||
25816 | if (found) { | ||
25817 | return; | ||
25818 | } | ||
25819 | found = child.key === key && !child.props[showProp]; | ||
25820 | }); | ||
25821 | } | ||
25822 | return found; | ||
25823 | } | ||
25824 | |||
25825 | function isSameChildren(c1, c2, showProp) { | ||
25826 | var same = c1.length === c2.length; | ||
25827 | if (same) { | ||
25828 | c1.forEach(function (child, index) { | ||
25829 | var child2 = c2[index]; | ||
25830 | if (child.key !== child2.key) { | ||
25831 | same = false; | ||
25832 | } else if (showProp && child.props[showProp] !== child2.props[showProp]) { | ||
25833 | same = false; | ||
25834 | } | ||
25835 | }); | ||
25836 | } | ||
25837 | return same; | ||
25838 | } | ||
25839 | |||
25840 | function mergeChildren(prev, next) { | ||
25841 | var ret = []; | ||
25842 | |||
25843 | // For each key of `next`, the list of keys to insert before that key in | ||
25844 | // the combined list | ||
25845 | var nextChildrenPending = {}; | ||
25846 | var pendingChildren = []; | ||
25847 | prev.forEach(function (child) { | ||
25848 | if (findChildInChildrenByKey(next, child.key)) { | ||
25849 | if (pendingChildren.length) { | ||
25850 | nextChildrenPending[child.key] = pendingChildren; | ||
25851 | pendingChildren = []; | ||
25852 | } | ||
25853 | } else { | ||
25854 | pendingChildren.push(child); | ||
25855 | } | ||
25856 | }); | ||
25857 | |||
25858 | next.forEach(function (child) { | ||
25859 | if (nextChildrenPending.hasOwnProperty(child.key)) { | ||
25860 | ret = ret.concat(nextChildrenPending[child.key]); | ||
25861 | } | ||
25862 | ret.push(child); | ||
25863 | }); | ||
25864 | |||
25865 | ret = ret.concat(pendingChildren); | ||
25866 | |||
25867 | return ret; | ||
25868 | } | ||
25869 | |||
25870 | /***/ }, | ||
25871 | /* 204 */ | ||
25872 | /***/ function(module, exports, __webpack_require__) { | ||
25873 | |||
25874 | 'use strict'; | ||
25875 | |||
25876 | Object.defineProperty(exports, '__esModule', { | ||
25877 | value: true | ||
25878 | }); | ||
25879 | |||
25880 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
25881 | |||
25882 | var _react = __webpack_require__(3); | ||
25883 | |||
25884 | var _react2 = _interopRequireDefault(_react); | ||
25885 | |||
25886 | var _reactDom = __webpack_require__(160); | ||
25887 | |||
25888 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
25889 | |||
25890 | var _cssAnimation = __webpack_require__(205); | ||
25891 | |||
25892 | var _cssAnimation2 = _interopRequireDefault(_cssAnimation); | ||
25893 | |||
25894 | var _util = __webpack_require__(208); | ||
25895 | |||
25896 | var _util2 = _interopRequireDefault(_util); | ||
25897 | |||
25898 | var transitionMap = { | ||
25899 | enter: 'transitionEnter', | ||
25900 | appear: 'transitionAppear', | ||
25901 | leave: 'transitionLeave' | ||
25902 | }; | ||
25903 | |||
25904 | var AnimateChild = _react2['default'].createClass({ | ||
25905 | displayName: 'AnimateChild', | ||
25906 | |||
25907 | propTypes: { | ||
25908 | children: _react2['default'].PropTypes.any | ||
25909 | }, | ||
25910 | |||
25911 | componentWillUnmount: function componentWillUnmount() { | ||
25912 | this.stop(); | ||
25913 | }, | ||
25914 | |||
25915 | componentWillEnter: function componentWillEnter(done) { | ||
25916 | if (_util2['default'].isEnterSupported(this.props)) { | ||
25917 | this.transition('enter', done); | ||
25918 | } else { | ||
25919 | done(); | ||
25920 | } | ||
25921 | }, | ||
25922 | |||
25923 | componentWillAppear: function componentWillAppear(done) { | ||
25924 | if (_util2['default'].isAppearSupported(this.props)) { | ||
25925 | this.transition('appear', done); | ||
25926 | } else { | ||
25927 | done(); | ||
25928 | } | ||
25929 | }, | ||
25930 | |||
25931 | componentWillLeave: function componentWillLeave(done) { | ||
25932 | if (_util2['default'].isLeaveSupported(this.props)) { | ||
25933 | this.transition('leave', done); | ||
25934 | } else { | ||
25935 | done(); | ||
25936 | } | ||
25937 | }, | ||
25938 | |||
25939 | transition: function transition(animationType, finishCallback) { | ||
25940 | var _this = this; | ||
25941 | |||
25942 | var node = _reactDom2['default'].findDOMNode(this); | ||
25943 | var props = this.props; | ||
25944 | var transitionName = props.transitionName; | ||
25945 | this.stop(); | ||
25946 | var end = function end() { | ||
25947 | _this.stopper = null; | ||
25948 | finishCallback(); | ||
25949 | }; | ||
25950 | if ((_cssAnimation.isCssAnimationSupported || !props.animation[animationType]) && transitionName && props[transitionMap[animationType]]) { | ||
25951 | this.stopper = (0, _cssAnimation2['default'])(node, transitionName + '-' + animationType, end); | ||
25952 | } else { | ||
25953 | this.stopper = props.animation[animationType](node, end); | ||
25954 | } | ||
25955 | }, | ||
25956 | |||
25957 | stop: function stop() { | ||
25958 | var stopper = this.stopper; | ||
25959 | if (stopper) { | ||
25960 | this.stopper = null; | ||
25961 | stopper.stop(); | ||
25962 | } | ||
25963 | }, | ||
25964 | |||
25965 | render: function render() { | ||
25966 | return this.props.children; | ||
25967 | } | ||
25968 | }); | ||
25969 | |||
25970 | exports['default'] = AnimateChild; | ||
25971 | module.exports = exports['default']; | ||
25972 | |||
25973 | /***/ }, | ||
25974 | /* 205 */ | ||
25975 | /***/ function(module, exports, __webpack_require__) { | ||
25976 | |||
25977 | 'use strict'; | ||
25978 | |||
25979 | var Event = __webpack_require__(206); | ||
25980 | var Css = __webpack_require__(207); | ||
25981 | var isCssAnimationSupported = Event.endEvents.length !== 0; | ||
25982 | |||
25983 | function getDuration(node, name) { | ||
25984 | var style = window.getComputedStyle(node); | ||
25985 | var prefixes = ['-webkit-', '-moz-', '-o-', 'ms-', '']; | ||
25986 | var ret = ''; | ||
25987 | for (var i = 0; i < prefixes.length; i++) { | ||
25988 | ret = style.getPropertyValue(prefixes[i] + name); | ||
25989 | if (ret) { | ||
25990 | break; | ||
25991 | } | ||
25992 | } | ||
25993 | return ret; | ||
25994 | } | ||
25995 | |||
25996 | function fixBrowserByTimeout(node) { | ||
25997 | if (isCssAnimationSupported) { | ||
25998 | var transitionDuration = parseFloat(getDuration(node, 'transition-duration')) || 0; | ||
25999 | var animationDuration = parseFloat(getDuration(node, 'animation-duration')) || 0; | ||
26000 | var time = Math.max(transitionDuration, animationDuration); | ||
26001 | // sometimes, browser bug | ||
26002 | node.rcEndAnimTimeout = setTimeout(function () { | ||
26003 | node.rcEndAnimTimeout = null; | ||
26004 | if (node.rcEndListener) { | ||
26005 | node.rcEndListener(); | ||
26006 | } | ||
26007 | }, time * 1000 + 200); | ||
26008 | } | ||
26009 | } | ||
26010 | |||
26011 | function clearBrowserBugTimeout(node) { | ||
26012 | if (node.rcEndAnimTimeout) { | ||
26013 | clearTimeout(node.rcEndAnimTimeout); | ||
26014 | node.rcEndAnimTimeout = null; | ||
26015 | } | ||
26016 | } | ||
26017 | |||
26018 | var cssAnimation = function cssAnimation(node, transitionName, callback) { | ||
26019 | var className = transitionName; | ||
26020 | var activeClassName = className + '-active'; | ||
26021 | |||
26022 | if (node.rcEndListener) { | ||
26023 | node.rcEndListener(); | ||
26024 | } | ||
26025 | |||
26026 | node.rcEndListener = function (e) { | ||
26027 | if (e && e.target !== node) { | ||
26028 | return; | ||
26029 | } | ||
26030 | |||
26031 | if (node.rcAnimTimeout) { | ||
26032 | clearTimeout(node.rcAnimTimeout); | ||
26033 | node.rcAnimTimeout = null; | ||
26034 | } | ||
26035 | |||
26036 | clearBrowserBugTimeout(node); | ||
26037 | |||
26038 | Css.removeClass(node, className); | ||
26039 | Css.removeClass(node, activeClassName); | ||
26040 | |||
26041 | Event.removeEndEventListener(node, node.rcEndListener); | ||
26042 | node.rcEndListener = null; | ||
26043 | |||
26044 | // Usually this optional callback is used for informing an owner of | ||
26045 | // a leave animation and telling it to remove the child. | ||
26046 | if (callback) { | ||
26047 | callback(); | ||
26048 | } | ||
26049 | }; | ||
26050 | |||
26051 | Event.addEndEventListener(node, node.rcEndListener); | ||
26052 | |||
26053 | Css.addClass(node, className); | ||
26054 | |||
26055 | node.rcAnimTimeout = setTimeout(function () { | ||
26056 | node.rcAnimTimeout = null; | ||
26057 | Css.addClass(node, activeClassName); | ||
26058 | fixBrowserByTimeout(node); | ||
26059 | }, 0); | ||
26060 | |||
26061 | return { | ||
26062 | stop: function stop() { | ||
26063 | if (node.rcEndListener) { | ||
26064 | node.rcEndListener(); | ||
26065 | } | ||
26066 | } | ||
26067 | }; | ||
26068 | }; | ||
26069 | |||
26070 | cssAnimation.style = function (node, style, callback) { | ||
26071 | if (node.rcEndListener) { | ||
26072 | node.rcEndListener(); | ||
26073 | } | ||
26074 | |||
26075 | node.rcEndListener = function (e) { | ||
26076 | if (e && e.target !== node) { | ||
26077 | return; | ||
26078 | } | ||
26079 | |||
26080 | if (node.rcAnimTimeout) { | ||
26081 | clearTimeout(node.rcAnimTimeout); | ||
26082 | node.rcAnimTimeout = null; | ||
26083 | } | ||
26084 | |||
26085 | clearBrowserBugTimeout(node); | ||
26086 | |||
26087 | Event.removeEndEventListener(node, node.rcEndListener); | ||
26088 | node.rcEndListener = null; | ||
26089 | |||
26090 | // Usually this optional callback is used for informing an owner of | ||
26091 | // a leave animation and telling it to remove the child. | ||
26092 | if (callback) { | ||
26093 | callback(); | ||
26094 | } | ||
26095 | }; | ||
26096 | |||
26097 | Event.addEndEventListener(node, node.rcEndListener); | ||
26098 | |||
26099 | node.rcAnimTimeout = setTimeout(function () { | ||
26100 | for (var s in style) { | ||
26101 | if (style.hasOwnProperty(s)) { | ||
26102 | node.style[s] = style[s]; | ||
26103 | } | ||
26104 | } | ||
26105 | node.rcAnimTimeout = null; | ||
26106 | fixBrowserByTimeout(node); | ||
26107 | }, 0); | ||
26108 | }; | ||
26109 | |||
26110 | cssAnimation.setTransition = function (node, p, value) { | ||
26111 | var property = p; | ||
26112 | var v = value; | ||
26113 | if (value === undefined) { | ||
26114 | v = property; | ||
26115 | property = ''; | ||
26116 | } | ||
26117 | property = property || ''; | ||
26118 | ['Webkit', 'Moz', 'O', | ||
26119 | // ms is special .... ! | ||
26120 | 'ms'].forEach(function (prefix) { | ||
26121 | node.style[prefix + 'Transition' + property] = v; | ||
26122 | }); | ||
26123 | }; | ||
26124 | |||
26125 | cssAnimation.addClass = Css.addClass; | ||
26126 | cssAnimation.removeClass = Css.removeClass; | ||
26127 | cssAnimation.isCssAnimationSupported = isCssAnimationSupported; | ||
26128 | |||
26129 | module.exports = cssAnimation; | ||
26130 | |||
26131 | /***/ }, | ||
26132 | /* 206 */ | ||
26133 | /***/ function(module, exports) { | ||
26134 | |||
26135 | 'use strict'; | ||
26136 | |||
26137 | var EVENT_NAME_MAP = { | ||
26138 | transitionend: { | ||
26139 | transition: 'transitionend', | ||
26140 | WebkitTransition: 'webkitTransitionEnd', | ||
26141 | MozTransition: 'mozTransitionEnd', | ||
26142 | OTransition: 'oTransitionEnd', | ||
26143 | msTransition: 'MSTransitionEnd' | ||
26144 | }, | ||
26145 | |||
26146 | animationend: { | ||
26147 | animation: 'animationend', | ||
26148 | WebkitAnimation: 'webkitAnimationEnd', | ||
26149 | MozAnimation: 'mozAnimationEnd', | ||
26150 | OAnimation: 'oAnimationEnd', | ||
26151 | msAnimation: 'MSAnimationEnd' | ||
26152 | } | ||
26153 | }; | ||
26154 | |||
26155 | var endEvents = []; | ||
26156 | |||
26157 | function detectEvents() { | ||
26158 | var testEl = document.createElement('div'); | ||
26159 | var style = testEl.style; | ||
26160 | |||
26161 | if (!('AnimationEvent' in window)) { | ||
26162 | delete EVENT_NAME_MAP.animationend.animation; | ||
26163 | } | ||
26164 | |||
26165 | if (!('TransitionEvent' in window)) { | ||
26166 | delete EVENT_NAME_MAP.transitionend.transition; | ||
26167 | } | ||
26168 | |||
26169 | for (var baseEventName in EVENT_NAME_MAP) { | ||
26170 | if (EVENT_NAME_MAP.hasOwnProperty(baseEventName)) { | ||
26171 | var baseEvents = EVENT_NAME_MAP[baseEventName]; | ||
26172 | for (var styleName in baseEvents) { | ||
26173 | if (styleName in style) { | ||
26174 | endEvents.push(baseEvents[styleName]); | ||
26175 | break; | ||
26176 | } | ||
26177 | } | ||
26178 | } | ||
26179 | } | ||
26180 | } | ||
26181 | |||
26182 | if (typeof window !== 'undefined') { | ||
26183 | detectEvents(); | ||
26184 | } | ||
26185 | |||
26186 | function addEventListener(node, eventName, eventListener) { | ||
26187 | node.addEventListener(eventName, eventListener, false); | ||
26188 | } | ||
26189 | |||
26190 | function removeEventListener(node, eventName, eventListener) { | ||
26191 | node.removeEventListener(eventName, eventListener, false); | ||
26192 | } | ||
26193 | |||
26194 | var TransitionEvents = { | ||
26195 | addEndEventListener: function addEndEventListener(node, eventListener) { | ||
26196 | if (endEvents.length === 0) { | ||
26197 | window.setTimeout(eventListener, 0); | ||
26198 | return; | ||
26199 | } | ||
26200 | endEvents.forEach(function (endEvent) { | ||
26201 | addEventListener(node, endEvent, eventListener); | ||
26202 | }); | ||
26203 | }, | ||
26204 | |||
26205 | endEvents: endEvents, | ||
26206 | |||
26207 | removeEndEventListener: function removeEndEventListener(node, eventListener) { | ||
26208 | if (endEvents.length === 0) { | ||
26209 | return; | ||
26210 | } | ||
26211 | endEvents.forEach(function (endEvent) { | ||
26212 | removeEventListener(node, endEvent, eventListener); | ||
26213 | }); | ||
26214 | } | ||
26215 | }; | ||
26216 | |||
26217 | module.exports = TransitionEvents; | ||
26218 | |||
26219 | /***/ }, | ||
26220 | /* 207 */ | ||
26221 | /***/ function(module, exports) { | ||
26222 | |||
26223 | 'use strict'; | ||
26224 | |||
26225 | var SPACE = ' '; | ||
26226 | var RE_CLASS = /[\n\t\r]/g; | ||
26227 | |||
26228 | function norm(elemClass) { | ||
26229 | return (SPACE + elemClass + SPACE).replace(RE_CLASS, SPACE); | ||
26230 | } | ||
26231 | |||
26232 | module.exports = { | ||
26233 | addClass: function addClass(elem, className) { | ||
26234 | elem.className += ' ' + className; | ||
26235 | }, | ||
26236 | |||
26237 | removeClass: function removeClass(elem, n) { | ||
26238 | var elemClass = elem.className.trim(); | ||
26239 | var className = norm(elemClass); | ||
26240 | var needle = n.trim(); | ||
26241 | needle = SPACE + needle + SPACE; | ||
26242 | // 一个 cls 有可能多次出现:'link link2 link link3 link' | ||
26243 | while (className.indexOf(needle) >= 0) { | ||
26244 | className = className.replace(needle, SPACE); | ||
26245 | } | ||
26246 | elem.className = className.trim(); | ||
26247 | } | ||
26248 | }; | ||
26249 | |||
26250 | /***/ }, | ||
26251 | /* 208 */ | ||
26252 | /***/ function(module, exports) { | ||
26253 | |||
26254 | "use strict"; | ||
26255 | |||
26256 | Object.defineProperty(exports, "__esModule", { | ||
26257 | value: true | ||
26258 | }); | ||
26259 | var util = { | ||
26260 | isAppearSupported: function isAppearSupported(props) { | ||
26261 | return props.transitionName && props.transitionAppear || props.animation.appear; | ||
26262 | }, | ||
26263 | isEnterSupported: function isEnterSupported(props) { | ||
26264 | return props.transitionName && props.transitionEnter || props.animation.enter; | ||
26265 | }, | ||
26266 | isLeaveSupported: function isLeaveSupported(props) { | ||
26267 | return props.transitionName && props.transitionLeave || props.animation.leave; | ||
26268 | }, | ||
26269 | |||
26270 | allowAppearCallback: function allowAppearCallback(props) { | ||
26271 | return props.transitionAppear || props.animation.appear; | ||
26272 | }, | ||
26273 | allowEnterCallback: function allowEnterCallback(props) { | ||
26274 | return props.transitionEnter || props.animation.enter; | ||
26275 | }, | ||
26276 | allowLeaveCallback: function allowLeaveCallback(props) { | ||
26277 | return props.transitionLeave || props.animation.leave; | ||
26278 | } | ||
26279 | }; | ||
26280 | exports["default"] = util; | ||
26281 | module.exports = exports["default"]; | ||
26282 | |||
26283 | /***/ }, | ||
26284 | /* 209 */ | ||
26285 | /***/ function(module, exports, __webpack_require__) { | ||
26286 | |||
26287 | 'use strict'; | ||
26288 | |||
26289 | Object.defineProperty(exports, '__esModule', { | ||
26290 | value: true | ||
26291 | }); | ||
26292 | |||
26293 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
26294 | |||
26295 | var _react = __webpack_require__(3); | ||
26296 | |||
26297 | var _react2 = _interopRequireDefault(_react); | ||
26298 | |||
26299 | var PopupInner = _react2['default'].createClass({ | ||
26300 | displayName: 'PopupInner', | ||
26301 | |||
26302 | propTypes: { | ||
26303 | hiddenClassName: _react.PropTypes.string, | ||
26304 | className: _react.PropTypes.string, | ||
26305 | onMouseEnter: _react.PropTypes.func, | ||
26306 | onMouseLeave: _react.PropTypes.func, | ||
26307 | children: _react.PropTypes.any | ||
26308 | }, | ||
26309 | render: function render() { | ||
26310 | var props = this.props; | ||
26311 | var className = props.className; | ||
26312 | if (!props.visible) { | ||
26313 | className += ' ' + props.hiddenClassName; | ||
26314 | } | ||
26315 | return _react2['default'].createElement( | ||
26316 | 'div', | ||
26317 | { className: className, | ||
26318 | onMouseEnter: props.onMouseEnter, | ||
26319 | onMouseLeave: props.onMouseLeave, | ||
26320 | style: props.style }, | ||
26321 | props.children | ||
26322 | ); | ||
26323 | } | ||
26324 | }); | ||
26325 | |||
26326 | exports['default'] = PopupInner; | ||
26327 | module.exports = exports['default']; | ||
26328 | |||
26329 | /***/ }, | ||
26330 | /* 210 */ | ||
26331 | /***/ function(module, exports, __webpack_require__) { | ||
26332 | |||
26333 | 'use strict'; | ||
26334 | |||
26335 | Object.defineProperty(exports, '__esModule', { | ||
26336 | value: true | ||
26337 | }); | ||
26338 | exports.getAlignFromPlacement = getAlignFromPlacement; | ||
26339 | exports.getPopupClassNameFromAlign = getPopupClassNameFromAlign; | ||
26340 | |||
26341 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
26342 | |||
26343 | var _objectAssign = __webpack_require__(185); | ||
26344 | |||
26345 | var _objectAssign2 = _interopRequireDefault(_objectAssign); | ||
26346 | |||
26347 | function isPointsEq(a1, a2) { | ||
26348 | return a1[0] === a2[0] && a1[1] === a2[1]; | ||
26349 | } | ||
26350 | |||
26351 | function getAlignFromPlacement(builtinPlacements, placementStr, align) { | ||
26352 | var baseAlign = builtinPlacements[placementStr] || {}; | ||
26353 | return (0, _objectAssign2['default'])({}, baseAlign, align); | ||
26354 | } | ||
26355 | |||
26356 | function getPopupClassNameFromAlign(builtinPlacements, prefixCls, align) { | ||
26357 | var points = align.points; | ||
26358 | for (var placement in builtinPlacements) { | ||
26359 | if (builtinPlacements.hasOwnProperty(placement)) { | ||
26360 | if (isPointsEq(builtinPlacements[placement].points, points)) { | ||
26361 | return prefixCls + '-placement-' + placement; | ||
26362 | } | ||
26363 | } | ||
26364 | } | ||
26365 | return ''; | ||
26366 | } | ||
26367 | |||
26368 | /***/ }, | ||
26369 | /* 211 */ | ||
26370 | /***/ function(module, exports, __webpack_require__) { | ||
26371 | |||
26372 | module.exports = { | ||
26373 | guid: __webpack_require__(212), | ||
26374 | classSet: __webpack_require__(213), | ||
26375 | joinClasses: __webpack_require__(214), | ||
26376 | KeyCode: __webpack_require__(215), | ||
26377 | PureRenderMixin: __webpack_require__(216), | ||
26378 | shallowEqual: __webpack_require__(217), | ||
26379 | createChainedFunction: __webpack_require__(218), | ||
26380 | Dom: { | ||
26381 | addEventListener: __webpack_require__(219), | ||
26382 | contains: __webpack_require__(223) | ||
26383 | }, | ||
26384 | Children: { | ||
26385 | toArray: __webpack_require__(224), | ||
26386 | mapSelf: __webpack_require__(225) | ||
26387 | } | ||
26388 | }; | ||
26389 | |||
26390 | |||
26391 | /***/ }, | ||
26392 | /* 212 */ | ||
26393 | /***/ function(module, exports) { | ||
26394 | |||
26395 | var seed = 0; | ||
26396 | module.exports = function () { | ||
26397 | return Date.now() + '_' + (seed++); | ||
26398 | }; | ||
26399 | |||
26400 | |||
26401 | /***/ }, | ||
26402 | /* 213 */ | ||
26403 | /***/ function(module, exports, __webpack_require__) { | ||
26404 | |||
26405 | module.exports = __webpack_require__(175); | ||
26406 | |||
26407 | |||
26408 | /***/ }, | ||
26409 | /* 214 */ | ||
26410 | /***/ function(module, exports) { | ||
26411 | |||
26412 | /** | ||
26413 | * Copyright 2013-2014, Facebook, Inc. | ||
26414 | * All rights reserved. | ||
26415 | * | ||
26416 | * This file contains an unmodified version of: | ||
26417 | * https://github.com/facebook/react/blob/v0.12.0/src/utils/joinClasses.js | ||
26418 | * | ||
26419 | * This source code is licensed under the BSD-style license found here: | ||
26420 | * https://github.com/facebook/react/blob/v0.12.0/LICENSE | ||
26421 | * An additional grant of patent rights can be found here: | ||
26422 | * https://github.com/facebook/react/blob/v0.12.0/PATENTS | ||
26423 | */ | ||
26424 | |||
26425 | "use strict"; | ||
26426 | |||
26427 | /** | ||
26428 | * Combines multiple className strings into one. | ||
26429 | * http://jsperf.com/joinclasses-args-vs-array | ||
26430 | * | ||
26431 | * @param {...?string} classes | ||
26432 | * @return {string} | ||
26433 | */ | ||
26434 | |||
26435 | function joinClasses(className /*, ... */ ) { | ||
26436 | if (!className) { | ||
26437 | className = ''; | ||
26438 | } | ||
26439 | var nextClass; | ||
26440 | var argLength = arguments.length; | ||
26441 | if (argLength > 1) { | ||
26442 | for (var ii = 1; ii < argLength; ii++) { | ||
26443 | nextClass = arguments[ii]; | ||
26444 | if (nextClass) { | ||
26445 | className = (className ? className + ' ' : '') + nextClass; | ||
26446 | } | ||
26447 | } | ||
26448 | } | ||
26449 | return className; | ||
26450 | } | ||
26451 | |||
26452 | module.exports = joinClasses; | ||
26453 | |||
26454 | |||
26455 | /***/ }, | ||
26456 | /* 215 */ | ||
26457 | /***/ function(module, exports) { | ||
26458 | |||
26459 | /** | ||
26460 | * @ignore | ||
26461 | * some key-codes definition and utils from closure-library | ||
26462 | * @author yiminghe@gmail.com | ||
26463 | */ | ||
26464 | |||
26465 | var KeyCode = { | ||
26466 | /** | ||
26467 | * MAC_ENTER | ||
26468 | */ | ||
26469 | MAC_ENTER: 3, | ||
26470 | /** | ||
26471 | * BACKSPACE | ||
26472 | */ | ||
26473 | BACKSPACE: 8, | ||
26474 | /** | ||
26475 | * TAB | ||
26476 | */ | ||
26477 | TAB: 9, | ||
26478 | /** | ||
26479 | * NUMLOCK on FF/Safari Mac | ||
26480 | */ | ||
26481 | NUM_CENTER: 12, // NUMLOCK on FF/Safari Mac | ||
26482 | /** | ||
26483 | * ENTER | ||
26484 | */ | ||
26485 | ENTER: 13, | ||
26486 | /** | ||
26487 | * SHIFT | ||
26488 | */ | ||
26489 | SHIFT: 16, | ||
26490 | /** | ||
26491 | * CTRL | ||
26492 | */ | ||
26493 | CTRL: 17, | ||
26494 | /** | ||
26495 | * ALT | ||
26496 | */ | ||
26497 | ALT: 18, | ||
26498 | /** | ||
26499 | * PAUSE | ||
26500 | */ | ||
26501 | PAUSE: 19, | ||
26502 | /** | ||
26503 | * CAPS_LOCK | ||
26504 | */ | ||
26505 | CAPS_LOCK: 20, | ||
26506 | /** | ||
26507 | * ESC | ||
26508 | */ | ||
26509 | ESC: 27, | ||
26510 | /** | ||
26511 | * SPACE | ||
26512 | */ | ||
26513 | SPACE: 32, | ||
26514 | /** | ||
26515 | * PAGE_UP | ||
26516 | */ | ||
26517 | PAGE_UP: 33, // also NUM_NORTH_EAST | ||
26518 | /** | ||
26519 | * PAGE_DOWN | ||
26520 | */ | ||
26521 | PAGE_DOWN: 34, // also NUM_SOUTH_EAST | ||
26522 | /** | ||
26523 | * END | ||
26524 | */ | ||
26525 | END: 35, // also NUM_SOUTH_WEST | ||
26526 | /** | ||
26527 | * HOME | ||
26528 | */ | ||
26529 | HOME: 36, // also NUM_NORTH_WEST | ||
26530 | /** | ||
26531 | * LEFT | ||
26532 | */ | ||
26533 | LEFT: 37, // also NUM_WEST | ||
26534 | /** | ||
26535 | * UP | ||
26536 | */ | ||
26537 | UP: 38, // also NUM_NORTH | ||
26538 | /** | ||
26539 | * RIGHT | ||
26540 | */ | ||
26541 | RIGHT: 39, // also NUM_EAST | ||
26542 | /** | ||
26543 | * DOWN | ||
26544 | */ | ||
26545 | DOWN: 40, // also NUM_SOUTH | ||
26546 | /** | ||
26547 | * PRINT_SCREEN | ||
26548 | */ | ||
26549 | PRINT_SCREEN: 44, | ||
26550 | /** | ||
26551 | * INSERT | ||
26552 | */ | ||
26553 | INSERT: 45, // also NUM_INSERT | ||
26554 | /** | ||
26555 | * DELETE | ||
26556 | */ | ||
26557 | DELETE: 46, // also NUM_DELETE | ||
26558 | /** | ||
26559 | * ZERO | ||
26560 | */ | ||
26561 | ZERO: 48, | ||
26562 | /** | ||
26563 | * ONE | ||
26564 | */ | ||
26565 | ONE: 49, | ||
26566 | /** | ||
26567 | * TWO | ||
26568 | */ | ||
26569 | TWO: 50, | ||
26570 | /** | ||
26571 | * THREE | ||
26572 | */ | ||
26573 | THREE: 51, | ||
26574 | /** | ||
26575 | * FOUR | ||
26576 | */ | ||
26577 | FOUR: 52, | ||
26578 | /** | ||
26579 | * FIVE | ||
26580 | */ | ||
26581 | FIVE: 53, | ||
26582 | /** | ||
26583 | * SIX | ||
26584 | */ | ||
26585 | SIX: 54, | ||
26586 | /** | ||
26587 | * SEVEN | ||
26588 | */ | ||
26589 | SEVEN: 55, | ||
26590 | /** | ||
26591 | * EIGHT | ||
26592 | */ | ||
26593 | EIGHT: 56, | ||
26594 | /** | ||
26595 | * NINE | ||
26596 | */ | ||
26597 | NINE: 57, | ||
26598 | /** | ||
26599 | * QUESTION_MARK | ||
26600 | */ | ||
26601 | QUESTION_MARK: 63, // needs localization | ||
26602 | /** | ||
26603 | * A | ||
26604 | */ | ||
26605 | A: 65, | ||
26606 | /** | ||
26607 | * B | ||
26608 | */ | ||
26609 | B: 66, | ||
26610 | /** | ||
26611 | * C | ||
26612 | */ | ||
26613 | C: 67, | ||
26614 | /** | ||
26615 | * D | ||
26616 | */ | ||
26617 | D: 68, | ||
26618 | /** | ||
26619 | * E | ||
26620 | */ | ||
26621 | E: 69, | ||
26622 | /** | ||
26623 | * F | ||
26624 | */ | ||
26625 | F: 70, | ||
26626 | /** | ||
26627 | * G | ||
26628 | */ | ||
26629 | G: 71, | ||
26630 | /** | ||
26631 | * H | ||
26632 | */ | ||
26633 | H: 72, | ||
26634 | /** | ||
26635 | * I | ||
26636 | */ | ||
26637 | I: 73, | ||
26638 | /** | ||
26639 | * J | ||
26640 | */ | ||
26641 | J: 74, | ||
26642 | /** | ||
26643 | * K | ||
26644 | */ | ||
26645 | K: 75, | ||
26646 | /** | ||
26647 | * L | ||
26648 | */ | ||
26649 | L: 76, | ||
26650 | /** | ||
26651 | * M | ||
26652 | */ | ||
26653 | M: 77, | ||
26654 | /** | ||
26655 | * N | ||
26656 | */ | ||
26657 | N: 78, | ||
26658 | /** | ||
26659 | * O | ||
26660 | */ | ||
26661 | O: 79, | ||
26662 | /** | ||
26663 | * P | ||
26664 | */ | ||
26665 | P: 80, | ||
26666 | /** | ||
26667 | * Q | ||
26668 | */ | ||
26669 | Q: 81, | ||
26670 | /** | ||
26671 | * R | ||
26672 | */ | ||
26673 | R: 82, | ||
26674 | /** | ||
26675 | * S | ||
26676 | */ | ||
26677 | S: 83, | ||
26678 | /** | ||
26679 | * T | ||
26680 | */ | ||
26681 | T: 84, | ||
26682 | /** | ||
26683 | * U | ||
26684 | */ | ||
26685 | U: 85, | ||
26686 | /** | ||
26687 | * V | ||
26688 | */ | ||
26689 | V: 86, | ||
26690 | /** | ||
26691 | * W | ||
26692 | */ | ||
26693 | W: 87, | ||
26694 | /** | ||
26695 | * X | ||
26696 | */ | ||
26697 | X: 88, | ||
26698 | /** | ||
26699 | * Y | ||
26700 | */ | ||
26701 | Y: 89, | ||
26702 | /** | ||
26703 | * Z | ||
26704 | */ | ||
26705 | Z: 90, | ||
26706 | /** | ||
26707 | * META | ||
26708 | */ | ||
26709 | META: 91, // WIN_KEY_LEFT | ||
26710 | /** | ||
26711 | * WIN_KEY_RIGHT | ||
26712 | */ | ||
26713 | WIN_KEY_RIGHT: 92, | ||
26714 | /** | ||
26715 | * CONTEXT_MENU | ||
26716 | */ | ||
26717 | CONTEXT_MENU: 93, | ||
26718 | /** | ||
26719 | * NUM_ZERO | ||
26720 | */ | ||
26721 | NUM_ZERO: 96, | ||
26722 | /** | ||
26723 | * NUM_ONE | ||
26724 | */ | ||
26725 | NUM_ONE: 97, | ||
26726 | /** | ||
26727 | * NUM_TWO | ||
26728 | */ | ||
26729 | NUM_TWO: 98, | ||
26730 | /** | ||
26731 | * NUM_THREE | ||
26732 | */ | ||
26733 | NUM_THREE: 99, | ||
26734 | /** | ||
26735 | * NUM_FOUR | ||
26736 | */ | ||
26737 | NUM_FOUR: 100, | ||
26738 | /** | ||
26739 | * NUM_FIVE | ||
26740 | */ | ||
26741 | NUM_FIVE: 101, | ||
26742 | /** | ||
26743 | * NUM_SIX | ||
26744 | */ | ||
26745 | NUM_SIX: 102, | ||
26746 | /** | ||
26747 | * NUM_SEVEN | ||
26748 | */ | ||
26749 | NUM_SEVEN: 103, | ||
26750 | /** | ||
26751 | * NUM_EIGHT | ||
26752 | */ | ||
26753 | NUM_EIGHT: 104, | ||
26754 | /** | ||
26755 | * NUM_NINE | ||
26756 | */ | ||
26757 | NUM_NINE: 105, | ||
26758 | /** | ||
26759 | * NUM_MULTIPLY | ||
26760 | */ | ||
26761 | NUM_MULTIPLY: 106, | ||
26762 | /** | ||
26763 | * NUM_PLUS | ||
26764 | */ | ||
26765 | NUM_PLUS: 107, | ||
26766 | /** | ||
26767 | * NUM_MINUS | ||
26768 | */ | ||
26769 | NUM_MINUS: 109, | ||
26770 | /** | ||
26771 | * NUM_PERIOD | ||
26772 | */ | ||
26773 | NUM_PERIOD: 110, | ||
26774 | /** | ||
26775 | * NUM_DIVISION | ||
26776 | */ | ||
26777 | NUM_DIVISION: 111, | ||
26778 | /** | ||
26779 | * F1 | ||
26780 | */ | ||
26781 | F1: 112, | ||
26782 | /** | ||
26783 | * F2 | ||
26784 | */ | ||
26785 | F2: 113, | ||
26786 | /** | ||
26787 | * F3 | ||
26788 | */ | ||
26789 | F3: 114, | ||
26790 | /** | ||
26791 | * F4 | ||
26792 | */ | ||
26793 | F4: 115, | ||
26794 | /** | ||
26795 | * F5 | ||
26796 | */ | ||
26797 | F5: 116, | ||
26798 | /** | ||
26799 | * F6 | ||
26800 | */ | ||
26801 | F6: 117, | ||
26802 | /** | ||
26803 | * F7 | ||
26804 | */ | ||
26805 | F7: 118, | ||
26806 | /** | ||
26807 | * F8 | ||
26808 | */ | ||
26809 | F8: 119, | ||
26810 | /** | ||
26811 | * F9 | ||
26812 | */ | ||
26813 | F9: 120, | ||
26814 | /** | ||
26815 | * F10 | ||
26816 | */ | ||
26817 | F10: 121, | ||
26818 | /** | ||
26819 | * F11 | ||
26820 | */ | ||
26821 | F11: 122, | ||
26822 | /** | ||
26823 | * F12 | ||
26824 | */ | ||
26825 | F12: 123, | ||
26826 | /** | ||
26827 | * NUMLOCK | ||
26828 | */ | ||
26829 | NUMLOCK: 144, | ||
26830 | /** | ||
26831 | * SEMICOLON | ||
26832 | */ | ||
26833 | SEMICOLON: 186, // needs localization | ||
26834 | /** | ||
26835 | * DASH | ||
26836 | */ | ||
26837 | DASH: 189, // needs localization | ||
26838 | /** | ||
26839 | * EQUALS | ||
26840 | */ | ||
26841 | EQUALS: 187, // needs localization | ||
26842 | /** | ||
26843 | * COMMA | ||
26844 | */ | ||
26845 | COMMA: 188, // needs localization | ||
26846 | /** | ||
26847 | * PERIOD | ||
26848 | */ | ||
26849 | PERIOD: 190, // needs localization | ||
26850 | /** | ||
26851 | * SLASH | ||
26852 | */ | ||
26853 | SLASH: 191, // needs localization | ||
26854 | /** | ||
26855 | * APOSTROPHE | ||
26856 | */ | ||
26857 | APOSTROPHE: 192, // needs localization | ||
26858 | /** | ||
26859 | * SINGLE_QUOTE | ||
26860 | */ | ||
26861 | SINGLE_QUOTE: 222, // needs localization | ||
26862 | /** | ||
26863 | * OPEN_SQUARE_BRACKET | ||
26864 | */ | ||
26865 | OPEN_SQUARE_BRACKET: 219, // needs localization | ||
26866 | /** | ||
26867 | * BACKSLASH | ||
26868 | */ | ||
26869 | BACKSLASH: 220, // needs localization | ||
26870 | /** | ||
26871 | * CLOSE_SQUARE_BRACKET | ||
26872 | */ | ||
26873 | CLOSE_SQUARE_BRACKET: 221, // needs localization | ||
26874 | /** | ||
26875 | * WIN_KEY | ||
26876 | */ | ||
26877 | WIN_KEY: 224, | ||
26878 | /** | ||
26879 | * MAC_FF_META | ||
26880 | */ | ||
26881 | MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91 | ||
26882 | /** | ||
26883 | * WIN_IME | ||
26884 | */ | ||
26885 | WIN_IME: 229 | ||
26886 | }; | ||
26887 | |||
26888 | /* | ||
26889 | whether text and modified key is entered at the same time. | ||
26890 | */ | ||
26891 | KeyCode.isTextModifyingKeyEvent = function (e) { | ||
26892 | var keyCode = e.keyCode; | ||
26893 | if (e.altKey && !e.ctrlKey || e.metaKey || | ||
26894 | // Function keys don't generate text | ||
26895 | keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) { | ||
26896 | return false; | ||
26897 | } | ||
26898 | |||
26899 | // The following keys are quite harmless, even in combination with | ||
26900 | // CTRL, ALT or SHIFT. | ||
26901 | switch (keyCode) { | ||
26902 | case KeyCode.ALT: | ||
26903 | case KeyCode.CAPS_LOCK: | ||
26904 | case KeyCode.CONTEXT_MENU: | ||
26905 | case KeyCode.CTRL: | ||
26906 | case KeyCode.DOWN: | ||
26907 | case KeyCode.END: | ||
26908 | case KeyCode.ESC: | ||
26909 | case KeyCode.HOME: | ||
26910 | case KeyCode.INSERT: | ||
26911 | case KeyCode.LEFT: | ||
26912 | case KeyCode.MAC_FF_META: | ||
26913 | case KeyCode.META: | ||
26914 | case KeyCode.NUMLOCK: | ||
26915 | case KeyCode.NUM_CENTER: | ||
26916 | case KeyCode.PAGE_DOWN: | ||
26917 | case KeyCode.PAGE_UP: | ||
26918 | case KeyCode.PAUSE: | ||
26919 | case KeyCode.PRINT_SCREEN: | ||
26920 | case KeyCode.RIGHT: | ||
26921 | case KeyCode.SHIFT: | ||
26922 | case KeyCode.UP: | ||
26923 | case KeyCode.WIN_KEY: | ||
26924 | case KeyCode.WIN_KEY_RIGHT: | ||
26925 | return false; | ||
26926 | default: | ||
26927 | return true; | ||
26928 | } | ||
26929 | }; | ||
26930 | |||
26931 | /* | ||
26932 | whether character is entered. | ||
26933 | */ | ||
26934 | KeyCode.isCharacterKey = function (keyCode) { | ||
26935 | if (keyCode >= KeyCode.ZERO && | ||
26936 | keyCode <= KeyCode.NINE) { | ||
26937 | return true; | ||
26938 | } | ||
26939 | |||
26940 | if (keyCode >= KeyCode.NUM_ZERO && | ||
26941 | keyCode <= KeyCode.NUM_MULTIPLY) { | ||
26942 | return true; | ||
26943 | } | ||
26944 | |||
26945 | if (keyCode >= KeyCode.A && | ||
26946 | keyCode <= KeyCode.Z) { | ||
26947 | return true; | ||
26948 | } | ||
26949 | |||
26950 | // Safari sends zero key code for non-latin characters. | ||
26951 | if (window.navigation.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) { | ||
26952 | return true; | ||
26953 | } | ||
26954 | |||
26955 | switch (keyCode) { | ||
26956 | case KeyCode.SPACE: | ||
26957 | case KeyCode.QUESTION_MARK: | ||
26958 | case KeyCode.NUM_PLUS: | ||
26959 | case KeyCode.NUM_MINUS: | ||
26960 | case KeyCode.NUM_PERIOD: | ||
26961 | case KeyCode.NUM_DIVISION: | ||
26962 | case KeyCode.SEMICOLON: | ||
26963 | case KeyCode.DASH: | ||
26964 | case KeyCode.EQUALS: | ||
26965 | case KeyCode.COMMA: | ||
26966 | case KeyCode.PERIOD: | ||
26967 | case KeyCode.SLASH: | ||
26968 | case KeyCode.APOSTROPHE: | ||
26969 | case KeyCode.SINGLE_QUOTE: | ||
26970 | case KeyCode.OPEN_SQUARE_BRACKET: | ||
26971 | case KeyCode.BACKSLASH: | ||
26972 | case KeyCode.CLOSE_SQUARE_BRACKET: | ||
26973 | return true; | ||
26974 | default: | ||
26975 | return false; | ||
26976 | } | ||
26977 | }; | ||
26978 | |||
26979 | module.exports = KeyCode; | ||
26980 | |||
26981 | |||
26982 | /***/ }, | ||
26983 | /* 216 */ | ||
26984 | /***/ function(module, exports, __webpack_require__) { | ||
26985 | |||
26986 | /** | ||
26987 | * Copyright 2013-2014, Facebook, Inc. | ||
26988 | * All rights reserved. | ||
26989 | * | ||
26990 | * This source code is licensed under the BSD-style license found in the | ||
26991 | * LICENSE file in the root directory of this source tree. An additional grant | ||
26992 | * of patent rights can be found in the PATENTS file in the same directory. | ||
26993 | * | ||
26994 | * @providesModule ReactComponentWithPureRenderMixin | ||
26995 | */ | ||
26996 | |||
26997 | "use strict"; | ||
26998 | |||
26999 | var shallowEqual = __webpack_require__(217); | ||
27000 | |||
27001 | /** | ||
27002 | * If your React component's render function is "pure", e.g. it will render the | ||
27003 | * same result given the same props and state, provide this Mixin for a | ||
27004 | * considerable performance boost. | ||
27005 | * | ||
27006 | * Most React components have pure render functions. | ||
27007 | * | ||
27008 | * Example: | ||
27009 | * | ||
27010 | * var ReactComponentWithPureRenderMixin = | ||
27011 | * require('ReactComponentWithPureRenderMixin'); | ||
27012 | * React.createClass({ | ||
27013 | * mixins: [ReactComponentWithPureRenderMixin], | ||
27014 | * | ||
27015 | * render: function() { | ||
27016 | * return <div className={this.props.className}>foo</div>; | ||
27017 | * } | ||
27018 | * }); | ||
27019 | * | ||
27020 | * Note: This only checks shallow equality for props and state. If these contain | ||
27021 | * complex data structures this mixin may have false-negatives for deeper | ||
27022 | * differences. Only mixin to components which have simple props and state, or | ||
27023 | * use `forceUpdate()` when you know deep data structures have changed. | ||
27024 | */ | ||
27025 | var ReactComponentWithPureRenderMixin = { | ||
27026 | shouldComponentUpdate: function(nextProps, nextState) { | ||
27027 | return !shallowEqual(this.props, nextProps) || | ||
27028 | !shallowEqual(this.state, nextState); | ||
27029 | } | ||
27030 | }; | ||
27031 | |||
27032 | module.exports = ReactComponentWithPureRenderMixin; | ||
27033 | |||
27034 | |||
27035 | /***/ }, | ||
27036 | /* 217 */ | ||
27037 | /***/ function(module, exports) { | ||
27038 | |||
27039 | /** | ||
27040 | * Copyright 2013-2014, Facebook, Inc. | ||
27041 | * All rights reserved. | ||
27042 | * | ||
27043 | * This source code is licensed under the BSD-style license found in the | ||
27044 | * LICENSE file in the root directory of this source tree. An additional grant | ||
27045 | * of patent rights can be found in the PATENTS file in the same directory. | ||
27046 | * | ||
27047 | * @providesModule shallowEqual | ||
27048 | */ | ||
27049 | |||
27050 | "use strict"; | ||
27051 | |||
27052 | /** | ||
27053 | * Performs equality by iterating through keys on an object and returning | ||
27054 | * false when any key has values which are not strictly equal between | ||
27055 | * objA and objB. Returns true when the values of all keys are strictly equal. | ||
27056 | * | ||
27057 | * @return {boolean} | ||
27058 | */ | ||
27059 | function shallowEqual(objA, objB) { | ||
27060 | if (objA === objB) { | ||
27061 | return true; | ||
27062 | } | ||
27063 | var key; | ||
27064 | // Test for A's keys different from B. | ||
27065 | for (key in objA) { | ||
27066 | if (objA.hasOwnProperty(key) && | ||
27067 | (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) { | ||
27068 | return false; | ||
27069 | } | ||
27070 | } | ||
27071 | // Test for B's keys missing from A. | ||
27072 | for (key in objB) { | ||
27073 | if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) { | ||
27074 | return false; | ||
27075 | } | ||
27076 | } | ||
27077 | return true; | ||
27078 | } | ||
27079 | |||
27080 | module.exports = shallowEqual; | ||
27081 | |||
27082 | |||
27083 | /***/ }, | ||
27084 | /* 218 */ | ||
27085 | /***/ function(module, exports) { | ||
27086 | |||
27087 | /** | ||
27088 | * Safe chained function | ||
27089 | * | ||
27090 | * Will only create a new function if needed, | ||
27091 | * otherwise will pass back existing functions or null. | ||
27092 | * | ||
27093 | * @returns {function|null} | ||
27094 | */ | ||
27095 | function createChainedFunction() { | ||
27096 | var args = arguments; | ||
27097 | |||
27098 | return function chainedFunction() { | ||
27099 | for (var i = 0; i < args.length; i++) { | ||
27100 | if (args[i] && args[i].apply) { | ||
27101 | args[i].apply(this, arguments); | ||
27102 | } | ||
27103 | } | ||
27104 | }; | ||
27105 | } | ||
27106 | |||
27107 | module.exports = createChainedFunction; | ||
27108 | |||
27109 | |||
27110 | /***/ }, | ||
27111 | /* 219 */ | ||
27112 | /***/ function(module, exports, __webpack_require__) { | ||
27113 | |||
27114 | var addDOMEventListener = __webpack_require__(220); | ||
27115 | |||
27116 | module.exports = addDOMEventListener['default'] || addDOMEventListener; | ||
27117 | |||
27118 | |||
27119 | /***/ }, | ||
27120 | /* 220 */ | ||
27121 | /***/ function(module, exports, __webpack_require__) { | ||
27122 | |||
27123 | 'use strict'; | ||
27124 | |||
27125 | Object.defineProperty(exports, '__esModule', { | ||
27126 | value: true | ||
27127 | }); | ||
27128 | exports['default'] = addEventListener; | ||
27129 | |||
27130 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
27131 | |||
27132 | var _EventObject = __webpack_require__(221); | ||
27133 | |||
27134 | var _EventObject2 = _interopRequireDefault(_EventObject); | ||
27135 | |||
27136 | function addEventListener(target, eventType, callback) { | ||
27137 | function wrapCallback(e) { | ||
27138 | var ne = new _EventObject2['default'](e); | ||
27139 | callback.call(target, ne); | ||
27140 | } | ||
27141 | |||
27142 | if (target.addEventListener) { | ||
27143 | target.addEventListener(eventType, wrapCallback, false); | ||
27144 | return { | ||
27145 | remove: function remove() { | ||
27146 | target.removeEventListener(eventType, wrapCallback, false); | ||
27147 | } | ||
27148 | }; | ||
27149 | } else if (target.attachEvent) { | ||
27150 | target.attachEvent('on' + eventType, wrapCallback); | ||
27151 | return { | ||
27152 | remove: function remove() { | ||
27153 | target.detachEvent('on' + eventType, wrapCallback); | ||
27154 | } | ||
27155 | }; | ||
27156 | } | ||
27157 | } | ||
27158 | |||
27159 | module.exports = exports['default']; | ||
27160 | |||
27161 | /***/ }, | ||
27162 | /* 221 */ | ||
27163 | /***/ function(module, exports, __webpack_require__) { | ||
27164 | |||
27165 | /** | ||
27166 | * @ignore | ||
27167 | * event object for dom | ||
27168 | * @author yiminghe@gmail.com | ||
27169 | */ | ||
27170 | |||
27171 | 'use strict'; | ||
27172 | |||
27173 | Object.defineProperty(exports, '__esModule', { | ||
27174 | value: true | ||
27175 | }); | ||
27176 | |||
27177 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
27178 | |||
27179 | var _EventBaseObject = __webpack_require__(222); | ||
27180 | |||
27181 | var _EventBaseObject2 = _interopRequireDefault(_EventBaseObject); | ||
27182 | |||
27183 | var _objectAssign = __webpack_require__(185); | ||
27184 | |||
27185 | var _objectAssign2 = _interopRequireDefault(_objectAssign); | ||
27186 | |||
27187 | var TRUE = true; | ||
27188 | var FALSE = false; | ||
27189 | var commonProps = ['altKey', 'bubbles', 'cancelable', 'ctrlKey', 'currentTarget', 'eventPhase', 'metaKey', 'shiftKey', 'target', 'timeStamp', 'view', 'type']; | ||
27190 | |||
27191 | function isNullOrUndefined(w) { | ||
27192 | return w === null || w === undefined; | ||
27193 | } | ||
27194 | |||
27195 | var eventNormalizers = [{ | ||
27196 | reg: /^key/, | ||
27197 | props: ['char', 'charCode', 'key', 'keyCode', 'which'], | ||
27198 | fix: function fix(event, nativeEvent) { | ||
27199 | if (isNullOrUndefined(event.which)) { | ||
27200 | event.which = !isNullOrUndefined(nativeEvent.charCode) ? nativeEvent.charCode : nativeEvent.keyCode; | ||
27201 | } | ||
27202 | |||
27203 | // add metaKey to non-Mac browsers (use ctrl for PC 's and Meta for Macs) | ||
27204 | if (event.metaKey === undefined) { | ||
27205 | event.metaKey = event.ctrlKey; | ||
27206 | } | ||
27207 | } | ||
27208 | }, { | ||
27209 | reg: /^touch/, | ||
27210 | props: ['touches', 'changedTouches', 'targetTouches'] | ||
27211 | }, { | ||
27212 | reg: /^hashchange$/, | ||
27213 | props: ['newURL', 'oldURL'] | ||
27214 | }, { | ||
27215 | reg: /^gesturechange$/i, | ||
27216 | props: ['rotation', 'scale'] | ||
27217 | }, { | ||
27218 | reg: /^(mousewheel|DOMMouseScroll)$/, | ||
27219 | props: [], | ||
27220 | fix: function fix(event, nativeEvent) { | ||
27221 | var deltaX = undefined; | ||
27222 | var deltaY = undefined; | ||
27223 | var delta = undefined; | ||
27224 | var wheelDelta = nativeEvent.wheelDelta; | ||
27225 | var axis = nativeEvent.axis; | ||
27226 | var wheelDeltaY = nativeEvent.wheelDeltaY; | ||
27227 | var wheelDeltaX = nativeEvent.wheelDeltaX; | ||
27228 | var detail = nativeEvent.detail; | ||
27229 | |||
27230 | // ie/webkit | ||
27231 | if (wheelDelta) { | ||
27232 | delta = wheelDelta / 120; | ||
27233 | } | ||
27234 | |||
27235 | // gecko | ||
27236 | if (detail) { | ||
27237 | // press control e.detail == 1 else e.detail == 3 | ||
27238 | delta = 0 - (detail % 3 === 0 ? detail / 3 : detail); | ||
27239 | } | ||
27240 | |||
27241 | // Gecko | ||
27242 | if (axis !== undefined) { | ||
27243 | if (axis === event.HORIZONTAL_AXIS) { | ||
27244 | deltaY = 0; | ||
27245 | deltaX = 0 - delta; | ||
27246 | } else if (axis === event.VERTICAL_AXIS) { | ||
27247 | deltaX = 0; | ||
27248 | deltaY = delta; | ||
27249 | } | ||
27250 | } | ||
27251 | |||
27252 | // Webkit | ||
27253 | if (wheelDeltaY !== undefined) { | ||
27254 | deltaY = wheelDeltaY / 120; | ||
27255 | } | ||
27256 | if (wheelDeltaX !== undefined) { | ||
27257 | deltaX = -1 * wheelDeltaX / 120; | ||
27258 | } | ||
27259 | |||
27260 | // 默认 deltaY (ie) | ||
27261 | if (!deltaX && !deltaY) { | ||
27262 | deltaY = delta; | ||
27263 | } | ||
27264 | |||
27265 | if (deltaX !== undefined) { | ||
27266 | /** | ||
27267 | * deltaX of mousewheel event | ||
27268 | * @property deltaX | ||
27269 | * @member Event.DomEvent.Object | ||
27270 | */ | ||
27271 | event.deltaX = deltaX; | ||
27272 | } | ||
27273 | |||
27274 | if (deltaY !== undefined) { | ||
27275 | /** | ||
27276 | * deltaY of mousewheel event | ||
27277 | * @property deltaY | ||
27278 | * @member Event.DomEvent.Object | ||
27279 | */ | ||
27280 | event.deltaY = deltaY; | ||
27281 | } | ||
27282 | |||
27283 | if (delta !== undefined) { | ||
27284 | /** | ||
27285 | * delta of mousewheel event | ||
27286 | * @property delta | ||
27287 | * @member Event.DomEvent.Object | ||
27288 | */ | ||
27289 | event.delta = delta; | ||
27290 | } | ||
27291 | } | ||
27292 | }, { | ||
27293 | reg: /^mouse|contextmenu|click|mspointer|(^DOMMouseScroll$)/i, | ||
27294 | props: ['buttons', 'clientX', 'clientY', 'button', 'offsetX', 'relatedTarget', 'which', 'fromElement', 'toElement', 'offsetY', 'pageX', 'pageY', 'screenX', 'screenY'], | ||
27295 | fix: function fix(event, nativeEvent) { | ||
27296 | var eventDoc = undefined; | ||
27297 | var doc = undefined; | ||
27298 | var body = undefined; | ||
27299 | var target = event.target; | ||
27300 | var button = nativeEvent.button; | ||
27301 | |||
27302 | // Calculate pageX/Y if missing and clientX/Y available | ||
27303 | if (target && isNullOrUndefined(event.pageX) && !isNullOrUndefined(nativeEvent.clientX)) { | ||
27304 | eventDoc = target.ownerDocument || document; | ||
27305 | doc = eventDoc.documentElement; | ||
27306 | body = eventDoc.body; | ||
27307 | event.pageX = nativeEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); | ||
27308 | event.pageY = nativeEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); | ||
27309 | } | ||
27310 | |||
27311 | // which for click: 1 === left; 2 === middle; 3 === right | ||
27312 | // do not use button | ||
27313 | if (!event.which && button !== undefined) { | ||
27314 | if (button & 1) { | ||
27315 | event.which = 1; | ||
27316 | } else if (button & 2) { | ||
27317 | event.which = 3; | ||
27318 | } else if (button & 4) { | ||
27319 | event.which = 2; | ||
27320 | } else { | ||
27321 | event.which = 0; | ||
27322 | } | ||
27323 | } | ||
27324 | |||
27325 | // add relatedTarget, if necessary | ||
27326 | if (!event.relatedTarget && event.fromElement) { | ||
27327 | event.relatedTarget = event.fromElement === target ? event.toElement : event.fromElement; | ||
27328 | } | ||
27329 | |||
27330 | return event; | ||
27331 | } | ||
27332 | }]; | ||
27333 | |||
27334 | function retTrue() { | ||
27335 | return TRUE; | ||
27336 | } | ||
27337 | |||
27338 | function retFalse() { | ||
27339 | return FALSE; | ||
27340 | } | ||
27341 | |||
27342 | function DomEventObject(nativeEvent) { | ||
27343 | var type = nativeEvent.type; | ||
27344 | |||
27345 | var isNative = typeof nativeEvent.stopPropagation === 'function' || typeof nativeEvent.cancelBubble === 'boolean'; | ||
27346 | |||
27347 | _EventBaseObject2['default'].call(this); | ||
27348 | |||
27349 | this.nativeEvent = nativeEvent; | ||
27350 | |||
27351 | // in case dom event has been mark as default prevented by lower dom node | ||
27352 | var isDefaultPrevented = retFalse; | ||
27353 | if ('defaultPrevented' in nativeEvent) { | ||
27354 | isDefaultPrevented = nativeEvent.defaultPrevented ? retTrue : retFalse; | ||
27355 | } else if ('getPreventDefault' in nativeEvent) { | ||
27356 | // https://bugzilla.mozilla.org/show_bug.cgi?id=691151 | ||
27357 | isDefaultPrevented = nativeEvent.getPreventDefault() ? retTrue : retFalse; | ||
27358 | } else if ('returnValue' in nativeEvent) { | ||
27359 | isDefaultPrevented = nativeEvent.returnValue === FALSE ? retTrue : retFalse; | ||
27360 | } | ||
27361 | |||
27362 | this.isDefaultPrevented = isDefaultPrevented; | ||
27363 | |||
27364 | var fixFns = []; | ||
27365 | var fixFn = undefined; | ||
27366 | var l = undefined; | ||
27367 | var prop = undefined; | ||
27368 | var props = commonProps.concat(); | ||
27369 | |||
27370 | eventNormalizers.forEach(function (normalizer) { | ||
27371 | if (type.match(normalizer.reg)) { | ||
27372 | props = props.concat(normalizer.props); | ||
27373 | if (normalizer.fix) { | ||
27374 | fixFns.push(normalizer.fix); | ||
27375 | } | ||
27376 | } | ||
27377 | }); | ||
27378 | |||
27379 | l = props.length; | ||
27380 | |||
27381 | // clone properties of the original event object | ||
27382 | while (l) { | ||
27383 | prop = props[--l]; | ||
27384 | this[prop] = nativeEvent[prop]; | ||
27385 | } | ||
27386 | |||
27387 | // fix target property, if necessary | ||
27388 | if (!this.target && isNative) { | ||
27389 | this.target = nativeEvent.srcElement || document; // srcElement might not be defined either | ||
27390 | } | ||
27391 | |||
27392 | // check if target is a text node (safari) | ||
27393 | if (this.target && this.target.nodeType === 3) { | ||
27394 | this.target = this.target.parentNode; | ||
27395 | } | ||
27396 | |||
27397 | l = fixFns.length; | ||
27398 | |||
27399 | while (l) { | ||
27400 | fixFn = fixFns[--l]; | ||
27401 | fixFn(this, nativeEvent); | ||
27402 | } | ||
27403 | |||
27404 | this.timeStamp = nativeEvent.timeStamp || Date.now(); | ||
27405 | } | ||
27406 | |||
27407 | var EventBaseObjectProto = _EventBaseObject2['default'].prototype; | ||
27408 | |||
27409 | (0, _objectAssign2['default'])(DomEventObject.prototype, EventBaseObjectProto, { | ||
27410 | constructor: DomEventObject, | ||
27411 | |||
27412 | preventDefault: function preventDefault() { | ||
27413 | var e = this.nativeEvent; | ||
27414 | |||
27415 | // if preventDefault exists run it on the original event | ||
27416 | if (e.preventDefault) { | ||
27417 | e.preventDefault(); | ||
27418 | } else { | ||
27419 | // otherwise set the returnValue property of the original event to FALSE (IE) | ||
27420 | e.returnValue = FALSE; | ||
27421 | } | ||
27422 | |||
27423 | EventBaseObjectProto.preventDefault.call(this); | ||
27424 | }, | ||
27425 | |||
27426 | stopPropagation: function stopPropagation() { | ||
27427 | var e = this.nativeEvent; | ||
27428 | |||
27429 | // if stopPropagation exists run it on the original event | ||
27430 | if (e.stopPropagation) { | ||
27431 | e.stopPropagation(); | ||
27432 | } else { | ||
27433 | // otherwise set the cancelBubble property of the original event to TRUE (IE) | ||
27434 | e.cancelBubble = TRUE; | ||
27435 | } | ||
27436 | |||
27437 | EventBaseObjectProto.stopPropagation.call(this); | ||
27438 | } | ||
27439 | }); | ||
27440 | |||
27441 | exports['default'] = DomEventObject; | ||
27442 | module.exports = exports['default']; | ||
27443 | |||
27444 | /***/ }, | ||
27445 | /* 222 */ | ||
27446 | /***/ function(module, exports) { | ||
27447 | |||
27448 | /** | ||
27449 | * @ignore | ||
27450 | * base event object for custom and dom event. | ||
27451 | * @author yiminghe@gmail.com | ||
27452 | */ | ||
27453 | |||
27454 | "use strict"; | ||
27455 | |||
27456 | Object.defineProperty(exports, "__esModule", { | ||
27457 | value: true | ||
27458 | }); | ||
27459 | function returnFalse() { | ||
27460 | return false; | ||
27461 | } | ||
27462 | |||
27463 | function returnTrue() { | ||
27464 | return true; | ||
27465 | } | ||
27466 | |||
27467 | function EventBaseObject() { | ||
27468 | this.timeStamp = Date.now(); | ||
27469 | this.target = undefined; | ||
27470 | this.currentTarget = undefined; | ||
27471 | } | ||
27472 | |||
27473 | EventBaseObject.prototype = { | ||
27474 | isEventObject: 1, | ||
27475 | |||
27476 | constructor: EventBaseObject, | ||
27477 | |||
27478 | isDefaultPrevented: returnFalse, | ||
27479 | |||
27480 | isPropagationStopped: returnFalse, | ||
27481 | |||
27482 | isImmediatePropagationStopped: returnFalse, | ||
27483 | |||
27484 | preventDefault: function preventDefault() { | ||
27485 | this.isDefaultPrevented = returnTrue; | ||
27486 | }, | ||
27487 | |||
27488 | stopPropagation: function stopPropagation() { | ||
27489 | this.isPropagationStopped = returnTrue; | ||
27490 | }, | ||
27491 | |||
27492 | stopImmediatePropagation: function stopImmediatePropagation() { | ||
27493 | this.isImmediatePropagationStopped = returnTrue; | ||
27494 | // fixed 1.2 | ||
27495 | // call stopPropagation implicitly | ||
27496 | this.stopPropagation(); | ||
27497 | }, | ||
27498 | |||
27499 | halt: function halt(immediate) { | ||
27500 | if (immediate) { | ||
27501 | this.stopImmediatePropagation(); | ||
27502 | } else { | ||
27503 | this.stopPropagation(); | ||
27504 | } | ||
27505 | this.preventDefault(); | ||
27506 | } | ||
27507 | }; | ||
27508 | |||
27509 | exports["default"] = EventBaseObject; | ||
27510 | module.exports = exports["default"]; | ||
27511 | |||
27512 | /***/ }, | ||
27513 | /* 223 */ | ||
27514 | /***/ function(module, exports) { | ||
27515 | |||
27516 | module.exports = function (root, node) { | ||
27517 | while (node) { | ||
27518 | if (node === root) { | ||
27519 | return true; | ||
27520 | } | ||
27521 | node = node.parentNode; | ||
27522 | } | ||
27523 | |||
27524 | return false; | ||
27525 | }; | ||
27526 | |||
27527 | |||
27528 | /***/ }, | ||
27529 | /* 224 */ | ||
27530 | /***/ function(module, exports, __webpack_require__) { | ||
27531 | |||
27532 | var React = __webpack_require__(3); | ||
27533 | |||
27534 | module.exports = function (children) { | ||
27535 | var ret = []; | ||
27536 | React.Children.forEach(children, function (c) { | ||
27537 | ret.push(c); | ||
27538 | }); | ||
27539 | return ret; | ||
27540 | }; | ||
27541 | |||
27542 | |||
27543 | /***/ }, | ||
27544 | /* 225 */ | ||
27545 | /***/ function(module, exports, __webpack_require__) { | ||
27546 | |||
27547 | var React = __webpack_require__(3); | ||
27548 | |||
27549 | function mirror(o) { | ||
27550 | return o; | ||
27551 | } | ||
27552 | |||
27553 | module.exports = function (children) { | ||
27554 | // return ReactFragment | ||
27555 | return React.Children.map(children, mirror); | ||
27556 | }; | ||
27557 | |||
27558 | |||
27559 | /***/ }, | ||
27560 | /* 226 */ | ||
27561 | /***/ function(module, exports) { | ||
27562 | |||
27563 | 'use strict'; | ||
27564 | |||
27565 | Object.defineProperty(exports, '__esModule', { | ||
27566 | value: true | ||
27567 | }); | ||
27568 | var autoAdjustOverflow = { | ||
27569 | adjustX: 1, | ||
27570 | adjustY: 1 | ||
27571 | }; | ||
27572 | |||
27573 | var targetOffset = [0, 0]; | ||
27574 | |||
27575 | var placements = { | ||
27576 | topLeft: { | ||
27577 | points: ['tl', 'tl'], | ||
27578 | overflow: autoAdjustOverflow, | ||
27579 | offset: [0, -3], | ||
27580 | targetOffset: targetOffset | ||
27581 | }, | ||
27582 | topRight: { | ||
27583 | points: ['tr', 'tr'], | ||
27584 | overflow: autoAdjustOverflow, | ||
27585 | offset: [0, -3], | ||
27586 | targetOffset: targetOffset | ||
27587 | }, | ||
27588 | bottomRight: { | ||
27589 | points: ['br', 'br'], | ||
27590 | overflow: autoAdjustOverflow, | ||
27591 | offset: [0, 3], | ||
27592 | targetOffset: targetOffset | ||
27593 | }, | ||
27594 | bottomLeft: { | ||
27595 | points: ['bl', 'bl'], | ||
27596 | overflow: autoAdjustOverflow, | ||
27597 | offset: [0, 3], | ||
27598 | targetOffset: targetOffset | ||
27599 | } | ||
27600 | }; | ||
27601 | |||
27602 | exports['default'] = placements; | ||
27603 | module.exports = exports['default']; | ||
27604 | |||
27605 | /***/ }, | ||
27606 | /* 227 */ | ||
27607 | /***/ function(module, exports, __webpack_require__) { | ||
27608 | |||
27609 | 'use strict'; | ||
27610 | |||
27611 | Object.defineProperty(exports, '__esModule', { | ||
27612 | value: true | ||
27613 | }); | ||
27614 | |||
27615 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
27616 | |||
27617 | var _react = __webpack_require__(3); | ||
27618 | |||
27619 | var _localeEn_US = __webpack_require__(228); | ||
27620 | |||
27621 | var _localeEn_US2 = _interopRequireDefault(_localeEn_US); | ||
27622 | |||
27623 | var _utilIndex = __webpack_require__(229); | ||
27624 | |||
27625 | exports['default'] = { | ||
27626 | propTypes: { | ||
27627 | prefixCls: _react.PropTypes.string, | ||
27628 | locale: _react.PropTypes.object | ||
27629 | }, | ||
27630 | |||
27631 | getDefaultProps: function getDefaultProps() { | ||
27632 | return { | ||
27633 | prefixCls: 'rc-time-picker', | ||
27634 | locale: _localeEn_US2['default'] | ||
27635 | }; | ||
27636 | }, | ||
27637 | |||
27638 | getFormatter: function getFormatter() { | ||
27639 | var formatter = this.props.formatter; | ||
27640 | var locale = this.props.locale; | ||
27641 | if (formatter) { | ||
27642 | if (formatter === this.lastFormatter) { | ||
27643 | return this.normalFormatter; | ||
27644 | } | ||
27645 | this.normalFormatter = (0, _utilIndex.getFormatter)(formatter, locale); | ||
27646 | this.lastFormatter = formatter; | ||
27647 | return this.normalFormatter; | ||
27648 | } | ||
27649 | if (!this.showSecond) { | ||
27650 | if (!this.notShowSecondFormatter) { | ||
27651 | this.notShowSecondFormatter = (0, _utilIndex.getFormatter)('HH:mm', locale); | ||
27652 | } | ||
27653 | return this.notShowSecondFormatter; | ||
27654 | } | ||
27655 | if (!this.showHour) { | ||
27656 | if (!this.notShowHourFormatter) { | ||
27657 | this.notShowHourFormatter = (0, _utilIndex.getFormatter)('mm:ss', locale); | ||
27658 | } | ||
27659 | return this.notShowHourFormatter; | ||
27660 | } | ||
27661 | if (!this.normalFormatter) { | ||
27662 | this.normalFormatter = (0, _utilIndex.getFormatter)('HH:mm:ss', locale); | ||
27663 | } | ||
27664 | return this.normalFormatter; | ||
27665 | } | ||
27666 | }; | ||
27667 | module.exports = exports['default']; | ||
27668 | |||
27669 | /***/ }, | ||
27670 | /* 228 */ | ||
27671 | /***/ function(module, exports, __webpack_require__) { | ||
27672 | |||
27673 | 'use strict'; | ||
27674 | |||
27675 | Object.defineProperty(exports, '__esModule', { | ||
27676 | value: true | ||
27677 | }); | ||
27678 | |||
27679 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
27680 | |||
27681 | var _gregorianCalendarFormatLibLocaleEn_US = __webpack_require__(166); | ||
27682 | |||
27683 | var _gregorianCalendarFormatLibLocaleEn_US2 = _interopRequireDefault(_gregorianCalendarFormatLibLocaleEn_US); | ||
27684 | |||
27685 | exports['default'] = { | ||
27686 | placeholderHHmmss: 'HH:MM:SS', | ||
27687 | placeholderHHmm: 'HH:MM', | ||
27688 | placeholdermmss: 'MM:SS', | ||
27689 | clear: 'Clear', | ||
27690 | format: _gregorianCalendarFormatLibLocaleEn_US2['default'] | ||
27691 | }; | ||
27692 | module.exports = exports['default']; | ||
27693 | |||
27694 | /***/ }, | ||
27695 | /* 229 */ | ||
27696 | /***/ function(module, exports, __webpack_require__) { | ||
27697 | |||
27698 | 'use strict'; | ||
27699 | |||
27700 | Object.defineProperty(exports, '__esModule', { | ||
27701 | value: true | ||
27702 | }); | ||
27703 | exports.getFormatter = getFormatter; | ||
27704 | |||
27705 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
27706 | |||
27707 | var _gregorianCalendarFormat = __webpack_require__(165); | ||
27708 | |||
27709 | var _gregorianCalendarFormat2 = _interopRequireDefault(_gregorianCalendarFormat); | ||
27710 | |||
27711 | function getFormatter(format, locale) { | ||
27712 | if (typeof format === 'string') { | ||
27713 | return new _gregorianCalendarFormat2['default'](format, locale.format); | ||
27714 | } | ||
27715 | return format; | ||
27716 | } | ||
27717 | |||
27718 | /***/ }, | ||
27719 | /* 230 */ | ||
27720 | /***/ function(module, exports, __webpack_require__) { | ||
27721 | |||
27722 | 'use strict'; | ||
27723 | |||
27724 | Object.defineProperty(exports, '__esModule', { | ||
27725 | value: true | ||
27726 | }); | ||
27727 | |||
27728 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
27729 | |||
27730 | var _react = __webpack_require__(3); | ||
27731 | |||
27732 | var _react2 = _interopRequireDefault(_react); | ||
27733 | |||
27734 | var _classnames = __webpack_require__(175); | ||
27735 | |||
27736 | var _classnames2 = _interopRequireDefault(_classnames); | ||
27737 | |||
27738 | var _mixinCommonMixin = __webpack_require__(227); | ||
27739 | |||
27740 | var _mixinCommonMixin2 = _interopRequireDefault(_mixinCommonMixin); | ||
27741 | |||
27742 | var _moduleHeader = __webpack_require__(231); | ||
27743 | |||
27744 | var _moduleHeader2 = _interopRequireDefault(_moduleHeader); | ||
27745 | |||
27746 | var _moduleCombobox = __webpack_require__(232); | ||
27747 | |||
27748 | var _moduleCombobox2 = _interopRequireDefault(_moduleCombobox); | ||
27749 | |||
27750 | function noop() {} | ||
27751 | |||
27752 | function generateOptions(length) { | ||
27753 | return Array.apply(null, { length: length }).map(function (item, index) { | ||
27754 | return index; | ||
27755 | }); | ||
27756 | } | ||
27757 | |||
27758 | var TimePanel = _react2['default'].createClass({ | ||
27759 | displayName: 'TimePanel', | ||
27760 | |||
27761 | propTypes: { | ||
27762 | prefixCls: _react.PropTypes.string, | ||
27763 | defaultValue: _react.PropTypes.object, | ||
27764 | locale: _react.PropTypes.object, | ||
27765 | placeholder: _react.PropTypes.string, | ||
27766 | formatter: _react.PropTypes.object, | ||
27767 | hourOptions: _react.PropTypes.array, | ||
27768 | minuteOptions: _react.PropTypes.array, | ||
27769 | secondOptions: _react.PropTypes.array, | ||
27770 | onChange: _react.PropTypes.func, | ||
27771 | onClear: _react.PropTypes.func | ||
27772 | }, | ||
27773 | |||
27774 | mixins: [_mixinCommonMixin2['default']], | ||
27775 | |||
27776 | getDefaultProps: function getDefaultProps() { | ||
27777 | return { | ||
27778 | hourOptions: generateOptions(24), | ||
27779 | minuteOptions: generateOptions(60), | ||
27780 | secondOptions: generateOptions(60), | ||
27781 | onChange: noop, | ||
27782 | onClear: noop | ||
27783 | }; | ||
27784 | }, | ||
27785 | |||
27786 | getInitialState: function getInitialState() { | ||
27787 | return { | ||
27788 | value: this.props.defaultValue | ||
27789 | }; | ||
27790 | }, | ||
27791 | |||
27792 | componentWillMount: function componentWillMount() { | ||
27793 | var formatter = this.props.formatter; | ||
27794 | var pattern = formatter.originalPattern; | ||
27795 | if (pattern === 'HH:mm') { | ||
27796 | this.showSecond = false; | ||
27797 | } else if (pattern === 'mm:ss') { | ||
27798 | this.showHour = false; | ||
27799 | } | ||
27800 | }, | ||
27801 | |||
27802 | onChange: function onChange(newValue) { | ||
27803 | this.setState({ value: newValue }); | ||
27804 | this.props.onChange(newValue); | ||
27805 | }, | ||
27806 | |||
27807 | onClear: function onClear() { | ||
27808 | this.props.onClear(); | ||
27809 | }, | ||
27810 | |||
27811 | getPlaceholder: function getPlaceholder(placeholder) { | ||
27812 | if (placeholder) { | ||
27813 | return placeholder; | ||
27814 | } | ||
27815 | |||
27816 | var locale = this.props.locale; | ||
27817 | |||
27818 | if (!this.showHour) { | ||
27819 | return locale.placeholdermmss; | ||
27820 | } else if (!this.showSecond) { | ||
27821 | return locale.placeholderHHmm; | ||
27822 | } | ||
27823 | return locale.placeholderHHmmss; | ||
27824 | }, | ||
27825 | |||
27826 | showHour: true, | ||
27827 | showSecond: true, | ||
27828 | |||
27829 | render: function render() { | ||
27830 | var _props = this.props; | ||
27831 | var locale = _props.locale; | ||
27832 | var prefixCls = _props.prefixCls; | ||
27833 | var defaultValue = _props.defaultValue; | ||
27834 | var placeholder = _props.placeholder; | ||
27835 | var hourOptions = _props.hourOptions; | ||
27836 | var minuteOptions = _props.minuteOptions; | ||
27837 | var secondOptions = _props.secondOptions; | ||
27838 | |||
27839 | var value = this.state.value || defaultValue; | ||
27840 | var cls = (0, _classnames2['default'])({ 'narrow': !this.showHour || !this.showSecond }); | ||
27841 | |||
27842 | return _react2['default'].createElement( | ||
27843 | 'div', | ||
27844 | { className: prefixCls + '-panel ' + cls }, | ||
27845 | _react2['default'].createElement(_moduleHeader2['default'], { | ||
27846 | prefixCls: prefixCls, | ||
27847 | gregorianTimePickerLocale: defaultValue.locale, | ||
27848 | locale: locale, | ||
27849 | value: value, | ||
27850 | formatter: this.getFormatter(), | ||
27851 | placeholder: this.getPlaceholder(placeholder), | ||
27852 | hourOptions: hourOptions, | ||
27853 | minuteOptions: minuteOptions, | ||
27854 | secondOptions: secondOptions, | ||
27855 | onChange: this.onChange, | ||
27856 | onClear: this.onClear, | ||
27857 | showClear: true | ||
27858 | }), | ||
27859 | _react2['default'].createElement(_moduleCombobox2['default'], { | ||
27860 | prefixCls: prefixCls, | ||
27861 | value: value, | ||
27862 | formatter: this.getFormatter(), | ||
27863 | onChange: this.onChange, | ||
27864 | showHour: this.showHour, | ||
27865 | showSecond: this.showSecond, | ||
27866 | hourOptions: hourOptions, | ||
27867 | minuteOptions: minuteOptions, | ||
27868 | secondOptions: secondOptions | ||
27869 | }) | ||
27870 | ); | ||
27871 | } | ||
27872 | }); | ||
27873 | |||
27874 | exports['default'] = TimePanel; | ||
27875 | module.exports = exports['default']; | ||
27876 | |||
27877 | /***/ }, | ||
27878 | /* 231 */ | ||
27879 | /***/ function(module, exports, __webpack_require__) { | ||
27880 | |||
27881 | 'use strict'; | ||
27882 | |||
27883 | Object.defineProperty(exports, '__esModule', { | ||
27884 | value: true | ||
27885 | }); | ||
27886 | |||
27887 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
27888 | |||
27889 | var _react = __webpack_require__(3); | ||
27890 | |||
27891 | var _react2 = _interopRequireDefault(_react); | ||
27892 | |||
27893 | var Header = _react2['default'].createClass({ | ||
27894 | displayName: 'Header', | ||
27895 | |||
27896 | propTypes: { | ||
27897 | formatter: _react.PropTypes.object, | ||
27898 | prefixCls: _react.PropTypes.string, | ||
27899 | gregorianTimePickerLocale: _react.PropTypes.object, | ||
27900 | locale: _react.PropTypes.object, | ||
27901 | disabledDate: _react.PropTypes.func, | ||
27902 | placeholder: _react.PropTypes.string, | ||
27903 | value: _react.PropTypes.object, | ||
27904 | hourOptions: _react.PropTypes.array, | ||
27905 | minuteOptions: _react.PropTypes.array, | ||
27906 | secondOptions: _react.PropTypes.array, | ||
27907 | onChange: _react.PropTypes.func, | ||
27908 | onClear: _react.PropTypes.func, | ||
27909 | showClear: _react.PropTypes.bool | ||
27910 | }, | ||
27911 | |||
27912 | getInitialState: function getInitialState() { | ||
27913 | var value = this.props.value; | ||
27914 | return { | ||
27915 | str: value && this.props.formatter.format(value) || '', | ||
27916 | invalid: false | ||
27917 | }; | ||
27918 | }, | ||
27919 | |||
27920 | componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
27921 | var value = nextProps.value; | ||
27922 | this.setState({ | ||
27923 | str: value && nextProps.formatter.format(value) || '', | ||
27924 | invalid: false | ||
27925 | }); | ||
27926 | }, | ||
27927 | |||
27928 | onInputChange: function onInputChange(event) { | ||
27929 | var str = event.target.value; | ||
27930 | this.setState({ | ||
27931 | str: str | ||
27932 | }); | ||
27933 | var value = null; | ||
27934 | var _props = this.props; | ||
27935 | var formatter = _props.formatter; | ||
27936 | var gregorianTimePickerLocale = _props.gregorianTimePickerLocale; | ||
27937 | var hourOptions = _props.hourOptions; | ||
27938 | var minuteOptions = _props.minuteOptions; | ||
27939 | var secondOptions = _props.secondOptions; | ||
27940 | var onChange = _props.onChange; | ||
27941 | |||
27942 | if (str) { | ||
27943 | var originalValue = this.props.value; | ||
27944 | try { | ||
27945 | value = formatter.parse(str, { | ||
27946 | locale: gregorianTimePickerLocale, | ||
27947 | obeyCount: true | ||
27948 | }); | ||
27949 | } catch (ex) { | ||
27950 | this.setState({ | ||
27951 | invalid: true | ||
27952 | }); | ||
27953 | return; | ||
27954 | } | ||
27955 | |||
27956 | if (value) { | ||
27957 | if (hourOptions.indexOf(value.fields[4]) < 0 || minuteOptions.indexOf(value.fields[5]) < 0 || secondOptions.indexOf(value.fields[6]) < 0) { | ||
27958 | this.setState({ | ||
27959 | invalid: true | ||
27960 | }); | ||
27961 | return; | ||
27962 | } | ||
27963 | |||
27964 | if (originalValue && value) { | ||
27965 | if (originalValue.fields[4] !== value.fields[4] || originalValue.fields[5] !== value.fields[5] || originalValue.fields[6] !== value.fields[6]) { | ||
27966 | onChange(value); | ||
27967 | } | ||
27968 | } else if (originalValue !== value) { | ||
27969 | onChange(value); | ||
27970 | } | ||
27971 | } else { | ||
27972 | this.setState({ | ||
27973 | invalid: true | ||
27974 | }); | ||
27975 | return; | ||
27976 | } | ||
27977 | } else { | ||
27978 | onChange(null); | ||
27979 | } | ||
27980 | |||
27981 | this.setState({ | ||
27982 | invalid: false | ||
27983 | }); | ||
27984 | }, | ||
27985 | |||
27986 | onClear: function onClear() { | ||
27987 | this.setState({ str: '' }); | ||
27988 | this.props.onClear(); | ||
27989 | }, | ||
27990 | |||
27991 | getClearButton: function getClearButton() { | ||
27992 | var _props2 = this.props; | ||
27993 | var locale = _props2.locale; | ||
27994 | var prefixCls = _props2.prefixCls; | ||
27995 | var showClear = _props2.showClear; | ||
27996 | |||
27997 | if (!showClear) { | ||
27998 | return null; | ||
27999 | } | ||
28000 | return _react2['default'].createElement('a', { className: prefixCls + '-clear-btn', role: 'button', title: locale.clear, onMouseDown: this.onClear }); | ||
28001 | }, | ||
28002 | |||
28003 | getInput: function getInput() { | ||
28004 | var _props3 = this.props; | ||
28005 | var prefixCls = _props3.prefixCls; | ||
28006 | var placeholder = _props3.placeholder; | ||
28007 | var _state = this.state; | ||
28008 | var invalid = _state.invalid; | ||
28009 | var str = _state.str; | ||
28010 | |||
28011 | var invalidClass = invalid ? prefixCls + '-input-invalid' : ''; | ||
28012 | return _react2['default'].createElement('input', { className: prefixCls + '-input ' + invalidClass, value: str, placeholder: placeholder, onChange: this.onInputChange }); | ||
28013 | }, | ||
28014 | |||
28015 | render: function render() { | ||
28016 | var prefixCls = this.props.prefixCls; | ||
28017 | |||
28018 | return _react2['default'].createElement( | ||
28019 | 'div', | ||
28020 | { className: prefixCls + '-input-wrap' }, | ||
28021 | this.getInput(), | ||
28022 | this.getClearButton() | ||
28023 | ); | ||
28024 | } | ||
28025 | }); | ||
28026 | |||
28027 | exports['default'] = Header; | ||
28028 | module.exports = exports['default']; | ||
28029 | |||
28030 | /***/ }, | ||
28031 | /* 232 */ | ||
28032 | /***/ function(module, exports, __webpack_require__) { | ||
28033 | |||
28034 | 'use strict'; | ||
28035 | |||
28036 | Object.defineProperty(exports, '__esModule', { | ||
28037 | value: true | ||
28038 | }); | ||
28039 | |||
28040 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
28041 | |||
28042 | var _react = __webpack_require__(3); | ||
28043 | |||
28044 | var _react2 = _interopRequireDefault(_react); | ||
28045 | |||
28046 | var _Select = __webpack_require__(233); | ||
28047 | |||
28048 | var _Select2 = _interopRequireDefault(_Select); | ||
28049 | |||
28050 | var formatOption = function formatOption(option) { | ||
28051 | if (option < 10) { | ||
28052 | return '0' + option; | ||
28053 | } | ||
28054 | return '' + option; | ||
28055 | }; | ||
28056 | |||
28057 | var Combobox = _react2['default'].createClass({ | ||
28058 | displayName: 'Combobox', | ||
28059 | |||
28060 | propTypes: { | ||
28061 | formatter: _react.PropTypes.object, | ||
28062 | prefixCls: _react.PropTypes.string, | ||
28063 | value: _react.PropTypes.object, | ||
28064 | onChange: _react.PropTypes.func, | ||
28065 | showHour: _react.PropTypes.bool, | ||
28066 | showSecond: _react.PropTypes.bool, | ||
28067 | hourOptions: _react.PropTypes.array, | ||
28068 | minuteOptions: _react.PropTypes.array, | ||
28069 | secondOptions: _react.PropTypes.array | ||
28070 | }, | ||
28071 | |||
28072 | onItemChange: function onItemChange(type, itemValue) { | ||
28073 | var _props = this.props; | ||
28074 | var value = _props.value; | ||
28075 | var onChange = _props.onChange; | ||
28076 | |||
28077 | var index = 4; | ||
28078 | if (type === 'minute') { | ||
28079 | index = 5; | ||
28080 | } else if (type === 'second') { | ||
28081 | index = 6; | ||
28082 | } | ||
28083 | value.fields[index] = itemValue; | ||
28084 | onChange(value); | ||
28085 | }, | ||
28086 | |||
28087 | getHourSelect: function getHourSelect(hour) { | ||
28088 | var _props2 = this.props; | ||
28089 | var prefixCls = _props2.prefixCls; | ||
28090 | var hourOptions = _props2.hourOptions; | ||
28091 | var showHour = _props2.showHour; | ||
28092 | |||
28093 | if (!showHour) { | ||
28094 | return null; | ||
28095 | } | ||
28096 | return _react2['default'].createElement(_Select2['default'], { | ||
28097 | prefixCls: prefixCls, | ||
28098 | options: hourOptions.map(function (option) { | ||
28099 | return formatOption(option); | ||
28100 | }), | ||
28101 | selectedIndex: hourOptions.indexOf(hour), | ||
28102 | type: 'hour', | ||
28103 | onSelect: this.onItemChange | ||
28104 | }); | ||
28105 | }, | ||
28106 | |||
28107 | getMinuteSelect: function getMinuteSelect(minute) { | ||
28108 | var _props3 = this.props; | ||
28109 | var prefixCls = _props3.prefixCls; | ||
28110 | var minuteOptions = _props3.minuteOptions; | ||
28111 | |||
28112 | return _react2['default'].createElement(_Select2['default'], { | ||
28113 | prefixCls: prefixCls, | ||
28114 | options: minuteOptions.map(function (option) { | ||
28115 | return formatOption(option); | ||
28116 | }), | ||
28117 | selectedIndex: minuteOptions.indexOf(minute), | ||
28118 | type: 'minute', | ||
28119 | onSelect: this.onItemChange | ||
28120 | }); | ||
28121 | }, | ||
28122 | |||
28123 | getSectionSelect: function getSectionSelect(second) { | ||
28124 | var _props4 = this.props; | ||
28125 | var prefixCls = _props4.prefixCls; | ||
28126 | var secondOptions = _props4.secondOptions; | ||
28127 | var showSecond = _props4.showSecond; | ||
28128 | |||
28129 | if (!showSecond) { | ||
28130 | return null; | ||
28131 | } | ||
28132 | return _react2['default'].createElement(_Select2['default'], { | ||
28133 | prefixCls: prefixCls, | ||
28134 | options: secondOptions.map(function (option) { | ||
28135 | return formatOption(option); | ||
28136 | }), | ||
28137 | selectedIndex: secondOptions.indexOf(second), | ||
28138 | type: 'second', | ||
28139 | onSelect: this.onItemChange | ||
28140 | }); | ||
28141 | }, | ||
28142 | |||
28143 | render: function render() { | ||
28144 | var _props5 = this.props; | ||
28145 | var prefixCls = _props5.prefixCls; | ||
28146 | var value = _props5.value; | ||
28147 | |||
28148 | var timeFields = value.fields; | ||
28149 | |||
28150 | return _react2['default'].createElement( | ||
28151 | 'div', | ||
28152 | { className: prefixCls + '-combobox' }, | ||
28153 | this.getHourSelect(timeFields[4]), | ||
28154 | this.getMinuteSelect(timeFields[5]), | ||
28155 | this.getSectionSelect(timeFields[6]) | ||
28156 | ); | ||
28157 | } | ||
28158 | }); | ||
28159 | |||
28160 | exports['default'] = Combobox; | ||
28161 | module.exports = exports['default']; | ||
28162 | |||
28163 | /***/ }, | ||
28164 | /* 233 */ | ||
28165 | /***/ function(module, exports, __webpack_require__) { | ||
28166 | |||
28167 | 'use strict'; | ||
28168 | |||
28169 | Object.defineProperty(exports, '__esModule', { | ||
28170 | value: true | ||
28171 | }); | ||
28172 | |||
28173 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
28174 | |||
28175 | var _react = __webpack_require__(3); | ||
28176 | |||
28177 | var _react2 = _interopRequireDefault(_react); | ||
28178 | |||
28179 | var _reactDom = __webpack_require__(160); | ||
28180 | |||
28181 | var _reactDom2 = _interopRequireDefault(_reactDom); | ||
28182 | |||
28183 | var _classnames = __webpack_require__(175); | ||
28184 | |||
28185 | var _classnames2 = _interopRequireDefault(_classnames); | ||
28186 | |||
28187 | var scrollTo = function scrollTo(element, to, duration) { | ||
28188 | // jump to target if duration zero | ||
28189 | if (duration <= 0) { | ||
28190 | element.scrollTop = to; | ||
28191 | return; | ||
28192 | } | ||
28193 | var difference = to - element.scrollTop; | ||
28194 | var perTick = difference / duration * 10; | ||
28195 | |||
28196 | setTimeout(function () { | ||
28197 | element.scrollTop = element.scrollTop + perTick; | ||
28198 | if (element.scrollTop === to) return; | ||
28199 | scrollTo(element, to, duration - 10); | ||
28200 | }, 10); | ||
28201 | }; | ||
28202 | |||
28203 | var Select = _react2['default'].createClass({ | ||
28204 | displayName: 'Select', | ||
28205 | |||
28206 | propTypes: { | ||
28207 | prefixCls: _react.PropTypes.string, | ||
28208 | options: _react.PropTypes.array, | ||
28209 | selectedIndex: _react.PropTypes.number, | ||
28210 | type: _react.PropTypes.string, | ||
28211 | onSelect: _react.PropTypes.func | ||
28212 | }, | ||
28213 | |||
28214 | componentDidMount: function componentDidMount() { | ||
28215 | // jump to selected option | ||
28216 | this.scrollToSelected(0); | ||
28217 | }, | ||
28218 | |||
28219 | componentDidUpdate: function componentDidUpdate() { | ||
28220 | // smooth scroll to selected option | ||
28221 | this.scrollToSelected(200); | ||
28222 | }, | ||
28223 | |||
28224 | onSelect: function onSelect(event) { | ||
28225 | // do nothing when select selected option | ||
28226 | if (event.target.getAttribute('class') === 'selected') { | ||
28227 | return; | ||
28228 | } | ||
28229 | // change combobox selection | ||
28230 | var _props = this.props; | ||
28231 | var onSelect = _props.onSelect; | ||
28232 | var type = _props.type; | ||
28233 | |||
28234 | var value = parseInt(event.target.innerHTML, 10); | ||
28235 | onSelect(type, value); | ||
28236 | }, | ||
28237 | |||
28238 | getOptions: function getOptions() { | ||
28239 | var _this = this; | ||
28240 | |||
28241 | var _props2 = this.props; | ||
28242 | var options = _props2.options; | ||
28243 | var selectedIndex = _props2.selectedIndex; | ||
28244 | |||
28245 | return options.map(function (item, index) { | ||
28246 | var cls = (0, _classnames2['default'])({ selected: selectedIndex === index }); | ||
28247 | var ref = selectedIndex === index ? 'selected' : null; | ||
28248 | return _react2['default'].createElement( | ||
28249 | 'li', | ||
28250 | { ref: ref, className: cls, key: index, onClick: _this.onSelect }, | ||
28251 | item | ||
28252 | ); | ||
28253 | }); | ||
28254 | }, | ||
28255 | |||
28256 | scrollToSelected: function scrollToSelected(duration) { | ||
28257 | // move to selected item | ||
28258 | var select = _reactDom2['default'].findDOMNode(this); | ||
28259 | var list = _reactDom2['default'].findDOMNode(this.refs.list); | ||
28260 | var index = this.props.selectedIndex - 2; | ||
28261 | if (index < 0) { | ||
28262 | index = 0; | ||
28263 | } | ||
28264 | var topOption = list.children[index]; | ||
28265 | var to = topOption.offsetTop - select.offsetTop; | ||
28266 | scrollTo(select, to, duration); | ||
28267 | }, | ||
28268 | |||
28269 | render: function render() { | ||
28270 | if (this.props.options.length === 0) { | ||
28271 | return null; | ||
28272 | } | ||
28273 | |||
28274 | var prefixCls = this.props.prefixCls; | ||
28275 | |||
28276 | return _react2['default'].createElement( | ||
28277 | 'div', | ||
28278 | { className: prefixCls + '-select' }, | ||
28279 | _react2['default'].createElement( | ||
28280 | 'ul', | ||
28281 | { ref: 'list' }, | ||
28282 | this.getOptions() | ||
28283 | ) | ||
28284 | ); | ||
28285 | } | ||
28286 | }); | ||
28287 | |||
28288 | exports['default'] = Select; | ||
28289 | module.exports = exports['default']; | ||
28290 | |||
28291 | /***/ }, | ||
28292 | /* 234 */ | ||
28293 | /***/ function(module, exports, __webpack_require__) { | ||
28294 | |||
28295 | 'use strict'; | ||
28296 | |||
28297 | Object.defineProperty(exports, '__esModule', { | ||
28298 | value: true | ||
28299 | }); | ||
28300 | |||
28301 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
28302 | |||
28303 | var _gregorianCalendarFormatLibLocaleZh_CN = __webpack_require__(235); | ||
28304 | |||
28305 | var _gregorianCalendarFormatLibLocaleZh_CN2 = _interopRequireDefault(_gregorianCalendarFormatLibLocaleZh_CN); | ||
28306 | |||
28307 | exports['default'] = { | ||
28308 | placeholderHHmmss: '时:分:秒', | ||
28309 | placeholderHHmm: '时:分', | ||
28310 | placeholdermmss: '分:秒', | ||
28311 | clear: '清除', | ||
28312 | format: _gregorianCalendarFormatLibLocaleZh_CN2['default'] | ||
28313 | }; | ||
28314 | module.exports = exports['default']; | ||
28315 | |||
28316 | /***/ }, | ||
28317 | /* 235 */ | ||
28318 | /***/ function(module, exports) { | ||
28319 | |||
28320 | 'use strict'; | ||
28321 | |||
28322 | module.exports = { | ||
28323 | eras: ['公元前', '公元'], | ||
28324 | months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], | ||
28325 | shortMonths: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], | ||
28326 | weekdays: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], | ||
28327 | shortWeekdays: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], | ||
28328 | veryShortWeekdays: ['日', '一', '二', '三', '四', '五', '六'], | ||
28329 | ampms: ['上午', '下午'], | ||
28330 | datePatterns: ['yyyy\'年\'M\'月\'d\'日\' EEEE', 'yyyy\'年\'M\'月\'d\'日\'', 'yyyy-M-d', 'yy-M-d'], | ||
28331 | timePatterns: ['ahh\'时\'mm\'分\'ss\'秒\' \'GMT\'Z', 'ahh\'时\'mm\'分\'ss\'秒\'', 'H:mm:ss', 'ah:mm'], | ||
28332 | dateTimePattern: '{date} {time}' | ||
28333 | }; | ||
28334 | |||
28335 | /***/ } | ||
28336 | ]); | ||
28337 | //# sourceMappingURL=pick-time.js.map \ No newline at end of file | ||