pseudo-dom 0.6.0 → 0.7.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/README.md +432 -13
- package/browser/pseudo-dom.js +3364 -603
- package/browser/pseudo-dom.min.js +1 -1
- package/dist/classes/PseudoEventListener.d.ts +96 -96
- package/dist/classes/PseudoEventListener.js +151 -151
- package/dist/classes/PseudoHTMLDocument.d.ts +67 -67
- package/dist/classes/PseudoHTMLDocument.js +144 -144
- package/dist/classes/PseudoNodeList.d.ts +34 -34
- package/dist/classes/PseudoNodeList.js +71 -71
- package/dist/classes.d.ts +20 -20
- package/dist/classes.js +31 -31
- package/dist/factories/createEvent.d.ts +28 -28
- package/dist/factories/createEvent.js +56 -56
- package/dist/factories/cssSelectAdapter.d.ts +23 -0
- package/dist/factories/cssSelectAdapter.js +87 -0
- package/dist/factories/cssSelectAdapter.min.js +1 -0
- package/dist/factories/eventDefaults.d.ts +31 -31
- package/dist/factories/eventDefaults.js +105 -105
- package/dist/factories/generateDocument.d.ts +11 -11
- package/dist/factories/generateDocument.js +65 -65
- package/dist/factories/generateNode.d.ts +32 -32
- package/dist/factories/generateNode.js +85 -85
- package/dist/factories/generateNodeList.d.ts +9 -9
- package/dist/factories/generateNodeList.js +13 -13
- package/dist/factories/query.d.ts +33 -0
- package/dist/factories/query.js +66 -0
- package/dist/factories/query.min.js +1 -0
- package/dist/factories.d.ts +11 -11
- package/dist/factories.js +27 -27
- package/dist/functions/activeElement.d.ts +14 -14
- package/dist/functions/activeElement.js +33 -33
- package/dist/functions/getParentNodes.d.ts +11 -11
- package/dist/functions/getParentNodes.js +22 -22
- package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
- package/dist/functions/getParentNodesFromAttribute.js +29 -29
- package/dist/functions/modifierState.d.ts +29 -29
- package/dist/functions/modifierState.js +41 -41
- package/dist/functions.d.ts +5 -5
- package/dist/functions.js +23 -23
- package/dist/interfaces/PseudoAnimation.d.ts +3 -3
- package/dist/interfaces/PseudoAnimation.js +5 -5
- package/dist/interfaces/PseudoAttr.d.ts +11 -11
- package/dist/interfaces/PseudoAttr.js +5 -5
- package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
- package/dist/interfaces/PseudoDOMTokenList.js +5 -5
- package/dist/interfaces/PseudoDocument.d.ts +7 -0
- package/dist/interfaces/PseudoDocument.js +5 -5
- package/dist/interfaces/PseudoDocumentFragment.d.ts +3 -3
- package/dist/interfaces/PseudoDocumentFragment.js +5 -5
- package/dist/interfaces/PseudoElement.d.ts +20 -7
- package/dist/interfaces/PseudoElement.js +5 -5
- package/dist/interfaces/PseudoEvent.d.ts +79 -79
- package/dist/interfaces/PseudoEvent.js +10 -10
- package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
- package/dist/interfaces/PseudoEventTarget.js +5 -5
- package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
- package/dist/interfaces/PseudoHTMLCollection.js +5 -5
- package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
- package/dist/interfaces/PseudoHTMLElement.js +5 -5
- package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
- package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
- package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
- package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
- package/dist/interfaces/PseudoNode.d.ts +179 -179
- package/dist/interfaces/PseudoNode.js +5 -5
- package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
- package/dist/interfaces/PseudoShadowRoot.js +5 -5
- package/dist/main.d.ts +63 -63
- package/dist/main.js +155 -155
- package/dist/services/AnimationService.d.ts +4 -4
- package/dist/services/AnimationService.js +16 -16
- package/dist/services/AttrService.d.ts +37 -37
- package/dist/services/AttrService.js +81 -81
- package/dist/services/CommentService.d.ts +1 -1
- package/dist/services/CommentService.js +13 -13
- package/dist/services/CustomEventService.d.ts +37 -37
- package/dist/services/CustomEventService.js +35 -35
- package/dist/services/DOMTokenListService.d.ts +33 -33
- package/dist/services/DOMTokenListService.js +117 -117
- package/dist/services/DocumentFragmentService.d.ts +13 -13
- package/dist/services/DocumentFragmentService.js +24 -24
- package/dist/services/DocumentService.d.ts +7 -0
- package/dist/services/DocumentService.js +23 -0
- package/dist/services/DocumentService.min.js +1 -1
- package/dist/services/ElementService.d.ts +13 -0
- package/dist/services/ElementService.js +20 -0
- package/dist/services/ElementService.min.js +1 -1
- package/dist/services/EventService.d.ts +120 -120
- package/dist/services/EventService.js +250 -250
- package/dist/services/EventTargetService.d.ts +84 -84
- package/dist/services/EventTargetService.js +232 -232
- package/dist/services/FocusEventService.d.ts +32 -32
- package/dist/services/FocusEventService.js +35 -35
- package/dist/services/HTMLCollectionService.d.ts +11 -6
- package/dist/services/HTMLCollectionService.js +25 -8
- package/dist/services/HTMLCollectionService.min.js +1 -1
- package/dist/services/HTMLElementService.d.ts +57 -57
- package/dist/services/HTMLElementService.js +163 -163
- package/dist/services/HTMLSlotElementService.d.ts +4 -4
- package/dist/services/HTMLSlotElementService.js +9 -9
- package/dist/services/InputEventService.d.ts +41 -41
- package/dist/services/InputEventService.js +47 -47
- package/dist/services/KeyboardEventService.d.ts +70 -70
- package/dist/services/KeyboardEventService.js +86 -86
- package/dist/services/MouseEventService.d.ts +80 -80
- package/dist/services/MouseEventService.js +108 -108
- package/dist/services/NamedNodeMapService.d.ts +23 -23
- package/dist/services/NamedNodeMapService.js +77 -77
- package/dist/services/NodeService.d.ts +26 -0
- package/dist/services/NodeService.js +42 -0
- package/dist/services/NodeService.min.js +1 -1
- package/dist/services/PointerEventService.d.ts +51 -51
- package/dist/services/PointerEventService.js +67 -67
- package/dist/services/ShadowRootService.d.ts +4 -4
- package/dist/services/ShadowRootService.js +9 -9
- package/dist/services/TextService.d.ts +1 -1
- package/dist/services/TextService.js +13 -13
- package/dist/services/UIEventService.d.ts +43 -43
- package/dist/services/UIEventService.js +42 -42
- package/dist/simulate.d.ts +32 -32
- package/dist/simulate.js +115 -115
- package/package.json +3 -2
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.InputEventService = void 0
|
|
7
|
-
/**
|
|
8
|
-
* @file Substitute for the DOM InputEvent Class.
|
|
9
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
-
* @version 1.0.0
|
|
11
|
-
*/
|
|
12
|
-
const UIEventService_1 = require('./UIEventService')
|
|
13
|
-
/**
|
|
14
|
-
* Simulate the behaviour of the InputEvent Class when there is no DOM available.
|
|
15
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
16
|
-
* @class
|
|
17
|
-
* @augments UIEventService
|
|
18
|
-
* @property {string|null} data
|
|
19
|
-
* @property {string} inputType
|
|
20
|
-
* @property {boolean} isComposing
|
|
21
|
-
*/
|
|
22
|
-
class InputEventService extends UIEventService_1.UIEventService {
|
|
23
|
-
/**
|
|
24
|
-
* @param {string} [typeArg=''] The type of the event
|
|
25
|
-
* @param {InputEventInit} [init={}] The options for the event
|
|
26
|
-
* @constructor
|
|
27
|
-
*/
|
|
28
|
-
constructor (typeArg = '', init = {}) {
|
|
29
|
-
super(typeArg, init)
|
|
30
|
-
this.inputData = typeof init.data === 'string' ? init.data : null
|
|
31
|
-
this.kind = init.inputType || ''
|
|
32
|
-
this.composing = !!init.isComposing
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get data () {
|
|
36
|
-
return this.inputData
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get inputType () {
|
|
40
|
-
return this.kind
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
get isComposing () {
|
|
44
|
-
return this.composing
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.InputEventService = InputEventService
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.InputEventService = void 0
|
|
7
|
+
/**
|
|
8
|
+
* @file Substitute for the DOM InputEvent Class.
|
|
9
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
const UIEventService_1 = require('./UIEventService')
|
|
13
|
+
/**
|
|
14
|
+
* Simulate the behaviour of the InputEvent Class when there is no DOM available.
|
|
15
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
16
|
+
* @class
|
|
17
|
+
* @augments UIEventService
|
|
18
|
+
* @property {string|null} data
|
|
19
|
+
* @property {string} inputType
|
|
20
|
+
* @property {boolean} isComposing
|
|
21
|
+
*/
|
|
22
|
+
class InputEventService extends UIEventService_1.UIEventService {
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} [typeArg=''] The type of the event
|
|
25
|
+
* @param {InputEventInit} [init={}] The options for the event
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
constructor (typeArg = '', init = {}) {
|
|
29
|
+
super(typeArg, init)
|
|
30
|
+
this.inputData = typeof init.data === 'string' ? init.data : null
|
|
31
|
+
this.kind = init.inputType || ''
|
|
32
|
+
this.composing = !!init.isComposing
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get data () {
|
|
36
|
+
return this.inputData
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get inputType () {
|
|
40
|
+
return this.kind
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get isComposing () {
|
|
44
|
+
return this.composing
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.InputEventService = InputEventService
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Substitute for the DOM KeyboardEvent Class.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
5
|
-
*/
|
|
6
|
-
import { UIEventInit, UIEventService } from './UIEventService';
|
|
7
|
-
/**
|
|
8
|
-
* The options for creating a keyboard event, on top of the ones every UI event has.
|
|
9
|
-
* @typedef {Object} KeyboardEventInit
|
|
10
|
-
* @property {string} [key=''] The value of the key, such as a or Enter
|
|
11
|
-
* @property {string} [code=''] The physical key, such as KeyA or Enter
|
|
12
|
-
* @property {number} [location=0] Where on the keyboard the key is (0 standard, 1 left, 2 right, 3 numeric pad)
|
|
13
|
-
* @property {boolean} [repeat=false] The key is being held down
|
|
14
|
-
* @property {boolean} [isComposing=false]
|
|
15
|
-
* @property {boolean} [ctrlKey=false]
|
|
16
|
-
* @property {boolean} [shiftKey=false]
|
|
17
|
-
* @property {boolean} [altKey=false]
|
|
18
|
-
* @property {boolean} [metaKey=false]
|
|
19
|
-
*/
|
|
20
|
-
export type KeyboardEventInit = UIEventInit & {
|
|
21
|
-
key?: string;
|
|
22
|
-
code?: string;
|
|
23
|
-
location?: number;
|
|
24
|
-
repeat?: boolean;
|
|
25
|
-
isComposing?: boolean;
|
|
26
|
-
ctrlKey?: boolean;
|
|
27
|
-
shiftKey?: boolean;
|
|
28
|
-
altKey?: boolean;
|
|
29
|
-
metaKey?: boolean;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Simulate the behaviour of the KeyboardEvent Class when there is no DOM available.
|
|
33
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
34
|
-
* @class
|
|
35
|
-
* @augments UIEventService
|
|
36
|
-
* @property {string} key
|
|
37
|
-
* @property {string} code
|
|
38
|
-
* @property {number} location
|
|
39
|
-
* @property {boolean} repeat
|
|
40
|
-
* @property {boolean} isComposing
|
|
41
|
-
*/
|
|
42
|
-
export declare class KeyboardEventService extends UIEventService {
|
|
43
|
-
private readonly keyValue;
|
|
44
|
-
private readonly keyCode;
|
|
45
|
-
private readonly keyLocation;
|
|
46
|
-
private readonly held;
|
|
47
|
-
private readonly composing;
|
|
48
|
-
private readonly modifiers;
|
|
49
|
-
/**
|
|
50
|
-
* @param {string} [typeArg=''] The type of the event
|
|
51
|
-
* @param {KeyboardEventInit} [init={}] The options for the event
|
|
52
|
-
* @constructor
|
|
53
|
-
*/
|
|
54
|
-
constructor(typeArg?: string, init?: KeyboardEventInit);
|
|
55
|
-
get key(): string;
|
|
56
|
-
get code(): string;
|
|
57
|
-
get location(): number;
|
|
58
|
-
get repeat(): boolean;
|
|
59
|
-
get isComposing(): boolean;
|
|
60
|
-
get ctrlKey(): boolean;
|
|
61
|
-
get shiftKey(): boolean;
|
|
62
|
-
get altKey(): boolean;
|
|
63
|
-
get metaKey(): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Whether a modifier key was held down when the event happened.
|
|
66
|
-
* @param {string} key Control, Shift, Alt or Meta
|
|
67
|
-
* @returns {boolean}
|
|
68
|
-
*/
|
|
69
|
-
getModifierState(key: string): boolean;
|
|
70
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the DOM KeyboardEvent Class.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { UIEventInit, UIEventService } from './UIEventService';
|
|
7
|
+
/**
|
|
8
|
+
* The options for creating a keyboard event, on top of the ones every UI event has.
|
|
9
|
+
* @typedef {Object} KeyboardEventInit
|
|
10
|
+
* @property {string} [key=''] The value of the key, such as a or Enter
|
|
11
|
+
* @property {string} [code=''] The physical key, such as KeyA or Enter
|
|
12
|
+
* @property {number} [location=0] Where on the keyboard the key is (0 standard, 1 left, 2 right, 3 numeric pad)
|
|
13
|
+
* @property {boolean} [repeat=false] The key is being held down
|
|
14
|
+
* @property {boolean} [isComposing=false]
|
|
15
|
+
* @property {boolean} [ctrlKey=false]
|
|
16
|
+
* @property {boolean} [shiftKey=false]
|
|
17
|
+
* @property {boolean} [altKey=false]
|
|
18
|
+
* @property {boolean} [metaKey=false]
|
|
19
|
+
*/
|
|
20
|
+
export type KeyboardEventInit = UIEventInit & {
|
|
21
|
+
key?: string;
|
|
22
|
+
code?: string;
|
|
23
|
+
location?: number;
|
|
24
|
+
repeat?: boolean;
|
|
25
|
+
isComposing?: boolean;
|
|
26
|
+
ctrlKey?: boolean;
|
|
27
|
+
shiftKey?: boolean;
|
|
28
|
+
altKey?: boolean;
|
|
29
|
+
metaKey?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Simulate the behaviour of the KeyboardEvent Class when there is no DOM available.
|
|
33
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
34
|
+
* @class
|
|
35
|
+
* @augments UIEventService
|
|
36
|
+
* @property {string} key
|
|
37
|
+
* @property {string} code
|
|
38
|
+
* @property {number} location
|
|
39
|
+
* @property {boolean} repeat
|
|
40
|
+
* @property {boolean} isComposing
|
|
41
|
+
*/
|
|
42
|
+
export declare class KeyboardEventService extends UIEventService {
|
|
43
|
+
private readonly keyValue;
|
|
44
|
+
private readonly keyCode;
|
|
45
|
+
private readonly keyLocation;
|
|
46
|
+
private readonly held;
|
|
47
|
+
private readonly composing;
|
|
48
|
+
private readonly modifiers;
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} [typeArg=''] The type of the event
|
|
51
|
+
* @param {KeyboardEventInit} [init={}] The options for the event
|
|
52
|
+
* @constructor
|
|
53
|
+
*/
|
|
54
|
+
constructor(typeArg?: string, init?: KeyboardEventInit);
|
|
55
|
+
get key(): string;
|
|
56
|
+
get code(): string;
|
|
57
|
+
get location(): number;
|
|
58
|
+
get repeat(): boolean;
|
|
59
|
+
get isComposing(): boolean;
|
|
60
|
+
get ctrlKey(): boolean;
|
|
61
|
+
get shiftKey(): boolean;
|
|
62
|
+
get altKey(): boolean;
|
|
63
|
+
get metaKey(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether a modifier key was held down when the event happened.
|
|
66
|
+
* @param {string} key Control, Shift, Alt or Meta
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
getModifierState(key: string): boolean;
|
|
70
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.KeyboardEventService = void 0
|
|
7
|
-
/**
|
|
8
|
-
* @file Substitute for the DOM KeyboardEvent Class.
|
|
9
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
-
* @version 1.0.0
|
|
11
|
-
*/
|
|
12
|
-
const UIEventService_1 = require('./UIEventService')
|
|
13
|
-
const modifierState_1 = require('../functions/modifierState')
|
|
14
|
-
/**
|
|
15
|
-
* Simulate the behaviour of the KeyboardEvent Class when there is no DOM available.
|
|
16
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
17
|
-
* @class
|
|
18
|
-
* @augments UIEventService
|
|
19
|
-
* @property {string} key
|
|
20
|
-
* @property {string} code
|
|
21
|
-
* @property {number} location
|
|
22
|
-
* @property {boolean} repeat
|
|
23
|
-
* @property {boolean} isComposing
|
|
24
|
-
*/
|
|
25
|
-
class KeyboardEventService extends UIEventService_1.UIEventService {
|
|
26
|
-
/**
|
|
27
|
-
* @param {string} [typeArg=''] The type of the event
|
|
28
|
-
* @param {KeyboardEventInit} [init={}] The options for the event
|
|
29
|
-
* @constructor
|
|
30
|
-
*/
|
|
31
|
-
constructor (typeArg = '', init = {}) {
|
|
32
|
-
super(typeArg, init)
|
|
33
|
-
this.keyValue = init.key || ''
|
|
34
|
-
this.keyCode = init.code || ''
|
|
35
|
-
this.keyLocation = init.location || 0
|
|
36
|
-
this.held = !!init.repeat
|
|
37
|
-
this.composing = !!init.isComposing
|
|
38
|
-
this.modifiers = (0, modifierState_1.modifierKeys)(init)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get key () {
|
|
42
|
-
return this.keyValue
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get code () {
|
|
46
|
-
return this.keyCode
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get location () {
|
|
50
|
-
return this.keyLocation
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
get repeat () {
|
|
54
|
-
return this.held
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get isComposing () {
|
|
58
|
-
return this.composing
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get ctrlKey () {
|
|
62
|
-
return this.modifiers.ctrlKey
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get shiftKey () {
|
|
66
|
-
return this.modifiers.shiftKey
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get altKey () {
|
|
70
|
-
return this.modifiers.altKey
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get metaKey () {
|
|
74
|
-
return this.modifiers.metaKey
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Whether a modifier key was held down when the event happened.
|
|
79
|
-
* @param {string} key Control, Shift, Alt or Meta
|
|
80
|
-
* @returns {boolean}
|
|
81
|
-
*/
|
|
82
|
-
getModifierState (key) {
|
|
83
|
-
return (0, modifierState_1.modifierState)(this.modifiers, key)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.KeyboardEventService = KeyboardEventService
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.KeyboardEventService = void 0
|
|
7
|
+
/**
|
|
8
|
+
* @file Substitute for the DOM KeyboardEvent Class.
|
|
9
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
const UIEventService_1 = require('./UIEventService')
|
|
13
|
+
const modifierState_1 = require('../functions/modifierState')
|
|
14
|
+
/**
|
|
15
|
+
* Simulate the behaviour of the KeyboardEvent Class when there is no DOM available.
|
|
16
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
17
|
+
* @class
|
|
18
|
+
* @augments UIEventService
|
|
19
|
+
* @property {string} key
|
|
20
|
+
* @property {string} code
|
|
21
|
+
* @property {number} location
|
|
22
|
+
* @property {boolean} repeat
|
|
23
|
+
* @property {boolean} isComposing
|
|
24
|
+
*/
|
|
25
|
+
class KeyboardEventService extends UIEventService_1.UIEventService {
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} [typeArg=''] The type of the event
|
|
28
|
+
* @param {KeyboardEventInit} [init={}] The options for the event
|
|
29
|
+
* @constructor
|
|
30
|
+
*/
|
|
31
|
+
constructor (typeArg = '', init = {}) {
|
|
32
|
+
super(typeArg, init)
|
|
33
|
+
this.keyValue = init.key || ''
|
|
34
|
+
this.keyCode = init.code || ''
|
|
35
|
+
this.keyLocation = init.location || 0
|
|
36
|
+
this.held = !!init.repeat
|
|
37
|
+
this.composing = !!init.isComposing
|
|
38
|
+
this.modifiers = (0, modifierState_1.modifierKeys)(init)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get key () {
|
|
42
|
+
return this.keyValue
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get code () {
|
|
46
|
+
return this.keyCode
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get location () {
|
|
50
|
+
return this.keyLocation
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get repeat () {
|
|
54
|
+
return this.held
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get isComposing () {
|
|
58
|
+
return this.composing
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get ctrlKey () {
|
|
62
|
+
return this.modifiers.ctrlKey
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get shiftKey () {
|
|
66
|
+
return this.modifiers.shiftKey
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get altKey () {
|
|
70
|
+
return this.modifiers.altKey
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get metaKey () {
|
|
74
|
+
return this.modifiers.metaKey
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Whether a modifier key was held down when the event happened.
|
|
79
|
+
* @param {string} key Control, Shift, Alt or Meta
|
|
80
|
+
* @returns {boolean}
|
|
81
|
+
*/
|
|
82
|
+
getModifierState (key) {
|
|
83
|
+
return (0, modifierState_1.modifierState)(this.modifiers, key)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.KeyboardEventService = KeyboardEventService
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Substitute for the DOM MouseEvent Class.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.0.0
|
|
5
|
-
*/
|
|
6
|
-
import { UIEventInit, UIEventService } from './UIEventService';
|
|
7
|
-
import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
8
|
-
/**
|
|
9
|
-
* The options for creating a mouse event, on top of the ones every UI event has.
|
|
10
|
-
* @typedef {Object} MouseEventInit
|
|
11
|
-
* @property {number} [screenX=0]
|
|
12
|
-
* @property {number} [screenY=0]
|
|
13
|
-
* @property {number} [clientX=0]
|
|
14
|
-
* @property {number} [clientY=0]
|
|
15
|
-
* @property {boolean} [ctrlKey=false]
|
|
16
|
-
* @property {boolean} [shiftKey=false]
|
|
17
|
-
* @property {boolean} [altKey=false]
|
|
18
|
-
* @property {boolean} [metaKey=false]
|
|
19
|
-
* @property {number} [button=0] The button which changed (0 is the main button)
|
|
20
|
-
* @property {number} [buttons=0] The buttons which are down
|
|
21
|
-
* @property {PseudoEventTarget|null} [relatedTarget=null] The other target involved (the one the mouse came from or went to)
|
|
22
|
-
*/
|
|
23
|
-
export type MouseEventInit = UIEventInit & {
|
|
24
|
-
screenX?: number;
|
|
25
|
-
screenY?: number;
|
|
26
|
-
clientX?: number;
|
|
27
|
-
clientY?: number;
|
|
28
|
-
ctrlKey?: boolean;
|
|
29
|
-
shiftKey?: boolean;
|
|
30
|
-
altKey?: boolean;
|
|
31
|
-
metaKey?: boolean;
|
|
32
|
-
button?: number;
|
|
33
|
-
buttons?: number;
|
|
34
|
-
relatedTarget?: PseudoEventTarget | null;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Simulate the behaviour of the MouseEvent Class when there is no DOM available.
|
|
38
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
39
|
-
* @class
|
|
40
|
-
* @augments UIEventService
|
|
41
|
-
* @property {number} screenX
|
|
42
|
-
* @property {number} screenY
|
|
43
|
-
* @property {number} clientX
|
|
44
|
-
* @property {number} clientY
|
|
45
|
-
* @property {number} button
|
|
46
|
-
* @property {number} buttons
|
|
47
|
-
* @property {PseudoEventTarget|null} relatedTarget
|
|
48
|
-
*/
|
|
49
|
-
export declare class MouseEventService extends UIEventService {
|
|
50
|
-
private readonly position;
|
|
51
|
-
private readonly modifiers;
|
|
52
|
-
private readonly buttonPressed;
|
|
53
|
-
private readonly buttonsDown;
|
|
54
|
-
private readonly related;
|
|
55
|
-
/**
|
|
56
|
-
* @param {string} [typeArg=''] The type of the event
|
|
57
|
-
* @param {MouseEventInit} [init={}] The options for the event
|
|
58
|
-
* @constructor
|
|
59
|
-
*/
|
|
60
|
-
constructor(typeArg?: string, init?: MouseEventInit);
|
|
61
|
-
get screenX(): number;
|
|
62
|
-
get screenY(): number;
|
|
63
|
-
get clientX(): number;
|
|
64
|
-
get clientY(): number;
|
|
65
|
-
get x(): number;
|
|
66
|
-
get y(): number;
|
|
67
|
-
get ctrlKey(): boolean;
|
|
68
|
-
get shiftKey(): boolean;
|
|
69
|
-
get altKey(): boolean;
|
|
70
|
-
get metaKey(): boolean;
|
|
71
|
-
get button(): number;
|
|
72
|
-
get buttons(): number;
|
|
73
|
-
get relatedTarget(): PseudoEventTarget | null;
|
|
74
|
-
/**
|
|
75
|
-
* Whether a modifier key was held down when the event happened.
|
|
76
|
-
* @param {string} key Control, Shift, Alt or Meta
|
|
77
|
-
* @returns {boolean}
|
|
78
|
-
*/
|
|
79
|
-
getModifierState(key: string): boolean;
|
|
80
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file Substitute for the DOM MouseEvent Class.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { UIEventInit, UIEventService } from './UIEventService';
|
|
7
|
+
import { PseudoEventTarget } from '../interfaces/PseudoEventTarget';
|
|
8
|
+
/**
|
|
9
|
+
* The options for creating a mouse event, on top of the ones every UI event has.
|
|
10
|
+
* @typedef {Object} MouseEventInit
|
|
11
|
+
* @property {number} [screenX=0]
|
|
12
|
+
* @property {number} [screenY=0]
|
|
13
|
+
* @property {number} [clientX=0]
|
|
14
|
+
* @property {number} [clientY=0]
|
|
15
|
+
* @property {boolean} [ctrlKey=false]
|
|
16
|
+
* @property {boolean} [shiftKey=false]
|
|
17
|
+
* @property {boolean} [altKey=false]
|
|
18
|
+
* @property {boolean} [metaKey=false]
|
|
19
|
+
* @property {number} [button=0] The button which changed (0 is the main button)
|
|
20
|
+
* @property {number} [buttons=0] The buttons which are down
|
|
21
|
+
* @property {PseudoEventTarget|null} [relatedTarget=null] The other target involved (the one the mouse came from or went to)
|
|
22
|
+
*/
|
|
23
|
+
export type MouseEventInit = UIEventInit & {
|
|
24
|
+
screenX?: number;
|
|
25
|
+
screenY?: number;
|
|
26
|
+
clientX?: number;
|
|
27
|
+
clientY?: number;
|
|
28
|
+
ctrlKey?: boolean;
|
|
29
|
+
shiftKey?: boolean;
|
|
30
|
+
altKey?: boolean;
|
|
31
|
+
metaKey?: boolean;
|
|
32
|
+
button?: number;
|
|
33
|
+
buttons?: number;
|
|
34
|
+
relatedTarget?: PseudoEventTarget | null;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Simulate the behaviour of the MouseEvent Class when there is no DOM available.
|
|
38
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
39
|
+
* @class
|
|
40
|
+
* @augments UIEventService
|
|
41
|
+
* @property {number} screenX
|
|
42
|
+
* @property {number} screenY
|
|
43
|
+
* @property {number} clientX
|
|
44
|
+
* @property {number} clientY
|
|
45
|
+
* @property {number} button
|
|
46
|
+
* @property {number} buttons
|
|
47
|
+
* @property {PseudoEventTarget|null} relatedTarget
|
|
48
|
+
*/
|
|
49
|
+
export declare class MouseEventService extends UIEventService {
|
|
50
|
+
private readonly position;
|
|
51
|
+
private readonly modifiers;
|
|
52
|
+
private readonly buttonPressed;
|
|
53
|
+
private readonly buttonsDown;
|
|
54
|
+
private readonly related;
|
|
55
|
+
/**
|
|
56
|
+
* @param {string} [typeArg=''] The type of the event
|
|
57
|
+
* @param {MouseEventInit} [init={}] The options for the event
|
|
58
|
+
* @constructor
|
|
59
|
+
*/
|
|
60
|
+
constructor(typeArg?: string, init?: MouseEventInit);
|
|
61
|
+
get screenX(): number;
|
|
62
|
+
get screenY(): number;
|
|
63
|
+
get clientX(): number;
|
|
64
|
+
get clientY(): number;
|
|
65
|
+
get x(): number;
|
|
66
|
+
get y(): number;
|
|
67
|
+
get ctrlKey(): boolean;
|
|
68
|
+
get shiftKey(): boolean;
|
|
69
|
+
get altKey(): boolean;
|
|
70
|
+
get metaKey(): boolean;
|
|
71
|
+
get button(): number;
|
|
72
|
+
get buttons(): number;
|
|
73
|
+
get relatedTarget(): PseudoEventTarget | null;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a modifier key was held down when the event happened.
|
|
76
|
+
* @param {string} key Control, Shift, Alt or Meta
|
|
77
|
+
* @returns {boolean}
|
|
78
|
+
*/
|
|
79
|
+
getModifierState(key: string): boolean;
|
|
80
|
+
}
|