|
| 1 | +@@warning("-30") |
| 2 | + |
| 3 | +open EventAPI |
| 4 | +open DOMAPI |
| 5 | + |
| 6 | +/** |
| 7 | +Simple user interface events. |
| 8 | +[See UIEvent on MDN](https://developer.mozilla.org/docs/Web/API/UIEvent) |
| 9 | +*/ |
| 10 | +type uiEvent = { |
| 11 | + ...event, |
| 12 | + /** |
| 13 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UIEvent/view) |
| 14 | + */ |
| 15 | + view: Null.t<window>, |
| 16 | + /** |
| 17 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UIEvent/detail) |
| 18 | + */ |
| 19 | + detail: int, |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | +The DOM CompositionEvent represents events that occur due to the user indirectly entering text. |
| 24 | +[See CompositionEvent on MDN](https://developer.mozilla.org/docs/Web/API/CompositionEvent) |
| 25 | +*/ |
| 26 | +type compositionEvent = { |
| 27 | + ...uiEvent, |
| 28 | + /** |
| 29 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CompositionEvent/data) |
| 30 | + */ |
| 31 | + data: string, |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | +Focus-related events like focus, blur, focusin, or focusout. |
| 36 | +[See FocusEvent on MDN](https://developer.mozilla.org/docs/Web/API/FocusEvent) |
| 37 | +*/ |
| 38 | +type focusEvent = { |
| 39 | + ...uiEvent, |
| 40 | + /** |
| 41 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FocusEvent/relatedTarget) |
| 42 | + */ |
| 43 | + relatedTarget: Null.t<eventTarget>, |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | +One drag data item. During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object. |
| 48 | +[See DataTransferItem on MDN](https://developer.mozilla.org/docs/Web/API/DataTransferItem) |
| 49 | +*/ |
| 50 | +type dataTransferItem = { |
| 51 | + /** |
| 52 | + Returns the drag data item kind, one of: "string", "file". |
| 53 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransferItem/kind) |
| 54 | + */ |
| 55 | + kind: string, |
| 56 | + /** |
| 57 | + Returns the drag data item type string. |
| 58 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransferItem/type) |
| 59 | + */ |
| 60 | + @as("type") |
| 61 | + type_: string, |
| 62 | +} |
| 63 | + |
| 64 | +/** |
| 65 | +A list of DataTransferItem objects representing items being dragged. During a drag operation, each DragEvent has a dataTransfer property and that property is a DataTransferItemList. |
| 66 | +[See DataTransferItemList on MDN](https://developer.mozilla.org/docs/Web/API/DataTransferItemList) |
| 67 | +*/ |
| 68 | +type dataTransferItemList = { |
| 69 | + /** |
| 70 | + Returns the number of items in the drag data store. |
| 71 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransferItemList/length) |
| 72 | + */ |
| 73 | + length: int, |
| 74 | +} |
| 75 | + |
| 76 | +/** |
| 77 | +Used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. For more information about drag and drop, see HTML Drag and Drop API. |
| 78 | +[See DataTransfer on MDN](https://developer.mozilla.org/docs/Web/API/DataTransfer) |
| 79 | +*/ |
| 80 | +type dataTransfer = { |
| 81 | + /** |
| 82 | + Returns the kind of operation that is currently selected. If the kind of operation isn't one of those that is allowed by the effectAllowed attribute, then the operation will fail. |
| 83 | +
|
| 84 | +Can be set, to change the selected operation. |
| 85 | +
|
| 86 | +The possible values are "none", "copy", "link", and "move". |
| 87 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransfer/dropEffect) |
| 88 | + */ |
| 89 | + mutable dropEffect: string, |
| 90 | + /** |
| 91 | + Returns the kinds of operations that are to be allowed. |
| 92 | +
|
| 93 | +Can be set (during the dragstart event), to change the allowed operations. |
| 94 | +
|
| 95 | +The possible values are "none", "copy", "copyLink", "copyMove", "link", "linkMove", "move", "all", and "uninitialized", |
| 96 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransfer/effectAllowed) |
| 97 | + */ |
| 98 | + mutable effectAllowed: string, |
| 99 | + /** |
| 100 | + Returns a DataTransferItemList object, with the drag data. |
| 101 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransfer/items) |
| 102 | + */ |
| 103 | + items: dataTransferItemList, |
| 104 | + /** |
| 105 | + Returns a frozen array listing the formats that were set in the dragstart event. In addition, if any files are being dragged, then one of the types will be the string "Files". |
| 106 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransfer/types) |
| 107 | + */ |
| 108 | + types: array<string>, |
| 109 | + /** |
| 110 | + Returns a FileList of the files being dragged, if any. |
| 111 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DataTransfer/files) |
| 112 | + */ |
| 113 | + files: fileList, |
| 114 | +} |
| 115 | + |
| 116 | +/** |
| 117 | +[See InputEvent on MDN](https://developer.mozilla.org/docs/Web/API/InputEvent) |
| 118 | +*/ |
| 119 | +type inputEvent = { |
| 120 | + ...uiEvent, |
| 121 | + /** |
| 122 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/InputEvent/data) |
| 123 | + */ |
| 124 | + data: Null.t<string>, |
| 125 | + /** |
| 126 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/InputEvent/isComposing) |
| 127 | + */ |
| 128 | + isComposing: bool, |
| 129 | + /** |
| 130 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/InputEvent/inputType) |
| 131 | + */ |
| 132 | + inputType: string, |
| 133 | + /** |
| 134 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/InputEvent/dataTransfer) |
| 135 | + */ |
| 136 | + dataTransfer: Null.t<dataTransfer>, |
| 137 | +} |
| 138 | + |
| 139 | +/** |
| 140 | +KeyboardEvent objects describe a user interaction with the keyboard; each event describes a single interaction between the user and a key (or combination of a key with modifier keys) on the keyboard. |
| 141 | +[See KeyboardEvent on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent) |
| 142 | +*/ |
| 143 | +type keyboardEvent = { |
| 144 | + ...uiEvent, |
| 145 | + /** |
| 146 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/key) |
| 147 | + */ |
| 148 | + key: string, |
| 149 | + /** |
| 150 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/code) |
| 151 | + */ |
| 152 | + code: string, |
| 153 | + /** |
| 154 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/location) |
| 155 | + */ |
| 156 | + location: int, |
| 157 | + /** |
| 158 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/ctrlKey) |
| 159 | + */ |
| 160 | + ctrlKey: bool, |
| 161 | + /** |
| 162 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/shiftKey) |
| 163 | + */ |
| 164 | + shiftKey: bool, |
| 165 | + /** |
| 166 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/altKey) |
| 167 | + */ |
| 168 | + altKey: bool, |
| 169 | + /** |
| 170 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/metaKey) |
| 171 | + */ |
| 172 | + metaKey: bool, |
| 173 | + /** |
| 174 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/repeat) |
| 175 | + */ |
| 176 | + repeat: bool, |
| 177 | + /** |
| 178 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/KeyboardEvent/isComposing) |
| 179 | + */ |
| 180 | + isComposing: bool, |
| 181 | +} |
| 182 | + |
| 183 | +/** |
| 184 | +Events that occur due to the user interacting with a pointing device (such as a mouse). Common events using this interface include click, dblclick, mouseup, mousedown. |
| 185 | +[See MouseEvent on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent) |
| 186 | +*/ |
| 187 | +type mouseEvent = { |
| 188 | + ...uiEvent, |
| 189 | + /** |
| 190 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/screenX) |
| 191 | + */ |
| 192 | + screenX: int, |
| 193 | + /** |
| 194 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/screenY) |
| 195 | + */ |
| 196 | + screenY: int, |
| 197 | + /** |
| 198 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/clientX) |
| 199 | + */ |
| 200 | + clientX: int, |
| 201 | + /** |
| 202 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/clientY) |
| 203 | + */ |
| 204 | + clientY: int, |
| 205 | + /** |
| 206 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/layerX) |
| 207 | + */ |
| 208 | + layerX: int, |
| 209 | + /** |
| 210 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/layerY) |
| 211 | + */ |
| 212 | + layerY: int, |
| 213 | + /** |
| 214 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/ctrlKey) |
| 215 | + */ |
| 216 | + ctrlKey: bool, |
| 217 | + /** |
| 218 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/shiftKey) |
| 219 | + */ |
| 220 | + shiftKey: bool, |
| 221 | + /** |
| 222 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/altKey) |
| 223 | + */ |
| 224 | + altKey: bool, |
| 225 | + /** |
| 226 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/metaKey) |
| 227 | + */ |
| 228 | + metaKey: bool, |
| 229 | + /** |
| 230 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/button) |
| 231 | + */ |
| 232 | + button: int, |
| 233 | + /** |
| 234 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/buttons) |
| 235 | + */ |
| 236 | + buttons: int, |
| 237 | + /** |
| 238 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/relatedTarget) |
| 239 | + */ |
| 240 | + relatedTarget: Null.t<eventTarget>, |
| 241 | + /** |
| 242 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/pageX) |
| 243 | + */ |
| 244 | + pageX: float, |
| 245 | + /** |
| 246 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/pageY) |
| 247 | + */ |
| 248 | + pageY: float, |
| 249 | + /** |
| 250 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/x) |
| 251 | + */ |
| 252 | + x: float, |
| 253 | + /** |
| 254 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/y) |
| 255 | + */ |
| 256 | + y: float, |
| 257 | + /** |
| 258 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/offsetX) |
| 259 | + */ |
| 260 | + offsetX: float, |
| 261 | + /** |
| 262 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/offsetY) |
| 263 | + */ |
| 264 | + offsetY: float, |
| 265 | + /** |
| 266 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/movementX) |
| 267 | + */ |
| 268 | + movementX: float, |
| 269 | + /** |
| 270 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MouseEvent/movementY) |
| 271 | + */ |
| 272 | + movementY: float, |
| 273 | +} |
| 274 | + |
| 275 | +/** |
| 276 | +Events that occur due to the user moving a mouse wheel or similar input device. |
| 277 | +[See WheelEvent on MDN](https://developer.mozilla.org/docs/Web/API/WheelEvent) |
| 278 | +*/ |
| 279 | +type wheelEvent = { |
| 280 | + ...mouseEvent, |
| 281 | + /** |
| 282 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WheelEvent/deltaX) |
| 283 | + */ |
| 284 | + deltaX: float, |
| 285 | + /** |
| 286 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WheelEvent/deltaY) |
| 287 | + */ |
| 288 | + deltaY: float, |
| 289 | + /** |
| 290 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WheelEvent/deltaZ) |
| 291 | + */ |
| 292 | + deltaZ: float, |
| 293 | + /** |
| 294 | + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WheelEvent/deltaMode) |
| 295 | + */ |
| 296 | + deltaMode: int, |
| 297 | +} |
| 298 | + |
| 299 | +type uiEventInit = { |
| 300 | + ...eventInit, |
| 301 | + mutable view?: Null.t<window>, |
| 302 | + mutable detail?: int, |
| 303 | + mutable which?: int, |
| 304 | +} |
| 305 | + |
| 306 | +type eventModifierInit = { |
| 307 | + ...uiEventInit, |
| 308 | + mutable ctrlKey?: bool, |
| 309 | + mutable shiftKey?: bool, |
| 310 | + mutable altKey?: bool, |
| 311 | + mutable metaKey?: bool, |
| 312 | + mutable modifierAltGraph?: bool, |
| 313 | + mutable modifierCapsLock?: bool, |
| 314 | + mutable modifierFn?: bool, |
| 315 | + mutable modifierFnLock?: bool, |
| 316 | + mutable modifierHyper?: bool, |
| 317 | + mutable modifierNumLock?: bool, |
| 318 | + mutable modifierScrollLock?: bool, |
| 319 | + mutable modifierSuper?: bool, |
| 320 | + mutable modifierSymbol?: bool, |
| 321 | + mutable modifierSymbolLock?: bool, |
| 322 | +} |
| 323 | + |
| 324 | +type mouseEventInit = { |
| 325 | + ...eventModifierInit, |
| 326 | + mutable screenX?: int, |
| 327 | + mutable screenY?: int, |
| 328 | + mutable clientX?: int, |
| 329 | + mutable clientY?: int, |
| 330 | + mutable button?: int, |
| 331 | + mutable buttons?: int, |
| 332 | + mutable relatedTarget?: Null.t<eventTarget>, |
| 333 | + mutable movementX?: float, |
| 334 | + mutable movementY?: float, |
| 335 | +} |
| 336 | + |
| 337 | +type focusEventInit = { |
| 338 | + ...uiEventInit, |
| 339 | + mutable relatedTarget?: Null.t<eventTarget>, |
| 340 | +} |
| 341 | + |
| 342 | +type compositionEventInit = { |
| 343 | + ...uiEventInit, |
| 344 | + mutable data?: string, |
| 345 | +} |
| 346 | + |
| 347 | +type wheelEventInit = { |
| 348 | + ...mouseEventInit, |
| 349 | + mutable deltaX?: float, |
| 350 | + mutable deltaY?: float, |
| 351 | + mutable deltaZ?: float, |
| 352 | + mutable deltaMode?: int, |
| 353 | +} |
| 354 | + |
| 355 | +type keyboardEventInit = { |
| 356 | + ...eventModifierInit, |
| 357 | + mutable key?: string, |
| 358 | + mutable code?: string, |
| 359 | + mutable location?: int, |
| 360 | + mutable repeat?: bool, |
| 361 | + mutable isComposing?: bool, |
| 362 | + mutable charCode?: int, |
| 363 | + mutable keyCode?: int, |
| 364 | +} |
| 365 | + |
| 366 | +type inputEventInit = { |
| 367 | + ...uiEventInit, |
| 368 | + mutable data?: Null.t<string>, |
| 369 | + mutable isComposing?: bool, |
| 370 | + mutable inputType?: string, |
| 371 | + mutable dataTransfer?: Null.t<dataTransfer>, |
| 372 | + mutable targetRanges?: array<staticRange>, |
| 373 | +} |
0 commit comments