@enact/ui 4.9.0-alpha.1 → 4.9.0-alpha.3

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.
@@ -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
- // eslint-disable-next-line react/no-find-dom-node
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 () {
@@ -3,6 +3,8 @@
3
3
  height: 100%;
4
4
  width: 100%;
5
5
  overflow: hidden;
6
+ /* hide native scrollbar */
7
+ scrollbar-width: none;
6
8
  }
7
9
  .virtualList.vertical {
8
10
  overflow-y: scroll;
@@ -18,6 +20,7 @@
18
20
  .virtualList .content {
19
21
  will-change: transform;
20
22
  }
23
+ /* NOTE: Needs to be revisited whether it can be replaced with scrollbar-width */
21
24
  .virtualList::-webkit-scrollbar {
22
25
  display: none;
23
26
  }
@@ -18,6 +18,19 @@ export interface gridListItemSizeShape {
18
18
  */;
19
19
  minHeight: number;
20
20
  }
21
+ /**
22
+ * The shape for the list different item size
23
+ in a list for .
24
+ */
25
+ export interface itemSizesShape {
26
+ /**
27
+ * The minimum size of the list item.
28
+ */
29
+ minSize: number /**
30
+ * An array of the list item size. If it is not defined, the list items will render with the `minSize` size.
31
+ */;
32
+ size: number[];
33
+ }
21
34
  export interface VirtualListProps extends VirtualListBasicProps {
22
35
  /**
23
36
  * A callback function that receives a reference to the `scrollTo` feature.
@@ -153,19 +166,6 @@ export class VirtualList extends React.Component<
153
166
  Merge<React.HTMLProps<HTMLElement>, VirtualListProps>
154
167
  > {}
155
168
 
156
- /**
157
- * The shape for the list different item size
158
- in a list for .
159
- */
160
- export interface itemSizesShape {
161
- /**
162
- * The minimum size of the list item.
163
- */
164
- minSize: number /**
165
- * An array of the list item size. If it is not defined, the list items will render with the `minSize` size.
166
- */;
167
- size: number[];
168
- }
169
169
  export interface VirtualListBasicProps {
170
170
  /**
171
171
  * The rendering function called for each item in the list.
@@ -59,6 +59,24 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
59
59
  * @exports VirtualListBasic
60
60
  */
61
61
  var nop = function nop() {};
62
+ var virtualListDefaultProps = {
63
+ cbScrollTo: nop,
64
+ direction: 'vertical',
65
+ horizontalScrollbar: 'auto',
66
+ noScrollByDrag: false,
67
+ noScrollByWheel: false,
68
+ onScroll: nop,
69
+ onScrollStart: nop,
70
+ onScrollStop: nop,
71
+ overscrollEffectOn: {
72
+ drag: false,
73
+ pageKey: false,
74
+ wheel: false
75
+ },
76
+ role: 'list',
77
+ scrollMode: 'translate',
78
+ verticalScrollbar: 'auto'
79
+ };
62
80
 
63
81
  /**
64
82
  * An unstyled scrollable virtual list component with touch support.
@@ -72,7 +90,8 @@ var nop = function nop() {};
72
90
  var VirtualList = exports.VirtualList = function VirtualList(props) {
73
91
  // Hooks
74
92
 
75
- var _useScroll = (0, _useScroll3["default"])(props),
93
+ var virtualListProps = Object.assign({}, virtualListDefaultProps, props);
94
+ var _useScroll = (0, _useScroll3["default"])(virtualListProps),
76
95
  scrollContentHandle = _useScroll.scrollContentHandle,
77
96
  ScrollContentWrapper = _useScroll.scrollContentWrapper,
78
97
  isHorizontalScrollbarVisible = _useScroll.isHorizontalScrollbarVisible,
@@ -294,7 +313,8 @@ VirtualList.propTypes = /** @lends ui/VirtualList.VirtualList.prototype */{
294
313
  */
295
314
  verticalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden'])
296
315
  };
297
- VirtualList.defaultProps = {
316
+ VirtualList.defaultPropValues = virtualListDefaultProps;
317
+ var virtualGridListDefaultProps = {
298
318
  cbScrollTo: nop,
299
319
  direction: 'vertical',
300
320
  horizontalScrollbar: 'auto',
@@ -323,7 +343,8 @@ VirtualList.defaultProps = {
323
343
  * @public
324
344
  */
325
345
  var VirtualGridList = exports.VirtualGridList = function VirtualGridList(props) {
326
- var _useScroll2 = (0, _useScroll3["default"])(props),
346
+ var virtualGridListProps = Object.assign({}, virtualGridListDefaultProps, props);
347
+ var _useScroll2 = (0, _useScroll3["default"])(virtualGridListProps),
327
348
  scrollContentHandle = _useScroll2.scrollContentHandle,
328
349
  ScrollContentWrapper = _useScroll2.scrollContentWrapper,
329
350
  isHorizontalScrollbarVisible = _useScroll2.isHorizontalScrollbarVisible,
@@ -542,22 +563,5 @@ VirtualGridList.propTypes = /** @lends ui/VirtualList.VirtualGridList.prototype
542
563
  */
543
564
  verticalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden'])
544
565
  };
545
- VirtualGridList.defaultProps = {
546
- cbScrollTo: nop,
547
- direction: 'vertical',
548
- horizontalScrollbar: 'auto',
549
- noScrollByDrag: false,
550
- noScrollByWheel: false,
551
- onScroll: nop,
552
- onScrollStart: nop,
553
- onScrollStop: nop,
554
- overscrollEffectOn: {
555
- drag: false,
556
- pageKey: false,
557
- wheel: false
558
- },
559
- role: 'list',
560
- scrollMode: 'translate',
561
- verticalScrollbar: 'auto'
562
- };
566
+ VirtualGridList.defaultPropValues = virtualGridListDefaultProps;
563
567
  var _default = exports["default"] = VirtualList;
@@ -3,6 +3,8 @@
3
3
  height: 100%;
4
4
  width: 100%;
5
5
  overflow: hidden;
6
+ /* hide native scrollbar */
7
+ scrollbar-width: none;
6
8
  }
7
9
  .virtualList .content {
8
10
  will-change: transform;
@@ -23,6 +25,7 @@
23
25
  position: absolute;
24
26
  will-change: transform;
25
27
  }
28
+ /* NOTE: Needs to be revisited whether it can be replaced with scrollbar-width */
26
29
  .virtualList::-webkit-scrollbar {
27
30
  display: none;
28
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/ui",
3
- "version": "4.9.0-alpha.1",
3
+ "version": "4.9.0-alpha.3",
4
4
  "description": "A collection of simplified unstyled cross-platform UI components for Enact",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,15 +32,15 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
- "@enact/core": "^4.9.0-alpha.1",
35
+ "@enact/core": "^4.9.0-alpha.3",
36
36
  "classnames": "^2.5.1",
37
37
  "direction": "^1.0.4",
38
38
  "invariant": "^2.2.4",
39
39
  "prop-types": "^15.8.1",
40
40
  "ramda": "^0.29.1",
41
- "react": "^18.2.0",
42
- "react-dom": "^18.2.0",
43
- "react-is": "^18.2.0",
41
+ "react": "^18.3.1",
42
+ "react-dom": "^18.3.1",
43
+ "react-is": "^18.3.1",
44
44
  "warning": "^4.0.3"
45
45
  }
46
46
  }
@@ -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
- // eslint-disable-next-line react/no-find-dom-node
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",
@@ -68,17 +68,19 @@ var configDefaults = {
68
68
  * @private
69
69
  */
70
70
  var updateWorkspaceBounds = function updateWorkspaceBounds(measurementNode) {
71
- if (measurementNode && (measurementNode.clientHeight || measurementNode.clientWidth)) {
72
- workspaceBounds = {
73
- height: measurementNode.clientHeight,
74
- width: measurementNode.clientWidth
75
- };
76
- } else if (measurementNode && (measurementNode.innerHeight || measurementNode.innerWidth)) {
77
- // A backup for if measurementNode is actually `window` and not a normal node
78
- workspaceBounds = {
79
- height: measurementNode.innerHeight,
80
- width: measurementNode.innerWidth
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') {