verstak 0.24.125 → 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.
- package/build/dist/source/archive/RxDomV1.js +1 -1
- package/build/dist/source/html/El.d.ts +2 -4
- package/build/dist/source/html/Elements.d.ts +3 -2
- package/build/dist/source/html/Elements.js +5 -2
- package/build/dist/source/html/Handlers.d.ts +6 -0
- package/build/dist/source/html/Handlers.js +55 -0
- package/build/dist/source/html/HtmlApiExt.d.ts +2 -0
- package/build/dist/source/html/HtmlApiExt.js +11 -1
- package/build/dist/source/html/api.d.ts +1 -1
- package/build/dist/source/html/api.js +1 -1
- package/build/dist/source/html/sensors/BasePointerSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/BasePointerSensor.js +2 -2
- package/build/dist/source/html/sensors/ButtonSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/ButtonSensor.js +18 -27
- package/build/dist/source/html/sensors/DataForSensor.d.ts +1 -0
- package/build/dist/source/html/sensors/DataForSensor.js +1 -0
- package/build/dist/source/html/sensors/FocusSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/FocusSensor.js +14 -17
- package/build/dist/source/html/sensors/HoverSensor.d.ts +15 -4
- package/build/dist/source/html/sensors/HoverSensor.js +64 -23
- package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/HtmlDragSensor.js +21 -30
- package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/HtmlElementSensor.js +7 -4
- package/build/dist/source/html/sensors/HtmlSensors.d.ts +23 -11
- package/build/dist/source/html/sensors/HtmlSensors.js +81 -35
- package/build/dist/source/html/sensors/KeyboardSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/KeyboardSensor.js +11 -20
- package/build/dist/source/html/sensors/PointerSensor.d.ts +3 -2
- package/build/dist/source/html/sensors/PointerSensor.js +21 -31
- package/build/dist/source/html/sensors/ScrollSensor.d.ts +12 -0
- package/build/dist/source/html/sensors/ScrollSensor.js +62 -0
- package/build/dist/source/html/sensors/WheelSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/WheelSensor.js +10 -19
- package/package.json +8 -8
- package/build/dist/source/html/ReactingFocuser.d.ts +0 -2
- package/build/dist/source/html/ReactingFocuser.js +0 -20
|
@@ -2,12 +2,10 @@ import { RxNode, BaseDriver } from "reactronic";
|
|
|
2
2
|
export declare class ElDriver<T extends Element, M = unknown> extends BaseDriver<El<T, M>> {
|
|
3
3
|
allocate(node: RxNode<El<T, M>>): El<T, M>;
|
|
4
4
|
}
|
|
5
|
-
export type
|
|
5
|
+
export type El<T = any, M = any> = {
|
|
6
6
|
readonly node: RxNode<El<T, M>>;
|
|
7
|
-
model: M;
|
|
8
|
-
};
|
|
9
|
-
export type El<T = any, M = any> = BaseEl<T, M> & {
|
|
10
7
|
native: T;
|
|
8
|
+
model: M;
|
|
11
9
|
kind: ElKind;
|
|
12
10
|
area: ElArea;
|
|
13
11
|
widthGrowth: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RxNodeDecl, RxNode } from "reactronic";
|
|
1
|
+
import { RxNodeDecl, RxNode, Delegate } from "reactronic";
|
|
2
2
|
import { El, ElArea } from "./El.js";
|
|
3
3
|
import { HtmlElementDriver } from "./HtmlDriver.js";
|
|
4
4
|
export declare function Section<M = unknown>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
|
|
@@ -9,7 +9,8 @@ export declare function cursor(areaParams: ElArea): void;
|
|
|
9
9
|
export declare function Note(content: string, declaration?: RxNodeDecl<El<HTMLElement, void>>): RxNode<El<HTMLElement, void>>;
|
|
10
10
|
export declare function HtmlNote(content: string, declaration?: RxNodeDecl<El<HTMLElement, void>>): RxNode<El<HTMLElement, void>>;
|
|
11
11
|
export declare function Group<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function Handler<M = unknown>(update: Delegate<El<void, M>>): RxNode<El<void, M>>;
|
|
13
|
+
export declare function SyntheticElement<M = unknown>(declaration?: RxNodeDecl<El<void, M>>, preset?: RxNodeDecl<El<void, M>>): RxNode<El<void, M>>;
|
|
13
14
|
export declare class VerstakElementDriver<T extends HTMLElement> extends HtmlElementDriver<T> {
|
|
14
15
|
update(node: RxNode<El<T>>): void | Promise<void>;
|
|
15
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RxNode } from "reactronic";
|
|
1
|
+
import { RxNode, Mode } from "reactronic";
|
|
2
2
|
import { Constants, CursorCommandDriver, ElKind, ElDriver } from "./El.js";
|
|
3
3
|
import { HtmlElementDriver } from "./HtmlDriver.js";
|
|
4
4
|
export function Section(declaration, preset) {
|
|
@@ -38,7 +38,10 @@ export function HtmlNote(content, declaration) {
|
|
|
38
38
|
export function Group(declaration, preset) {
|
|
39
39
|
return RxNode.acquire(Drivers.group, declaration, preset);
|
|
40
40
|
}
|
|
41
|
-
export function
|
|
41
|
+
export function Handler(update) {
|
|
42
|
+
return SyntheticElement({ mode: Mode.independentUpdate, update });
|
|
43
|
+
}
|
|
44
|
+
export function SyntheticElement(declaration, preset) {
|
|
42
45
|
return RxNode.acquire(Drivers.pseudo, declaration, preset);
|
|
43
46
|
}
|
|
44
47
|
export class VerstakElementDriver extends HtmlElementDriver {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ToggleRef } from "reactronic";
|
|
2
|
+
import { FocusModel } from "./sensors/FocusSensor.js";
|
|
3
|
+
import { ResizedElement } from "./sensors/ResizeSensor.js";
|
|
4
|
+
export declare function OnClick(target: HTMLElement, action: (() => void) | ToggleRef | undefined, key?: string): void;
|
|
5
|
+
export declare function OnResize(target: HTMLElement, action: ((element: ResizedElement) => void) | undefined, key?: string): void;
|
|
6
|
+
export declare function OnFocus(target: HTMLElement, model: FocusModel, switchEditMode?: ((model?: FocusModel) => void) | undefined, key?: string): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Mode, ToggleRef, unobs } from "reactronic";
|
|
2
|
+
import { SyntheticElement } from "./Elements.js";
|
|
3
|
+
export function OnClick(target, action, key) {
|
|
4
|
+
if (action !== undefined) {
|
|
5
|
+
SyntheticElement({
|
|
6
|
+
key,
|
|
7
|
+
mode: Mode.independentUpdate,
|
|
8
|
+
triggers: { target },
|
|
9
|
+
update() {
|
|
10
|
+
const pointer = target.sensors.pointer;
|
|
11
|
+
if (pointer.clicked) {
|
|
12
|
+
if (action instanceof Function) {
|
|
13
|
+
unobs(() => action());
|
|
14
|
+
}
|
|
15
|
+
else if (action instanceof ToggleRef) {
|
|
16
|
+
unobs(() => action.toggle());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function OnResize(target, action, key) {
|
|
24
|
+
if (action) {
|
|
25
|
+
SyntheticElement({
|
|
26
|
+
key,
|
|
27
|
+
mode: Mode.independentUpdate,
|
|
28
|
+
triggers: { target },
|
|
29
|
+
update() {
|
|
30
|
+
const resize = target.sensors.resize;
|
|
31
|
+
resize.resizedElements.forEach(x => {
|
|
32
|
+
action(x);
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function OnFocus(target, model, switchEditMode = undefined, key) {
|
|
39
|
+
SyntheticElement({
|
|
40
|
+
key,
|
|
41
|
+
mode: Mode.independentUpdate,
|
|
42
|
+
triggers: { target, model },
|
|
43
|
+
initialize(b) {
|
|
44
|
+
b.node.configureReactronic({ throttling: 0 });
|
|
45
|
+
},
|
|
46
|
+
update() {
|
|
47
|
+
if (switchEditMode !== undefined) {
|
|
48
|
+
switchEditMode(model);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
model.isEditMode ? target.focus() : target.blur();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { SymDataForSensor, SymResizeObserver } from "./sensors/DataForSensor.js";
|
|
1
|
+
import { SymDataForSensor, SymHtmlSensors, SymResizeObserver } from "./sensors/DataForSensor.js";
|
|
2
|
+
import { HtmlSensors } from "./sensors/HtmlSensors.js";
|
|
2
3
|
const ElementType = global.Element;
|
|
3
4
|
if (ElementType !== undefined) {
|
|
5
|
+
Object.defineProperty(ElementType.prototype, "sensors", {
|
|
6
|
+
configurable: false, enumerable: false,
|
|
7
|
+
get() {
|
|
8
|
+
let result = this[SymHtmlSensors];
|
|
9
|
+
if (result === undefined)
|
|
10
|
+
result = this[SymHtmlSensors] = new HtmlSensors(this);
|
|
11
|
+
return result;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
4
14
|
Object.defineProperty(ElementType.prototype, "dataForSensor", {
|
|
5
15
|
configurable: false, enumerable: false,
|
|
6
16
|
get() {
|
|
@@ -4,7 +4,7 @@ export * from "./HtmlDriver.js";
|
|
|
4
4
|
export * from "./HtmlElements.js";
|
|
5
5
|
export * from "./HtmlApiExt.js";
|
|
6
6
|
export * from "./Elements.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./Handlers.js";
|
|
8
8
|
export * from "./sensors/Sensor.js";
|
|
9
9
|
export * from "./sensors/PointerSensor.js";
|
|
10
10
|
export * from "./sensors/BasePointerSensor.js";
|
|
@@ -4,7 +4,7 @@ export * from "./HtmlDriver.js";
|
|
|
4
4
|
export * from "./HtmlElements.js";
|
|
5
5
|
export * from "./HtmlApiExt.js";
|
|
6
6
|
export * from "./Elements.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./Handlers.js";
|
|
8
8
|
export * from "./sensors/Sensor.js";
|
|
9
9
|
export * from "./sensors/PointerSensor.js";
|
|
10
10
|
export * from "./sensors/BasePointerSensor.js";
|
|
@@ -12,7 +12,7 @@ export declare class BasePointerSensor extends HtmlElementSensor {
|
|
|
12
12
|
positionX: number;
|
|
13
13
|
positionY: number;
|
|
14
14
|
modifiers: KeyboardModifiers;
|
|
15
|
-
constructor(focusSensor?: FocusSensor, windowSensor?: WindowSensor);
|
|
15
|
+
constructor(element: HTMLElement | SVGElement, focusSensor?: FocusSensor, windowSensor?: WindowSensor);
|
|
16
16
|
}
|
|
17
17
|
export declare function extractPointerButton(e: MouseEvent): PointerButton;
|
|
18
18
|
export declare function isPointerButtonDown(button: PointerButton, buttonsMask: number): boolean;
|
|
@@ -8,8 +8,8 @@ export var PointerButton;
|
|
|
8
8
|
PointerButton[PointerButton["Middle"] = 4] = "Middle";
|
|
9
9
|
})(PointerButton || (PointerButton = {}));
|
|
10
10
|
export class BasePointerSensor extends HtmlElementSensor {
|
|
11
|
-
constructor(focusSensor, windowSensor) {
|
|
12
|
-
super(focusSensor, windowSensor);
|
|
11
|
+
constructor(element, focusSensor, windowSensor) {
|
|
12
|
+
super(element, focusSensor, windowSensor);
|
|
13
13
|
this.positionX = Infinity;
|
|
14
14
|
this.positionY = Infinity;
|
|
15
15
|
this.modifiers = KeyboardModifiers.None;
|
|
@@ -15,8 +15,8 @@ export declare class ButtonSensor extends BasePointerSensor {
|
|
|
15
15
|
selectedX: number;
|
|
16
16
|
selectedY: number;
|
|
17
17
|
selected: boolean;
|
|
18
|
-
constructor(focusSensor: FocusSensor, windowSensor: WindowSensor);
|
|
19
|
-
listen(
|
|
18
|
+
constructor(element: HTMLElement | SVGElement, focusSensor: FocusSensor, windowSensor: WindowSensor);
|
|
19
|
+
listen(enabled?: boolean): void;
|
|
20
20
|
protected onPointerDown(e: PointerEvent): void;
|
|
21
21
|
protected onPointerMove(e: PointerEvent): void;
|
|
22
22
|
protected onPointerUp(e: PointerEvent): void;
|
|
@@ -19,8 +19,8 @@ export var ButtonState;
|
|
|
19
19
|
ButtonState[ButtonState["Released"] = 3] = "Released";
|
|
20
20
|
})(ButtonState || (ButtonState = {}));
|
|
21
21
|
export class ButtonSensor extends BasePointerSensor {
|
|
22
|
-
constructor(focusSensor, windowSensor) {
|
|
23
|
-
super(focusSensor, windowSensor);
|
|
22
|
+
constructor(element, focusSensor, windowSensor) {
|
|
23
|
+
super(element, focusSensor, windowSensor);
|
|
24
24
|
this.state = ButtonState.Released;
|
|
25
25
|
this.pointerButton = PointerButton.None;
|
|
26
26
|
this.originData = undefined;
|
|
@@ -29,24 +29,21 @@ export class ButtonSensor extends BasePointerSensor {
|
|
|
29
29
|
this.selectedY = Infinity;
|
|
30
30
|
this.selected = false;
|
|
31
31
|
}
|
|
32
|
-
listen(
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
element.addEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
|
|
48
|
-
element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
49
|
-
}
|
|
32
|
+
listen(enabled = true) {
|
|
33
|
+
const element = this.sourceElement;
|
|
34
|
+
if (enabled) {
|
|
35
|
+
element.addEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
|
|
36
|
+
element.addEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
|
|
37
|
+
element.addEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
|
|
38
|
+
element.addEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
|
|
39
|
+
element.addEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
element.removeEventListener("pointerdown", this.onPointerDown.bind(this), { capture: true });
|
|
43
|
+
element.removeEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
|
|
44
|
+
element.removeEventListener("pointerup", this.onPointerUp.bind(this), { capture: true });
|
|
45
|
+
element.removeEventListener("lostpointercapture", this.onLostPointerCapture.bind(this), { capture: true });
|
|
46
|
+
element.removeEventListener("keydown", this.onKeyDown.bind(this), { capture: true });
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
onPointerDown(e) {
|
|
@@ -161,12 +158,6 @@ export class ButtonSensor extends BasePointerSensor {
|
|
|
161
158
|
this.revision++;
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
__decorate([
|
|
165
|
-
transactional,
|
|
166
|
-
__metadata("design:type", Function),
|
|
167
|
-
__metadata("design:paramtypes", [Object, Boolean]),
|
|
168
|
-
__metadata("design:returntype", void 0)
|
|
169
|
-
], ButtonSensor.prototype, "listen", null);
|
|
170
161
|
__decorate([
|
|
171
162
|
transactional,
|
|
172
163
|
options({ logging: LoggingLevel.Off }),
|
|
@@ -176,7 +167,7 @@ __decorate([
|
|
|
176
167
|
], ButtonSensor.prototype, "press", null);
|
|
177
168
|
__decorate([
|
|
178
169
|
transactional,
|
|
179
|
-
options({ reentrance: Reentrance.
|
|
170
|
+
options({ reentrance: Reentrance.cancelPrevious, logging: LoggingLevel.Off }),
|
|
180
171
|
__metadata("design:type", Function),
|
|
181
172
|
__metadata("design:paramtypes", [PointerEvent]),
|
|
182
173
|
__metadata("design:returntype", void 0)
|
|
@@ -13,6 +13,7 @@ export type DataForSensor = {
|
|
|
13
13
|
htmlDraggable?: unknown;
|
|
14
14
|
button?: unknown;
|
|
15
15
|
};
|
|
16
|
+
export declare const SymHtmlSensors: unique symbol;
|
|
16
17
|
export declare const SymDataForSensor: unique symbol;
|
|
17
18
|
export declare const SymResizeObserver: unique symbol;
|
|
18
19
|
export declare const EmptyDataArray: any[];
|
|
@@ -15,9 +15,9 @@ export declare class FocusSensor extends HtmlElementSensor {
|
|
|
15
15
|
activeData: unknown;
|
|
16
16
|
oldActiveData: unknown;
|
|
17
17
|
contextElementDataList: unknown[];
|
|
18
|
-
constructor(windowSensor: WindowSensor);
|
|
18
|
+
constructor(element: HTMLElement | SVGElement, windowSensor: WindowSensor);
|
|
19
19
|
setActiveData(data: unknown, debugHint?: string): void;
|
|
20
|
-
listen(
|
|
20
|
+
listen(enabled?: boolean): void;
|
|
21
21
|
reset(): void;
|
|
22
22
|
protected onFocusIn(e: FocusEvent): void;
|
|
23
23
|
protected onFocusOut(e: FocusEvent): void;
|
|
@@ -12,8 +12,8 @@ import { objectHasMember } from "../ElUtils.js";
|
|
|
12
12
|
import { grabElementDataList, SymDataForSensor } from "./DataForSensor.js";
|
|
13
13
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
14
14
|
export class FocusSensor extends HtmlElementSensor {
|
|
15
|
-
constructor(windowSensor) {
|
|
16
|
-
super(undefined, windowSensor);
|
|
15
|
+
constructor(element, windowSensor) {
|
|
16
|
+
super(element, undefined, windowSensor);
|
|
17
17
|
this.activeData = undefined;
|
|
18
18
|
this.oldActiveData = undefined;
|
|
19
19
|
this.contextElementDataList = [];
|
|
@@ -36,20 +36,17 @@ export class FocusSensor extends HtmlElementSensor {
|
|
|
36
36
|
this.activeData = data;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
listen(
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
element.addEventListener("focusout", this.onFocusOut.bind(this), { capture: true });
|
|
51
|
-
element.addEventListener("mousedown", this.onMouseDown.bind(this), { capture: true });
|
|
52
|
-
}
|
|
39
|
+
listen(enabled = true) {
|
|
40
|
+
const element = this.sourceElement;
|
|
41
|
+
if (enabled) {
|
|
42
|
+
element.addEventListener("focusin", this.onFocusIn.bind(this), { capture: true });
|
|
43
|
+
element.addEventListener("focusout", this.onFocusOut.bind(this), { capture: true });
|
|
44
|
+
element.addEventListener("mousedown", this.onMouseDown.bind(this), { capture: true });
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
element.removeEventListener("focusin", this.onFocusIn.bind(this), { capture: true });
|
|
48
|
+
element.removeEventListener("focusout", this.onFocusOut.bind(this), { capture: true });
|
|
49
|
+
element.removeEventListener("mousedown", this.onMouseDown.bind(this), { capture: true });
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
reset() {
|
|
@@ -138,7 +135,7 @@ __decorate([
|
|
|
138
135
|
__decorate([
|
|
139
136
|
transactional,
|
|
140
137
|
__metadata("design:type", Function),
|
|
141
|
-
__metadata("design:paramtypes", [
|
|
138
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
142
139
|
__metadata("design:returntype", void 0)
|
|
143
140
|
], FocusSensor.prototype, "listen", null);
|
|
144
141
|
__decorate([
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { BasePointerSensor } from "./BasePointerSensor.js";
|
|
2
|
+
export type IHoverable = {
|
|
3
|
+
isHovered: boolean;
|
|
4
|
+
onHoverStart?: (hover: HoverSensor) => void;
|
|
5
|
+
onHoverEnd?: (hover: HoverSensor) => void;
|
|
6
|
+
};
|
|
2
7
|
export declare class HoverSensor extends BasePointerSensor {
|
|
8
|
+
isHovered: boolean;
|
|
3
9
|
target: unknown;
|
|
4
|
-
constructor();
|
|
5
|
-
listen(
|
|
10
|
+
constructor(element: HTMLElement | SVGElement);
|
|
11
|
+
listen(enabled?: boolean): void;
|
|
12
|
+
protected onPointerEnter(e: PointerEvent): void;
|
|
6
13
|
protected onPointerOver(e: PointerEvent): void;
|
|
7
|
-
protected
|
|
14
|
+
protected onPointerMove(e: PointerEvent): void;
|
|
15
|
+
protected onPointerLeave(e: PointerEvent): void;
|
|
16
|
+
protected doPointerEnter(e: PointerEvent): void;
|
|
8
17
|
protected doPointerOver(e: PointerEvent): void;
|
|
9
|
-
protected
|
|
18
|
+
protected doPointerMove(e: PointerEvent): void;
|
|
19
|
+
protected doPointerLeave(e: PointerEvent): void;
|
|
20
|
+
protected reset(): void;
|
|
10
21
|
}
|
|
@@ -8,34 +8,48 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { options, transactional, LoggingLevel } from "reactronic";
|
|
11
|
-
import {
|
|
12
|
-
import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor.js";
|
|
11
|
+
import { SymDataForSensor, findTargetElementData } from "./DataForSensor.js";
|
|
13
12
|
import { BasePointerSensor } from "./BasePointerSensor.js";
|
|
13
|
+
import { KeyboardModifiers, extractModifierKeys } from "./KeyboardSensor.js";
|
|
14
14
|
export class HoverSensor extends BasePointerSensor {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
15
|
+
constructor(element) {
|
|
16
|
+
super(element);
|
|
17
17
|
this.target = undefined;
|
|
18
|
+
this.isHovered = false;
|
|
18
19
|
this.target = undefined;
|
|
19
20
|
}
|
|
20
|
-
listen(
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.sourceElement = element;
|
|
28
|
-
if (element && enabled) {
|
|
29
|
-
element.addEventListener("pointerover", this.onPointerOver.bind(this), { capture: true });
|
|
30
|
-
element.addEventListener("pointerout", this.onPointerOut.bind(this), { capture: true });
|
|
31
|
-
}
|
|
21
|
+
listen(enabled = true) {
|
|
22
|
+
const element = this.sourceElement;
|
|
23
|
+
if (enabled) {
|
|
24
|
+
element.addEventListener("pointerenter", this.onPointerEnter.bind(this));
|
|
25
|
+
element.addEventListener("pointerover", this.onPointerOver.bind(this), { capture: true });
|
|
26
|
+
element.addEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
|
|
27
|
+
element.addEventListener("pointerleave", this.onPointerLeave.bind(this));
|
|
32
28
|
}
|
|
29
|
+
else {
|
|
30
|
+
element.removeEventListener("pointerenter", this.onPointerEnter.bind(this));
|
|
31
|
+
element.removeEventListener("pointerover", this.onPointerOver.bind(this), { capture: true });
|
|
32
|
+
element.removeEventListener("pointermove", this.onPointerMove.bind(this), { capture: true });
|
|
33
|
+
element.removeEventListener("pointerleave", this.onPointerLeave.bind(this));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
onPointerEnter(e) {
|
|
37
|
+
this.doPointerEnter(e);
|
|
33
38
|
}
|
|
34
39
|
onPointerOver(e) {
|
|
35
40
|
this.doPointerOver(e);
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
this.
|
|
42
|
+
onPointerMove(e) {
|
|
43
|
+
this.doPointerMove(e);
|
|
44
|
+
}
|
|
45
|
+
onPointerLeave(e) {
|
|
46
|
+
this.doPointerLeave(e);
|
|
47
|
+
}
|
|
48
|
+
doPointerEnter(e) {
|
|
49
|
+
this.preventDefault = false;
|
|
50
|
+
this.stopPropagation = false;
|
|
51
|
+
this.isHovered = true;
|
|
52
|
+
this.revision++;
|
|
39
53
|
}
|
|
40
54
|
doPointerOver(e) {
|
|
41
55
|
var _a;
|
|
@@ -49,21 +63,34 @@ export class HoverSensor extends BasePointerSensor {
|
|
|
49
63
|
this.positionY = e.clientY;
|
|
50
64
|
this.revision++;
|
|
51
65
|
}
|
|
52
|
-
|
|
66
|
+
doPointerMove(e) {
|
|
67
|
+
this.preventDefault = false;
|
|
68
|
+
this.stopPropagation = false;
|
|
69
|
+
this.modifiers = extractModifierKeys(e);
|
|
70
|
+
this.positionX = e.clientX;
|
|
71
|
+
this.positionY = e.clientY;
|
|
72
|
+
this.revision++;
|
|
73
|
+
}
|
|
74
|
+
doPointerLeave(e) {
|
|
75
|
+
this.reset();
|
|
76
|
+
}
|
|
77
|
+
reset() {
|
|
53
78
|
this.preventDefault = false;
|
|
54
79
|
this.stopPropagation = false;
|
|
80
|
+
this.isHovered = false;
|
|
81
|
+
this.target = undefined;
|
|
55
82
|
this.positionX = Infinity;
|
|
56
83
|
this.positionY = Infinity;
|
|
57
84
|
this.modifiers = KeyboardModifiers.None;
|
|
58
|
-
this.target = undefined;
|
|
59
85
|
}
|
|
60
86
|
}
|
|
61
87
|
__decorate([
|
|
62
88
|
transactional,
|
|
89
|
+
options({ logging: LoggingLevel.Off }),
|
|
63
90
|
__metadata("design:type", Function),
|
|
64
|
-
__metadata("design:paramtypes", [
|
|
91
|
+
__metadata("design:paramtypes", [PointerEvent]),
|
|
65
92
|
__metadata("design:returntype", void 0)
|
|
66
|
-
], HoverSensor.prototype, "
|
|
93
|
+
], HoverSensor.prototype, "doPointerEnter", null);
|
|
67
94
|
__decorate([
|
|
68
95
|
transactional,
|
|
69
96
|
options({ logging: LoggingLevel.Off }),
|
|
@@ -71,10 +98,24 @@ __decorate([
|
|
|
71
98
|
__metadata("design:paramtypes", [PointerEvent]),
|
|
72
99
|
__metadata("design:returntype", void 0)
|
|
73
100
|
], HoverSensor.prototype, "doPointerOver", null);
|
|
101
|
+
__decorate([
|
|
102
|
+
transactional,
|
|
103
|
+
options({ logging: LoggingLevel.Off }),
|
|
104
|
+
__metadata("design:type", Function),
|
|
105
|
+
__metadata("design:paramtypes", [PointerEvent]),
|
|
106
|
+
__metadata("design:returntype", void 0)
|
|
107
|
+
], HoverSensor.prototype, "doPointerMove", null);
|
|
108
|
+
__decorate([
|
|
109
|
+
transactional,
|
|
110
|
+
options({ logging: LoggingLevel.Off }),
|
|
111
|
+
__metadata("design:type", Function),
|
|
112
|
+
__metadata("design:paramtypes", [PointerEvent]),
|
|
113
|
+
__metadata("design:returntype", void 0)
|
|
114
|
+
], HoverSensor.prototype, "doPointerLeave", null);
|
|
74
115
|
__decorate([
|
|
75
116
|
transactional,
|
|
76
117
|
options({ logging: LoggingLevel.Off }),
|
|
77
118
|
__metadata("design:type", Function),
|
|
78
119
|
__metadata("design:paramtypes", []),
|
|
79
120
|
__metadata("design:returntype", void 0)
|
|
80
|
-
], HoverSensor.prototype, "
|
|
121
|
+
], HoverSensor.prototype, "reset", null);
|
|
@@ -33,12 +33,12 @@ export declare class HtmlDragSensor extends HtmlElementSensor {
|
|
|
33
33
|
immediatePositionX: number;
|
|
34
34
|
immediatePositionY: number;
|
|
35
35
|
immediateModifiers: KeyboardModifiers;
|
|
36
|
-
constructor(focusSensor: FocusSensor, windowSensor: WindowSensor);
|
|
36
|
+
constructor(element: HTMLElement | SVGElement, focusSensor: FocusSensor, windowSensor: WindowSensor);
|
|
37
37
|
getData(format: string): unknown;
|
|
38
38
|
setData(format: string, value: unknown): void;
|
|
39
39
|
clearData(format?: string): void;
|
|
40
40
|
setDragImage(value: HTMLElement, x: number, y: number): void;
|
|
41
|
-
listen(
|
|
41
|
+
listen(enabled?: boolean): void;
|
|
42
42
|
protected onDragStart(e: DragEvent): void;
|
|
43
43
|
protected onDrag(e: DragEvent): void;
|
|
44
44
|
protected onDragEnter(e: DragEvent): void;
|
|
@@ -12,8 +12,8 @@ import { findTargetElementData, SymDataForSensor } from "./DataForSensor.js";
|
|
|
12
12
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
13
13
|
import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor.js";
|
|
14
14
|
export class HtmlDragSensor extends HtmlElementSensor {
|
|
15
|
-
constructor(focusSensor, windowSensor) {
|
|
16
|
-
super(focusSensor, windowSensor);
|
|
15
|
+
constructor(element, focusSensor, windowSensor) {
|
|
16
|
+
super(element, focusSensor, windowSensor);
|
|
17
17
|
this.draggable = undefined;
|
|
18
18
|
this.dragSource = undefined;
|
|
19
19
|
this.dragTarget = undefined;
|
|
@@ -60,28 +60,25 @@ export class HtmlDragSensor extends HtmlElementSensor {
|
|
|
60
60
|
this.draggingImageX = x;
|
|
61
61
|
this.draggingImageY = y;
|
|
62
62
|
}
|
|
63
|
-
listen(
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
element.addEventListener("drop", this.onDrop.bind(this), { capture: true });
|
|
83
|
-
element.addEventListener("dragend", this.onDragEnd.bind(this), { capture: true });
|
|
84
|
-
}
|
|
63
|
+
listen(enabled = true) {
|
|
64
|
+
const element = this.sourceElement;
|
|
65
|
+
if (enabled) {
|
|
66
|
+
element.addEventListener("dragstart", this.onDragStart.bind(this), { capture: true });
|
|
67
|
+
element.addEventListener("drag", this.onDrag.bind(this), { capture: true });
|
|
68
|
+
element.addEventListener("dragenter", this.onDragEnter.bind(this), { capture: false });
|
|
69
|
+
element.addEventListener("dragleave", this.onDragLeave.bind(this), { capture: false });
|
|
70
|
+
element.addEventListener("dragover", this.onDragOver.bind(this), { capture: true });
|
|
71
|
+
element.addEventListener("drop", this.onDrop.bind(this), { capture: true });
|
|
72
|
+
element.addEventListener("dragend", this.onDragEnd.bind(this), { capture: true });
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
element.removeEventListener("dragstart", this.onDragStart.bind(this), { capture: true });
|
|
76
|
+
element.removeEventListener("drag", this.onDrag.bind(this), { capture: true });
|
|
77
|
+
element.removeEventListener("dragenter", this.onDragEnter.bind(this), { capture: false });
|
|
78
|
+
element.removeEventListener("dragleave", this.onDragLeave.bind(this), { capture: false });
|
|
79
|
+
element.removeEventListener("dragover", this.onDragOver.bind(this), { capture: true });
|
|
80
|
+
element.removeEventListener("drop", this.onDrop.bind(this), { capture: true });
|
|
81
|
+
element.removeEventListener("dragend", this.onDragEnd.bind(this), { capture: true });
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
84
|
onDragStart(e) {
|
|
@@ -291,12 +288,6 @@ __decorate([
|
|
|
291
288
|
raw,
|
|
292
289
|
__metadata("design:type", Boolean)
|
|
293
290
|
], HtmlDragSensor.prototype, "dropAllowed", void 0);
|
|
294
|
-
__decorate([
|
|
295
|
-
transactional,
|
|
296
|
-
__metadata("design:type", Function),
|
|
297
|
-
__metadata("design:paramtypes", [Object, Boolean]),
|
|
298
|
-
__metadata("design:returntype", void 0)
|
|
299
|
-
], HtmlDragSensor.prototype, "listen", null);
|
|
300
291
|
__decorate([
|
|
301
292
|
transactional,
|
|
302
293
|
options({ logging: LoggingLevel.Off }),
|
|
@@ -2,12 +2,12 @@ import { DataForSensor } from "./DataForSensor.js";
|
|
|
2
2
|
import { Sensor } from "./Sensor.js";
|
|
3
3
|
import { WindowSensor } from "./WindowSensor.js";
|
|
4
4
|
export declare class HtmlElementSensor extends Sensor {
|
|
5
|
+
readonly sourceElement: HTMLElement | SVGElement;
|
|
5
6
|
readonly focusSensor?: any;
|
|
6
7
|
readonly windowSensor?: WindowSensor;
|
|
7
|
-
sourceElement: HTMLElement | undefined;
|
|
8
8
|
preventDefault: boolean;
|
|
9
9
|
stopPropagation: boolean;
|
|
10
|
-
constructor(focusSensor?: any, windowSensor?: WindowSensor);
|
|
11
|
-
protected getDefaultSensorData(): DataForSensor
|
|
10
|
+
constructor(sourceElement: HTMLElement | SVGElement, focusSensor?: any, windowSensor?: WindowSensor);
|
|
11
|
+
protected getDefaultSensorData(): DataForSensor;
|
|
12
12
|
protected setPreventDefaultAndStopPropagation(e: Event): void;
|
|
13
13
|
}
|
|
@@ -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 =
|
|
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
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
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(
|
|
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(
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
|
|
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(
|
|
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(
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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 = (
|
|
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
|
-
|
|
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.
|
|
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(
|
|
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(
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
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.
|
|
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.
|
|
3
|
+
"version": "0.24.127",
|
|
4
4
|
"description": "Verstak - Front-End Library",
|
|
5
5
|
"publisher": "Nezaboodka Software",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/nezaboodka/verstak/blob/master/README.md#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"reactronic": "^0.24.
|
|
34
|
+
"reactronic": "^0.24.127"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/node": "20.
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
39
|
-
"@typescript-eslint/parser": "6.
|
|
40
|
-
"ava": "
|
|
41
|
-
"c8": "
|
|
42
|
-
"eslint": "8.
|
|
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"
|
|
@@ -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
|
-
}
|