verstak 0.24.124 → 0.24.127

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.
Files changed (37) hide show
  1. package/build/dist/source/archive/RxDomV1.js +1 -1
  2. package/build/dist/source/html/El.d.ts +2 -4
  3. package/build/dist/source/html/Elements.d.ts +3 -2
  4. package/build/dist/source/html/Elements.js +5 -2
  5. package/build/dist/source/html/Handlers.d.ts +6 -0
  6. package/build/dist/source/html/Handlers.js +55 -0
  7. package/build/dist/source/html/HtmlApiExt.d.ts +2 -0
  8. package/build/dist/source/html/HtmlApiExt.js +11 -1
  9. package/build/dist/source/html/api.d.ts +1 -1
  10. package/build/dist/source/html/api.js +1 -1
  11. package/build/dist/source/html/sensors/BasePointerSensor.d.ts +1 -1
  12. package/build/dist/source/html/sensors/BasePointerSensor.js +2 -2
  13. package/build/dist/source/html/sensors/ButtonSensor.d.ts +2 -2
  14. package/build/dist/source/html/sensors/ButtonSensor.js +18 -27
  15. package/build/dist/source/html/sensors/DataForSensor.d.ts +1 -0
  16. package/build/dist/source/html/sensors/DataForSensor.js +1 -0
  17. package/build/dist/source/html/sensors/FocusSensor.d.ts +2 -2
  18. package/build/dist/source/html/sensors/FocusSensor.js +14 -17
  19. package/build/dist/source/html/sensors/HoverSensor.d.ts +15 -4
  20. package/build/dist/source/html/sensors/HoverSensor.js +64 -23
  21. package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +2 -2
  22. package/build/dist/source/html/sensors/HtmlDragSensor.js +21 -30
  23. package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +3 -3
  24. package/build/dist/source/html/sensors/HtmlElementSensor.js +7 -4
  25. package/build/dist/source/html/sensors/HtmlSensors.d.ts +23 -11
  26. package/build/dist/source/html/sensors/HtmlSensors.js +81 -35
  27. package/build/dist/source/html/sensors/KeyboardSensor.d.ts +2 -2
  28. package/build/dist/source/html/sensors/KeyboardSensor.js +11 -20
  29. package/build/dist/source/html/sensors/PointerSensor.d.ts +3 -2
  30. package/build/dist/source/html/sensors/PointerSensor.js +21 -31
  31. package/build/dist/source/html/sensors/ScrollSensor.d.ts +12 -0
  32. package/build/dist/source/html/sensors/ScrollSensor.js +62 -0
  33. package/build/dist/source/html/sensors/WheelSensor.d.ts +2 -2
  34. package/build/dist/source/html/sensors/WheelSensor.js +10 -19
  35. package/package.json +11 -11
  36. package/build/dist/source/html/ReactingFocuser.d.ts +0 -2
  37. package/build/dist/source/html/ReactingFocuser.js +0 -20
@@ -12,17 +12,16 @@ import { SymDataForSensor } from "./DataForSensor.js";
12
12
  import { Sensor } from "./Sensor.js";
13
13
  import { WindowSensor } from "./WindowSensor.js";
14
14
  export class HtmlElementSensor extends Sensor {
15
- constructor(focusSensor, windowSensor) {
15
+ constructor(sourceElement, focusSensor, windowSensor) {
16
16
  super();
17
- this.sourceElement = undefined;
17
+ this.sourceElement = sourceElement;
18
18
  this.focusSensor = focusSensor;
19
19
  this.windowSensor = windowSensor;
20
20
  this.preventDefault = false;
21
21
  this.stopPropagation = false;
22
22
  }
23
23
  getDefaultSensorData() {
24
- const sourceElement = this.sourceElement;
25
- return sourceElement ? sourceElement[SymDataForSensor] : undefined;
24
+ return this.sourceElement[SymDataForSensor];
26
25
  }
27
26
  setPreventDefaultAndStopPropagation(e) {
28
27
  if (this.preventDefault) {
@@ -35,6 +34,10 @@ export class HtmlElementSensor extends Sensor {
35
34
  }
36
35
  }
37
36
  }
37
+ __decorate([
38
+ raw,
39
+ __metadata("design:type", Object)
40
+ ], HtmlElementSensor.prototype, "sourceElement", void 0);
38
41
  __decorate([
39
42
  raw,
40
43
  __metadata("design:type", Object)
@@ -5,18 +5,30 @@ import { KeyboardSensor } from "./KeyboardSensor.js";
5
5
  import { ButtonSensor } from "./ButtonSensor.js";
6
6
  import { ResizeSensor } from "./ResizeSensor.js";
7
7
  import { WheelSensor } from "./WheelSensor.js";
8
+ import { ScrollSensor } from "./ScrollSensor.js";
8
9
  import { WindowSensor } from "./WindowSensor.js";
9
10
  import { PointerSensor } from "./PointerSensor.js";
10
11
  export declare class HtmlSensors {
11
- readonly window: WindowSensor;
12
- readonly focus: FocusSensor;
13
- readonly hover: HoverSensor;
14
- readonly keyboard: KeyboardSensor;
15
- readonly wheel: WheelSensor;
16
- readonly resize: ResizeSensor;
17
- readonly htmlDrag: HtmlDragSensor;
18
- readonly button: ButtonSensor;
19
- readonly pointer: PointerSensor;
20
- constructor();
21
- listen(element: HTMLElement | undefined, enabled?: boolean): void;
12
+ private readonly _element;
13
+ private _window;
14
+ get window(): WindowSensor;
15
+ private _focus;
16
+ get focus(): FocusSensor;
17
+ private _hover;
18
+ get hover(): HoverSensor;
19
+ private _keyboard;
20
+ get keyboard(): KeyboardSensor;
21
+ private _wheel;
22
+ get wheel(): WheelSensor;
23
+ private _scroll;
24
+ get scroll(): ScrollSensor;
25
+ private _resize;
26
+ get resize(): ResizeSensor;
27
+ private _htmlDrag;
28
+ get htmlDrag(): HtmlDragSensor;
29
+ private _button;
30
+ get button(): ButtonSensor;
31
+ private _pointer;
32
+ get pointer(): PointerSensor;
33
+ constructor(element: HTMLElement | SVGElement);
22
34
  }
@@ -1,13 +1,3 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { transactional } from "reactronic";
11
1
  import { FocusSensor } from "./FocusSensor.js";
12
2
  import { HoverSensor } from "./HoverSensor.js";
13
3
  import { HtmlDragSensor } from "./HtmlDragSensor.js";
@@ -15,33 +5,89 @@ import { KeyboardSensor } from "./KeyboardSensor.js";
15
5
  import { ButtonSensor } from "./ButtonSensor.js";
16
6
  import { ResizeSensor } from "./ResizeSensor.js";
17
7
  import { WheelSensor } from "./WheelSensor.js";
8
+ import { ScrollSensor } from "./ScrollSensor.js";
18
9
  import { WindowSensor } from "./WindowSensor.js";
19
10
  import { PointerSensor } from "./PointerSensor.js";
20
11
  export class HtmlSensors {
21
- constructor() {
22
- this.window = new WindowSensor();
23
- this.focus = new FocusSensor(this.window);
24
- this.hover = new HoverSensor();
25
- this.keyboard = new KeyboardSensor();
26
- this.wheel = new WheelSensor();
27
- this.resize = new ResizeSensor();
28
- this.htmlDrag = new HtmlDragSensor(this.focus, this.window);
29
- this.button = new ButtonSensor(this.focus, this.window);
30
- this.pointer = new PointerSensor(this.focus, this.window);
31
- }
32
- listen(element, enabled = true) {
33
- this.focus.listen(element, enabled);
34
- this.hover.listen(element, enabled);
35
- this.keyboard.listen(element, enabled);
36
- this.wheel.listen(element, enabled);
37
- this.htmlDrag.listen(element, enabled);
38
- this.button.listen(element, enabled);
39
- this.pointer.listen(element, enabled);
12
+ get window() {
13
+ if (this._window === undefined) {
14
+ this._window = new WindowSensor();
15
+ }
16
+ return this._window;
17
+ }
18
+ get focus() {
19
+ if (this._focus === undefined) {
20
+ this._focus = new FocusSensor(this._element, this.window);
21
+ this._focus.listen();
22
+ }
23
+ return this._focus;
24
+ }
25
+ get hover() {
26
+ if (this._hover === undefined) {
27
+ this._hover = new HoverSensor(this._element);
28
+ this._hover.listen();
29
+ }
30
+ return this._hover;
31
+ }
32
+ get keyboard() {
33
+ if (this._keyboard === undefined) {
34
+ this._keyboard = new KeyboardSensor(this._element);
35
+ this._keyboard.listen();
36
+ }
37
+ return this._keyboard;
38
+ }
39
+ get wheel() {
40
+ if (this._wheel === undefined) {
41
+ this._wheel = new WheelSensor(this._element);
42
+ this._wheel.listen();
43
+ }
44
+ return this._wheel;
45
+ }
46
+ get scroll() {
47
+ if (this._scroll === undefined) {
48
+ this._scroll = new ScrollSensor(this._element);
49
+ this._scroll.listen();
50
+ }
51
+ return this._scroll;
52
+ }
53
+ get resize() {
54
+ if (this._resize === undefined) {
55
+ this._resize = new ResizeSensor();
56
+ }
57
+ return this._resize;
58
+ }
59
+ get htmlDrag() {
60
+ if (this._htmlDrag === undefined) {
61
+ this._htmlDrag = new HtmlDragSensor(this._element, this.focus, this.window);
62
+ this._htmlDrag.listen();
63
+ }
64
+ return this._htmlDrag;
65
+ }
66
+ get button() {
67
+ if (this._button === undefined) {
68
+ this._button = new ButtonSensor(this._element, this.focus, this.window);
69
+ this._button.listen();
70
+ }
71
+ return this._button;
72
+ }
73
+ get pointer() {
74
+ if (this._pointer === undefined) {
75
+ this._pointer = new PointerSensor(this._element, this.focus, this.window);
76
+ this._pointer.listen();
77
+ }
78
+ return this._pointer;
79
+ }
80
+ constructor(element) {
81
+ this._element = element;
82
+ this._window = undefined;
83
+ this._focus = undefined;
84
+ this._hover = undefined;
85
+ this._keyboard = undefined;
86
+ this._wheel = undefined;
87
+ this._scroll = undefined;
88
+ this._resize = undefined;
89
+ this._htmlDrag = undefined;
90
+ this._button = undefined;
91
+ this._pointer = undefined;
40
92
  }
41
93
  }
42
- __decorate([
43
- transactional,
44
- __metadata("design:type", Function),
45
- __metadata("design:paramtypes", [Object, Boolean]),
46
- __metadata("design:returntype", void 0)
47
- ], HtmlSensors.prototype, "listen", null);
@@ -20,8 +20,8 @@ export declare class KeyboardSensor extends HtmlElementSensor {
20
20
  down: string;
21
21
  up: string;
22
22
  modifiers: KeyboardModifiers;
23
- constructor();
24
- listen(element: HTMLElement | undefined, enabled?: boolean): void;
23
+ constructor(element: HTMLElement | SVGElement);
24
+ listen(enabled?: boolean): void;
25
25
  reset(): void;
26
26
  protected onKeyDown(e: KeyboardEvent): void;
27
27
  protected onKeyUp(e: KeyboardEvent): void;
@@ -29,24 +29,21 @@ export var KeyboardModifiers;
29
29
  KeyboardModifiers[KeyboardModifiers["AltMeta"] = 12] = "AltMeta";
30
30
  })(KeyboardModifiers || (KeyboardModifiers = {}));
31
31
  export class KeyboardSensor extends HtmlElementSensor {
32
- constructor() {
33
- super();
32
+ constructor(element) {
33
+ super(element);
34
34
  this.down = "";
35
35
  this.up = "";
36
36
  this.modifiers = KeyboardModifiers.None;
37
37
  }
38
- listen(element, enabled = true) {
39
- const existing = this.sourceElement;
40
- if (element !== existing) {
41
- if (existing) {
42
- existing.removeEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
43
- existing.removeEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
44
- }
45
- this.sourceElement = element;
46
- if (element && enabled) {
47
- element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
48
- element.addEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
49
- }
38
+ listen(enabled = true) {
39
+ const element = this.sourceElement;
40
+ if (enabled) {
41
+ element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
42
+ element.addEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
43
+ }
44
+ else {
45
+ element.removeEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
46
+ element.removeEventListener("keyup", this.onKeyUp.bind(this), { capture: true });
50
47
  }
51
48
  }
52
49
  reset() {
@@ -95,12 +92,6 @@ export class KeyboardSensor extends HtmlElementSensor {
95
92
  return modifier;
96
93
  }
97
94
  }
98
- __decorate([
99
- transactional,
100
- __metadata("design:type", Function),
101
- __metadata("design:paramtypes", [Object, Boolean]),
102
- __metadata("design:returntype", void 0)
103
- ], KeyboardSensor.prototype, "listen", null);
104
95
  __decorate([
105
96
  transactional,
106
97
  __metadata("design:type", Function),
@@ -34,10 +34,10 @@ export declare class PointerSensor extends BasePointerSensor {
34
34
  immediatePositionY: number;
35
35
  immediateModifiers: KeyboardModifiers;
36
36
  static readonly DraggingThreshold = 4;
37
- constructor(focusSensor: FocusSensor, windowSensor: WindowSensor);
37
+ constructor(element: HTMLElement | SVGElement, focusSensor: FocusSensor, windowSensor: WindowSensor);
38
38
  getData(): unknown;
39
39
  setData(value: unknown): void;
40
- listen(element: HTMLElement | undefined, enabled?: boolean): void;
40
+ listen(enabled?: boolean): void;
41
41
  protected onPointerDown(e: PointerEvent): void;
42
42
  protected onPointerMove(e: PointerEvent): void;
43
43
  protected onPointerUp(e: PointerEvent): void;
@@ -54,6 +54,7 @@ export declare class PointerSensor extends BasePointerSensor {
54
54
  protected cancelDragging(): void;
55
55
  protected reset(): void;
56
56
  protected updateClicking(e: PointerEvent): boolean;
57
+ private _getDefaultDataForSensor;
57
58
  protected updateDragTarget(e: PointerEvent): void;
58
59
  protected whenClickingOrDragging(): void;
59
60
  protected whenMoving(): void;
@@ -12,8 +12,8 @@ import { extractPointerButton, isPointerButtonDown, PointerButton, BasePointerSe
12
12
  import { findTargetElementData, SymDataForSensor } from "./DataForSensor.js";
13
13
  import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor.js";
14
14
  export class PointerSensor extends BasePointerSensor {
15
- constructor(focusSensor, windowSensor) {
16
- super(focusSensor, windowSensor);
15
+ constructor(element, focusSensor, windowSensor) {
16
+ super(element, focusSensor, windowSensor);
17
17
  this.hotPositionX = Infinity;
18
18
  this.hotPositionY = Infinity;
19
19
  this.pointerButton = PointerButton.None;
@@ -51,24 +51,16 @@ export class PointerSensor extends BasePointerSensor {
51
51
  setData(value) {
52
52
  this.draggingData = value;
53
53
  }
54
- listen(element, enabled = true) {
55
- const existing = this.sourceElement;
56
- if (element !== existing) {
57
- if (existing) {
58
- existing.removeEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
59
- existing.removeEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
60
- existing.removeEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
61
- existing.removeEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
62
- existing.removeEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
63
- }
64
- this.sourceElement = element;
65
- if (element && enabled) {
66
- element.addEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
67
- element.addEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
68
- element.addEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
69
- element.addEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
70
- element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
71
- }
54
+ listen(enabled = true) {
55
+ const element = this.sourceElement;
56
+ if (enabled) {
57
+ element.addEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
58
+ element.addEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
59
+ element.addEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
60
+ element.addEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
61
+ element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
62
+ }
63
+ else {
72
64
  }
73
65
  }
74
66
  onPointerDown(e) {
@@ -134,20 +126,20 @@ export class PointerSensor extends BasePointerSensor {
134
126
  this.immediatePositionY = e.clientY;
135
127
  }
136
128
  tryClickingOrDragging(e) {
137
- var _a;
129
+ var _a, _b;
138
130
  this.preventDefault = false;
139
131
  this.stopPropagation = false;
140
132
  const targetPath = e.composedPath();
141
133
  const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
142
134
  const { data, window } = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["click", "draggable"]);
143
- const clickable = data === null || data === void 0 ? void 0 : data.click;
135
+ const clickable = (_a = data === null || data === void 0 ? void 0 : data.click) !== null && _a !== void 0 ? _a : this._getDefaultDataForSensor(e);
144
136
  const draggable = data === null || data === void 0 ? void 0 : data.draggable;
145
137
  if (clickable || draggable) {
146
138
  this.clickable = clickable;
147
139
  this.clicking = clickable;
148
140
  this.draggableData = draggable;
149
141
  this.tryingDragging = draggable !== undefined;
150
- this.dragSource = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["drag"], true).data) === null || _a === void 0 ? void 0 : _a.drag;
142
+ this.dragSource = (_b = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["drag"], true).data) === null || _b === void 0 ? void 0 : _b.drag;
151
143
  this.pointerButton = extractPointerButton(e);
152
144
  this.startX = e.clientX;
153
145
  this.startY = e.clientY;
@@ -248,7 +240,8 @@ export class PointerSensor extends BasePointerSensor {
248
240
  var _a;
249
241
  const targetPath = e.composedPath();
250
242
  const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
251
- const clickable = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["click"]).data) === null || _a === void 0 ? void 0 : _a.click;
243
+ let clickable = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["click"]).data) === null || _a === void 0 ? void 0 : _a.click;
244
+ clickable = clickable !== null && clickable !== void 0 ? clickable : this._getDefaultDataForSensor(e);
252
245
  const isSameClickable = this.clickable === clickable;
253
246
  if (isSameClickable)
254
247
  this.clicking = clickable;
@@ -257,6 +250,9 @@ export class PointerSensor extends BasePointerSensor {
257
250
  this.immediatePositionY = e.clientY;
258
251
  return isSameClickable;
259
252
  }
253
+ _getDefaultDataForSensor(e) {
254
+ return e.currentTarget === this.sourceElement ? e.currentTarget : undefined;
255
+ }
260
256
  updateDragTarget(e) {
261
257
  const targetPath = e.composedPath();
262
258
  const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
@@ -302,12 +298,6 @@ __decorate([
302
298
  raw,
303
299
  __metadata("design:type", Boolean)
304
300
  ], PointerSensor.prototype, "dropAllowed", void 0);
305
- __decorate([
306
- transactional,
307
- __metadata("design:type", Function),
308
- __metadata("design:paramtypes", [Object, Boolean]),
309
- __metadata("design:returntype", void 0)
310
- ], PointerSensor.prototype, "listen", null);
311
301
  __decorate([
312
302
  transactional,
313
303
  options({ logging: LoggingLevel.Off }),
@@ -324,7 +314,7 @@ __decorate([
324
314
  ], PointerSensor.prototype, "tryClickingOrDragging", null);
325
315
  __decorate([
326
316
  transactional,
327
- options({ reentrance: Reentrance.CancelPrevious, logging: LoggingLevel.Off }),
317
+ options({ reentrance: Reentrance.cancelPrevious, logging: LoggingLevel.Off }),
328
318
  __metadata("design:type", Function),
329
319
  __metadata("design:paramtypes", [PointerEvent]),
330
320
  __metadata("design:returntype", void 0)
@@ -0,0 +1,12 @@
1
+ import { HtmlElementSensor } from "./HtmlElementSensor.js";
2
+ export declare class ScrollSensor extends HtmlElementSensor {
3
+ x: number;
4
+ y: number;
5
+ constructor(element: HTMLElement | SVGElement);
6
+ listen(enabled?: boolean): void;
7
+ reset(): void;
8
+ protected onScroll(e: Event): void;
9
+ protected doScroll(e: Event): void;
10
+ protected doReset(): void;
11
+ protected updateSensorData(e: Event): void;
12
+ }
@@ -0,0 +1,62 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { options, Reentrance, transactional, LoggingLevel } from "reactronic";
11
+ import { HtmlElementSensor } from "./HtmlElementSensor.js";
12
+ export class ScrollSensor extends HtmlElementSensor {
13
+ constructor(element) {
14
+ super(element);
15
+ this.x = Infinity;
16
+ this.y = Infinity;
17
+ }
18
+ listen(enabled = true) {
19
+ const element = this.sourceElement;
20
+ if (enabled) {
21
+ element.addEventListener("scroll", this.onScroll.bind(this), { capture: true, passive: true });
22
+ }
23
+ else {
24
+ element.removeEventListener("scroll", this.onScroll.bind(this), { capture: true });
25
+ }
26
+ }
27
+ reset() {
28
+ this.doReset();
29
+ }
30
+ onScroll(e) {
31
+ this.doScroll(e);
32
+ }
33
+ doScroll(e) {
34
+ this.updateSensorData(e);
35
+ }
36
+ doReset() {
37
+ this.preventDefault = false;
38
+ this.stopPropagation = false;
39
+ this.x = Infinity;
40
+ this.y = Infinity;
41
+ }
42
+ updateSensorData(e) {
43
+ this.preventDefault = false;
44
+ this.stopPropagation = false;
45
+ this.x = this.sourceElement.scrollLeft;
46
+ this.y = this.sourceElement.scrollTop;
47
+ this.revision++;
48
+ }
49
+ }
50
+ __decorate([
51
+ transactional,
52
+ __metadata("design:type", Function),
53
+ __metadata("design:paramtypes", []),
54
+ __metadata("design:returntype", void 0)
55
+ ], ScrollSensor.prototype, "reset", null);
56
+ __decorate([
57
+ transactional,
58
+ options({ reentrance: Reentrance.cancelPrevious, logging: LoggingLevel.Off }),
59
+ __metadata("design:type", Function),
60
+ __metadata("design:paramtypes", [Event]),
61
+ __metadata("design:returntype", void 0)
62
+ ], ScrollSensor.prototype, "doScroll", null);
@@ -3,8 +3,8 @@ export declare class WheelSensor extends BasePointerSensor {
3
3
  target: unknown;
4
4
  deltaX: number;
5
5
  deltaY: number;
6
- constructor();
7
- listen(element: HTMLElement | undefined, enabled?: boolean): void;
6
+ constructor(element: HTMLElement | SVGElement);
7
+ listen(enabled?: boolean): void;
8
8
  reset(): void;
9
9
  protected onWheel(e: WheelEvent): void;
10
10
  protected doWheel(e: WheelEvent): void;
@@ -12,23 +12,20 @@ import { findTargetElementData, SymDataForSensor } from "./DataForSensor.js";
12
12
  import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor.js";
13
13
  import { BasePointerSensor } from "./BasePointerSensor.js";
14
14
  export class WheelSensor extends BasePointerSensor {
15
- constructor() {
16
- super();
15
+ constructor(element) {
16
+ super(element);
17
17
  this.target = undefined;
18
18
  this.target = undefined;
19
19
  this.deltaX = Infinity;
20
20
  this.deltaY = Infinity;
21
21
  }
22
- listen(element, enabled = true) {
23
- const existing = this.sourceElement;
24
- if (element !== existing) {
25
- if (existing) {
26
- existing.removeEventListener("wheel", this.onWheel.bind(this), { capture: true });
27
- }
28
- this.sourceElement = element;
29
- if (element && enabled) {
30
- element.addEventListener("wheel", this.onWheel.bind(this), { capture: true, passive: true });
31
- }
22
+ listen(enabled = true) {
23
+ const element = this.sourceElement;
24
+ if (enabled) {
25
+ element.addEventListener("wheel", this.onWheel.bind(this), { capture: true, passive: true });
26
+ }
27
+ else {
28
+ element.removeEventListener("wheel", this.onWheel.bind(this), { capture: true });
32
29
  }
33
30
  }
34
31
  reset() {
@@ -65,12 +62,6 @@ export class WheelSensor extends BasePointerSensor {
65
62
  this.revision++;
66
63
  }
67
64
  }
68
- __decorate([
69
- transactional,
70
- __metadata("design:type", Function),
71
- __metadata("design:paramtypes", [Object, Boolean]),
72
- __metadata("design:returntype", void 0)
73
- ], WheelSensor.prototype, "listen", null);
74
65
  __decorate([
75
66
  transactional,
76
67
  __metadata("design:type", Function),
@@ -79,7 +70,7 @@ __decorate([
79
70
  ], WheelSensor.prototype, "reset", null);
80
71
  __decorate([
81
72
  transactional,
82
- options({ reentrance: Reentrance.CancelPrevious, logging: LoggingLevel.Off }),
73
+ options({ reentrance: Reentrance.cancelPrevious, logging: LoggingLevel.Off }),
83
74
  __metadata("design:type", Function),
84
75
  __metadata("design:paramtypes", [WheelEvent]),
85
76
  __metadata("design:returntype", void 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verstak",
3
- "version": "0.24.124",
3
+ "version": "0.24.127",
4
4
  "description": "Verstak - Front-End Library",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",
@@ -31,23 +31,23 @@
31
31
  },
32
32
  "homepage": "https://github.com/nezaboodka/verstak/blob/master/README.md#readme",
33
33
  "dependencies": {
34
- "reactronic": "^0.24.124"
34
+ "reactronic": "^0.24.127"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "20.10.4",
38
- "@typescript-eslint/eslint-plugin": "6.13.2",
39
- "@typescript-eslint/parser": "6.13.2",
40
- "ava": "5.3.1",
41
- "c8": "8.0.1",
42
- "eslint": "8.55.0",
37
+ "@types/node": "20.11.16",
38
+ "@typescript-eslint/eslint-plugin": "6.20.0",
39
+ "@typescript-eslint/parser": "6.20.0",
40
+ "ava": "6.1.1",
41
+ "c8": "9.1.0",
42
+ "eslint": "8.56.0",
43
43
  "ts-node": "10.9.2",
44
44
  "tsconfig-paths": "4.2.0",
45
45
  "typescript": "5.3.2"
46
46
  },
47
47
  "scripts": {
48
- "build": "eslint source/**/*.ts test/**/*.ts && tsc",
49
- "fix": "eslint --fix source/**/*.ts test/**/*.ts",
50
- "pack": "eslint source/**/*.ts test/**/*.ts && tsc --sourceMap false --removeComments true",
48
+ "build": "eslint source/**.ts test/**.ts && tsc",
49
+ "fix": "eslint --fix source/**.ts test/**.ts",
50
+ "pack": "eslint source/**.ts test/**.ts && tsc --sourceMap false --removeComments true",
51
51
  "test": "ava",
52
52
  "cover": "c8 ava && open build/coverage/index.html"
53
53
  }
@@ -1,2 +0,0 @@
1
- import { FocusModel } from "./sensors/FocusSensor.js";
2
- export declare function FocuserReaction(key: string, target: HTMLElement, model: FocusModel, switchEditMode?: ((model?: FocusModel) => void) | undefined): void;
@@ -1,20 +0,0 @@
1
- import { Mode } from "reactronic";
2
- import { PseudoElement } from "./Elements.js";
3
- export function FocuserReaction(key, target, model, switchEditMode = undefined) {
4
- PseudoElement({
5
- key,
6
- mode: Mode.IndependentUpdate,
7
- triggers: { target, model },
8
- initialize(b) {
9
- b.node.configureReactronic({ throttling: 0 });
10
- },
11
- update() {
12
- if (switchEditMode !== undefined) {
13
- switchEditMode(model);
14
- }
15
- else {
16
- model.isEditMode ? target.focus() : target.blur();
17
- }
18
- },
19
- });
20
- }