se-design 1.0.50 → 1.0.51
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/components/Dropdown/index.d.ts +1 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/index17.js +126 -114
- package/dist/index17.js.map +1 -1
- package/dist/index177.js +5 -5
- package/dist/index185.js +1 -1
- package/dist/index217.js +5 -10
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +21 -9
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +9 -4
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +10 -170
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +5 -11
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +169 -4
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +11 -22
- package/dist/index223.js.map +1 -1
- package/dist/index23.js +6 -6
- package/dist/index23.js.map +1 -1
- package/dist/index65.js +1 -1
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ type DropdownProps = {
|
|
|
23
23
|
hasError?: boolean;
|
|
24
24
|
errorMessage?: string;
|
|
25
25
|
onApply?: (selectedValue: DropdownValue[]) => void;
|
|
26
|
+
onClear?: () => void;
|
|
26
27
|
customDropdownContent?: () => React.ReactNode;
|
|
27
28
|
isBorderless?: boolean;
|
|
28
29
|
dropDownSrcAutomationId?: string;
|
|
@@ -25,5 +25,6 @@ export interface PopoverProps {
|
|
|
25
25
|
sourceRole?: 'button' | 'combobox';
|
|
26
26
|
popoverContentStyleProperty?: React.CSSProperties;
|
|
27
27
|
disableClickToggle?: boolean;
|
|
28
|
+
disableAutoClose?: boolean;
|
|
28
29
|
}
|
|
29
30
|
export declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<PopoverHandle>>;
|
package/dist/index17.js
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { getA11yNameAttributes as
|
|
4
|
-
function
|
|
5
|
-
return
|
|
6
|
-
for (var
|
|
7
|
-
var p = arguments[
|
|
8
|
-
for (var
|
|
1
|
+
import H, { forwardRef as se, useState as L, useRef as I, useEffect as C, useImperativeHandle as ce } from "react";
|
|
2
|
+
import ae from "react-dom";
|
|
3
|
+
import { getA11yNameAttributes as le } from "./index64.js";
|
|
4
|
+
function B() {
|
|
5
|
+
return B = Object.assign ? Object.assign.bind() : function(h) {
|
|
6
|
+
for (var y = 1; y < arguments.length; y++) {
|
|
7
|
+
var p = arguments[y];
|
|
8
|
+
for (var g in p) ({}).hasOwnProperty.call(p, g) && (h[g] = p[g]);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
11
|
-
},
|
|
10
|
+
return h;
|
|
11
|
+
}, B.apply(null, arguments);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
className:
|
|
15
|
-
automationId:
|
|
13
|
+
const de = /* @__PURE__ */ se(({
|
|
14
|
+
className: h = "",
|
|
15
|
+
automationId: y = "",
|
|
16
16
|
position: p = "bottom-center",
|
|
17
|
-
popoverContentAutomationId:
|
|
18
|
-
contentWidth:
|
|
19
|
-
renderPopoverContents:
|
|
20
|
-
renderPopoverSrcElement:
|
|
21
|
-
onPopoverToggle:
|
|
22
|
-
isPopoverOpen:
|
|
23
|
-
disabled:
|
|
24
|
-
isWithPortal:
|
|
25
|
-
ariaLabel:
|
|
26
|
-
ariaLabelledBy:
|
|
27
|
-
sourceRole:
|
|
28
|
-
popoverContentStyleProperty:
|
|
17
|
+
popoverContentAutomationId: g = "",
|
|
18
|
+
contentWidth: N = "max",
|
|
19
|
+
renderPopoverContents: T,
|
|
20
|
+
renderPopoverSrcElement: X,
|
|
21
|
+
onPopoverToggle: j,
|
|
22
|
+
isPopoverOpen: F,
|
|
23
|
+
disabled: k = !1,
|
|
24
|
+
isWithPortal: b = !1,
|
|
25
|
+
ariaLabel: G,
|
|
26
|
+
ariaLabelledBy: J,
|
|
27
|
+
sourceRole: z = "button",
|
|
28
|
+
popoverContentStyleProperty: O = {
|
|
29
29
|
zIndex: 1e3,
|
|
30
30
|
borderColor: "var(--color-gray-200)",
|
|
31
31
|
color: "var(--color-gray-900)",
|
|
32
32
|
backgroundColor: "var(--color-white)"
|
|
33
33
|
},
|
|
34
|
-
disableClickToggle:
|
|
35
|
-
noBorder:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
disableClickToggle: Q = !1,
|
|
35
|
+
noBorder: Y = !1,
|
|
36
|
+
disableAutoClose: d = !1,
|
|
37
|
+
...Z
|
|
38
|
+
}, ee) => {
|
|
39
|
+
const [s, f] = L(!1), [w, $] = L(p), [te, q] = L(!1), l = I(null), a = I(null), K = I(d);
|
|
40
|
+
K.current = d;
|
|
41
|
+
const oe = le({
|
|
42
|
+
ariaLabel: G,
|
|
43
|
+
ariaLabelledBy: J,
|
|
41
44
|
ariaDescribedBy: void 0
|
|
42
45
|
// Popover doesn't support describedBy yet
|
|
43
|
-
}), [
|
|
46
|
+
}), [M, P] = L({
|
|
44
47
|
top: 0,
|
|
45
48
|
left: 0
|
|
46
|
-
}),
|
|
49
|
+
}), E = (e = "bottom-center") => {
|
|
47
50
|
if (!l.current) return {
|
|
48
51
|
top: 0,
|
|
49
52
|
left: 0
|
|
@@ -74,90 +77,98 @@ const ue = /* @__PURE__ */ ne(({
|
|
|
74
77
|
n = t.bottom, r = t.left;
|
|
75
78
|
break;
|
|
76
79
|
}
|
|
77
|
-
const
|
|
78
|
-
if ((o === "bottom-center" || o === "top-center") && (r = r -
|
|
79
|
-
const
|
|
80
|
-
|
|
80
|
+
const u = a.current?.getBoundingClientRect(), v = u?.width || 0, m = u?.height || 0;
|
|
81
|
+
if ((o === "bottom-center" || o === "top-center") && (r = r - v / 2), r + v > i && (r = Math.max(0, i - v)), r < 0 && (r = 0), n + m > c) {
|
|
82
|
+
const x = t.top, ie = c - t.bottom;
|
|
83
|
+
x >= m || x > ie ? (n = t.top - m, n < 0 && (n = 0)) : n = Math.max(0, c - m);
|
|
81
84
|
}
|
|
82
|
-
return n < 0 && (n = t.bottom, n +
|
|
85
|
+
return n < 0 && (n = t.bottom, n + m > c && (n = Math.max(0, c - m))), {
|
|
83
86
|
top: n,
|
|
84
87
|
left: r
|
|
85
88
|
};
|
|
86
89
|
};
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
return document.body.addEventListener("click",
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
C(() => {
|
|
91
|
+
if (j && j(s), s && !b)
|
|
92
|
+
return d || document.body.addEventListener("click", U, !0), ne(), () => {
|
|
93
|
+
d || document.body.removeEventListener("click", U, !0);
|
|
94
|
+
};
|
|
95
|
+
if (s && b) {
|
|
96
|
+
d ? window.addEventListener("scroll", _) : (document.body.addEventListener("click", R, !0), window.addEventListener("scroll", R)), window.addEventListener("resize", V);
|
|
92
97
|
const e = setTimeout(() => {
|
|
93
|
-
const t =
|
|
94
|
-
|
|
98
|
+
const t = E(w);
|
|
99
|
+
D(), t && P(t);
|
|
95
100
|
}, 0), o = setTimeout(() => {
|
|
96
|
-
const t =
|
|
101
|
+
const t = E(w);
|
|
97
102
|
t && P(t);
|
|
98
103
|
}, 10);
|
|
99
104
|
return () => {
|
|
100
|
-
document.body.removeEventListener("click",
|
|
105
|
+
d ? window.removeEventListener("scroll", _) : (document.body.removeEventListener("click", R, !0), window.removeEventListener("scroll", R)), window.removeEventListener("resize", V), clearTimeout(e), clearTimeout(o);
|
|
101
106
|
};
|
|
102
107
|
}
|
|
103
|
-
}, [s,
|
|
104
|
-
const
|
|
108
|
+
}, [s, b, d]);
|
|
109
|
+
const D = () => {
|
|
105
110
|
if (!l.current) {
|
|
106
|
-
|
|
111
|
+
q(!1);
|
|
107
112
|
return;
|
|
108
113
|
}
|
|
109
114
|
const e = l.current.getBoundingClientRect(), o = window.innerHeight, t = window.innerWidth, i = e.top < o && e.bottom > 0 && e.left < t && e.right > 0;
|
|
110
|
-
|
|
115
|
+
q(i);
|
|
111
116
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}, [
|
|
117
|
+
C(() => {
|
|
118
|
+
f(F ?? !1);
|
|
119
|
+
}, [F]), C(() => {
|
|
115
120
|
s && a.current && setTimeout(() => {
|
|
116
121
|
const e = ['[role="menuitem"]', '[role="option"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]', "button:not([disabled])", "a[href]", '[tabindex]:not([tabindex="-1"])'].join(", "), o = a.current?.querySelector(e);
|
|
117
122
|
o && document.activeElement === l.current && o.focus();
|
|
118
123
|
}, 0);
|
|
119
124
|
}, [s]);
|
|
120
|
-
const
|
|
125
|
+
const ne = () => {
|
|
121
126
|
if (!a.current) return;
|
|
122
127
|
const e = a.current.getBoundingClientRect(), o = window.innerHeight;
|
|
123
|
-
e?.bottom > o ?
|
|
124
|
-
},
|
|
128
|
+
e?.bottom > o ? $(p.includes("left") ? "top-left" : p.includes("right") ? "top-right" : "top-center") : e?.top < 0 && $(p.includes("left") ? "bottom-left" : p.includes("right") ? "bottom-right" : "bottom-center");
|
|
129
|
+
}, U = (e) => {
|
|
125
130
|
const o = l.current;
|
|
126
131
|
if (!o) return;
|
|
127
|
-
const t = e.target, i = o.contains(t), c = a.current?.contains(t), r = t.closest?.(".se-design-popover-wrapper"),
|
|
128
|
-
(!i && !c ||
|
|
129
|
-
},
|
|
132
|
+
const t = e.target, i = o.contains(t), c = a.current?.contains(t), r = t.closest?.(".se-design-popover-wrapper"), u = r && r !== o, v = a.current?.contains(r);
|
|
133
|
+
d || (!i && !c || u && !v) && f(!1);
|
|
134
|
+
}, R = (e) => {
|
|
130
135
|
const o = l.current, t = a.current;
|
|
131
136
|
if (!o) return;
|
|
132
|
-
if (
|
|
133
|
-
const
|
|
134
|
-
|
|
137
|
+
if (D(), e.type === "scroll" && s) {
|
|
138
|
+
const x = E(w);
|
|
139
|
+
x && P(x);
|
|
140
|
+
}
|
|
141
|
+
const i = e.target, c = o.contains(i), n = t?.contains(i), u = i.closest?.(".se-design-popover-wrapper"), v = u && u !== o, m = a.current?.contains(u);
|
|
142
|
+
d || (!c && !n || v && !m) && f(!1);
|
|
143
|
+
}, V = () => {
|
|
144
|
+
if (s && b && l.current) {
|
|
145
|
+
D();
|
|
146
|
+
const e = E(w);
|
|
147
|
+
e && P(e);
|
|
135
148
|
}
|
|
136
|
-
|
|
137
|
-
(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
S();
|
|
141
|
-
const e = x(y);
|
|
149
|
+
}, _ = () => {
|
|
150
|
+
if (s && b && l.current) {
|
|
151
|
+
D();
|
|
152
|
+
const e = E(w);
|
|
142
153
|
e && P(e);
|
|
143
154
|
}
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
},
|
|
155
|
+
}, S = () => {
|
|
156
|
+
f((e) => !e);
|
|
157
|
+
}, A = (e, o) => {
|
|
147
158
|
if (!o) return;
|
|
148
159
|
const t = ['[role="menuitem"]', '[role="option"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]', "button:not([disabled])", "a[href]", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", '[tabindex]:not([tabindex="-1"])'].join(", "), i = Array.from(o.querySelectorAll(t)).filter((r) => {
|
|
149
|
-
const
|
|
150
|
-
return !r.hasAttribute("disabled") && !r.hasAttribute("aria-disabled") &&
|
|
160
|
+
const u = window.getComputedStyle(r);
|
|
161
|
+
return !r.hasAttribute("disabled") && !r.hasAttribute("aria-disabled") && u.display !== "none" && u.visibility !== "hidden" && (r.tabIndex >= 0 || r.hasAttribute("role"));
|
|
151
162
|
});
|
|
152
163
|
if (i.length === 0) return;
|
|
153
164
|
const c = i.findIndex((r) => r === document.activeElement);
|
|
154
165
|
let n = -1;
|
|
155
166
|
e.key === "ArrowDown" ? (e.preventDefault(), e.stopPropagation(), n = c < i.length - 1 ? c + 1 : 0) : e.key === "ArrowUp" ? (e.preventDefault(), e.stopPropagation(), n = c > 0 ? c - 1 : i.length - 1) : e.key === "Home" ? (e.preventDefault(), e.stopPropagation(), n = 0) : e.key === "End" && (e.preventDefault(), e.stopPropagation(), n = i.length - 1), n >= 0 && i[n] ? i[n].focus() : c === -1 && i.length > 0 && i[0].focus();
|
|
156
167
|
};
|
|
157
|
-
|
|
158
|
-
togglePopover:
|
|
168
|
+
ce(ee, () => ({
|
|
169
|
+
togglePopover: S
|
|
159
170
|
}), []);
|
|
160
|
-
const
|
|
171
|
+
const re = {
|
|
161
172
|
"bottom-left": {
|
|
162
173
|
left: "0",
|
|
163
174
|
top: "100%"
|
|
@@ -184,19 +195,19 @@ const ue = /* @__PURE__ */ ne(({
|
|
|
184
195
|
transform: "translateX(-50%)",
|
|
185
196
|
bottom: "100%"
|
|
186
197
|
}
|
|
187
|
-
},
|
|
188
|
-
return /* @__PURE__ */
|
|
189
|
-
className: "se-design-popover-wrapper cursor-pointer relative" + (
|
|
198
|
+
}, W = Y ? "" : "shadow-md border rounded-md";
|
|
199
|
+
return /* @__PURE__ */ H.createElement("div", B({
|
|
200
|
+
className: "se-design-popover-wrapper cursor-pointer relative" + (h.length > 0 ? ` ${h}` : "") + (s ? " open" : "") + (k ? " opacity-50 cursor-not-allowed pointer-events-none" : ""),
|
|
190
201
|
ref: l,
|
|
191
202
|
onClick: (e) => {
|
|
192
|
-
|
|
203
|
+
k || Q || (e.stopPropagation(), S());
|
|
193
204
|
},
|
|
194
205
|
onKeyDown: (e) => {
|
|
195
|
-
if (!
|
|
206
|
+
if (!k)
|
|
196
207
|
if (e.key === "Enter" || e.key === " ") {
|
|
197
208
|
e.preventDefault(), e.stopPropagation();
|
|
198
209
|
const o = s;
|
|
199
|
-
|
|
210
|
+
S(), o || setTimeout(() => {
|
|
200
211
|
const t = a.current;
|
|
201
212
|
if (t) {
|
|
202
213
|
const i = ['[role="menuitem"]', '[role="option"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]', "button:not([disabled])", "a[href]", '[tabindex]:not([tabindex="-1"])'].join(", "), c = t.querySelector(i);
|
|
@@ -204,11 +215,11 @@ const ue = /* @__PURE__ */ ne(({
|
|
|
204
215
|
}
|
|
205
216
|
}, 0);
|
|
206
217
|
} else if (e.key === "Escape" && s)
|
|
207
|
-
e.preventDefault(), e.stopPropagation(),
|
|
218
|
+
e.preventDefault(), e.stopPropagation(), f(!1);
|
|
208
219
|
else if ((e.key === "ArrowDown" || e.key === "ArrowUp") && s) {
|
|
209
220
|
const o = a.current;
|
|
210
|
-
o &&
|
|
211
|
-
} else e.key === "ArrowDown" && !s && (e.preventDefault(), e.stopPropagation(),
|
|
221
|
+
o && A(e, o);
|
|
222
|
+
} else e.key === "ArrowDown" && !s && (e.preventDefault(), e.stopPropagation(), f(!0), setTimeout(() => {
|
|
212
223
|
const o = a.current;
|
|
213
224
|
if (o) {
|
|
214
225
|
const t = ['[role="menuitem"]', '[role="option"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]', "button:not([disabled])", "a[href]", '[tabindex]:not([tabindex="-1"])'].join(", "), i = o.querySelector(t);
|
|
@@ -218,53 +229,54 @@ const ue = /* @__PURE__ */ ne(({
|
|
|
218
229
|
},
|
|
219
230
|
onBlur: () => {
|
|
220
231
|
s && setTimeout(() => {
|
|
232
|
+
if (K.current) return;
|
|
221
233
|
const e = document.activeElement, o = l.current?.contains(e), t = a.current?.contains(e);
|
|
222
|
-
!o && !t &&
|
|
234
|
+
!o && !t && f(!1);
|
|
223
235
|
}, 0);
|
|
224
236
|
},
|
|
225
|
-
role:
|
|
237
|
+
role: z,
|
|
226
238
|
"aria-expanded": s ? "true" : "false",
|
|
227
|
-
"aria-haspopup":
|
|
228
|
-
tabIndex:
|
|
229
|
-
"aria-disabled":
|
|
230
|
-
},
|
|
231
|
-
"data-automation-id":
|
|
232
|
-
},
|
|
239
|
+
"aria-haspopup": z === "combobox" ? "listbox" : "true",
|
|
240
|
+
tabIndex: k ? -1 : 0,
|
|
241
|
+
"aria-disabled": k ? "true" : "false"
|
|
242
|
+
}, oe, {
|
|
243
|
+
"data-automation-id": y
|
|
244
|
+
}, Z), X({
|
|
233
245
|
displayPopover: s,
|
|
234
|
-
togglePopover:
|
|
235
|
-
}), s && !
|
|
236
|
-
className: `popover-content absolute ${
|
|
246
|
+
togglePopover: S
|
|
247
|
+
}), s && !b && /* @__PURE__ */ H.createElement("div", {
|
|
248
|
+
className: `popover-content absolute ${W} z-[1000] ${N == "full" ? "w-full" : "w-max"}`,
|
|
237
249
|
style: {
|
|
238
|
-
...
|
|
239
|
-
...
|
|
250
|
+
...O,
|
|
251
|
+
...re[w]
|
|
240
252
|
},
|
|
241
253
|
onClick: (e) => e.stopPropagation(),
|
|
242
254
|
onKeyDown: (e) => {
|
|
243
|
-
e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(),
|
|
255
|
+
e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(), f(!1), l.current?.focus()) : (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End") && A(e, a.current);
|
|
244
256
|
},
|
|
245
257
|
ref: a,
|
|
246
|
-
"data-automation-id":
|
|
247
|
-
},
|
|
248
|
-
closePopoverCb: () =>
|
|
249
|
-
})),
|
|
250
|
-
className: `popover-content-with-portal ${
|
|
258
|
+
"data-automation-id": g
|
|
259
|
+
}, T({
|
|
260
|
+
closePopoverCb: () => f(!1)
|
|
261
|
+
})), b && s && te && /* @__PURE__ */ ae.createPortal(/* @__PURE__ */ H.createElement("div", {
|
|
262
|
+
className: `popover-content-with-portal ${W} ${N == "full" ? "w-full" : "w-max"}`,
|
|
251
263
|
style: {
|
|
252
264
|
position: "fixed",
|
|
253
|
-
top:
|
|
254
|
-
left:
|
|
255
|
-
...
|
|
265
|
+
top: M.top,
|
|
266
|
+
left: M.left,
|
|
267
|
+
...O
|
|
256
268
|
},
|
|
257
269
|
onClick: (e) => e.stopPropagation(),
|
|
258
270
|
onKeyDown: (e) => {
|
|
259
|
-
e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(),
|
|
271
|
+
e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(), f(!1), l.current?.focus()) : (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End") && A(e, a.current);
|
|
260
272
|
},
|
|
261
273
|
ref: a,
|
|
262
|
-
"data-automation-id":
|
|
263
|
-
},
|
|
264
|
-
closePopoverCb: () =>
|
|
274
|
+
"data-automation-id": g
|
|
275
|
+
}, T({
|
|
276
|
+
closePopoverCb: () => f(!1)
|
|
265
277
|
})), document.body));
|
|
266
278
|
});
|
|
267
279
|
export {
|
|
268
|
-
|
|
280
|
+
de as Popover
|
|
269
281
|
};
|
|
270
282
|
//# sourceMappingURL=index17.js.map
|
package/dist/index17.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index17.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport { getA11yNameAttributes } from '../../utils/a11y';\n\nexport interface PopoverHandle {\n togglePopover: () => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: () => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0 });\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n const popoverWidth = popoverRect?.width || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above viewport\n if (top < 0) {\n top = 0;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n if (top < 0) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n\n return { top, left };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n document.body.addEventListener('click', clickListener, true);\n checkPopoverPosition();\n return () => document.body.removeEventListener('click', clickListener, true);\n } else if (displayPopover && isWithPortal) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Initial position calculation\n const timeout1 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n checkSourceVisibility();\n\n if (position) {\n setPortalPosition(position);\n }\n }, 0);\n\n // Recalculate after popover is rendered to get accurate dimensions\n const timeout2 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }, 10);\n\n return () => {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n window.removeEventListener('resize', resizeListenerWithPortal);\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }\n }, [displayPopover, isWithPortal]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens\n if (displayPopover && popoverContentRef.current) {\n setTimeout(() => {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = popoverContentRef.current?.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable && document.activeElement === srcElementRef.current) {\n firstFocusable.focus();\n }\n }, 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = () => {\n setDisplayPopover((displayPopover) => !displayPopover);\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Find all focusable elements within the popover content\n // This includes elements with role=\"menuitem\", role=\"option\", tabIndex >= 0, etc.\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(focusableSelectors)).filter((el) => {\n // Filter out disabled and hidden elements\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n !el.hasAttribute('aria-disabled') &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening\n if (!wasOpen) {\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n }}\n onBlur={() => {\n if (!displayPopover) return;\n\n // Use setTimeout to allow focus to settle\n setTimeout(() => {\n const activeElement = document.activeElement as Node;\n const isFocusInSource = srcElementRef.current?.contains(activeElement);\n const isFocusInPopover = popoverContentRef.current?.contains(activeElement);\n\n // Close if focus has moved outside both source and popover content\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }, 0);\n }}\n role={sourceRole}\n aria-expanded={displayPopover ? 'true' : 'false'}\n aria-haspopup={sourceRole === 'combobox' ? 'listbox' : 'true'}\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled ? 'true' : 'false'}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal ${popoverContentClasses} ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n ...popoverContentStyleProperty\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","portalPosition","setPortalPosition","top","left","calculatePositionOfPopover","current","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","clickAndScrollListenerWithPortal","resizeListenerWithPortal","timeout1","setTimeout","checkSourceVisibility","timeout2","clearTimeout","rec","isVisible","focusableSelectors","join","firstFocusable","querySelector","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","handleArrowKeyNavigation","e","container","focusableElements","Array","from","querySelectorAll","filter","el","style","getComputedStyle","hasAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","wasOpen","currentRef","onBlur","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal"],"mappings":";;;;;;;;;;;;AA4BO,MAAMA,wBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,EACXC,4BAAAA,IAA6B;AAAA,EAC7BC,cAAAA,IAAe;AAAA,EACfC,uBAAAA;AAAAA,EACAC,yBAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,IACbC,OAAO;AAAA,IACPC,iBAAiB;AAAA,EAAA;AAAA,EAEnBC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACX,GAAGC;AACL,GACAC,MACG;AACH,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,CAACC,GAAiBC,CAAkB,IAAIF,EAASvB,CAAQ,GACzD,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IACL,sBAAoB7B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEkI,gBAAgBA,MAAM/G,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GAENd,KACCa,KACAK,KACA4G,gBAAAA,GAASC,aACPb,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IACE7H,WAAW,+BAA+B2H,CAAqB,IAC7DvH,KAAgB,SAAS,WAAW,OAAO;AAAA,IAE7CuG,OAAO;AAAA,MACLzG,UAAU;AAAA,MACVqC,KAAKF,EAAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrB,GAAG1B;AAAAA,IAAAA;AAAAA,IAELiH,SAAU5B,CAAAA,MAAMA,EAAEoB,gBAAAA;AAAAA,IAClBS,WAAY7B,CAAAA,MAAM;AAEhB,MAAIA,EAAEkB,QAAQ,YACZlB,EAAEmB,eAAAA,GACFnB,EAAEoB,gBAAAA,GACF/F,EAAkB,EAAK,GACvBM,EAAcY,SAASyC,MAAAA,MACdgB,EAAEkB,QAAQ,eAAelB,EAAEkB,QAAQ,aAAalB,EAAEkB,QAAQ,UAAUlB,EAAEkB,QAAQ,UAEvFnB,EAAyBC,GAAGnE,EAAkBU,OAAO;AAAA,IAEzD;AAAA,IACApB,KAAKU;AAAAA,IACL,sBAAoB7B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEkI,gBAAgBA,MAAM/G,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GACLuC,SAASC,IACX,CACC;AAET,CACF;"}
|
|
1
|
+
{"version":3,"file":"index17.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport { getA11yNameAttributes } from '../../utils/a11y';\n\nexport interface PopoverHandle {\n togglePopover: () => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: () => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n disableAutoClose?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n disableAutoClose = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Use a ref to track the latest disableAutoClose value for async callbacks\n const disableAutoCloseRef = useRef(disableAutoClose);\n disableAutoCloseRef.current = disableAutoClose;\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0 });\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n const popoverWidth = popoverRect?.width || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above viewport\n if (top < 0) {\n top = 0;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n if (top < 0) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n\n return { top, left };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n // Add click listener for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickListener, true);\n }\n checkPopoverPosition();\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickListener, true);\n }\n };\n } else if (displayPopover && isWithPortal) {\n // Add click/scroll listeners for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n // When disableAutoClose is true, still listen to scroll for repositioning\n window.addEventListener('scroll', scrollListenerForRepositioning);\n }\n // Always add resize listener for repositioning\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Initial position calculation\n const timeout1 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n checkSourceVisibility();\n\n if (position) {\n setPortalPosition(position);\n }\n }, 0);\n\n // Recalculate after popover is rendered to get accurate dimensions\n const timeout2 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }, 10);\n\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n window.removeEventListener('scroll', scrollListenerForRepositioning);\n }\n window.removeEventListener('resize', resizeListenerWithPortal);\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }\n }, [displayPopover, isWithPortal, disableAutoClose]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens\n if (displayPopover && popoverContentRef.current) {\n setTimeout(() => {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = popoverContentRef.current?.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable && document.activeElement === srcElementRef.current) {\n firstFocusable.focus();\n }\n }, 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if (disableAutoClose) return;\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n if (disableAutoClose) return;\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const scrollListenerForRepositioning = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = () => {\n setDisplayPopover((displayPopover) => !displayPopover);\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Find all focusable elements within the popover content\n // This includes elements with role=\"menuitem\", role=\"option\", tabIndex >= 0, etc.\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(focusableSelectors)).filter((el) => {\n // Filter out disabled and hidden elements\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n !el.hasAttribute('aria-disabled') &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening\n if (!wasOpen) {\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n const focusableSelectors = [\n '[role=\"menuitem\"]',\n '[role=\"option\"]',\n '[role=\"menuitemcheckbox\"]',\n '[role=\"menuitemradio\"]',\n 'button:not([disabled])',\n 'a[href]',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(', ');\n const firstFocusable = currentRef.querySelector<HTMLElement>(focusableSelectors);\n if (firstFocusable) {\n firstFocusable.focus();\n }\n }\n }, 0);\n }\n }}\n onBlur={() => {\n if (!displayPopover) return;\n\n // Use setTimeout to allow focus to settle and state updates to process\n setTimeout(() => {\n // Check disableAutoClose ref inside timeout to get the latest value\n // This handles race conditions when disableAutoClose prop changes\n // right before/during the blur event (e.g., opening a modal)\n if (disableAutoCloseRef.current) return;\n\n const activeElement = document.activeElement as Node;\n const isFocusInSource = srcElementRef.current?.contains(activeElement);\n const isFocusInPopover = popoverContentRef.current?.contains(activeElement);\n\n // Close if focus has moved outside both source and popover content\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }, 0);\n }}\n role={sourceRole}\n aria-expanded={displayPopover ? 'true' : 'false'}\n aria-haspopup={sourceRole === 'combobox' ? 'listbox' : 'true'}\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled ? 'true' : 'false'}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal ${popoverContentClasses} ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n ...popoverContentStyleProperty\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n }\n }}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","disableAutoCloseRef","current","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","portalPosition","setPortalPosition","top","left","calculatePositionOfPopover","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","timeout1","setTimeout","checkSourceVisibility","timeout2","clearTimeout","rec","isVisible","focusableSelectors","join","firstFocusable","querySelector","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","handleArrowKeyNavigation","e","container","focusableElements","Array","from","querySelectorAll","filter","el","style","getComputedStyle","hasAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","wasOpen","currentRef","onBlur","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal"],"mappings":";;;;;;;;;;;;AA6BO,MAAMA,wBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,EACXC,4BAAAA,IAA6B;AAAA,EAC7BC,cAAAA,IAAe;AAAA,EACfC,uBAAAA;AAAAA,EACAC,yBAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,IACbC,OAAO;AAAA,IACPC,iBAAiB;AAAA,EAAA;AAAA,EAEnBC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,kBAAAA,IAAmB;AAAA,EACnB,GAAGC;AACL,GACAC,OACG;AACH,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,CAACC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E,EAAkBE,OAAO;AAAA,IAEzD;AAAA,IACAZ,KAAKU;AAAAA,IACL,sBAAoB9B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEqI,gBAAgBA,MAAMjH,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GACLwC,SAASC,IACX,CACC;AAET,CACF;"}
|
package/dist/index177.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import N from "./
|
|
2
|
-
import R from "./
|
|
3
|
-
import D from "./
|
|
4
|
-
import { SVGInjector as A } from "./
|
|
5
|
-
import { p as t } from "./
|
|
1
|
+
import N from "./index219.js";
|
|
2
|
+
import R from "./index220.js";
|
|
3
|
+
import D from "./index221.js";
|
|
4
|
+
import { SVGInjector as A } from "./index222.js";
|
|
5
|
+
import { p as t } from "./index223.js";
|
|
6
6
|
import * as h from "react";
|
|
7
7
|
var O = function(s) {
|
|
8
8
|
var o = s?.ownerDocument || document;
|
package/dist/index185.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef as E, useLayoutEffect as f } from "react";
|
|
2
|
-
import { getFirstFocusableElement as d, getFocusableElements as g } from "./
|
|
2
|
+
import { getFirstFocusableElement as d, getFocusableElements as g } from "./index218.js";
|
|
3
3
|
function y(e, t) {
|
|
4
4
|
return t === "first" ? d({
|
|
5
5
|
container: e
|
package/dist/index217.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (i.indexOf(e) !== -1) continue;
|
|
6
|
-
o[e] = t[e];
|
|
7
|
-
}
|
|
8
|
-
return o;
|
|
9
|
-
}
|
|
1
|
+
const t = () => typeof navigator < "u" && /Android/i.test(navigator.userAgent), o = (i) => {
|
|
2
|
+
const r = "pointerType" in i ? i.pointerType : void 0;
|
|
3
|
+
return r === "" && i.isTrusted ? !0 : t() && r ? i.type === "click" && i.buttons === 1 : i.detail === 0 && !r;
|
|
4
|
+
};
|
|
10
5
|
export {
|
|
11
|
-
|
|
6
|
+
o as isVirtualClick
|
|
12
7
|
};
|
|
13
8
|
//# sourceMappingURL=index217.js.map
|
package/dist/index217.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index217.js","sources":["../
|
|
1
|
+
{"version":3,"file":"index217.js","sources":["../src/utils/virtualClick.ts"],"sourcesContent":["/**\n * Input/virtual click detection helpers.\n */\n\nconst isAndroid = () =>\n typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);\n\nexport const isVirtualClick = (event: MouseEvent | PointerEvent): boolean => {\n const pointerType = 'pointerType' in event ? event.pointerType : undefined;\n\n // JAWS/NVDA with Firefox.\n if (pointerType === '' && event.isTrusted) {\n return true;\n }\n\n // Android TalkBack's detail value varies depending on listener type.\n if (isAndroid() && pointerType) {\n return event.type === 'click' && event.buttons === 1;\n }\n\n // Most browsers: virtual click has detail === 0 and no pointerType.\n return event.detail === 0 && !pointerType;\n};\n\n\n"],"names":["isAndroid","navigator","test","userAgent","isVirtualClick","event","pointerType","undefined","isTrusted","type","buttons","detail"],"mappings":"AAIA,MAAMA,IAAYA,MAChB,OAAOC,YAAc,OAAe,WAAWC,KAAKD,UAAUE,SAAS,GAE5DC,IAAiBA,CAACC,MAA8C;AAC3E,QAAMC,IAAc,iBAAiBD,IAAQA,EAAMC,cAAcC;AAGjE,SAAID,MAAgB,MAAMD,EAAMG,YACvB,KAILR,EAAAA,KAAeM,IACVD,EAAMI,SAAS,WAAWJ,EAAMK,YAAY,IAI9CL,EAAMM,WAAW,KAAK,CAACL;AAChC;"}
|