decord/source/1538_useFocusEvents.js

77 lines
1.9 KiB
JavaScript
Raw Normal View History

2026-07-29 08:29:29 +00:00
// Module ID: 1538
// Function ID: 1539
2026-07-20 16:05:17 +00:00
// Name: useFocusEvents
2026-07-29 08:29:29 +00:00
// Dependencies: [19, 1508]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-07-29 08:29:29 +00:00
// Module 1538 (useFocusEvents)
import noop from "noop";
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
export default function useFocusEvents(arg0) {
let emitter;
let state;
({ state, emitter } = arg0);
2026-07-29 08:29:29 +00:00
let context;
let React;
let key;
2026-07-23 10:11:24 +00:00
context = React.useContext(emitter(context[1]));
React = React.useRef();
2026-07-29 08:29:29 +00:00
key = state.routes[state.index].key;
2026-07-20 16:05:17 +00:00
const items = [key, emitter, context];
const effect = React.useEffect(() => {
let addListenerResult;
2026-07-29 08:29:29 +00:00
if (context != null) {
2026-07-20 16:05:17 +00:00
addListenerResult = context.addListener("focus", () => {
2026-07-29 08:29:29 +00:00
noop.current = closure_3;
closure_0.emit({ type: "focus", target: closure_3 });
2026-07-20 16:05:17 +00:00
});
}
return addListenerResult;
}, items);
const items1 = [key, emitter, context];
const effect1 = React.useEffect(() => {
let addListenerResult;
2026-07-29 08:29:29 +00:00
if (context != null) {
2026-07-20 16:05:17 +00:00
addListenerResult = context.addListener("blur", () => {
2026-07-29 08:29:29 +00:00
noop.current = undefined;
closure_0.emit({ type: "blur", target: closure_3 });
2026-07-20 16:05:17 +00:00
});
}
return addListenerResult;
}, items1);
const items2 = [key, emitter, context];
const effect2 = React.useEffect(() => {
const current = ref.current;
ref.current = key;
2026-07-29 08:29:29 +00:00
let tmp3 = tmp2;
2026-07-20 16:05:17 +00:00
if (undefined === current) {
2026-07-29 08:29:29 +00:00
tmp3 = context;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!tmp3) {
let obj = { type: "focus", target: null };
obj[1] = tmp;
2026-07-20 16:05:17 +00:00
emitter.emit(obj);
}
2026-07-29 08:29:29 +00:00
let tmp6 = current === tmp;
2026-07-20 16:05:17 +00:00
if (!tmp6) {
let tmp7 = context;
if (context) {
2026-07-29 08:29:29 +00:00
tmp7 = !obj2.isFocused();
2026-07-20 16:05:17 +00:00
}
tmp6 = tmp7;
2026-07-29 08:29:29 +00:00
obj2 = context;
2026-07-20 16:05:17 +00:00
}
if (!tmp6) {
2026-07-29 08:29:29 +00:00
if (tmp2) {
obj = { type: "blur", target: null };
obj[1] = current;
2026-07-20 16:05:17 +00:00
emitter.emit(obj);
2026-07-29 08:29:29 +00:00
obj = { type: "focus", target: null };
obj[1] = tmp;
2026-07-20 16:05:17 +00:00
emitter.emit(obj);
}
}
}, items2);
};