verstak 0.22.412
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/LICENSE +202 -0
- package/README.md +28 -0
- package/build/dist/source/api.d.ts +2 -0
- package/build/dist/source/api.js +2 -0
- package/build/dist/source/archive/RxDomV1.Types.d.ts +46 -0
- package/build/dist/source/archive/RxDomV1.Types.js +22 -0
- package/build/dist/source/archive/RxDomV1.d.ts +45 -0
- package/build/dist/source/archive/RxDomV1.js +556 -0
- package/build/dist/source/core/Elements.d.ts +4 -0
- package/build/dist/source/core/Elements.js +7 -0
- package/build/dist/source/core/Restyler.d.ts +7 -0
- package/build/dist/source/core/Restyler.js +30 -0
- package/build/dist/source/core/RxNode.d.ts +59 -0
- package/build/dist/source/core/RxNode.js +426 -0
- package/build/dist/source/core/Utils.d.ts +1 -0
- package/build/dist/source/core/Utils.js +3 -0
- package/build/dist/source/core/api.d.ts +4 -0
- package/build/dist/source/core/api.js +4 -0
- package/build/dist/source/html/CellRange.d.ts +11 -0
- package/build/dist/source/html/CellRange.js +175 -0
- package/build/dist/source/html/HtmlApiExt.d.ts +7 -0
- package/build/dist/source/html/HtmlApiExt.js +25 -0
- package/build/dist/source/html/HtmlElements.d.ts +349 -0
- package/build/dist/source/html/HtmlElements.js +529 -0
- package/build/dist/source/html/HtmlNodeFactory.d.ts +19 -0
- package/build/dist/source/html/HtmlNodeFactory.js +96 -0
- package/build/dist/source/html/RxFocuser.d.ts +2 -0
- package/build/dist/source/html/RxFocuser.js +11 -0
- package/build/dist/source/html/api.d.ts +18 -0
- package/build/dist/source/html/api.js +18 -0
- package/build/dist/source/html/sensors/BasePointerSensor.d.ts +18 -0
- package/build/dist/source/html/sensors/BasePointerSensor.js +32 -0
- package/build/dist/source/html/sensors/ButtonSensor.d.ts +32 -0
- package/build/dist/source/html/sensors/ButtonSensor.js +211 -0
- package/build/dist/source/html/sensors/DataForSensor.d.ts +27 -0
- package/build/dist/source/html/sensors/DataForSensor.js +72 -0
- package/build/dist/source/html/sensors/FocusSensor.d.ts +29 -0
- package/build/dist/source/html/sensors/FocusSensor.js +182 -0
- package/build/dist/source/html/sensors/HoverSensor.d.ts +10 -0
- package/build/dist/source/html/sensors/HoverSensor.js +80 -0
- package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +61 -0
- package/build/dist/source/html/sensors/HtmlDragSensor.js +386 -0
- package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +13 -0
- package/build/dist/source/html/sensors/HtmlElementSensor.js +53 -0
- package/build/dist/source/html/sensors/HtmlSensors.d.ts +22 -0
- package/build/dist/source/html/sensors/HtmlSensors.js +47 -0
- package/build/dist/source/html/sensors/KeyboardSensor.d.ts +33 -0
- package/build/dist/source/html/sensors/KeyboardSensor.js +143 -0
- package/build/dist/source/html/sensors/PointerSensor.d.ts +60 -0
- package/build/dist/source/html/sensors/PointerSensor.js +394 -0
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +18 -0
- package/build/dist/source/html/sensors/ResizeSensor.js +72 -0
- package/build/dist/source/html/sensors/Sensor.d.ts +6 -0
- package/build/dist/source/html/sensors/Sensor.js +11 -0
- package/build/dist/source/html/sensors/WheelSensor.d.ts +13 -0
- package/build/dist/source/html/sensors/WheelSensor.js +86 -0
- package/build/dist/source/html/sensors/WindowSensor.d.ts +10 -0
- package/build/dist/source/html/sensors/WindowSensor.js +38 -0
- package/package.json +54 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Rx } from 'reactronic';
|
|
2
|
+
import { RxNode, NodeFactory } from '../core/api';
|
|
3
|
+
export class ElementNodeFactory extends NodeFactory {
|
|
4
|
+
initialize(node, element) {
|
|
5
|
+
element = this.createElement(node);
|
|
6
|
+
if (Rx.isLogging)
|
|
7
|
+
element.id = node.name;
|
|
8
|
+
super.initialize(node, element);
|
|
9
|
+
}
|
|
10
|
+
finalize(node, isLeader) {
|
|
11
|
+
var _a;
|
|
12
|
+
const e = node.element;
|
|
13
|
+
if (e) {
|
|
14
|
+
(_a = e.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(e);
|
|
15
|
+
if (isLeader)
|
|
16
|
+
e.remove();
|
|
17
|
+
}
|
|
18
|
+
super.finalize(node, isLeader);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
arrange(node, strict) {
|
|
22
|
+
const e = node.element;
|
|
23
|
+
if (e) {
|
|
24
|
+
const nativeParent = ElementNodeFactory.findNearestParentHtmlElementNode(node).element;
|
|
25
|
+
if (nativeParent) {
|
|
26
|
+
if (strict) {
|
|
27
|
+
const after = ElementNodeFactory.findPrevSiblingHtmlElementNode(node.item);
|
|
28
|
+
if (after === undefined) {
|
|
29
|
+
if (nativeParent !== e.parentNode || !e.previousSibling)
|
|
30
|
+
nativeParent.prepend(e);
|
|
31
|
+
}
|
|
32
|
+
else if (after.self.parent.element === nativeParent) {
|
|
33
|
+
const nativeAfter = after.self.element;
|
|
34
|
+
if (nativeAfter instanceof Element) {
|
|
35
|
+
if (nativeAfter.nextSibling !== e)
|
|
36
|
+
nativeParent.insertBefore(e, nativeAfter.nextSibling);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
nativeParent.appendChild(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
render(node) {
|
|
46
|
+
const result = super.render(node);
|
|
47
|
+
if (gBlinkingEffect)
|
|
48
|
+
blink(node.element, RxNode.currentRenderingPriority, node.stamp);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
static get blinkingEffect() {
|
|
52
|
+
return gBlinkingEffect;
|
|
53
|
+
}
|
|
54
|
+
static set blinkingEffect(value) {
|
|
55
|
+
if (value === undefined) {
|
|
56
|
+
const effect = gBlinkingEffect;
|
|
57
|
+
RxNode.forAllNodesDo((e) => {
|
|
58
|
+
if (e instanceof HTMLElement)
|
|
59
|
+
e.classList.remove(`${effect}-0`, `${effect}-1`);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
gBlinkingEffect = value;
|
|
63
|
+
}
|
|
64
|
+
static findNearestParentHtmlElementNode(node) {
|
|
65
|
+
let p = node.parent;
|
|
66
|
+
while (p.element instanceof Element === false && p !== node)
|
|
67
|
+
p = p.parent;
|
|
68
|
+
return p;
|
|
69
|
+
}
|
|
70
|
+
static findPrevSiblingHtmlElementNode(item) {
|
|
71
|
+
let p = item.prev;
|
|
72
|
+
while (p && !(p.self.element instanceof Element))
|
|
73
|
+
p = p.prev;
|
|
74
|
+
return p;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export class HtmlElementNodeFactory extends ElementNodeFactory {
|
|
78
|
+
createElement(node) {
|
|
79
|
+
return document.createElement(node.factory.name);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export class SvgElementNodeFactory extends ElementNodeFactory {
|
|
83
|
+
createElement(node) {
|
|
84
|
+
return document.createElementNS('http://www.w3.org/2000/svg', node.factory.name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function blink(e, priority, revision) {
|
|
88
|
+
if (e !== undefined) {
|
|
89
|
+
const n1 = revision % 2;
|
|
90
|
+
const n2 = 1 >> n1;
|
|
91
|
+
const effect = gBlinkingEffect;
|
|
92
|
+
e.classList.toggle(`${effect}-${priority}-${n1}`, true);
|
|
93
|
+
e.classList.toggle(`${effect}-${priority}-${n2}`, false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
let gBlinkingEffect = undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Reaction } from '../core/Elements';
|
|
2
|
+
export function RxFocuser(name, target, model, switchEditMode = undefined) {
|
|
3
|
+
Reaction(name, { target, model }, (_, node) => {
|
|
4
|
+
if (switchEditMode !== undefined) {
|
|
5
|
+
switchEditMode(model);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
model.isEditMode ? target.focus() : target.blur();
|
|
9
|
+
}
|
|
10
|
+
}, undefined, undefined, 0);
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './HtmlNodeFactory';
|
|
2
|
+
export * from './HtmlElements';
|
|
3
|
+
export * from './HtmlApiExt';
|
|
4
|
+
export * from './RxFocuser';
|
|
5
|
+
export * from './CellRange';
|
|
6
|
+
export * from './sensors/Sensor';
|
|
7
|
+
export * from './sensors/PointerSensor';
|
|
8
|
+
export * from './sensors/BasePointerSensor';
|
|
9
|
+
export * from './sensors/FocusSensor';
|
|
10
|
+
export * from './sensors/ButtonSensor';
|
|
11
|
+
export * from './sensors/HoverSensor';
|
|
12
|
+
export * from './sensors/WheelSensor';
|
|
13
|
+
export * from './sensors/KeyboardSensor';
|
|
14
|
+
export * from './sensors/ResizeSensor';
|
|
15
|
+
export * from './sensors/HtmlDragSensor';
|
|
16
|
+
export * from './sensors/HtmlSensors';
|
|
17
|
+
export * from './sensors/WindowSensor';
|
|
18
|
+
import './HtmlApiExt';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './HtmlNodeFactory';
|
|
2
|
+
export * from './HtmlElements';
|
|
3
|
+
export * from './HtmlApiExt';
|
|
4
|
+
export * from './RxFocuser';
|
|
5
|
+
export * from './CellRange';
|
|
6
|
+
export * from './sensors/Sensor';
|
|
7
|
+
export * from './sensors/PointerSensor';
|
|
8
|
+
export * from './sensors/BasePointerSensor';
|
|
9
|
+
export * from './sensors/FocusSensor';
|
|
10
|
+
export * from './sensors/ButtonSensor';
|
|
11
|
+
export * from './sensors/HoverSensor';
|
|
12
|
+
export * from './sensors/WheelSensor';
|
|
13
|
+
export * from './sensors/KeyboardSensor';
|
|
14
|
+
export * from './sensors/ResizeSensor';
|
|
15
|
+
export * from './sensors/HtmlDragSensor';
|
|
16
|
+
export * from './sensors/HtmlSensors';
|
|
17
|
+
export * from './sensors/WindowSensor';
|
|
18
|
+
import './HtmlApiExt';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FocusSensor } from './FocusSensor';
|
|
2
|
+
import { HtmlElementSensor } from './HtmlElementSensor';
|
|
3
|
+
import { KeyboardModifiers } from './KeyboardSensor';
|
|
4
|
+
import { WindowSensor } from './WindowSensor';
|
|
5
|
+
export declare enum PointerButton {
|
|
6
|
+
None = 0,
|
|
7
|
+
Left = 1,
|
|
8
|
+
Right = 2,
|
|
9
|
+
Middle = 4
|
|
10
|
+
}
|
|
11
|
+
export declare class BasePointerSensor extends HtmlElementSensor {
|
|
12
|
+
positionX: number;
|
|
13
|
+
positionY: number;
|
|
14
|
+
modifiers: KeyboardModifiers;
|
|
15
|
+
constructor(focusSensor?: FocusSensor, windowSensor?: WindowSensor);
|
|
16
|
+
}
|
|
17
|
+
export declare function extractPointerButton(e: MouseEvent): PointerButton;
|
|
18
|
+
export declare function isPointerButtonDown(button: PointerButton, buttonsMask: number): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HtmlElementSensor } from './HtmlElementSensor';
|
|
2
|
+
import { KeyboardModifiers } from './KeyboardSensor';
|
|
3
|
+
export var PointerButton;
|
|
4
|
+
(function (PointerButton) {
|
|
5
|
+
PointerButton[PointerButton["None"] = 0] = "None";
|
|
6
|
+
PointerButton[PointerButton["Left"] = 1] = "Left";
|
|
7
|
+
PointerButton[PointerButton["Right"] = 2] = "Right";
|
|
8
|
+
PointerButton[PointerButton["Middle"] = 4] = "Middle";
|
|
9
|
+
})(PointerButton || (PointerButton = {}));
|
|
10
|
+
export class BasePointerSensor extends HtmlElementSensor {
|
|
11
|
+
constructor(focusSensor, windowSensor) {
|
|
12
|
+
super(focusSensor, windowSensor);
|
|
13
|
+
this.positionX = Infinity;
|
|
14
|
+
this.positionY = Infinity;
|
|
15
|
+
this.modifiers = KeyboardModifiers.None;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function extractPointerButton(e) {
|
|
19
|
+
switch (e.button) {
|
|
20
|
+
case 0:
|
|
21
|
+
return PointerButton.Left;
|
|
22
|
+
case 1:
|
|
23
|
+
return PointerButton.Middle;
|
|
24
|
+
case 2:
|
|
25
|
+
return PointerButton.Right;
|
|
26
|
+
default:
|
|
27
|
+
return PointerButton.None;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function isPointerButtonDown(button, buttonsMask) {
|
|
31
|
+
return (buttonsMask & button) !== 0;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PointerButton, BasePointerSensor } from './BasePointerSensor';
|
|
2
|
+
import { FocusSensor } from './FocusSensor';
|
|
3
|
+
import { WindowSensor } from './WindowSensor';
|
|
4
|
+
export declare enum ButtonState {
|
|
5
|
+
Pressed = 0,
|
|
6
|
+
Selecting = 1,
|
|
7
|
+
Selected = 2,
|
|
8
|
+
Released = 3
|
|
9
|
+
}
|
|
10
|
+
export declare class ButtonSensor extends BasePointerSensor {
|
|
11
|
+
state: ButtonState;
|
|
12
|
+
pointerButton: PointerButton;
|
|
13
|
+
originData: unknown;
|
|
14
|
+
selectedData: unknown;
|
|
15
|
+
selectedX: number;
|
|
16
|
+
selectedY: number;
|
|
17
|
+
selected: boolean;
|
|
18
|
+
constructor(focusSensor: FocusSensor, windowSensor: WindowSensor);
|
|
19
|
+
listen(element: HTMLElement | undefined, enabled?: boolean): void;
|
|
20
|
+
protected onPointerDown(e: PointerEvent): void;
|
|
21
|
+
protected onPointerMove(e: PointerEvent): void;
|
|
22
|
+
protected onPointerUp(e: PointerEvent): void;
|
|
23
|
+
protected onLostPointerCapture(e: PointerEvent): void;
|
|
24
|
+
protected onKeyDown(e: KeyboardEvent): void;
|
|
25
|
+
protected press(e: PointerEvent): void;
|
|
26
|
+
protected selecting(e: PointerEvent): void;
|
|
27
|
+
protected select(e: PointerEvent): void;
|
|
28
|
+
protected release(): void;
|
|
29
|
+
protected cancel(): void;
|
|
30
|
+
protected reset(): void;
|
|
31
|
+
protected updateSensorData(e: PointerEvent): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
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, Transaction, LoggingLevel } from 'reactronic';
|
|
11
|
+
import { extractPointerButton, isPointerButtonDown, PointerButton, BasePointerSensor } from './BasePointerSensor';
|
|
12
|
+
import { findTargetElementData, SymDataForSensor } from './DataForSensor';
|
|
13
|
+
import { extractModifierKeys, KeyboardModifiers } from './KeyboardSensor';
|
|
14
|
+
export var ButtonState;
|
|
15
|
+
(function (ButtonState) {
|
|
16
|
+
ButtonState[ButtonState["Pressed"] = 0] = "Pressed";
|
|
17
|
+
ButtonState[ButtonState["Selecting"] = 1] = "Selecting";
|
|
18
|
+
ButtonState[ButtonState["Selected"] = 2] = "Selected";
|
|
19
|
+
ButtonState[ButtonState["Released"] = 3] = "Released";
|
|
20
|
+
})(ButtonState || (ButtonState = {}));
|
|
21
|
+
export class ButtonSensor extends BasePointerSensor {
|
|
22
|
+
constructor(focusSensor, windowSensor) {
|
|
23
|
+
super(focusSensor, windowSensor);
|
|
24
|
+
this.state = ButtonState.Released;
|
|
25
|
+
this.pointerButton = PointerButton.None;
|
|
26
|
+
this.originData = undefined;
|
|
27
|
+
this.selectedData = undefined;
|
|
28
|
+
this.selectedX = Infinity;
|
|
29
|
+
this.selectedY = Infinity;
|
|
30
|
+
this.selected = false;
|
|
31
|
+
}
|
|
32
|
+
listen(element, enabled = true) {
|
|
33
|
+
const existing = this.sourceElement;
|
|
34
|
+
if (element !== existing) {
|
|
35
|
+
if (existing) {
|
|
36
|
+
existing.removeEventListener('pointerdown', this.onPointerDown.bind(this), { capture: true });
|
|
37
|
+
existing.removeEventListener('pointermove', this.onPointerMove.bind(this), { capture: true });
|
|
38
|
+
existing.removeEventListener('pointerup', this.onPointerUp.bind(this), { capture: true });
|
|
39
|
+
existing.removeEventListener('lostpointercapture', this.onLostPointerCapture.bind(this), { capture: true });
|
|
40
|
+
existing.removeEventListener('keydown', this.onKeyDown.bind(this), { capture: true });
|
|
41
|
+
}
|
|
42
|
+
this.sourceElement = element;
|
|
43
|
+
if (element && enabled) {
|
|
44
|
+
element.addEventListener('pointerdown', this.onPointerDown.bind(this), { capture: true });
|
|
45
|
+
element.addEventListener('pointermove', this.onPointerMove.bind(this), { capture: true });
|
|
46
|
+
element.addEventListener('pointerup', this.onPointerUp.bind(this), { capture: true });
|
|
47
|
+
element.addEventListener('lostpointercapture', this.onLostPointerCapture.bind(this), { capture: true });
|
|
48
|
+
element.addEventListener('keydown', this.onKeyDown.bind(this), { capture: true });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
onPointerDown(e) {
|
|
53
|
+
if (this.state === ButtonState.Released && (this.pointerButton === PointerButton.None))
|
|
54
|
+
this.press(e);
|
|
55
|
+
this.setPreventDefaultAndStopPropagation(e);
|
|
56
|
+
}
|
|
57
|
+
onPointerMove(e) {
|
|
58
|
+
const state = this.state;
|
|
59
|
+
if (isPointerButtonDown(this.pointerButton, e.buttons)) {
|
|
60
|
+
if (state === ButtonState.Pressed || state === ButtonState.Selecting)
|
|
61
|
+
this.selecting(e);
|
|
62
|
+
}
|
|
63
|
+
else if (state !== ButtonState.Released) {
|
|
64
|
+
this.cancel();
|
|
65
|
+
this.reset();
|
|
66
|
+
}
|
|
67
|
+
this.setPreventDefaultAndStopPropagation(e);
|
|
68
|
+
}
|
|
69
|
+
onPointerUp(e) {
|
|
70
|
+
const button = extractPointerButton(e);
|
|
71
|
+
if (button === this.pointerButton) {
|
|
72
|
+
if (this.state === ButtonState.Selecting) {
|
|
73
|
+
this.select(e);
|
|
74
|
+
this.release();
|
|
75
|
+
}
|
|
76
|
+
else if (this.state === ButtonState.Pressed) {
|
|
77
|
+
this.release();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else
|
|
81
|
+
this.cancel();
|
|
82
|
+
this.reset();
|
|
83
|
+
this.setPreventDefaultAndStopPropagation(e);
|
|
84
|
+
}
|
|
85
|
+
onLostPointerCapture(e) {
|
|
86
|
+
if (this.state !== ButtonState.Released) {
|
|
87
|
+
this.cancel();
|
|
88
|
+
this.reset();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onKeyDown(e) {
|
|
92
|
+
if (e.key === 'Escape' && this.state !== ButtonState.Released) {
|
|
93
|
+
this.cancel();
|
|
94
|
+
this.reset();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
press(e) {
|
|
98
|
+
this.preventDefault = false;
|
|
99
|
+
this.stopPropagation = false;
|
|
100
|
+
const targetPath = e.composedPath();
|
|
101
|
+
const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
|
|
102
|
+
const { data, window } = findTargetElementData(targetPath, underPointer, SymDataForSensor, ['button']);
|
|
103
|
+
const originData = data === null || data === void 0 ? void 0 : data.button;
|
|
104
|
+
if (originData) {
|
|
105
|
+
this.state = ButtonState.Pressed;
|
|
106
|
+
this.pointerButton = extractPointerButton(e);
|
|
107
|
+
this.originData = originData;
|
|
108
|
+
this.modifiers = extractModifierKeys(e);
|
|
109
|
+
this.positionX = e.clientX;
|
|
110
|
+
this.positionY = e.clientY;
|
|
111
|
+
this.revision++;
|
|
112
|
+
}
|
|
113
|
+
Transaction.separate(() => {
|
|
114
|
+
var _a;
|
|
115
|
+
(_a = this.windowSensor) === null || _a === void 0 ? void 0 : _a.setActiveWindow(window, 'button');
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
selecting(e) {
|
|
119
|
+
this.updateSensorData(e);
|
|
120
|
+
this.state = ButtonState.Selecting;
|
|
121
|
+
this.selected = false;
|
|
122
|
+
}
|
|
123
|
+
select(e) {
|
|
124
|
+
this.updateSensorData(e);
|
|
125
|
+
this.state = ButtonState.Selected;
|
|
126
|
+
this.selectedX = e.clientX;
|
|
127
|
+
this.selectedY = e.clientY;
|
|
128
|
+
this.selected = true;
|
|
129
|
+
}
|
|
130
|
+
release() {
|
|
131
|
+
this.preventDefault = false;
|
|
132
|
+
this.stopPropagation = false;
|
|
133
|
+
this.state = ButtonState.Released;
|
|
134
|
+
this.revision++;
|
|
135
|
+
}
|
|
136
|
+
cancel() {
|
|
137
|
+
this.state = ButtonState.Released;
|
|
138
|
+
this.selected = false;
|
|
139
|
+
this.revision++;
|
|
140
|
+
}
|
|
141
|
+
reset() {
|
|
142
|
+
this.preventDefault = false;
|
|
143
|
+
this.stopPropagation = false;
|
|
144
|
+
this.state = ButtonState.Released;
|
|
145
|
+
this.originData = undefined;
|
|
146
|
+
this.selectedData = undefined;
|
|
147
|
+
this.pointerButton = PointerButton.None;
|
|
148
|
+
this.positionX = Infinity;
|
|
149
|
+
this.positionY = Infinity;
|
|
150
|
+
this.selectedX = Infinity;
|
|
151
|
+
this.selectedY = Infinity;
|
|
152
|
+
this.modifiers = KeyboardModifiers.None;
|
|
153
|
+
this.selected = false;
|
|
154
|
+
}
|
|
155
|
+
updateSensorData(e) {
|
|
156
|
+
this.preventDefault = false;
|
|
157
|
+
this.stopPropagation = false;
|
|
158
|
+
this.modifiers = extractModifierKeys(e);
|
|
159
|
+
this.positionX = e.clientX;
|
|
160
|
+
this.positionY = e.clientY;
|
|
161
|
+
this.revision++;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
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
|
+
__decorate([
|
|
171
|
+
transactional,
|
|
172
|
+
options({ logging: LoggingLevel.Off }),
|
|
173
|
+
__metadata("design:type", Function),
|
|
174
|
+
__metadata("design:paramtypes", [PointerEvent]),
|
|
175
|
+
__metadata("design:returntype", void 0)
|
|
176
|
+
], ButtonSensor.prototype, "press", null);
|
|
177
|
+
__decorate([
|
|
178
|
+
transactional,
|
|
179
|
+
options({ reentrance: Reentrance.CancelPrevious, logging: LoggingLevel.Off }),
|
|
180
|
+
__metadata("design:type", Function),
|
|
181
|
+
__metadata("design:paramtypes", [PointerEvent]),
|
|
182
|
+
__metadata("design:returntype", void 0)
|
|
183
|
+
], ButtonSensor.prototype, "selecting", null);
|
|
184
|
+
__decorate([
|
|
185
|
+
transactional,
|
|
186
|
+
options({ logging: LoggingLevel.Off }),
|
|
187
|
+
__metadata("design:type", Function),
|
|
188
|
+
__metadata("design:paramtypes", [PointerEvent]),
|
|
189
|
+
__metadata("design:returntype", void 0)
|
|
190
|
+
], ButtonSensor.prototype, "select", null);
|
|
191
|
+
__decorate([
|
|
192
|
+
transactional,
|
|
193
|
+
options({ logging: LoggingLevel.Off }),
|
|
194
|
+
__metadata("design:type", Function),
|
|
195
|
+
__metadata("design:paramtypes", []),
|
|
196
|
+
__metadata("design:returntype", void 0)
|
|
197
|
+
], ButtonSensor.prototype, "release", null);
|
|
198
|
+
__decorate([
|
|
199
|
+
transactional,
|
|
200
|
+
options({ logging: LoggingLevel.Off }),
|
|
201
|
+
__metadata("design:type", Function),
|
|
202
|
+
__metadata("design:paramtypes", []),
|
|
203
|
+
__metadata("design:returntype", void 0)
|
|
204
|
+
], ButtonSensor.prototype, "cancel", null);
|
|
205
|
+
__decorate([
|
|
206
|
+
transactional,
|
|
207
|
+
options({ logging: LoggingLevel.Off }),
|
|
208
|
+
__metadata("design:type", Function),
|
|
209
|
+
__metadata("design:paramtypes", []),
|
|
210
|
+
__metadata("design:returntype", void 0)
|
|
211
|
+
], ButtonSensor.prototype, "reset", null);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface DataForSensor {
|
|
2
|
+
context?: unknown;
|
|
3
|
+
window?: unknown;
|
|
4
|
+
focus?: unknown;
|
|
5
|
+
hover?: unknown;
|
|
6
|
+
keyboard?: unknown;
|
|
7
|
+
click?: unknown;
|
|
8
|
+
wheel?: unknown;
|
|
9
|
+
resize?: unknown;
|
|
10
|
+
drag?: unknown;
|
|
11
|
+
draggable?: unknown;
|
|
12
|
+
htmlDrag?: unknown;
|
|
13
|
+
htmlDraggable?: unknown;
|
|
14
|
+
button?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export declare const SymDataForSensor: unique symbol;
|
|
17
|
+
export declare const SymResizeObserver: unique symbol;
|
|
18
|
+
export declare const EmptyDataArray: any[];
|
|
19
|
+
export declare function findTargetElementData(targetPath: any[], underPointer: any[], sym: symbol, anyOfPayloadKeys: Array<keyof DataForSensor>, ignoreWindow?: boolean): {
|
|
20
|
+
data?: DataForSensor;
|
|
21
|
+
window: unknown;
|
|
22
|
+
};
|
|
23
|
+
export declare function grabElementDataList(targetPath: any[], sym: symbol, payloadKey: keyof DataForSensor, existing: Array<unknown>, ignoreWindow?: boolean, predicate?: (element: any) => boolean): {
|
|
24
|
+
dataList: Array<unknown>;
|
|
25
|
+
window: unknown;
|
|
26
|
+
activeData: unknown;
|
|
27
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const SymDataForSensor = Symbol('DataForSensor');
|
|
2
|
+
export const SymResizeObserver = Symbol('ResizeObserver');
|
|
3
|
+
export const EmptyDataArray = [];
|
|
4
|
+
export function findTargetElementData(targetPath, underPointer, sym, anyOfPayloadKeys, ignoreWindow = false) {
|
|
5
|
+
let result = undefined;
|
|
6
|
+
let i = 0;
|
|
7
|
+
let window = undefined;
|
|
8
|
+
while (i < targetPath.length) {
|
|
9
|
+
const candidate = targetPath[i];
|
|
10
|
+
const candidateData = candidate[sym];
|
|
11
|
+
if (candidateData !== undefined) {
|
|
12
|
+
if (!ignoreWindow) {
|
|
13
|
+
if (window === undefined)
|
|
14
|
+
window = candidateData['window'];
|
|
15
|
+
else if (window !== candidateData['window'])
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
if (result === undefined) {
|
|
19
|
+
for (const payloadKey of anyOfPayloadKeys) {
|
|
20
|
+
const payload = candidateData[payloadKey];
|
|
21
|
+
if (payload !== undefined && underPointer.includes(candidate)) {
|
|
22
|
+
result = candidateData;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
i++;
|
|
29
|
+
}
|
|
30
|
+
return { data: result, window };
|
|
31
|
+
}
|
|
32
|
+
export function grabElementDataList(targetPath, sym, payloadKey, existing, ignoreWindow = false, predicate = () => false) {
|
|
33
|
+
let result = existing;
|
|
34
|
+
let i = 0;
|
|
35
|
+
let j = 0;
|
|
36
|
+
let window = undefined;
|
|
37
|
+
let activeData = undefined;
|
|
38
|
+
while (i < targetPath.length) {
|
|
39
|
+
let payload = undefined;
|
|
40
|
+
const candidate = targetPath[i];
|
|
41
|
+
const candidateData = candidate[sym];
|
|
42
|
+
if (candidateData !== undefined) {
|
|
43
|
+
if (!ignoreWindow) {
|
|
44
|
+
if (window === undefined)
|
|
45
|
+
window = candidateData['window'];
|
|
46
|
+
else if (window !== candidateData['window'])
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
payload = candidateData[payloadKey];
|
|
50
|
+
if (payload !== undefined) {
|
|
51
|
+
if (result !== existing) {
|
|
52
|
+
result.push(payload);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if (payload !== existing[j]) {
|
|
56
|
+
result = existing.slice(0, j);
|
|
57
|
+
result.push(payload);
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
j++;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (activeData === undefined && predicate(candidate)) {
|
|
65
|
+
activeData = payload;
|
|
66
|
+
}
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
if (j === 0 && result === existing && existing.length > 0)
|
|
70
|
+
result = EmptyDataArray;
|
|
71
|
+
return { dataList: result, window, activeData };
|
|
72
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ToggleRef } from 'reactronic';
|
|
2
|
+
import { HtmlElementSensor } from './HtmlElementSensor';
|
|
3
|
+
import { WindowSensor } from './WindowSensor';
|
|
4
|
+
export interface FocusModel {
|
|
5
|
+
isEditMode: boolean;
|
|
6
|
+
onFocusIn?: (focus: FocusSensor) => void;
|
|
7
|
+
onFocusOut?: (focus: FocusSensor) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface ContextModel {
|
|
10
|
+
contextToggle?: ToggleRef;
|
|
11
|
+
onContextIn?: (focus: FocusSensor) => void;
|
|
12
|
+
onContextOut?: (focus: FocusSensor) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class FocusSensor extends HtmlElementSensor {
|
|
15
|
+
activeData: unknown;
|
|
16
|
+
oldActiveData: unknown;
|
|
17
|
+
contextElementDataList: unknown[];
|
|
18
|
+
constructor(windowSensor: WindowSensor);
|
|
19
|
+
setActiveData(data: unknown, debugHint?: string): void;
|
|
20
|
+
listen(element: HTMLElement | undefined, enabled?: boolean): void;
|
|
21
|
+
reset(): void;
|
|
22
|
+
protected onFocusIn(e: FocusEvent): void;
|
|
23
|
+
protected onFocusOut(e: FocusEvent): void;
|
|
24
|
+
protected onMouseDown(e: MouseEvent): void;
|
|
25
|
+
protected doFocusIn(e: FocusEvent): void;
|
|
26
|
+
protected doFocusOut(e: FocusEvent): void;
|
|
27
|
+
protected doMouseDown(e: MouseEvent): void;
|
|
28
|
+
private trySetEditMode;
|
|
29
|
+
}
|