@enact/ui 4.5.2 → 4.6.0
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.
- package/AnnounceDecorator/Announce.js +1 -40
- package/AnnounceDecorator/AnnounceDecorator.js +3 -21
- package/AnnounceDecorator/tests/Announce-specs.js +2 -7
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
- package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
- package/AnnounceDecorator/useAnnounce.js +0 -6
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +8 -28
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +33 -63
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +30 -0
- package/Cancelable/Cancelable.js +8 -47
- package/Cancelable/cancelHandler.js +5 -12
- package/Cancelable/modalHandler.js +3 -11
- package/Cancelable/tests/Cancelable-specs.js +3 -57
- package/Changeable/Changeable.js +2 -34
- package/Changeable/tests/Changeable-specs.js +20 -66
- package/ComponentOverride/ComponentOverride.js +1 -13
- package/FloatingLayer/FloatingLayer.js +17 -73
- package/FloatingLayer/FloatingLayerContainer.js +0 -15
- package/FloatingLayer/FloatingLayerDecorator.js +4 -17
- package/FloatingLayer/Scrim.js +9 -53
- package/FloatingLayer/index.js +0 -4
- package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
- package/FloatingLayer/tests/Scrim-specs.js +0 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
- package/FloatingLayer/useFloatingLayer.js +3 -14
- package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
- package/ForwardRef/ForwardRef.js +1 -10
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +18 -51
- package/Group/Group.js +5 -36
- package/Group/GroupItem.js +16 -33
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +8 -36
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +19 -53
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +17 -55
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +17 -46
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +18 -47
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +9 -33
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.d.ts +2 -2
- package/LabeledIcon/LabeledIcon.js +22 -53
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +18 -44
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +23 -46
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +70 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +295 -87
- package/Measurable/Measurable.js +12 -34
- package/Measurable/tests/Measurable-specs.js +115 -0
- package/Media/Media.js +15 -65
- package/Media/tests/Media-specs.js +168 -0
- package/Placeholder/PlaceholderControllerDecorator.js +7 -43
- package/Placeholder/PlaceholderDecorator.js +7 -38
- package/Placeholder/index.js +1 -5
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +14 -45
- package/ProgressBar/tests/ProgressBar-specs.js +0 -17
- package/RadioDecorator/RadioControllerDecorator.js +1 -29
- package/RadioDecorator/RadioDecorator.js +4 -42
- package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
- package/Repeater/Repeater.js +9 -33
- package/Repeater/tests/Repeater-specs.js +0 -38
- package/Resizable/Resizable.js +9 -37
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +11 -47
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +12 -35
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +15 -58
- package/Routable/tests/Routable-specs.js +7 -33
- package/Routable/tests/Router-specs.js +18 -44
- package/Routable/useLink.js +4 -8
- package/Routable/util.js +18 -24
- package/Scrollable/ScrollAnimator.js +49 -65
- package/Scrollable/ScrollThumb.js +2 -13
- package/Scrollable/Scrollable.js +180 -387
- package/Scrollable/ScrollableNative.js +189 -392
- package/Scrollable/Scrollbar.js +30 -102
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- package/Scroller/tests/Scroller-specs.js +56 -0
- package/Skinnable/Skinnable.js +11 -38
- package/Skinnable/tests/Skinnable-specs.js +3 -74
- package/Skinnable/tests/useSkins-specs.js +1 -13
- package/Skinnable/tests/util-specs.js +0 -14
- package/Skinnable/useSkins.js +8 -15
- package/Skinnable/util.js +9 -20
- package/Slider/Knob.js +5 -24
- package/Slider/PositionDecorator.js +16 -54
- package/Slider/Slider.d.ts +2 -2
- package/Slider/Slider.js +29 -67
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.d.ts +1 -1
- package/SlotItem/SlotItem.js +17 -43
- package/SlotItem/tests/SlotItem-specs.js +0 -5
- package/Slottable/Slottable.js +4 -12
- package/Slottable/tests/Slottable-specs.js +19 -46
- package/Slottable/tests/useSlots-specs.js +27 -65
- package/Slottable/useSlots.js +8 -33
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +16 -43
- package/Spinner/tests/Spinner-specs.js +0 -15
- package/ToggleIcon/ToggleIcon.js +10 -36
- package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
- package/ToggleItem/ToggleItem.d.ts +3 -3
- package/ToggleItem/ToggleItem.js +18 -55
- package/ToggleItem/tests/ToggleItem-specs.js +0 -30
- package/Toggleable/Toggle.js +1 -15
- package/Toggleable/Toggleable.js +12 -45
- package/Toggleable/tests/Toggleable-specs.js +28 -96
- package/Toggleable/useToggle.js +3 -19
- package/Touchable/ClickAllow.js +5 -14
- package/Touchable/Drag.js +16 -54
- package/Touchable/Flick.js +11 -42
- package/Touchable/Hold.js +21 -68
- package/Touchable/Touch.js +37 -65
- package/Touchable/Touchable.js +32 -71
- package/Touchable/config.js +8 -22
- package/Touchable/tests/Touchable-specs.js +270 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +17 -34
- package/Transition/Transition.js +37 -118
- package/Transition/tests/Transition-specs.js +20 -60
- package/ViewManager/Arranger.js +10 -22
- package/ViewManager/TransitionGroup.js +32 -107
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.d.ts +1 -1
- package/ViewManager/ViewManager.js +20 -84
- package/ViewManager/tests/View-specs.js +0 -17
- package/ViewManager/tests/ViewManager-specs.js +236 -305
- package/ViewManager/tests/test-utils.js +0 -8
- package/VirtualList/UiVirtualListBase.js +259 -409
- package/VirtualList/VirtualList.d.ts +4 -4
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +273 -431
- package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
- package/VirtualList/tests/VirtualGridList-specs.js +614 -0
- package/VirtualList/tests/VirtualList-native-specs.js +152 -0
- package/VirtualList/tests/VirtualList-specs.js +423 -95
- package/internal/IdProvider/IdProvider.js +7 -21
- package/internal/IdProvider/Provider.js +4 -17
- package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
- package/internal/IdProvider/tests/useId-specs.js +6 -20
- package/internal/IdProvider/useId.js +0 -6
- package/internal/Pure/Pure.js +3 -30
- package/internal/Pure/tests/Pure-specs.js +88 -0
- package/internal/localized-fonts/localized-fonts.js +33 -62
- package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
- package/internal/selection/selection.js +1 -6
- package/internal/selection/tests/selection-specs.js +6 -4
- package/internal/validators/tests/validators-specs.js +80 -0
- package/internal/validators/validators.js +14 -34
- package/package.json +9 -3
- package/resolution/ResolutionDecorator.js +4 -40
- package/resolution/index.js +0 -7
- package/resolution/resolution.js +42 -80
- package/resolution/tests/ResolutionDecorator-specs.js +4 -11
- package/resolution/tests/resolution-specs.js +2 -2
- package/useControlledState/tests/useControlledState-specs.js +15 -46
- package/useControlledState/useControlledState.js +11 -22
- package/useScroll/ScrollAnimator.js +49 -65
- package/useScroll/Scrollbar.js +22 -58
- package/useScroll/ScrollbarTrack.js +3 -19
- package/useScroll/useScroll.js +267 -454
- package/useScroll/utilDOM.js +8 -14
- package/useScroll/utilEvent.js +0 -4
|
@@ -4,53 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.TransitionGroup = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
9
|
-
|
|
10
8
|
var _handle = require("@enact/core/handle");
|
|
11
|
-
|
|
12
9
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _eqBy = _interopRequireDefault(require("ramda/src/eqBy"));
|
|
15
|
-
|
|
16
11
|
var _findIndex = _interopRequireDefault(require("ramda/src/findIndex"));
|
|
17
|
-
|
|
18
12
|
var _identity = _interopRequireDefault(require("ramda/src/identity"));
|
|
19
|
-
|
|
20
13
|
var _prop = _interopRequireDefault(require("ramda/src/prop"));
|
|
21
|
-
|
|
22
14
|
var _propEq = _interopRequireDefault(require("ramda/src/propEq"));
|
|
23
|
-
|
|
24
15
|
var _remove = _interopRequireDefault(require("ramda/src/remove"));
|
|
25
|
-
|
|
26
16
|
var _unionWith = _interopRequireDefault(require("ramda/src/unionWith"));
|
|
27
|
-
|
|
28
17
|
var _useWith = _interopRequireDefault(require("ramda/src/useWith"));
|
|
29
|
-
|
|
30
18
|
var _react = require("react");
|
|
31
|
-
|
|
32
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
|
-
|
|
34
20
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
35
|
-
|
|
36
21
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
37
|
-
|
|
38
22
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
39
|
-
|
|
40
23
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
41
|
-
|
|
42
24
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
43
|
-
|
|
44
25
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
45
|
-
|
|
46
26
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
47
|
-
|
|
48
27
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
49
|
-
|
|
50
28
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
51
|
-
|
|
52
29
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
|
-
|
|
54
30
|
/**
|
|
55
31
|
* Returns the index of a child in an array found by `key` matching
|
|
56
32
|
*
|
|
@@ -62,6 +38,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
62
38
|
*/
|
|
63
39
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
64
40
|
var indexOfChild = (0, _useWith["default"])(_findIndex["default"], [(0, _propEq["default"])('key'), _identity["default"]]);
|
|
41
|
+
|
|
65
42
|
/**
|
|
66
43
|
* Returns an array of non-null children
|
|
67
44
|
*
|
|
@@ -70,14 +47,13 @@ var indexOfChild = (0, _useWith["default"])(_findIndex["default"], [(0, _propEq[
|
|
|
70
47
|
* @returns {Object[]} Array of children
|
|
71
48
|
* @private
|
|
72
49
|
*/
|
|
73
|
-
|
|
74
50
|
var mapChildren = function mapChildren(children) {
|
|
75
51
|
var result = children && _react.Children.toArray(children);
|
|
76
|
-
|
|
77
52
|
return result ? result.filter(function (c) {
|
|
78
53
|
return !!c;
|
|
79
54
|
}) : [];
|
|
80
55
|
};
|
|
56
|
+
|
|
81
57
|
/**
|
|
82
58
|
* Merges two arrays of children without any duplicates (by `key`)
|
|
83
59
|
*
|
|
@@ -87,14 +63,14 @@ var mapChildren = function mapChildren(children) {
|
|
|
87
63
|
* @method
|
|
88
64
|
* @private
|
|
89
65
|
*/
|
|
66
|
+
var mergeChildren = (0, _unionWith["default"])((0, _eqBy["default"])((0, _prop["default"])('key')));
|
|
90
67
|
|
|
91
|
-
|
|
92
|
-
var mergeChildren = (0, _unionWith["default"])((0, _eqBy["default"])((0, _prop["default"])('key'))); // Cached event forwarders
|
|
93
|
-
|
|
68
|
+
// Cached event forwarders
|
|
94
69
|
var forwardOnAppear = (0, _handle.forward)('onAppear');
|
|
95
70
|
var forwardOnEnter = (0, _handle.forward)('onEnter');
|
|
96
71
|
var forwardOnLeave = (0, _handle.forward)('onLeave');
|
|
97
72
|
var forwardOnStay = (0, _handle.forward)('onStay');
|
|
73
|
+
|
|
98
74
|
/**
|
|
99
75
|
* Manages the transition of added and removed child components. Children that are added are
|
|
100
76
|
* transitioned in and those removed are transition out via optional callbacks on the child.
|
|
@@ -107,49 +83,36 @@ var forwardOnStay = (0, _handle.forward)('onStay');
|
|
|
107
83
|
* @memberof ui/ViewManager
|
|
108
84
|
* @private
|
|
109
85
|
*/
|
|
110
|
-
|
|
111
86
|
var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
112
87
|
_inherits(TransitionGroup, _Component);
|
|
113
|
-
|
|
114
88
|
var _super = _createSuper(TransitionGroup);
|
|
115
|
-
|
|
116
89
|
function TransitionGroup(props) {
|
|
117
90
|
var _this;
|
|
118
|
-
|
|
119
91
|
_classCallCheck(this, TransitionGroup);
|
|
120
|
-
|
|
121
92
|
_this = _super.call(this, props);
|
|
122
|
-
|
|
123
93
|
_this.performAppear = function (key) {
|
|
124
94
|
_this.currentlyTransitioningKeys[key] = true;
|
|
125
95
|
var component = _this.groupRefs[key];
|
|
126
|
-
|
|
127
96
|
if (component.componentWillAppear) {
|
|
128
97
|
component.componentWillAppear(_this._handleDoneAppearing.bind(_assertThisInitialized(_this), key));
|
|
129
98
|
} else {
|
|
130
99
|
_this._handleDoneAppearing(key);
|
|
131
100
|
}
|
|
132
101
|
};
|
|
133
|
-
|
|
134
102
|
_this._handleDoneAppearing = function (key) {
|
|
135
103
|
var component = _this.groupRefs[key];
|
|
136
|
-
|
|
137
104
|
if (component.componentDidAppear) {
|
|
138
105
|
component.componentDidAppear();
|
|
139
106
|
}
|
|
140
|
-
|
|
141
107
|
forwardOnAppear({
|
|
142
108
|
type: 'onAppear',
|
|
143
109
|
view: component
|
|
144
110
|
}, _this.props);
|
|
145
|
-
|
|
146
111
|
_this.completeTransition({
|
|
147
112
|
key: key,
|
|
148
113
|
noForwarding: true
|
|
149
114
|
});
|
|
150
|
-
|
|
151
115
|
var currentChildMapping = mapChildren(_this.props.children);
|
|
152
|
-
|
|
153
116
|
if (!currentChildMapping || !currentChildMapping.find(function (child) {
|
|
154
117
|
return child.key === key;
|
|
155
118
|
})) {
|
|
@@ -157,62 +120,49 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
157
120
|
_this.performLeave(key);
|
|
158
121
|
}
|
|
159
122
|
};
|
|
160
|
-
|
|
161
123
|
_this.performEnter = function (key) {
|
|
162
124
|
_this.currentlyTransitioningKeys[key] = true;
|
|
163
125
|
var component = _this.groupRefs[key];
|
|
164
|
-
|
|
165
126
|
if (component.componentWillEnter) {
|
|
166
127
|
component.componentWillEnter(_this._handleDoneEntering.bind(_assertThisInitialized(_this), key));
|
|
167
128
|
} else {
|
|
168
129
|
_this._handleDoneEntering(key);
|
|
169
130
|
}
|
|
170
131
|
};
|
|
171
|
-
|
|
172
132
|
_this._handleDoneEntering = function (key) {
|
|
173
133
|
var component = _this.groupRefs[key];
|
|
174
|
-
|
|
175
134
|
if (component.componentDidEnter) {
|
|
176
135
|
component.componentDidEnter();
|
|
177
136
|
}
|
|
178
|
-
|
|
179
137
|
forwardOnEnter({
|
|
180
138
|
type: 'onEnter',
|
|
181
139
|
view: component
|
|
182
140
|
}, _this.props);
|
|
183
|
-
|
|
184
141
|
_this.completeTransition({
|
|
185
142
|
key: key
|
|
186
143
|
});
|
|
187
144
|
};
|
|
188
|
-
|
|
189
145
|
_this.performStay = function (key) {
|
|
190
146
|
var component = _this.groupRefs[key];
|
|
191
|
-
|
|
192
147
|
if (component.componentWillStay) {
|
|
193
148
|
component.componentWillStay(_this._handleDoneStaying.bind(_assertThisInitialized(_this), key));
|
|
194
149
|
} else {
|
|
195
150
|
_this._handleDoneStaying(key);
|
|
196
151
|
}
|
|
197
152
|
};
|
|
198
|
-
|
|
199
153
|
_this._handleDoneStaying = function (key) {
|
|
200
154
|
var component = _this.groupRefs[key];
|
|
201
|
-
|
|
202
155
|
if (component.componentDidStay) {
|
|
203
156
|
component.componentDidStay();
|
|
204
157
|
}
|
|
205
|
-
|
|
206
158
|
forwardOnStay({
|
|
207
159
|
type: 'onStay',
|
|
208
160
|
view: component
|
|
209
161
|
}, _this.props);
|
|
210
162
|
};
|
|
211
|
-
|
|
212
163
|
_this.performLeave = function (key) {
|
|
213
164
|
_this.currentlyTransitioningKeys[key] = true;
|
|
214
165
|
var component = _this.groupRefs[key];
|
|
215
|
-
|
|
216
166
|
if (component.componentWillLeave) {
|
|
217
167
|
component.componentWillLeave(_this._handleDoneLeaving.bind(_assertThisInitialized(_this), key));
|
|
218
168
|
} else {
|
|
@@ -222,23 +172,18 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
222
172
|
_this._handleDoneLeaving(key);
|
|
223
173
|
}
|
|
224
174
|
};
|
|
225
|
-
|
|
226
175
|
_this._handleDoneLeaving = function (key) {
|
|
227
176
|
var component = _this.groupRefs[key];
|
|
228
|
-
|
|
229
177
|
if (component.componentDidLeave) {
|
|
230
178
|
component.componentDidLeave();
|
|
231
179
|
}
|
|
232
|
-
|
|
233
180
|
forwardOnLeave({
|
|
234
181
|
type: 'onLeave',
|
|
235
182
|
view: component
|
|
236
183
|
}, _this.props);
|
|
237
|
-
|
|
238
184
|
_this.completeTransition({
|
|
239
185
|
key: key
|
|
240
186
|
});
|
|
241
|
-
|
|
242
187
|
_this.setState(function (state) {
|
|
243
188
|
var index = indexOfChild(key, state.children);
|
|
244
189
|
return {
|
|
@@ -246,13 +191,11 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
246
191
|
};
|
|
247
192
|
});
|
|
248
193
|
};
|
|
249
|
-
|
|
250
194
|
_this.storeRefs = function (key) {
|
|
251
195
|
return function (node) {
|
|
252
196
|
_this.groupRefs[key] = node;
|
|
253
197
|
};
|
|
254
198
|
};
|
|
255
|
-
|
|
256
199
|
_this.state = {
|
|
257
200
|
firstRender: true,
|
|
258
201
|
children: []
|
|
@@ -265,15 +208,14 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
265
208
|
_this.groupRefs = {};
|
|
266
209
|
return _this;
|
|
267
210
|
}
|
|
268
|
-
|
|
269
211
|
_createClass(TransitionGroup, [{
|
|
270
212
|
key: "componentDidMount",
|
|
271
213
|
value: function componentDidMount() {
|
|
272
214
|
var _this2 = this;
|
|
215
|
+
this.hasMounted = true;
|
|
273
216
|
|
|
274
|
-
|
|
217
|
+
// this isn't used by ViewManager or View at the moment but leaving it around for future
|
|
275
218
|
// flexibility
|
|
276
|
-
|
|
277
219
|
this.state.children.forEach(function (child) {
|
|
278
220
|
return _this2.performAppear(child.key);
|
|
279
221
|
});
|
|
@@ -288,17 +230,17 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
288
230
|
key: "reconcileUnmountedChildren",
|
|
289
231
|
value: function reconcileUnmountedChildren(prevChildMapping, nextChildMapping) {
|
|
290
232
|
var _this3 = this;
|
|
291
|
-
|
|
292
233
|
var nextChildKeys = nextChildMapping.map(function (c) {
|
|
293
234
|
return c.key;
|
|
294
235
|
});
|
|
295
236
|
var prevChildKeys = prevChildMapping.map(function (c) {
|
|
296
237
|
return c.key;
|
|
297
|
-
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// `state.children` represents the mounted children. if a view change happens during a
|
|
298
241
|
// transition causing the View to be unmounted before it fires its callback, the
|
|
299
242
|
// currentlyTransitioningKeys map will be out of sync. To manage that, we check for keys
|
|
300
243
|
// that have fallen out of the `children` array and manually clean them up from the map.
|
|
301
|
-
|
|
302
244
|
prevChildKeys.filter(function (key) {
|
|
303
245
|
return !nextChildKeys.includes(key);
|
|
304
246
|
}).forEach(function (key) {
|
|
@@ -311,7 +253,6 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
311
253
|
key: "reconcileChildren",
|
|
312
254
|
value: function reconcileChildren(prevActiveChildMapping, nextActiveChildMapping) {
|
|
313
255
|
var _this4 = this;
|
|
314
|
-
|
|
315
256
|
var size = this.props.size;
|
|
316
257
|
var nextChildKeys = nextActiveChildMapping.map(function (c) {
|
|
317
258
|
return c.key;
|
|
@@ -321,22 +262,23 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
321
262
|
});
|
|
322
263
|
var droppedKeys = prevChildKeys.filter(function (key) {
|
|
323
264
|
return !nextChildKeys.includes(key);
|
|
324
|
-
});
|
|
265
|
+
});
|
|
325
266
|
|
|
267
|
+
// if children haven't changed, there's nothing to reconcile
|
|
326
268
|
if (prevActiveChildMapping.length === nextActiveChildMapping.length && droppedKeys.length === 0) {
|
|
327
269
|
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
270
|
+
}
|
|
330
271
|
|
|
272
|
+
// remove any "dropped" children from the list of transitioning children
|
|
331
273
|
droppedKeys.forEach(function (key) {
|
|
332
274
|
return _this4.completeTransition({
|
|
333
275
|
key: key
|
|
334
276
|
});
|
|
335
|
-
});
|
|
277
|
+
});
|
|
336
278
|
|
|
279
|
+
// mark any new child as entering
|
|
337
280
|
nextChildKeys.forEach(function (key, index) {
|
|
338
281
|
var hasPrev = prevChildKeys.includes(key);
|
|
339
|
-
|
|
340
282
|
if (!hasPrev || _this4.currentlyTransitioningKeys[key]) {
|
|
341
283
|
// flag a view to enter if it's new (!hasPrev), or if it's not new (hasPrev) but is
|
|
342
284
|
// re-entering (is currently transitioning)
|
|
@@ -348,30 +290,32 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
348
290
|
// everything else is leaving
|
|
349
291
|
_this4.keysToLeave.push(key);
|
|
350
292
|
}
|
|
351
|
-
});
|
|
293
|
+
});
|
|
352
294
|
|
|
295
|
+
// mark any previous child not remaining as leaving
|
|
353
296
|
prevChildKeys.forEach(function (key) {
|
|
354
297
|
var hasNext = nextChildKeys.includes(key);
|
|
355
|
-
var isRendered = Boolean(_this4.groupRefs[key]);
|
|
356
|
-
|
|
298
|
+
var isRendered = Boolean(_this4.groupRefs[key]);
|
|
299
|
+
// flag a view to leave if it isn't in the new set (!hasNext) and it exists (isRendered)
|
|
357
300
|
if (!hasNext && isRendered) {
|
|
358
301
|
_this4.keysToLeave.push(key);
|
|
359
302
|
}
|
|
360
303
|
});
|
|
361
|
-
|
|
362
304
|
if (this.keysToEnter.length || this.keysToLeave.length) {
|
|
363
305
|
(0, _handle.forwardCustom)('onWillTransition')(null, this.props);
|
|
364
|
-
}
|
|
365
|
-
|
|
306
|
+
}
|
|
366
307
|
|
|
308
|
+
// once the component has been updated, start the enter transition for new children,
|
|
367
309
|
var keysToEnter = this.keysToEnter;
|
|
368
310
|
this.keysToEnter = [];
|
|
369
|
-
keysToEnter.forEach(this.performEnter);
|
|
311
|
+
keysToEnter.forEach(this.performEnter);
|
|
370
312
|
|
|
313
|
+
// ... the stay transition for any children remaining,
|
|
371
314
|
var keysToStay = this.keysToStay;
|
|
372
315
|
this.keysToStay = [];
|
|
373
|
-
keysToStay.forEach(this.performStay);
|
|
316
|
+
keysToStay.forEach(this.performStay);
|
|
374
317
|
|
|
318
|
+
// ... and the leave transition for departing children
|
|
375
319
|
var keysToLeave = this.keysToLeave;
|
|
376
320
|
this.keysToLeave = [];
|
|
377
321
|
keysToLeave.forEach(this.performLeave);
|
|
@@ -380,12 +324,10 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
380
324
|
key: "completeTransition",
|
|
381
325
|
value: function completeTransition(_ref) {
|
|
382
326
|
var key = _ref.key,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
327
|
+
_ref$noForwarding = _ref.noForwarding,
|
|
328
|
+
noForwarding = _ref$noForwarding === void 0 ? false : _ref$noForwarding;
|
|
386
329
|
if (key in this.currentlyTransitioningKeys) {
|
|
387
330
|
delete this.currentlyTransitioningKeys[key];
|
|
388
|
-
|
|
389
331
|
if (!noForwarding && Object.keys(this.currentlyTransitioningKeys).length === 0) {
|
|
390
332
|
(0, _handle.forwardCustom)('onTransition')(null, this.props);
|
|
391
333
|
}
|
|
@@ -395,7 +337,6 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
395
337
|
key: "render",
|
|
396
338
|
value: function render() {
|
|
397
339
|
var _this5 = this;
|
|
398
|
-
|
|
399
340
|
// support wrapping arbitrary children with a component that supports the necessary
|
|
400
341
|
// lifecycle methods to animate transitions
|
|
401
342
|
var childrenToRender = this.state.children.map(function (child) {
|
|
@@ -406,8 +347,9 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
406
347
|
leaving: isLeaving,
|
|
407
348
|
appearing: !_this5.hasMounted
|
|
408
349
|
});
|
|
409
|
-
});
|
|
350
|
+
});
|
|
410
351
|
|
|
352
|
+
// Do not forward TransitionGroup props to primitive DOM nodes
|
|
411
353
|
var props = Object.assign({}, this.props);
|
|
412
354
|
props.ref = this.props.componentRef;
|
|
413
355
|
delete props.childFactory;
|
|
@@ -427,7 +369,6 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
427
369
|
key: "getDerivedStateFromProps",
|
|
428
370
|
value: function getDerivedStateFromProps(props, state) {
|
|
429
371
|
var children = mapChildren(props.children).slice(0, props.size);
|
|
430
|
-
|
|
431
372
|
if (state.firstRender) {
|
|
432
373
|
return {
|
|
433
374
|
activeChildren: children,
|
|
@@ -435,30 +376,23 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
435
376
|
firstRender: false
|
|
436
377
|
};
|
|
437
378
|
}
|
|
438
|
-
|
|
439
379
|
return {
|
|
440
380
|
activeChildren: children,
|
|
441
381
|
children: mergeChildren(children, state.children).slice(0, props.size)
|
|
442
382
|
};
|
|
443
383
|
}
|
|
444
384
|
}]);
|
|
445
|
-
|
|
446
385
|
return TransitionGroup;
|
|
447
386
|
}(_react.Component);
|
|
448
|
-
|
|
449
387
|
exports.TransitionGroup = TransitionGroup;
|
|
450
|
-
TransitionGroup.propTypes =
|
|
451
|
-
/** @lends ui/ViewManager.TransitionGroup.prototype */
|
|
452
|
-
{
|
|
388
|
+
TransitionGroup.propTypes = /** @lends ui/ViewManager.TransitionGroup.prototype */{
|
|
453
389
|
children: _propTypes2["default"].node.isRequired,
|
|
454
|
-
|
|
455
390
|
/**
|
|
456
391
|
* Adapts children to be compatible with TransitionGroup
|
|
457
392
|
*
|
|
458
393
|
* @type {Function}
|
|
459
394
|
*/
|
|
460
395
|
childFactory: _propTypes2["default"].func,
|
|
461
|
-
|
|
462
396
|
/**
|
|
463
397
|
* Type of component wrapping the children.
|
|
464
398
|
*
|
|
@@ -468,64 +402,55 @@ TransitionGroup.propTypes =
|
|
|
468
402
|
* @default 'div'
|
|
469
403
|
*/
|
|
470
404
|
component: _propTypes["default"].renderable,
|
|
471
|
-
|
|
472
405
|
/**
|
|
473
|
-
* Called with a reference to
|
|
406
|
+
* Called with a reference to {@link ui/ViewManager.TransitionGroup#component|component}
|
|
474
407
|
*
|
|
475
408
|
* @type {Object|Function}
|
|
476
409
|
* @private
|
|
477
410
|
*/
|
|
478
411
|
componentRef: _propTypes["default"].ref,
|
|
479
|
-
|
|
480
412
|
/**
|
|
481
413
|
* Current Index the ViewManager is on
|
|
482
414
|
*
|
|
483
415
|
* @type {Number}
|
|
484
416
|
*/
|
|
485
417
|
currentIndex: _propTypes2["default"].number,
|
|
486
|
-
|
|
487
418
|
/**
|
|
488
419
|
* Called when each view is rendered during initial construction.
|
|
489
420
|
*
|
|
490
421
|
* @type {Function}
|
|
491
422
|
*/
|
|
492
423
|
onAppear: _propTypes2["default"].func,
|
|
493
|
-
|
|
494
424
|
/**
|
|
495
425
|
* Called when each view completes its transition into the viewport.
|
|
496
426
|
*
|
|
497
427
|
* @type {Function}
|
|
498
428
|
*/
|
|
499
429
|
onEnter: _propTypes2["default"].func,
|
|
500
|
-
|
|
501
430
|
/**
|
|
502
431
|
* Called when each view completes its transition out of the viewport.
|
|
503
432
|
*
|
|
504
433
|
* @type {Function}
|
|
505
434
|
*/
|
|
506
435
|
onLeave: _propTypes2["default"].func,
|
|
507
|
-
|
|
508
436
|
/**
|
|
509
437
|
* Called when each view completes its transition within the viewport.
|
|
510
438
|
*
|
|
511
439
|
* @type {Function}
|
|
512
440
|
*/
|
|
513
441
|
onStay: _propTypes2["default"].func,
|
|
514
|
-
|
|
515
442
|
/**
|
|
516
443
|
* Called once when all views have completed their transition.
|
|
517
444
|
*
|
|
518
445
|
* @type {Function}
|
|
519
446
|
*/
|
|
520
447
|
onTransition: _propTypes2["default"].func,
|
|
521
|
-
|
|
522
448
|
/**
|
|
523
449
|
* Called once before views begin their transition.
|
|
524
450
|
*
|
|
525
451
|
* @type {Function}
|
|
526
452
|
*/
|
|
527
453
|
onWillTransition: _propTypes2["default"].func,
|
|
528
|
-
|
|
529
454
|
/**
|
|
530
455
|
* Maximum number of rendered children.
|
|
531
456
|
*
|