@enact/ui 4.9.0-alpha.2 → 4.9.0-beta.1
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/CHANGELOG.md +14 -0
- package/Layout/Cell.js +6 -2
- package/Placeholder/PlaceholderControllerDecorator.js +10 -10
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +7 -2
- package/ViewManager/TransitionGroup.js +35 -5
- package/ViewManager/View.js +19 -3
- package/ViewManager/tests/View-specs.js +36 -0
- package/package.json +2 -2
- package/resolution/ResolutionDecorator.js +2 -3
- package/resolution/resolution.js +14 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
The following is a curated list of changes in the Enact ui module, newest changes on the top.
|
|
4
4
|
|
|
5
|
+
## [4.9.0-beta.1] - 2024-06-17
|
|
6
|
+
|
|
7
|
+
No significant changes.
|
|
8
|
+
|
|
9
|
+
## [4.9.0-alpha.3] - 2024-06-05
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- `ui/Placeholder.PlaceholderControllerDecorator` and `ui/ViewManager` to have sibling DOM node as alternative to findDOMNode API which will be removed in React 19
|
|
14
|
+
|
|
15
|
+
## [4.0.15] - 2024-05-28
|
|
16
|
+
|
|
17
|
+
No significant changes.
|
|
18
|
+
|
|
5
19
|
## [4.9.0-alpha.2] - 2024-05-24
|
|
6
20
|
|
|
7
21
|
No significant changes.
|
package/Layout/Cell.js
CHANGED
|
@@ -11,7 +11,8 @@ var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
|
|
|
11
11
|
var _resolution = _interopRequireDefault(require("../resolution"));
|
|
12
12
|
var _LayoutModule = _interopRequireDefault(require("./Layout.module.css"));
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
var _excluded = ["component", "componentCss", "componentRef"]
|
|
14
|
+
var _excluded = ["component", "componentCss", "componentRef"],
|
|
15
|
+
_excluded2 = ["key"];
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
17
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
18
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -192,10 +193,13 @@ var CellBase = exports.CellBase = (0, _kind["default"])({
|
|
|
192
193
|
delete rest.grow;
|
|
193
194
|
delete rest.shrink;
|
|
194
195
|
delete rest.size;
|
|
196
|
+
var _rest = _objectSpread({}, rest),
|
|
197
|
+
key = _rest.key,
|
|
198
|
+
restProps = _objectWithoutProperties(_rest, _excluded2);
|
|
195
199
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread({
|
|
196
200
|
css: componentCss,
|
|
197
201
|
ref: componentRef
|
|
198
|
-
},
|
|
202
|
+
}, restProps), key);
|
|
199
203
|
}
|
|
200
204
|
});
|
|
201
205
|
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = exports.PlaceholderControllerDecorator = exports.PlaceholderContext = void 0;
|
|
7
7
|
var _handle = require("@enact/core/handle");
|
|
8
8
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
9
|
+
var _WithRef = require("@enact/core/internal/WithRef");
|
|
9
10
|
var _util = require("@enact/core/util");
|
|
10
11
|
var _Registry = _interopRequireDefault(require("@enact/core/internal/Registry"));
|
|
11
12
|
var _react = require("react");
|
|
12
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -85,13 +85,10 @@ var PlaceholderControllerDecorator = exports.PlaceholderControllerDecorator = (0
|
|
|
85
85
|
return _class = /*#__PURE__*/function (_Component) {
|
|
86
86
|
_inherits(_class, _Component);
|
|
87
87
|
var _super = _createSuper(_class);
|
|
88
|
-
function _class() {
|
|
88
|
+
function _class(props) {
|
|
89
89
|
var _this;
|
|
90
90
|
_classCallCheck(this, _class);
|
|
91
|
-
|
|
92
|
-
args[_key] = arguments[_key];
|
|
93
|
-
}
|
|
94
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
91
|
+
_this = _super.call(this, props);
|
|
95
92
|
_this.bounds = null;
|
|
96
93
|
_this.leftThreshold = -1;
|
|
97
94
|
_this.node = null;
|
|
@@ -111,6 +108,7 @@ var PlaceholderControllerDecorator = exports.PlaceholderControllerDecorator = (0
|
|
|
111
108
|
scrollTop = _ref.scrollTop;
|
|
112
109
|
_this.setThresholds(scrollTop, scrollLeft);
|
|
113
110
|
});
|
|
111
|
+
_this.nodeRef = /*#__PURE__*/(0, _react.createRef)();
|
|
114
112
|
return _this;
|
|
115
113
|
}
|
|
116
114
|
_createClass(_class, [{
|
|
@@ -130,9 +128,7 @@ var PlaceholderControllerDecorator = exports.PlaceholderControllerDecorator = (0
|
|
|
130
128
|
if (bounds != null) {
|
|
131
129
|
this.bounds = Object.assign({}, bounds);
|
|
132
130
|
} else {
|
|
133
|
-
|
|
134
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
135
|
-
this.node = _reactDom["default"].findDOMNode(this);
|
|
131
|
+
this.node = this.nodeRef.current;
|
|
136
132
|
this.bounds = {
|
|
137
133
|
height: this.node.offsetHeight,
|
|
138
134
|
width: this.node.offsetWidth
|
|
@@ -167,10 +163,14 @@ var PlaceholderControllerDecorator = exports.PlaceholderControllerDecorator = (0
|
|
|
167
163
|
key: "render",
|
|
168
164
|
value: function render() {
|
|
169
165
|
var props = Object.assign({}, this.props);
|
|
166
|
+
var WrappedWithRef = (0, _WithRef.WithRef)(Wrapped);
|
|
170
167
|
if (notify) props[notify] = this.handleNotify;
|
|
171
168
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PlaceholderContext.Provider, {
|
|
172
169
|
value: this.registry.register,
|
|
173
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
170
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedWithRef, _objectSpread(_objectSpread({}, props), {}, {
|
|
171
|
+
outermostRef: this.nodeRef,
|
|
172
|
+
referrerName: "Placeholder"
|
|
173
|
+
}))
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
}]);
|
|
@@ -4,13 +4,18 @@ require("@testing-library/jest-dom");
|
|
|
4
4
|
var _react = require("@testing-library/react");
|
|
5
5
|
var _Placeholder = require("../../Placeholder");
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
12
|
describe('PlaceholderControllerDecorator', function () {
|
|
8
13
|
var data;
|
|
9
14
|
var DivComponent = function DivComponent(props) {
|
|
10
15
|
data = props;
|
|
11
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
16
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({
|
|
12
17
|
"data-testid": "component"
|
|
13
|
-
});
|
|
18
|
+
}, props));
|
|
14
19
|
};
|
|
15
20
|
var Component = (0, _Placeholder.PlaceholderControllerDecorator)(DivComponent);
|
|
16
21
|
describe('config', function () {
|
|
@@ -16,6 +16,7 @@ var _remove = _interopRequireDefault(require("ramda/src/remove"));
|
|
|
16
16
|
var _unionWith = _interopRequireDefault(require("ramda/src/unionWith"));
|
|
17
17
|
var _useWith = _interopRequireDefault(require("ramda/src/useWith"));
|
|
18
18
|
var _react = require("react");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
20
21
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
22
|
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
@@ -39,8 +40,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
39
40
|
* @returns {Number} Index of child
|
|
40
41
|
* @method
|
|
41
42
|
* @private
|
|
42
|
-
*/
|
|
43
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
43
|
+
*/ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
44
44
|
var indexOfChild = (0, _useWith["default"])(_findIndex["default"], [(0, _propEq["default"])('key'), _identity["default"]]);
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -200,6 +200,23 @@ var TransitionGroup = exports.TransitionGroup = /*#__PURE__*/function (_Componen
|
|
|
200
200
|
_this.groupRefs[key] = node;
|
|
201
201
|
};
|
|
202
202
|
};
|
|
203
|
+
/* This code is the same as @enact/core/WithRef. */
|
|
204
|
+
_this.getNodeRef = function () {
|
|
205
|
+
var _refNode$parentElemen;
|
|
206
|
+
var refNode = _this.nodeRef.current;
|
|
207
|
+
var attributeSelector = "[data-transitiongroup-id=\"".concat(refNode.getAttribute('data-transitiongroup-target'), "\"]");
|
|
208
|
+
/* The intended code is to search for the referrer element via a single querySelector call. But unit tests cannot handle :has() properly.
|
|
209
|
+
const selector = `:scope ${attributeSelector}, :scope :has(${attributeSelector})`;
|
|
210
|
+
return refNode?.parentElement?.querySelector(selector) || null;
|
|
211
|
+
*/
|
|
212
|
+
var targetNode = (refNode === null || refNode === void 0 || (_refNode$parentElemen = refNode.parentElement) === null || _refNode$parentElemen === void 0 ? void 0 : _refNode$parentElemen.querySelector(attributeSelector)) || null;
|
|
213
|
+
for (var current = targetNode; current; current = current.parentElement) {
|
|
214
|
+
var _current;
|
|
215
|
+
if (((_current = current) === null || _current === void 0 ? void 0 : _current.parentElement) === (refNode === null || refNode === void 0 ? void 0 : refNode.parentElement)) {
|
|
216
|
+
return current;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
203
220
|
_this.state = {
|
|
204
221
|
firstRender: true,
|
|
205
222
|
children: []
|
|
@@ -210,6 +227,8 @@ var TransitionGroup = exports.TransitionGroup = /*#__PURE__*/function (_Componen
|
|
|
210
227
|
_this.keysToLeave = [];
|
|
211
228
|
_this.keysToStay = [];
|
|
212
229
|
_this.groupRefs = {};
|
|
230
|
+
_this.nodeRef = /*#__PURE__*/(0, _react.createRef)();
|
|
231
|
+
_this.refNodeId = '#transition#group#';
|
|
213
232
|
return _this;
|
|
214
233
|
}
|
|
215
234
|
_createClass(TransitionGroup, [{
|
|
@@ -343,19 +362,22 @@ var TransitionGroup = exports.TransitionGroup = /*#__PURE__*/function (_Componen
|
|
|
343
362
|
var _this5 = this;
|
|
344
363
|
// support wrapping arbitrary children with a component that supports the necessary
|
|
345
364
|
// lifecycle methods to animate transitions
|
|
346
|
-
var childrenToRender = this.state.children.map(function (child) {
|
|
365
|
+
var childrenToRender = this.state.children.map(function (child, index) {
|
|
347
366
|
var isLeaving = child.props['data-index'] !== _this5.props.currentIndex && typeof child.props['data-index'] !== 'undefined';
|
|
348
367
|
return /*#__PURE__*/(0, _react.cloneElement)(_this5.props.childFactory(child), {
|
|
349
368
|
key: child.key,
|
|
350
369
|
ref: _this5.storeRefs(child.key),
|
|
351
370
|
leaving: isLeaving,
|
|
352
|
-
appearing: !_this5.hasMounted
|
|
371
|
+
appearing: !_this5.hasMounted,
|
|
372
|
+
getParentRef: _this5.getNodeRef,
|
|
373
|
+
renderedIndex: index
|
|
353
374
|
});
|
|
354
375
|
});
|
|
355
376
|
|
|
356
377
|
// Do not forward TransitionGroup props to primitive DOM nodes
|
|
357
378
|
var props = Object.assign({}, this.props);
|
|
358
379
|
props.ref = this.props.componentRef;
|
|
380
|
+
props['data-transitiongroup-id'] = this.refNodeId;
|
|
359
381
|
delete props.childFactory;
|
|
360
382
|
delete props.component;
|
|
361
383
|
delete props.componentRef;
|
|
@@ -367,7 +389,15 @@ var TransitionGroup = exports.TransitionGroup = /*#__PURE__*/function (_Componen
|
|
|
367
389
|
delete props.onTransition;
|
|
368
390
|
delete props.onWillTransition;
|
|
369
391
|
delete props.size;
|
|
370
|
-
return /*#__PURE__*/(0,
|
|
392
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
393
|
+
children: [/*#__PURE__*/(0, _react.createElement)(this.props.component, props, childrenToRender), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
394
|
+
"data-transitiongroup-target": this.refNodeId,
|
|
395
|
+
ref: this.nodeRef,
|
|
396
|
+
style: {
|
|
397
|
+
display: 'none'
|
|
398
|
+
}
|
|
399
|
+
})]
|
|
400
|
+
});
|
|
371
401
|
}
|
|
372
402
|
}], [{
|
|
373
403
|
key: "getDerivedStateFromProps",
|
package/ViewManager/View.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.wrapWithView = exports["default"] = exports.View = void 0;
|
|
|
7
7
|
var _util = require("@enact/core/util");
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
10
|
var _Arranger = require("./Arranger");
|
|
12
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -65,18 +64,21 @@ var View = exports.View = /*#__PURE__*/function (_Component) {
|
|
|
65
64
|
* @private
|
|
66
65
|
*/
|
|
67
66
|
_this.prepareTransition = function (arranger, callback, noAnimation) {
|
|
67
|
+
var _getParentRef;
|
|
68
68
|
var _this$props = _this.props,
|
|
69
69
|
duration = _this$props.duration,
|
|
70
|
+
getParentRef = _this$props.getParentRef,
|
|
70
71
|
index = _this$props.index,
|
|
71
72
|
_this$props$previousI = _this$props.previousIndex,
|
|
72
73
|
previousIndex = _this$props$previousI === void 0 ? index : _this$props$previousI,
|
|
74
|
+
_this$props$renderedI = _this$props.renderedIndex,
|
|
75
|
+
renderedIndex = _this$props$renderedI === void 0 ? 0 : _this$props$renderedI,
|
|
73
76
|
reverseTransition = _this$props.reverseTransition,
|
|
74
77
|
rtl = _this$props.rtl;
|
|
75
78
|
|
|
76
79
|
// Need to ensure that we have a valid node reference before we animation. Sometimes, React
|
|
77
80
|
// will replace the node after mount causing a reference cached there to be invalid.
|
|
78
|
-
|
|
79
|
-
_this.node = _reactDom["default"].findDOMNode(_assertThisInitialized(_this));
|
|
81
|
+
_this.node = getParentRef === null || getParentRef === void 0 || (_getParentRef = getParentRef()) === null || _getParentRef === void 0 || (_getParentRef = _getParentRef.children) === null || _getParentRef === void 0 ? void 0 : _getParentRef[renderedIndex];
|
|
80
82
|
if (_this.animation && _this.animation.playState !== 'finished' && _this.changeDirection) {
|
|
81
83
|
_this.animation.reverse();
|
|
82
84
|
} else {
|
|
@@ -299,6 +301,13 @@ View.propTypes = /** @lends ui/ViewManager.View.prototype */{
|
|
|
299
301
|
* @public
|
|
300
302
|
*/
|
|
301
303
|
enteringProp: _propTypes["default"].string,
|
|
304
|
+
/**
|
|
305
|
+
* A getter function for a DOM node of the parent element
|
|
306
|
+
*
|
|
307
|
+
* @type {Function}
|
|
308
|
+
* @private
|
|
309
|
+
*/
|
|
310
|
+
getParentRef: _propTypes["default"].func,
|
|
302
311
|
/**
|
|
303
312
|
* Index of the currently 'active' view.
|
|
304
313
|
*
|
|
@@ -325,6 +334,13 @@ View.propTypes = /** @lends ui/ViewManager.View.prototype */{
|
|
|
325
334
|
* @type {Number}
|
|
326
335
|
*/
|
|
327
336
|
previousIndex: _propTypes["default"].number,
|
|
337
|
+
/**
|
|
338
|
+
* Index of the view node among the rendered children of the parent node
|
|
339
|
+
*
|
|
340
|
+
* @type {Number}
|
|
341
|
+
* @private
|
|
342
|
+
*/
|
|
343
|
+
renderedIndex: _propTypes["default"].number,
|
|
328
344
|
/**
|
|
329
345
|
* When `true`, indicates if the transition should be reversed. The effect depends on how the provided
|
|
330
346
|
* `arranger` handles reversal.
|
|
@@ -122,10 +122,16 @@ describe('View', function () {
|
|
|
122
122
|
});
|
|
123
123
|
test('should call callback for "stay"', function (done) {
|
|
124
124
|
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
125
|
+
var getParentRef = function getParentRef() {
|
|
126
|
+
return {
|
|
127
|
+
children: [{}]
|
|
128
|
+
};
|
|
129
|
+
};
|
|
125
130
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
126
131
|
arranger: _testUtils.MockArranger,
|
|
127
132
|
duration: 16,
|
|
128
133
|
ref: ref,
|
|
134
|
+
getParentRef: getParentRef,
|
|
129
135
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
130
136
|
}));
|
|
131
137
|
var spy = jest.fn(function () {
|
|
@@ -140,10 +146,16 @@ describe('View', function () {
|
|
|
140
146
|
});
|
|
141
147
|
test('should call callback for "enter"', function (done) {
|
|
142
148
|
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
149
|
+
var getParentRef = function getParentRef() {
|
|
150
|
+
return {
|
|
151
|
+
children: [{}]
|
|
152
|
+
};
|
|
153
|
+
};
|
|
143
154
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
144
155
|
arranger: _testUtils.MockArranger,
|
|
145
156
|
duration: 16,
|
|
146
157
|
ref: ref,
|
|
158
|
+
getParentRef: getParentRef,
|
|
147
159
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
148
160
|
}));
|
|
149
161
|
var spy = jest.fn(function () {
|
|
@@ -158,10 +170,16 @@ describe('View', function () {
|
|
|
158
170
|
});
|
|
159
171
|
test('should call callback for "leave"', function (done) {
|
|
160
172
|
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
173
|
+
var getParentRef = function getParentRef() {
|
|
174
|
+
return {
|
|
175
|
+
children: [{}]
|
|
176
|
+
};
|
|
177
|
+
};
|
|
161
178
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
162
179
|
arranger: _testUtils.MockArranger,
|
|
163
180
|
duration: 16,
|
|
164
181
|
ref: ref,
|
|
182
|
+
getParentRef: getParentRef,
|
|
165
183
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
166
184
|
}));
|
|
167
185
|
var spy = jest.fn(function () {
|
|
@@ -177,11 +195,17 @@ describe('View', function () {
|
|
|
177
195
|
test('should call callback immediately when {noAnimation}', function () {
|
|
178
196
|
var spy = jest.fn();
|
|
179
197
|
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
198
|
+
var getParentRef = function getParentRef() {
|
|
199
|
+
return {
|
|
200
|
+
children: [{}]
|
|
201
|
+
};
|
|
202
|
+
};
|
|
180
203
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
181
204
|
arranger: _testUtils.MockArranger,
|
|
182
205
|
duration: 16,
|
|
183
206
|
noAnimation: true,
|
|
184
207
|
ref: ref,
|
|
208
|
+
getParentRef: getParentRef,
|
|
185
209
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
186
210
|
}));
|
|
187
211
|
(0, _react.act)(function () {
|
|
@@ -193,10 +217,16 @@ describe('View', function () {
|
|
|
193
217
|
test('should call callback immediately for "appear"', function () {
|
|
194
218
|
var spy = jest.fn();
|
|
195
219
|
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
220
|
+
var getParentRef = function getParentRef() {
|
|
221
|
+
return {
|
|
222
|
+
children: [{}]
|
|
223
|
+
};
|
|
224
|
+
};
|
|
196
225
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
197
226
|
arranger: _testUtils.MockArranger,
|
|
198
227
|
duration: 16,
|
|
199
228
|
ref: ref,
|
|
229
|
+
getParentRef: getParentRef,
|
|
200
230
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
201
231
|
}));
|
|
202
232
|
(0, _react.act)(function () {
|
|
@@ -222,10 +252,16 @@ describe('View', function () {
|
|
|
222
252
|
})
|
|
223
253
|
};
|
|
224
254
|
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
255
|
+
var getParentRef = function getParentRef() {
|
|
256
|
+
return {
|
|
257
|
+
children: [{}]
|
|
258
|
+
};
|
|
259
|
+
};
|
|
225
260
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
226
261
|
arranger: arranger,
|
|
227
262
|
duration: 1000,
|
|
228
263
|
ref: ref,
|
|
264
|
+
getParentRef: getParentRef,
|
|
229
265
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
230
266
|
}));
|
|
231
267
|
(0, _react.act)(function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui",
|
|
3
|
-
"version": "4.9.0-
|
|
3
|
+
"version": "4.9.0-beta.1",
|
|
4
4
|
"description": "A collection of simplified unstyled cross-platform UI components for Enact",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@enact/core": "^4.9.0-
|
|
35
|
+
"@enact/core": "^4.9.0-beta.1",
|
|
36
36
|
"classnames": "^2.5.1",
|
|
37
37
|
"direction": "^1.0.4",
|
|
38
38
|
"invariant": "^2.2.4",
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.ResolutionDecorator = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
9
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
11
10
|
var _resolution = require("./resolution");
|
|
@@ -136,9 +135,9 @@ var ResolutionDecorator = exports.ResolutionDecorator = (0, _hoc["default"])(def
|
|
|
136
135
|
_createClass(_class, [{
|
|
137
136
|
key: "componentDidMount",
|
|
138
137
|
value: function componentDidMount() {
|
|
138
|
+
var _document$getElements;
|
|
139
139
|
if (config.dynamic) window.addEventListener('resize', this.handleResize);
|
|
140
|
-
|
|
141
|
-
this.rootNode = _reactDom["default"].findDOMNode(this);
|
|
140
|
+
this.rootNode = ((_document$getElements = document.getElementsByClassName((0, _resolution.getResolutionClasses)())) === null || _document$getElements === void 0 ? void 0 : _document$getElements[0]) || null;
|
|
142
141
|
}
|
|
143
142
|
}, {
|
|
144
143
|
key: "componentWillUnmount",
|
package/resolution/resolution.js
CHANGED
|
@@ -68,17 +68,19 @@ var configDefaults = {
|
|
|
68
68
|
* @private
|
|
69
69
|
*/
|
|
70
70
|
var updateWorkspaceBounds = function updateWorkspaceBounds(measurementNode) {
|
|
71
|
-
if (measurementNode
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
if (measurementNode) {
|
|
72
|
+
if (measurementNode.clientHeight || measurementNode.clientWidth) {
|
|
73
|
+
workspaceBounds = {
|
|
74
|
+
height: measurementNode.clientHeight,
|
|
75
|
+
width: measurementNode.clientWidth
|
|
76
|
+
};
|
|
77
|
+
} else if (measurementNode.innerHeight || measurementNode.innerWidth) {
|
|
78
|
+
// A backup for if measurementNode is actually `window` and not a normal node
|
|
79
|
+
workspaceBounds = {
|
|
80
|
+
height: measurementNode.innerHeight,
|
|
81
|
+
width: measurementNode.innerWidth
|
|
82
|
+
};
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
};
|
|
84
86
|
|
|
@@ -235,8 +237,8 @@ function calculateFontSize(type) {
|
|
|
235
237
|
* @function
|
|
236
238
|
* @memberof ui/resolution
|
|
237
239
|
* @param {String} size A valid CSS measurement to be applied as the base document font size.
|
|
238
|
-
* @private
|
|
239
240
|
* @returns {undefined}
|
|
241
|
+
* @private
|
|
240
242
|
*/
|
|
241
243
|
function updateBaseFontSize(size) {
|
|
242
244
|
if (typeof window === 'object') {
|