@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.
@@ -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 { GestureEvent } from "./gesture-event";
6
- export interface GestureDragEvent extends GestureEvent<"gesture-drag"> {
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<GestureDragEvent> {
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<GestureEvent>): Observable<GestureCaptureState>;
15
- handle(events: Observable<GestureEvent>): Observable<Mutable<GestureDragEvent>>;
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 GestureDomEvent<T extends GestureEvent> = T extends GestureEvent<infer N> ? CustomEvent<T> & {
2
+ export type GestureEvent<T extends GestureDetail> = T extends GestureDetail<infer N> ? CustomEvent<T> & {
3
3
  type: N;
4
4
  } : never;
5
- export interface GestureEvent<T extends string = string> {
6
- readonly type: T;
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 { GestureEvent } from "./gesture-event";
4
- export type GestureLongtapEvent = GestureEvent<"gesture-longtap">;
5
- export type GestureLongtapOptions = GestureOptions<GestureLongTapImpl>;
6
- export declare class GestureLongTapImpl extends Gesture<GestureLongtapEvent> {
7
- constructor(options?: GestureLongtapOptions);
8
- capture(events: Observable<GestureEvent>): Observable<GestureCaptureState>;
9
- handle(events: Observable<GestureEvent>): Observable<import("utility-types").Mutable<GestureLongtapEvent>>;
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?: GestureLongtapOptions): GestureLongTapImpl;
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 { GestureEvent } from "./gesture-event";
4
- export type GestureTapEvent = GestureEvent<"gesture-tap">;
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<GestureTapEvent> {
6
+ export declare class GestureTapImpl<T extends GestureTapDetail = GestureTapDetail> extends Gesture<T> {
7
7
  constructor(options?: GestureTapOptions);
8
- capture(events: Observable<GestureEvent>): Observable<GestureCaptureState>;
9
- handle(events: Observable<GestureEvent>): Observable<import("utility-types").Mutable<GestureTapEvent>>;
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>;
@@ -1,6 +1,6 @@
1
1
  import { Observable } from "rxjs";
2
2
  import { FunctionKeys, Mutable } from "utility-types";
3
- import { GestureEvent, GesturePointerType } from "./gesture-event";
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>, "filterListeners" | "name" | FunctionKeys<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 GestureEvent = GestureEvent> {
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
- readonly filterPointerTypes: Array<GesturePointerType>;
20
- readonly filterMouseButtons: Array<number>;
21
- readonly filterListeners: Array<keyof DocumentEventMap>;
22
- constructor(name: string, listeners: Array<keyof DocumentEventMap>, options?: _GestureOptions);
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<GestureEvent>): Observable<GestureCaptureState>;
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
- handle(events: Observable<GestureEvent>): Observable<Mutable<T>>;
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 { GestureDomEvent } from "./gesture-event";
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<GestureDomEvent<GesturesToEventsType<T>>>;
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.71",
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/style": "0.0.71",
13
- "@ngutil/common": "0.0.71"
12
+ "@ngutil/common": "0.0.73",
13
+ "@ngutil/style": "0.0.73"
14
14
  },
15
15
  "publishConfig": {
16
16
  "access": "public",