@angular/cdk 8.1.4 → 8.2.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.
- package/a11y/typings/index.metadata.json +1 -1
- package/a11y/typings/key-manager/focus-key-manager.d.ts +1 -1
- package/bundles/cdk-a11y.umd.js +10 -2
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +1 -1
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +239 -36
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +2 -2
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +15 -8
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-overlay.umd.min.js +2 -2
- package/bundles/cdk-overlay.umd.min.js.map +1 -1
- package/bundles/cdk-platform.umd.js +21 -0
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js +1 -1
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +1 -1
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-stepper.umd.js +46 -40
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js +1 -1
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +4 -4
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-testing.umd.js +404 -0
- package/bundles/cdk-testing.umd.js.map +1 -0
- package/bundles/cdk-testing.umd.min.js +9 -0
- package/bundles/cdk-testing.umd.min.js.map +1 -0
- package/bundles/cdk-text-field.umd.js +3 -3
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/drag-drop/typings/drag-ref.d.ts +9 -0
- package/drag-drop/typings/drop-list-ref.d.ts +7 -1
- package/drag-drop/typings/index.metadata.json +1 -1
- package/esm2015/a11y.js +10 -2
- package/esm2015/a11y.js.map +1 -1
- package/esm2015/cdk.js +1 -1
- package/esm2015/cdk.js.map +1 -1
- package/esm2015/drag-drop.js +212 -37
- package/esm2015/drag-drop.js.map +1 -1
- package/esm2015/overlay.js +13 -6
- package/esm2015/overlay.js.map +1 -1
- package/esm2015/platform.js +21 -1
- package/esm2015/platform.js.map +1 -1
- package/esm2015/scrolling.js +1 -1
- package/esm2015/scrolling.js.map +1 -1
- package/esm2015/stepper.js +51 -45
- package/esm2015/stepper.js.map +1 -1
- package/esm2015/table.js +4 -4
- package/esm2015/table.js.map +1 -1
- package/esm2015/testing.js +370 -0
- package/esm2015/testing.js.map +1 -0
- package/esm2015/text-field.js +1 -1
- package/esm2015/text-field.js.map +1 -1
- package/esm5/a11y.es5.js +10 -2
- package/esm5/a11y.es5.js.map +1 -1
- package/esm5/cdk.es5.js +1 -1
- package/esm5/cdk.es5.js.map +1 -1
- package/esm5/drag-drop.es5.js +241 -38
- package/esm5/drag-drop.es5.js.map +1 -1
- package/esm5/overlay.es5.js +15 -8
- package/esm5/overlay.es5.js.map +1 -1
- package/esm5/platform.es5.js +21 -1
- package/esm5/platform.es5.js.map +1 -1
- package/esm5/scrolling.es5.js +1 -1
- package/esm5/scrolling.es5.js.map +1 -1
- package/esm5/stepper.es5.js +49 -43
- package/esm5/stepper.es5.js.map +1 -1
- package/esm5/table.es5.js +4 -4
- package/esm5/table.es5.js.map +1 -1
- package/esm5/testing.es5.js +390 -0
- package/esm5/testing.es5.js.map +1 -0
- package/esm5/text-field.es5.js +3 -3
- package/esm5/text-field.es5.js.map +1 -1
- package/overlay/typings/index.metadata.json +1 -1
- package/overlay/typings/position/flexible-connected-position-strategy.d.ts +5 -2
- package/overlay/typings/public-api.d.ts +1 -1
- package/package.json +4 -4
- package/platform/typings/features/shadow-dom.d.ts +9 -0
- package/platform/typings/index.metadata.json +1 -1
- package/platform/typings/public-api.d.ts +1 -0
- package/schematics/ng-update/index.js +2 -2
- package/schematics/ng-update/index.js.map +1 -1
- package/schematics/ng-update/test-cases/misc/global-stylesheets-test.css +1 -0
- package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +3 -3
- package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js.map +1 -1
- package/schematics/tsconfig.tsbuildinfo +2898 -2898
- package/schematics/update-tool/index.js +9 -5
- package/schematics/update-tool/index.js.map +1 -1
- package/scrolling/typings/virtual-scroll-viewport.d.ts +1 -1
- package/stepper/typings/index.metadata.json +1 -1
- package/stepper/typings/stepper.d.ts +3 -3
- package/table/typings/table.d.ts +4 -4
- package/testing/index.d.ts +8 -0
- package/testing/index.metadata.json +12 -0
- package/testing/package.json +8 -0
- package/testing/typings/dispatch-events.d.ts +33 -0
- package/testing/typings/element-focus.d.ts +18 -0
- package/testing/typings/event-objects.d.ts +34 -0
- package/testing/typings/index.d.ts +4 -0
- package/testing/typings/index.metadata.json +1 -0
- package/testing/typings/public-api.d.ts +11 -0
- package/testing/typings/type-in-element.d.ts +41 -0
- package/testing.d.ts +8 -0
- package/testing.metadata.json +12 -0
- package/text-field/typings/autosize.d.ts +1 -1
- package/typings/a11y/index.metadata.json +1 -1
- package/typings/a11y/key-manager/focus-key-manager.d.ts +1 -1
- package/typings/drag-drop/drag-ref.d.ts +9 -0
- package/typings/drag-drop/drop-list-ref.d.ts +7 -1
- package/typings/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/a11y/index.metadata.json +1 -1
- package/typings/esm5/a11y/key-manager/focus-key-manager.d.ts +1 -1
- package/typings/esm5/drag-drop/drag-ref.d.ts +9 -0
- package/typings/esm5/drag-drop/drop-list-ref.d.ts +7 -1
- package/typings/esm5/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/index.metadata.json +1 -1
- package/typings/esm5/overlay/index.metadata.json +1 -1
- package/typings/esm5/overlay/position/flexible-connected-position-strategy.d.ts +5 -2
- package/typings/esm5/overlay/public-api.d.ts +1 -1
- package/typings/esm5/platform/features/shadow-dom.d.ts +9 -0
- package/typings/esm5/platform/index.metadata.json +1 -1
- package/typings/esm5/platform/public-api.d.ts +1 -0
- package/typings/esm5/scrolling/virtual-scroll-viewport.d.ts +1 -1
- package/typings/esm5/stepper/index.metadata.json +1 -1
- package/typings/esm5/stepper/stepper.d.ts +3 -3
- package/typings/esm5/table/table.d.ts +4 -4
- package/typings/esm5/testing/dispatch-events.d.ts +33 -0
- package/typings/esm5/testing/element-focus.d.ts +18 -0
- package/typings/esm5/testing/event-objects.d.ts +34 -0
- package/typings/esm5/testing/index.d.ts +4 -0
- package/typings/esm5/testing/index.metadata.json +1 -0
- package/typings/esm5/testing/public-api.d.ts +11 -0
- package/typings/esm5/testing/type-in-element.d.ts +41 -0
- package/typings/esm5/text-field/autosize.d.ts +1 -1
- package/typings/index.metadata.json +1 -1
- package/typings/overlay/index.metadata.json +1 -1
- package/typings/overlay/position/flexible-connected-position-strategy.d.ts +5 -2
- package/typings/overlay/public-api.d.ts +1 -1
- package/typings/platform/features/shadow-dom.d.ts +9 -0
- package/typings/platform/index.metadata.json +1 -1
- package/typings/platform/public-api.d.ts +1 -0
- package/typings/scrolling/virtual-scroll-viewport.d.ts +1 -1
- package/typings/stepper/index.metadata.json +1 -1
- package/typings/stepper/stepper.d.ts +3 -3
- package/typings/table/table.d.ts +4 -4
- package/typings/testing/dispatch-events.d.ts +33 -0
- package/typings/testing/element-focus.d.ts +18 -0
- package/typings/testing/event-objects.d.ts +34 -0
- package/typings/testing/index.d.ts +4 -0
- package/typings/testing/index.metadata.json +1 -0
- package/typings/testing/public-api.d.ts +11 -0
- package/typings/testing/type-in-element.d.ts +41 -0
- package/typings/text-field/autosize.d.ts +1 -1
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
(function (global, factory) {
|
|
9
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
10
|
+
typeof define === 'function' && define.amd ? define('@angular/cdk/testing', ['exports'], factory) :
|
|
11
|
+
(factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.testing = {})));
|
|
12
|
+
}(this, (function (exports) { 'use strict';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @fileoverview added by tsickle
|
|
16
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Creates a browser MouseEvent with the specified options.
|
|
20
|
+
* \@docs-private
|
|
21
|
+
* @param {?} type
|
|
22
|
+
* @param {?=} x
|
|
23
|
+
* @param {?=} y
|
|
24
|
+
* @param {?=} button
|
|
25
|
+
* @return {?}
|
|
26
|
+
*/
|
|
27
|
+
function createMouseEvent(type, x, y, button) {
|
|
28
|
+
if (x === void 0) { x = 0; }
|
|
29
|
+
if (y === void 0) { y = 0; }
|
|
30
|
+
if (button === void 0) { button = 0; }
|
|
31
|
+
/** @type {?} */
|
|
32
|
+
var event = document.createEvent('MouseEvent');
|
|
33
|
+
/** @type {?} */
|
|
34
|
+
var originalPreventDefault = event.preventDefault;
|
|
35
|
+
event.initMouseEvent(type, true, /* canBubble */ true, /* cancelable */ window, /* view */ 0, /* detail */ x, /* screenX */ y, /* screenY */ x, /* clientX */ y, /* clientY */ false, /* ctrlKey */ false, /* altKey */ false, /* shiftKey */ false, /* metaKey */ button, /* button */ null /* relatedTarget */);
|
|
36
|
+
// `initMouseEvent` doesn't allow us to pass the `buttons` and
|
|
37
|
+
// defaults it to 0 which looks like a fake event.
|
|
38
|
+
Object.defineProperty(event, 'buttons', { get: (/**
|
|
39
|
+
* @return {?}
|
|
40
|
+
*/
|
|
41
|
+
function () { return 1; }) });
|
|
42
|
+
// IE won't set `defaultPrevented` on synthetic events so we need to do it manually.
|
|
43
|
+
event.preventDefault = (/**
|
|
44
|
+
* @return {?}
|
|
45
|
+
*/
|
|
46
|
+
function () {
|
|
47
|
+
Object.defineProperty(event, 'defaultPrevented', { get: (/**
|
|
48
|
+
* @return {?}
|
|
49
|
+
*/
|
|
50
|
+
function () { return true; }) });
|
|
51
|
+
return originalPreventDefault.apply(this, arguments);
|
|
52
|
+
});
|
|
53
|
+
return event;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates a browser TouchEvent with the specified pointer coordinates.
|
|
57
|
+
* \@docs-private
|
|
58
|
+
* @param {?} type
|
|
59
|
+
* @param {?=} pageX
|
|
60
|
+
* @param {?=} pageY
|
|
61
|
+
* @return {?}
|
|
62
|
+
*/
|
|
63
|
+
function createTouchEvent(type, pageX, pageY) {
|
|
64
|
+
if (pageX === void 0) { pageX = 0; }
|
|
65
|
+
if (pageY === void 0) { pageY = 0; }
|
|
66
|
+
// In favor of creating events that work for most of the browsers, the event is created
|
|
67
|
+
// as a basic UI Event. The necessary details for the event will be set manually.
|
|
68
|
+
/** @type {?} */
|
|
69
|
+
var event = document.createEvent('UIEvent');
|
|
70
|
+
/** @type {?} */
|
|
71
|
+
var touchDetails = { pageX: pageX, pageY: pageY };
|
|
72
|
+
// TS3.6 removes the initUIEvent method and suggests porting to "new UIEvent()".
|
|
73
|
+
((/** @type {?} */ (event))).initUIEvent(type, true, true, window, 0);
|
|
74
|
+
// Most of the browsers don't have a "initTouchEvent" method that can be used to define
|
|
75
|
+
// the touch details.
|
|
76
|
+
Object.defineProperties(event, {
|
|
77
|
+
touches: { value: [touchDetails] },
|
|
78
|
+
targetTouches: { value: [touchDetails] },
|
|
79
|
+
changedTouches: { value: [touchDetails] }
|
|
80
|
+
});
|
|
81
|
+
return event;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Dispatches a keydown event from an element.
|
|
85
|
+
* \@docs-private
|
|
86
|
+
* @param {?} type
|
|
87
|
+
* @param {?=} keyCode
|
|
88
|
+
* @param {?=} key
|
|
89
|
+
* @param {?=} target
|
|
90
|
+
* @param {?=} modifiers
|
|
91
|
+
* @return {?}
|
|
92
|
+
*/
|
|
93
|
+
function createKeyboardEvent(type, keyCode, key, target, modifiers) {
|
|
94
|
+
if (keyCode === void 0) { keyCode = 0; }
|
|
95
|
+
if (key === void 0) { key = ''; }
|
|
96
|
+
if (modifiers === void 0) { modifiers = {}; }
|
|
97
|
+
/** @type {?} */
|
|
98
|
+
var event = (/** @type {?} */ (document.createEvent('KeyboardEvent')));
|
|
99
|
+
/** @type {?} */
|
|
100
|
+
var originalPreventDefault = event.preventDefault;
|
|
101
|
+
// Firefox does not support `initKeyboardEvent`, but supports `initKeyEvent`.
|
|
102
|
+
if (event.initKeyEvent) {
|
|
103
|
+
event.initKeyEvent(type, true, true, window, modifiers.control, modifiers.alt, modifiers.shift, modifiers.meta, keyCode);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// `initKeyboardEvent` expects to receive modifiers as a whitespace-delimited string
|
|
107
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent
|
|
108
|
+
/** @type {?} */
|
|
109
|
+
var modifiersStr = (modifiers.control ? 'Control ' : '' + modifiers.alt ? 'Alt ' : '' +
|
|
110
|
+
modifiers.shift ? 'Shift ' : '' + modifiers.meta ? 'Meta' : '').trim();
|
|
111
|
+
event.initKeyboardEvent(type, true, /* canBubble */ true, /* cancelable */ window, /* view */ 0, /* char */ key, /* key */ 0, /* location */ modifiersStr, /* modifiersList */ false /* repeat */);
|
|
112
|
+
}
|
|
113
|
+
// Webkit Browsers don't set the keyCode when calling the init function.
|
|
114
|
+
// See related bug https://bugs.webkit.org/show_bug.cgi?id=16735
|
|
115
|
+
Object.defineProperties(event, {
|
|
116
|
+
keyCode: { get: (/**
|
|
117
|
+
* @return {?}
|
|
118
|
+
*/
|
|
119
|
+
function () { return keyCode; }) },
|
|
120
|
+
key: { get: (/**
|
|
121
|
+
* @return {?}
|
|
122
|
+
*/
|
|
123
|
+
function () { return key; }) },
|
|
124
|
+
target: { get: (/**
|
|
125
|
+
* @return {?}
|
|
126
|
+
*/
|
|
127
|
+
function () { return target; }) },
|
|
128
|
+
ctrlKey: { get: (/**
|
|
129
|
+
* @return {?}
|
|
130
|
+
*/
|
|
131
|
+
function () { return !!modifiers.control; }) },
|
|
132
|
+
altKey: { get: (/**
|
|
133
|
+
* @return {?}
|
|
134
|
+
*/
|
|
135
|
+
function () { return !!modifiers.alt; }) },
|
|
136
|
+
shiftKey: { get: (/**
|
|
137
|
+
* @return {?}
|
|
138
|
+
*/
|
|
139
|
+
function () { return !!modifiers.shift; }) },
|
|
140
|
+
metaKey: { get: (/**
|
|
141
|
+
* @return {?}
|
|
142
|
+
*/
|
|
143
|
+
function () { return !!modifiers.meta; }) }
|
|
144
|
+
});
|
|
145
|
+
// IE won't set `defaultPrevented` on synthetic events so we need to do it manually.
|
|
146
|
+
event.preventDefault = (/**
|
|
147
|
+
* @return {?}
|
|
148
|
+
*/
|
|
149
|
+
function () {
|
|
150
|
+
Object.defineProperty(event, 'defaultPrevented', { get: (/**
|
|
151
|
+
* @return {?}
|
|
152
|
+
*/
|
|
153
|
+
function () { return true; }) });
|
|
154
|
+
return originalPreventDefault.apply(this, arguments);
|
|
155
|
+
});
|
|
156
|
+
return event;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Creates a fake event object with any desired event type.
|
|
160
|
+
* \@docs-private
|
|
161
|
+
* @param {?} type
|
|
162
|
+
* @param {?=} canBubble
|
|
163
|
+
* @param {?=} cancelable
|
|
164
|
+
* @return {?}
|
|
165
|
+
*/
|
|
166
|
+
function createFakeEvent(type, canBubble, cancelable) {
|
|
167
|
+
if (canBubble === void 0) { canBubble = false; }
|
|
168
|
+
if (cancelable === void 0) { cancelable = true; }
|
|
169
|
+
/** @type {?} */
|
|
170
|
+
var event = document.createEvent('Event');
|
|
171
|
+
event.initEvent(type, canBubble, cancelable);
|
|
172
|
+
return event;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @fileoverview added by tsickle
|
|
177
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
178
|
+
*/
|
|
179
|
+
/**
|
|
180
|
+
* Utility to dispatch any event on a Node.
|
|
181
|
+
* \@docs-private
|
|
182
|
+
* @param {?} node
|
|
183
|
+
* @param {?} event
|
|
184
|
+
* @return {?}
|
|
185
|
+
*/
|
|
186
|
+
function dispatchEvent(node, event) {
|
|
187
|
+
node.dispatchEvent(event);
|
|
188
|
+
return event;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Shorthand to dispatch a fake event on a specified node.
|
|
192
|
+
* \@docs-private
|
|
193
|
+
* @param {?} node
|
|
194
|
+
* @param {?} type
|
|
195
|
+
* @param {?=} canBubble
|
|
196
|
+
* @return {?}
|
|
197
|
+
*/
|
|
198
|
+
function dispatchFakeEvent(node, type, canBubble) {
|
|
199
|
+
return dispatchEvent(node, createFakeEvent(type, canBubble));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Shorthand to dispatch a keyboard event with a specified key code.
|
|
203
|
+
* \@docs-private
|
|
204
|
+
* @param {?} node
|
|
205
|
+
* @param {?} type
|
|
206
|
+
* @param {?=} keyCode
|
|
207
|
+
* @param {?=} key
|
|
208
|
+
* @param {?=} target
|
|
209
|
+
* @param {?=} modifiers
|
|
210
|
+
* @return {?}
|
|
211
|
+
*/
|
|
212
|
+
function dispatchKeyboardEvent(node, type, keyCode, key, target, modifiers) {
|
|
213
|
+
return (/** @type {?} */ (dispatchEvent(node, createKeyboardEvent(type, keyCode, key, target, modifiers))));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Shorthand to dispatch a mouse event on the specified coordinates.
|
|
217
|
+
* \@docs-private
|
|
218
|
+
* @param {?} node
|
|
219
|
+
* @param {?} type
|
|
220
|
+
* @param {?=} x
|
|
221
|
+
* @param {?=} y
|
|
222
|
+
* @param {?=} event
|
|
223
|
+
* @return {?}
|
|
224
|
+
*/
|
|
225
|
+
function dispatchMouseEvent(node, type, x, y, event) {
|
|
226
|
+
if (x === void 0) { x = 0; }
|
|
227
|
+
if (y === void 0) { y = 0; }
|
|
228
|
+
if (event === void 0) { event = createMouseEvent(type, x, y); }
|
|
229
|
+
return (/** @type {?} */ (dispatchEvent(node, event)));
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Shorthand to dispatch a touch event on the specified coordinates.
|
|
233
|
+
* \@docs-private
|
|
234
|
+
* @param {?} node
|
|
235
|
+
* @param {?} type
|
|
236
|
+
* @param {?=} x
|
|
237
|
+
* @param {?=} y
|
|
238
|
+
* @return {?}
|
|
239
|
+
*/
|
|
240
|
+
function dispatchTouchEvent(node, type, x, y) {
|
|
241
|
+
if (x === void 0) { x = 0; }
|
|
242
|
+
if (y === void 0) { y = 0; }
|
|
243
|
+
return dispatchEvent(node, createTouchEvent(type, x, y));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @fileoverview added by tsickle
|
|
248
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
249
|
+
*/
|
|
250
|
+
/**
|
|
251
|
+
* @param {?} element
|
|
252
|
+
* @param {?} event
|
|
253
|
+
* @return {?}
|
|
254
|
+
*/
|
|
255
|
+
function triggerFocusChange(element, event) {
|
|
256
|
+
/** @type {?} */
|
|
257
|
+
var eventFired = false;
|
|
258
|
+
/** @type {?} */
|
|
259
|
+
var handler = (/**
|
|
260
|
+
* @return {?}
|
|
261
|
+
*/
|
|
262
|
+
function () { return eventFired = true; });
|
|
263
|
+
element.addEventListener(event, handler);
|
|
264
|
+
element[event]();
|
|
265
|
+
element.removeEventListener(event, handler);
|
|
266
|
+
if (!eventFired) {
|
|
267
|
+
dispatchFakeEvent(element, event);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Patches an elements focus and blur methods to emit events consistently and predictably.
|
|
272
|
+
* This is necessary, because some browsers, like IE11, will call the focus handlers asynchronously,
|
|
273
|
+
* while others won't fire them at all if the browser window is not focused.
|
|
274
|
+
* \@docs-private
|
|
275
|
+
* @param {?} element
|
|
276
|
+
* @return {?}
|
|
277
|
+
*/
|
|
278
|
+
function patchElementFocus(element) {
|
|
279
|
+
element.focus = (/**
|
|
280
|
+
* @return {?}
|
|
281
|
+
*/
|
|
282
|
+
function () { return dispatchFakeEvent(element, 'focus'); });
|
|
283
|
+
element.blur = (/**
|
|
284
|
+
* @return {?}
|
|
285
|
+
*/
|
|
286
|
+
function () { return dispatchFakeEvent(element, 'blur'); });
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* \@docs-private
|
|
290
|
+
* @param {?} element
|
|
291
|
+
* @return {?}
|
|
292
|
+
*/
|
|
293
|
+
function triggerFocus(element) {
|
|
294
|
+
triggerFocusChange(element, 'focus');
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* \@docs-private
|
|
298
|
+
* @param {?} element
|
|
299
|
+
* @return {?}
|
|
300
|
+
*/
|
|
301
|
+
function triggerBlur(element) {
|
|
302
|
+
triggerFocusChange(element, 'blur');
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @fileoverview added by tsickle
|
|
307
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
308
|
+
*/
|
|
309
|
+
/**
|
|
310
|
+
* Checks whether the given Element is a text input element.
|
|
311
|
+
* \@docs-private
|
|
312
|
+
* @param {?} element
|
|
313
|
+
* @return {?}
|
|
314
|
+
*/
|
|
315
|
+
function isTextInput(element) {
|
|
316
|
+
return element.nodeName.toLowerCase() === 'input' ||
|
|
317
|
+
element.nodeName.toLowerCase() === 'textarea';
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* @param {?} element
|
|
321
|
+
* @param {...?} modifiersAndKeys
|
|
322
|
+
* @return {?}
|
|
323
|
+
*/
|
|
324
|
+
function typeInElement(element) {
|
|
325
|
+
var modifiersAndKeys = [];
|
|
326
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
327
|
+
modifiersAndKeys[_i - 1] = arguments[_i];
|
|
328
|
+
}
|
|
329
|
+
/** @type {?} */
|
|
330
|
+
var first = modifiersAndKeys[0];
|
|
331
|
+
/** @type {?} */
|
|
332
|
+
var modifiers;
|
|
333
|
+
/** @type {?} */
|
|
334
|
+
var rest;
|
|
335
|
+
if (typeof first !== 'string' && first.keyCode === undefined && first.key === undefined) {
|
|
336
|
+
modifiers = first;
|
|
337
|
+
rest = modifiersAndKeys.slice(1);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
modifiers = {};
|
|
341
|
+
rest = modifiersAndKeys;
|
|
342
|
+
}
|
|
343
|
+
/** @type {?} */
|
|
344
|
+
var keys = rest
|
|
345
|
+
.map((/**
|
|
346
|
+
* @param {?} k
|
|
347
|
+
* @return {?}
|
|
348
|
+
*/
|
|
349
|
+
function (k) { return typeof k === 'string' ?
|
|
350
|
+
k.split('').map((/**
|
|
351
|
+
* @param {?} c
|
|
352
|
+
* @return {?}
|
|
353
|
+
*/
|
|
354
|
+
function (c) { return ({ keyCode: c.toUpperCase().charCodeAt(0), key: c }); })) : [k]; }))
|
|
355
|
+
.reduce((/**
|
|
356
|
+
* @param {?} arr
|
|
357
|
+
* @param {?} k
|
|
358
|
+
* @return {?}
|
|
359
|
+
*/
|
|
360
|
+
function (arr, k) { return arr.concat(k); }), []);
|
|
361
|
+
triggerFocus(element);
|
|
362
|
+
for (var _a = 0, keys_1 = keys; _a < keys_1.length; _a++) {
|
|
363
|
+
var key = keys_1[_a];
|
|
364
|
+
dispatchKeyboardEvent(element, 'keydown', key.keyCode, key.key, element, modifiers);
|
|
365
|
+
dispatchKeyboardEvent(element, 'keypress', key.keyCode, key.key, element, modifiers);
|
|
366
|
+
if (isTextInput(element) && key.key && key.key.length === 1) {
|
|
367
|
+
element.value += key.key;
|
|
368
|
+
dispatchFakeEvent(element, 'input');
|
|
369
|
+
}
|
|
370
|
+
dispatchKeyboardEvent(element, 'keyup', key.keyCode, key.key, element, modifiers);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Clears the text in an input or textarea element.
|
|
375
|
+
* \@docs-private
|
|
376
|
+
* @param {?} element
|
|
377
|
+
* @return {?}
|
|
378
|
+
*/
|
|
379
|
+
function clearElement(element) {
|
|
380
|
+
triggerFocus((/** @type {?} */ (element)));
|
|
381
|
+
element.value = '';
|
|
382
|
+
dispatchFakeEvent(element, 'input');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
exports.dispatchEvent = dispatchEvent;
|
|
386
|
+
exports.dispatchFakeEvent = dispatchFakeEvent;
|
|
387
|
+
exports.dispatchKeyboardEvent = dispatchKeyboardEvent;
|
|
388
|
+
exports.dispatchMouseEvent = dispatchMouseEvent;
|
|
389
|
+
exports.dispatchTouchEvent = dispatchTouchEvent;
|
|
390
|
+
exports.createMouseEvent = createMouseEvent;
|
|
391
|
+
exports.createTouchEvent = createTouchEvent;
|
|
392
|
+
exports.createKeyboardEvent = createKeyboardEvent;
|
|
393
|
+
exports.createFakeEvent = createFakeEvent;
|
|
394
|
+
exports.isTextInput = isTextInput;
|
|
395
|
+
exports.typeInElement = typeInElement;
|
|
396
|
+
exports.clearElement = clearElement;
|
|
397
|
+
exports.patchElementFocus = patchElementFocus;
|
|
398
|
+
exports.triggerFocus = triggerFocus;
|
|
399
|
+
exports.triggerBlur = triggerBlur;
|
|
400
|
+
|
|
401
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
402
|
+
|
|
403
|
+
})));
|
|
404
|
+
//# sourceMappingURL=cdk-testing.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdk-testing.umd.js","sources":["../../src/cdk/testing/type-in-element.ts","../../src/cdk/testing/element-focus.ts","../../src/cdk/testing/dispatch-events.ts","../../src/cdk/testing/event-objects.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {dispatchFakeEvent, dispatchKeyboardEvent} from './dispatch-events';\nimport {triggerFocus} from './element-focus';\nimport {ModifierKeys} from './event-objects';\n\n/**\n * Checks whether the given Element is a text input element.\n * @docs-private\n */\nexport function isTextInput(element: Element): element is HTMLInputElement | HTMLTextAreaElement {\n return element.nodeName.toLowerCase() === 'input' ||\n element.nodeName.toLowerCase() === 'textarea' ;\n}\n\n/**\n * Focuses an input, sets its value and dispatches\n * the `input` event, simulating the user typing.\n * @param element Element onto which to set the value.\n * @param keys The keys to send to the element.\n * @docs-private\n */\nexport function typeInElement(\n element: HTMLElement, ...keys: (string | {keyCode?: number, key?: string})[]): void;\n\n/**\n * Focuses an input, sets its value and dispatches\n * the `input` event, simulating the user typing.\n * @param element Element onto which to set the value.\n * @param modifiers Modifier keys that are held while typing.\n * @param keys The keys to send to the element.\n * @docs-private\n */\nexport function typeInElement(element: HTMLElement, modifiers: ModifierKeys,\n ...keys: (string | {keyCode?: number, key?: string})[]): void;\n\nexport function typeInElement(element: HTMLElement, ...modifiersAndKeys: any) {\n const first = modifiersAndKeys[0];\n let modifiers: ModifierKeys;\n let rest: (string | {keyCode?: number, key?: string})[];\n if (typeof first !== 'string' && first.keyCode === undefined && first.key === undefined) {\n modifiers = first;\n rest = modifiersAndKeys.slice(1);\n } else {\n modifiers = {};\n rest = modifiersAndKeys;\n }\n const keys: {keyCode?: number, key?: string}[] = rest\n .map(k => typeof k === 'string' ?\n k.split('').map(c => ({keyCode: c.toUpperCase().charCodeAt(0), key: c})) : [k])\n .reduce((arr, k) => arr.concat(k), []);\n\n triggerFocus(element);\n for (const key of keys) {\n dispatchKeyboardEvent(element, 'keydown', key.keyCode, key.key, element, modifiers);\n dispatchKeyboardEvent(element, 'keypress', key.keyCode, key.key, element, modifiers);\n if (isTextInput(element) && key.key && key.key.length === 1) {\n element.value += key.key;\n dispatchFakeEvent(element, 'input');\n }\n dispatchKeyboardEvent(element, 'keyup', key.keyCode, key.key, element, modifiers);\n }\n}\n\n/**\n * Clears the text in an input or textarea element.\n * @docs-private\n */\nexport function clearElement(element: HTMLInputElement | HTMLTextAreaElement) {\n triggerFocus(element as HTMLElement);\n element.value = '';\n dispatchFakeEvent(element, 'input');\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {dispatchFakeEvent} from './dispatch-events';\n\nfunction triggerFocusChange(element: HTMLElement, event: 'focus' | 'blur') {\n let eventFired = false;\n const handler = () => eventFired = true;\n element.addEventListener(event, handler);\n element[event]();\n element.removeEventListener(event, handler);\n if (!eventFired) {\n dispatchFakeEvent(element, event);\n }\n}\n\n/**\n * Patches an elements focus and blur methods to emit events consistently and predictably.\n * This is necessary, because some browsers, like IE11, will call the focus handlers asynchronously,\n * while others won't fire them at all if the browser window is not focused.\n * @docs-private\n */\nexport function patchElementFocus(element: HTMLElement) {\n element.focus = () => dispatchFakeEvent(element, 'focus');\n element.blur = () => dispatchFakeEvent(element, 'blur');\n}\n\n/** @docs-private */\nexport function triggerFocus(element: HTMLElement) {\n triggerFocusChange(element, 'focus');\n}\n\n/** @docs-private */\nexport function triggerBlur(element: HTMLElement) {\n triggerFocusChange(element, 'blur');\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {\n createFakeEvent,\n createKeyboardEvent,\n createMouseEvent,\n createTouchEvent,\n ModifierKeys\n} from './event-objects';\n\n/**\n * Utility to dispatch any event on a Node.\n * @docs-private\n */\nexport function dispatchEvent(node: Node | Window, event: Event): Event {\n node.dispatchEvent(event);\n return event;\n}\n\n/**\n * Shorthand to dispatch a fake event on a specified node.\n * @docs-private\n */\nexport function dispatchFakeEvent(node: Node | Window, type: string, canBubble?: boolean): Event {\n return dispatchEvent(node, createFakeEvent(type, canBubble));\n}\n\n/**\n * Shorthand to dispatch a keyboard event with a specified key code.\n * @docs-private\n */\nexport function dispatchKeyboardEvent(node: Node, type: string, keyCode?: number, key?: string,\n target?: Element, modifiers?: ModifierKeys): KeyboardEvent {\n return dispatchEvent(node,\n createKeyboardEvent(type, keyCode, key, target, modifiers)) as KeyboardEvent;\n}\n\n/**\n * Shorthand to dispatch a mouse event on the specified coordinates.\n * @docs-private\n */\nexport function dispatchMouseEvent(node: Node, type: string, x = 0, y = 0,\n event = createMouseEvent(type, x, y)): MouseEvent {\n return dispatchEvent(node, event) as MouseEvent;\n}\n\n/**\n * Shorthand to dispatch a touch event on the specified coordinates.\n * @docs-private\n */\nexport function dispatchTouchEvent(node: Node, type: string, x = 0, y = 0) {\n return dispatchEvent(node, createTouchEvent(type, x, y));\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/** Modifier keys that may be held while typing. */\nexport interface ModifierKeys {\n control?: boolean;\n alt?: boolean;\n shift?: boolean;\n meta?: boolean;\n}\n\n/**\n * Creates a browser MouseEvent with the specified options.\n * @docs-private\n */\nexport function createMouseEvent(type: string, x = 0, y = 0, button = 0) {\n const event = document.createEvent('MouseEvent');\n const originalPreventDefault = event.preventDefault;\n\n event.initMouseEvent(type,\n true, /* canBubble */\n true, /* cancelable */\n window, /* view */\n 0, /* detail */\n x, /* screenX */\n y, /* screenY */\n x, /* clientX */\n y, /* clientY */\n false, /* ctrlKey */\n false, /* altKey */\n false, /* shiftKey */\n false, /* metaKey */\n button, /* button */\n null /* relatedTarget */);\n\n // `initMouseEvent` doesn't allow us to pass the `buttons` and\n // defaults it to 0 which looks like a fake event.\n Object.defineProperty(event, 'buttons', {get: () => 1});\n\n // IE won't set `defaultPrevented` on synthetic events so we need to do it manually.\n event.preventDefault = function() {\n Object.defineProperty(event, 'defaultPrevented', { get: () => true });\n return originalPreventDefault.apply(this, arguments);\n };\n\n return event;\n}\n\n/**\n * Creates a browser TouchEvent with the specified pointer coordinates.\n * @docs-private\n */\nexport function createTouchEvent(type: string, pageX = 0, pageY = 0) {\n // In favor of creating events that work for most of the browsers, the event is created\n // as a basic UI Event. The necessary details for the event will be set manually.\n const event = document.createEvent('UIEvent');\n const touchDetails = {pageX, pageY};\n\n // TS3.6 removes the initUIEvent method and suggests porting to \"new UIEvent()\".\n (event as any).initUIEvent(type, true, true, window, 0);\n\n // Most of the browsers don't have a \"initTouchEvent\" method that can be used to define\n // the touch details.\n Object.defineProperties(event, {\n touches: {value: [touchDetails]},\n targetTouches: {value: [touchDetails]},\n changedTouches: {value: [touchDetails]}\n });\n\n return event;\n}\n\n/**\n * Dispatches a keydown event from an element.\n * @docs-private\n */\nexport function createKeyboardEvent(type: string, keyCode: number = 0, key: string = '',\n target?: Element, modifiers: ModifierKeys = {}) {\n const event = document.createEvent('KeyboardEvent') as any;\n const originalPreventDefault = event.preventDefault;\n\n // Firefox does not support `initKeyboardEvent`, but supports `initKeyEvent`.\n if (event.initKeyEvent) {\n event.initKeyEvent(type, true, true, window, modifiers.control, modifiers.alt, modifiers.shift,\n modifiers.meta, keyCode);\n } else {\n // `initKeyboardEvent` expects to receive modifiers as a whitespace-delimited string\n // See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent\n const modifiersStr = (modifiers.control ? 'Control ' : '' + modifiers.alt ? 'Alt ' : '' +\n modifiers.shift ? 'Shift ' : '' + modifiers.meta ? 'Meta' : '').trim();\n event.initKeyboardEvent(type,\n true, /* canBubble */\n true, /* cancelable */\n window, /* view */\n 0, /* char */\n key, /* key */\n 0, /* location */\n modifiersStr, /* modifiersList */\n false /* repeat */);\n }\n\n // Webkit Browsers don't set the keyCode when calling the init function.\n // See related bug https://bugs.webkit.org/show_bug.cgi?id=16735\n Object.defineProperties(event, {\n keyCode: { get: () => keyCode },\n key: { get: () => key },\n target: { get: () => target },\n ctrlKey: { get: () => !!modifiers.control },\n altKey: { get: () => !!modifiers.alt },\n shiftKey: { get: () => !!modifiers.shift },\n metaKey: { get: () => !!modifiers.meta }\n });\n\n // IE won't set `defaultPrevented` on synthetic events so we need to do it manually.\n event.preventDefault = function() {\n Object.defineProperty(event, 'defaultPrevented', { get: () => true });\n return originalPreventDefault.apply(this, arguments);\n };\n\n return event;\n}\n\n/**\n * Creates a fake event object with any desired event type.\n * @docs-private\n */\nexport function createFakeEvent(type: string, canBubble = false, cancelable = true) {\n const event = document.createEvent('Event');\n event.initEvent(type, canBubble, cancelable);\n return event;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AGoBA,SAAgB,gBAAgB,CAAC,IAAY,EAAE,CAAK,EAAE,CAAK,EAAE,MAAU,EAAvE;IAA+C,IAA/C,CAAA,KAAA,KAAA,CAAA,EAA+C,EAAA,CAA/C,GAAA,CAAoD,CAApD,EAAA;IAAsD,IAAtD,CAAA,KAAA,KAAA,CAAA,EAAsD,EAAA,CAAtD,GAAA,CAA2D,CAA3D,EAAA;IAA6D,IAA7D,MAAA,KAAA,KAAA,CAAA,EAA6D,EAAA,MAA7D,GAAA,CAAuE,CAAvE,EAAA;;IACA,IAAQ,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,CAAlD;;IACA,I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,OAAO,EAAE,SAAS,CAAC,CAAC;KACnF;CACF;;;;;;;AAMD,SAAgB,YAAY,CAAC,OAA+C,EAA5E;IACE,YAAY,oBAAC,OAAO,GAAgB,CAAC;IACrC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC;IACnB,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;CACrC;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("@angular/cdk/testing",["exports"],t):t((e.ng=e.ng||{},e.ng.cdk=e.ng.cdk||{},e.ng.cdk.testing={}))}(this,function(e){"use strict";function t(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0);var o=document.createEvent("MouseEvent"),i=o.preventDefault;return o.initMouseEvent(e,!0,!0,window,0,t,n,t,n,!1,!1,!1,!1,r,null),Object.defineProperty(o,"buttons",{get:function(){return 1}}),o.preventDefault=function(){return Object.defineProperty(o,"defaultPrevented",{get:function(){return!0}}),i.apply(this,arguments)},o}function n(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=document.createEvent("UIEvent"),o={pageX:t,pageY:n};return r.initUIEvent(e,!0,!0,window,0),Object.defineProperties(r,{touches:{value:[o]},targetTouches:{value:[o]},changedTouches:{value:[o]}}),r}function r(e,t,n,r,o){void 0===t&&(t=0),void 0===n&&(n=""),void 0===o&&(o={});var i=document.createEvent("KeyboardEvent"),u=i.preventDefault;if(i.initKeyEvent)i.initKeyEvent(e,!0,!0,window,o.control,o.alt,o.shift,o.meta,t);else{var c=(o.control?"Control ":""+o.alt?"Alt ":""+o.shift?"Shift ":""+o.meta?"Meta":"").trim();i.initKeyboardEvent(e,!0,!0,window,0,n,0,c,!1)}return Object.defineProperties(i,{keyCode:{get:function(){return t}},key:{get:function(){return n}},target:{get:function(){return r}},ctrlKey:{get:function(){return!!o.control}},altKey:{get:function(){return!!o.alt}},shiftKey:{get:function(){return!!o.shift}},metaKey:{get:function(){return!!o.meta}}}),i.preventDefault=function(){return Object.defineProperty(i,"defaultPrevented",{get:function(){return!0}}),u.apply(this,arguments)},i}function o(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!0);var r=document.createEvent("Event");return r.initEvent(e,t,n),r}function i(e,t){return e.dispatchEvent(t),t}function u(e,t,n){return i(e,o(t,n))}function c(e,t,n,o,u,c){return i(e,r(t,n,o,u,c))}function a(e,n,r,o,u){return void 0===r&&(r=0),void 0===o&&(o=0),void 0===u&&(u=t(n,r,o)),i(e,u)}function d(e,t,r,o){return void 0===r&&(r=0),void 0===o&&(o=0),i(e,n(t,r,o))}function f(e,t){var n=!1,r=function(){return n=!0};e.addEventListener(t,r),e[t](),e.removeEventListener(t,r),n||u(e,t)}function v(e){e.focus=function(){return u(e,"focus")},e.blur=function(){return u(e,"blur")}}function s(e){f(e,"focus")}function l(e){f(e,"blur")}function p(e){return"input"===e.nodeName.toLowerCase()||"textarea"===e.nodeName.toLowerCase()}function y(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r,o,i=t[0];"string"!=typeof i&&void 0===i.keyCode&&void 0===i.key?(r=i,o=t.slice(1)):(r={},o=t);var a=o.map(function(e){return"string"==typeof e?e.split("").map(function(e){return{keyCode:e.toUpperCase().charCodeAt(0),key:e}}):[e]}).reduce(function(e,t){return e.concat(t)},[]);s(e);for(var d=0,f=a;d<f.length;d++){var v=f[d];c(e,"keydown",v.keyCode,v.key,e,r),c(e,"keypress",v.keyCode,v.key,e,r),p(e)&&v.key&&1===v.key.length&&(e.value+=v.key,u(e,"input")),c(e,"keyup",v.keyCode,v.key,e,r)}}function g(e){s(e),e.value="",u(e,"input")}e.dispatchEvent=i,e.dispatchFakeEvent=u,e.dispatchKeyboardEvent=c,e.dispatchMouseEvent=a,e.dispatchTouchEvent=d,e.createMouseEvent=t,e.createTouchEvent=n,e.createKeyboardEvent=r,e.createFakeEvent=o,e.isTextInput=p,e.typeInElement=y,e.clearElement=g,e.patchElementFocus=v,e.triggerFocus=s,e.triggerBlur=l,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
9
|
+
//# sourceMappingURL=cdk-testing.umd.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdk-testing.umd.min.js","sources":["../../src/cdk/testing/event-objects.ts","../../src/cdk/testing/dispatch-events.ts","../../src/cdk/testing/element-focus.ts","../../src/cdk/testing/type-in-element.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n/** Modifier keys that may be held while typing. */\nexport interface ModifierKeys {\n control?: boolean;\n alt?: boolean;\n shift?: boolean;\n meta?: boolean;\n}\n\n/**\n * Creates a browser MouseEvent with the specified options.\n * @docs-private\n */\nexport function createMouseEvent(type: string, x = 0, y = 0, button = 0) {\n const event = document.createEvent('MouseEvent');\n const originalPreventDefault = event.preventDefault;\n\n event.initMouseEvent(type,\n true, /* canBubble */\n true, /* cancelable */\n window, /* view */\n 0, /* detail */\n x, /* screenX */\n y, /* screenY */\n x, /* clientX */\n y, /* clientY */\n false, /* ctrlKey */\n false, /* altKey */\n false, /* shiftKey */\n false, /* metaKey */\n button, /* button */\n null /* relatedTarget */);\n\n // `initMouseEvent` doesn't allow us to pass the `buttons` and\n // defaults it to 0 which looks like a fake event.\n Object.defineProperty(event, 'buttons', {get: () => 1});\n\n // IE won't set `defaultPrevented` on synthetic events so we need to do it manually.\n event.preventDefault = function() {\n Object.defineProperty(event, 'defaultPrevented', { get: () => true });\n return originalPreventDefault.apply(this, arguments);\n };\n\n return event;\n}\n\n/**\n * Creates a browser TouchEvent with the specified pointer coordinates.\n * @docs-private\n */\nexport function createTouchEvent(type: string, pageX = 0, pageY = 0) {\n // In favor of creating events that work for most of the browsers, the event is created\n // as a basic UI Event. The necessary details for the event will be set manually.\n const event = document.createEvent('UIEvent');\n const touchDetails = {pageX, pageY};\n\n // TS3.6 removes the initUIEvent method and suggests porting to \"new UIEvent()\".\n (event as any).initUIEvent(type, true, true, window, 0);\n\n // Most of the browsers don't have a \"initTouchEvent\" method that can be used to define\n // the touch details.\n Object.defineProperties(event, {\n touches: {value: [touchDetails]},\n targetTouches: {value: [touchDetails]},\n changedTouches: {value: [touchDetails]}\n });\n\n return event;\n}\n\n/**\n * Dispatches a keydown event from an element.\n * @docs-private\n */\nexport function createKeyboardEvent(type: string, keyCode: number = 0, key: string = '',\n target?: Element, modifiers: ModifierKeys = {}) {\n const event = document.createEvent('KeyboardEvent') as any;\n const originalPreventDefault = event.preventDefault;\n\n // Firefox does not support `initKeyboardEvent`, but supports `initKeyEvent`.\n if (event.initKeyEvent) {\n event.initKeyEvent(type, true, true, window, modifiers.control, modifiers.alt, modifiers.shift,\n modifiers.meta, keyCode);\n } else {\n // `initKeyboardEvent` expects to receive modifiers as a whitespace-delimited string\n // See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyboardEvent\n const modifiersStr = (modifiers.control ? 'Control ' : '' + modifiers.alt ? 'Alt ' : '' +\n modifiers.shift ? 'Shift ' : '' + modifiers.meta ? 'Meta' : '').trim();\n event.initKeyboardEvent(type,\n true, /* canBubble */\n true, /* cancelable */\n window, /* view */\n 0, /* char */\n key, /* key */\n 0, /* location */\n modifiersStr, /* modifiersList */\n false /* repeat */);\n }\n\n // Webkit Browsers don't set the keyCode when calling the init function.\n // See related bug https://bugs.webkit.org/show_bug.cgi?id=16735\n Object.defineProperties(event, {\n keyCode: { get: () => keyCode },\n key: { get: () => key },\n target: { get: () => target },\n ctrlKey: { get: () => !!modifiers.control },\n altKey: { get: () => !!modifiers.alt },\n shiftKey: { get: () => !!modifiers.shift },\n metaKey: { get: () => !!modifiers.meta }\n });\n\n // IE won't set `defaultPrevented` on synthetic events so we need to do it manually.\n event.preventDefault = function() {\n Object.defineProperty(event, 'defaultPrevented', { get: () => true });\n return originalPreventDefault.apply(this, arguments);\n };\n\n return event;\n}\n\n/**\n * Creates a fake event object with any desired event type.\n * @docs-private\n */\nexport function createFakeEvent(type: string, canBubble = false, cancelable = true) {\n const event = document.createEvent('Event');\n event.initEvent(type, canBubble, cancelable);\n return event;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {\n createFakeEvent,\n createKeyboardEvent,\n createMouseEvent,\n createTouchEvent,\n ModifierKeys\n} from './event-objects';\n\n/**\n * Utility to dispatch any event on a Node.\n * @docs-private\n */\nexport function dispatchEvent(node: Node | Window, event: Event): Event {\n node.dispatchEvent(event);\n return event;\n}\n\n/**\n * Shorthand to dispatch a fake event on a specified node.\n * @docs-private\n */\nexport function dispatchFakeEvent(node: Node | Window, type: string, canBubble?: boolean): Event {\n return dispatchEvent(node, createFakeEvent(type, canBubble));\n}\n\n/**\n * Shorthand to dispatch a keyboard event with a specified key code.\n * @docs-private\n */\nexport function dispatchKeyboardEvent(node: Node, type: string, keyCode?: number, key?: string,\n target?: Element, modifiers?: ModifierKeys): KeyboardEvent {\n return dispatchEvent(node,\n createKeyboardEvent(type, keyCode, key, target, modifiers)) as KeyboardEvent;\n}\n\n/**\n * Shorthand to dispatch a mouse event on the specified coordinates.\n * @docs-private\n */\nexport function dispatchMouseEvent(node: Node, type: string, x = 0, y = 0,\n event = createMouseEvent(type, x, y)): MouseEvent {\n return dispatchEvent(node, event) as MouseEvent;\n}\n\n/**\n * Shorthand to dispatch a touch event on the specified coordinates.\n * @docs-private\n */\nexport function dispatchTouchEvent(node: Node, type: string, x = 0, y = 0) {\n return dispatchEvent(node, createTouchEvent(type, x, y));\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {dispatchFakeEvent} from './dispatch-events';\n\nfunction triggerFocusChange(element: HTMLElement, event: 'focus' | 'blur') {\n let eventFired = false;\n const handler = () => eventFired = true;\n element.addEventListener(event, handler);\n element[event]();\n element.removeEventListener(event, handler);\n if (!eventFired) {\n dispatchFakeEvent(element, event);\n }\n}\n\n/**\n * Patches an elements focus and blur methods to emit events consistently and predictably.\n * This is necessary, because some browsers, like IE11, will call the focus handlers asynchronously,\n * while others won't fire them at all if the browser window is not focused.\n * @docs-private\n */\nexport function patchElementFocus(element: HTMLElement) {\n element.focus = () => dispatchFakeEvent(element, 'focus');\n element.blur = () => dispatchFakeEvent(element, 'blur');\n}\n\n/** @docs-private */\nexport function triggerFocus(element: HTMLElement) {\n triggerFocusChange(element, 'focus');\n}\n\n/** @docs-private */\nexport function triggerBlur(element: HTMLElement) {\n triggerFocusChange(element, 'blur');\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {dispatchFakeEvent, dispatchKeyboardEvent} from './dispatch-events';\nimport {triggerFocus} from './element-focus';\nimport {ModifierKeys} from './event-objects';\n\n/**\n * Checks whether the given Element is a text input element.\n * @docs-private\n */\nexport function isTextInput(element: Element): element is HTMLInputElement | HTMLTextAreaElement {\n return element.nodeName.toLowerCase() === 'input' ||\n element.nodeName.toLowerCase() === 'textarea' ;\n}\n\n/**\n * Focuses an input, sets its value and dispatches\n * the `input` event, simulating the user typing.\n * @param element Element onto which to set the value.\n * @param keys The keys to send to the element.\n * @docs-private\n */\nexport function typeInElement(\n element: HTMLElement, ...keys: (string | {keyCode?: number, key?: string})[]): void;\n\n/**\n * Focuses an input, sets its value and dispatches\n * the `input` event, simulating the user typing.\n * @param element Element onto which to set the value.\n * @param modifiers Modifier keys that are held while typing.\n * @param keys The keys to send to the element.\n * @docs-private\n */\nexport function typeInElement(element: HTMLElement, modifiers: ModifierKeys,\n ...keys: (string | {keyCode?: number, key?: string})[]): void;\n\nexport function typeInElement(element: HTMLElement, ...modifiersAndKeys: any) {\n const first = modifiersAndKeys[0];\n let modifiers: ModifierKeys;\n let rest: (string | {keyCode?: number, key?: string})[];\n if (typeof first !== 'string' && first.keyCode === undefined && first.key === undefined) {\n modifiers = first;\n rest = modifiersAndKeys.slice(1);\n } else {\n modifiers = {};\n rest = modifiersAndKeys;\n }\n const keys: {keyCode?: number, key?: string}[] = rest\n .map(k => typeof k === 'string' ?\n k.split('').map(c => ({keyCode: c.toUpperCase().charCodeAt(0), key: c})) : [k])\n .reduce((arr, k) => arr.concat(k), []);\n\n triggerFocus(element);\n for (const key of keys) {\n dispatchKeyboardEvent(element, 'keydown', key.keyCode, key.key, element, modifiers);\n dispatchKeyboardEvent(element, 'keypress', key.keyCode, key.key, element, modifiers);\n if (isTextInput(element) && key.key && key.key.length === 1) {\n element.value += key.key;\n dispatchFakeEvent(element, 'input');\n }\n dispatchKeyboardEvent(element, 'keyup', key.keyCode, key.key, element, modifiers);\n }\n}\n\n/**\n * Clears the text in an input or textarea element.\n * @docs-private\n */\nexport function clearElement(element: HTMLInputElement | HTMLTextAreaElement) {\n triggerFocus(element as HTMLElement);\n element.value = '';\n dispatchFakeEvent(element, 'input');\n}\n"],"names":["createMouseEvent","type","x","y","button","event","document","createEvent","originalPreventDefault","preventDefault","initMouseEvent","window","Object","defineProperty","get","apply","this","arguments","createTouchEvent","pageX","pageY","touchDetails","initUIEvent","defineProperties","touches","value","targetTouches","changedTouches","createKeyboardEvent","keyCode","key","target","modifiers","initKeyEvent","control","alt","shift","meta","modifiersStr","trim","initKeyboardEvent","ctrlKey","altKey","shiftKey","metaKey","createFakeEvent","canBubble","cancelable","initEvent","dispatchEvent","node","dispatchFakeEvent","dispatchKeyboardEvent","dispatchMouseEvent","dispatchTouchEvent","triggerFocusChange","element","eventFired","handler","addEventListener","removeEventListener","patchElementFocus","focus","blur","triggerFocus","triggerBlur","isTextInput","nodeName","toLowerCase","typeInElement","modifiersAndKeys","_i","length","rest","first","undefined","slice","keys","map","k","split","c","toUpperCase","charCodeAt","reduce","arr","concat","_a","keys_1","clearElement"],"mappings":";;;;;;;6PAoBA,SAAgBA,GAAiBC,EAAcC,EAAOC,EAAOC,OAA7D,KAAAF,IAA+CA,EAA/C,OAAA,KAAAC,IAAsDA,EAAtD,OAAA,KAAAC,IAA6DA,EAA7D,EACA,IAAQC,GAAQC,SAASC,YAAY,cAC7BC,EAAyBH,EAAMI,cA4BrC,OA1BAJ,GAAMK,eAAeT,GACnB,GACA,EACAU,OACA,EACAT,EACAC,EACAD,EACAC,GACA,GACA,GACA,GACA,EACAC,EACA,MAIFQ,OAAOC,eAAeR,EAAO,WAAYS,IAAG,WAAQ,MAAA,MAGpDT,EAAMI,eAAc,WAElB,MADAG,QAAOC,eAAeR,EAAO,oBAAsBS,IAAG,WAAQ,OAAA,KACvDN,EAAuBO,MAAMC,KAAMC,YAGrCZ,EAOT,QAAgBa,GAAiBjB,EAAckB,EAAWC,OAA1D,KAAAD,IAA+CA,EAA/C,OAAA,KAAAC,IAA0DA,EAA1D,EAGA,IAAQf,GAAQC,SAASC,YAAY,WAC7Bc,GAAgBF,MAAxBA,EAA+BC,MAA/BA,EAaE,OAVA,GAAeE,YAAYrB,GAAM,GAAM,EAAMU,OAAQ,GAIrDC,OAAOW,iBAAiBlB,GACtBmB,SAAUC,OAAQJ,IAClBK,eAAgBD,OAAQJ,IACxBM,gBAAiBF,OAAQJ,MAGpBhB,EAOT,QAAgBuB,GAAoB3B,EAAc4B,EAAqBC,EACnCC,EAAkBC,OADtD,KAAAH,IAAkDA,EAAlD,OAAA,KAAAC,IAAuEA,EAAvE,QACA,KAAAE,IAAsDA,KACtD,IAAQ3B,GAAQC,SAASC,YAAY,iBAC7B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,EAC5CK,IAAG,SAACC,GAAK,MAAa,gBAANA,GACbA,EAAEC,MAAM,IAAIF,IAAG,SAACG,GAAK,OAAEpD,QAASoD,EAAEC,cAAcC,WAAW,GAAIrD,IAAKmD,MAAQF,KAC/EK,OAAM,SAAEC,EAAKN,GAAM,MAAAM,GAAIC,OAAOP,OAEnCf,GAAaR,EACb,KAAkB,GAApB+B,GAAA,EAAoBC,EAApBX,EAAoBU,EAApBC,EAAAhB,OAAoBe,IAAM,CAAnB,GAAMzD,GAAb0D,EAAAD,EACInC,GAAsBI,EAAS,UAAW1B,EAAID,QAASC,EAAIA,IAAK0B,EAASxB,GACzEoB,EAAsBI,EAAS,WAAY1B,EAAID,QAASC,EAAIA,IAAK0B,EAASxB,GACtEkC,EAAYV,IAAY1B,EAAIA,KAA0B,IAAnBA,EAAIA,IAAI0C,SAC7ChB,EAAQ/B,OAASK,EAAIA,IACrBqB,EAAkBK,EAAS,UAE7BJ,EAAsBI,EAAS,QAAS1B,EAAID,QAASC,EAAIA,IAAK0B,EAASxB,IAQ3E,QAAgByD,GAAajC,GAC3BQ,EAAY,GACZR,EAAQ/B,MAAQ,GAChB0B,EAAkBK,EAAS"}
|
|
@@ -491,14 +491,14 @@ var CdkTextareaAutosize = /** @class */ (function () {
|
|
|
491
491
|
this._previousMinRows = this._minRows;
|
|
492
492
|
};
|
|
493
493
|
/**
|
|
494
|
-
* Resets the textarea to
|
|
494
|
+
* Resets the textarea to its original size
|
|
495
495
|
*/
|
|
496
496
|
/**
|
|
497
|
-
* Resets the textarea to
|
|
497
|
+
* Resets the textarea to its original size
|
|
498
498
|
* @return {?}
|
|
499
499
|
*/
|
|
500
500
|
CdkTextareaAutosize.prototype.reset = /**
|
|
501
|
-
* Resets the textarea to
|
|
501
|
+
* Resets the textarea to its original size
|
|
502
502
|
* @return {?}
|
|
503
503
|
*/
|
|
504
504
|
function () {
|