@oscarpalmer/toretto 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -10
- package/src/event.ts +8 -30
- package/src/models.ts +0 -10
- package/types/event.d.ts +3 -11
- package/types/index.d.cts +2 -18
- package/types/models.d.ts +0 -8
package/package.json
CHANGED
|
@@ -80,15 +80,8 @@
|
|
|
80
80
|
"require": "./dist/style.js"
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
|
-
"files": [
|
|
84
|
-
|
|
85
|
-
"src",
|
|
86
|
-
"types"
|
|
87
|
-
],
|
|
88
|
-
"keywords": [
|
|
89
|
-
"dom",
|
|
90
|
-
"utility"
|
|
91
|
-
],
|
|
83
|
+
"files": ["dist", "src", "types"],
|
|
84
|
+
"keywords": ["dom", "utility"],
|
|
92
85
|
"license": "MIT",
|
|
93
86
|
"main": "dist/index.js",
|
|
94
87
|
"module": "dist/index.mjs",
|
|
@@ -109,5 +102,5 @@
|
|
|
109
102
|
},
|
|
110
103
|
"type": "module",
|
|
111
104
|
"types": "types/index.d.cts",
|
|
112
|
-
"version": "0.
|
|
105
|
+
"version": "0.12.1"
|
|
113
106
|
}
|
package/src/event.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import {isPlainObject} from '@oscarpalmer/atoms/is';
|
|
2
|
-
import type {
|
|
3
|
-
CustomDispatchOptions,
|
|
4
|
-
DispatchOptions,
|
|
5
|
-
EventPosition,
|
|
6
|
-
} from './models';
|
|
2
|
+
import type {EventPosition} from './models';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
5
|
* Remove the current event listener
|
|
10
6
|
*/
|
|
11
7
|
type RemoveEventListener = () => void;
|
|
12
8
|
|
|
13
|
-
function createDispatchOptions(options:
|
|
9
|
+
function createDispatchOptions(options: EventInit): EventInit {
|
|
14
10
|
return {
|
|
15
11
|
bubbles: getBoolean(options?.bubbles),
|
|
16
12
|
cancelable: getBoolean(options?.cancelable),
|
|
@@ -18,7 +14,7 @@ function createDispatchOptions(options: DispatchOptions): DispatchOptions {
|
|
|
18
14
|
};
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
function createEvent(type: string, options?:
|
|
17
|
+
function createEvent(type: string, options?: CustomEventInit): Event {
|
|
22
18
|
const hasOptions = isPlainObject(options);
|
|
23
19
|
|
|
24
20
|
if (hasOptions && 'detail' in options) {
|
|
@@ -55,16 +51,7 @@ function createEventOptions(
|
|
|
55
51
|
export function dispatch<Type extends keyof HTMLElementEventMap>(
|
|
56
52
|
target: EventTarget,
|
|
57
53
|
type: Type,
|
|
58
|
-
options?:
|
|
59
|
-
): void;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Dispatch an event for a target
|
|
63
|
-
*/
|
|
64
|
-
export function dispatch<Type extends keyof HTMLElementEventMap>(
|
|
65
|
-
target: EventTarget,
|
|
66
|
-
type: Type,
|
|
67
|
-
options?: CustomDispatchOptions,
|
|
54
|
+
options?: CustomEventInit,
|
|
68
55
|
): void;
|
|
69
56
|
|
|
70
57
|
/**
|
|
@@ -73,22 +60,13 @@ export function dispatch<Type extends keyof HTMLElementEventMap>(
|
|
|
73
60
|
export function dispatch(
|
|
74
61
|
target: EventTarget,
|
|
75
62
|
type: string,
|
|
76
|
-
options?:
|
|
63
|
+
options?: CustomEventInit,
|
|
77
64
|
): void;
|
|
78
65
|
|
|
79
|
-
|
|
80
|
-
* Dispatch an event for a target
|
|
81
|
-
*/
|
|
82
|
-
export function dispatch(
|
|
83
|
-
target: EventTarget,
|
|
84
|
-
type: string,
|
|
85
|
-
options?: CustomDispatchOptions,
|
|
86
|
-
): void;
|
|
87
|
-
|
|
88
|
-
export function dispatch(
|
|
66
|
+
export function dispatch<Type extends keyof HTMLElementEventMap>(
|
|
89
67
|
target: EventTarget,
|
|
90
|
-
type: string,
|
|
91
|
-
options?:
|
|
68
|
+
type: Type | string,
|
|
69
|
+
options?: CustomEventInit,
|
|
92
70
|
): void {
|
|
93
71
|
target.dispatchEvent(createEvent(type, options));
|
|
94
72
|
}
|
package/src/models.ts
CHANGED
|
@@ -3,16 +3,6 @@ export type Attribute<Value = unknown> = {
|
|
|
3
3
|
value: Value;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
export type CustomDispatchOptions = {
|
|
7
|
-
detail?: unknown;
|
|
8
|
-
} & DispatchOptions;
|
|
9
|
-
|
|
10
|
-
export type DispatchOptions = {
|
|
11
|
-
bubbles?: boolean;
|
|
12
|
-
cancelable?: boolean;
|
|
13
|
-
composed?: boolean;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
6
|
export type EventPosition = {
|
|
17
7
|
x: number;
|
|
18
8
|
y: number;
|
package/types/event.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EventPosition } from './models';
|
|
2
2
|
/**
|
|
3
3
|
* Remove the current event listener
|
|
4
4
|
*/
|
|
@@ -6,19 +6,11 @@ type RemoveEventListener = () => void;
|
|
|
6
6
|
/**
|
|
7
7
|
* Dispatch an event for a target
|
|
8
8
|
*/
|
|
9
|
-
export declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?:
|
|
9
|
+
export declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
|
|
10
10
|
/**
|
|
11
11
|
* Dispatch an event for a target
|
|
12
12
|
*/
|
|
13
|
-
export declare function dispatch
|
|
14
|
-
/**
|
|
15
|
-
* Dispatch an event for a target
|
|
16
|
-
*/
|
|
17
|
-
export declare function dispatch(target: EventTarget, type: string, options?: DispatchOptions): void;
|
|
18
|
-
/**
|
|
19
|
-
* Dispatch an event for a target
|
|
20
|
-
*/
|
|
21
|
-
export declare function dispatch(target: EventTarget, type: string, options?: CustomDispatchOptions): void;
|
|
13
|
+
export declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
|
|
22
14
|
/**
|
|
23
15
|
* Get the X- and Y-coordinates from a pointer event
|
|
24
16
|
*/
|
package/types/index.d.cts
CHANGED
|
@@ -4,14 +4,6 @@ export type Attribute<Value = unknown> = {
|
|
|
4
4
|
name: string;
|
|
5
5
|
value: Value;
|
|
6
6
|
};
|
|
7
|
-
export type CustomDispatchOptions = {
|
|
8
|
-
detail?: unknown;
|
|
9
|
-
} & DispatchOptions;
|
|
10
|
-
export type DispatchOptions = {
|
|
11
|
-
bubbles?: boolean;
|
|
12
|
-
cancelable?: boolean;
|
|
13
|
-
composed?: boolean;
|
|
14
|
-
};
|
|
15
7
|
export type EventPosition = {
|
|
16
8
|
x: number;
|
|
17
9
|
y: number;
|
|
@@ -110,19 +102,11 @@ export type RemoveEventListener = () => void;
|
|
|
110
102
|
/**
|
|
111
103
|
* Dispatch an event for a target
|
|
112
104
|
*/
|
|
113
|
-
export declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?:
|
|
114
|
-
/**
|
|
115
|
-
* Dispatch an event for a target
|
|
116
|
-
*/
|
|
117
|
-
export declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomDispatchOptions): void;
|
|
118
|
-
/**
|
|
119
|
-
* Dispatch an event for a target
|
|
120
|
-
*/
|
|
121
|
-
export declare function dispatch(target: EventTarget, type: string, options?: DispatchOptions): void;
|
|
105
|
+
export declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
|
|
122
106
|
/**
|
|
123
107
|
* Dispatch an event for a target
|
|
124
108
|
*/
|
|
125
|
-
export declare function dispatch(target: EventTarget, type: string, options?:
|
|
109
|
+
export declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
|
|
126
110
|
/**
|
|
127
111
|
* Get the X- and Y-coordinates from a pointer event
|
|
128
112
|
*/
|
package/types/models.d.ts
CHANGED
|
@@ -2,14 +2,6 @@ export type Attribute<Value = unknown> = {
|
|
|
2
2
|
name: string;
|
|
3
3
|
value: Value;
|
|
4
4
|
};
|
|
5
|
-
export type CustomDispatchOptions = {
|
|
6
|
-
detail?: unknown;
|
|
7
|
-
} & DispatchOptions;
|
|
8
|
-
export type DispatchOptions = {
|
|
9
|
-
bubbles?: boolean;
|
|
10
|
-
cancelable?: boolean;
|
|
11
|
-
composed?: boolean;
|
|
12
|
-
};
|
|
13
5
|
export type EventPosition = {
|
|
14
6
|
x: number;
|
|
15
7
|
y: number;
|