@viasat/beam-react 2.26.1 → 2.28.0
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/assets/panel.css +1 -1
- package/chunks/{FloatingUI.context.D3kSM-y1.js → FloatingUI.context.Dl4Y1y1z.js} +2 -2
- package/chunks/{panel.module.DJLJpnm_.js → panel.module.BblnuBjO.js} +11 -2
- package/chunks/panel.module.CVyUzyCZ.js +1 -0
- package/lib/Autocomplete/Autocomplete.figma.d.ts +1 -0
- package/lib/Avatar/Avatar.figma.d.ts +1 -0
- package/lib/Avatar/AvatarGroup.figma.d.ts +1 -0
- package/lib/BadgeDot/BadgeDot.figma.d.ts +1 -0
- package/lib/Chips/Chips.figma.d.ts +1 -0
- package/lib/Dialog/Dialog.Header.es.js +1 -1
- package/lib/Dialog/Dialog.Trigger.es.js +1 -1
- package/lib/Divider/Divider.figma.d.ts +1 -0
- package/lib/FloatingUI/FloatingUI.content.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.context.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.root.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.trigger.close.es.js +7 -7
- package/lib/FloatingUI/FloatingUI.trigger.es.js +4 -4
- package/lib/InputChoiceGroup/RadioButtonGroup/RadioButtonGroup.figma.d.ts +1 -0
- package/lib/InputChoiceGroup/SwitchGroup/SwitchGroup.figma.d.ts +1 -0
- package/lib/Link/Link.figma.d.ts +1 -0
- package/lib/Menu/ActionListContextWrapper.es.js +1 -1
- package/lib/NativeSelect/NativeSelect.figma.d.ts +1 -0
- package/lib/Popover/Popover.content.es.js +1 -1
- package/lib/Popover/Popover.trigger.es.js +1 -1
- package/lib/RadioButton/RadioButton.figma.d.ts +1 -0
- package/lib/Select/Select.figma.d.ts +1 -0
- package/lib/Slider/Slider.figma.d.ts +1 -0
- package/lib/TextArea/TextArea.figma.d.ts +1 -0
- package/lib/Tooltip/Tooltip.es.js +1 -1
- package/lib/wip/Panel/Footer/Panel.Footer.Actions.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Footer.Actions.es.js → Footer/Panel.Footer.Actions.es.js} +3 -3
- package/lib/wip/Panel/Footer/Panel.Footer.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Footer.d.ts → Footer/Panel.Footer.d.ts} +1 -1
- package/lib/wip/Panel/{Panel.Footer.es.js → Footer/Panel.Footer.es.js} +6 -6
- package/lib/wip/Panel/Header/Panel.Header.ContentAfter.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Header.ContentAfter.es.js → Header/Panel.Header.ContentAfter.es.js} +3 -3
- package/lib/wip/Panel/Header/Panel.Header.ContentBefore.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Header.ContentBefore.es.js → Header/Panel.Header.ContentBefore.es.js} +3 -3
- package/lib/wip/Panel/Header/Panel.Header.Description.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Header.Description.es.js → Header/Panel.Header.Description.es.js} +3 -3
- package/lib/wip/Panel/Header/Panel.Header.Heading.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Header.Heading.es.js → Header/Panel.Header.Heading.es.js} +6 -6
- package/lib/wip/Panel/Header/Panel.Header.Row.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Header.Row.es.js → Header/Panel.Header.Row.es.js} +6 -6
- package/lib/wip/Panel/Header/Panel.Header.Subheader.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Header.Subheader.es.js → Header/Panel.Header.Subheader.es.js} +3 -3
- package/lib/wip/Panel/Header/Panel.Header.cjs.js +1 -0
- package/lib/wip/Panel/{Panel.Header.d.ts → Header/Panel.Header.d.ts} +1 -1
- package/lib/wip/Panel/{Panel.Header.es.js → Header/Panel.Header.es.js} +6 -6
- package/lib/wip/Panel/Panel.Body.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Body.es.js +1 -1
- package/lib/wip/Panel/Panel.Inline.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Inline.d.ts +3 -2
- package/lib/wip/Panel/Panel.Inline.es.js +67 -55
- package/lib/wip/Panel/Panel.Overlay.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Overlay.d.ts +4 -2
- package/lib/wip/Panel/Panel.Overlay.es.js +90 -45
- package/lib/wip/Panel/Panel.ResizeHandle.cjs.js +1 -0
- package/lib/wip/Panel/Panel.ResizeHandle.d.ts +1 -0
- package/lib/wip/Panel/Panel.ResizeHandle.es.js +18 -0
- package/lib/wip/Panel/Panel.cjs.js +1 -1
- package/lib/wip/Panel/Panel.d.ts +10 -10
- package/lib/wip/Panel/Panel.es.js +101 -86
- package/lib/wip/Panel/Panel.helpers.cjs.js +1 -1
- package/lib/wip/Panel/Panel.helpers.d.ts +3 -2
- package/lib/wip/Panel/Panel.helpers.es.js +29 -24
- package/lib/wip/Panel/Panel.types.d.ts +61 -4
- package/lib/wip/Panel/Panel.useResize.cjs.js +1 -0
- package/lib/wip/Panel/Panel.useResize.d.ts +17 -0
- package/lib/wip/Panel/Panel.useResize.es.js +43 -0
- package/lib/wip/Panel/index.d.ts +9 -9
- package/package.json +6 -6
- package/utils/hooks/useElementResize.cjs.js +1 -1
- package/utils/hooks/useElementResize.d.ts +1 -1
- package/utils/hooks/useElementResize.es.js +40 -34
- package/chunks/panel.module.DCpj0tSX.js +0 -1
- package/lib/wip/Panel/Panel.Footer.Actions.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Footer.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Header.ContentAfter.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Header.ContentBefore.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Header.Description.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Header.Heading.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Header.Row.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Header.Subheader.cjs.js +0 -1
- package/lib/wip/Panel/Panel.Header.cjs.js +0 -1
- /package/lib/wip/Panel/{Panel.Footer.Actions.d.ts → Footer/Panel.Footer.Actions.d.ts} +0 -0
- /package/lib/wip/Panel/{Panel.Header.ContentAfter.d.ts → Header/Panel.Header.ContentAfter.d.ts} +0 -0
- /package/lib/wip/Panel/{Panel.Header.ContentBefore.d.ts → Header/Panel.Header.ContentBefore.d.ts} +0 -0
- /package/lib/wip/Panel/{Panel.Header.Description.d.ts → Header/Panel.Header.Description.d.ts} +0 -0
- /package/lib/wip/Panel/{Panel.Header.Heading.d.ts → Header/Panel.Header.Heading.d.ts} +0 -0
- /package/lib/wip/Panel/{Panel.Header.Row.d.ts → Header/Panel.Header.Row.d.ts} +0 -0
- /package/lib/wip/Panel/{Panel.Header.Subheader.d.ts → Header/Panel.Header.Subheader.d.ts} +0 -0
|
@@ -1,101 +1,116 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { g as
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import S from "clsx";
|
|
3
|
+
import { useMemo as z } from "react";
|
|
4
|
+
import { g as V } from "../../../chunks/classNames.BTJmrO_L.js";
|
|
5
5
|
import "../../../chunks/constants.CKKGf1-i.js";
|
|
6
|
-
import { Header as
|
|
7
|
-
import { Body as
|
|
8
|
-
import { Footer as
|
|
9
|
-
import { usePanelClose as
|
|
10
|
-
import { InlinePanel as
|
|
11
|
-
import { OverlayPanel as
|
|
12
|
-
import { s as e } from "../../../chunks/panel.module.
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
import { Header as W } from "./Header/Panel.Header.es.js";
|
|
7
|
+
import { Body as q } from "./Panel.Body.es.js";
|
|
8
|
+
import { Footer as G } from "./Footer/Panel.Footer.es.js";
|
|
9
|
+
import { resolveOffset as U, usePanelClose as J, getPanelDividerState as Q, PANEL_TRANSITION_DURATION_MS as X, getResolvedPanelPosition as Y } from "./Panel.helpers.es.js";
|
|
10
|
+
import { InlinePanel as Z } from "./Panel.Inline.es.js";
|
|
11
|
+
import { OverlayPanel as k } from "./Panel.Overlay.es.js";
|
|
12
|
+
import { s as e } from "../../../chunks/panel.module.BblnuBjO.js";
|
|
13
|
+
const ee = 165, oe = 100, se = (s, m) => {
|
|
14
|
+
if (!s || m === "full") return;
|
|
15
|
+
const p = m === "bottom", r = typeof s == "object" ? s : {}, c = r.minSize ?? (p ? oe : ee), n = r.maxSize ?? 1 / 0, f = r.storageKey ?? "";
|
|
16
|
+
return { minSize: c, maxSize: n, storageKey: f };
|
|
17
|
+
}, { baseClassNamePrefix: o } = V("panel"), d = ({
|
|
18
|
+
children: s,
|
|
19
|
+
className: m,
|
|
20
|
+
padding: p = "md",
|
|
21
|
+
onOpenChange: r,
|
|
22
|
+
open: c,
|
|
23
|
+
size: n = "md",
|
|
24
|
+
dismissible: f = !0,
|
|
25
|
+
closeButtonAriaLabel: N = "Close panel",
|
|
26
|
+
kind: i = "inline",
|
|
27
|
+
position: g,
|
|
28
|
+
divider: M = !0,
|
|
29
|
+
dividerColor: v,
|
|
30
|
+
isAnimated: P = !0,
|
|
31
|
+
onBeforeClose: x,
|
|
32
|
+
modalType: a,
|
|
33
|
+
offset: O,
|
|
34
|
+
resizable: D,
|
|
35
|
+
id: _,
|
|
36
|
+
...u
|
|
30
37
|
}) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
const t = Y(g), l = se(D, t), B = !!l;
|
|
39
|
+
if (process.env.NODE_ENV !== "production") {
|
|
40
|
+
l && !l.storageKey && console.warn("Panel: provide a `storageKey` in the `resizable` config to persist panel size across sessions."), a === "alert" && f && console.warn('Panel: `dismissible` is ignored when `modalType="alert"`. The close button is always hidden.');
|
|
41
|
+
const { closeOnOutsidePress: L } = u;
|
|
42
|
+
L && a !== "nonModal" && a !== void 0 && console.warn('Panel: `closeOnOutsidePress` has no effect when `modalType` is not `"nonModal"`.');
|
|
43
|
+
}
|
|
44
|
+
const y = a === "alert" ? !1 : f, T = n && (t !== "bottom" || n === "full"), $ = i === "overlay" && O ? U(O) : void 0, C = !!$, I = S(
|
|
37
45
|
e[o],
|
|
38
|
-
e[`${o}--${
|
|
39
|
-
|
|
40
|
-
e[`${o}--padding-${
|
|
41
|
-
e[`${o}--position-${
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
e[`${o}--${i}`],
|
|
47
|
+
T && e[`${o}--size-${n}`],
|
|
48
|
+
e[`${o}--padding-${p}`],
|
|
49
|
+
e[`${o}--position-${t}`],
|
|
50
|
+
C && e[`${o}--floating`],
|
|
51
|
+
B && e[`${o}--resizable`],
|
|
52
|
+
m
|
|
53
|
+
), A = S(
|
|
44
54
|
e[`${o}__inline-wrapper`],
|
|
45
|
-
|
|
46
|
-
), { requestClose:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
),
|
|
55
|
+
e[`${o}__inline-wrapper--size-${n}`]
|
|
56
|
+
), { requestClose: h, handleOverlayOpenChange: H } = J(
|
|
57
|
+
x,
|
|
58
|
+
r
|
|
59
|
+
), b = z(
|
|
50
60
|
() => ({
|
|
51
|
-
kind:
|
|
52
|
-
dismissible:
|
|
53
|
-
closeButtonAriaLabel:
|
|
54
|
-
position:
|
|
55
|
-
requestClose:
|
|
61
|
+
kind: i,
|
|
62
|
+
dismissible: y,
|
|
63
|
+
closeButtonAriaLabel: N,
|
|
64
|
+
position: g,
|
|
65
|
+
requestClose: h
|
|
56
66
|
}),
|
|
57
|
-
[
|
|
58
|
-
), { showDivider:
|
|
59
|
-
() => ({ duration:
|
|
60
|
-
[
|
|
67
|
+
[i, y, N, g, h]
|
|
68
|
+
), { showDivider: K, dividerBefore: R, dividerInner: F, dividerAfter: j } = Q(M && !C, t), w = z(
|
|
69
|
+
() => ({ duration: P ? X : 0 }),
|
|
70
|
+
[P]
|
|
61
71
|
);
|
|
62
|
-
return
|
|
63
|
-
|
|
72
|
+
return i === "inline" ? /* @__PURE__ */ E(
|
|
73
|
+
Z,
|
|
64
74
|
{
|
|
65
|
-
contextValue:
|
|
66
|
-
panelClassName:
|
|
67
|
-
inlineWrapperClassName:
|
|
68
|
-
resolvedPosition:
|
|
69
|
-
dividerBefore:
|
|
70
|
-
dividerInner:
|
|
71
|
-
dividerAfter:
|
|
72
|
-
dividerColor:
|
|
73
|
-
open:
|
|
74
|
-
transitionConfig:
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
contextValue: b,
|
|
76
|
+
panelClassName: I,
|
|
77
|
+
inlineWrapperClassName: A,
|
|
78
|
+
resolvedPosition: t,
|
|
79
|
+
dividerBefore: R,
|
|
80
|
+
dividerInner: F,
|
|
81
|
+
dividerAfter: j,
|
|
82
|
+
dividerColor: v,
|
|
83
|
+
open: c,
|
|
84
|
+
transitionConfig: w,
|
|
85
|
+
resizeConfig: l,
|
|
86
|
+
id: _,
|
|
87
|
+
...u,
|
|
88
|
+
children: s
|
|
77
89
|
}
|
|
78
|
-
) : /* @__PURE__ */
|
|
79
|
-
|
|
90
|
+
) : /* @__PURE__ */ E(
|
|
91
|
+
k,
|
|
80
92
|
{
|
|
81
|
-
contextValue:
|
|
82
|
-
panelClassName:
|
|
83
|
-
resolvedPosition:
|
|
84
|
-
showDivider:
|
|
85
|
-
dividerColor:
|
|
86
|
-
modalType:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
contextValue: b,
|
|
94
|
+
panelClassName: I,
|
|
95
|
+
resolvedPosition: t,
|
|
96
|
+
showDivider: K,
|
|
97
|
+
dividerColor: v,
|
|
98
|
+
modalType: a,
|
|
99
|
+
floatingOffset: $,
|
|
100
|
+
open: c,
|
|
101
|
+
onOpenChange: H,
|
|
102
|
+
transitionConfig: w,
|
|
103
|
+
resizeConfig: l,
|
|
104
|
+
id: _,
|
|
105
|
+
...u,
|
|
106
|
+
children: s
|
|
92
107
|
}
|
|
93
108
|
);
|
|
94
109
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
d.displayName = "Panel";
|
|
111
|
+
d.Header = W;
|
|
112
|
+
d.Body = q;
|
|
113
|
+
d.Footer = G;
|
|
99
114
|
export {
|
|
100
|
-
|
|
115
|
+
d as Panel
|
|
101
116
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),d=400;function P(e){return e===!0?{x:"1rem",y:"1rem"}:typeof e=="string"?{x:e,y:e}:{x:e.x,y:e.y}}const f="01",a=e=>e||"end",v=(e,t)=>{const r=e&&t!=="full";return{showDivider:r,dividerBefore:r&&t!=="start"&&t!=="bottom",dividerInner:r&&t==="bottom",dividerAfter:r&&t==="start"}},D=(e,t)=>{if(e!=="isModal")return e==="alert"?{escapeKey:!1,outsidePress:!1}:{escapeKey:!0,outsidePress:t??!1}},_=e=>e==="escape-key"?"escapeKey":e==="outside-press"?"outsidePress":"programmatic",y=(e,t)=>{const r=u.useCallback(i=>{if(!e){t==null||t(!1);return}const s=e(i);s instanceof Promise?s.then(l=>{l&&(t==null||t(!1))}).catch(()=>{}):s&&(t==null||t(!1))},[e,t]),c=u.useCallback((i,s,l)=>{i?t==null||t(!0):r(_(l))},[t,r]);return{requestClose:r,handleOverlayOpenChange:c}};exports.DEFAULT_PANEL_DIVIDER_COLOR=f;exports.PANEL_TRANSITION_DURATION_MS=d;exports.getPanelDismissConfig=D;exports.getPanelDividerState=v;exports.getResolvedPanelPosition=a;exports.resolveOffset=P;exports.usePanelClose=y;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OpenChangeReason } from '@floating-ui/react';
|
|
2
|
-
import { PanelCloseReason, PanelDividerColor, PanelModalType, PanelPosition, PanelProps } from './Panel.types';
|
|
2
|
+
import { OverlayPanelProps, PanelCloseReason, PanelDividerColor, PanelModalType, PanelPosition, PanelProps, ResolvedPanelOffset } from './Panel.types';
|
|
3
3
|
export declare const PANEL_TRANSITION_DURATION_MS = 400;
|
|
4
|
+
export declare function resolveOffset(offset: Exclude<OverlayPanelProps['offset'], false | undefined>): ResolvedPanelOffset;
|
|
4
5
|
export declare const DEFAULT_PANEL_DIVIDER_COLOR: PanelDividerColor;
|
|
5
6
|
export declare const getResolvedPanelPosition: (position?: PanelPosition) => PanelPosition;
|
|
6
7
|
export declare const getPanelDividerState: (divider: boolean, position?: PanelPosition) => {
|
|
@@ -13,7 +14,7 @@ export declare const getPanelDividerState: (divider: boolean, position?: PanelPo
|
|
|
13
14
|
* Returns the floating-ui `dismiss` config for an overlay panel.
|
|
14
15
|
*
|
|
15
16
|
* - `isModal` — `undefined` (floating-ui defaults: ESC + backdrop click both close)
|
|
16
|
-
* - `nonModal` / omitted — ESC
|
|
17
|
+
* - `nonModal` / omitted — ESC closes; outside-press controlled by `closeOnOutsidePress`
|
|
17
18
|
* - `alert` — ESC and outside-press both suppressed
|
|
18
19
|
*/
|
|
19
20
|
export declare const getPanelDismissConfig: (modalType: PanelModalType | undefined, closeOnOutsidePress?: boolean) => {
|
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
const P = 400
|
|
3
|
-
|
|
1
|
+
import { useCallback as l } from "react";
|
|
2
|
+
const P = 400;
|
|
3
|
+
function v(t) {
|
|
4
|
+
return t === !0 ? { x: "1rem", y: "1rem" } : typeof t == "string" ? { x: t, y: t } : { x: t.x, y: t.y };
|
|
5
|
+
}
|
|
6
|
+
const m = "01", y = (t) => t || "end", D = (t, r) => {
|
|
7
|
+
const s = t && r !== "full";
|
|
4
8
|
return {
|
|
5
|
-
showDivider:
|
|
6
|
-
dividerBefore:
|
|
9
|
+
showDivider: s,
|
|
10
|
+
dividerBefore: s && r !== "start" && r !== "bottom",
|
|
7
11
|
// For 'bottom' panels the divider must sit inside the scrollable wrapper (above the content),
|
|
8
12
|
// not outside it — so it is rendered via dividerInner rather than dividerBefore.
|
|
9
|
-
dividerInner:
|
|
10
|
-
dividerAfter:
|
|
13
|
+
dividerInner: s && r === "bottom",
|
|
14
|
+
dividerAfter: s && r === "start"
|
|
11
15
|
};
|
|
12
|
-
}, _ = (t,
|
|
16
|
+
}, _ = (t, r) => {
|
|
13
17
|
if (t !== "isModal")
|
|
14
|
-
return t === "alert" ? { escapeKey: !1, outsidePress: !1 } : { escapeKey: !
|
|
15
|
-
},
|
|
16
|
-
const
|
|
18
|
+
return t === "alert" ? { escapeKey: !1, outsidePress: !1 } : { escapeKey: !0, outsidePress: r ?? !1 };
|
|
19
|
+
}, d = (t) => t === "escape-key" ? "escapeKey" : t === "outside-press" ? "outsidePress" : "programmatic", A = (t, r) => {
|
|
20
|
+
const s = l(
|
|
17
21
|
(i) => {
|
|
18
22
|
if (!t) {
|
|
19
|
-
|
|
23
|
+
r == null || r(!1);
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
26
|
const e = t(i);
|
|
23
|
-
e instanceof Promise ? e.then((
|
|
24
|
-
|
|
27
|
+
e instanceof Promise ? e.then((u) => {
|
|
28
|
+
u && (r == null || r(!1));
|
|
25
29
|
}).catch(() => {
|
|
26
|
-
}) : e && (
|
|
30
|
+
}) : e && (r == null || r(!1));
|
|
27
31
|
},
|
|
28
|
-
[t,
|
|
29
|
-
),
|
|
30
|
-
(i, e,
|
|
31
|
-
i ?
|
|
32
|
+
[t, r]
|
|
33
|
+
), c = l(
|
|
34
|
+
(i, e, u) => {
|
|
35
|
+
i ? r == null || r(!0) : s(d(u));
|
|
32
36
|
},
|
|
33
|
-
[
|
|
37
|
+
[r, s]
|
|
34
38
|
);
|
|
35
|
-
return { requestClose:
|
|
39
|
+
return { requestClose: s, handleOverlayOpenChange: c };
|
|
36
40
|
};
|
|
37
41
|
export {
|
|
38
|
-
|
|
42
|
+
m as DEFAULT_PANEL_DIVIDER_COLOR,
|
|
39
43
|
P as PANEL_TRANSITION_DURATION_MS,
|
|
40
44
|
_ as getPanelDismissConfig,
|
|
41
45
|
D as getPanelDividerState,
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
y as getResolvedPanelPosition,
|
|
47
|
+
v as resolveOffset,
|
|
48
|
+
A as usePanelClose
|
|
44
49
|
};
|
|
@@ -3,10 +3,26 @@ import { PanelDividerColor, PanelDividerColors } from '@viasat/beam-shared/compo
|
|
|
3
3
|
export type { PanelDividerColor };
|
|
4
4
|
export { PanelDividerColors };
|
|
5
5
|
export type PanelKind = 'inline' | 'overlay';
|
|
6
|
+
export type ResolvedPanelOffset = {
|
|
7
|
+
x: string;
|
|
8
|
+
y: string;
|
|
9
|
+
};
|
|
6
10
|
export type PanelPosition = 'start' | 'end' | 'bottom' | 'full';
|
|
7
11
|
export type PanelModalType = 'nonModal' | 'isModal' | 'alert';
|
|
8
|
-
export type PanelSize = 'sm' | 'md' | 'lg' | 'full'
|
|
12
|
+
export type PanelSize = 'sm' | 'md' | 'lg' | 'full';
|
|
9
13
|
export type PanelPadding = 'sm' | 'md';
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for resizable panels.
|
|
16
|
+
* Pass `true` to use defaults, or an object for custom constraints.
|
|
17
|
+
*/
|
|
18
|
+
export type PanelResizable = boolean | {
|
|
19
|
+
/** Minimum panel size in px. Default: 165 for start/end, 100 for bottom. */
|
|
20
|
+
minSize?: number;
|
|
21
|
+
/** Maximum panel size in px. Default: 50% viewport width for start/end, 90% viewport height for bottom. */
|
|
22
|
+
maxSize?: number;
|
|
23
|
+
/** localStorage key for persisting the panel's last-used size across sessions. */
|
|
24
|
+
storageKey?: string;
|
|
25
|
+
};
|
|
10
26
|
/**
|
|
11
27
|
* The reason a Panel close was requested via user interaction.
|
|
12
28
|
*
|
|
@@ -87,6 +103,14 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
|
|
|
87
103
|
* @default 'end'
|
|
88
104
|
*/
|
|
89
105
|
position?: PanelPosition;
|
|
106
|
+
/**
|
|
107
|
+
* Enables user-resizing via a drag handle at the panel edge.
|
|
108
|
+
* Pass `true` to use default min/max constraints, or an object to set custom
|
|
109
|
+
* values in pixels. Has no effect when `position="full"`.
|
|
110
|
+
* Provide a `storageKey` in the config object to persist the panel's last-used size across sessions.
|
|
111
|
+
* @default false
|
|
112
|
+
*/
|
|
113
|
+
resizable?: PanelResizable;
|
|
90
114
|
/**
|
|
91
115
|
* Called before the Panel closes due to a user interaction. Return `false` (or
|
|
92
116
|
* `Promise<false>`) to cancel the close — for example, when the panel contains
|
|
@@ -122,6 +146,7 @@ export interface InlinePanelProps extends BasePanelProps {
|
|
|
122
146
|
*/
|
|
123
147
|
kind?: 'inline';
|
|
124
148
|
modalType?: never;
|
|
149
|
+
offset?: never;
|
|
125
150
|
}
|
|
126
151
|
export interface OverlayPanelProps extends BasePanelProps {
|
|
127
152
|
/**
|
|
@@ -130,8 +155,12 @@ export interface OverlayPanelProps extends BasePanelProps {
|
|
|
130
155
|
kind: 'overlay';
|
|
131
156
|
/**
|
|
132
157
|
* Specify the modal type (overlay only).
|
|
133
|
-
*
|
|
134
|
-
* `
|
|
158
|
+
*
|
|
159
|
+
* - `'nonModal'` (default) — page stays interactive; ESC closes the panel;
|
|
160
|
+
* outside clicks only close when `closeOnOutsidePress` is set.
|
|
161
|
+
* - `'isModal'` — backdrop overlay, focus trapped; ESC and backdrop click close the panel.
|
|
162
|
+
* - `'alert'` — close button hidden, ESC and outside clicks are suppressed.
|
|
163
|
+
*
|
|
135
164
|
* @default 'nonModal'
|
|
136
165
|
*/
|
|
137
166
|
modalType?: PanelModalType;
|
|
@@ -141,6 +170,34 @@ export interface OverlayPanelProps extends BasePanelProps {
|
|
|
141
170
|
* @default false
|
|
142
171
|
*/
|
|
143
172
|
closeOnOutsidePress?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Activates the floating/offset visual style for overlay panels.
|
|
175
|
+
* The panel is inset from the viewport edge, gains border radius,
|
|
176
|
+
* and hides the outer divider.
|
|
177
|
+
* Pass `true` to use the default offset (`1rem`), or a CSS length
|
|
178
|
+
* string (for example, `"2rem"`) for a custom offset on all sides. Pass a
|
|
179
|
+
* `{ x, y }` object (for example, `{ x: "2rem", y: "0.5rem" }`) for
|
|
180
|
+
* independent horizontal and vertical offsets.
|
|
181
|
+
* Setting this prop automatically suppresses the outer divider regardless
|
|
182
|
+
* of the `divider` prop value.
|
|
183
|
+
* @default false
|
|
184
|
+
*/
|
|
185
|
+
offset?: boolean | string | {
|
|
186
|
+
x: string;
|
|
187
|
+
y: string;
|
|
188
|
+
};
|
|
144
189
|
}
|
|
145
190
|
export type PanelProps = InlinePanelProps | OverlayPanelProps;
|
|
146
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Resolved resize configuration passed to internal Panel components.
|
|
193
|
+
* Presence signals resizing is enabled; absence signals it is disabled.
|
|
194
|
+
*/
|
|
195
|
+
export type PanelResizeConfig = {
|
|
196
|
+
/** @default 165 for start/end, 100 for bottom */
|
|
197
|
+
minSize: number;
|
|
198
|
+
/** @default 50dvw for start/end, 90dvh for bottom */
|
|
199
|
+
maxSize: number;
|
|
200
|
+
/** localStorage key for size persistence */
|
|
201
|
+
storageKey: string;
|
|
202
|
+
};
|
|
203
|
+
export type { PanelHeaderProps } from './Header/Panel.Header';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),k=require("../../../utils/hooks/useElementResize.cjs.js"),y=require("../../../utils/hooks/useLocalStorage.cjs.js"),R=({resizeConfig:u,position:l,floatingRef:c,requireMount:s=!1})=>{const n=!!u,{minSize:z=0,maxSize:b=0,storageKey:o=""}=u??{},i=t.useRef(null),[r,_]=t.useState(!1),m=t.useCallback(e=>{i.current=e,s&&_(!!e)},[s]),[S,d]=y.useLocalStorage(o||"__panel_no_key__","0",n&&!!o),a=n&&Number(S)>0?Number(S):0,f=t.useCallback(e=>{o&&d(e.toString())},[o,d]);return k.useElementResize(s?n&&r:n,c,i,z,b,a,l==="bottom"?"y":"x",l==="end",f),t.useEffect(()=>{if(!s||!r||!a||!c.current)return;const e=l==="bottom"?"blockSize":"inlineSize";c.current.style[e]=`${a}px`},[r]),{handleRef:m}};exports.usePanelResize=R;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PanelPosition, PanelResizeConfig } from './Panel.types';
|
|
2
|
+
type UsePanelResizeOptions = {
|
|
3
|
+
resizeConfig?: PanelResizeConfig;
|
|
4
|
+
position: PanelPosition;
|
|
5
|
+
floatingRef: React.RefObject<HTMLElement | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Overlay panels start closed: the floating element and resize handle don't mount until open.
|
|
8
|
+
* useElementResize's listener-attach effect would otherwise run with a null handle ref and never
|
|
9
|
+
* re-run (ref object identity is stable). When true, this hook tracks handle mount via callback
|
|
10
|
+
* ref and re-applies the stored size each time the panel opens.
|
|
11
|
+
*/
|
|
12
|
+
requireMount?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const usePanelResize: ({ resizeConfig, position, floatingRef, requireMount, }: UsePanelResizeOptions) => {
|
|
15
|
+
handleRef: (el: HTMLDivElement | null) => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useRef as _, useState as x, useCallback as u, useEffect as y } from "react";
|
|
2
|
+
import { useElementResize as k } from "../../../utils/hooks/useElementResize.es.js";
|
|
3
|
+
import { useLocalStorage as E } from "../../../utils/hooks/useLocalStorage.es.js";
|
|
4
|
+
const N = ({
|
|
5
|
+
resizeConfig: l,
|
|
6
|
+
position: o,
|
|
7
|
+
floatingRef: r,
|
|
8
|
+
requireMount: t = !1
|
|
9
|
+
}) => {
|
|
10
|
+
const n = !!l, { minSize: S = 0, maxSize: z = 0, storageKey: s = "" } = l ?? {}, m = _(null), [c, f] = x(!1), b = u(
|
|
11
|
+
(e) => {
|
|
12
|
+
m.current = e, t && f(!!e);
|
|
13
|
+
},
|
|
14
|
+
[t]
|
|
15
|
+
), [i, d] = E(
|
|
16
|
+
s || "__panel_no_key__",
|
|
17
|
+
"0",
|
|
18
|
+
n && !!s
|
|
19
|
+
), a = n && Number(i) > 0 ? Number(i) : 0, p = u(
|
|
20
|
+
(e) => {
|
|
21
|
+
s && d(e.toString());
|
|
22
|
+
},
|
|
23
|
+
[s, d]
|
|
24
|
+
);
|
|
25
|
+
return k(
|
|
26
|
+
t ? n && c : n,
|
|
27
|
+
r,
|
|
28
|
+
m,
|
|
29
|
+
S,
|
|
30
|
+
z,
|
|
31
|
+
a,
|
|
32
|
+
o === "bottom" ? "y" : "x",
|
|
33
|
+
o === "end",
|
|
34
|
+
p
|
|
35
|
+
), y(() => {
|
|
36
|
+
if (!t || !c || !a || !r.current) return;
|
|
37
|
+
const e = o === "bottom" ? "blockSize" : "inlineSize";
|
|
38
|
+
r.current.style[e] = `${a}px`;
|
|
39
|
+
}, [c]), { handleRef: b };
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
N as usePanelResize
|
|
43
|
+
};
|
package/lib/wip/Panel/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { Panel } from './Panel';
|
|
2
2
|
export type { PanelProps, InlinePanelProps, OverlayPanelProps, PanelKind, PanelPosition, PanelModalType, PanelSize, PanelPadding, PanelCloseReason, } from './Panel.types';
|
|
3
|
-
export type { PanelHeaderProps } from './Panel.Header';
|
|
4
|
-
export type { PanelHeaderRowProps } from './Panel.Header.Row';
|
|
5
|
-
export type { PanelHeaderContentBeforeProps } from './Panel.Header.ContentBefore';
|
|
6
|
-
export type { PanelHeaderHeadingProps } from './Panel.Header.Heading';
|
|
7
|
-
export type { PanelHeaderDescriptionProps } from './Panel.Header.Description';
|
|
8
|
-
export type { PanelHeaderContentAfterProps } from './Panel.Header.ContentAfter';
|
|
9
|
-
export type { PanelHeaderSubheaderProps } from './Panel.Header.Subheader';
|
|
3
|
+
export type { PanelHeaderProps } from './Header/Panel.Header';
|
|
4
|
+
export type { PanelHeaderRowProps } from './Header/Panel.Header.Row';
|
|
5
|
+
export type { PanelHeaderContentBeforeProps } from './Header/Panel.Header.ContentBefore';
|
|
6
|
+
export type { PanelHeaderHeadingProps } from './Header/Panel.Header.Heading';
|
|
7
|
+
export type { PanelHeaderDescriptionProps } from './Header/Panel.Header.Description';
|
|
8
|
+
export type { PanelHeaderContentAfterProps } from './Header/Panel.Header.ContentAfter';
|
|
9
|
+
export type { PanelHeaderSubheaderProps } from './Header/Panel.Header.Subheader';
|
|
10
10
|
export type { PanelBodyProps } from './Panel.Body';
|
|
11
|
-
export type { PanelFooterProps } from './Panel.Footer';
|
|
12
|
-
export type { PanelFooterActionsProps } from './Panel.Footer.Actions';
|
|
11
|
+
export type { PanelFooterProps } from './Footer/Panel.Footer';
|
|
12
|
+
export type { PanelFooterActionsProps } from './Footer/Panel.Footer.Actions';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
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.
|
|
63
|
-
"@viasat/beam-shared": "2.
|
|
64
|
-
"@viasat/beam-styles": "2.
|
|
65
|
-
"@viasat/beam-tokens": "2.
|
|
66
|
-
"@viasat/beam-icons": "2.
|
|
62
|
+
"@viasat/beam-fonts": "2.28.0",
|
|
63
|
+
"@viasat/beam-shared": "2.28.0",
|
|
64
|
+
"@viasat/beam-styles": "2.28.0",
|
|
65
|
+
"@viasat/beam-tokens": "2.28.0",
|
|
66
|
+
"@viasat/beam-icons": "2.28.0",
|
|
67
67
|
"clsx": "^1.2.1",
|
|
68
68
|
"@floating-ui/react": "^0.26.18",
|
|
69
69
|
"@stepperize/react": "^5.1.5",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),m=(g,n,o,P=165,k=400,i=0,e="x",W=!1,M)=>{const[$,Y]=r.useState(i),h=r.useRef(0),X=r.useRef(!1),L=r.useRef(i),s=r.useRef(null),p=r.useRef(null),w=r.useRef(M);w.current=M,r.useLayoutEffect(()=>{if(!i||!n.current||!g)return;const t=e==="y"?"blockSize":"inlineSize";n.current.style[t]=`${i}px`},[]);const C=r.useCallback(t=>{if(!n.current)return;const u=k===1/0?e==="y"?window.innerHeight*.9:window.innerWidth*.5:k;if(e==="y"){const c=t.clientY-h.current,f=n.current.offsetHeight-c;f>=P&&f<=u&&(h.current=t.clientY,L.current=f,Y(f),n.current.style.blockSize=`${f}px`)}else{const c=t.clientX-h.current,v=n.current.offsetWidth,y=X.current!==W?v-c:v+c;y>=P&&y<=u&&(h.current=t.clientX,L.current=y,Y(y),n.current.style.inlineSize=`${y}px`)}},[n,P,k,e,W]),d=r.useCallback(t=>{s.current=t,p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null,s.current&&(C(s.current),s.current=null)}))},[C]),l=r.useCallback(t=>{var u,c;(u=o.current)==null||u.releasePointerCapture(t.pointerId),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",l),p.current!==null&&(cancelAnimationFrame(p.current),p.current=null),s.current&&(C(s.current),s.current=null),n.current&&(n.current.style.transition=""),(c=w.current)==null||c.call(w,L.current)},[C,d,n,o]),I=r.useCallback(t=>{var u,c,v;t.preventDefault(),n.current&&(X.current=e==="x"?getComputedStyle(n.current).direction==="rtl":!1,n.current.style.transition="none"),(u=o.current)==null||u.setPointerCapture(t.pointerId),h.current=e==="y"?t.clientY:t.clientX,L.current=e==="y"?((c=n.current)==null?void 0:c.offsetHeight)??i:((v=n.current)==null?void 0:v.offsetWidth)??i,document.addEventListener("pointermove",d),document.addEventListener("pointerup",l)},[d,l,n,o,e,i]);return r.useEffect(()=>{if(!g||!o.current)return;const t=o.current;return t.addEventListener("pointerdown",I),()=>{t.removeEventListener("pointerdown",I),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",l)}},[I,d,l,g,o]),$};exports.useElementResize=m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useElementResize: (resizeEnabled: boolean, resizableElementRef: React.RefObject<HTMLElement>, resizeHandlerRef: React.RefObject<HTMLElement>,
|
|
1
|
+
export declare const useElementResize: (resizeEnabled: boolean, resizableElementRef: React.RefObject<HTMLElement>, resizeHandlerRef: React.RefObject<HTMLElement>, minSize?: number, maxSize?: number, defaultSize?: number, axis?: "x" | "y", invertX?: boolean, onDragEnd?: (size: number) => void) => number;
|
|
@@ -1,46 +1,52 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useState as A, useRef as v, useLayoutEffect as F, useCallback as C, useEffect as q } from "react";
|
|
2
|
+
const U = (I, n, o, P = 165, W = 400, e = 0, c = "x", k = !1, M) => {
|
|
3
|
+
const [m, X] = A(e), y = v(0), $ = v(!1), w = v(e), i = v(null), s = v(null), g = v(M);
|
|
4
|
+
g.current = M, F(() => {
|
|
5
|
+
if (!e || !n.current || !I) return;
|
|
6
|
+
const t = c === "y" ? "blockSize" : "inlineSize";
|
|
7
|
+
n.current.style[t] = `${e}px`;
|
|
8
|
+
}, []);
|
|
9
|
+
const l = C(
|
|
6
10
|
(t) => {
|
|
7
11
|
if (!n.current) return;
|
|
8
|
-
const
|
|
9
|
-
c
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const u = W === 1 / 0 ? c === "y" ? window.innerHeight * 0.9 : window.innerWidth * 0.5 : W;
|
|
13
|
+
if (c === "y") {
|
|
14
|
+
const r = t.clientY - y.current, h = n.current.offsetHeight - r;
|
|
15
|
+
h >= P && h <= u && (y.current = t.clientY, w.current = h, X(h), n.current.style.blockSize = `${h}px`);
|
|
16
|
+
} else {
|
|
17
|
+
const r = t.clientX - y.current, d = n.current.offsetWidth, L = $.current !== k ? d - r : d + r;
|
|
18
|
+
L >= P && L <= u && (y.current = t.clientX, w.current = L, X(L), n.current.style.inlineSize = `${L}px`);
|
|
19
|
+
}
|
|
14
20
|
},
|
|
15
|
-
[n,
|
|
16
|
-
),
|
|
17
|
-
() => W(L, M),
|
|
18
|
-
[L]
|
|
19
|
-
), e = s(
|
|
21
|
+
[n, P, W, c, k]
|
|
22
|
+
), p = C(
|
|
20
23
|
(t) => {
|
|
21
|
-
|
|
24
|
+
i.current = t, s.current === null && (s.current = requestAnimationFrame(() => {
|
|
25
|
+
s.current = null, i.current && (l(i.current), i.current = null);
|
|
26
|
+
}));
|
|
22
27
|
},
|
|
23
|
-
[
|
|
24
|
-
),
|
|
28
|
+
[l]
|
|
29
|
+
), f = C(
|
|
25
30
|
(t) => {
|
|
26
|
-
|
|
31
|
+
var u, r;
|
|
32
|
+
(u = o.current) == null || u.releasePointerCapture(t.pointerId), document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", f), s.current !== null && (cancelAnimationFrame(s.current), s.current = null), i.current && (l(i.current), i.current = null), n.current && (n.current.style.transition = ""), (r = g.current) == null || r.call(g, w.current);
|
|
27
33
|
},
|
|
28
|
-
[
|
|
34
|
+
[l, p, n, o]
|
|
35
|
+
), Y = C(
|
|
36
|
+
(t) => {
|
|
37
|
+
var u, r, d;
|
|
38
|
+
t.preventDefault(), n.current && ($.current = c === "x" ? getComputedStyle(n.current).direction === "rtl" : !1, n.current.style.transition = "none"), (u = o.current) == null || u.setPointerCapture(t.pointerId), y.current = c === "y" ? t.clientY : t.clientX, w.current = c === "y" ? ((r = n.current) == null ? void 0 : r.offsetHeight) ?? e : ((d = n.current) == null ? void 0 : d.offsetWidth) ?? e, document.addEventListener("pointermove", p), document.addEventListener("pointerup", f);
|
|
39
|
+
},
|
|
40
|
+
[p, f, n, o, c, e]
|
|
29
41
|
);
|
|
30
|
-
return
|
|
31
|
-
if (!
|
|
32
|
-
const t =
|
|
33
|
-
return t
|
|
34
|
-
t
|
|
42
|
+
return q(() => {
|
|
43
|
+
if (!I || !o.current) return;
|
|
44
|
+
const t = o.current;
|
|
45
|
+
return t.addEventListener("pointerdown", Y), () => {
|
|
46
|
+
t.removeEventListener("pointerdown", Y), document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", f);
|
|
35
47
|
};
|
|
36
|
-
}, [
|
|
37
|
-
i,
|
|
38
|
-
o,
|
|
39
|
-
e,
|
|
40
|
-
p,
|
|
41
|
-
r
|
|
42
|
-
]), a;
|
|
48
|
+
}, [Y, p, f, I, o]), m;
|
|
43
49
|
};
|
|
44
50
|
export {
|
|
45
|
-
|
|
51
|
+
U as useElementResize
|
|
46
52
|
};
|