@lightningtv/solid 0.0.8 → 0.0.10
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/dist/{source → src}/Text.jsx +1 -0
- package/dist/src/Text.jsx.map +1 -0
- package/dist/{source → src}/View.jsx +1 -0
- package/dist/src/View.jsx.map +1 -0
- package/dist/{types → src}/activeElement.d.ts +1 -1
- package/dist/{source → src}/activeElement.js +1 -0
- package/dist/src/activeElement.js.map +1 -0
- package/dist/{types → src}/index.d.ts +3 -4
- package/dist/{source → src}/index.js +4 -4
- package/dist/src/index.js.map +1 -0
- package/dist/src/jsx-runtime.js +2 -0
- package/dist/src/jsx-runtime.js.map +1 -0
- package/dist/{source → src}/primitives/announcer/announcer.js +1 -0
- package/dist/src/primitives/announcer/announcer.js.map +1 -0
- package/dist/{source → src}/primitives/announcer/index.js +1 -0
- package/dist/src/primitives/announcer/index.js.map +1 -0
- package/dist/{source → src}/primitives/announcer/speech.js +1 -0
- package/dist/src/primitives/announcer/speech.js.map +1 -0
- package/dist/{source → src}/primitives/createInfiniteItems.js +1 -0
- package/dist/src/primitives/createInfiniteItems.js.map +1 -0
- package/dist/{types → src}/primitives/createSpriteMap.d.ts +1 -0
- package/dist/{source → src}/primitives/createSpriteMap.js +1 -0
- package/dist/src/primitives/createSpriteMap.js.map +1 -0
- package/dist/{source → src}/primitives/index.js +1 -0
- package/dist/src/primitives/index.js.map +1 -0
- package/dist/{source → src}/primitives/portal.jsx +1 -0
- package/dist/src/primitives/portal.jsx.map +1 -0
- package/dist/{source → src}/primitives/useFocusManager.js +1 -0
- package/dist/src/primitives/useFocusManager.js.map +1 -0
- package/dist/{source → src}/primitives/useMouse.js +29 -13
- package/dist/src/primitives/useMouse.js.map +1 -0
- package/dist/{source → src}/primitives/withPadding.js +1 -0
- package/dist/src/primitives/withPadding.js.map +1 -0
- package/dist/src/render.d.ts +22 -0
- package/dist/{source → src}/render.js +1 -0
- package/dist/src/render.js.map +1 -0
- package/dist/{source → src}/solidOpts.js +1 -0
- package/dist/src/solidOpts.js.map +1 -0
- package/dist/{source → src}/utils.js +1 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +12 -8
- package/src/index.ts +6 -7
- package/src/primitives/useMouse.ts +39 -18
- package/dist/esm/index.js +0 -1011
- package/dist/esm/index.js.map +0 -1
- package/dist/source/jsx-runtime.js +0 -1
- package/dist/types/render.d.ts +0 -22
- /package/dist/{types → src}/Text.d.ts +0 -0
- /package/dist/{types → src}/View.d.ts +0 -0
- /package/dist/{types → src}/jsx-runtime.d.ts +0 -0
- /package/dist/{types → src}/primitives/announcer/announcer.d.ts +0 -0
- /package/dist/{types → src}/primitives/announcer/index.d.ts +0 -0
- /package/dist/{types → src}/primitives/announcer/speech.d.ts +0 -0
- /package/dist/{types → src}/primitives/createInfiniteItems.d.ts +0 -0
- /package/dist/{types → src}/primitives/index.d.ts +0 -0
- /package/dist/{types → src}/primitives/portal.d.ts +0 -0
- /package/dist/{types → src}/primitives/useFocusManager.d.ts +0 -0
- /package/dist/{types → src}/primitives/useMouse.d.ts +0 -0
- /package/dist/{types → src}/primitives/withPadding.d.ts +0 -0
- /package/dist/{types → src}/solidOpts.d.ts +0 -0
- /package/dist/{types → src}/utils.d.ts +0 -0
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
activeElement,
|
|
5
5
|
setActiveElement,
|
|
6
6
|
rootNode,
|
|
7
|
+
Config,
|
|
7
8
|
} from '@lightningtv/solid';
|
|
8
9
|
import { makeEventListener } from '@solid-primitives/event-listener';
|
|
9
10
|
import { useMousePosition } from '@solid-primitives/mouse';
|
|
@@ -41,15 +42,16 @@ const handleScroll = throttle((e: WheelEvent): void => {
|
|
|
41
42
|
|
|
42
43
|
const handleClick = (e: MouseEvent): void => {
|
|
43
44
|
const active = activeElement();
|
|
45
|
+
const precision = Config.rendererOptions?.deviceLogicalPixelRatio || 1;
|
|
44
46
|
if (
|
|
45
47
|
active &&
|
|
46
48
|
testCollision(
|
|
47
49
|
e.clientX,
|
|
48
50
|
e.clientY,
|
|
49
|
-
(active.lng as MainOnlyNode).coreNode.absX,
|
|
50
|
-
(active.lng as MainOnlyNode).coreNode.absY,
|
|
51
|
-
active.width,
|
|
52
|
-
active.height,
|
|
51
|
+
(active.lng as MainOnlyNode).coreNode.absX * precision,
|
|
52
|
+
(active.lng as MainOnlyNode).coreNode.absY * precision,
|
|
53
|
+
active.width! * precision,
|
|
54
|
+
active.height! * precision,
|
|
53
55
|
)
|
|
54
56
|
) {
|
|
55
57
|
document.dispatchEvent(createKeyboardEvent('Enter', 13));
|
|
@@ -72,26 +74,45 @@ function getChildrenByPosition(
|
|
|
72
74
|
x: number,
|
|
73
75
|
y: number,
|
|
74
76
|
): ElementNode[] {
|
|
75
|
-
|
|
77
|
+
const result: ElementNode[] = [];
|
|
78
|
+
const precision = Config.rendererOptions?.deviceLogicalPixelRatio || 1;
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
// Queue for BFS
|
|
81
|
+
let queue: ElementNode[] = [node];
|
|
82
|
+
|
|
83
|
+
while (queue.length > 0) {
|
|
84
|
+
// Process nodes at the current level
|
|
85
|
+
const currentLevelNodes: ElementNode[] = [];
|
|
86
|
+
|
|
87
|
+
for (const currentNode of queue) {
|
|
80
88
|
if (
|
|
81
|
-
|
|
89
|
+
currentNode.alpha !== 0 &&
|
|
82
90
|
testCollision(
|
|
83
91
|
x,
|
|
84
92
|
y,
|
|
85
|
-
(
|
|
86
|
-
(
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
(currentNode.lng as MainOnlyNode).coreNode.absX * precision,
|
|
94
|
+
(currentNode.lng as MainOnlyNode).coreNode.absY * precision,
|
|
95
|
+
currentNode.width! * precision,
|
|
96
|
+
currentNode.height! * precision,
|
|
89
97
|
)
|
|
90
98
|
) {
|
|
91
|
-
|
|
92
|
-
result = [...result, ...getChildrenByPosition(child, x, y)];
|
|
99
|
+
currentLevelNodes.push(currentNode);
|
|
93
100
|
}
|
|
94
101
|
}
|
|
102
|
+
|
|
103
|
+
const size = currentLevelNodes.length;
|
|
104
|
+
if (size === 0) {
|
|
105
|
+
break;
|
|
106
|
+
} else if (size > 1) {
|
|
107
|
+
// Find the node with the highest zIndex
|
|
108
|
+
currentLevelNodes.sort((a, b) => (a.zIndex || 0) - (b.zIndex || 0));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const highestZIndexNode = currentLevelNodes[0] as ElementNode;
|
|
112
|
+
result.push(highestZIndexNode);
|
|
113
|
+
if (!highestZIndexNode.isTextNode()) {
|
|
114
|
+
queue = highestZIndexNode.children as ElementNode[];
|
|
115
|
+
}
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
return result;
|
|
@@ -104,9 +125,9 @@ export function useMouse(myApp: ElementNode = rootNode): void {
|
|
|
104
125
|
makeEventListener(window, 'click', handleClick);
|
|
105
126
|
createEffect(() => {
|
|
106
127
|
if (scheduled()) {
|
|
107
|
-
const result = getChildrenByPosition(myApp, pos.x, pos.y)
|
|
108
|
-
|
|
109
|
-
|
|
128
|
+
const result = getChildrenByPosition(myApp, pos.x, pos.y).filter(
|
|
129
|
+
(el) => (el.focus || el.onFocus || el.onEnter) && !el.skipFocus,
|
|
130
|
+
);
|
|
110
131
|
|
|
111
132
|
if (result.length) {
|
|
112
133
|
let activeElm = result[result.length - 1];
|