@rokkit/actions 1.1.18 → 1.1.19
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/dist/keyboard.svelte.d.ts +5 -7
- package/dist/pannable.svelte.d.ts +5 -6
- package/dist/swipeable.svelte.d.ts +6 -14
- package/dist/types.d.ts +44 -0
- package/package.json +1 -1
- package/src/keyboard.svelte.js +7 -3
- package/src/pannable.svelte.js +9 -1
- package/src/swipeable.svelte.js +9 -3
- package/src/types.js +20 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export function keyboard(root: HTMLElement, options?: import("./types.js").KeyboardConfig): void;
|
|
1
|
+
export function keyboard<Node extends HTMLElement>(node: Node, parameter?: {
|
|
2
|
+
[x: string]: RegExp | string[];
|
|
3
|
+
} | null | undefined): void | import("svelte/action").ActionReturn<{
|
|
4
|
+
[x: string]: RegExp | string[];
|
|
5
|
+
} | null | undefined, Record<`on${string}`, (event: CustomEvent<string>) => void>>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function pannable(node: HTMLElement): void;
|
|
1
|
+
export function pannable<Node extends HTMLElement>(node: Node, parameter?: undefined): void | import("svelte/action").ActionReturn<undefined, {
|
|
2
|
+
onpanstart?: (event: CustomEvent<import("./types.js").Coords>) => void;
|
|
3
|
+
onpanmove?: (event: CustomEvent<import("./types.js").Coords>) => void;
|
|
4
|
+
onpanend?: (event: CustomEvent<import("./types.js").Coords>) => void;
|
|
5
|
+
}>;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export function swipeable(node: HTMLElement, options?: {
|
|
9
|
-
horizontal: boolean;
|
|
10
|
-
vertical: boolean;
|
|
11
|
-
threshold: number;
|
|
12
|
-
enabled: boolean;
|
|
13
|
-
minSpeed: number;
|
|
14
|
-
}): import("./types").SvelteActionReturn;
|
|
1
|
+
export function swipeable<Node extends HTMLElement>(node: Node, parameter?: import("./types.js").SwipeableOptions | undefined): void | import("svelte/action").ActionReturn<import("./types.js").SwipeableOptions | undefined, {
|
|
2
|
+
onswipeLeft?: (event: CustomEvent<undefined>) => void;
|
|
3
|
+
onswipeRight?: (event: CustomEvent<undefined>) => void;
|
|
4
|
+
onswipeUp?: (event: CustomEvent<undefined>) => void;
|
|
5
|
+
onswipeDown?: (event: CustomEvent<undefined>) => void;
|
|
6
|
+
}>;
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,50 @@ export type EventMapping = {
|
|
|
12
12
|
*/
|
|
13
13
|
pattern?: RegExp | undefined;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Options for the `swipeable` action. All fields are optional; unspecified
|
|
17
|
+
* fields fall back to the action's internal defaults.
|
|
18
|
+
*/
|
|
19
|
+
export type SwipeableOptions = {
|
|
20
|
+
/**
|
|
21
|
+
* - Detect horizontal swipes (default true)
|
|
22
|
+
*/
|
|
23
|
+
horizontal?: boolean | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* - Detect vertical swipes (default false)
|
|
26
|
+
*/
|
|
27
|
+
vertical?: boolean | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* - Minimum distance in px to register a swipe (default 100)
|
|
30
|
+
*/
|
|
31
|
+
threshold?: number | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* - Whether the action is active (default true)
|
|
34
|
+
*/
|
|
35
|
+
enabled?: boolean | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* - Minimum swipe speed in px/s (default 300)
|
|
38
|
+
*/
|
|
39
|
+
minSpeed?: number | undefined;
|
|
40
|
+
};
|
|
41
|
+
export type Coords = {
|
|
42
|
+
/**
|
|
43
|
+
* - Current x position
|
|
44
|
+
*/
|
|
45
|
+
x: number;
|
|
46
|
+
/**
|
|
47
|
+
* - Current y position
|
|
48
|
+
*/
|
|
49
|
+
y: number;
|
|
50
|
+
/**
|
|
51
|
+
* - Delta x since last event (panmove only)
|
|
52
|
+
*/
|
|
53
|
+
dx?: number | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* - Delta y since last event (panmove only)
|
|
56
|
+
*/
|
|
57
|
+
dy?: number | undefined;
|
|
58
|
+
};
|
|
15
59
|
export type KeyboardConfig = {
|
|
16
60
|
[x: string]: RegExp | string[];
|
|
17
61
|
};
|
package/package.json
CHANGED
package/src/keyboard.svelte.js
CHANGED
|
@@ -12,10 +12,14 @@ const defaultKeyMappings = {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Handle keyboard events
|
|
15
|
+
* Handle keyboard events.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* The dispatched event names are derived from the keys of the supplied
|
|
18
|
+
* `KeyboardConfig` (e.g. a config of `{ prev, next }` dispatches `prev`/`next`),
|
|
19
|
+
* so the third Action generic declares an open-ended set of `on*` CustomEvent
|
|
20
|
+
* attributes so consumers using `use:keyboard onprev={...}` type-check.
|
|
21
|
+
*
|
|
22
|
+
* @type {import('svelte/action').Action<HTMLElement, import('./types.js').KeyboardConfig | null | undefined, Record<`on${string}`, (event: CustomEvent<string>) => void>>}
|
|
19
23
|
*/
|
|
20
24
|
export function keyboard(root, options = null) {
|
|
21
25
|
const keyMappings = options ?? defaultKeyMappings
|
package/src/pannable.svelte.js
CHANGED
|
@@ -28,7 +28,15 @@ function handleEvent(node, event, name, coords) {
|
|
|
28
28
|
/**
|
|
29
29
|
* Makes an element pannable with mouse or touch events.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
31
|
+
* The third Action generic declares the `onpan*` attributes so consumers using
|
|
32
|
+
* `use:pannable onpanstart={...}` type-check. `panstart`/`panend` carry the
|
|
33
|
+
* pointer position; `panmove` additionally carries the delta (dx/dy).
|
|
34
|
+
*
|
|
35
|
+
* @type {import('svelte/action').Action<HTMLElement, undefined, {
|
|
36
|
+
* onpanstart?: (event: CustomEvent<import('./types.js').Coords>) => void,
|
|
37
|
+
* onpanmove?: (event: CustomEvent<import('./types.js').Coords>) => void,
|
|
38
|
+
* onpanend?: (event: CustomEvent<import('./types.js').Coords>) => void
|
|
39
|
+
* }>}
|
|
32
40
|
*/
|
|
33
41
|
export function pannable(node) {
|
|
34
42
|
let coords = { x: 0, y: 0 }
|
package/src/swipeable.svelte.js
CHANGED
|
@@ -122,9 +122,15 @@ function getListeners(node, options, track) {
|
|
|
122
122
|
/**
|
|
123
123
|
* A svelte action function that captures swipe actions and emits event for corresponding movements.
|
|
124
124
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
125
|
+
* The third Action generic declares the `onswipe*` attributes so consumers using
|
|
126
|
+
* `use:swipeable onswipeLeft={...}` type-check (each is a CustomEvent).
|
|
127
|
+
*
|
|
128
|
+
* @type {import('svelte/action').Action<HTMLElement, import('./types.js').SwipeableOptions | undefined, {
|
|
129
|
+
* onswipeLeft?: (event: CustomEvent<undefined>) => void,
|
|
130
|
+
* onswipeRight?: (event: CustomEvent<undefined>) => void,
|
|
131
|
+
* onswipeUp?: (event: CustomEvent<undefined>) => void,
|
|
132
|
+
* onswipeDown?: (event: CustomEvent<undefined>) => void
|
|
133
|
+
* }>}
|
|
128
134
|
*/
|
|
129
135
|
export function swipeable(node, options = defaultOptions) {
|
|
130
136
|
const track = {}
|
package/src/types.js
CHANGED
|
@@ -5,6 +5,26 @@
|
|
|
5
5
|
* @property {RegExp} [pattern] - The pattern that triggers the event
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Options for the `swipeable` action. All fields are optional; unspecified
|
|
10
|
+
* fields fall back to the action's internal defaults.
|
|
11
|
+
*
|
|
12
|
+
* @typedef {Object} SwipeableOptions
|
|
13
|
+
* @property {boolean} [horizontal] - Detect horizontal swipes (default true)
|
|
14
|
+
* @property {boolean} [vertical] - Detect vertical swipes (default false)
|
|
15
|
+
* @property {number} [threshold] - Minimum distance in px to register a swipe (default 100)
|
|
16
|
+
* @property {boolean} [enabled] - Whether the action is active (default true)
|
|
17
|
+
* @property {number} [minSpeed] - Minimum swipe speed in px/s (default 300)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} Coords
|
|
22
|
+
* @property {number} x - Current x position
|
|
23
|
+
* @property {number} y - Current y position
|
|
24
|
+
* @property {number} [dx] - Delta x since last event (panmove only)
|
|
25
|
+
* @property {number} [dy] - Delta y since last event (panmove only)
|
|
26
|
+
*/
|
|
27
|
+
|
|
8
28
|
/**
|
|
9
29
|
* @typedef {Object<string, (string[]|RegExp) >} KeyboardConfig
|
|
10
30
|
*/
|