react 15.7.0 → 16.0.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +26 -16
  2. package/PATENTS +33 -0
  3. package/README.md +7 -0
  4. package/dist/react-with-addons.js +3831 -4404
  5. package/dist/react-with-addons.min.js +7 -6
  6. package/dist/react.js +2929 -3319
  7. package/dist/react.min.js +7 -5
  8. package/lib/KeyEscapeUtils.js +5 -3
  9. package/lib/PooledClass.js +5 -3
  10. package/lib/React.js +20 -61
  11. package/lib/ReactAddonsDOMDependencies.js +5 -3
  12. package/lib/ReactAddonsDOMDependenciesUMDShim.js +5 -3
  13. package/lib/ReactCSSTransitionGroup.js +9 -9
  14. package/lib/ReactCSSTransitionGroupChild.js +118 -134
  15. package/lib/ReactChildren.js +9 -7
  16. package/lib/ReactClass.js +703 -0
  17. package/lib/{ReactBaseClasses.js → ReactComponent.js} +11 -40
  18. package/lib/ReactComponentTreeHook.js +63 -58
  19. package/lib/ReactComponentTreeHookUMDShim.js +5 -3
  20. package/lib/ReactComponentWithPureRenderMixin.js +5 -3
  21. package/lib/ReactCurrentOwner.js +7 -3
  22. package/lib/ReactCurrentOwnerUMDShim.js +5 -3
  23. package/lib/ReactDOMFactories.js +6 -3
  24. package/lib/ReactElement.js +9 -7
  25. package/lib/ReactElementSymbol.js +5 -3
  26. package/lib/ReactElementType.js +5 -3
  27. package/lib/ReactElementValidator.js +13 -12
  28. package/lib/ReactFragment.js +5 -3
  29. package/lib/ReactNoopUpdateQueue.js +15 -16
  30. package/lib/ReactPropTypeLocationNames.js +5 -3
  31. package/lib/ReactPropTypeLocations.js +5 -3
  32. package/lib/ReactPropTypes.js +447 -7
  33. package/lib/ReactPureComponent.js +41 -0
  34. package/lib/ReactStateSetters.js +5 -3
  35. package/lib/ReactTransitionChildMapping.js +5 -3
  36. package/lib/ReactTransitionEvents.js +5 -3
  37. package/lib/ReactTransitionGroup.js +8 -12
  38. package/lib/ReactTypeOfWork.js +26 -0
  39. package/lib/ReactUMDEntry.js +8 -7
  40. package/lib/ReactUMDShim.js +5 -3
  41. package/lib/ReactVersion.js +6 -4
  42. package/lib/ReactWithAddons.js +5 -5
  43. package/lib/ReactWithAddonsUMDEntry.js +8 -7
  44. package/lib/canDefineProperty.js +5 -3
  45. package/lib/checkReactTypeSpec.js +22 -9
  46. package/lib/deprecated.js +8 -6
  47. package/lib/flattenChildren.js +5 -3
  48. package/lib/getComponentName.js +37 -0
  49. package/lib/getIteratorFn.js +5 -3
  50. package/lib/getNextDebugID.js +5 -3
  51. package/lib/onlyChild.js +6 -4
  52. package/lib/reactProdInvariant.js +4 -2
  53. package/lib/shallowCompare.js +5 -3
  54. package/lib/sliceChildren.js +5 -3
  55. package/lib/traverseAllChildren.js +6 -4
  56. package/lib/update.js +5 -3
  57. package/package.json +24 -35
  58. package/cjs/react-jsx-dev-runtime.development.js +0 -866
  59. package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  60. package/cjs/react-jsx-runtime.development.js +0 -888
  61. package/cjs/react-jsx-runtime.production.min.js +0 -10
  62. package/jsx-dev-runtime.js +0 -7
  63. package/jsx-runtime.js +0 -7
  64. package/lib/LinkedStateMixin.js +0 -32
  65. package/lib/ReactComponentTreeDevtool.js +0 -12
  66. package/lib/ReactLink.js +0 -47
  67. package/lib/ReactPropTypesSecret.js +0 -14
  68. package/lib/createClass.js +0 -20
  69. package/lib/getNextDebugIDUMDShim.js +0 -15
  70. package/lib/lowPriorityWarning.js +0 -62
@@ -1,22 +1,23 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
9
11
  'use strict';
10
12
 
11
- var _prodInvariant = require('./reactProdInvariant'),
12
- _assign = require('object-assign');
13
+ var _prodInvariant = require('./reactProdInvariant');
13
14
 
14
15
  var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
15
16
 
16
17
  var canDefineProperty = require('./canDefineProperty');
17
18
  var emptyObject = require('fbjs/lib/emptyObject');
18
19
  var invariant = require('fbjs/lib/invariant');
19
- var lowPriorityWarning = require('./lowPriorityWarning');
20
+ var warning = require('fbjs/lib/warning');
20
21
 
21
22
  /**
22
23
  * Base class helpers for the updating state of a component.
@@ -59,10 +60,7 @@ ReactComponent.prototype.isReactComponent = {};
59
60
  */
60
61
  ReactComponent.prototype.setState = function (partialState, callback) {
61
62
  !(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.') : _prodInvariant('85') : void 0;
62
- this.updater.enqueueSetState(this, partialState);
63
- if (callback) {
64
- this.updater.enqueueCallback(this, callback, 'setState');
65
- }
63
+ this.updater.enqueueSetState(this, partialState, callback, 'setState');
66
64
  };
67
65
 
68
66
  /**
@@ -80,10 +78,7 @@ ReactComponent.prototype.setState = function (partialState, callback) {
80
78
  * @protected
81
79
  */
82
80
  ReactComponent.prototype.forceUpdate = function (callback) {
83
- this.updater.enqueueForceUpdate(this);
84
- if (callback) {
85
- this.updater.enqueueCallback(this, callback, 'forceUpdate');
86
- }
81
+ this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
87
82
  };
88
83
 
89
84
  /**
@@ -100,7 +95,7 @@ if (process.env.NODE_ENV !== 'production') {
100
95
  if (canDefineProperty) {
101
96
  Object.defineProperty(ReactComponent.prototype, methodName, {
102
97
  get: function () {
103
- lowPriorityWarning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
98
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : void 0;
104
99
  return undefined;
105
100
  }
106
101
  });
@@ -113,28 +108,4 @@ if (process.env.NODE_ENV !== 'production') {
113
108
  }
114
109
  }
115
110
 
116
- /**
117
- * Base class helpers for the updating state of a component.
118
- */
119
- function ReactPureComponent(props, context, updater) {
120
- // Duplicated from ReactComponent.
121
- this.props = props;
122
- this.context = context;
123
- this.refs = emptyObject;
124
- // We initialize the default updater but the real one gets injected by the
125
- // renderer.
126
- this.updater = updater || ReactNoopUpdateQueue;
127
- }
128
-
129
- function ComponentDummy() {}
130
- ComponentDummy.prototype = ReactComponent.prototype;
131
- ReactPureComponent.prototype = new ComponentDummy();
132
- ReactPureComponent.prototype.constructor = ReactPureComponent;
133
- // Avoid an extra prototype jump for these methods.
134
- _assign(ReactPureComponent.prototype, ReactComponent.prototype);
135
- ReactPureComponent.prototype.isPureReactComponent = true;
136
-
137
- module.exports = {
138
- Component: ReactComponent,
139
- PureComponent: ReactPureComponent
140
- };
111
+ module.exports = ReactComponent;
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2016-present, Facebook, Inc.
2
+ * Copyright 2016-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  *
8
10
  */
@@ -12,7 +14,14 @@
12
14
  var _prodInvariant = require('./reactProdInvariant');
13
15
 
14
16
  var ReactCurrentOwner = require('./ReactCurrentOwner');
17
+ var ReactTypeOfWork = require('./ReactTypeOfWork');
18
+ var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent,
19
+ FunctionalComponent = ReactTypeOfWork.FunctionalComponent,
20
+ ClassComponent = ReactTypeOfWork.ClassComponent,
21
+ HostComponent = ReactTypeOfWork.HostComponent;
15
22
 
23
+
24
+ var getComponentName = require('./getComponentName');
16
25
  var invariant = require('fbjs/lib/invariant');
17
26
  var warning = require('fbjs/lib/warning');
18
27
 
@@ -22,11 +31,11 @@ function isNative(fn) {
22
31
  var hasOwnProperty = Object.prototype.hasOwnProperty;
23
32
  var reIsNative = RegExp('^' + funcToString
24
33
  // Take an example native function source for comparison
25
- .call(hasOwnProperty
34
+ .call(hasOwnProperty)
26
35
  // Strip regex characters so we can use it for regex
27
- ).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'
36
+ .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
28
37
  // Remove hasOwnProperty from the template to make it generic
29
- ).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
38
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
30
39
  try {
31
40
  var source = funcToString.call(fn);
32
41
  return reIsNative.test(source);
@@ -163,10 +172,29 @@ function describeID(id) {
163
172
  return describeComponentFrame(name, element && element._source, ownerName);
164
173
  }
165
174
 
175
+ function describeFiber(fiber) {
176
+ switch (fiber.tag) {
177
+ case IndeterminateComponent:
178
+ case FunctionalComponent:
179
+ case ClassComponent:
180
+ case HostComponent:
181
+ var owner = fiber._debugOwner;
182
+ var source = fiber._debugSource;
183
+ var name = getComponentName(fiber);
184
+ var ownerName = null;
185
+ if (owner) {
186
+ ownerName = getComponentName(owner);
187
+ }
188
+ return describeComponentFrame(name, source, ownerName);
189
+ default:
190
+ return '';
191
+ }
192
+ }
193
+
166
194
  var ReactComponentTreeHook = {
167
195
  onSetChildren: function (id, nextChildIDs) {
168
196
  var item = getItem(id);
169
- !item ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Item must have been set') : _prodInvariant('144') : void 0;
197
+ invariant(item, 'Item must have been set');
170
198
  item.childIDs = nextChildIDs;
171
199
 
172
200
  for (var i = 0; i < nextChildIDs.length; i++) {
@@ -206,7 +234,7 @@ var ReactComponentTreeHook = {
206
234
  },
207
235
  onMountComponent: function (id) {
208
236
  var item = getItem(id);
209
- !item ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Item must have been set') : _prodInvariant('144') : void 0;
237
+ invariant(item, 'Item must have been set');
210
238
  item.isMounted = true;
211
239
  var isRoot = item.parentID === 0;
212
240
  if (isRoot) {
@@ -259,13 +287,20 @@ var ReactComponentTreeHook = {
259
287
  if (topElement) {
260
288
  var name = getDisplayName(topElement);
261
289
  var owner = topElement._owner;
262
- info += describeComponentFrame(name, topElement._source, owner && owner.getName());
290
+ info += describeComponentFrame(name, topElement._source, owner && getComponentName(owner));
263
291
  }
264
292
 
265
293
  var currentOwner = ReactCurrentOwner.current;
266
- var id = currentOwner && currentOwner._debugID;
267
-
268
- info += ReactComponentTreeHook.getStackAddendumByID(id);
294
+ if (currentOwner) {
295
+ if (typeof currentOwner.tag === 'number') {
296
+ var workInProgress = currentOwner;
297
+ // Safe because if current owner exists, we are reconciling,
298
+ // and it is guaranteed to be the work-in-progress version.
299
+ info += ReactComponentTreeHook.getStackAddendumByWorkInProgressFiber(workInProgress);
300
+ } else if (typeof currentOwner._debugID === 'number') {
301
+ info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID);
302
+ }
303
+ }
269
304
  return info;
270
305
  },
271
306
  getStackAddendumByID: function (id) {
@@ -276,6 +311,21 @@ var ReactComponentTreeHook = {
276
311
  }
277
312
  return info;
278
313
  },
314
+
315
+
316
+ // This function can only be called with a work-in-progress fiber and
317
+ // only during begin or complete phase. Do not call it under any other
318
+ // circumstances.
319
+ getStackAddendumByWorkInProgressFiber: function (workInProgress) {
320
+ var info = '';
321
+ var node = workInProgress;
322
+ do {
323
+ info += describeFiber(node);
324
+ // Otherwise this return pointer might point to the wrong tree:
325
+ node = node['return'];
326
+ } while (node);
327
+ return info;
328
+ },
279
329
  getChildIDs: function (id) {
280
330
  var item = getItem(id);
281
331
  return item ? item.childIDs : [];
@@ -325,52 +375,7 @@ var ReactComponentTreeHook = {
325
375
 
326
376
 
327
377
  getRootIDs: getRootIDs,
328
- getRegisteredIDs: getItemIDs,
329
-
330
- pushNonStandardWarningStack: function (isCreatingElement, currentSource) {
331
- if (typeof console.reactStack !== 'function') {
332
- return;
333
- }
334
-
335
- var stack = [];
336
- var currentOwner = ReactCurrentOwner.current;
337
- var id = currentOwner && currentOwner._debugID;
338
-
339
- try {
340
- if (isCreatingElement) {
341
- stack.push({
342
- name: id ? ReactComponentTreeHook.getDisplayName(id) : null,
343
- fileName: currentSource ? currentSource.fileName : null,
344
- lineNumber: currentSource ? currentSource.lineNumber : null
345
- });
346
- }
347
-
348
- while (id) {
349
- var element = ReactComponentTreeHook.getElement(id);
350
- var parentID = ReactComponentTreeHook.getParentID(id);
351
- var ownerID = ReactComponentTreeHook.getOwnerID(id);
352
- var ownerName = ownerID ? ReactComponentTreeHook.getDisplayName(ownerID) : null;
353
- var source = element && element._source;
354
- stack.push({
355
- name: ownerName,
356
- fileName: source ? source.fileName : null,
357
- lineNumber: source ? source.lineNumber : null
358
- });
359
- id = parentID;
360
- }
361
- } catch (err) {
362
- // Internal state is messed up.
363
- // Stop building the stack (it's just a nice to have).
364
- }
365
-
366
- console.reactStack(stack);
367
- },
368
- popNonStandardWarningStack: function () {
369
- if (typeof console.reactStackEnd !== 'function') {
370
- return;
371
- }
372
- console.reactStackEnd();
373
- }
378
+ getRegisteredIDs: getItemIDs
374
379
  };
375
380
 
376
381
  module.exports = ReactComponentTreeHook;
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  *
8
10
  */
@@ -16,11 +18,13 @@
16
18
  * currently being constructed.
17
19
  */
18
20
  var ReactCurrentOwner = {
21
+
19
22
  /**
20
23
  * @internal
21
24
  * @type {ReactComponent}
22
25
  */
23
26
  current: null
27
+
24
28
  };
25
29
 
26
30
  module.exports = ReactCurrentOwner;
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
@@ -23,6 +25,7 @@ if (process.env.NODE_ENV !== 'production') {
23
25
 
24
26
  /**
25
27
  * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
28
+ * This is also accessible via `React.DOM`.
26
29
  *
27
30
  * @public
28
31
  */
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2014-present, Facebook, Inc.
2
+ * Copyright 2014-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  */
8
10
 
@@ -163,7 +165,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
163
165
 
164
166
  /**
165
167
  * Create and return a new ReactElement of the given type.
166
- * See https://facebook.github.io/react/docs/top-level-api.html#react.createelement
168
+ * See https://facebook.github.io/react/docs/react-api.html#createelement
167
169
  */
168
170
  ReactElement.createElement = function (type, config, children) {
169
171
  var propName;
@@ -239,7 +241,7 @@ ReactElement.createElement = function (type, config, children) {
239
241
 
240
242
  /**
241
243
  * Return a function that produces ReactElements of a given type.
242
- * See https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
244
+ * See https://facebook.github.io/react/docs/react-api.html#createfactory
243
245
  */
244
246
  ReactElement.createFactory = function (type) {
245
247
  var factory = ReactElement.createElement.bind(null, type);
@@ -260,7 +262,7 @@ ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
260
262
 
261
263
  /**
262
264
  * Clone and return a new ReactElement using element as the starting point.
263
- * See https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement
265
+ * See https://facebook.github.io/react/docs/react-api.html#cloneelement
264
266
  */
265
267
  ReactElement.cloneElement = function (element, config, children) {
266
268
  var propName;
@@ -326,7 +328,7 @@ ReactElement.cloneElement = function (element, config, children) {
326
328
 
327
329
  /**
328
330
  * Verifies the object is a ReactElement.
329
- * See https://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement
331
+ * See https://facebook.github.io/react/docs/react-api.html#isvalidelement
330
332
  * @param {?object} object
331
333
  * @return {boolean} True if `object` is a valid component.
332
334
  * @final
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2014-present, Facebook, Inc.
2
+ * Copyright 2014-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  *
8
10
  */
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2016-present, Facebook, Inc.
2
+ * Copyright 2016-present, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
6
8
  *
7
9
  *
8
10
  */