verstak 0.22.500 → 0.22.503
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/api.d.ts +2 -2
- package/build/dist/source/api.js +2 -2
- package/build/dist/source/archive/RxDomV1.d.ts +1 -1
- package/build/dist/source/archive/RxDomV1.js +13 -13
- package/build/dist/source/core/Allocator.d.ts +64 -0
- package/build/dist/source/core/Allocator.js +141 -0
- package/build/dist/source/core/CellRange.d.ts +8 -0
- package/build/dist/source/core/CellRange.js +173 -0
- package/build/dist/source/core/Kernel.d.ts +77 -0
- package/build/dist/source/core/Kernel.js +504 -0
- package/build/dist/source/core/Restyler.js +1 -1
- package/build/dist/source/core/api.d.ts +5 -5
- package/build/dist/source/core/api.js +5 -5
- package/build/dist/source/html/Blocks.d.ts +14 -0
- package/build/dist/source/html/Blocks.js +124 -0
- package/build/dist/source/html/HtmlApiExt.d.ts +1 -1
- package/build/dist/source/html/HtmlApiExt.js +3 -3
- package/build/dist/source/html/HtmlBlocks.d.ts +175 -0
- package/build/dist/source/html/HtmlBlocks.js +356 -0
- package/build/dist/source/html/HtmlDriver.d.ts +20 -0
- package/build/dist/source/html/{HtmlNodeFactory.js → HtmlDriver.js} +25 -23
- package/build/dist/source/html/ReactingFocuser.d.ts +2 -0
- package/build/dist/source/html/ReactingFocuser.js +16 -0
- package/build/dist/source/html/api.d.ts +18 -17
- package/build/dist/source/html/api.js +18 -17
- package/build/dist/source/html/sensors/BasePointerSensor.d.ts +4 -4
- package/build/dist/source/html/sensors/BasePointerSensor.js +2 -2
- package/build/dist/source/html/sensors/ButtonSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/ButtonSensor.js +17 -17
- package/build/dist/source/html/sensors/DataForSensor.js +6 -6
- package/build/dist/source/html/sensors/FocusSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/FocusSensor.js +27 -27
- package/build/dist/source/html/sensors/HoverSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/HoverSensor.js +9 -9
- package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +6 -6
- package/build/dist/source/html/sensors/HtmlDragSensor.js +28 -28
- package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/HtmlElementSensor.js +4 -4
- package/build/dist/source/html/sensors/HtmlSensors.d.ts +9 -9
- package/build/dist/source/html/sensors/HtmlSensors.js +10 -10
- package/build/dist/source/html/sensors/KeyboardSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/KeyboardSensor.js +18 -18
- package/build/dist/source/html/sensors/PointerSensor.d.ts +4 -4
- package/build/dist/source/html/sensors/PointerSensor.js +20 -20
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +3 -3
- package/build/dist/source/html/sensors/ResizeSensor.js +13 -13
- package/build/dist/source/html/sensors/Sensor.d.ts +1 -1
- package/build/dist/source/html/sensors/Sensor.js +1 -1
- package/build/dist/source/html/sensors/WheelSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/WheelSensor.js +7 -7
- package/build/dist/source/html/sensors/WindowSensor.d.ts +2 -2
- package/build/dist/source/html/sensors/WindowSensor.js +5 -5
- package/package.json +3 -3
- package/build/dist/source/core/Block.d.ts +0 -62
- package/build/dist/source/core/Block.js +0 -431
- package/build/dist/source/core/Elements.d.ts +0 -3
- package/build/dist/source/core/Elements.js +0 -7
- package/build/dist/source/core/Layout.d.ts +0 -27
- package/build/dist/source/core/Layout.js +0 -259
- package/build/dist/source/html/Cluster.d.ts +0 -11
- package/build/dist/source/html/Cluster.js +0 -14
- package/build/dist/source/html/HtmlElements.d.ts +0 -349
- package/build/dist/source/html/HtmlElements.js +0 -529
- package/build/dist/source/html/HtmlNodeFactory.d.ts +0 -19
- package/build/dist/source/html/RxFocuser.d.ts +0 -2
- package/build/dist/source/html/RxFocuser.js +0 -11
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Rx } from
|
|
2
|
-
import {
|
|
3
|
-
export class
|
|
1
|
+
import { Rx } from "reactronic";
|
|
2
|
+
import { VBlock, AbstractDriver } from "../core/api";
|
|
3
|
+
export class BaseHtmlDriver extends AbstractDriver {
|
|
4
4
|
initialize(block, element) {
|
|
5
5
|
element = this.createElement(block);
|
|
6
|
-
if (Rx.isLogging)
|
|
7
|
-
element.
|
|
6
|
+
if (Rx.isLogging && this.name)
|
|
7
|
+
element.setAttribute("n", block.name);
|
|
8
8
|
super.initialize(block, element);
|
|
9
9
|
}
|
|
10
10
|
finalize(block, isLeader) {
|
|
11
11
|
var _a;
|
|
12
|
-
const e = block.
|
|
12
|
+
const e = block.native;
|
|
13
13
|
if (e) {
|
|
14
14
|
(_a = e.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(e);
|
|
15
15
|
if (isLeader)
|
|
@@ -18,19 +18,19 @@ export class AbstractHtmlBlockFactory extends BlockFactory {
|
|
|
18
18
|
super.finalize(block, isLeader);
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
const e = block.
|
|
21
|
+
deploy(block, sequential) {
|
|
22
|
+
const e = block.native;
|
|
23
23
|
if (e) {
|
|
24
|
-
const nativeParent =
|
|
24
|
+
const nativeParent = BaseHtmlDriver.findNearestParentHtmlBlock(block).native;
|
|
25
25
|
if (nativeParent) {
|
|
26
|
-
if (
|
|
27
|
-
const after =
|
|
26
|
+
if (sequential) {
|
|
27
|
+
const after = BaseHtmlDriver.findPrevSiblingHtmlBlock(block.item);
|
|
28
28
|
if (after === undefined) {
|
|
29
29
|
if (nativeParent !== e.parentNode || !e.previousSibling)
|
|
30
30
|
nativeParent.prepend(e);
|
|
31
31
|
}
|
|
32
|
-
else
|
|
33
|
-
const nativeAfter = after.
|
|
32
|
+
else {
|
|
33
|
+
const nativeAfter = after.instance.native;
|
|
34
34
|
if (nativeAfter instanceof Element) {
|
|
35
35
|
if (nativeAfter.nextSibling !== e)
|
|
36
36
|
nativeParent.insertBefore(e, nativeAfter.nextSibling);
|
|
@@ -42,10 +42,12 @@ export class AbstractHtmlBlockFactory extends BlockFactory {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
relocate(block) {
|
|
46
|
+
}
|
|
45
47
|
render(block) {
|
|
46
48
|
const result = super.render(block);
|
|
47
49
|
if (gBlinkingEffect)
|
|
48
|
-
blink(block.
|
|
50
|
+
blink(block.native, VBlock.currentRenderingPriority, block.stamp);
|
|
49
51
|
return result;
|
|
50
52
|
}
|
|
51
53
|
static get blinkingEffect() {
|
|
@@ -54,7 +56,7 @@ export class AbstractHtmlBlockFactory extends BlockFactory {
|
|
|
54
56
|
static set blinkingEffect(value) {
|
|
55
57
|
if (value === undefined) {
|
|
56
58
|
const effect = gBlinkingEffect;
|
|
57
|
-
|
|
59
|
+
VBlock.runForAllBlocks((e) => {
|
|
58
60
|
if (e instanceof HTMLElement)
|
|
59
61
|
e.classList.remove(`${effect}-0`, `${effect}-1`);
|
|
60
62
|
});
|
|
@@ -62,26 +64,26 @@ export class AbstractHtmlBlockFactory extends BlockFactory {
|
|
|
62
64
|
gBlinkingEffect = value;
|
|
63
65
|
}
|
|
64
66
|
static findNearestParentHtmlBlock(block) {
|
|
65
|
-
let p = block.
|
|
66
|
-
while (p.
|
|
67
|
-
p = p.
|
|
67
|
+
let p = block.host;
|
|
68
|
+
while (p.native instanceof Element === false && p !== block)
|
|
69
|
+
p = p.host;
|
|
68
70
|
return p;
|
|
69
71
|
}
|
|
70
72
|
static findPrevSiblingHtmlBlock(item) {
|
|
71
73
|
let p = item.prev;
|
|
72
|
-
while (p && !(p.
|
|
74
|
+
while (p && !(p.instance.native instanceof Element))
|
|
73
75
|
p = p.prev;
|
|
74
76
|
return p;
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
|
-
export class
|
|
79
|
+
export class HtmlDriver extends BaseHtmlDriver {
|
|
78
80
|
createElement(block) {
|
|
79
|
-
return document.createElement(block.
|
|
81
|
+
return document.createElement(block.driver.name);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
export class
|
|
84
|
+
export class SvgDriver extends BaseHtmlDriver {
|
|
83
85
|
createElement(block) {
|
|
84
|
-
return document.createElementNS(
|
|
86
|
+
return document.createElementNS("http://www.w3.org/2000/svg", block.driver.name);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
function blink(e, priority, revision) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VBlock } from "../core/api";
|
|
2
|
+
export function ReactingFocuser(name, target, model, switchEditMode = undefined) {
|
|
3
|
+
VBlock.claim(name, {
|
|
4
|
+
reacting: true,
|
|
5
|
+
triggers: { target, model },
|
|
6
|
+
throttling: 0,
|
|
7
|
+
render() {
|
|
8
|
+
if (switchEditMode !== undefined) {
|
|
9
|
+
switchEditMode(model);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
model.isEditMode ? target.focus() : target.blur();
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
|
|
1
|
+
export * from "./HtmlDriver";
|
|
2
|
+
export * from "./HtmlBlocks";
|
|
3
|
+
export * from "./HtmlApiExt";
|
|
4
|
+
export * from "./Blocks";
|
|
5
|
+
export * from "./ReactingFocuser";
|
|
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";
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
|
|
1
|
+
export * from "./HtmlDriver";
|
|
2
|
+
export * from "./HtmlBlocks";
|
|
3
|
+
export * from "./HtmlApiExt";
|
|
4
|
+
export * from "./Blocks";
|
|
5
|
+
export * from "./ReactingFocuser";
|
|
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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FocusSensor } from
|
|
2
|
-
import { HtmlElementSensor } from
|
|
3
|
-
import { KeyboardModifiers } from
|
|
4
|
-
import { WindowSensor } from
|
|
1
|
+
import { FocusSensor } from "./FocusSensor";
|
|
2
|
+
import { HtmlElementSensor } from "./HtmlElementSensor";
|
|
3
|
+
import { KeyboardModifiers } from "./KeyboardSensor";
|
|
4
|
+
import { WindowSensor } from "./WindowSensor";
|
|
5
5
|
export declare enum PointerButton {
|
|
6
6
|
None = 0,
|
|
7
7
|
Left = 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HtmlElementSensor } from
|
|
2
|
-
import { KeyboardModifiers } from
|
|
1
|
+
import { HtmlElementSensor } from "./HtmlElementSensor";
|
|
2
|
+
import { KeyboardModifiers } from "./KeyboardSensor";
|
|
3
3
|
export var PointerButton;
|
|
4
4
|
(function (PointerButton) {
|
|
5
5
|
PointerButton[PointerButton["None"] = 0] = "None";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PointerButton, BasePointerSensor } from
|
|
2
|
-
import { FocusSensor } from
|
|
3
|
-
import { WindowSensor } from
|
|
1
|
+
import { PointerButton, BasePointerSensor } from "./BasePointerSensor";
|
|
2
|
+
import { FocusSensor } from "./FocusSensor";
|
|
3
|
+
import { WindowSensor } from "./WindowSensor";
|
|
4
4
|
export declare enum ButtonState {
|
|
5
5
|
Pressed = 0,
|
|
6
6
|
Selecting = 1,
|
|
@@ -7,10 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
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
|
-
import { options, Reentrance, transactional, Transaction, LoggingLevel } from
|
|
11
|
-
import { extractPointerButton, isPointerButtonDown, PointerButton, BasePointerSensor } from
|
|
12
|
-
import { findTargetElementData, SymDataForSensor } from
|
|
13
|
-
import { extractModifierKeys, KeyboardModifiers } from
|
|
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
14
|
export var ButtonState;
|
|
15
15
|
(function (ButtonState) {
|
|
16
16
|
ButtonState[ButtonState["Pressed"] = 0] = "Pressed";
|
|
@@ -33,19 +33,19 @@ export class ButtonSensor extends BasePointerSensor {
|
|
|
33
33
|
const existing = this.sourceElement;
|
|
34
34
|
if (element !== existing) {
|
|
35
35
|
if (existing) {
|
|
36
|
-
existing.removeEventListener(
|
|
37
|
-
existing.removeEventListener(
|
|
38
|
-
existing.removeEventListener(
|
|
39
|
-
existing.removeEventListener(
|
|
40
|
-
existing.removeEventListener(
|
|
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
41
|
}
|
|
42
42
|
this.sourceElement = element;
|
|
43
43
|
if (element && enabled) {
|
|
44
|
-
element.addEventListener(
|
|
45
|
-
element.addEventListener(
|
|
46
|
-
element.addEventListener(
|
|
47
|
-
element.addEventListener(
|
|
48
|
-
element.addEventListener(
|
|
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
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -89,7 +89,7 @@ export class ButtonSensor extends BasePointerSensor {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
onKeyDown(e) {
|
|
92
|
-
if (e.key ===
|
|
92
|
+
if (e.key === "Escape" && this.state !== ButtonState.Released) {
|
|
93
93
|
this.cancel();
|
|
94
94
|
this.reset();
|
|
95
95
|
}
|
|
@@ -99,7 +99,7 @@ export class ButtonSensor extends BasePointerSensor {
|
|
|
99
99
|
this.stopPropagation = false;
|
|
100
100
|
const targetPath = e.composedPath();
|
|
101
101
|
const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
|
|
102
|
-
const { data, window } = findTargetElementData(targetPath, underPointer, SymDataForSensor, [
|
|
102
|
+
const { data, window } = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["button"]);
|
|
103
103
|
const originData = data === null || data === void 0 ? void 0 : data.button;
|
|
104
104
|
if (originData) {
|
|
105
105
|
this.state = ButtonState.Pressed;
|
|
@@ -112,7 +112,7 @@ export class ButtonSensor extends BasePointerSensor {
|
|
|
112
112
|
}
|
|
113
113
|
Transaction.separate(() => {
|
|
114
114
|
var _a;
|
|
115
|
-
(_a = this.windowSensor) === null || _a === void 0 ? void 0 : _a.setActiveWindow(window,
|
|
115
|
+
(_a = this.windowSensor) === null || _a === void 0 ? void 0 : _a.setActiveWindow(window, "button");
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
selecting(e) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const SymDataForSensor = Symbol(
|
|
2
|
-
export const SymResizeObserver = Symbol(
|
|
1
|
+
export const SymDataForSensor = Symbol("DataForSensor");
|
|
2
|
+
export const SymResizeObserver = Symbol("ResizeObserver");
|
|
3
3
|
export const EmptyDataArray = [];
|
|
4
4
|
export function findTargetElementData(targetPath, underPointer, sym, anyOfPayloadKeys, ignoreWindow = false) {
|
|
5
5
|
let result = undefined;
|
|
@@ -11,8 +11,8 @@ export function findTargetElementData(targetPath, underPointer, sym, anyOfPayloa
|
|
|
11
11
|
if (candidateData !== undefined) {
|
|
12
12
|
if (!ignoreWindow) {
|
|
13
13
|
if (window === undefined)
|
|
14
|
-
window = candidateData[
|
|
15
|
-
else if (window !== candidateData[
|
|
14
|
+
window = candidateData["window"];
|
|
15
|
+
else if (window !== candidateData["window"])
|
|
16
16
|
break;
|
|
17
17
|
}
|
|
18
18
|
if (result === undefined) {
|
|
@@ -42,8 +42,8 @@ export function grabElementDataList(targetPath, sym, payloadKey, existing, ignor
|
|
|
42
42
|
if (candidateData !== undefined) {
|
|
43
43
|
if (!ignoreWindow) {
|
|
44
44
|
if (window === undefined)
|
|
45
|
-
window = candidateData[
|
|
46
|
-
else if (window !== candidateData[
|
|
45
|
+
window = candidateData["window"];
|
|
46
|
+
else if (window !== candidateData["window"])
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
payload = candidateData[payloadKey];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ToggleRef } from
|
|
2
|
-
import { HtmlElementSensor } from
|
|
3
|
-
import { WindowSensor } from
|
|
1
|
+
import { ToggleRef } from "reactronic";
|
|
2
|
+
import { HtmlElementSensor } from "./HtmlElementSensor";
|
|
3
|
+
import { WindowSensor } from "./WindowSensor";
|
|
4
4
|
export interface FocusModel {
|
|
5
5
|
isEditMode: boolean;
|
|
6
6
|
onFocusIn?: (focus: FocusSensor) => void;
|
|
@@ -7,10 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
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
|
-
import { options, transactional, LoggingLevel } from
|
|
11
|
-
import { objectHasMember } from
|
|
12
|
-
import { grabElementDataList, SymDataForSensor } from
|
|
13
|
-
import { HtmlElementSensor } from
|
|
10
|
+
import { options, transactional, LoggingLevel } from "reactronic";
|
|
11
|
+
import { objectHasMember } from "../../core/Utils";
|
|
12
|
+
import { grabElementDataList, SymDataForSensor } from "./DataForSensor";
|
|
13
|
+
import { HtmlElementSensor } from "./HtmlElementSensor";
|
|
14
14
|
export class FocusSensor extends HtmlElementSensor {
|
|
15
15
|
constructor(windowSensor) {
|
|
16
16
|
super(undefined, windowSensor);
|
|
@@ -18,16 +18,16 @@ export class FocusSensor extends HtmlElementSensor {
|
|
|
18
18
|
this.oldActiveData = undefined;
|
|
19
19
|
this.contextElementDataList = [];
|
|
20
20
|
}
|
|
21
|
-
setActiveData(data, debugHint =
|
|
21
|
+
setActiveData(data, debugHint = "") {
|
|
22
22
|
var _a, _b;
|
|
23
23
|
if (data !== this.activeData) {
|
|
24
24
|
const activeData = this.activeData;
|
|
25
|
-
if (activeData !== undefined && objectHasMember(activeData,
|
|
25
|
+
if (activeData !== undefined && objectHasMember(activeData, "isEditMode")) {
|
|
26
26
|
activeData.isEditMode = false;
|
|
27
27
|
(_a = activeData.onFocusOut) === null || _a === void 0 ? void 0 : _a.call(activeData, this);
|
|
28
28
|
}
|
|
29
29
|
if (data !== undefined) {
|
|
30
|
-
if (objectHasMember(data,
|
|
30
|
+
if (objectHasMember(data, "isEditMode")) {
|
|
31
31
|
data.isEditMode = true;
|
|
32
32
|
(_b = data.onFocusIn) === null || _b === void 0 ? void 0 : _b.call(data, this);
|
|
33
33
|
}
|
|
@@ -40,15 +40,15 @@ export class FocusSensor extends HtmlElementSensor {
|
|
|
40
40
|
const existing = this.sourceElement;
|
|
41
41
|
if (element !== existing) {
|
|
42
42
|
if (existing) {
|
|
43
|
-
existing.removeEventListener(
|
|
44
|
-
existing.removeEventListener(
|
|
45
|
-
existing.removeEventListener(
|
|
43
|
+
existing.removeEventListener("focusin", this.onFocusIn.bind(this), { capture: true });
|
|
44
|
+
existing.removeEventListener("focusout", this.onFocusOut.bind(this), { capture: true });
|
|
45
|
+
existing.removeEventListener("mousedown", this.onMouseDown.bind(this), { capture: true });
|
|
46
46
|
}
|
|
47
47
|
this.sourceElement = element;
|
|
48
48
|
if (element && enabled) {
|
|
49
|
-
element.addEventListener(
|
|
50
|
-
element.addEventListener(
|
|
51
|
-
element.addEventListener(
|
|
49
|
+
element.addEventListener("focusin", this.onFocusIn.bind(this), { capture: true });
|
|
50
|
+
element.addEventListener("focusout", this.onFocusOut.bind(this), { capture: true });
|
|
51
|
+
element.addEventListener("mousedown", this.onMouseDown.bind(this), { capture: true });
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -71,11 +71,11 @@ export class FocusSensor extends HtmlElementSensor {
|
|
|
71
71
|
doFocusIn(e) {
|
|
72
72
|
var _a;
|
|
73
73
|
const path = e.composedPath();
|
|
74
|
-
const { dataList: focusDataList, activeData: focusActiveData, window } = grabElementDataList(path, SymDataForSensor,
|
|
74
|
+
const { dataList: focusDataList, activeData: focusActiveData, window } = grabElementDataList(path, SymDataForSensor, "focus", this.elementDataList, false, e => document.activeElement === e);
|
|
75
75
|
this.elementDataList = focusDataList;
|
|
76
76
|
this.setActiveData(focusActiveData);
|
|
77
77
|
(_a = this.windowSensor) === null || _a === void 0 ? void 0 : _a.setActiveWindow(window);
|
|
78
|
-
const { dataList: contextDataList } = grabElementDataList(path, SymDataForSensor,
|
|
78
|
+
const { dataList: contextDataList } = grabElementDataList(path, SymDataForSensor, "context", this.contextElementDataList, true);
|
|
79
79
|
this.contextElementDataList = toggleContextRefs(this, this.contextElementDataList, contextDataList);
|
|
80
80
|
this.reset();
|
|
81
81
|
}
|
|
@@ -84,16 +84,16 @@ export class FocusSensor extends HtmlElementSensor {
|
|
|
84
84
|
const isLosingFocus = e.relatedTarget === null;
|
|
85
85
|
if (isLosingFocus) {
|
|
86
86
|
const path = e.composedPath();
|
|
87
|
-
const { dataList } = grabElementDataList(path, SymDataForSensor,
|
|
87
|
+
const { dataList } = grabElementDataList(path, SymDataForSensor, "focus", this.elementDataList, true);
|
|
88
88
|
this.elementDataList = dataList;
|
|
89
89
|
const filteredElementDataList = dataList.filter(x => x !== this.activeData);
|
|
90
90
|
if (filteredElementDataList.length > 0) {
|
|
91
|
-
this.trySetEditMode(filteredElementDataList[0],
|
|
91
|
+
this.trySetEditMode(filteredElementDataList[0], " └─");
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
const defaultData = this.getDefaultSensorData();
|
|
95
95
|
if ((defaultData === null || defaultData === void 0 ? void 0 : defaultData.focus) !== undefined) {
|
|
96
|
-
this.trySetEditMode(defaultData.focus,
|
|
96
|
+
this.trySetEditMode(defaultData.focus, " └─");
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
99
|
this.setActiveData(undefined);
|
|
@@ -110,21 +110,21 @@ export class FocusSensor extends HtmlElementSensor {
|
|
|
110
110
|
const path = e.composedPath();
|
|
111
111
|
const isClickInsideTabIndexedElement = path.find(el => el !== document.body && el.tabIndex >= 0) !== undefined;
|
|
112
112
|
if (path.length > 0 && !isClickInsideTabIndexedElement) {
|
|
113
|
-
const { dataList } = grabElementDataList(path, SymDataForSensor,
|
|
113
|
+
const { dataList } = grabElementDataList(path, SymDataForSensor, "focus", this.elementDataList, true);
|
|
114
114
|
this.elementDataList = dataList;
|
|
115
115
|
if (dataList.length > 0) {
|
|
116
|
-
this.trySetEditMode(dataList[0],
|
|
116
|
+
this.trySetEditMode(dataList[0], "└─");
|
|
117
117
|
e.preventDefault();
|
|
118
118
|
}
|
|
119
|
-
const { dataList: contextDataList } = grabElementDataList(path, SymDataForSensor,
|
|
119
|
+
const { dataList: contextDataList } = grabElementDataList(path, SymDataForSensor, "context", this.contextElementDataList, true);
|
|
120
120
|
this.contextElementDataList = toggleContextRefs(this, this.contextElementDataList, contextDataList);
|
|
121
121
|
this.reset();
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
trySetEditMode(candidateData, indent =
|
|
127
|
-
if (candidateData !== undefined && objectHasMember(candidateData,
|
|
126
|
+
trySetEditMode(candidateData, indent = "") {
|
|
127
|
+
if (candidateData !== undefined && objectHasMember(candidateData, "isEditMode")) {
|
|
128
128
|
candidateData.isEditMode = true;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -165,16 +165,16 @@ function toggleContextRefs(focusSensor, existing, updated) {
|
|
|
165
165
|
if (updated !== existing) {
|
|
166
166
|
existing.forEach(x => {
|
|
167
167
|
var _a;
|
|
168
|
-
if (objectHasMember(x,
|
|
168
|
+
if (objectHasMember(x, "contextToggle") && x.contextToggle && x.contextToggle.valueOn !== x.contextToggle.valueOff)
|
|
169
169
|
x.contextToggle.variable = x.contextToggle.valueOff;
|
|
170
|
-
if (objectHasMember(x,
|
|
170
|
+
if (objectHasMember(x, "onContextOut"))
|
|
171
171
|
(_a = x.onContextOut) === null || _a === void 0 ? void 0 : _a.call(x, focusSensor);
|
|
172
172
|
});
|
|
173
173
|
updated.forEach(x => {
|
|
174
174
|
var _a;
|
|
175
|
-
if (objectHasMember(x,
|
|
175
|
+
if (objectHasMember(x, "contextToggle") && x.contextToggle)
|
|
176
176
|
x.contextToggle.variable = x.contextToggle.valueOn;
|
|
177
|
-
if (objectHasMember(x,
|
|
177
|
+
if (objectHasMember(x, "onContextIn"))
|
|
178
178
|
(_a = x.onContextIn) === null || _a === void 0 ? void 0 : _a.call(x, focusSensor);
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -7,10 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
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
|
-
import { options, transactional, LoggingLevel } from
|
|
11
|
-
import { findTargetElementData, SymDataForSensor } from
|
|
12
|
-
import { extractModifierKeys, KeyboardModifiers } from
|
|
13
|
-
import { BasePointerSensor } from
|
|
10
|
+
import { options, transactional, LoggingLevel } from "reactronic";
|
|
11
|
+
import { findTargetElementData, SymDataForSensor } from "./DataForSensor";
|
|
12
|
+
import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor";
|
|
13
|
+
import { BasePointerSensor } from "./BasePointerSensor";
|
|
14
14
|
export class HoverSensor extends BasePointerSensor {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
@@ -21,13 +21,13 @@ export class HoverSensor extends BasePointerSensor {
|
|
|
21
21
|
const existing = this.sourceElement;
|
|
22
22
|
if (element !== existing) {
|
|
23
23
|
if (existing) {
|
|
24
|
-
existing.removeEventListener(
|
|
25
|
-
existing.removeEventListener(
|
|
24
|
+
existing.removeEventListener("pointerover", this.onPointerOver.bind(this), { capture: true });
|
|
25
|
+
existing.removeEventListener("pointerout", this.onPointerOut.bind(this), { capture: true });
|
|
26
26
|
}
|
|
27
27
|
this.sourceElement = element;
|
|
28
28
|
if (element && enabled) {
|
|
29
|
-
element.addEventListener(
|
|
30
|
-
element.addEventListener(
|
|
29
|
+
element.addEventListener("pointerover", this.onPointerOver.bind(this), { capture: true });
|
|
30
|
+
element.addEventListener("pointerout", this.onPointerOut.bind(this), { capture: true });
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -43,7 +43,7 @@ export class HoverSensor extends BasePointerSensor {
|
|
|
43
43
|
this.stopPropagation = false;
|
|
44
44
|
const targetPath = e.composedPath();
|
|
45
45
|
const underPointer = document.elementsFromPoint(e.clientX, e.clientY);
|
|
46
|
-
this.target = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, [
|
|
46
|
+
this.target = (_a = findTargetElementData(targetPath, underPointer, SymDataForSensor, ["hover"]).data) === null || _a === void 0 ? void 0 : _a.hover;
|
|
47
47
|
this.modifiers = extractModifierKeys(e);
|
|
48
48
|
this.positionX = e.clientX;
|
|
49
49
|
this.positionY = e.clientY;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FocusSensor } from
|
|
2
|
-
import { HtmlElementSensor } from
|
|
3
|
-
import { KeyboardModifiers } from
|
|
4
|
-
import { WindowSensor } from
|
|
5
|
-
export declare type DragEffectAllowed =
|
|
6
|
-
export declare type DropEffect =
|
|
1
|
+
import { FocusSensor } from "./FocusSensor";
|
|
2
|
+
import { HtmlElementSensor } from "./HtmlElementSensor";
|
|
3
|
+
import { KeyboardModifiers } from "./KeyboardSensor";
|
|
4
|
+
import { WindowSensor } from "./WindowSensor";
|
|
5
|
+
export declare type DragEffectAllowed = "none" | "copy" | "copyLink" | "copyMove" | "link" | "linkMove" | "move" | "all" | "uninitialized";
|
|
6
|
+
export declare type DropEffect = "none" | "copy" | "link" | "move";
|
|
7
7
|
export declare class HtmlDragSensor extends HtmlElementSensor {
|
|
8
8
|
draggable: unknown;
|
|
9
9
|
dragSource: unknown;
|