pseudo-dom 0.6.0 → 0.8.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.
Files changed (131) hide show
  1. package/README.md +686 -241
  2. package/browser/pseudo-dom.js +3576 -735
  3. package/browser/pseudo-dom.min.js +1 -1
  4. package/dist/classes/PseudoEventListener.d.ts +96 -96
  5. package/dist/classes/PseudoEventListener.js +151 -151
  6. package/dist/classes/PseudoHTMLDocument.d.ts +17 -43
  7. package/dist/classes/PseudoHTMLDocument.js +24 -94
  8. package/dist/classes/PseudoHTMLDocument.min.js +1 -1
  9. package/dist/classes/PseudoNodeList.d.ts +34 -34
  10. package/dist/classes/PseudoNodeList.js +71 -71
  11. package/dist/factories/createEvent.d.ts +28 -28
  12. package/dist/factories/createEvent.js +56 -56
  13. package/dist/factories/cssSelectAdapter.d.ts +23 -0
  14. package/dist/factories/cssSelectAdapter.js +87 -0
  15. package/dist/factories/cssSelectAdapter.min.js +1 -0
  16. package/dist/factories/eventDefaults.d.ts +31 -31
  17. package/dist/factories/eventDefaults.js +105 -105
  18. package/dist/factories/generateDocument.d.ts +11 -11
  19. package/dist/factories/generateDocument.js +65 -65
  20. package/dist/factories/generateNodeList.d.ts +9 -9
  21. package/dist/factories/generateNodeList.js +13 -13
  22. package/dist/factories/query.d.ts +33 -0
  23. package/dist/factories/query.js +66 -0
  24. package/dist/factories/query.min.js +1 -0
  25. package/dist/functions/activeElement.d.ts +14 -14
  26. package/dist/functions/activeElement.js +33 -33
  27. package/dist/functions/getElementById.d.ts +13 -0
  28. package/dist/functions/getElementById.js +33 -0
  29. package/dist/functions/getElementById.min.js +1 -0
  30. package/dist/functions/getParentNodes.d.ts +11 -11
  31. package/dist/functions/getParentNodes.js +22 -22
  32. package/dist/functions/getParentNodesFromAttribute.d.ts +14 -14
  33. package/dist/functions/getParentNodesFromAttribute.js +29 -29
  34. package/dist/functions/modifierState.d.ts +29 -29
  35. package/dist/functions/modifierState.js +41 -41
  36. package/dist/interfaces/PseudoAnimation.d.ts +3 -3
  37. package/dist/interfaces/PseudoAnimation.js +5 -5
  38. package/dist/interfaces/PseudoAttr.d.ts +11 -11
  39. package/dist/interfaces/PseudoAttr.js +5 -5
  40. package/dist/interfaces/PseudoDOMTokenList.d.ts +16 -16
  41. package/dist/interfaces/PseudoDOMTokenList.js +5 -5
  42. package/dist/interfaces/PseudoDocument.d.ts +32 -0
  43. package/dist/interfaces/PseudoDocument.js +5 -5
  44. package/dist/interfaces/PseudoDocumentFragment.d.ts +7 -0
  45. package/dist/interfaces/PseudoDocumentFragment.js +5 -5
  46. package/dist/interfaces/PseudoElement.d.ts +702 -689
  47. package/dist/interfaces/PseudoElement.js +5 -5
  48. package/dist/interfaces/PseudoEvent.d.ts +79 -79
  49. package/dist/interfaces/PseudoEvent.js +10 -10
  50. package/dist/interfaces/PseudoEventTarget.d.ts +46 -46
  51. package/dist/interfaces/PseudoEventTarget.js +5 -5
  52. package/dist/interfaces/PseudoHTMLCollection.d.ts +23 -23
  53. package/dist/interfaces/PseudoHTMLCollection.js +5 -5
  54. package/dist/interfaces/PseudoHTMLElement.d.ts +22 -22
  55. package/dist/interfaces/PseudoHTMLElement.js +5 -5
  56. package/dist/interfaces/PseudoHTMLSlotElement.d.ts +3 -3
  57. package/dist/interfaces/PseudoHTMLSlotElement.js +5 -5
  58. package/dist/interfaces/PseudoNamedNodeMap.d.ts +11 -11
  59. package/dist/interfaces/PseudoNamedNodeMap.js +5 -5
  60. package/dist/interfaces/PseudoNode.d.ts +179 -179
  61. package/dist/interfaces/PseudoNode.js +5 -5
  62. package/dist/interfaces/PseudoShadowRoot.d.ts +3 -3
  63. package/dist/interfaces/PseudoShadowRoot.js +5 -5
  64. package/dist/main.d.ts +63 -63
  65. package/dist/main.js +155 -155
  66. package/dist/services/AnimationService.d.ts +4 -4
  67. package/dist/services/AnimationService.js +16 -16
  68. package/dist/services/AttrService.d.ts +37 -37
  69. package/dist/services/AttrService.js +81 -81
  70. package/dist/services/CommentService.d.ts +1 -1
  71. package/dist/services/CommentService.js +13 -13
  72. package/dist/services/CustomEventService.d.ts +37 -37
  73. package/dist/services/CustomEventService.js +35 -35
  74. package/dist/services/DOMTokenListService.d.ts +33 -33
  75. package/dist/services/DOMTokenListService.js +117 -117
  76. package/dist/services/DocumentFragmentService.d.ts +8 -0
  77. package/dist/services/DocumentFragmentService.js +18 -0
  78. package/dist/services/DocumentFragmentService.min.js +1 -1
  79. package/dist/services/DocumentService.d.ts +35 -1
  80. package/dist/services/DocumentService.js +72 -0
  81. package/dist/services/DocumentService.min.js +1 -1
  82. package/dist/services/ElementService.d.ts +191 -178
  83. package/dist/services/ElementService.js +426 -406
  84. package/dist/services/ElementService.min.js +1 -1
  85. package/dist/services/EventService.d.ts +120 -120
  86. package/dist/services/EventService.js +250 -250
  87. package/dist/services/EventTargetService.d.ts +84 -84
  88. package/dist/services/EventTargetService.js +232 -232
  89. package/dist/services/FocusEventService.d.ts +32 -32
  90. package/dist/services/FocusEventService.js +35 -35
  91. package/dist/services/HTMLCollectionService.d.ts +54 -49
  92. package/dist/services/HTMLCollectionService.js +92 -75
  93. package/dist/services/HTMLCollectionService.min.js +1 -1
  94. package/dist/services/HTMLElementService.d.ts +57 -57
  95. package/dist/services/HTMLElementService.js +163 -163
  96. package/dist/services/HTMLSlotElementService.d.ts +4 -4
  97. package/dist/services/HTMLSlotElementService.js +9 -9
  98. package/dist/services/InputEventService.d.ts +41 -41
  99. package/dist/services/InputEventService.js +47 -47
  100. package/dist/services/KeyboardEventService.d.ts +70 -70
  101. package/dist/services/KeyboardEventService.js +86 -86
  102. package/dist/services/MouseEventService.d.ts +80 -80
  103. package/dist/services/MouseEventService.js +108 -108
  104. package/dist/services/NamedNodeMapService.d.ts +23 -23
  105. package/dist/services/NamedNodeMapService.js +77 -77
  106. package/dist/services/NodeService.d.ts +297 -271
  107. package/dist/services/NodeService.js +721 -679
  108. package/dist/services/NodeService.min.js +1 -1
  109. package/dist/services/PointerEventService.d.ts +51 -51
  110. package/dist/services/PointerEventService.js +67 -67
  111. package/dist/services/ShadowRootService.d.ts +4 -4
  112. package/dist/services/ShadowRootService.js +9 -9
  113. package/dist/services/TextService.d.ts +1 -1
  114. package/dist/services/TextService.js +13 -13
  115. package/dist/services/UIEventService.d.ts +43 -43
  116. package/dist/services/UIEventService.js +42 -42
  117. package/dist/simulate.d.ts +32 -32
  118. package/dist/simulate.js +115 -115
  119. package/package.json +4 -3
  120. package/dist/classes.d.ts +0 -20
  121. package/dist/classes.js +0 -31
  122. package/dist/classes.min.js +0 -1
  123. package/dist/factories/generateNode.d.ts +0 -32
  124. package/dist/factories/generateNode.js +0 -85
  125. package/dist/factories/generateNode.min.js +0 -1
  126. package/dist/factories.d.ts +0 -11
  127. package/dist/factories.js +0 -27
  128. package/dist/factories.min.js +0 -1
  129. package/dist/functions.d.ts +0 -5
  130. package/dist/functions.js +0 -23
  131. package/dist/functions.min.js +0 -1
@@ -1,163 +1,163 @@
1
- 'use strict'
2
-
3
- const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
4
- return mod && mod.__esModule
5
- ? mod
6
- : {
7
- default: mod
8
- }
9
- }
10
- Object.defineProperty(exports, '__esModule', {
11
- value: true
12
- })
13
- exports.HTMLElementService = void 0
14
- const ElementService_1 = require('./ElementService')
15
- const createEvent_1 = __importDefault(require('../factories/createEvent'))
16
- const activeElement_1 = require('../functions/activeElement')
17
- /**
18
- * Simulate the behaviour of the HTMLElement Class when there is no DOM available.
19
- * @author Joshua Heagle <joshuaheagle@gmail.com>
20
- * @class
21
- * @augments PseudoElement
22
- * @property {boolean} hidden - State of whether element is visible
23
- * @property {number} offsetHeight - The height of the element as offset by the parent element
24
- * @property {number} offsetLeft - The position of the left side of the element based on the parent element
25
- * @property {PseudoHTMLElement} offsetParent - A reference to the closest positioned parent element
26
- * @property {number} offsetTop - The position of the top side of the element based on the parent element
27
- * @property {number} offsetWidth - The width of the element as offset by the parent element
28
- * @property {Object} style - A container to define all applied inline-styles
29
- * @property {string} title - The title attribute which affects the text visible on hover
30
- */
31
- class HTMLElementService extends ElementService_1.ElementService {
32
- /**
33
- * Simulate the HTMLElement object when the Dom is not available
34
- * @param {Object} [elementOptions={}]
35
- * @param {string} [elementOptions.tagName='']
36
- * @param {PseudoNode|Object} [elementOptions.parent={}]
37
- * @param {Array} [elementOptions.children=[]]
38
- * @constructor
39
- */
40
- constructor ({
41
- tagName = '',
42
- parent = null,
43
- children = []
44
- } = {}) {
45
- super({
46
- tagName,
47
- attributes: [{
48
- name: 'hidden',
49
- value: false
50
- }, {
51
- name: 'offsetHeight',
52
- value: 0
53
- }, {
54
- name: 'offsetLeft',
55
- value: 0
56
- }, {
57
- name: 'offsetParent',
58
- value: null
59
- }, {
60
- name: 'offsetTop',
61
- value: 0
62
- }, {
63
- name: 'offsetWidth',
64
- value: 0
65
- }, {
66
- name: 'style',
67
- value: {}
68
- }, {
69
- name: 'title',
70
- value: ''
71
- }],
72
- parent,
73
- children
74
- })
75
- }
76
-
77
- /**
78
- * Whether this element can have the focus: form controls and links which are not disabled, and anything with a tabindex.
79
- * @returns {boolean}
80
- */
81
- get canFocus () {
82
- if (this.hasAttribute('disabled')) {
83
- return false
84
- }
85
- switch (this.tagName) {
86
- case 'button':
87
- case 'select':
88
- case 'textarea':
89
- return true
90
- case 'input':
91
- return String(this.getAttribute('type') || '').toLowerCase() !== 'hidden'
92
- case 'a':
93
- return this.hasAttribute('href') || this.hasAttribute('tabindex')
94
- default:
95
- return this.hasAttribute('tabindex')
96
- }
97
- }
98
-
99
- /**
100
- * Click the element: a click event is sent to it, which bubbles and can be cancelled, like one from a user but a
101
- * script made it (so it is not trusted). A disabled element does nothing.
102
- */
103
- click () {
104
- if (this.hasAttribute('disabled')) {
105
- return
106
- }
107
- this.dispatchEvent((0, createEvent_1.default)('click', {}, {
108
- browser: true
109
- }))
110
- }
111
-
112
- /**
113
- * Give the element the focus. The element which had it gets blur then focusout, and this one gets focus then
114
- * focusin (blur and focus do not bubble, focusin and focusout do). Nothing happens when the element cannot have the
115
- * focus or already has it.
116
- */
117
- focus () {
118
- const root = this.getRootNode()
119
- const previous = (0, activeElement_1.getActiveElement)(root)
120
- if (!this.canFocus || previous === this) {
121
- return
122
- }
123
- const send = (target, type, relatedTarget) => {
124
- target.dispatchEvent((0, createEvent_1.default)(type, {
125
- relatedTarget
126
- }, {
127
- browser: true,
128
- trusted: true
129
- }))
130
- }
131
- if (previous) {
132
- send(previous, 'blur', this)
133
- send(previous, 'focusout', this)
134
- }
135
- (0, activeElement_1.setActiveElement)(root, this)
136
- send(this, 'focus', previous)
137
- send(this, 'focusin', previous)
138
- }
139
-
140
- /**
141
- * Take the focus away from the element, when it has it: it gets blur then focusout.
142
- */
143
- blur () {
144
- const root = this.getRootNode()
145
- if ((0, activeElement_1.getActiveElement)(root) !== this) {
146
- return
147
- }
148
- (0, activeElement_1.setActiveElement)(root, null)
149
- this.dispatchEvent((0, createEvent_1.default)('blur', {
150
- relatedTarget: null
151
- }, {
152
- browser: true,
153
- trusted: true
154
- }))
155
- this.dispatchEvent((0, createEvent_1.default)('focusout', {
156
- relatedTarget: null
157
- }, {
158
- browser: true,
159
- trusted: true
160
- }))
161
- }
162
- }
163
- exports.HTMLElementService = HTMLElementService
1
+ 'use strict'
2
+
3
+ const __importDefault = void 0 && (void 0).__importDefault || function (mod) {
4
+ return mod && mod.__esModule
5
+ ? mod
6
+ : {
7
+ default: mod
8
+ }
9
+ }
10
+ Object.defineProperty(exports, '__esModule', {
11
+ value: true
12
+ })
13
+ exports.HTMLElementService = void 0
14
+ const ElementService_1 = require('./ElementService')
15
+ const createEvent_1 = __importDefault(require('../factories/createEvent'))
16
+ const activeElement_1 = require('../functions/activeElement')
17
+ /**
18
+ * Simulate the behaviour of the HTMLElement Class when there is no DOM available.
19
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
20
+ * @class
21
+ * @augments PseudoElement
22
+ * @property {boolean} hidden - State of whether element is visible
23
+ * @property {number} offsetHeight - The height of the element as offset by the parent element
24
+ * @property {number} offsetLeft - The position of the left side of the element based on the parent element
25
+ * @property {PseudoHTMLElement} offsetParent - A reference to the closest positioned parent element
26
+ * @property {number} offsetTop - The position of the top side of the element based on the parent element
27
+ * @property {number} offsetWidth - The width of the element as offset by the parent element
28
+ * @property {Object} style - A container to define all applied inline-styles
29
+ * @property {string} title - The title attribute which affects the text visible on hover
30
+ */
31
+ class HTMLElementService extends ElementService_1.ElementService {
32
+ /**
33
+ * Simulate the HTMLElement object when the Dom is not available
34
+ * @param {Object} [elementOptions={}]
35
+ * @param {string} [elementOptions.tagName='']
36
+ * @param {PseudoNode|Object} [elementOptions.parent={}]
37
+ * @param {Array} [elementOptions.children=[]]
38
+ * @constructor
39
+ */
40
+ constructor ({
41
+ tagName = '',
42
+ parent = null,
43
+ children = []
44
+ } = {}) {
45
+ super({
46
+ tagName,
47
+ attributes: [{
48
+ name: 'hidden',
49
+ value: false
50
+ }, {
51
+ name: 'offsetHeight',
52
+ value: 0
53
+ }, {
54
+ name: 'offsetLeft',
55
+ value: 0
56
+ }, {
57
+ name: 'offsetParent',
58
+ value: null
59
+ }, {
60
+ name: 'offsetTop',
61
+ value: 0
62
+ }, {
63
+ name: 'offsetWidth',
64
+ value: 0
65
+ }, {
66
+ name: 'style',
67
+ value: {}
68
+ }, {
69
+ name: 'title',
70
+ value: ''
71
+ }],
72
+ parent,
73
+ children
74
+ })
75
+ }
76
+
77
+ /**
78
+ * Whether this element can have the focus: form controls and links which are not disabled, and anything with a tabindex.
79
+ * @returns {boolean}
80
+ */
81
+ get canFocus () {
82
+ if (this.hasAttribute('disabled')) {
83
+ return false
84
+ }
85
+ switch (this.tagName) {
86
+ case 'button':
87
+ case 'select':
88
+ case 'textarea':
89
+ return true
90
+ case 'input':
91
+ return String(this.getAttribute('type') || '').toLowerCase() !== 'hidden'
92
+ case 'a':
93
+ return this.hasAttribute('href') || this.hasAttribute('tabindex')
94
+ default:
95
+ return this.hasAttribute('tabindex')
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Click the element: a click event is sent to it, which bubbles and can be cancelled, like one from a user but a
101
+ * script made it (so it is not trusted). A disabled element does nothing.
102
+ */
103
+ click () {
104
+ if (this.hasAttribute('disabled')) {
105
+ return
106
+ }
107
+ this.dispatchEvent((0, createEvent_1.default)('click', {}, {
108
+ browser: true
109
+ }))
110
+ }
111
+
112
+ /**
113
+ * Give the element the focus. The element which had it gets blur then focusout, and this one gets focus then
114
+ * focusin (blur and focus do not bubble, focusin and focusout do). Nothing happens when the element cannot have the
115
+ * focus or already has it.
116
+ */
117
+ focus () {
118
+ const root = this.getRootNode()
119
+ const previous = (0, activeElement_1.getActiveElement)(root)
120
+ if (!this.canFocus || previous === this) {
121
+ return
122
+ }
123
+ const send = (target, type, relatedTarget) => {
124
+ target.dispatchEvent((0, createEvent_1.default)(type, {
125
+ relatedTarget
126
+ }, {
127
+ browser: true,
128
+ trusted: true
129
+ }))
130
+ }
131
+ if (previous) {
132
+ send(previous, 'blur', this)
133
+ send(previous, 'focusout', this)
134
+ }
135
+ (0, activeElement_1.setActiveElement)(root, this)
136
+ send(this, 'focus', previous)
137
+ send(this, 'focusin', previous)
138
+ }
139
+
140
+ /**
141
+ * Take the focus away from the element, when it has it: it gets blur then focusout.
142
+ */
143
+ blur () {
144
+ const root = this.getRootNode()
145
+ if ((0, activeElement_1.getActiveElement)(root) !== this) {
146
+ return
147
+ }
148
+ (0, activeElement_1.setActiveElement)(root, null)
149
+ this.dispatchEvent((0, createEvent_1.default)('blur', {
150
+ relatedTarget: null
151
+ }, {
152
+ browser: true,
153
+ trusted: true
154
+ }))
155
+ this.dispatchEvent((0, createEvent_1.default)('focusout', {
156
+ relatedTarget: null
157
+ }, {
158
+ browser: true,
159
+ trusted: true
160
+ }))
161
+ }
162
+ }
163
+ exports.HTMLElementService = HTMLElementService
@@ -1,4 +1,4 @@
1
- import { PseudoHTMLSlotElement } from '../interfaces/PseudoHTMLSlotElement';
2
- import { HTMLElementService } from './HTMLElementService';
3
- export declare class HTMLSlotElementService extends HTMLElementService implements Partial<PseudoHTMLSlotElement> {
4
- }
1
+ import { PseudoHTMLSlotElement } from '../interfaces/PseudoHTMLSlotElement';
2
+ import { HTMLElementService } from './HTMLElementService';
3
+ export declare class HTMLSlotElementService extends HTMLElementService implements Partial<PseudoHTMLSlotElement> {
4
+ }
@@ -1,9 +1,9 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.HTMLSlotElementService = void 0
7
- const HTMLElementService_1 = require('./HTMLElementService')
8
- class HTMLSlotElementService extends HTMLElementService_1.HTMLElementService {}
9
- exports.HTMLSlotElementService = HTMLSlotElementService
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.HTMLSlotElementService = void 0
7
+ const HTMLElementService_1 = require('./HTMLElementService')
8
+ class HTMLSlotElementService extends HTMLElementService_1.HTMLElementService {}
9
+ exports.HTMLSlotElementService = HTMLSlotElementService
@@ -1,41 +1,41 @@
1
- /**
2
- * @file Substitute for the DOM InputEvent 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 an input event, on top of the ones every UI event has.
9
- * @typedef {Object} InputEventInit
10
- * @property {string|null} [data=null] The characters which were entered
11
- * @property {string} [inputType=''] What kind of change it was, such as insertText
12
- * @property {boolean} [isComposing=false]
13
- */
14
- export type InputEventInit = UIEventInit & {
15
- data?: string | null;
16
- inputType?: string;
17
- isComposing?: boolean;
18
- };
19
- /**
20
- * Simulate the behaviour of the InputEvent Class when there is no DOM available.
21
- * @author Joshua Heagle <joshuaheagle@gmail.com>
22
- * @class
23
- * @augments UIEventService
24
- * @property {string|null} data
25
- * @property {string} inputType
26
- * @property {boolean} isComposing
27
- */
28
- export declare class InputEventService extends UIEventService {
29
- private readonly inputData;
30
- private readonly kind;
31
- private readonly composing;
32
- /**
33
- * @param {string} [typeArg=''] The type of the event
34
- * @param {InputEventInit} [init={}] The options for the event
35
- * @constructor
36
- */
37
- constructor(typeArg?: string, init?: InputEventInit);
38
- get data(): string | null;
39
- get inputType(): string;
40
- get isComposing(): boolean;
41
- }
1
+ /**
2
+ * @file Substitute for the DOM InputEvent 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 an input event, on top of the ones every UI event has.
9
+ * @typedef {Object} InputEventInit
10
+ * @property {string|null} [data=null] The characters which were entered
11
+ * @property {string} [inputType=''] What kind of change it was, such as insertText
12
+ * @property {boolean} [isComposing=false]
13
+ */
14
+ export type InputEventInit = UIEventInit & {
15
+ data?: string | null;
16
+ inputType?: string;
17
+ isComposing?: boolean;
18
+ };
19
+ /**
20
+ * Simulate the behaviour of the InputEvent Class when there is no DOM available.
21
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
22
+ * @class
23
+ * @augments UIEventService
24
+ * @property {string|null} data
25
+ * @property {string} inputType
26
+ * @property {boolean} isComposing
27
+ */
28
+ export declare class InputEventService extends UIEventService {
29
+ private readonly inputData;
30
+ private readonly kind;
31
+ private readonly composing;
32
+ /**
33
+ * @param {string} [typeArg=''] The type of the event
34
+ * @param {InputEventInit} [init={}] The options for the event
35
+ * @constructor
36
+ */
37
+ constructor(typeArg?: string, init?: InputEventInit);
38
+ get data(): string | null;
39
+ get inputType(): string;
40
+ get isComposing(): boolean;
41
+ }
@@ -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
+ }