@viasat/beam-react 2.10.1 → 2.10.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/chunks/{FloatingUI.context.2kPXcTvi.js → FloatingUI.context.DtJA57si.js} +123 -109
- package/chunks/FloatingUI.context.Du9g2lSg.js +1 -0
- package/lib/Dialog/Dialog.Header.cjs.js +1 -1
- package/lib/Dialog/Dialog.Header.es.js +1 -1
- package/lib/Dialog/Dialog.Trigger.cjs.js +1 -1
- package/lib/Dialog/Dialog.Trigger.es.js +1 -1
- package/lib/Dialog/Dialog.d.ts +1 -1
- package/lib/FloatingUI/FloatingUI.content.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.content.es.js +1 -2
- package/lib/FloatingUI/FloatingUI.context.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.context.d.ts +7 -2
- package/lib/FloatingUI/FloatingUI.context.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.root.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.root.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.trigger.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.trigger.close.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.trigger.close.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.trigger.es.js +1 -1
- package/lib/Menu/ActionListContextWrapper.cjs.js +1 -1
- package/lib/Menu/ActionListContextWrapper.es.js +1 -1
- package/lib/Menu/Menu.cjs.js +1 -1
- package/lib/Menu/Menu.d.ts +1 -1
- package/lib/Menu/Menu.es.js +42 -40
- package/lib/Popover/Popover.content.cjs.js +1 -1
- package/lib/Popover/Popover.content.es.js +1 -1
- package/lib/Popover/Popover.d.ts +6 -1
- package/lib/Popover/Popover.trigger.cjs.js +1 -1
- package/lib/Popover/Popover.trigger.es.js +1 -1
- package/lib/Tooltip/Tooltip.cjs.js +1 -1
- package/lib/Tooltip/Tooltip.es.js +1 -1
- package/package.json +6 -6
- package/chunks/FloatingUI.context.BULqADss.js +0 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import h from "react";
|
|
2
|
-
import { offset as
|
|
3
|
-
import { useFloatingNodeId as
|
|
4
|
-
import { useConfigurableInteractions as
|
|
5
|
-
const
|
|
2
|
+
import { offset as Y, size as k, autoPlacement as q, flip as J, shift as K, hide as Q } from "@floating-ui/dom";
|
|
3
|
+
import { useFloatingNodeId as Z, useFloating as w, autoUpdate as tt } from "@floating-ui/react";
|
|
4
|
+
import { useConfigurableInteractions as et } from "../lib/FloatingUI/FloatingUI.interactions.es.js";
|
|
5
|
+
const _ = Math.min, nt = Math.max, ot = {
|
|
6
6
|
left: "right",
|
|
7
7
|
right: "left",
|
|
8
8
|
bottom: "top",
|
|
9
9
|
top: "bottom"
|
|
10
10
|
};
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function st(t, e, i) {
|
|
12
|
+
return nt(t, _(e, i));
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function it(t, e) {
|
|
15
15
|
return typeof t == "function" ? t(e) : t;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function G(t) {
|
|
18
18
|
return t.split("-")[0];
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function ct(t) {
|
|
21
21
|
return t.split("-")[1];
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function W(t) {
|
|
24
24
|
return t === "x" ? "y" : "x";
|
|
25
25
|
}
|
|
26
|
-
function ct(t) {
|
|
27
|
-
return t === "y" ? "height" : "width";
|
|
28
|
-
}
|
|
29
26
|
function rt(t) {
|
|
30
|
-
return
|
|
27
|
+
return t === "y" ? "height" : "width";
|
|
31
28
|
}
|
|
32
29
|
function lt(t) {
|
|
33
|
-
return
|
|
30
|
+
return ["top", "bottom"].includes(G(t)) ? "y" : "x";
|
|
34
31
|
}
|
|
35
32
|
function ft(t) {
|
|
36
|
-
return
|
|
33
|
+
return W(lt(t));
|
|
37
34
|
}
|
|
38
35
|
function ut(t) {
|
|
36
|
+
return t.replace(/left|right|bottom|top/g, (e) => ot[e]);
|
|
37
|
+
}
|
|
38
|
+
function at(t) {
|
|
39
39
|
return {
|
|
40
40
|
top: 0,
|
|
41
41
|
right: 0,
|
|
@@ -44,53 +44,53 @@ function ut(t) {
|
|
|
44
44
|
...t
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return typeof t != "number" ?
|
|
47
|
+
function pt(t) {
|
|
48
|
+
return typeof t != "number" ? at(t) : {
|
|
49
49
|
top: t,
|
|
50
50
|
right: t,
|
|
51
51
|
bottom: t,
|
|
52
52
|
left: t
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
const
|
|
55
|
+
const dt = 16, At = (t) => {
|
|
56
56
|
var e;
|
|
57
57
|
return {
|
|
58
58
|
visibility: (e = t.hide) != null && e.referenceHidden ? "hidden" : "visible"
|
|
59
59
|
};
|
|
60
|
-
},
|
|
60
|
+
}, gt = (t) => ({
|
|
61
61
|
name: "arrowStyles",
|
|
62
62
|
options: t,
|
|
63
63
|
async fn(e) {
|
|
64
|
-
var
|
|
65
|
-
const { x: i, y: c, placement: l, rects: s, platform: n, elements:
|
|
66
|
-
if (
|
|
64
|
+
var T, V;
|
|
65
|
+
const { x: i, y: c, placement: l, rects: s, platform: n, elements: d, middlewareData: g } = e, { element: u, padding: a = 0 } = it(t, e) || {};
|
|
66
|
+
if (u == null)
|
|
67
67
|
return {};
|
|
68
|
-
const
|
|
69
|
-
let
|
|
70
|
-
(!
|
|
71
|
-
const
|
|
72
|
-
placement:
|
|
73
|
-
arrowHeight:
|
|
74
|
-
arrowWidth:
|
|
68
|
+
const A = pt(a), m = { x: i, y: c }, r = ft(l), C = W(r), x = rt(r), p = await n.getDimensions(u), I = r === "y", o = I ? "top" : "left", U = I ? "bottom" : "right", $ = I ? "clientHeight" : "clientWidth", L = s.reference[x] + s.reference[r] - m[r] - s.floating[x], j = m[r] - s.reference[r], D = await ((T = n.getOffsetParent) == null ? void 0 : T.call(n, u));
|
|
69
|
+
let b = D ? D[$] : 0;
|
|
70
|
+
(!b || !await ((V = n.isElement) == null ? void 0 : V.call(n, D))) && (b = d.floating[$] || s.floating[x]);
|
|
71
|
+
const M = L / 2 - j / 2, v = b / 2 - p.width / 2 - 1, F = _(A[o], v), E = _(A[U], v), O = F, z = b - p.width - E, f = b / 2 - p.width / 2 + M, P = st(O, f, z), y = !g.arrow && ct(l) != null && f !== P && s.reference[x] / 2 - (f < O ? F : E) - p.width / 2 < 0, N = y ? f < O ? f - O : f - z : 0, S = G(l), X = ["top", "left"].includes(S) ? -1 : 1, B = p.height * X, H = mt({
|
|
72
|
+
placement: S,
|
|
73
|
+
arrowHeight: p.height,
|
|
74
|
+
arrowWidth: p.width,
|
|
75
75
|
// pass arrow middleware
|
|
76
|
-
[r]:
|
|
76
|
+
[r]: P
|
|
77
77
|
// for posterity, this is what the floating-ui arrow middleware returns
|
|
78
78
|
// centerOffset: center - offset - alignmentOffset,
|
|
79
79
|
// ...(shouldAddOffset && { alignmentOffset }),
|
|
80
80
|
});
|
|
81
81
|
return {
|
|
82
|
-
[r]: m[r] +
|
|
83
|
-
[
|
|
84
|
-
data:
|
|
85
|
-
reset:
|
|
82
|
+
[r]: m[r] + N,
|
|
83
|
+
[C]: m[C] + B,
|
|
84
|
+
data: H,
|
|
85
|
+
reset: y
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
}),
|
|
88
|
+
}), R = (t, e, i, c) => {
|
|
89
89
|
if (c) {
|
|
90
90
|
const l = c === !0 ? i() : i(c);
|
|
91
91
|
t[e](l);
|
|
92
92
|
}
|
|
93
|
-
},
|
|
93
|
+
}, ht = ({
|
|
94
94
|
baseConfig: t,
|
|
95
95
|
middleware: e,
|
|
96
96
|
offset: i,
|
|
@@ -100,25 +100,36 @@ const Pt = (t) => {
|
|
|
100
100
|
const s = { ...t, placement: l };
|
|
101
101
|
let n = [];
|
|
102
102
|
if (typeof e.overrides != "object") {
|
|
103
|
-
n.push(
|
|
104
|
-
let
|
|
105
|
-
e.autoPlacement && (
|
|
103
|
+
n.push(Y(i));
|
|
104
|
+
let d = e.flip ?? !0;
|
|
105
|
+
if (e.autoPlacement && (d = !1), R(
|
|
106
106
|
n,
|
|
107
107
|
"unshift",
|
|
108
|
-
|
|
108
|
+
q,
|
|
109
109
|
e.autoPlacement
|
|
110
|
-
),
|
|
110
|
+
), R(n, "unshift", J, d), e.size) {
|
|
111
|
+
const g = e.size === !0 ? {
|
|
112
|
+
padding: dt,
|
|
113
|
+
apply({ availableHeight: u, elements: a }) {
|
|
114
|
+
Object.assign(a.floating.style, {
|
|
115
|
+
maxHeight: `${u}px`
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
} : e.size;
|
|
119
|
+
n.push(k(g));
|
|
120
|
+
}
|
|
121
|
+
R(n, "push", K, e.shift ?? !0), R(n, "push", Q, e.hide ?? !0);
|
|
111
122
|
} else
|
|
112
123
|
n.push(...e.overrides);
|
|
113
|
-
return c.hide || n.push(
|
|
114
|
-
},
|
|
124
|
+
return c.hide || n.push(gt(c.options)), typeof e.overrides == "function" && (n = e.overrides(n)), s.middleware = n, s;
|
|
125
|
+
}, mt = ({
|
|
115
126
|
placement: t,
|
|
116
127
|
arrowHeight: e,
|
|
117
128
|
arrowWidth: i,
|
|
118
129
|
x: c,
|
|
119
130
|
y: l
|
|
120
131
|
}) => {
|
|
121
|
-
const s =
|
|
132
|
+
const s = G(t), n = i / 2 - e, d = {
|
|
122
133
|
/* since the default orientation is pointing down, we don't need to rotate the arrow
|
|
123
134
|
if the tooltip is on top of the reference element
|
|
124
135
|
*/
|
|
@@ -146,7 +157,7 @@ const Pt = (t) => {
|
|
|
146
157
|
*/
|
|
147
158
|
left: `rotate(-90deg) translateX(${-n}px)`,
|
|
148
159
|
right: `rotate(90deg) translateX(${n}px)`
|
|
149
|
-
}[s],
|
|
160
|
+
}[s], g = -i / 2 - e, u = {
|
|
150
161
|
/*
|
|
151
162
|
* If the tooltip is at the top of the anchor, place the arrow at the bottom of
|
|
152
163
|
* the tooltip with bottom: 0. The bottom of the arrow will be flush with the bottom
|
|
@@ -188,16 +199,16 @@ const Pt = (t) => {
|
|
|
188
199
|
* | .. | | *
|
|
189
200
|
* | | |/
|
|
190
201
|
*/
|
|
191
|
-
left: `${
|
|
202
|
+
left: `${g}px`,
|
|
192
203
|
// similarly for the right side
|
|
193
|
-
right: `${
|
|
194
|
-
}[s],
|
|
195
|
-
transform:
|
|
204
|
+
right: `${g}px`
|
|
205
|
+
}[s], a = {
|
|
206
|
+
transform: d
|
|
196
207
|
};
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
return
|
|
200
|
-
},
|
|
208
|
+
a.left = c != null ? `${c}px` : "", a.top = l != null ? `${l}px` : "";
|
|
209
|
+
const A = ut(s);
|
|
210
|
+
return a[A] = u, a;
|
|
211
|
+
}, It = ({
|
|
201
212
|
defaultOpen: t = !1,
|
|
202
213
|
open: e,
|
|
203
214
|
placement: i = "top",
|
|
@@ -206,44 +217,46 @@ const Pt = (t) => {
|
|
|
206
217
|
onOpenChange: l,
|
|
207
218
|
openOnClick: s,
|
|
208
219
|
openOnHover: n,
|
|
209
|
-
openOnFocus:
|
|
210
|
-
openOnSelected:
|
|
211
|
-
focusConfiguration:
|
|
212
|
-
listNavigation:
|
|
213
|
-
typeahead:
|
|
220
|
+
openOnFocus: d,
|
|
221
|
+
openOnSelected: g,
|
|
222
|
+
focusConfiguration: u,
|
|
223
|
+
listNavigation: a,
|
|
224
|
+
typeahead: A,
|
|
214
225
|
// Floating UI Middlewares
|
|
215
226
|
middleware: m,
|
|
216
227
|
autoPlacement: r,
|
|
217
|
-
flip:
|
|
228
|
+
flip: C = !0,
|
|
218
229
|
shift: x = !0,
|
|
219
|
-
autoHiding:
|
|
230
|
+
autoHiding: p,
|
|
231
|
+
size: I,
|
|
220
232
|
// Floating UI Arrow
|
|
221
233
|
arrow: o,
|
|
222
234
|
transitionConfig: U,
|
|
223
|
-
portalled:
|
|
224
|
-
role:
|
|
235
|
+
portalled: $,
|
|
236
|
+
role: L,
|
|
225
237
|
rootContext: j
|
|
226
238
|
}) => {
|
|
227
|
-
const [
|
|
228
|
-
...
|
|
239
|
+
const [D, b] = h.useState(t), [M, v] = h.useState(), [F, E] = h.useState(), [O, z] = h.useState(null), f = e ?? D, P = l ?? b, y = Z(), N = h.useMemo(() => ({
|
|
240
|
+
...ht({
|
|
229
241
|
baseConfig: {
|
|
230
|
-
open:
|
|
231
|
-
onOpenChange:
|
|
232
|
-
whileElementsMounted:
|
|
233
|
-
nodeId:
|
|
242
|
+
open: f,
|
|
243
|
+
onOpenChange: P,
|
|
244
|
+
whileElementsMounted: tt,
|
|
245
|
+
nodeId: y,
|
|
234
246
|
rootContext: j
|
|
235
247
|
},
|
|
236
248
|
middleware: {
|
|
237
249
|
overrides: m,
|
|
238
250
|
autoPlacement: r,
|
|
239
|
-
flip:
|
|
251
|
+
flip: C,
|
|
240
252
|
shift: x,
|
|
241
|
-
hide:
|
|
253
|
+
hide: p,
|
|
254
|
+
size: I
|
|
242
255
|
},
|
|
243
256
|
arrow: {
|
|
244
257
|
hide: (o == null ? void 0 : o.hide) ?? !1,
|
|
245
258
|
options: {
|
|
246
|
-
element:
|
|
259
|
+
element: O || null,
|
|
247
260
|
padding: o == null ? void 0 : o.edgePadding
|
|
248
261
|
}
|
|
249
262
|
},
|
|
@@ -251,70 +264,71 @@ const Pt = (t) => {
|
|
|
251
264
|
offset: c ?? 0
|
|
252
265
|
})
|
|
253
266
|
}), [
|
|
254
|
-
|
|
255
|
-
b,
|
|
267
|
+
y,
|
|
256
268
|
f,
|
|
269
|
+
P,
|
|
257
270
|
m,
|
|
258
271
|
r,
|
|
259
|
-
|
|
272
|
+
C,
|
|
260
273
|
x,
|
|
261
|
-
|
|
274
|
+
p,
|
|
275
|
+
I,
|
|
262
276
|
o == null ? void 0 : o.hide,
|
|
263
277
|
o == null ? void 0 : o.edgePadding,
|
|
264
|
-
|
|
278
|
+
O,
|
|
265
279
|
i,
|
|
266
280
|
c,
|
|
267
281
|
j
|
|
268
|
-
]),
|
|
269
|
-
context:
|
|
282
|
+
]), S = w(N), X = S.context, B = et({
|
|
283
|
+
context: X,
|
|
270
284
|
openOnClick: s,
|
|
271
285
|
openOnHover: n,
|
|
272
|
-
openOnFocus:
|
|
273
|
-
openOnSelected:
|
|
274
|
-
role:
|
|
275
|
-
listNavigation:
|
|
276
|
-
typeahead:
|
|
286
|
+
openOnFocus: d,
|
|
287
|
+
openOnSelected: g,
|
|
288
|
+
role: L,
|
|
289
|
+
listNavigation: a,
|
|
290
|
+
typeahead: A
|
|
277
291
|
});
|
|
278
292
|
return h.useMemo(
|
|
279
293
|
() => ({
|
|
280
|
-
open:
|
|
281
|
-
setOpen:
|
|
282
|
-
...
|
|
283
|
-
...
|
|
284
|
-
portalled:
|
|
285
|
-
focusConfiguration:
|
|
294
|
+
open: f,
|
|
295
|
+
setOpen: P,
|
|
296
|
+
...B,
|
|
297
|
+
...S,
|
|
298
|
+
portalled: $,
|
|
299
|
+
focusConfiguration: u,
|
|
286
300
|
transitionConfig: U,
|
|
287
|
-
labelId:
|
|
288
|
-
descriptionId:
|
|
301
|
+
labelId: M,
|
|
302
|
+
descriptionId: F,
|
|
289
303
|
arrow: o,
|
|
290
|
-
setLabelId:
|
|
291
|
-
setDescriptionId:
|
|
292
|
-
setArrowEl:
|
|
293
|
-
nodeId:
|
|
304
|
+
setLabelId: v,
|
|
305
|
+
setDescriptionId: E,
|
|
306
|
+
setArrowEl: z,
|
|
307
|
+
nodeId: y
|
|
294
308
|
}),
|
|
295
309
|
[
|
|
296
|
-
b,
|
|
297
310
|
f,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
311
|
+
P,
|
|
312
|
+
B,
|
|
313
|
+
S,
|
|
314
|
+
$,
|
|
315
|
+
u,
|
|
302
316
|
U,
|
|
303
|
-
|
|
304
|
-
|
|
317
|
+
M,
|
|
318
|
+
F,
|
|
305
319
|
o,
|
|
306
|
-
|
|
320
|
+
y
|
|
307
321
|
]
|
|
308
322
|
);
|
|
309
|
-
},
|
|
310
|
-
const t = h.useContext(
|
|
323
|
+
}, xt = h.createContext(null), St = () => {
|
|
324
|
+
const t = h.useContext(xt);
|
|
311
325
|
if (t == null)
|
|
312
326
|
throw new Error("FloatingUI components must be wrapped in <FloatingUI />");
|
|
313
327
|
return t;
|
|
314
328
|
};
|
|
315
329
|
export {
|
|
316
|
-
|
|
330
|
+
xt as B,
|
|
317
331
|
St as a,
|
|
318
|
-
|
|
319
|
-
|
|
332
|
+
It as u,
|
|
333
|
+
At as v
|
|
320
334
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const h=require("react"),F=require("@floating-ui/dom"),X=require("@floating-ui/react"),J=require("../lib/FloatingUI/FloatingUI.interactions.cjs.js"),G=Math.min,K=Math.max,Q={left:"right",right:"left",bottom:"top",top:"bottom"};function Z(t,e,i){return K(t,G(e,i))}function w(t,e){return typeof t=="function"?t(e):t}function T(t){return t.split("-")[0]}function tt(t){return t.split("-")[1]}function Y(t){return t==="x"?"y":"x"}function et(t){return t==="y"?"height":"width"}function nt(t){return["top","bottom"].includes(T(t))?"y":"x"}function ot(t){return Y(nt(t))}function st(t){return t.replace(/left|right|bottom|top/g,e=>Q[e])}function it(t){return{top:0,right:0,bottom:0,left:0,...t}}function ct(t){return typeof t!="number"?it(t):{top:t,right:t,bottom:t,left:t}}const lt=16,rt=t=>{var e;return{visibility:(e=t.hide)!=null&&e.referenceHidden?"hidden":"visible"}},ut=t=>({name:"arrowStyles",options:t,async fn(e){var V,W;const{x:i,y:c,placement:r,rects:s,platform:n,elements:g,middlewareData:p}=e,{element:f,padding:a=0}=w(t,e)||{};if(f==null)return{};const y=ct(a),m={x:i,y:c},l=ot(r),U=Y(l),x=et(l),d=await n.getDimensions(f),A=l==="y",o=A?"top":"left",j=A?"bottom":"right",C=A?"clientHeight":"clientWidth",_=s.reference[x]+s.reference[l]-m[l]-s.floating[x],B=m[l]-s.reference[l],$=await((V=n.getOffsetParent)==null?void 0:V.call(n,f));let b=$?$[C]:0;(!b||!await((W=n.isElement)==null?void 0:W.call(n,$)))&&(b=g.floating[C]||s.floating[x]);const M=_/2-B/2,v=b/2-d.width/2-1,D=G(y[o],v),E=G(y[j],v),O=D,z=b-d.width-E,u=b/2-d.width/2+M,P=Z(O,u,z),I=!p.arrow&&tt(r)!=null&&u!==P&&s.reference[x]/2-(u<O?D:E)-d.width/2<0,H=I?u<O?u-O:u-z:0,S=T(r),L=["top","left"].includes(S)?-1:1,q=d.height*L,N=at({placement:S,arrowHeight:d.height,arrowWidth:d.width,[l]:P});return{[l]:m[l]+H,[U]:m[U]+q,data:N,reset:I}}}),R=(t,e,i,c)=>{if(c){const r=c===!0?i():i(c);t[e](r)}},ft=({baseConfig:t,middleware:e,offset:i,arrow:c,placement:r="top"})=>{const s={...t,placement:r};let n=[];if(typeof e.overrides!="object"){n.push(F.offset(i));let g=e.flip??!0;if(e.autoPlacement&&(g=!1),R(n,"unshift",F.autoPlacement,e.autoPlacement),R(n,"unshift",F.flip,g),e.size){const p=e.size===!0?{padding:lt,apply({availableHeight:f,elements:a}){Object.assign(a.floating.style,{maxHeight:`${f}px`})}}:e.size;n.push(F.size(p))}R(n,"push",F.shift,e.shift??!0),R(n,"push",F.hide,e.hide??!0)}else n.push(...e.overrides);return c.hide||n.push(ut(c.options)),typeof e.overrides=="function"&&(n=e.overrides(n)),s.middleware=n,s},at=({placement:t,arrowHeight:e,arrowWidth:i,x:c,y:r})=>{const s=T(t),n=i/2-e,g={top:"rotate(0deg)",bottom:"rotate(180deg)",left:`rotate(-90deg) translateX(${-n}px)`,right:`rotate(90deg) translateX(${n}px)`}[s],p=-i/2-e,f={top:`${-e}px`,bottom:`${-e*2}px`,left:`${p}px`,right:`${p}px`}[s],a={transform:g};a.left=c!=null?`${c}px`:"",a.top=r!=null?`${r}px`:"";const y=st(s);return a[y]=f,a},dt=({defaultOpen:t=!1,open:e,placement:i="top",offset:c,onOpenChange:r,openOnClick:s,openOnHover:n,openOnFocus:g,openOnSelected:p,focusConfiguration:f,listNavigation:a,typeahead:y,middleware:m,autoPlacement:l,flip:U=!0,shift:x=!0,autoHiding:d,size:A,arrow:o,transitionConfig:j,portalled:C,role:_,rootContext:B})=>{const[$,b]=h.useState(t),[M,v]=h.useState(),[D,E]=h.useState(),[O,z]=h.useState(null),u=e??$,P=r??b,I=X.useFloatingNodeId(),H=h.useMemo(()=>{const N={open:u,onOpenChange:P,whileElementsMounted:X.autoUpdate,nodeId:I,rootContext:B};return{...ft({baseConfig:N,middleware:{overrides:m,autoPlacement:l,flip:U,shift:x,hide:d,size:A},arrow:{hide:(o==null?void 0:o.hide)??!1,options:{element:O||null,padding:o==null?void 0:o.edgePadding}},placement:i,offset:c??0})}},[I,u,P,m,l,U,x,d,A,o==null?void 0:o.hide,o==null?void 0:o.edgePadding,O,i,c,B]),S=X.useFloating(H),L=S.context,q=J.useConfigurableInteractions({context:L,openOnClick:s,openOnHover:n,openOnFocus:g,openOnSelected:p,role:_,listNavigation:a,typeahead:y});return h.useMemo(()=>({open:u,setOpen:P,...q,...S,portalled:C,focusConfiguration:f,transitionConfig:j,labelId:M,descriptionId:D,arrow:o,setLabelId:v,setDescriptionId:E,setArrowEl:z,nodeId:I}),[u,P,q,S,C,f,j,M,D,o,I])},k=h.createContext(null),gt=()=>{const t=h.useContext(k);if(t==null)throw new Error("FloatingUI components must be wrapped in <FloatingUI />");return t};exports.BmFloatingUIContext=k;exports.useBmFloatingUI=dt;exports.useBmFloatingUIContext=gt;exports.visibilityHandler=rt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("clsx"),x=require("react"),q=require("../../chunks/CheckCircleOutline.iRHrT_Eb.js"),y=require("../../chunks/ErrorOutline.Cb78OesH.js"),E=require("../../chunks/InfoOutline.Gr8gkm5N.js"),I=require("../../chunks/WarningOutlined.BPePPeyt.js"),u=require("../../chunks/classNames.DAeKwerT.js");require("../../chunks/constants.hwjHOsvT.js");const i=require("../../chunks/dialog.module.COfowyPc.js"),$=require("../Tooltip/Tooltip.cjs.js"),B=require("../CloseButton/CloseButton.cjs.js"),O=require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("clsx"),x=require("react"),q=require("../../chunks/CheckCircleOutline.iRHrT_Eb.js"),y=require("../../chunks/ErrorOutline.Cb78OesH.js"),E=require("../../chunks/InfoOutline.Gr8gkm5N.js"),I=require("../../chunks/WarningOutlined.BPePPeyt.js"),u=require("../../chunks/classNames.DAeKwerT.js");require("../../chunks/constants.hwjHOsvT.js");const i=require("../../chunks/dialog.module.COfowyPc.js"),$=require("../Tooltip/Tooltip.cjs.js"),B=require("../CloseButton/CloseButton.cjs.js"),O=require("../../chunks/FloatingUI.context.Du9g2lSg.js"),S=require("./Dialog.context.cjs.js"),c={positive:"Success",warning:"Warning",negative:"Error",information:"Information"},k=({icon:t,appearance:l,iconAriaLabel:s})=>{const o=x.useMemo(()=>({positive:e.jsx(q.SvgCheckCircleOutline,{role:"img","aria-label":s||c.positive}),warning:e.jsx(I.SvgWarningOutlined,{role:"img","aria-label":s||c.warning}),negative:e.jsx(y.SvgErrorOutline,{role:"img","aria-label":s||c.negative}),information:e.jsx(E.SvgInfoOutline,{role:"img","aria-label":s||c.information})}),[s]),{subElementClassPrefix:r}=u.getBEMClassNames("dialog__header"),a=m(i.styles[`${r}icon`],l&&i.styles[`${r}icon--${l}`]);return!t&&!l?null:e.jsx("div",{className:a,children:t||(l?o[l]:null)})},w=({ariaLabel:t="Close dialog"})=>{const{subElementClassPrefix:l}=u.getBEMClassNames("dialog__header"),{setOpen:s}=O.useBmFloatingUIContext(),o=x.useCallback(r=>{s==null||s(!1,r,"click")},[s]);return e.jsx("div",{className:i.styles[`${l}close-trigger`],children:e.jsx($.Tooltip,{text:t,children:e.jsx(B.CloseButton,{"aria-label":t,size:"lg",onClick:o})})})},C=({children:t,className:l,dismissible:s=!0,appearance:o,closeButtonAriaLabel:r="Close dialog",heading:a,description:g,icon:f,iconAriaLabel:h,divider:d=!0,disableDividerOnOverflow:j=!1,...v})=>{const{baseClassNamePrefix:_,subElementClassPrefix:n}=u.getBEMClassNames("dialog__header"),{overflowing:N}=S.useDialogContext(),b=d===!0||d===!1&&!j&&N;return e.jsxs("div",{className:m(i.styles[_],l),...v,children:[e.jsxs("div",{className:i.styles[`${n}row`],children:[e.jsx(k,{icon:f,appearance:o,iconAriaLabel:h}),a&&e.jsx("h2",{className:i.styles[`${n}heading`],children:a}),s&&e.jsx(w,{ariaLabel:r})]}),g&&e.jsx("p",{className:i.styles[`${n}description`],children:g}),t&&e.jsx("div",{className:i.styles[`${n}children`],children:t}),b&&e.jsx("hr",{"aria-hidden":"true",className:i.styles[`${n}divider`]})]})};C.displayName="Dialog.Header";exports.Header=C;
|
|
@@ -10,7 +10,7 @@ import "../../chunks/constants.CKKGf1-i.js";
|
|
|
10
10
|
import { s as r } from "../../chunks/dialog.module.D6BI3ubv.js";
|
|
11
11
|
import { Tooltip as k } from "../Tooltip/Tooltip.es.js";
|
|
12
12
|
import { CloseButton as B } from "../CloseButton/CloseButton.es.js";
|
|
13
|
-
import { a as P } from "../../chunks/FloatingUI.context.
|
|
13
|
+
import { a as P } from "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
14
14
|
import { useDialogContext as D } from "./Dialog.context.es.js";
|
|
15
15
|
const m = {
|
|
16
16
|
positive: "Success",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime");require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime");require("../../chunks/FloatingUI.context.Du9g2lSg.js");const l=require("../FloatingUI/FloatingUI.trigger.cjs.js"),t=require("../FloatingUI/FloatingUI.trigger.close.cjs.js");require("../FloatingUI/FloatingUI.content.cjs.js");require("react");const g=({children:e,...r})=>i.jsx(l.Trigger,{...r,children:e});g.displayName="Dialog.Trigger";const o=({children:e,...r})=>i.jsx(t.CloseTrigger,{...r,children:e});o.displayName="Dialog.CloseTrigger";exports.CloseTrigger=o;exports.Trigger=g;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import "../../chunks/FloatingUI.context.
|
|
2
|
+
import "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
3
3
|
import { Trigger as o } from "../FloatingUI/FloatingUI.trigger.es.js";
|
|
4
4
|
import { CloseTrigger as e } from "../FloatingUI/FloatingUI.trigger.close.es.js";
|
|
5
5
|
import "../FloatingUI/FloatingUI.content.es.js";
|
package/lib/Dialog/Dialog.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { FloatingPortalProps, UseFloatingOptions, UseRoleProps } from '@floating
|
|
|
3
3
|
import { ThemeTypes } from '@viasat/beam-shared/utils';
|
|
4
4
|
import { DialogSize } from '@viasat/beam-shared/components/dialog';
|
|
5
5
|
import { FloatingUIProps } from '../FloatingUI/FloatingUI.context';
|
|
6
|
-
export interface DialogProps extends Omit<FloatingUIProps, 'arrow' | 'offset' | 'autoHiding' | 'autoPlacement' | 'flip' | 'listNavigation' | 'middleware' | 'openOnClick' | 'openOnFocus' | 'openOnHover' | 'placement' | 'rootContext' | 'shift' | 'transitionConfig' | 'typeahead'> {
|
|
6
|
+
export interface DialogProps extends Omit<FloatingUIProps, 'arrow' | 'offset' | 'autoHiding' | 'autoPlacement' | 'flip' | 'listNavigation' | 'middleware' | 'openOnClick' | 'openOnFocus' | 'openOnHover' | 'placement' | 'rootContext' | 'shift' | 'size' | 'transitionConfig' | 'typeahead'> {
|
|
7
7
|
/**
|
|
8
8
|
* Specify the theme of the Dialog. By default it inherits the theme from the parent
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),x=require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),x=require("../../chunks/FloatingUI.context.Du9g2lSg.js"),f=require("react"),i=require("@floating-ui/react"),m=require("../../chunks/classNames.DAeKwerT.js");require("../../chunks/constants.hwjHOsvT.js");const b=require("clsx"),d=require("../../chunks/floatingui.module.D3Aw_aYe.js"),w=require("../Box/Box.cjs.js"),N=require("./FloatingUI.arrow.cjs.js");function S({children:o,props:e}){if(!e)return o;const t=typeof e=="boolean"?{}:e;return a.jsx(i.FloatingPortal,{...t,children:o})}function v({children:o,props:e}){if(!e)return o;const t=typeof e=="boolean",r=e==="transparent",{baseClassNamePrefix:l,classModifierPrefix:c}=m.getBEMClassNames("floatingui__overlay"),u={className:b(d.floatinguiStyles[l],r&&d.floatinguiStyles[`${c}transparent`]),lockScroll:!0},s=t||r?u:{...u,...e};return a.jsx(i.FloatingOverlay,{...s,children:o})}function B({children:o,context:e,props:t}){const r=f.useMemo(()=>({context:e,...typeof t=="boolean"?{}:t}),[e,t]);return t?a.jsx(i.FloatingFocusManager,{...r,children:o}):o}const y=f.forwardRef(({children:o,className:e,style:t,overlay:r,skipFloatingStyles:l=!1,...c},u)=>{const{context:s,nodeId:C,arrow:g,...n}=x.useBmFloatingUIContext(),P=i.useMergeRefs([n.refs.setFloating,u]),{isMounted:_,status:j}=i.useTransitionStatus(s,n.transitionConfig),{baseClassNamePrefix:F}=m.getBEMClassNames("floatingui"),q=l?e:b(d.floatinguiStyles[F],e),I=f.useMemo(()=>({...l?{}:s.floatingStyles,...x.visibilityHandler(s.middlewareData),...t}),[s.floatingStyles,s.middlewareData,l,t]);return _?a.jsx(i.FloatingNode,{id:C,children:a.jsx(S,{props:n.portalled,children:a.jsx(v,{props:r,children:a.jsx(B,{context:s,props:n.focusConfiguration,children:a.jsxs(w.Box,{"data-status":j,ref:P,style:I,className:q,"aria-labelledby":n.labelId,"aria-describedby":n.descriptionId,...n.getFloatingProps(c),children:[o,g&&a.jsx(N.Arrow,{options:g,middleware:n.middlewareData,ref:M=>n.setArrowEl(M)})]})})})})}):null});exports.Content=y;exports.default=y;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as n, jsxs as M } from "react/jsx-runtime";
|
|
2
|
-
import { a as v, v as I } from "../../chunks/FloatingUI.context.
|
|
2
|
+
import { a as v, v as I } from "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
3
3
|
import c, { useMemo as N } from "react";
|
|
4
4
|
import { useMergeRefs as B, useTransitionStatus as R, FloatingNode as S, FloatingPortal as D, FloatingOverlay as O, FloatingFocusManager as U } from "@floating-ui/react";
|
|
5
5
|
import { g as u } from "../../chunks/classNames.BTJmrO_L.js";
|
|
@@ -60,7 +60,6 @@ const V = c.forwardRef(
|
|
|
60
60
|
), { baseClassNamePrefix: y } = u("floatingui"), C = s ? t : g(d[y], t), w = N(
|
|
61
61
|
() => ({
|
|
62
62
|
...s ? {} : r.floatingStyles,
|
|
63
|
-
// Use floatingStyles for non-dialog content
|
|
64
63
|
...I(r.middlewareData),
|
|
65
64
|
...e
|
|
66
65
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react");const t=require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react");const t=require("../../chunks/FloatingUI.context.Du9g2lSg.js");require("@floating-ui/react");require("./FloatingUI.interactions.cjs.js");exports.BmFloatingUIContext=t.BmFloatingUIContext;exports.useBmFloatingUI=t.useBmFloatingUI;exports.useBmFloatingUIContext=t.useBmFloatingUIContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { MiddlewareModifier } from '@viasat/beam-shared/components/floatingui';
|
|
3
|
-
import { Placement, AutoPlacementOptions, FlipOptions, ShiftOptions, HideOptions, OffsetOptions, UseHoverProps, UseClickProps, UseFocusProps, FloatingPortalProps, UseTransitionStylesProps, UseFloatingOptions, UseRoleProps, FloatingRootContext, UseListNavigationProps, UseTypeaheadProps } from '@floating-ui/react';
|
|
3
|
+
import { Placement, AutoPlacementOptions, FlipOptions, ShiftOptions, HideOptions, OffsetOptions, UseHoverProps, UseClickProps, UseFocusProps, FloatingPortalProps, UseTransitionStylesProps, UseFloatingOptions, UseRoleProps, FloatingRootContext, UseListNavigationProps, UseTypeaheadProps, SizeOptions } from '@floating-ui/react';
|
|
4
4
|
import { FocusManagerProps } from '../FloatingUI/FloatingUI.content';
|
|
5
5
|
import { ArrowOptions } from '../FloatingUI/FloatingUI.arrow';
|
|
6
6
|
import { UseSelectedProps } from './useSelected';
|
|
@@ -36,6 +36,11 @@ export interface FloatingUIProps {
|
|
|
36
36
|
* [HideOptions](https://floating-ui.com/docs/hide#options)
|
|
37
37
|
*/
|
|
38
38
|
autoHiding?: boolean | HideOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Constrain the floating element's size to fit within available space.
|
|
41
|
+
* [SizeOptions](https://floating-ui.com/docs/size#options)
|
|
42
|
+
*/
|
|
43
|
+
size?: boolean | SizeOptions;
|
|
39
44
|
/**
|
|
40
45
|
* Middleware functions to modify the behavior of the floating element
|
|
41
46
|
*/
|
|
@@ -116,7 +121,7 @@ export interface FloatingUIProps {
|
|
|
116
121
|
*/
|
|
117
122
|
typeahead?: UseTypeaheadProps;
|
|
118
123
|
}
|
|
119
|
-
export declare const useBmFloatingUI: ({ defaultOpen, open: controlledOpen, placement, offset: _offset, onOpenChange: setControlledOpen, openOnClick, openOnHover, openOnFocus, openOnSelected, focusConfiguration, listNavigation, typeahead, middleware, autoPlacement, flip, shift, autoHiding, arrow, transitionConfig, portalled, role, rootContext, }: FloatingUIProps) => {
|
|
124
|
+
export declare const useBmFloatingUI: ({ defaultOpen, open: controlledOpen, placement, offset: _offset, onOpenChange: setControlledOpen, openOnClick, openOnHover, openOnFocus, openOnSelected, focusConfiguration, listNavigation, typeahead, middleware, autoPlacement, flip, shift, autoHiding, size, arrow, transitionConfig, portalled, role, rootContext, }: FloatingUIProps) => {
|
|
120
125
|
portalled: boolean | FloatingPortalProps | undefined;
|
|
121
126
|
focusConfiguration: boolean | FocusManagerProps | undefined;
|
|
122
127
|
transitionConfig: UseTransitionStylesProps | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
import { B as e, u as n, a as r } from "../../chunks/FloatingUI.context.
|
|
2
|
+
import { B as e, u as n, a as r } from "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
3
3
|
import "@floating-ui/react";
|
|
4
4
|
import "./FloatingUI.interactions.es.js";
|
|
5
5
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),t=require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),t=require("../../chunks/FloatingUI.context.Du9g2lSg.js");function e({children:o,...i}){const n=t.useBmFloatingUI({...i});return l.jsx(t.BmFloatingUIContext.Provider,{value:n,children:o})}exports.FloatingUIRoot=e;exports.default=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),u=require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),u=require("../../chunks/FloatingUI.context.Du9g2lSg.js"),l=require("@floating-ui/react"),g=require("../../utils/functions.cjs.js"),n=({children:t,...s})=>{try{const r=u.useBmFloatingUIContext(),e=o.useMemo(()=>g.ensureSingularRef(t),[t]),c=l.useMergeRefs([r.refs.setReference,e.props.ref??e.ref]),i=r.getReferenceProps({...s,...e.props,ref:c});return o.cloneElement(e,i)}catch{throw new Error("Expected a single child element with a ref for the FloatingUI trigger")}};exports.Trigger=n;exports.default=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),o=require("react"),d=require("../../utils/functions.cjs.js"),m=require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),o=require("react"),d=require("../../utils/functions.cjs.js"),m=require("../../chunks/FloatingUI.context.Du9g2lSg.js"),g=({children:l,...n})=>{const{setOpen:s}=m.useBmFloatingUIContext(),e=o.useMemo(()=>d.ensureSingularRef(l),[l]),r=o.useCallback(t=>{s==null||s(!1,t,"click")},[s]),c=o.useCallback(t=>{var i,u;r(t),(u=(i=e.props).onClick)==null||u.call(i,t)},[r,e.props]),C=o.useMemo(()=>({...n,...e.props,onClick:c}),[c,n,e.props]);return a.jsx(a.Fragment,{children:o.cloneElement(e,C)})};exports.CloseTrigger=g;exports.default=g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as f, Fragment as u } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as a, useCallback as m, cloneElement as C } from "react";
|
|
3
3
|
import { ensureSingularRef as d } from "../../utils/functions.es.js";
|
|
4
|
-
import { a as g } from "../../chunks/FloatingUI.context.
|
|
4
|
+
import { a as g } from "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
5
5
|
const b = ({ children: e, ...l }) => {
|
|
6
6
|
const { setOpen: r } = g(), o = a(() => d(e), [e]), n = m(
|
|
7
7
|
(s) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import f, { useMemo as c } from "react";
|
|
2
|
-
import { a } from "../../chunks/FloatingUI.context.
|
|
2
|
+
import { a } from "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
3
3
|
import { useMergeRefs as i } from "@floating-ui/react";
|
|
4
4
|
import { ensureSingularRef as m } from "../../utils/functions.es.js";
|
|
5
5
|
const h = ({ children: r, ...o }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("../ActionList/ActionList.context.cjs.js"),r=require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("../ActionList/ActionList.context.cjs.js"),r=require("../../chunks/FloatingUI.context.Du9g2lSg.js"),s=({children:t,...e})=>{const{getItemProps:o}=r.useBmFloatingUIContext();return i.jsx(n.ActionListContextProvider,{getItemProps:o,...e,children:t})};exports.ActionListContextWrapper=s;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { ActionListContextProvider as i } from "../ActionList/ActionList.context.es.js";
|
|
3
|
-
import { a as n } from "../../chunks/FloatingUI.context.
|
|
3
|
+
import { a as n } from "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
4
4
|
const x = ({
|
|
5
5
|
children: t,
|
|
6
6
|
...o
|
package/lib/Menu/Menu.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),t=require("react"),k=require("../Popover/Popover.cjs.js"),C=require("./Menu.context.cjs.js"),F=require("./Menu.PopoverContent.cjs.js"),j=require("./Menu.Trigger.cjs.js"),w=require("@floating-ui/react"),N=require("./ActionListContextWrapper.cjs.js"),W=require("../ActionList/ActionList.context.cjs.js"),H="12rem",r=({children:O,open:M,onOpenChange:x,maxHeight:c,minWidth:f,maxWidth:b,size:y,...o})=>{const e=C.useMenuContext(),[m,v]=t.useState(null),g=t.useRef([]),_=t.useRef([]),n=e===void 0,s=!n,[A,P]=t.useState(o.defaultOpen??!1),q=M??A,i=x??P,h=t.useCallback(l=>{i(!1,l,"click"),e==null||e.close()},[i,e]),p=t.useCallback(l=>{e==null||e.open(l),i(!0)},[i,e]),u=t.useMemo(()=>({parentMenuContext:e,minWidth:f??(e==null?void 0:e.minWidth)??H,maxWidth:b??(e==null?void 0:e.maxWidth),maxHeight:c??(e==null?void 0:e.maxHeight),close:h,open:p}),[h,c,b,f,p,e]),I=t.useCallback((l,a,T)=>{a!=="checkbox"&&a!=="radio"&&a!=="flyout"&&u.close(T)},[u]),R=t.useMemo(()=>[r],[]),L=W.useActionListContext();return d.jsx(C.MenuContext.Provider,{value:u,children:d.jsx(k.Popover,{open:q,onOpenChange:i,placement:n?"bottom-start":"right-start",openOnClick:n,openOnHover:{enabled:s,mouseOnly:!0,move:s,handleClose:w.safePolygon({blockPointerEvents:!0})},openOnFocus:s,size:y??!c,flip:!0,hideArrow:!0,portalled:o.portalled??!0,autoHiding:!1,...o,focusConfiguration:{modal:!1,initialFocus:s?-1:0,returnFocus:n,restoreFocus:n,order:["content","reference"],...o.focusConfiguration},listNavigation:{enabled:!0,listRef:g,activeIndex:m,onNavigate:v,loop:!0,focusItemOnHover:!1,focusItemOnOpen:!0,openOnArrowKeyDown:!0,nested:s,...o.listNavigation},typeahead:{enabled:!0,listRef:_,activeIndex:m,onMatch:v,...o.typeahead},role:{enabled:!0,role:"menu",...o.role},children:d.jsx(N.ActionListContextWrapper,{elementsRef:g,labelsRef:_,itemsFocusable:!1,onItemClick:I,insideMenu:!0,allowChildrenTypes:R,parentContext:L,children:O})})})};r.Trigger=j.MenuTrigger;r.PopoverContent=F.MenuPopoverContent;exports.Menu=r;
|
package/lib/Menu/Menu.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface MenuProps extends Omit<PopoverProps, 'listNavigation'> {
|
|
|
33
33
|
listNavigation?: Partial<PopoverProps['listNavigation']>;
|
|
34
34
|
}
|
|
35
35
|
export declare const Menu: {
|
|
36
|
-
({ children, open, onOpenChange, maxHeight, minWidth, maxWidth, ...props }: MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
({ children, open, onOpenChange, maxHeight, minWidth, maxWidth, size: sizeProp, ...props }: MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
Trigger: ({ children, ...props }: import('./Menu.Trigger').MenuTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
38
38
|
PopoverContent: ({ children, style, className: _className, ...props }: import('./Menu.PopoverContent').MenuPopoverContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
};
|
package/lib/Menu/Menu.es.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as b, useRef as I, useCallback as
|
|
3
|
-
import { Popover as
|
|
4
|
-
import { useMenuContext as
|
|
5
|
-
import { MenuPopoverContent as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useRef as I, useCallback as u, useMemo as y } from "react";
|
|
3
|
+
import { Popover as M } from "../Popover/Popover.es.js";
|
|
4
|
+
import { useMenuContext as W, MenuContext as D } from "./Menu.context.es.js";
|
|
5
|
+
import { MenuPopoverContent as z } from "./Menu.PopoverContent.es.js";
|
|
6
6
|
import { MenuTrigger as E } from "./Menu.Trigger.es.js";
|
|
7
7
|
import { safePolygon as _ } from "@floating-ui/react";
|
|
8
8
|
import { ActionListContextWrapper as j } from "./ActionListContextWrapper.es.js";
|
|
9
9
|
import { useActionListContext as K } from "../ActionList/ActionList.context.es.js";
|
|
10
|
-
const S = "12rem",
|
|
10
|
+
const S = "12rem", m = ({
|
|
11
11
|
children: A,
|
|
12
|
-
open:
|
|
13
|
-
onOpenChange:
|
|
14
|
-
maxHeight:
|
|
12
|
+
open: F,
|
|
13
|
+
onOpenChange: P,
|
|
14
|
+
maxHeight: r,
|
|
15
15
|
minWidth: f,
|
|
16
16
|
maxWidth: d,
|
|
17
|
+
size: R,
|
|
17
18
|
...o
|
|
18
19
|
}) => {
|
|
19
|
-
const e =
|
|
20
|
-
(
|
|
21
|
-
|
|
20
|
+
const e = W(), [p, h] = b(null), v = I([]), g = I([]), t = e === void 0, n = !t, [T, k] = b(o.defaultOpen ?? !1), w = F ?? T, s = P ?? k, O = u(
|
|
21
|
+
(i) => {
|
|
22
|
+
s(!1, i, "click"), e == null || e.close();
|
|
22
23
|
},
|
|
23
|
-
[
|
|
24
|
-
), C =
|
|
25
|
-
(
|
|
26
|
-
e == null || e.open(
|
|
24
|
+
[s, e]
|
|
25
|
+
), C = u(
|
|
26
|
+
(i) => {
|
|
27
|
+
e == null || e.open(i), s(!0);
|
|
27
28
|
},
|
|
28
|
-
[
|
|
29
|
-
),
|
|
29
|
+
[s, e]
|
|
30
|
+
), l = y(
|
|
30
31
|
() => ({
|
|
31
32
|
parentMenuContext: e,
|
|
32
33
|
minWidth: f ?? (e == null ? void 0 : e.minWidth) ?? S,
|
|
33
34
|
maxWidth: d ?? (e == null ? void 0 : e.maxWidth),
|
|
34
|
-
maxHeight:
|
|
35
|
+
maxHeight: r ?? (e == null ? void 0 : e.maxHeight),
|
|
35
36
|
close: O,
|
|
36
37
|
open: C
|
|
37
38
|
}),
|
|
38
|
-
[O,
|
|
39
|
-
),
|
|
40
|
-
(
|
|
41
|
-
|
|
39
|
+
[O, r, d, f, C, e]
|
|
40
|
+
), x = u(
|
|
41
|
+
(i, c, H) => {
|
|
42
|
+
c !== "checkbox" && c !== "radio" && c !== "flyout" && l.close(H);
|
|
42
43
|
},
|
|
43
|
-
[
|
|
44
|
-
),
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
|
|
44
|
+
[l]
|
|
45
|
+
), L = y(() => [m], []), N = K();
|
|
46
|
+
return /* @__PURE__ */ a(D.Provider, { value: l, children: /* @__PURE__ */ a(
|
|
47
|
+
M,
|
|
47
48
|
{
|
|
48
|
-
open:
|
|
49
|
-
onOpenChange:
|
|
49
|
+
open: w,
|
|
50
|
+
onOpenChange: s,
|
|
50
51
|
placement: t ? "bottom-start" : "right-start",
|
|
51
52
|
openOnClick: t,
|
|
52
53
|
openOnHover: {
|
|
@@ -58,6 +59,7 @@ const S = "12rem", u = ({
|
|
|
58
59
|
})
|
|
59
60
|
},
|
|
60
61
|
openOnFocus: n,
|
|
62
|
+
size: R ?? !r,
|
|
61
63
|
flip: !0,
|
|
62
64
|
hideArrow: !0,
|
|
63
65
|
portalled: o.portalled ?? !0,
|
|
@@ -73,7 +75,7 @@ const S = "12rem", u = ({
|
|
|
73
75
|
},
|
|
74
76
|
listNavigation: {
|
|
75
77
|
enabled: !0,
|
|
76
|
-
listRef:
|
|
78
|
+
listRef: v,
|
|
77
79
|
activeIndex: p,
|
|
78
80
|
onNavigate: h,
|
|
79
81
|
loop: !0,
|
|
@@ -85,7 +87,7 @@ const S = "12rem", u = ({
|
|
|
85
87
|
},
|
|
86
88
|
typeahead: {
|
|
87
89
|
enabled: !0,
|
|
88
|
-
listRef:
|
|
90
|
+
listRef: g,
|
|
89
91
|
activeIndex: p,
|
|
90
92
|
onMatch: h,
|
|
91
93
|
...o.typeahead
|
|
@@ -95,24 +97,24 @@ const S = "12rem", u = ({
|
|
|
95
97
|
role: "menu",
|
|
96
98
|
...o.role
|
|
97
99
|
},
|
|
98
|
-
children: /* @__PURE__ */
|
|
100
|
+
children: /* @__PURE__ */ a(
|
|
99
101
|
j,
|
|
100
102
|
{
|
|
101
|
-
elementsRef:
|
|
102
|
-
labelsRef:
|
|
103
|
+
elementsRef: v,
|
|
104
|
+
labelsRef: g,
|
|
103
105
|
itemsFocusable: !1,
|
|
104
|
-
onItemClick:
|
|
106
|
+
onItemClick: x,
|
|
105
107
|
insideMenu: !0,
|
|
106
|
-
allowChildrenTypes:
|
|
107
|
-
parentContext:
|
|
108
|
+
allowChildrenTypes: L,
|
|
109
|
+
parentContext: N,
|
|
108
110
|
children: A
|
|
109
111
|
}
|
|
110
112
|
)
|
|
111
113
|
}
|
|
112
114
|
) });
|
|
113
115
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
m.Trigger = E;
|
|
117
|
+
m.PopoverContent = z;
|
|
116
118
|
export {
|
|
117
|
-
|
|
119
|
+
m as Menu
|
|
118
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),u=require("clsx"),l=require("../../chunks/popover.module.Dum8SaSU.js"),p=require("../../chunks/classNames.DAeKwerT.js"),t=require("../../chunks/constants.hwjHOsvT.js");require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),u=require("clsx"),l=require("../../chunks/popover.module.Dum8SaSU.js"),p=require("../../chunks/classNames.DAeKwerT.js"),t=require("../../chunks/constants.hwjHOsvT.js");require("../../chunks/FloatingUI.context.Du9g2lSg.js");require("react");require("@floating-ui/react");const m=require("../FloatingUI/FloatingUI.content.cjs.js"),q=require("./Popover.context.cjs.js");function o({children:r,className:n,...s}){const{theme:e,appearance:i}=q.usePopoverContext(),{baseClassNamePrefix:a}=p.getBEMClassNames("popover");return c.jsx(m.Content,{className:u(e&&t.themeClassName(e),l.popoverStyles[a],i==="inverse"&&t.BEAM_INVERSE,n),...s,children:r})}o.displayName="Popover.Content";exports.Content=o;
|
|
@@ -3,7 +3,7 @@ import a from "clsx";
|
|
|
3
3
|
import { p as n } from "../../chunks/popover.module.C6KFea25.js";
|
|
4
4
|
import { g as i } from "../../chunks/classNames.BTJmrO_L.js";
|
|
5
5
|
import { t as f, c as C } from "../../chunks/constants.CKKGf1-i.js";
|
|
6
|
-
import "../../chunks/FloatingUI.context.
|
|
6
|
+
import "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import "@floating-ui/react";
|
|
9
9
|
import { Content as c } from "../FloatingUI/FloatingUI.content.es.js";
|
package/lib/Popover/Popover.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Trigger, CloseTrigger } from './Popover.trigger';
|
|
|
4
4
|
import { FloatingUIProps } from '../FloatingUI/FloatingUI.context';
|
|
5
5
|
import { Spacing, ThemeTypes } from '@viasat/beam-shared/utils';
|
|
6
6
|
import { MiddlewareModifier } from '@viasat/beam-shared/components/floatingui';
|
|
7
|
-
import { Placement, AutoPlacementOptions, FlipOptions, ShiftOptions, HideOptions, OffsetOptions, UseHoverProps, UseClickProps, UseFocusProps, FloatingPortalProps, UseFloatingOptions, UseRoleProps } from '@floating-ui/react';
|
|
7
|
+
import { Placement, AutoPlacementOptions, FlipOptions, ShiftOptions, HideOptions, OffsetOptions, UseHoverProps, UseClickProps, UseFocusProps, FloatingPortalProps, UseFloatingOptions, UseRoleProps, SizeOptions } from '@floating-ui/react';
|
|
8
8
|
import { FocusManagerProps } from '../FloatingUI/FloatingUI.content';
|
|
9
9
|
export interface PopoverProps extends Omit<FloatingUIProps, 'arrow' | 'offset'> {
|
|
10
10
|
/**
|
|
@@ -57,6 +57,11 @@ export interface PopoverProps extends Omit<FloatingUIProps, 'arrow' | 'offset'>
|
|
|
57
57
|
* <a href="https://floating-ui.com/docs/hide#options" target="_blank" rel="noopener noreferrer">HideOptions</a>
|
|
58
58
|
*/
|
|
59
59
|
autoHiding?: boolean | HideOptions;
|
|
60
|
+
/**
|
|
61
|
+
* Constrain the floating element's size to fit within available space.
|
|
62
|
+
* <a href="https://floating-ui.com/docs/size#options" target="_blank" rel="noopener noreferrer">SizeOptions</a>
|
|
63
|
+
*/
|
|
64
|
+
size?: boolean | SizeOptions;
|
|
60
65
|
/**
|
|
61
66
|
* Middleware functions to modify the behavior of the floating element
|
|
62
67
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime");require("../../chunks/FloatingUI.context.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime");require("../../chunks/FloatingUI.context.Du9g2lSg.js");const t=require("../FloatingUI/FloatingUI.trigger.cjs.js"),s=require("../FloatingUI/FloatingUI.trigger.close.cjs.js");require("../FloatingUI/FloatingUI.content.cjs.js");require("react");const g=({children:e,...r})=>i.jsx(t.Trigger,{...r,children:e});g.displayName="Popover.Trigger";const o=({children:e,...r})=>i.jsx(s.CloseTrigger,{...r,children:e});o.displayName="Popover.CloseTrigger";exports.CloseTrigger=o;exports.Trigger=g;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import "../../chunks/FloatingUI.context.
|
|
2
|
+
import "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
3
3
|
import { Trigger as g } from "../FloatingUI/FloatingUI.trigger.es.js";
|
|
4
4
|
import { CloseTrigger as i } from "../FloatingUI/FloatingUI.trigger.close.es.js";
|
|
5
5
|
import "../FloatingUI/FloatingUI.content.es.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var N=require("../../assets/Tooltip.css");Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),g=require("react"),h=require("../FloatingUI/FloatingUI.root.cjs.js"),d=require("../FloatingUI/FloatingUI.trigger.cjs.js");require("../../chunks/FloatingUI.context.
|
|
1
|
+
var N=require("../../assets/Tooltip.css");Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),g=require("react"),h=require("../FloatingUI/FloatingUI.root.cjs.js"),d=require("../FloatingUI/FloatingUI.trigger.cjs.js");require("../../chunks/FloatingUI.context.Du9g2lSg.js");const w=require("../FloatingUI/FloatingUI.content.cjs.js"),p=require("../../chunks/tokens.Bc11gmpN.js"),j=require("../../chunks/classNames.DAeKwerT.js");require("../../chunks/constants.hwjHOsvT.js");const u=require("../../utils/hooks/index.cjs.js"),x=require("clsx"),b=require("../../chunks/CSSLookup.DESAWWRT.js"),l={"bm-light":"bm-light","bm-dark":"bm-dark","bm-inverse":"bm-inverse","bm-tooltip__icon-trigger":"bm-tooltip__icon-trigger","bm-tooltip":"bm-tooltip","bm-tooltip__arrow":"bm-tooltip__arrow","bm-tooltip__icon-trigger--disabled":"bm-tooltip__icon-trigger--disabled","bm-tooltip__icon-trigger--xs":"bm-tooltip__icon-trigger--xs","bm-tooltip__icon-trigger--sm":"bm-tooltip__icon-trigger--sm","bm-tooltip__icon-trigger--md":"bm-tooltip__icon-trigger--md","bm-tooltip__icon-trigger--lg":"bm-tooltip__icon-trigger--lg","bm-tooltip__icon-trigger--xl":"bm-tooltip__icon-trigger--xl"},{baseClassNamePrefix:I,subElementClassPrefix:_}=j.getBEMClassNames("tooltip");function f({children:e,portalled:r=!1,text:i,disabled:t,showDelay:a,role:c,...n}){const s=u.useCSSLookup(p.bmCompTooltipSpaceArrow),m=u.useCSSLookup(p.bmCompTooltipSpaceOffset),C=g.useMemo(()=>({edgePadding:b.parseSizeString(s),className:l[`${_}arrow`],hide:!1}),[s]),T=t?{}:{openOnHover:{restMs:a},openOnFocus:!0,openOnSelected:!0},q=c||{enabled:!0,role:"tooltip"};return o.jsxs(h.FloatingUIRoot,{...T,arrow:C,offset:b.parseSizeString(m),portalled:r,transitionConfig:{duration:{open:0,close:200}},role:q,...n,children:[o.jsx(S.Provider,{value:{disabled:t},children:o.jsx(d.Trigger,{children:e})}),o.jsx(F,{theme:n.theme,children:i})]})}const S=g.createContext({disabled:!1}),k=g.forwardRef(({children:e,size:r="md",type:i="button",className:t,...a},c)=>{const{disabled:n}=g.useContext(S),s=`${_}icon-trigger`,m=x(l[`${s}--${r}`],l[s],n&&l[`${_}icon-trigger--disabled`],t);return o.jsx(d.Trigger,{children:o.jsx("button",{ref:c,type:i,disabled:n,className:m,...a,"aria-label":"tooltip trigger",children:e})})});function F({children:e,theme:r,className:i,...t}){return o.jsx(w.Content,{className:x(r,l[I],i),...t,children:e})}exports.Tooltip=f;exports.TooltipIconTrigger=k;exports.default=f;
|
|
@@ -3,7 +3,7 @@ import { jsx as t, jsxs as w } from "react/jsx-runtime";
|
|
|
3
3
|
import { createContext as h, forwardRef as T, useContext as S, useMemo as N } from "react";
|
|
4
4
|
import { FloatingUIRoot as P } from "../FloatingUI/FloatingUI.root.es.js";
|
|
5
5
|
import { Trigger as _ } from "../FloatingUI/FloatingUI.trigger.es.js";
|
|
6
|
-
import "../../chunks/FloatingUI.context.
|
|
6
|
+
import "../../chunks/FloatingUI.context.DtJA57si.js";
|
|
7
7
|
import { Content as k } from "../FloatingUI/FloatingUI.content.es.js";
|
|
8
8
|
import { j as v, k as O } from "../../chunks/tokens.BD_71qmL.js";
|
|
9
9
|
import { g as $ } from "../../chunks/classNames.BTJmrO_L.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"description": "React component library for the Beam design system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Viasat",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@viasat/beam-fonts": "2.10.
|
|
63
|
-
"@viasat/beam-shared": "2.10.
|
|
64
|
-
"@viasat/beam-styles": "2.10.
|
|
65
|
-
"@viasat/beam-tokens": "2.10.
|
|
66
|
-
"@viasat/beam-icons": "2.10.
|
|
62
|
+
"@viasat/beam-fonts": "2.10.2",
|
|
63
|
+
"@viasat/beam-shared": "2.10.2",
|
|
64
|
+
"@viasat/beam-styles": "2.10.2",
|
|
65
|
+
"@viasat/beam-tokens": "2.10.2",
|
|
66
|
+
"@viasat/beam-icons": "2.10.2",
|
|
67
67
|
"clsx": "^1.2.1",
|
|
68
68
|
"@floating-ui/react": "^0.26.18",
|
|
69
69
|
"@stepperize/react": "^5.1.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const h=require("react"),$=require("@floating-ui/dom"),H=require("@floating-ui/react"),K=require("../lib/FloatingUI/FloatingUI.interactions.cjs.js"),N=Math.min,Q=Math.max,V={left:"right",right:"left",bottom:"top",top:"bottom"};function Z(t,e,i){return Q(t,N(e,i))}function w(t,e){return typeof t=="function"?t(e):t}function T(t){return t.split("-")[0]}function tt(t){return t.split("-")[1]}function k(t){return t==="x"?"y":"x"}function et(t){return t==="y"?"height":"width"}function nt(t){return["top","bottom"].includes(T(t))?"y":"x"}function ot(t){return k(nt(t))}function st(t){return t.replace(/left|right|bottom|top/g,e=>V[e])}function it(t){return{top:0,right:0,bottom:0,left:0,...t}}function ct(t){return typeof t!="number"?it(t):{top:t,right:t,bottom:t,left:t}}const lt=t=>{var e;return{visibility:(e=t.hide)!=null&&e.referenceHidden?"hidden":"visible"}},rt=t=>({name:"arrowStyles",options:t,async fn(e){var W,Y;const{x:i,y:c,placement:r,rects:s,platform:n,elements:a,middlewareData:O}=e,{element:d,padding:g=0}=w(t,e)||{};if(d==null)return{};const P=ct(g),m={x:i,y:c},l=ot(r),S=k(l),x=et(l),f=await n.getDimensions(d),o=l==="y",B=o?"top":"left",D=o?"bottom":"right",M=o?"clientHeight":"clientWidth",j=s.reference[x]+s.reference[l]-m[l]-s.floating[x],X=m[l]-s.reference[l],A=await((W=n.getOffsetParent)==null?void 0:W.call(n,d));let p=A?A[M]:0;(!p||!await((Y=n.isElement)==null?void 0:Y.call(n,A)))&&(p=a.floating[M]||s.floating[x]);const _=j/2-X/2,F=p/2-f.width/2-1,v=N(P[B],F),U=N(P[D],F),y=v,b=p-f.width-U,u=p/2-f.width/2+_,I=Z(y,u,b),E=!O.arrow&&tt(r)!=null&&u!==I&&s.reference[x]/2-(u<y?v:U)-f.width/2<0,C=E?u<y?u-y:u-b:0,q=T(r),R=["top","left"].includes(q)?-1:1,z=f.height*R,J=ft({placement:q,arrowHeight:f.height,arrowWidth:f.width,[l]:I});return{[l]:m[l]+C,[S]:m[S]+z,data:J,reset:E}}}),L=(t,e,i,c)=>{if(c){const r=c===!0?i():i(c);t[e](r)}},ut=({baseConfig:t,middleware:e,offset:i,arrow:c,placement:r="top"})=>{const s={...t,placement:r};let n=[];if(typeof e.overrides!="object"){n.push($.offset(i));let a=e.flip??!0;e.autoPlacement&&(a=!1),L(n,"unshift",$.autoPlacement,e.autoPlacement),L(n,"push",$.shift,e.shift??!0),L(n,"unshift",$.flip,a),L(n,"push",$.hide,e.hide??!0)}else n.push(...e.overrides);return c.hide||n.push(rt(c.options)),typeof e.overrides=="function"&&(n=e.overrides(n)),s.middleware=n,s},ft=({placement:t,arrowHeight:e,arrowWidth:i,x:c,y:r})=>{const s=T(t),n=i/2-e,a={top:"rotate(0deg)",bottom:"rotate(180deg)",left:`rotate(-90deg) translateX(${-n}px)`,right:`rotate(90deg) translateX(${n}px)`}[s],O=-i/2-e,d={top:`${-e}px`,bottom:`${-e*2}px`,left:`${O}px`,right:`${O}px`}[s],g={transform:a};g.left=c!=null?`${c}px`:"",g.top=r!=null?`${r}px`:"";const P=st(s);return g[P]=d,g},at=({defaultOpen:t=!1,open:e,placement:i="top",offset:c,onOpenChange:r,openOnClick:s,openOnHover:n,openOnFocus:a,openOnSelected:O,focusConfiguration:d,listNavigation:g,typeahead:P,middleware:m,autoPlacement:l,flip:S=!0,shift:x=!0,autoHiding:f,arrow:o,transitionConfig:B,portalled:D,role:M,rootContext:j})=>{const[X,A]=h.useState(t),[p,_]=h.useState(),[F,v]=h.useState(),[U,y]=h.useState(null),b=e??X,u=r??A,I=H.useFloatingNodeId(),E=h.useMemo(()=>{const z={open:b,onOpenChange:u,whileElementsMounted:H.autoUpdate,nodeId:I,rootContext:j};return{...ut({baseConfig:z,middleware:{overrides:m,autoPlacement:l,flip:S,shift:x,hide:f},arrow:{hide:(o==null?void 0:o.hide)??!1,options:{element:U||null,padding:o==null?void 0:o.edgePadding}},placement:i,offset:c??0})}},[I,b,u,m,l,S,x,f,o==null?void 0:o.hide,o==null?void 0:o.edgePadding,U,i,c,j]),C=H.useFloating(E),q=C.context,R=K.useConfigurableInteractions({context:q,openOnClick:s,openOnHover:n,openOnFocus:a,openOnSelected:O,role:M,listNavigation:g,typeahead:P});return h.useMemo(()=>({open:b,setOpen:u,...R,...C,portalled:D,focusConfiguration:d,transitionConfig:B,labelId:p,descriptionId:F,arrow:o,setLabelId:_,setDescriptionId:v,setArrowEl:y,nodeId:I}),[b,u,R,C,D,d,B,p,F,o,I])},G=h.createContext(null),dt=()=>{const t=h.useContext(G);if(t==null)throw new Error("FloatingUI components must be wrapped in <FloatingUI />");return t};exports.BmFloatingUIContext=G;exports.useBmFloatingUI=at;exports.useBmFloatingUIContext=dt;exports.visibilityHandler=lt;
|