react 16.0.0-alpha.2 → 16.0.0-alpha.6

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 (36) hide show
  1. package/dist/react.js +330 -295
  2. package/dist/react.min.js +3 -3
  3. package/lib/React.js +4 -14
  4. package/lib/ReactClass.js +5 -11
  5. package/lib/ReactComponentTreeHook.js +8 -47
  6. package/lib/ReactCurrentOwner.js +0 -2
  7. package/lib/ReactDebugCurrentFrame.js +55 -0
  8. package/lib/ReactElementValidator.js +44 -21
  9. package/lib/ReactFiberComponentTreeHook.js +62 -0
  10. package/lib/ReactNoopUpdateQueue.js +0 -1
  11. package/lib/ReactPropTypes.js +12 -23
  12. package/lib/ReactVersion.js +1 -1
  13. package/lib/checkPropTypes.js +64 -0
  14. package/lib/checkReactTypeSpec.js +5 -81
  15. package/lib/deprecated.js +1 -1
  16. package/lib/traverseAllChildren.js +2 -2
  17. package/package.json +1 -1
  18. package/dist/react-with-addons.js +0 -5323
  19. package/dist/react-with-addons.min.js +0 -17
  20. package/lib/ReactAddonsDOMDependencies.js +0 -36
  21. package/lib/ReactAddonsDOMDependenciesUMDShim.js +0 -35
  22. package/lib/ReactCSSTransitionGroup.js +0 -104
  23. package/lib/ReactCSSTransitionGroupChild.js +0 -166
  24. package/lib/ReactComponentWithPureRenderMixin.js +0 -47
  25. package/lib/ReactFragment.js +0 -68
  26. package/lib/ReactPropTypeLocationNames.js +0 -24
  27. package/lib/ReactPropTypeLocations.js +0 -12
  28. package/lib/ReactStateSetters.js +0 -103
  29. package/lib/ReactTransitionChildMapping.js +0 -102
  30. package/lib/ReactTransitionEvents.js +0 -72
  31. package/lib/ReactTransitionGroup.js +0 -228
  32. package/lib/ReactWithAddons.js +0 -50
  33. package/lib/ReactWithAddonsUMDEntry.js +0 -32
  34. package/lib/shallowCompare.js +0 -24
  35. package/lib/sliceChildren.js +0 -33
  36. package/lib/update.js +0 -111
@@ -1,24 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
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.
8
- *
9
- *
10
- */
11
-
12
- 'use strict';
13
-
14
- var ReactPropTypeLocationNames = {};
15
-
16
- if (process.env.NODE_ENV !== 'production') {
17
- ReactPropTypeLocationNames = {
18
- prop: 'prop',
19
- context: 'context',
20
- childContext: 'child context'
21
- };
22
- }
23
-
24
- module.exports = ReactPropTypeLocationNames;
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
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.
8
- *
9
- *
10
- */
11
-
12
- 'use strict';
@@ -1,103 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
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.
8
- *
9
- */
10
-
11
- 'use strict';
12
-
13
- var ReactStateSetters = {
14
- /**
15
- * Returns a function that calls the provided function, and uses the result
16
- * of that to set the component's state.
17
- *
18
- * @param {ReactCompositeComponent} component
19
- * @param {function} funcReturningState Returned callback uses this to
20
- * determine how to update state.
21
- * @return {function} callback that when invoked uses funcReturningState to
22
- * determined the object literal to setState.
23
- */
24
- createStateSetter: function (component, funcReturningState) {
25
- return function (a, b, c, d, e, f) {
26
- var partialState = funcReturningState.call(component, a, b, c, d, e, f);
27
- if (partialState) {
28
- component.setState(partialState);
29
- }
30
- };
31
- },
32
-
33
- /**
34
- * Returns a single-argument callback that can be used to update a single
35
- * key in the component's state.
36
- *
37
- * Note: this is memoized function, which makes it inexpensive to call.
38
- *
39
- * @param {ReactCompositeComponent} component
40
- * @param {string} key The key in the state that you should update.
41
- * @return {function} callback of 1 argument which calls setState() with
42
- * the provided keyName and callback argument.
43
- */
44
- createStateKeySetter: function (component, key) {
45
- // Memoize the setters.
46
- var cache = component.__keySetters || (component.__keySetters = {});
47
- return cache[key] || (cache[key] = createStateKeySetter(component, key));
48
- }
49
- };
50
-
51
- function createStateKeySetter(component, key) {
52
- // Partial state is allocated outside of the function closure so it can be
53
- // reused with every call, avoiding memory allocation when this function
54
- // is called.
55
- var partialState = {};
56
- return function stateKeySetter(value) {
57
- partialState[key] = value;
58
- component.setState(partialState);
59
- };
60
- }
61
-
62
- ReactStateSetters.Mixin = {
63
- /**
64
- * Returns a function that calls the provided function, and uses the result
65
- * of that to set the component's state.
66
- *
67
- * For example, these statements are equivalent:
68
- *
69
- * this.setState({x: 1});
70
- * this.createStateSetter(function(xValue) {
71
- * return {x: xValue};
72
- * })(1);
73
- *
74
- * @param {function} funcReturningState Returned callback uses this to
75
- * determine how to update state.
76
- * @return {function} callback that when invoked uses funcReturningState to
77
- * determined the object literal to setState.
78
- */
79
- createStateSetter: function (funcReturningState) {
80
- return ReactStateSetters.createStateSetter(this, funcReturningState);
81
- },
82
-
83
- /**
84
- * Returns a single-argument callback that can be used to update a single
85
- * key in the component's state.
86
- *
87
- * For example, these statements are equivalent:
88
- *
89
- * this.setState({x: 1});
90
- * this.createStateKeySetter('x')(1);
91
- *
92
- * Note: this is memoized function, which makes it inexpensive to call.
93
- *
94
- * @param {string} key The key in the state that you should update.
95
- * @return {function} callback of 1 argument which calls setState() with
96
- * the provided keyName and callback argument.
97
- */
98
- createStateKeySetter: function (key) {
99
- return ReactStateSetters.createStateKeySetter(this, key);
100
- }
101
- };
102
-
103
- module.exports = ReactStateSetters;
@@ -1,102 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
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.
8
- *
9
- */
10
-
11
- 'use strict';
12
-
13
- var flattenChildren = require('./flattenChildren');
14
-
15
- var ReactTransitionChildMapping = {
16
- /**
17
- * Given `this.props.children`, return an object mapping key to child. Just
18
- * simple syntactic sugar around flattenChildren().
19
- *
20
- * @param {*} children `this.props.children`
21
- * @param {number=} selfDebugID Optional debugID of the current internal instance.
22
- * @return {object} Mapping of key to child
23
- */
24
- getChildMapping: function (children, selfDebugID) {
25
- if (!children) {
26
- return children;
27
- }
28
-
29
- if (process.env.NODE_ENV !== 'production') {
30
- return flattenChildren(children, selfDebugID);
31
- }
32
-
33
- return flattenChildren(children);
34
- },
35
-
36
- /**
37
- * When you're adding or removing children some may be added or removed in the
38
- * same render pass. We want to show *both* since we want to simultaneously
39
- * animate elements in and out. This function takes a previous set of keys
40
- * and a new set of keys and merges them with its best guess of the correct
41
- * ordering. In the future we may expose some of the utilities in
42
- * ReactMultiChild to make this easy, but for now React itself does not
43
- * directly have this concept of the union of prevChildren and nextChildren
44
- * so we implement it here.
45
- *
46
- * @param {object} prev prev children as returned from
47
- * `ReactTransitionChildMapping.getChildMapping()`.
48
- * @param {object} next next children as returned from
49
- * `ReactTransitionChildMapping.getChildMapping()`.
50
- * @return {object} a key set that contains all keys in `prev` and all keys
51
- * in `next` in a reasonable order.
52
- */
53
- mergeChildMappings: function (prev, next) {
54
- prev = prev || {};
55
- next = next || {};
56
-
57
- function getValueForKey(key) {
58
- if (next.hasOwnProperty(key)) {
59
- return next[key];
60
- } else {
61
- return prev[key];
62
- }
63
- }
64
-
65
- // For each key of `next`, the list of keys to insert before that key in
66
- // the combined list
67
- var nextKeysPending = {};
68
-
69
- var pendingKeys = [];
70
- for (var prevKey in prev) {
71
- if (next.hasOwnProperty(prevKey)) {
72
- if (pendingKeys.length) {
73
- nextKeysPending[prevKey] = pendingKeys;
74
- pendingKeys = [];
75
- }
76
- } else {
77
- pendingKeys.push(prevKey);
78
- }
79
- }
80
-
81
- var i;
82
- var childMapping = {};
83
- for (var nextKey in next) {
84
- if (nextKeysPending.hasOwnProperty(nextKey)) {
85
- for (i = 0; i < nextKeysPending[nextKey].length; i++) {
86
- var pendingNextKey = nextKeysPending[nextKey][i];
87
- childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
88
- }
89
- }
90
- childMapping[nextKey] = getValueForKey(nextKey);
91
- }
92
-
93
- // Finally, add the keys which didn't appear before any key in `next`
94
- for (i = 0; i < pendingKeys.length; i++) {
95
- childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
96
- }
97
-
98
- return childMapping;
99
- }
100
- };
101
-
102
- module.exports = ReactTransitionChildMapping;
@@ -1,72 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
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.
8
- *
9
- */
10
-
11
- 'use strict';
12
-
13
- var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
14
-
15
- var getVendorPrefixedEventName = require('react-dom/lib/getVendorPrefixedEventName');
16
-
17
- var endEvents = [];
18
-
19
- function detectEvents() {
20
- var animEnd = getVendorPrefixedEventName('animationend');
21
- var transEnd = getVendorPrefixedEventName('transitionend');
22
-
23
- if (animEnd) {
24
- endEvents.push(animEnd);
25
- }
26
-
27
- if (transEnd) {
28
- endEvents.push(transEnd);
29
- }
30
- }
31
-
32
- if (ExecutionEnvironment.canUseDOM) {
33
- detectEvents();
34
- }
35
-
36
- // We use the raw {add|remove}EventListener() call because EventListener
37
- // does not know how to remove event listeners and we really should
38
- // clean up. Also, these events are not triggered in older browsers
39
- // so we should be A-OK here.
40
-
41
- function addEventListener(node, eventName, eventListener) {
42
- node.addEventListener(eventName, eventListener, false);
43
- }
44
-
45
- function removeEventListener(node, eventName, eventListener) {
46
- node.removeEventListener(eventName, eventListener, false);
47
- }
48
-
49
- var ReactTransitionEvents = {
50
- addEndEventListener: function (node, eventListener) {
51
- if (endEvents.length === 0) {
52
- // If CSS transitions are not supported, trigger an "end animation"
53
- // event immediately.
54
- window.setTimeout(eventListener, 0);
55
- return;
56
- }
57
- endEvents.forEach(function (endEvent) {
58
- addEventListener(node, endEvent, eventListener);
59
- });
60
- },
61
-
62
- removeEndEventListener: function (node, eventListener) {
63
- if (endEvents.length === 0) {
64
- return;
65
- }
66
- endEvents.forEach(function (endEvent) {
67
- removeEventListener(node, endEvent, eventListener);
68
- });
69
- }
70
- };
71
-
72
- module.exports = ReactTransitionEvents;
@@ -1,228 +0,0 @@
1
- /**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
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.
8
- *
9
- */
10
-
11
- 'use strict';
12
-
13
- var _assign = require('object-assign');
14
-
15
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
-
17
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
18
-
19
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
20
-
21
- var React = require('./React');
22
- var ReactTransitionChildMapping = require('./ReactTransitionChildMapping');
23
-
24
- var emptyFunction = require('fbjs/lib/emptyFunction');
25
-
26
- /**
27
- * A basis for animations. When children are declaratively added or removed,
28
- * special lifecycle hooks are called.
29
- * See https://facebook.github.io/react/docs/animation.html#low-level-api-reacttransitiongroup
30
- */
31
-
32
- var ReactTransitionGroup = function (_React$Component) {
33
- _inherits(ReactTransitionGroup, _React$Component);
34
-
35
- function ReactTransitionGroup() {
36
- var _temp, _this, _ret;
37
-
38
- _classCallCheck(this, ReactTransitionGroup);
39
-
40
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
41
- args[_key] = arguments[_key];
42
- }
43
-
44
- return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
45
- // TODO: can we get useful debug information to show at this point?
46
- children: ReactTransitionChildMapping.getChildMapping(_this.props.children)
47
- }, _this.performAppear = function (key) {
48
- _this.currentlyTransitioningKeys[key] = true;
49
-
50
- var component = _this.refs[key];
51
-
52
- if (component.componentWillAppear) {
53
- component.componentWillAppear(_this._handleDoneAppearing.bind(_this, key));
54
- } else {
55
- _this._handleDoneAppearing(key);
56
- }
57
- }, _this._handleDoneAppearing = function (key) {
58
- var component = _this.refs[key];
59
- if (component.componentDidAppear) {
60
- component.componentDidAppear();
61
- }
62
-
63
- delete _this.currentlyTransitioningKeys[key];
64
-
65
- var currentChildMapping = ReactTransitionChildMapping.getChildMapping(_this.props.children);
66
-
67
- if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
68
- // This was removed before it had fully appeared. Remove it.
69
- _this.performLeave(key);
70
- }
71
- }, _this.performEnter = function (key) {
72
- _this.currentlyTransitioningKeys[key] = true;
73
-
74
- var component = _this.refs[key];
75
-
76
- if (component.componentWillEnter) {
77
- component.componentWillEnter(_this._handleDoneEntering.bind(_this, key));
78
- } else {
79
- _this._handleDoneEntering(key);
80
- }
81
- }, _this._handleDoneEntering = function (key) {
82
- var component = _this.refs[key];
83
- if (component.componentDidEnter) {
84
- component.componentDidEnter();
85
- }
86
-
87
- delete _this.currentlyTransitioningKeys[key];
88
-
89
- var currentChildMapping = ReactTransitionChildMapping.getChildMapping(_this.props.children);
90
-
91
- if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
92
- // This was removed before it had fully entered. Remove it.
93
- _this.performLeave(key);
94
- }
95
- }, _this.performLeave = function (key) {
96
- _this.currentlyTransitioningKeys[key] = true;
97
-
98
- var component = _this.refs[key];
99
- if (component.componentWillLeave) {
100
- component.componentWillLeave(_this._handleDoneLeaving.bind(_this, key));
101
- } else {
102
- // Note that this is somewhat dangerous b/c it calls setState()
103
- // again, effectively mutating the component before all the work
104
- // is done.
105
- _this._handleDoneLeaving(key);
106
- }
107
- }, _this._handleDoneLeaving = function (key) {
108
- var component = _this.refs[key];
109
-
110
- if (component.componentDidLeave) {
111
- component.componentDidLeave();
112
- }
113
-
114
- delete _this.currentlyTransitioningKeys[key];
115
-
116
- var currentChildMapping = ReactTransitionChildMapping.getChildMapping(_this.props.children);
117
-
118
- if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
119
- // This entered again before it fully left. Add it again.
120
- _this.performEnter(key);
121
- } else {
122
- _this.setState(function (state) {
123
- var newChildren = _assign({}, state.children);
124
- delete newChildren[key];
125
- return { children: newChildren };
126
- });
127
- }
128
- }, _temp), _possibleConstructorReturn(_this, _ret);
129
- }
130
-
131
- ReactTransitionGroup.prototype.componentWillMount = function componentWillMount() {
132
- this.currentlyTransitioningKeys = {};
133
- this.keysToEnter = [];
134
- this.keysToLeave = [];
135
- };
136
-
137
- ReactTransitionGroup.prototype.componentDidMount = function componentDidMount() {
138
- var initialChildMapping = this.state.children;
139
- for (var key in initialChildMapping) {
140
- if (initialChildMapping[key]) {
141
- this.performAppear(key);
142
- }
143
- }
144
- };
145
-
146
- ReactTransitionGroup.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
147
- var nextChildMapping = ReactTransitionChildMapping.getChildMapping(nextProps.children);
148
- var prevChildMapping = this.state.children;
149
-
150
- this.setState({
151
- children: ReactTransitionChildMapping.mergeChildMappings(prevChildMapping, nextChildMapping)
152
- });
153
-
154
- var key;
155
-
156
- for (key in nextChildMapping) {
157
- var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
158
- if (nextChildMapping[key] && !hasPrev && !this.currentlyTransitioningKeys[key]) {
159
- this.keysToEnter.push(key);
160
- }
161
- }
162
-
163
- for (key in prevChildMapping) {
164
- var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
165
- if (prevChildMapping[key] && !hasNext && !this.currentlyTransitioningKeys[key]) {
166
- this.keysToLeave.push(key);
167
- }
168
- }
169
-
170
- // If we want to someday check for reordering, we could do it here.
171
- };
172
-
173
- ReactTransitionGroup.prototype.componentDidUpdate = function componentDidUpdate() {
174
- var keysToEnter = this.keysToEnter;
175
- this.keysToEnter = [];
176
- keysToEnter.forEach(this.performEnter);
177
-
178
- var keysToLeave = this.keysToLeave;
179
- this.keysToLeave = [];
180
- keysToLeave.forEach(this.performLeave);
181
- };
182
-
183
- ReactTransitionGroup.prototype.render = function render() {
184
- // TODO: we could get rid of the need for the wrapper node
185
- // by cloning a single child
186
- var childrenToRender = [];
187
- for (var key in this.state.children) {
188
- var child = this.state.children[key];
189
- if (child) {
190
- // You may need to apply reactive updates to a child as it is leaving.
191
- // The normal React way to do it won't work since the child will have
192
- // already been removed. In case you need this behavior you can provide
193
- // a childFactory function to wrap every child, even the ones that are
194
- // leaving.
195
- childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
196
- }
197
- }
198
-
199
- // Do not forward ReactTransitionGroup props to primitive DOM nodes
200
- var props = _assign({}, this.props);
201
- delete props.transitionLeave;
202
- delete props.transitionName;
203
- delete props.transitionAppear;
204
- delete props.transitionEnter;
205
- delete props.childFactory;
206
- delete props.transitionLeaveTimeout;
207
- delete props.transitionEnterTimeout;
208
- delete props.transitionAppearTimeout;
209
- delete props.component;
210
-
211
- return React.createElement(this.props.component, props, childrenToRender);
212
- };
213
-
214
- return ReactTransitionGroup;
215
- }(React.Component);
216
-
217
- ReactTransitionGroup.displayName = 'ReactTransitionGroup';
218
- ReactTransitionGroup.propTypes = {
219
- component: React.PropTypes.any,
220
- childFactory: React.PropTypes.func
221
- };
222
- ReactTransitionGroup.defaultProps = {
223
- component: 'span',
224
- childFactory: emptyFunction.thatReturnsArgument
225
- };
226
-
227
-
228
- module.exports = ReactTransitionGroup;