@enact/ui 4.1.2 → 4.5.0-alpha.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/AnnounceDecorator/Announce.js +9 -9
- package/AnnounceDecorator/AnnounceDecorator.js +6 -4
- package/AnnounceDecorator/tests/Announce-specs.js +13 -5
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
- package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
- package/AnnounceDecorator/useAnnounce.js +1 -1
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +6 -4
- package/BodyText/tests/BodyText-specs.js +51 -37
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +11 -7
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +25 -0
- package/Cancelable/Cancelable.js +12 -11
- package/Cancelable/tests/Cancelable-specs.js +133 -70
- package/Changeable/Changeable.js +9 -9
- package/Changeable/tests/Changeable-specs.js +172 -110
- package/ComponentOverride/ComponentOverride.js +6 -4
- package/FloatingLayer/FloatingLayer.js +40 -49
- package/FloatingLayer/FloatingLayer.module.css +3 -0
- package/FloatingLayer/FloatingLayerContainer.js +2 -2
- package/FloatingLayer/FloatingLayerDecorator.js +6 -4
- package/FloatingLayer/Scrim.js +9 -7
- package/FloatingLayer/index.js +1 -1
- package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
- package/FloatingLayer/tests/Scrim-specs.js +20 -11
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +17 -11
- package/FloatingLayer/useFloatingLayer.js +2 -2
- package/FloatingLayer/useFloatingLayerDecorator.js +1 -1
- package/ForwardRef/ForwardRef.js +3 -3
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +6 -4
- package/Group/Group.d.ts +2 -2
- package/Group/Group.js +7 -4
- package/Group/GroupItem.js +6 -4
- package/Group/tests/Group-specs.js +73 -43
- package/Heading/Heading.d.ts +2 -1
- package/Heading/Heading.js +6 -4
- package/Heading/tests/Heading-specs.js +27 -20
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +6 -4
- package/Icon/tests/Icon-specs.js +54 -33
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +6 -4
- package/IconButton/tests/IconButton-specs.js +2 -2
- package/Image/Image.js +6 -4
- package/Image/tests/Image-specs.js +41 -31
- package/ImageItem/ImageItem.js +8 -5
- package/ImageItem/tests/ImageItem-specs.js +75 -72
- package/Item/Item.js +6 -4
- package/Item/tests/Item-specs.js +59 -35
- package/LabeledIcon/LabeledIcon.d.ts +4 -4
- package/LabeledIcon/LabeledIcon.js +6 -4
- package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
- package/Layout/Cell.js +6 -4
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +6 -4
- package/Layout/tests/Layout-specs.js +42 -30
- package/Marquee/MarqueeBase.js +7 -9
- package/Marquee/MarqueeController.js +9 -9
- package/Marquee/MarqueeDecorator.js +18 -13
- package/Marquee/index.d.ts +4 -1
- package/Marquee/index.js +2 -1
- package/Marquee/tests/Marquee-specs.js +254 -122
- package/Measurable/Measurable.js +4 -4
- package/Media/Media.js +10 -10
- package/Placeholder/PlaceholderControllerDecorator.js +9 -9
- package/Placeholder/PlaceholderDecorator.js +9 -9
- package/ProgressBar/ProgressBar.js +6 -4
- package/ProgressBar/tests/ProgressBar-specs.js +60 -42
- package/README.md +1 -1
- package/RadioDecorator/RadioControllerDecorator.js +9 -9
- package/RadioDecorator/RadioDecorator.js +12 -14
- package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
- package/Repeater/Repeater.d.ts +2 -1
- package/Repeater/Repeater.js +6 -4
- package/Repeater/tests/Repeater-specs.js +90 -49
- package/Resizable/Resizable.js +10 -10
- package/Routable/Link.js +9 -7
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +10 -6
- package/Routable/Route.js +1 -1
- package/Routable/Router.js +14 -11
- package/Routable/tests/Routable-specs.js +29 -20
- package/Routable/tests/Router-specs.js +65 -41
- package/Routable/useLink.js +1 -1
- package/Routable/util.js +1 -1
- package/Scrollable/ScrollAnimator.js +2 -2
- package/Scrollable/ScrollThumb.js +3 -3
- package/Scrollable/Scrollable.js +14 -10
- package/Scrollable/ScrollableNative.js +14 -10
- package/Scrollable/Scrollbar.js +14 -8
- package/Scroller/Scroller.d.ts +2 -14
- package/Scroller/Scroller.js +8 -7
- package/Scroller/ScrollerBasic.js +18 -35
- package/Scroller/UiScrollerBase.js +9 -7
- package/Skinnable/Skinnable.js +6 -4
- package/Skinnable/tests/Skinnable-specs.js +104 -56
- package/Skinnable/tests/useSkins-specs.js +39 -44
- package/Skinnable/useSkins.js +1 -1
- package/Slider/Knob.js +6 -4
- package/Slider/PositionDecorator.js +9 -9
- package/Slider/Slider.d.ts +3 -3
- package/Slider/Slider.js +6 -4
- package/Slider/tests/Slider-specs.js +4 -4
- package/SlotItem/SlotItem.d.ts +2 -2
- package/SlotItem/SlotItem.js +6 -4
- package/SlotItem/tests/SlotItem-specs.js +4 -4
- package/Slottable/Slottable.js +3 -3
- package/Slottable/tests/Slottable-specs.js +67 -36
- package/Slottable/tests/useSlots-specs.js +68 -35
- package/Slottable/useSlots.js +6 -4
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +6 -4
- package/Spinner/tests/Spinner-specs.js +46 -31
- package/ToggleIcon/ToggleIcon.js +6 -4
- package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
- package/ToggleItem/ToggleItem.d.ts +13 -11
- package/ToggleItem/ToggleItem.js +6 -4
- package/ToggleItem/tests/ToggleItem-specs.js +54 -37
- package/Toggleable/Toggle.js +10 -10
- package/Toggleable/Toggleable.js +11 -17
- package/Toggleable/tests/Toggleable-specs.js +464 -324
- package/Toggleable/useToggle.js +4 -2
- package/Touchable/ClickAllow.js +2 -2
- package/Touchable/Drag.js +22 -22
- package/Touchable/Flick.js +22 -18
- package/Touchable/Hold.js +18 -23
- package/Touchable/Touch.js +2 -2
- package/Touchable/Touchable.d.ts +3 -3
- package/Touchable/Touchable.js +7 -4
- package/Touchable/config.js +3 -3
- package/Touchable/tests/Touchable-specs.js +225 -109
- package/Touchable/tests/useTouch-specs.js +163 -86
- package/Touchable/useTouch.js +4 -4
- package/Transition/Transition.d.ts +29 -27
- package/Transition/Transition.js +22 -17
- package/Transition/tests/Transition-specs.js +116 -36
- package/ViewManager/Arranger.js +3 -3
- package/ViewManager/TransitionGroup.js +10 -9
- package/ViewManager/View.js +7 -7
- package/ViewManager/ViewManager.d.ts +4 -4
- package/ViewManager/ViewManager.js +24 -22
- package/ViewManager/tests/View-specs.js +141 -81
- package/ViewManager/tests/ViewManager-specs.js +486 -193
- package/VirtualList/UiVirtualListBase.js +26 -35
- package/VirtualList/VirtualList.d.ts +11 -29
- package/VirtualList/VirtualList.js +10 -9
- package/VirtualList/VirtualListBase.js +1 -1
- package/VirtualList/VirtualListBasic.js +44 -61
- package/VirtualList/tests/VirtualList-specs.js +81 -95
- package/internal/IdProvider/IdProvider.js +3 -3
- package/internal/IdProvider/Provider.js +2 -2
- package/internal/IdProvider/tests/useId-specs.js +37 -20
- package/internal/Pure/Pure.js +9 -9
- package/internal/localized-fonts/localized-fonts.js +1 -1
- package/internal/validators/validators.js +1 -1
- package/package.json +11 -11
- package/resolution/ResolutionDecorator.js +9 -9
- package/resolution/index.js +2 -2
- package/resolution/resolution.js +4 -2
- package/resolution/tests/ResolutionDecorator-specs.js +17 -8
- package/styles/mixins.less +14 -2
- package/useControlledState/tests/useControlledState-specs.js +68 -43
- package/useControlledState/useControlledState.js +2 -2
- package/useScroll/ScrollAnimator.js +2 -2
- package/useScroll/Scrollbar.js +7 -4
- package/useScroll/ScrollbarTrack.js +6 -4
- package/useScroll/useScroll.js +18 -29
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var _useTouch = _interopRequireDefault(require("../useTouch"));
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
6
4
|
|
|
7
5
|
var _config = require("../config");
|
|
8
6
|
|
|
7
|
+
var _useTouch = _interopRequireDefault(require("../useTouch"));
|
|
8
|
+
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
|
|
11
|
+
var _excluded = ["activeProp", "id"];
|
|
12
|
+
|
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
14
|
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
16
|
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
18
|
|
|
17
19
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
20
|
|
|
@@ -21,14 +23,19 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
21
23
|
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; }
|
|
22
24
|
|
|
23
25
|
describe('useTouch', function () {
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
+
var data;
|
|
27
|
+
|
|
28
|
+
var DivComponent = function DivComponent(props) {
|
|
29
|
+
data = props;
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
31
|
+
"data-testid": "component"
|
|
32
|
+
});
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
var TouchableComponent = function TouchableComponent(_ref) {
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
rest = _objectWithoutProperties(_ref,
|
|
36
|
+
var activeProp = _ref.activeProp,
|
|
37
|
+
id = _ref.id,
|
|
38
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
39
|
|
|
33
40
|
var hook = (0, _useTouch["default"])(_objectSpread({
|
|
34
41
|
getActive: !!activeProp
|
|
@@ -48,13 +55,11 @@ describe('useTouch', function () {
|
|
|
48
55
|
beforeEach(_config.resetDefaultConfig);
|
|
49
56
|
afterEach(_config.resetDefaultConfig);
|
|
50
57
|
test('should return active state when activeProp is configured', function () {
|
|
51
|
-
|
|
58
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
52
59
|
activeProp: "active"
|
|
53
60
|
}));
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
var actual = ('active' in wrapped.props());
|
|
57
|
-
expect(actual).toBe(expected);
|
|
61
|
+
var expected = data.active;
|
|
62
|
+
expect(expected).toBeDefined();
|
|
58
63
|
});
|
|
59
64
|
test('should merge configurations', function () {
|
|
60
65
|
(0, _config.configure)({
|
|
@@ -108,83 +113,116 @@ describe('useTouch', function () {
|
|
|
108
113
|
describe('#onDown', function () {
|
|
109
114
|
test('should invoke onDown handle on mouse down', function () {
|
|
110
115
|
var handler = jest.fn();
|
|
111
|
-
|
|
116
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
112
117
|
activeProp: "active",
|
|
113
118
|
onDown: handler
|
|
114
119
|
}));
|
|
115
|
-
|
|
120
|
+
|
|
121
|
+
var component = _react.screen.getByTestId('component');
|
|
122
|
+
|
|
123
|
+
_react.fireEvent.mouseDown(component, {});
|
|
124
|
+
|
|
116
125
|
var expected = 1;
|
|
117
|
-
|
|
118
|
-
expect(actual).toBe(expected);
|
|
126
|
+
expect(handler).toHaveBeenCalledTimes(expected);
|
|
119
127
|
});
|
|
120
128
|
});
|
|
121
129
|
describe('#onUp', function () {
|
|
122
130
|
test('should invoke onUp handle on mouse up', function () {
|
|
123
131
|
var handler = jest.fn();
|
|
124
|
-
|
|
132
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
125
133
|
activeProp: "active",
|
|
126
134
|
onUp: handler
|
|
127
135
|
}));
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
|
|
137
|
+
var component = _react.screen.getByTestId('component');
|
|
138
|
+
|
|
139
|
+
_react.fireEvent.mouseDown(component, {});
|
|
140
|
+
|
|
141
|
+
_react.fireEvent.mouseUp(component, {});
|
|
142
|
+
|
|
130
143
|
var expected = 1;
|
|
131
|
-
|
|
132
|
-
expect(actual).toBe(expected);
|
|
144
|
+
expect(handler).toHaveBeenCalledTimes(expected);
|
|
133
145
|
});
|
|
134
146
|
});
|
|
135
147
|
describe('#onTap', function () {
|
|
136
148
|
test('should be called on mouse up', function () {
|
|
137
149
|
var handler = jest.fn();
|
|
138
|
-
|
|
150
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
139
151
|
activeProp: "active",
|
|
140
152
|
onTap: handler
|
|
141
153
|
}));
|
|
142
|
-
|
|
143
|
-
|
|
154
|
+
|
|
155
|
+
var component = _react.screen.getByTestId('component');
|
|
156
|
+
|
|
157
|
+
_react.fireEvent.mouseDown(component, {});
|
|
158
|
+
|
|
159
|
+
_react.fireEvent.mouseUp(component, {});
|
|
160
|
+
|
|
144
161
|
var expected = 1;
|
|
145
|
-
|
|
146
|
-
expect(actual).toBe(expected);
|
|
162
|
+
expect(handler).toHaveBeenCalledTimes(expected);
|
|
147
163
|
});
|
|
148
164
|
test('should be called on click', function () {
|
|
149
165
|
var handler = jest.fn();
|
|
150
|
-
|
|
166
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
151
167
|
activeProp: "active",
|
|
152
168
|
onTap: handler
|
|
153
169
|
}));
|
|
154
|
-
|
|
170
|
+
|
|
171
|
+
var component = _react.screen.getByTestId('component');
|
|
172
|
+
|
|
173
|
+
_react.fireEvent.click(component, {});
|
|
174
|
+
|
|
155
175
|
var expected = 1;
|
|
156
|
-
|
|
157
|
-
expect(actual).toBe(expected);
|
|
176
|
+
expect(handler).toHaveBeenCalledTimes(expected);
|
|
158
177
|
});
|
|
159
178
|
test('should be called before onClick on click', function () {
|
|
160
179
|
var handler = jest.fn();
|
|
161
|
-
|
|
180
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
162
181
|
activeProp: "active",
|
|
163
182
|
onClick: handler,
|
|
164
183
|
onTap: handler
|
|
165
184
|
}));
|
|
166
|
-
|
|
185
|
+
|
|
186
|
+
var component = _react.screen.getByTestId('component');
|
|
187
|
+
|
|
188
|
+
_react.fireEvent.click(component, {});
|
|
189
|
+
|
|
167
190
|
var expected = ['onTap', 'click'];
|
|
168
191
|
var actual = handler.mock.calls.map(function (call) {
|
|
169
192
|
return call[0].type;
|
|
170
193
|
});
|
|
171
194
|
expect(actual).toEqual(expected);
|
|
172
195
|
});
|
|
173
|
-
test('should be called before
|
|
196
|
+
test('should be called before onClick on mouse up', function () {
|
|
174
197
|
var handler = jest.fn();
|
|
175
|
-
|
|
198
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
176
199
|
activeProp: "active",
|
|
177
200
|
onClick: handler,
|
|
178
201
|
onTap: handler
|
|
179
202
|
}));
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
203
|
+
|
|
204
|
+
var component = _react.screen.getByTestId('component');
|
|
205
|
+
|
|
206
|
+
var mouseDownEvent = _react.createEvent.mouseDown(component, {});
|
|
207
|
+
|
|
208
|
+
var mouseUpEvent = _react.createEvent.mouseUp(component, {});
|
|
209
|
+
|
|
210
|
+
var clickEvent = _react.createEvent.click(component, {}); // a matching timeStamp is used by Touchable to prevent multiple onTaps on "true"
|
|
211
|
+
// click (mouseup + click)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
Object.defineProperty(mouseDownEvent, 'timeStamp', {
|
|
215
|
+
value: 1
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(mouseUpEvent, 'timeStamp', {
|
|
218
|
+
value: 1
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(clickEvent, 'timeStamp', {
|
|
221
|
+
value: 1
|
|
222
|
+
});
|
|
223
|
+
(0, _react.fireEvent)(component, mouseDownEvent);
|
|
224
|
+
(0, _react.fireEvent)(component, mouseUpEvent);
|
|
225
|
+
(0, _react.fireEvent)(component, clickEvent);
|
|
188
226
|
var expected = ['onTap', 'click'];
|
|
189
227
|
var actual = handler.mock.calls.map(function (call) {
|
|
190
228
|
return call[0].type;
|
|
@@ -193,95 +231,129 @@ describe('useTouch', function () {
|
|
|
193
231
|
});
|
|
194
232
|
test('should be preventable via onUp handler', function () {
|
|
195
233
|
var handler = jest.fn();
|
|
196
|
-
|
|
234
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
197
235
|
activeProp: "active",
|
|
198
236
|
onTap: handler,
|
|
199
237
|
onUp: preventDefault
|
|
200
238
|
}));
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
239
|
+
|
|
240
|
+
var component = _react.screen.getByTestId('component');
|
|
241
|
+
|
|
242
|
+
_react.fireEvent.mouseDown(component, {});
|
|
243
|
+
|
|
244
|
+
_react.fireEvent.mouseUp(component, {});
|
|
245
|
+
|
|
246
|
+
expect(handler).not.toHaveBeenCalled();
|
|
206
247
|
});
|
|
207
248
|
});
|
|
208
249
|
describe('state management', function () {
|
|
209
250
|
describe('activate', function () {
|
|
210
251
|
test('should update active state on mouse down when activeProp is configured', function () {
|
|
211
252
|
var handler = jest.fn();
|
|
212
|
-
|
|
253
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
213
254
|
activeProp: "active",
|
|
214
255
|
onDown: handler
|
|
215
256
|
}));
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
257
|
+
|
|
258
|
+
var component = _react.screen.getByTestId('component');
|
|
259
|
+
|
|
260
|
+
var beforeDown = data.active;
|
|
261
|
+
|
|
262
|
+
_react.fireEvent.mouseDown(component, {});
|
|
263
|
+
|
|
264
|
+
var afterDown = data.active;
|
|
219
265
|
var expected = false;
|
|
220
266
|
var actual = beforeDown === afterDown;
|
|
221
267
|
expect(actual).toBe(expected);
|
|
222
268
|
});
|
|
223
269
|
test('should not update active state on mouse down when disabled', function () {
|
|
224
270
|
var handler = jest.fn();
|
|
225
|
-
|
|
271
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
226
272
|
activeProp: "active",
|
|
227
273
|
disabled: true,
|
|
228
274
|
onDown: handler
|
|
229
275
|
}));
|
|
230
|
-
|
|
276
|
+
|
|
277
|
+
var component = _react.screen.getByTestId('component');
|
|
278
|
+
|
|
279
|
+
_react.fireEvent.mouseDown(component, {});
|
|
280
|
+
|
|
231
281
|
var expected = false;
|
|
232
|
-
var actual =
|
|
282
|
+
var actual = data.active;
|
|
233
283
|
expect(actual).toBe(expected);
|
|
234
284
|
});
|
|
235
285
|
test('should not update active state on mouse down when preventDefault is called', function () {
|
|
236
|
-
|
|
286
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
237
287
|
activeProp: "active",
|
|
238
288
|
onDown: preventDefault
|
|
239
289
|
}));
|
|
240
|
-
|
|
290
|
+
|
|
291
|
+
var component = _react.screen.getByTestId('component');
|
|
292
|
+
|
|
293
|
+
_react.fireEvent.mouseDown(component, {});
|
|
294
|
+
|
|
241
295
|
var expected = false;
|
|
242
|
-
var actual =
|
|
296
|
+
var actual = data.active;
|
|
243
297
|
expect(actual).toBe(expected);
|
|
244
298
|
});
|
|
245
299
|
});
|
|
246
300
|
describe('deactivate', function () {
|
|
247
301
|
test('should update active state on mouse up when activeProp is configured', function () {
|
|
248
302
|
var handler = jest.fn();
|
|
249
|
-
|
|
303
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
250
304
|
activeProp: "active",
|
|
251
305
|
onDown: handler
|
|
252
306
|
}));
|
|
253
|
-
|
|
254
|
-
var
|
|
255
|
-
|
|
256
|
-
|
|
307
|
+
|
|
308
|
+
var component = _react.screen.getByTestId('component');
|
|
309
|
+
|
|
310
|
+
_react.fireEvent.mouseDown(component, {});
|
|
311
|
+
|
|
312
|
+
var beforeUp = data.active;
|
|
313
|
+
|
|
314
|
+
_react.fireEvent.mouseUp(component, {});
|
|
315
|
+
|
|
316
|
+
var afterUp = data.active;
|
|
257
317
|
var expected = false;
|
|
258
318
|
var actual = beforeUp === afterUp;
|
|
259
319
|
expect(actual).toBe(expected);
|
|
260
320
|
});
|
|
261
321
|
test('should not update active state on mouse down when disabled', function () {
|
|
262
322
|
var handler = jest.fn();
|
|
263
|
-
|
|
323
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
264
324
|
activeProp: "active",
|
|
265
325
|
disabled: true,
|
|
266
326
|
onDown: handler
|
|
267
327
|
}));
|
|
268
|
-
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
|
|
328
|
+
|
|
329
|
+
var component = _react.screen.getByTestId('component');
|
|
330
|
+
|
|
331
|
+
_react.fireEvent.mouseDown(component, {});
|
|
332
|
+
|
|
333
|
+
var beforeUp = data.active;
|
|
334
|
+
|
|
335
|
+
_react.fireEvent.mouseUp(component, {});
|
|
336
|
+
|
|
337
|
+
var afterUp = data.active;
|
|
272
338
|
var expected = true;
|
|
273
339
|
var actual = beforeUp === afterUp;
|
|
274
340
|
expect(actual).toBe(expected);
|
|
275
341
|
});
|
|
276
342
|
test('should not update active state on mouse down when preventDefault is called', function () {
|
|
277
|
-
|
|
343
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TouchableComponent, {
|
|
278
344
|
activeProp: "active",
|
|
279
345
|
onDown: preventDefault
|
|
280
346
|
}));
|
|
281
|
-
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
|
|
347
|
+
|
|
348
|
+
var component = _react.screen.getByTestId('component');
|
|
349
|
+
|
|
350
|
+
_react.fireEvent.mouseDown(component, {});
|
|
351
|
+
|
|
352
|
+
var beforeUp = data.active;
|
|
353
|
+
|
|
354
|
+
_react.fireEvent.mouseUp(component, {});
|
|
355
|
+
|
|
356
|
+
var afterUp = data.active;
|
|
285
357
|
var expected = true;
|
|
286
358
|
var actual = beforeUp === afterUp;
|
|
287
359
|
expect(actual).toBe(expected);
|
|
@@ -301,14 +373,17 @@ describe('useTouch', function () {
|
|
|
301
373
|
id: "outer"
|
|
302
374
|
}, outerHook.handlers), {}, {
|
|
303
375
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
|
|
304
|
-
|
|
376
|
+
"data-testid": "inner"
|
|
305
377
|
}, innerHook.handlers), {}, {
|
|
306
378
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DivComponent, {})
|
|
307
379
|
}))
|
|
308
380
|
}));
|
|
309
381
|
};
|
|
310
382
|
|
|
311
|
-
|
|
383
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
384
|
+
|
|
385
|
+
var inner = _react.screen.getByTestId('inner');
|
|
386
|
+
|
|
312
387
|
var mouseEvent = {
|
|
313
388
|
timeStamp: 1
|
|
314
389
|
};
|
|
@@ -323,14 +398,16 @@ describe('useTouch', function () {
|
|
|
323
398
|
clientY: 0
|
|
324
399
|
}]
|
|
325
400
|
};
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
401
|
+
|
|
402
|
+
_react.fireEvent.touchStart(inner, touchEvent);
|
|
403
|
+
|
|
404
|
+
_react.fireEvent.touchEnd(inner, touchEvent);
|
|
405
|
+
|
|
406
|
+
_react.fireEvent.mouseDown(inner, mouseEvent);
|
|
407
|
+
|
|
408
|
+
_react.fireEvent.mouseUp(inner, mouseEvent);
|
|
409
|
+
|
|
410
|
+
expect(handler).toHaveBeenCalled();
|
|
334
411
|
});
|
|
335
412
|
});
|
|
336
413
|
});
|
package/Touchable/useTouch.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useTouch = useTouch;
|
|
7
6
|
exports["default"] = void 0;
|
|
7
|
+
exports.useTouch = useTouch;
|
|
8
8
|
|
|
9
9
|
var _useClass = _interopRequireDefault(require("@enact/core/useClass"));
|
|
10
10
|
|
|
@@ -16,9 +16,9 @@ var _Touch = _interopRequireDefault(require("./Touch"));
|
|
|
16
16
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
18
|
|
|
19
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
20
|
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
22
|
|
|
23
23
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
30
30
|
|
|
31
31
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
32
32
|
|
|
33
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr
|
|
33
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
34
34
|
|
|
35
35
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
36
36
|
|
|
@@ -75,10 +75,11 @@ are also supported and treated as milliseconds.
|
|
|
75
75
|
*/
|
|
76
76
|
noAnimation?: boolean;
|
|
77
77
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
* The transition timing function.
|
|
79
|
+
* * Supported function names are: `ease` , `ease-in` , `ease-out` , `ease-in-out` , `ease-in-quart` ,
|
|
80
|
+
*
|
|
81
|
+
* `ease-out-quart` , and `linear` .
|
|
82
|
+
*/
|
|
82
83
|
timingFunction?: string;
|
|
83
84
|
/**
|
|
84
85
|
* The type of transition to affect the content.
|
|
@@ -86,19 +87,19 @@ are also supported and treated as milliseconds.
|
|
|
86
87
|
*
|
|
87
88
|
* Details on types:
|
|
88
89
|
* * `'slide'` - Typically used for bringing something which is off the edge of the screen,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
|
|
91
|
+
an overlaying menu. This requires no re-rendering or repainting of the screen during
|
|
92
|
+
the transition, making it very performant. However, this does not affect layout at
|
|
93
|
+
all, which makes it less useful for transitioning from a place already on the
|
|
94
|
+
screen.
|
|
94
95
|
* * `'clip'` - This is useful for showing a component that transitions-in from a location
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
that is already on the screen. Examples would be an expanding header or an
|
|
97
|
+
accordion. This type does affects layout, its current size will push other sibling
|
|
98
|
+
elements to make room for itself. Because of this, repainting the layout does happen
|
|
99
|
+
during transition.
|
|
99
100
|
* * `'fade'` - Fade the components onto the screen, from 0 opacity (completely invisible)
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
|
|
102
|
+
menu, a panel, or even view contents. This does not affect layout at all.
|
|
102
103
|
*/
|
|
103
104
|
type?: string;
|
|
104
105
|
/**
|
|
@@ -130,7 +131,8 @@ export interface TransitionProps {
|
|
|
130
131
|
/**
|
|
131
132
|
* Controls how long the transition should take.
|
|
132
133
|
* * Supported preset durations are: `'short'` (250ms), `'medium'` (500ms), and `'long'` (1s).
|
|
133
|
-
|
|
134
|
+
*
|
|
135
|
+
* `'medium'` (500ms) is default when no others are specified.
|
|
134
136
|
*
|
|
135
137
|
* Any valid CSS duration value is also accepted, e.g. "200ms" or "3s". Pure numeric values
|
|
136
138
|
are also supported and treated as miliseconds.
|
|
@@ -162,19 +164,19 @@ Supported function names are: `ease` , `ease-in` , `ease-out` , `ease-in-out
|
|
|
162
164
|
*
|
|
163
165
|
* Details on types:
|
|
164
166
|
* * `'slide'` - Typically used for bringing something which is off the edge of the screen,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
and not visible, onto the screen. Think of a popup, toast, notification, dialog, or
|
|
168
|
+
an overlaying menu. This requires no re-rendering or repainting of the screen during
|
|
169
|
+
the transition, making it very performant. However, this does not affect layout at
|
|
170
|
+
all, which makes it less useful for transitioning from a place already on the
|
|
171
|
+
screen.
|
|
170
172
|
* * `'clip'` - This is useful for showing a component that transitions-in from a location
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
that is already on the screen. Examples would be an expanding header or an
|
|
174
|
+
accordion. This type does affects layout, its current size will push other sibling
|
|
175
|
+
elements to make room for itself. Because of this, repainting the layout does happen
|
|
176
|
+
during transition.
|
|
175
177
|
* * `'fade'` - Fade the components onto the screen, from 0 opacity (completely invisible)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
to 1 (full visibility). Pretty basic, but useful for fading on/off a tooltip, a
|
|
179
|
+
menu, a panel, or even view contents. This does not affect layout at all.
|
|
178
180
|
*/
|
|
179
181
|
type?: string;
|
|
180
182
|
/**
|