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.
- 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 +11 -11
- 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
|
}
|