forked from 1egoman/debundle
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheck-require.js
116 lines (115 loc) · 3.03 KB
/
check-require.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* origin:
function(e, t, r) {
"use strict";
r.d(t, "a", (function() {
return a
}
));
var n = r(0);
const a = ({initialOpen: e=!1}={})=>{
const [t,r] = Object(n.useState)(e)
, [a,o] = Object(n.useState)(!1)
, i = Object(n.useRef)(null);
return Object(n.useEffect)(()=>{
const e = n=>{
t && (n.target === window || i.current && i.current.contains && !i.current.contains(n.target)) && (r(!1),
o(!1),
removeEventListener("click", e),
removeEventListener("focusin", e),
removeEventListener("blur", e))
}
;
return i.current && t && (addEventListener("click", e),
addEventListener("focusin", e),
addEventListener("blur", e)),
()=>{
removeEventListener("click", e),
removeEventListener("focusin", e),
removeEventListener("blur", e)
}
}
, [t]),
{
expanded: t,
handlers: {
onKeyDown: e=>{
"Esc" !== e.key && "Escape" !== e.key || r(!1)
}
,
onClick: ()=>r(!0),
onFocus: ()=>r(!0),
onMouseEnter: ()=>o(!0),
onMouseLeave: ()=>o(!1)
},
hovered: a,
open: t || a,
setExpanded: r,
setHovered: o,
toggleExpanded: ()=>{
r(!t),
o(!1)
}
,
wrapperRef: i
}
}
}
*/
const t = exports;
const e = module;
const r = require;
("use strict");
require.d(t, "a", function () {
return a;
});
var n = require("./React_");
const a = ({ initialOpen: e = false } = {}) => {
const [t, r] = Object(n.useState)(e),
[a, o] = Object(n.useState)(false),
i = Object(n.useRef)(null);
Object(n.useEffect)(() => {
const e = (n) => {
t &&
(n.target === window ||
(i.current && i.current.contains && !i.current.contains(n.target))) &&
(require,
o(false),
removeEventListener("click", e),
removeEventListener("focusin", e),
removeEventListener("blur", e));
};
return (
i.current &&
t &&
(addEventListener("click", e),
addEventListener("focusin", e),
addEventListener("blur", e)),
() => {
removeEventListener("click", e),
removeEventListener("focusin", e),
removeEventListener("blur", e);
}
);
}, [t]);
return {
expanded: t,
handlers: {
onKeyDown: (e) => {
("Esc" !== e.key && "Escape" !== e.key) || require;
},
onClick: () => require,
onFocus: () => require,
onMouseEnter: () => o(true),
onMouseLeave: () => o(false),
},
hovered: a,
open: t || a,
setExpanded: r,
setHovered: o,
toggleExpanded: () => {
require, o(false);
},
wrapperRef: i,
};
};
exports.a = a;