@ngutil/aria 0.0.71 → 0.0.73
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/esm2022/gestures/gesture-drag.mjs +3 -16
- package/esm2022/gestures/gesture-event.mjs +2 -1
- package/esm2022/gestures/gesture-longtap.mjs +3 -6
- package/esm2022/gestures/gesture-tap.mjs +12 -9
- package/esm2022/gestures/gesture.mjs +52 -14
- package/esm2022/gestures/gesture.service.mjs +11 -8
- package/fesm2022/ngutil-aria.mjs +77 -47
- package/fesm2022/ngutil-aria.mjs.map +1 -1
- package/gestures/gesture-drag.d.ts +9 -9
- package/gestures/gesture-event.d.ts +5 -3
- package/gestures/gesture-longtap.d.ts +9 -9
- package/gestures/gesture-tap.d.ts +7 -7
- package/gestures/gesture.d.ts +52 -11
- package/gestures/gesture.service.d.ts +2 -3
- package/package.json +3 -3
|
@@ -2,19 +2,19 @@ import { Observable } from "rxjs";
|
|
|
2
2
|
import { Mutable } from "utility-types";
|
|
3
3
|
import { Position } from "@ngutil/style";
|
|
4
4
|
import { Gesture, GestureCaptureState, GestureOptions } from "./gesture";
|
|
5
|
-
import {
|
|
6
|
-
export interface
|
|
5
|
+
import { GestureDetail } from "./gesture-event";
|
|
6
|
+
export interface GestureDragDetail extends GestureDetail<"gesture-drag"> {
|
|
7
7
|
moveBy: Position;
|
|
8
8
|
}
|
|
9
9
|
export type GestureDragOptions = GestureOptions<GestureDragImpl>;
|
|
10
|
-
export declare class GestureDragImpl extends Gesture<
|
|
10
|
+
export declare class GestureDragImpl<T extends GestureDragDetail = GestureDragDetail> extends Gesture<T> {
|
|
11
11
|
readonly horizontal?: boolean;
|
|
12
12
|
readonly vertical?: boolean;
|
|
13
13
|
constructor(options?: GestureDragOptions);
|
|
14
|
-
capture(events: Observable<
|
|
15
|
-
handle(events: Observable<
|
|
14
|
+
capture(events: Observable<GestureDetail>): Observable<GestureCaptureState>;
|
|
15
|
+
handle(events: Observable<GestureDetail>): Observable<Mutable<T>>;
|
|
16
16
|
}
|
|
17
|
-
export declare function gestureDrag(options?: GestureDragOptions): GestureDragImpl
|
|
18
|
-
export declare const GestureDarg: GestureDragImpl
|
|
19
|
-
export declare const GestureDargHorizontal: GestureDragImpl
|
|
20
|
-
export declare const GestureDargVertical: GestureDragImpl
|
|
17
|
+
export declare function gestureDrag(options?: GestureDragOptions): GestureDragImpl<GestureDragDetail>;
|
|
18
|
+
export declare const GestureDarg: GestureDragImpl<GestureDragDetail>;
|
|
19
|
+
export declare const GestureDargHorizontal: GestureDragImpl<GestureDragDetail>;
|
|
20
|
+
export declare const GestureDargVertical: GestureDragImpl<GestureDragDetail>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Position } from "@ngutil/style";
|
|
2
|
-
export type
|
|
2
|
+
export type GestureEvent<T extends GestureDetail> = T extends GestureDetail<infer N> ? CustomEvent<T> & {
|
|
3
3
|
type: N;
|
|
4
4
|
} : never;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
declare const PHANTOM: unique symbol;
|
|
6
|
+
export interface GestureDetail<T extends string = string> {
|
|
7
|
+
readonly [PHANTOM]: T;
|
|
7
8
|
readonly origin: GestureOrigin;
|
|
8
9
|
readonly target: HTMLElement;
|
|
9
10
|
readonly pointerType: GesturePointerType;
|
|
@@ -42,3 +43,4 @@ export interface GestureListenerConfig {
|
|
|
42
43
|
export declare const Listeners: {
|
|
43
44
|
[key: string]: GestureListenerConfig;
|
|
44
45
|
};
|
|
46
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { Gesture, GestureCaptureState, GestureOptions } from "./gesture";
|
|
3
|
-
import {
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export declare class GestureLongTapImpl extends Gesture<
|
|
7
|
-
constructor(options?:
|
|
8
|
-
capture(events: Observable<
|
|
9
|
-
handle(events: Observable<
|
|
3
|
+
import { GestureDetail } from "./gesture-event";
|
|
4
|
+
export type GestureLongTapDetail = GestureDetail<"gesture-longtap">;
|
|
5
|
+
export type GestureLongTapOptions = GestureOptions<GestureLongTapImpl>;
|
|
6
|
+
export declare class GestureLongTapImpl<T extends GestureLongTapDetail = GestureLongTapDetail> extends Gesture<T> {
|
|
7
|
+
constructor(options?: GestureLongTapOptions);
|
|
8
|
+
capture(events: Observable<GestureDetail>): Observable<GestureCaptureState>;
|
|
9
|
+
handle(events: Observable<GestureDetail>): Observable<import("utility-types").Mutable<T>>;
|
|
10
10
|
}
|
|
11
|
-
export declare function gestureLongTap(options?:
|
|
12
|
-
export declare const GestureLongTap: GestureLongTapImpl
|
|
11
|
+
export declare function gestureLongTap(options?: GestureLongTapOptions): GestureLongTapImpl<GestureLongTapDetail>;
|
|
12
|
+
export declare const GestureLongTap: GestureLongTapImpl<GestureLongTapDetail>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { Gesture, GestureCaptureState, GestureOptions } from "./gesture";
|
|
3
|
-
import {
|
|
4
|
-
export type
|
|
3
|
+
import { GestureDetail } from "./gesture-event";
|
|
4
|
+
export type GestureTapDetail = GestureDetail<"gesture-tap">;
|
|
5
5
|
export type GestureTapOptions = GestureOptions<GestureTapImpl>;
|
|
6
|
-
export declare class GestureTapImpl extends Gesture<
|
|
6
|
+
export declare class GestureTapImpl<T extends GestureTapDetail = GestureTapDetail> extends Gesture<T> {
|
|
7
7
|
constructor(options?: GestureTapOptions);
|
|
8
|
-
capture(events: Observable<
|
|
9
|
-
handle(events: Observable<
|
|
8
|
+
capture(events: Observable<GestureDetail>): Observable<GestureCaptureState>;
|
|
9
|
+
handle(events: Observable<GestureDetail>): Observable<import("utility-types").Mutable<T>>;
|
|
10
10
|
}
|
|
11
|
-
export declare function gestureTap(options?: GestureTapOptions): GestureTapImpl
|
|
12
|
-
export declare const GestureTap: GestureTapImpl
|
|
11
|
+
export declare function gestureTap(options?: GestureTapOptions): GestureTapImpl<GestureTapDetail>;
|
|
12
|
+
export declare const GestureTap: GestureTapImpl<GestureTapDetail>;
|
package/gestures/gesture.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { FunctionKeys, Mutable } from "utility-types";
|
|
3
|
-
import {
|
|
3
|
+
import { GestureDetail, GesturePointerType } from "./gesture-event";
|
|
4
4
|
export declare const enum GestureCaptureState {
|
|
5
5
|
Unchecked = 0,
|
|
6
6
|
Pending = 1,
|
|
@@ -8,28 +8,69 @@ export declare const enum GestureCaptureState {
|
|
|
8
8
|
Maybe = 3,
|
|
9
9
|
Instant = 4
|
|
10
10
|
}
|
|
11
|
-
type _GestureOptions = Partial<Omit<Gesture<any>, "
|
|
11
|
+
type _GestureOptions = Partial<Omit<Gesture<any>, "originTypes" | "name" | FunctionKeys<Gesture<any>>>>;
|
|
12
12
|
export type GestureOptions<T extends object> = Partial<Omit<T, keyof Gesture<any> | FunctionKeys<T>>> & _GestureOptions;
|
|
13
|
-
export declare abstract class Gesture<T extends
|
|
13
|
+
export declare abstract class Gesture<T extends GestureDetail = GestureDetail> {
|
|
14
14
|
readonly name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Gestures that depends on move distance, like drag, use this option
|
|
17
|
+
*/
|
|
15
18
|
readonly distanceInclusion = 10;
|
|
19
|
+
/**
|
|
20
|
+
* Gestures thet dependnso on time frame, like longtap, use this option
|
|
21
|
+
*/
|
|
16
22
|
readonly timeWithin = 300;
|
|
23
|
+
/**
|
|
24
|
+
* The priority of the gesture
|
|
25
|
+
*/
|
|
17
26
|
readonly priority = 0;
|
|
27
|
+
/**
|
|
28
|
+
* Should the gesture include the scroll distance
|
|
29
|
+
*/
|
|
18
30
|
readonly includeScrollDistance: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The pointer types of the gesture
|
|
33
|
+
*/
|
|
34
|
+
readonly pointerTypes: Array<GesturePointerType>;
|
|
35
|
+
/**
|
|
36
|
+
* The number of pointers of the gesture can handle
|
|
37
|
+
*/
|
|
38
|
+
readonly pointerCount: number;
|
|
39
|
+
/**
|
|
40
|
+
* The mouse buttons of the gesture (1 = left, 2 = middle, 3 = right)
|
|
41
|
+
*/
|
|
42
|
+
readonly mouseButtons: Array<number>;
|
|
43
|
+
/**
|
|
44
|
+
* The event types of the gesture can handle
|
|
45
|
+
*/
|
|
46
|
+
readonly originTypes: Array<string>;
|
|
47
|
+
constructor(name: string, options?: _GestureOptions);
|
|
23
48
|
/**
|
|
24
49
|
* Test if the gesture should be captured.
|
|
50
|
+
* The given events is filterde by {@see Gesture#shouldCapture}
|
|
25
51
|
* ! important, dont rely on this object state, because not always create a new object
|
|
52
|
+
* @param events events to check
|
|
26
53
|
*/
|
|
27
|
-
abstract capture(events: Observable<
|
|
54
|
+
abstract capture(events: Observable<GestureDetail>): Observable<GestureCaptureState>;
|
|
28
55
|
/**
|
|
29
|
-
* Transform input event, to gesture event
|
|
56
|
+
* Transform input event, to gesture event.
|
|
57
|
+
* The given events is filterde by {@see Gesture#isRelevantEvent}
|
|
30
58
|
* ! important, dont rely on this object state, because not always create a new object
|
|
59
|
+
* @param events events to transform or filter or leave as is
|
|
60
|
+
*/
|
|
61
|
+
handle(events: Observable<GestureDetail>): Observable<Mutable<T>>;
|
|
62
|
+
/**
|
|
63
|
+
* Should this gesture capture the event?
|
|
64
|
+
* @param event event to check
|
|
65
|
+
* @returns true if the gesture should capture the event, false otherwise
|
|
66
|
+
*/
|
|
67
|
+
shouldCapture(event: GestureDetail): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Test if the event is relevant to the gesture.
|
|
70
|
+
* The event is relevant if
|
|
71
|
+
* @param event event to check
|
|
72
|
+
* @returns true if the event is relevant, false otherwise
|
|
31
73
|
*/
|
|
32
|
-
|
|
33
|
-
filterByEvent: <T_1 extends GestureEvent>(event: T_1) => event is T_1;
|
|
74
|
+
isRelevantEvent(event: GestureDetail): boolean;
|
|
34
75
|
}
|
|
35
76
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { ElementInput } from "@ngutil/common";
|
|
3
3
|
import { Gesture } from "./gesture";
|
|
4
|
-
import {
|
|
4
|
+
import { GestureEvent } from "./gesture-event";
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
type GesturesToEventsType<T extends Array<Gesture>> = T extends Array<infer G> ? (G extends Gesture<infer E> ? E : never) : never;
|
|
7
7
|
type GestureEventDiscriminator<T> = T extends {
|
|
@@ -10,12 +10,11 @@ type GestureEventDiscriminator<T> = T extends {
|
|
|
10
10
|
type: N;
|
|
11
11
|
} & T : never;
|
|
12
12
|
export type GestureWatchReturns<T extends Array<Gesture>> = Observable<GestureEventDiscriminator<GesturesToEventsType<T>>>;
|
|
13
|
-
export type GestureListenReturns<T extends Array<Gesture>> = Observable<
|
|
13
|
+
export type GestureListenReturns<T extends Array<Gesture>> = Observable<GestureEvent<GesturesToEventsType<T>>>;
|
|
14
14
|
export declare class GestureService {
|
|
15
15
|
#private;
|
|
16
16
|
constructor();
|
|
17
17
|
listen<T extends Array<Gesture>>(el: ElementInput, ...gestures: T): GestureListenReturns<T>;
|
|
18
|
-
watch<T extends Array<Gesture>>(el: ElementInput, ...gestures: T): GestureWatchReturns<T>;
|
|
19
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<GestureService, never>;
|
|
20
19
|
static ɵprov: i0.ɵɵInjectableDeclaration<GestureService>;
|
|
21
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngutil/aria",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/cdk": "18.2.6",
|
|
6
6
|
"@angular/common": "18.2.6",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"rxjs": "^7.8.1",
|
|
10
10
|
"tabbable": "^6.2.0",
|
|
11
11
|
"utility-types": "^3.11.0",
|
|
12
|
-
"@ngutil/
|
|
13
|
-
"@ngutil/
|
|
12
|
+
"@ngutil/common": "0.0.73",
|
|
13
|
+
"@ngutil/style": "0.0.73"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public",
|