@solidtv/solid 1.2.1 → 1.2.2
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/src/core/activeElement.d.ts +13 -10
- package/dist/src/core/activeElement.js +13 -10
- package/dist/src/core/activeElement.js.map +1 -1
- package/dist/src/core/config.js +1 -1
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/elementNode.js +3 -3
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/focusManager.d.ts +12 -1
- package/dist/src/core/focusManager.js +13 -2
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/primitives/useFocusManager.d.ts +2 -2
- package/dist/src/primitives/useFocusManager.js +2 -2
- package/dist/src/primitives/useFocusManager.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/activeElement.ts +13 -10
- package/src/core/config.ts +1 -1
- package/src/core/elementNode.ts +3 -3
- package/src/core/focusManager.ts +16 -2
- package/src/index.ts +2 -2
- package/src/primitives/useFocusManager.ts +2 -5
package/package.json
CHANGED
|
@@ -5,17 +5,20 @@ import type { ElementNode } from './elementNode.js';
|
|
|
5
5
|
* Generic active-element signal — intentionally decoupled from the focus
|
|
6
6
|
* manager so consumers can drive focus from their own focus-management logic.
|
|
7
7
|
*
|
|
8
|
-
* `
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* `setActiveElement` is the *raw* signal setter: it only updates the reactive
|
|
9
|
+
* value. It does NOT move focus state, fire `onFocus`/`onBlur`, or touch the
|
|
10
|
+
* focus path — that is the focus manager's job (`setActiveElementCore` in
|
|
11
|
+
* {@link ./focusManager.ts}).
|
|
11
12
|
*
|
|
12
|
-
* The built-in focus manager applies focus via `
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
13
|
+
* The built-in focus manager applies focus via `setActiveElementCore` and
|
|
14
|
+
* publishes the result through `Config.setActiveElement`, which defaults to
|
|
15
|
+
* this setter. A library shipping its own focus manager can read
|
|
16
|
+
* {@link activeElement}, reassign `Config.setActiveElement` (e.g. to inject a
|
|
17
|
+
* Solid owner context), or call `setActiveElement` directly — without depending
|
|
18
|
+
* on `focusManager.ts`. Because it is a terminal signal write (it never calls
|
|
19
|
+
* back into the focus manager), wiring it into `Config.setActiveElement` cannot
|
|
20
|
+
* recurse.
|
|
18
21
|
*/
|
|
19
|
-
export const [activeElement,
|
|
22
|
+
export const [activeElement, setActiveElement] = createSignal<
|
|
20
23
|
ElementNode | undefined
|
|
21
24
|
>(undefined);
|
package/src/core/config.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type ElementNode,
|
|
10
10
|
convertToShader as defaultConvertToShader,
|
|
11
11
|
} from './elementNode.js';
|
|
12
|
-
import { setActiveElementSignal } from './activeElement.js';
|
|
12
|
+
import { setActiveElement as setActiveElementSignal } from './activeElement.js';
|
|
13
13
|
import {
|
|
14
14
|
DomRendererMainSettings,
|
|
15
15
|
IRendererShader,
|
package/src/core/elementNode.ts
CHANGED
|
@@ -55,7 +55,7 @@ import { assertTruthy } from '@solidtv/renderer/utils';
|
|
|
55
55
|
import { NodeType, TextNode } from './nodeTypes.js';
|
|
56
56
|
import {
|
|
57
57
|
ForwardFocusHandler,
|
|
58
|
-
|
|
58
|
+
setActiveElementCore,
|
|
59
59
|
FocusNode,
|
|
60
60
|
} from './focusManager.js';
|
|
61
61
|
import { initClickInspector } from './clickInspector.js';
|
|
@@ -130,7 +130,7 @@ function runPostMutation() {
|
|
|
130
130
|
|
|
131
131
|
// Phase 3: focus. setFocus() may have evaluated forwardFocus pre-render
|
|
132
132
|
// (when no children existed yet); deferredFocusElement re-runs setFocus
|
|
133
|
-
// here once the subtree has rendered, then
|
|
133
|
+
// here once the subtree has rendered, then setActiveElementCore is applied.
|
|
134
134
|
if (deferredFocusElement !== null) {
|
|
135
135
|
const el = deferredFocusElement;
|
|
136
136
|
deferredFocusElement = null;
|
|
@@ -138,7 +138,7 @@ function runPostMutation() {
|
|
|
138
138
|
} else if (nextActiveElement !== null) {
|
|
139
139
|
const element = nextActiveElement;
|
|
140
140
|
nextActiveElement = null;
|
|
141
|
-
|
|
141
|
+
setActiveElementCore(element);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
package/src/core/focusManager.ts
CHANGED
|
@@ -9,7 +9,10 @@ import type {
|
|
|
9
9
|
KeyMap,
|
|
10
10
|
} from './focusKeyTypes.js';
|
|
11
11
|
import { isFunction } from './utils.js';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
activeElement,
|
|
14
|
+
setActiveElement as setActiveElementSignal,
|
|
15
|
+
} from './activeElement.js';
|
|
13
16
|
|
|
14
17
|
let _signalWrapper: (cb: () => void) => void = (cb) => cb();
|
|
15
18
|
|
|
@@ -201,7 +204,18 @@ export const printFocusHistory = (count: number): void => {
|
|
|
201
204
|
|
|
202
205
|
// ---------------------------------------------------------------------------
|
|
203
206
|
|
|
204
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Built-in "apply focus" routine: diffs the focus path, fires
|
|
209
|
+
* `onFocus`/`onBlur`/`onFocusChanged`, records history, then publishes the
|
|
210
|
+
* active element through the `Config.setActiveElement` hook.
|
|
211
|
+
*
|
|
212
|
+
* This is what `ElementNode.setFocus()` ultimately invokes. It is intentionally
|
|
213
|
+
* *not* the public `setActiveElement` export — that name is the raw signal
|
|
214
|
+
* setter (see {@link ./activeElement.ts}). Keeping them separate is what stops
|
|
215
|
+
* a custom `Config.setActiveElement` (wired to a setter) from recursing back
|
|
216
|
+
* through the focus-path logic.
|
|
217
|
+
*/
|
|
218
|
+
export const setActiveElementCore = (elm: ElementNode) => {
|
|
205
219
|
const prev = activeElement();
|
|
206
220
|
if (elm === prev) return;
|
|
207
221
|
updateFocusPath(elm, prev);
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ export type * from '@solidtv/solid/jsx-runtime';
|
|
|
2
2
|
export * from './core/index.js';
|
|
3
3
|
export type * from './core/index.js';
|
|
4
4
|
export type { KeyHandler, KeyMap } from './core/focusManager.js';
|
|
5
|
-
export { activeElement,
|
|
6
|
-
export {
|
|
5
|
+
export { activeElement, setActiveElement } from './core/activeElement.js';
|
|
6
|
+
export { setActiveElementCore } from './core/focusManager.js';
|
|
7
7
|
export * from './utils.js';
|
|
8
8
|
export * from './render.js';
|
|
9
9
|
export * from './types.js';
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export {
|
|
2
2
|
focusPath,
|
|
3
3
|
useFocusManager,
|
|
4
|
-
|
|
4
|
+
setActiveElementCore,
|
|
5
5
|
type KeyMap,
|
|
6
6
|
type KeyHoldOptions,
|
|
7
7
|
} from '../core/focusManager.js';
|
|
8
|
-
export {
|
|
9
|
-
activeElement,
|
|
10
|
-
setActiveElementSignal,
|
|
11
|
-
} from '../core/activeElement.js';
|
|
8
|
+
export { activeElement, setActiveElement } from '../core/activeElement.js';
|