@enact/ui 5.4.2 → 5.5.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 +9 -5
- package/AnnounceDecorator/AnnounceDecorator.js +5 -3
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +4 -1
- package/AnnounceDecorator/tests/useAnnounce-specs.js +4 -1
- package/CHANGELOG.md +25 -0
- package/Cancelable/Cancelable.js +7 -0
- package/Cancelable/tests/Cancelable-specs.js +26 -0
- package/Changeable/Changeable.js +6 -0
- package/Changeable/tests/Changeable-specs.js +4 -1
- package/FloatingLayer/FloatingLayer.js +3 -0
- package/FloatingLayer/FloatingLayerDecorator.js +2 -0
- package/FloatingLayer/Scrim.js +3 -0
- package/Marquee/Marquee.module.css +1 -1
- package/Marquee/MarqueeDecorator.js +19 -3
- package/Marquee/tests/Marquee-specs.js +306 -1
- package/Marquee/useMarqueeController.js +6 -4
- package/Measurable/tests/Measurable-specs.js +6 -2
- package/Media/Media.js +5 -2
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +4 -1
- package/Resizable/tests/Resizable-specs.js +4 -1
- package/Resizable/tests/useResize-specs.js +4 -1
- package/Routable/Route.js +5 -3
- package/Routable/Router.js +25 -16
- package/Routable/tests/Routable-specs.js +16 -0
- package/Scroller/Scroller.js +6 -5
- package/Scroller/ScrollerBasic.js +5 -5
- package/Skinnable/Skinnable.js +9 -7
- package/Skinnable/tests/Skinnable-specs.js +7 -2
- package/Skinnable/useSkins.js +6 -2
- package/Slider/PositionDecorator.js +20 -5
- package/Slider/Slider.d.ts +4 -0
- package/Slider/Slider.js +10 -0
- package/Slider/tests/Slider-specs.js +18 -0
- package/Slider/utils.js +9 -1
- package/Toggleable/Toggleable.js +4 -2
- package/Toggleable/tests/Toggleable-specs.js +4 -1
- package/Touchable/Touchable.js +6 -4
- package/Touchable/tests/Touchable-specs.js +4 -1
- package/Touchable/tests/useTouch-specs.js +4 -1
- package/Touchable/useTouch.js +7 -2
- package/Transition/Transition.js +2 -0
- package/ViewManager/TransitionGroup.js +3 -0
- package/ViewManager/View.js +2 -0
- package/ViewManager/ViewManager.js +7 -0
- package/VirtualList/VirtualList.js +7 -5
- package/VirtualList/VirtualListBasic.js +12 -7
- package/VirtualList/tests/VirtualList-native-specs.js +14 -0
- package/VirtualList/tests/VirtualList-specs.js +13 -0
- package/internal/IdProvider/IdProvider.js +2 -0
- package/internal/IdProvider/tests/IdProvider-specs.js +4 -1
- package/internal/Pure/tests/Pure-specs.js +7 -0
- package/package.json +12 -7
- package/resolution/ResolutionDecorator.js +21 -18
- package/resolution/index.d.ts +63 -4
- package/resolution/index.js +18 -2
- package/resolution/resolution.js +209 -29
- package/resolution/tests/ResolutionDecorator-specs.js +84 -4
- package/resolution/tests/resolution-specs.js +217 -599
- package/useControlledState/tests/useControlledState-specs.js +4 -1
- package/useControlledState/useControlledState.js +11 -7
- package/useScroll/Scrollbar.js +27 -24
- package/useScroll/ScrollbarTrack.js +5 -3
- package/useScroll/tests/useScroll-specs.js +148 -7
- package/useScroll/useScroll.js +94 -14
- package/useScroll/utilEvent.js +18 -0
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = exports.ScrollerBasic = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
8
8
|
var _platform = require("@enact/core/platform");
|
|
9
|
+
var _util = require("@enact/core/util");
|
|
9
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
11
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
11
12
|
var _react = require("react");
|
|
@@ -39,13 +40,10 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
|
|
|
39
40
|
* @public
|
|
40
41
|
*/
|
|
41
42
|
var ScrollerBasic = exports.ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
42
|
-
function ScrollerBasic() {
|
|
43
|
+
function ScrollerBasic(props) {
|
|
43
44
|
var _this;
|
|
44
45
|
_classCallCheck(this, ScrollerBasic);
|
|
45
|
-
|
|
46
|
-
args[_key] = arguments[_key];
|
|
47
|
-
}
|
|
48
|
-
_this = _callSuper(this, ScrollerBasic, [].concat(args));
|
|
46
|
+
_this = _callSuper(this, ScrollerBasic, [props]);
|
|
49
47
|
_this.scrollAnimationId = null;
|
|
50
48
|
_this.scrollBounds = {
|
|
51
49
|
clientWidth: 0,
|
|
@@ -110,6 +108,7 @@ var ScrollerBasic = exports.ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
|
110
108
|
}
|
|
111
109
|
return false;
|
|
112
110
|
};
|
|
111
|
+
(0, _util.checkPropTypes)(_this, props);
|
|
113
112
|
return _this;
|
|
114
113
|
}
|
|
115
114
|
_inherits(ScrollerBasic, _Component);
|
|
@@ -121,6 +120,7 @@ var ScrollerBasic = exports.ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
|
121
120
|
}, {
|
|
122
121
|
key: "componentDidUpdate",
|
|
123
122
|
value: function componentDidUpdate(prevProps) {
|
|
123
|
+
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
124
124
|
this.calculateMetrics();
|
|
125
125
|
if (this.props.isVerticalScrollbarVisible && !prevProps.isVerticalScrollbarVisible) {
|
|
126
126
|
this.forceUpdate();
|
package/Skinnable/Skinnable.js
CHANGED
|
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "useSkins", {
|
|
|
12
12
|
});
|
|
13
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
14
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
15
|
+
var _util = require("@enact/core/util");
|
|
15
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
17
|
var _useSkins = _interopRequireDefault(require("./useSkins"));
|
|
17
|
-
var
|
|
18
|
+
var _util2 = require("./util");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
var _excluded = ["className", "skin", "skinVariants"];
|
|
20
21
|
/**
|
|
@@ -141,14 +142,15 @@ var Skinnable = exports.Skinnable = (0, _hoc["default"])(defaultConfig, function
|
|
|
141
142
|
defaultSkin = config.defaultSkin,
|
|
142
143
|
variants = config.allowedVariants,
|
|
143
144
|
variantsProp = config.variantsProp;
|
|
144
|
-
var defaultVariants = (0,
|
|
145
|
+
var defaultVariants = (0, _util2.objectify)(config.defaultVariants);
|
|
145
146
|
|
|
146
147
|
// eslint-disable-next-line no-shadow
|
|
147
|
-
function Skinnable(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
function Skinnable(props) {
|
|
149
|
+
(0, _util.checkPropTypes)(Skinnable, props);
|
|
150
|
+
var className = props.className,
|
|
151
|
+
skin = props.skin,
|
|
152
|
+
skinVariants = props.skinVariants,
|
|
153
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
152
154
|
var hook = (0, _useSkins["default"])({
|
|
153
155
|
defaultSkin: defaultSkin,
|
|
154
156
|
defaultVariants: defaultVariants,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require("@testing-library/jest-dom");
|
|
4
4
|
var _react = require("@testing-library/react");
|
|
5
|
+
var _react2 = require("react");
|
|
5
6
|
var _Skinnable = _interopRequireDefault(require("../Skinnable"));
|
|
6
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -15,7 +16,9 @@ describe('Skinnable Specs', function () {
|
|
|
15
16
|
var config = {};
|
|
16
17
|
var data;
|
|
17
18
|
var Component = function Component(props) {
|
|
18
|
-
|
|
19
|
+
(0, _react2.useEffect)(function () {
|
|
20
|
+
data = props;
|
|
21
|
+
}, [props]);
|
|
19
22
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
|
|
20
23
|
};
|
|
21
24
|
var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
|
|
@@ -71,7 +74,9 @@ describe('Skinnable Specs', function () {
|
|
|
71
74
|
};
|
|
72
75
|
var data;
|
|
73
76
|
var Component = function Component(props) {
|
|
74
|
-
|
|
77
|
+
(0, _react2.useEffect)(function () {
|
|
78
|
+
data = props;
|
|
79
|
+
}, [props]);
|
|
75
80
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
|
|
76
81
|
};
|
|
77
82
|
var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
|
package/Skinnable/useSkins.js
CHANGED
|
@@ -94,10 +94,14 @@ function useSkins(config) {
|
|
|
94
94
|
var _ref = (0, _react.use)(SkinContext) || {},
|
|
95
95
|
parentSkin = _ref.parentSkin,
|
|
96
96
|
parentVariants = _ref.parentVariants;
|
|
97
|
+
var currentParentVariants = (0, _react.useMemo)(function () {
|
|
98
|
+
return parentVariants;
|
|
99
|
+
}, [parentVariants]);
|
|
97
100
|
var effectiveSkin = (0, _util.determineSkin)(defaultSkin, skin, parentSkin);
|
|
101
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
102
|
var effectiveVariants = (0, _react.useMemo)(function () {
|
|
99
|
-
return (0, _util.determineVariants)(defaultVariants, variants, skinVariants,
|
|
100
|
-
}, [
|
|
103
|
+
return (0, _util.determineVariants)(defaultVariants, variants, skinVariants, currentParentVariants);
|
|
104
|
+
}, [currentParentVariants, parentVariants, skinVariants, variants]);
|
|
101
105
|
var className = (0, _util.getClassName)(skins, effectiveSkin, effectiveVariants);
|
|
102
106
|
var value = (0, _react.useMemo)(function () {
|
|
103
107
|
return {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = exports.PositionDecorator = void 0;
|
|
7
7
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
8
8
|
var _handle = require("@enact/core/handle");
|
|
9
|
+
var _util = require("@enact/core/util");
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
12
|
var _validators = require("../internal/validators");
|
|
@@ -51,6 +52,7 @@ var PositionDecorator = exports.PositionDecorator = (0, _hoc["default"])(functio
|
|
|
51
52
|
var _this;
|
|
52
53
|
_classCallCheck(this, _Class);
|
|
53
54
|
_this = _callSuper(this, _Class, [props]);
|
|
55
|
+
(0, _util.checkPropTypes)(_this, props);
|
|
54
56
|
_this.handleDown = _this.handleDown.bind(_this);
|
|
55
57
|
_this.handleDrag = _this.handleDrag.bind(_this);
|
|
56
58
|
_this.handleDragStart = _this.handleDragStart.bind(_this);
|
|
@@ -62,9 +64,15 @@ var PositionDecorator = exports.PositionDecorator = (0, _hoc["default"])(functio
|
|
|
62
64
|
}
|
|
63
65
|
_inherits(_Class, _Component);
|
|
64
66
|
return _createClass(_Class, [{
|
|
67
|
+
key: "componentDidUpdate",
|
|
68
|
+
value: function componentDidUpdate(prevProps) {
|
|
69
|
+
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
65
72
|
key: "emitChangeForPosition",
|
|
66
73
|
value: function emitChangeForPosition(x, y) {
|
|
67
74
|
var _this$props = this.props,
|
|
75
|
+
colorPicker = _this$props.colorPicker,
|
|
68
76
|
max = _this$props.max,
|
|
69
77
|
min = _this$props.min,
|
|
70
78
|
orientation = _this$props.orientation,
|
|
@@ -93,12 +101,19 @@ var PositionDecorator = exports.PositionDecorator = (0, _hoc["default"])(functio
|
|
|
93
101
|
// recalculate the proportion based on the stepped value
|
|
94
102
|
proportion = (0, _utils.calcProportion)(min, max, value);
|
|
95
103
|
}
|
|
104
|
+
var onChangeObj = {
|
|
105
|
+
type: 'onChange',
|
|
106
|
+
value: value,
|
|
107
|
+
proportion: proportion
|
|
108
|
+
};
|
|
109
|
+
if (colorPicker) {
|
|
110
|
+
onChangeObj.color = {
|
|
111
|
+
hex: (0, _utils.hslToHex)(value),
|
|
112
|
+
hsl: "hsla(".concat(value, ", 100%, 50%, 1)")
|
|
113
|
+
};
|
|
114
|
+
}
|
|
96
115
|
if (value !== this.props.value) {
|
|
97
|
-
(0, _handle.forward)('onChange',
|
|
98
|
-
type: 'onChange',
|
|
99
|
-
value: value,
|
|
100
|
-
proportion: proportion
|
|
101
|
-
}, this.props);
|
|
116
|
+
(0, _handle.forward)('onChange', onChangeObj, this.props);
|
|
102
117
|
}
|
|
103
118
|
}
|
|
104
119
|
}, {
|
package/Slider/Slider.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ will have its props merged with the above props.
|
|
|
62
62
|
* Background progress, as a proportion between `0` and `1` .
|
|
63
63
|
*/
|
|
64
64
|
backgroundProgress?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Indicates if Slider will be used as a colorPicker.
|
|
67
|
+
*/
|
|
68
|
+
colorPicker?: boolean;
|
|
65
69
|
/**
|
|
66
70
|
* Called with a reference to the root component.
|
|
67
71
|
*
|
package/Slider/Slider.js
CHANGED
|
@@ -77,6 +77,14 @@ var SliderBase = exports.SliderBase = (0, _kind["default"])({
|
|
|
77
77
|
* @public
|
|
78
78
|
*/
|
|
79
79
|
backgroundProgress: _propTypes2["default"].number,
|
|
80
|
+
/**
|
|
81
|
+
* Indicates if Slider will be used as a colorPicker.
|
|
82
|
+
*
|
|
83
|
+
* @type {Boolean}
|
|
84
|
+
* @default false
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
colorPicker: _propTypes2["default"].bool,
|
|
80
88
|
/**
|
|
81
89
|
* Called with a reference to the root component.
|
|
82
90
|
*
|
|
@@ -249,6 +257,7 @@ var SliderBase = exports.SliderBase = (0, _kind["default"])({
|
|
|
249
257
|
value: _propTypes2["default"].number
|
|
250
258
|
},
|
|
251
259
|
defaultProps: {
|
|
260
|
+
colorPicker: false,
|
|
252
261
|
disabled: false,
|
|
253
262
|
knobComponent: _Knob["default"],
|
|
254
263
|
min: 0,
|
|
@@ -310,6 +319,7 @@ var SliderBase = exports.SliderBase = (0, _kind["default"])({
|
|
|
310
319
|
_ref4$value = _ref4.value,
|
|
311
320
|
value = _ref4$value === void 0 ? min : _ref4$value,
|
|
312
321
|
rest = _objectWithoutProperties(_ref4, _excluded);
|
|
322
|
+
delete rest.colorPicker;
|
|
313
323
|
delete rest.noFill;
|
|
314
324
|
delete rest.pressed;
|
|
315
325
|
delete rest.step;
|
|
@@ -101,6 +101,24 @@ describe('Slider', function () {
|
|
|
101
101
|
var actual = handleChange.mock.calls.length && handleChange.mock.calls[0][0];
|
|
102
102
|
expect(actual).toMatchObject(expected);
|
|
103
103
|
});
|
|
104
|
+
test('should fire `onChange` with `onChange` type of vertical slider when value changed with `colorPicker` true', function () {
|
|
105
|
+
var handleChange = jest.fn();
|
|
106
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider["default"], {
|
|
107
|
+
colorPicker: true,
|
|
108
|
+
defaultValue: 50,
|
|
109
|
+
onChange: handleChange,
|
|
110
|
+
progressBarComponent: _ProgressBar["default"],
|
|
111
|
+
orientation: "vertical",
|
|
112
|
+
step: 5
|
|
113
|
+
}));
|
|
114
|
+
var knob = _react.screen.getByRole('progressbar').children.item(1);
|
|
115
|
+
_react.fireEvent.mouseDown(knob);
|
|
116
|
+
var expected = {
|
|
117
|
+
type: 'onChange'
|
|
118
|
+
};
|
|
119
|
+
var actual = handleChange.mock.calls.length && handleChange.mock.calls[0][0];
|
|
120
|
+
expect(actual).toMatchObject(expected);
|
|
121
|
+
});
|
|
104
122
|
});
|
|
105
123
|
describe('Knob', function () {
|
|
106
124
|
test('should render a knob', function () {
|
package/Slider/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.calcProportion = void 0;
|
|
6
|
+
exports.hslToHex = exports.calcProportion = void 0;
|
|
7
7
|
var calcProportion = exports.calcProportion = function calcProportion(min, max, value) {
|
|
8
8
|
if (value <= min) {
|
|
9
9
|
return 0;
|
|
@@ -12,4 +12,12 @@ var calcProportion = exports.calcProportion = function calcProportion(min, max,
|
|
|
12
12
|
} else {
|
|
13
13
|
return (value - min) / (max - min);
|
|
14
14
|
}
|
|
15
|
+
};
|
|
16
|
+
var hslToHex = exports.hslToHex = function hslToHex(h) {
|
|
17
|
+
var f = function f(n) {
|
|
18
|
+
var k = (n + h / 30) % 12;
|
|
19
|
+
var color = 1 / 2 - 1 / 2 * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
20
|
+
return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
|
|
21
|
+
};
|
|
22
|
+
return "#".concat(f(0)).concat(f(8)).concat(f(4));
|
|
15
23
|
};
|
package/Toggleable/Toggleable.js
CHANGED
|
@@ -176,6 +176,7 @@ var ToggleableHOC = exports.Toggleable = (0, _hoc["default"])(defaultConfig, fun
|
|
|
176
176
|
}, rest);
|
|
177
177
|
var updated = _objectSpread({}, props);
|
|
178
178
|
var propSelected = props[prop];
|
|
179
|
+
(0, _util.checkPropTypes)(Toggleable, props);
|
|
179
180
|
var hook = (0, _useToggle.useToggle)({
|
|
180
181
|
defaultSelected: props[defaultPropKey],
|
|
181
182
|
disabled: disabled,
|
|
@@ -198,8 +199,9 @@ var ToggleableHOC = exports.Toggleable = (0, _hoc["default"])(defaultConfig, fun
|
|
|
198
199
|
selected: null
|
|
199
200
|
}),
|
|
200
201
|
instance = _useRef.current;
|
|
201
|
-
var selected = instance.selected && propSelected == null ? false : hook.selected;
|
|
202
|
-
instance.selected = propSelected;
|
|
202
|
+
var selected = instance.selected && propSelected == null ? false : hook.selected; // eslint-disable-line react-hooks/refs
|
|
203
|
+
instance.selected = propSelected; // eslint-disable-line react-hooks/refs
|
|
204
|
+
|
|
203
205
|
if (prop) {
|
|
204
206
|
updated[prop] = selected;
|
|
205
207
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require("@testing-library/jest-dom");
|
|
4
4
|
var _react = require("@testing-library/react");
|
|
5
|
+
var _react2 = require("react");
|
|
5
6
|
var _Toggleable = _interopRequireDefault(require("../Toggleable"));
|
|
6
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -9,7 +10,9 @@ describe('Toggleable', function () {
|
|
|
9
10
|
var data;
|
|
10
11
|
var DivComponent = function DivComponent(props) {
|
|
11
12
|
var _props$selected;
|
|
12
|
-
|
|
13
|
+
(0, _react2.useEffect)(function () {
|
|
14
|
+
data = props;
|
|
15
|
+
}, [props]);
|
|
13
16
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
14
17
|
"data-testid": "selected-state",
|
|
15
18
|
children: (_props$selected = props.selected) === null || _props$selected === void 0 ? void 0 : _props$selected.toString()
|
package/Touchable/Touchable.js
CHANGED
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "useTouch", {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
21
|
+
var _util = require("@enact/core/util");
|
|
21
22
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
22
23
|
var _config = require("./config");
|
|
23
24
|
var _Drag = require("./Drag");
|
|
@@ -152,7 +153,8 @@ var Touchable = exports.Touchable = (0, _hoc["default"])(defaultConfig, function
|
|
|
152
153
|
var activeProp = config.activeProp;
|
|
153
154
|
|
|
154
155
|
// eslint-disable-next-line no-shadow
|
|
155
|
-
var
|
|
156
|
+
var _Touchable = function Touchable(props) {
|
|
157
|
+
(0, _util.checkPropTypes)(_Touchable, props);
|
|
156
158
|
var _props$disabled = props.disabled,
|
|
157
159
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
158
160
|
_props$noResume = props.noResume,
|
|
@@ -177,7 +179,7 @@ var Touchable = exports.Touchable = (0, _hoc["default"])(defaultConfig, function
|
|
|
177
179
|
ref: ref
|
|
178
180
|
}));
|
|
179
181
|
};
|
|
180
|
-
|
|
182
|
+
_Touchable.propTypes = {
|
|
181
183
|
/**
|
|
182
184
|
* Disables the component.
|
|
183
185
|
*
|
|
@@ -412,7 +414,7 @@ var Touchable = exports.Touchable = (0, _hoc["default"])(defaultConfig, function
|
|
|
412
414
|
current: _propTypes["default"].any
|
|
413
415
|
})
|
|
414
416
|
};
|
|
415
|
-
|
|
416
|
-
return
|
|
417
|
+
_Touchable.displayName = 'Touchable';
|
|
418
|
+
return _Touchable;
|
|
417
419
|
});
|
|
418
420
|
var _default = exports["default"] = Touchable;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
+
var _react2 = require("react");
|
|
4
5
|
var _config = require("../config");
|
|
5
6
|
var _Touchable = _interopRequireDefault(require("../Touchable"));
|
|
6
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -29,7 +30,9 @@ describe('Touchable', function () {
|
|
|
29
30
|
onTouchStart = _ref.onTouchStart,
|
|
30
31
|
onTouchEnd = _ref.onTouchEnd,
|
|
31
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
-
|
|
33
|
+
(0, _react2.useEffect)(function () {
|
|
34
|
+
data = props;
|
|
35
|
+
}, [props]);
|
|
33
36
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
34
37
|
"data-testid": "component",
|
|
35
38
|
id: id,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
+
var _react2 = require("react");
|
|
4
5
|
var _config = require("../config");
|
|
5
6
|
var _useTouch = _interopRequireDefault(require("../useTouch"));
|
|
6
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -16,7 +17,9 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
16
17
|
describe('useTouch', function () {
|
|
17
18
|
var data;
|
|
18
19
|
var DivComponent = function DivComponent(props) {
|
|
19
|
-
|
|
20
|
+
(0, _react2.useEffect)(function () {
|
|
21
|
+
data = props;
|
|
22
|
+
}, [props]);
|
|
20
23
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
21
24
|
"data-testid": "component"
|
|
22
25
|
});
|
package/Touchable/useTouch.js
CHANGED
|
@@ -104,6 +104,10 @@ function useTouch() {
|
|
|
104
104
|
_useState2 = _slicedToArray(_useState, 2),
|
|
105
105
|
state = _useState2[0],
|
|
106
106
|
setState = _useState2[1];
|
|
107
|
+
var _useState3 = (0, _react.useState)(null),
|
|
108
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
109
|
+
prevTouchState = _useState4[0],
|
|
110
|
+
setPrevTouchState = _useState4[1];
|
|
107
111
|
touch.setPropsAndContext(_objectSpread(_objectSpread({}, config), {}, {
|
|
108
112
|
disabled: !!disabled
|
|
109
113
|
}), state, setState);
|
|
@@ -131,11 +135,12 @@ function useTouch() {
|
|
|
131
135
|
}
|
|
132
136
|
}, [disabled]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
133
137
|
|
|
134
|
-
|
|
138
|
+
if (state !== prevTouchState) {
|
|
135
139
|
setState(function (prevState) {
|
|
136
140
|
return !getActive || disabled ? _state.States.Inactive : prevState;
|
|
137
141
|
});
|
|
138
|
-
|
|
142
|
+
setPrevTouchState(state);
|
|
143
|
+
}
|
|
139
144
|
return {
|
|
140
145
|
active: state !== _state.States.Inactive,
|
|
141
146
|
handlers: touch.getHandlers()
|
package/Transition/Transition.js
CHANGED
|
@@ -365,6 +365,7 @@ var Transition = exports.Transition = /*#__PURE__*/function (_Component) {
|
|
|
365
365
|
_this.childRef = function (node) {
|
|
366
366
|
_this.childNode = node;
|
|
367
367
|
};
|
|
368
|
+
(0, _util.checkPropTypes)(_this, props);
|
|
368
369
|
_this.state = {
|
|
369
370
|
initialHeight: null,
|
|
370
371
|
initialWidth: null,
|
|
@@ -402,6 +403,7 @@ var Transition = exports.Transition = /*#__PURE__*/function (_Component) {
|
|
|
402
403
|
var _this$state = this.state,
|
|
403
404
|
initialHeight = _this$state.initialHeight,
|
|
404
405
|
renderState = _this$state.renderState;
|
|
406
|
+
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
405
407
|
if (this.state.renderState === TRANSITION_STATE.MEASURE) {
|
|
406
408
|
this.measuringJob.stop();
|
|
407
409
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = exports.TransitionGroup = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
8
8
|
var _handle = require("@enact/core/handle");
|
|
9
|
+
var _util = require("@enact/core/util");
|
|
9
10
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
10
11
|
var _eqBy = _interopRequireDefault(require("ramda/src/eqBy"));
|
|
11
12
|
var _findIndex = _interopRequireDefault(require("ramda/src/findIndex"));
|
|
@@ -215,6 +216,7 @@ var TransitionGroup = exports.TransitionGroup = /*#__PURE__*/function (_Componen
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
};
|
|
219
|
+
(0, _util.checkPropTypes)(_this, props);
|
|
218
220
|
_this.state = {
|
|
219
221
|
firstRender: true,
|
|
220
222
|
children: []
|
|
@@ -245,6 +247,7 @@ var TransitionGroup = exports.TransitionGroup = /*#__PURE__*/function (_Componen
|
|
|
245
247
|
}, {
|
|
246
248
|
key: "componentDidUpdate",
|
|
247
249
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
250
|
+
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
248
251
|
this.reconcileUnmountedChildren(prevState.children, this.state.children);
|
|
249
252
|
this.reconcileChildren(prevState.activeChildren, this.state.activeChildren);
|
|
250
253
|
}
|
package/ViewManager/View.js
CHANGED
|
@@ -106,6 +106,7 @@ var View = exports.View = /*#__PURE__*/function (_Component) {
|
|
|
106
106
|
_this.animation.finish();
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
+
(0, _util.checkPropTypes)(_this, props);
|
|
109
110
|
_this.animation = null;
|
|
110
111
|
_this.state = {
|
|
111
112
|
entering: !props.appearing
|
|
@@ -128,6 +129,7 @@ var View = exports.View = /*#__PURE__*/function (_Component) {
|
|
|
128
129
|
}, {
|
|
129
130
|
key: "componentDidUpdate",
|
|
130
131
|
value: function componentDidUpdate(prevProps) {
|
|
132
|
+
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
131
133
|
this.changeDirection = this.shouldChangeDirection(prevProps, this.props);
|
|
132
134
|
}
|
|
133
135
|
}, {
|
|
@@ -11,6 +11,7 @@ var _exportNames = {
|
|
|
11
11
|
exports["default"] = exports.ViewManagerDecorator = exports.ViewManagerBase = exports.ViewManager = void 0;
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
13
13
|
var _handle = _interopRequireWildcard(require("@enact/core/handle"));
|
|
14
|
+
var _util = require("@enact/core/util");
|
|
14
15
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
15
16
|
var _react = require("react");
|
|
16
17
|
var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
|
|
@@ -86,6 +87,7 @@ var ViewManagerBase = exports.ViewManagerBase = (_Class = /*#__PURE__*/function
|
|
|
86
87
|
};
|
|
87
88
|
_this.handleTransition = (0, _handle["default"])((0, _handle.forwardCustom)('onTransition', _this.makeTransitionEvent)).bindAs(_this, 'handleTransition');
|
|
88
89
|
_this.handleWillTransition = (0, _handle["default"])((0, _handle.forwardCustom)('onWillTransition', _this.makeTransitionEvent)).bindAs(_this, 'handleWillTransition');
|
|
90
|
+
(0, _util.checkPropTypes)(_this, props);
|
|
89
91
|
_this.state = {
|
|
90
92
|
prevIndex: null,
|
|
91
93
|
reverseTransition: null
|
|
@@ -94,6 +96,11 @@ var ViewManagerBase = exports.ViewManagerBase = (_Class = /*#__PURE__*/function
|
|
|
94
96
|
}
|
|
95
97
|
_inherits(ViewManagerBase, _Component);
|
|
96
98
|
return _createClass(ViewManagerBase, [{
|
|
99
|
+
key: "componentDidUpdate",
|
|
100
|
+
value: function componentDidUpdate(prevProps) {
|
|
101
|
+
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
97
104
|
key: "render",
|
|
98
105
|
value: function render() {
|
|
99
106
|
var _this$props = this.props,
|
|
@@ -74,7 +74,8 @@ var virtualListDefaultProps = {
|
|
|
74
74
|
* @ui
|
|
75
75
|
* @public
|
|
76
76
|
*/
|
|
77
|
-
var
|
|
77
|
+
var _VirtualList = exports.VirtualList = function VirtualList(props) {
|
|
78
|
+
(0, _util.checkPropTypes)(_VirtualList, props);
|
|
78
79
|
// Hooks
|
|
79
80
|
|
|
80
81
|
var virtualListProps = (0, _util.setDefaultProps)(props, virtualListDefaultProps);
|
|
@@ -105,8 +106,8 @@ var VirtualList = exports.VirtualList = function VirtualList(props) {
|
|
|
105
106
|
}))
|
|
106
107
|
}));
|
|
107
108
|
};
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
_VirtualList.displayName = 'ui:VirtualList';
|
|
110
|
+
_VirtualList.propTypes = /** @lends ui/VirtualList.VirtualList.prototype */{
|
|
110
111
|
/**
|
|
111
112
|
* A callback function that receives a reference to the `scrollTo` feature.
|
|
112
113
|
*
|
|
@@ -300,7 +301,7 @@ VirtualList.propTypes = /** @lends ui/VirtualList.VirtualList.prototype */{
|
|
|
300
301
|
*/
|
|
301
302
|
verticalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden'])
|
|
302
303
|
};
|
|
303
|
-
|
|
304
|
+
_VirtualList.defaultPropValues = virtualListDefaultProps;
|
|
304
305
|
var virtualGridListDefaultProps = {
|
|
305
306
|
cbScrollTo: nop,
|
|
306
307
|
direction: 'vertical',
|
|
@@ -330,6 +331,7 @@ var virtualGridListDefaultProps = {
|
|
|
330
331
|
* @public
|
|
331
332
|
*/
|
|
332
333
|
var VirtualGridList = exports.VirtualGridList = function VirtualGridList(props) {
|
|
334
|
+
(0, _util.checkPropTypes)(_VirtualList, props);
|
|
333
335
|
var virtualGridListProps = (0, _util.setDefaultProps)(props, virtualGridListDefaultProps);
|
|
334
336
|
var _useScroll2 = (0, _useScroll3["default"])(virtualGridListProps),
|
|
335
337
|
scrollContentHandle = _useScroll2.scrollContentHandle,
|
|
@@ -551,4 +553,4 @@ VirtualGridList.propTypes = /** @lends ui/VirtualList.VirtualGridList.prototype
|
|
|
551
553
|
verticalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden'])
|
|
552
554
|
};
|
|
553
555
|
VirtualGridList.defaultPropValues = virtualGridListDefaultProps;
|
|
554
|
-
var _default = exports["default"] =
|
|
556
|
+
var _default = exports["default"] = _VirtualList;
|
|
@@ -177,13 +177,13 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
177
177
|
offset = optionalOffset;
|
|
178
178
|
} else if (_this.props.itemSizes) {
|
|
179
179
|
// 'end' for different item sizes
|
|
180
|
-
offset = primary.clientSize - _this.props.itemSizes[index] -
|
|
180
|
+
offset = primary.clientSize - _this.props.itemSizes[index] - (optionalOffset || marginOffset);
|
|
181
181
|
} else if (stickTo === 'center') {
|
|
182
182
|
// 'center'
|
|
183
183
|
offset = primary.clientSize / 2 - primary.gridSize / 2 - optionalOffset;
|
|
184
184
|
} else {
|
|
185
185
|
// 'end' for same item sizes
|
|
186
|
-
offset = primary.clientSize - primary.itemSize -
|
|
186
|
+
offset = primary.clientSize - primary.itemSize - (optionalOffset || marginOffset);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/* istanbul ignore next */
|
|
@@ -357,6 +357,7 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
357
357
|
}
|
|
358
358
|
return false;
|
|
359
359
|
};
|
|
360
|
+
(0, _util.checkPropTypes)(_this, _props);
|
|
360
361
|
_this.contentRef = /*#__PURE__*/(0, _react.createRef)();
|
|
361
362
|
_this.itemContainerRefs = [];
|
|
362
363
|
_this.state = {
|
|
@@ -394,16 +395,20 @@ var VirtualListBasic = exports.VirtualListBasic = /*#__PURE__*/function (_Compon
|
|
|
394
395
|
}, {
|
|
395
396
|
key: "componentDidUpdate",
|
|
396
397
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
397
|
-
var items =
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
var items = this.props.itemRefs.current;
|
|
399
|
+
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
400
|
+
if (!this.itemMarginTop && this.itemMarginTop !== 0 && items[0]) {
|
|
401
|
+
var firstItemStyle = window.getComputedStyle(items[0]);
|
|
400
402
|
this.itemMarginTop = Number(firstItemStyle.getPropertyValue('margin-top').slice(0, -2));
|
|
401
403
|
this.itemMarginBottom = Number(firstItemStyle.getPropertyValue('margin-bottom').slice(0, -2));
|
|
402
404
|
this.itemMarginLeft = Number(firstItemStyle.getPropertyValue('margin-left').slice(0, -2));
|
|
403
405
|
this.itemMarginRight = Number(firstItemStyle.getPropertyValue('margin-right').slice(0, -2));
|
|
406
|
+
if (this.isPrimaryDirectionVertical) {
|
|
407
|
+
this.scrollBounds.maxTop += this.itemMarginTop + this.itemMarginBottom;
|
|
408
|
+
} else {
|
|
409
|
+
this.scrollBounds.maxLeft += this.itemMarginLeft + this.itemMarginRight;
|
|
410
|
+
}
|
|
404
411
|
}
|
|
405
|
-
this.scrollBounds.maxTop += this.itemMarginTop + this.itemMarginBottom;
|
|
406
|
-
this.scrollBounds.maxLeft += this.itemMarginLeft + this.itemMarginRight;
|
|
407
412
|
var deferScrollTo = false;
|
|
408
413
|
var _this$state = this.state,
|
|
409
414
|
firstIndex = _this$state.firstIndex,
|
|
@@ -29,6 +29,7 @@ describe('VirtualList with native scrollMode', function () {
|
|
|
29
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
30
|
// eslint-disable-line enact/display-name
|
|
31
31
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
32
|
+
"data-index": index,
|
|
32
33
|
id: 'item' + index,
|
|
33
34
|
children: items[index].name
|
|
34
35
|
}));
|
|
@@ -58,6 +59,19 @@ describe('VirtualList with native scrollMode', function () {
|
|
|
58
59
|
var actual = _react.screen.getByRole('list').children.item(0).textContent;
|
|
59
60
|
expect(actual).toBe(expected);
|
|
60
61
|
});
|
|
62
|
+
test('should render a list of \'items\' with horizontal direction', function () {
|
|
63
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
64
|
+
clientSize: clientSize,
|
|
65
|
+
dataSize: dataSize,
|
|
66
|
+
direction: "horizontal",
|
|
67
|
+
itemRenderer: renderItem,
|
|
68
|
+
itemSize: itemSize,
|
|
69
|
+
scrollMode: "native"
|
|
70
|
+
}));
|
|
71
|
+
var expected = 'Account 0';
|
|
72
|
+
var actual = _react.screen.getByRole('list').children.item(0).textContent;
|
|
73
|
+
expect(actual).toBe(expected);
|
|
74
|
+
});
|
|
61
75
|
test('should render overhang items when clientSize is not given', function () {
|
|
62
76
|
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
63
77
|
dataSize: dataSize,
|
|
@@ -114,6 +114,7 @@ describe('VirtualList', function () {
|
|
|
114
114
|
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
115
115
|
// eslint-disable-line enact/display-name
|
|
116
116
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
117
|
+
"data-index": index,
|
|
117
118
|
id: 'item' + index,
|
|
118
119
|
children: items[index].name
|
|
119
120
|
}));
|
|
@@ -152,6 +153,18 @@ describe('VirtualList', function () {
|
|
|
152
153
|
var actual = _react.screen.getByRole('list').children.item(0).textContent;
|
|
153
154
|
expect(actual).toBe(expected);
|
|
154
155
|
});
|
|
156
|
+
test('should render a list of \'items\' with horizontal direction', function () {
|
|
157
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
158
|
+
clientSize: clientSize,
|
|
159
|
+
dataSize: dataSize,
|
|
160
|
+
direction: "horizontal",
|
|
161
|
+
itemRenderer: renderItem,
|
|
162
|
+
itemSize: itemSize
|
|
163
|
+
}));
|
|
164
|
+
var expected = 'Account 0';
|
|
165
|
+
var actual = _react.screen.getByRole('list').children.item(0).textContent;
|
|
166
|
+
expect(actual).toBe(expected);
|
|
167
|
+
});
|
|
155
168
|
test('should render overhang items when clientSize is not given', function () {
|
|
156
169
|
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
157
170
|
dataSize: dataSize,
|