@viasat/beam-react 2.10.2 → 2.11.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/lib/wip/Panel/Panel.Header.Row.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Header.Row.es.js +17 -17
- package/lib/wip/Panel/Panel.cjs.js +1 -1
- package/lib/wip/Panel/Panel.context.d.ts +6 -5
- package/lib/wip/Panel/Panel.d.ts +1 -1
- package/lib/wip/Panel/Panel.es.js +69 -68
- package/lib/wip/Panel/Panel.helpers.cjs.js +1 -1
- package/lib/wip/Panel/Panel.helpers.d.ts +6 -1
- package/lib/wip/Panel/Panel.helpers.es.js +49 -27
- package/lib/wip/Panel/Panel.types.d.ts +34 -0
- package/lib/wip/Panel/index.d.ts +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("clsx"),m=require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");const _=require("../../CloseButton/CloseButton.cjs.js"),b=require("./Panel.context.cjs.js"),s=require("../../../chunks/panel.module.BX1x4FlX.js"),{subElementClassPrefix:C}=m.getBEMClassNames("panel"),t=`${C}header`,l=({children:o,className:n,...a})=>{const{dismissible:r,closeButtonAriaLabel:i,requestClose:c}=b.usePanelContext(),u=d(s.styles[`${t}__row`],n);return e.jsxs("div",{className:u,...a,children:[o,r&&e.jsx("div",{className:s.styles[`${t}__close-button`],children:e.jsx(_.CloseButton,{"aria-label":i,onClick:()=>c("closeButton"),size:"lg"})})]})};l.displayName="Panel.Header.Row";exports.Row=l;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as c, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import p from "clsx";
|
|
3
3
|
import { g as d } from "../../../chunks/classNames.BTJmrO_L.js";
|
|
4
4
|
import "../../../chunks/constants.CKKGf1-i.js";
|
|
5
|
-
import { CloseButton as
|
|
6
|
-
import { usePanelContext as
|
|
7
|
-
import { s as
|
|
8
|
-
const { subElementClassPrefix:
|
|
9
|
-
children:
|
|
10
|
-
className:
|
|
11
|
-
...
|
|
5
|
+
import { CloseButton as u } from "../../CloseButton/CloseButton.es.js";
|
|
6
|
+
import { usePanelContext as f } from "./Panel.context.es.js";
|
|
7
|
+
import { s as e } from "../../../chunks/panel.module.BVm3KvDs.js";
|
|
8
|
+
const { subElementClassPrefix: C } = d("panel"), o = `${C}header`, b = ({
|
|
9
|
+
children: t,
|
|
10
|
+
className: l,
|
|
11
|
+
...a
|
|
12
12
|
}) => {
|
|
13
|
-
const { dismissible:
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const { dismissible: r, closeButtonAriaLabel: i, requestClose: m } = f(), n = p(e[`${o}__row`], l);
|
|
14
|
+
return /* @__PURE__ */ c("div", { className: n, ...a, children: [
|
|
15
|
+
t,
|
|
16
|
+
r && /* @__PURE__ */ s("div", { className: e[`${o}__close-button`], children: /* @__PURE__ */ s(
|
|
17
|
+
u,
|
|
18
18
|
{
|
|
19
|
-
"aria-label":
|
|
20
|
-
onClick: () =>
|
|
19
|
+
"aria-label": i,
|
|
20
|
+
onClick: () => m("closeButton"),
|
|
21
21
|
size: "lg"
|
|
22
22
|
}
|
|
23
23
|
) })
|
|
24
24
|
] });
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
b.displayName = "Panel.Header.Row";
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
b as Row
|
|
29
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("clsx"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("clsx"),U=require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");const N=require("./Panel.context.cjs.js"),B=require("./Panel.Header.cjs.js"),T=require("./Panel.Body.cjs.js"),A=require("./Panel.Footer.cjs.js"),t=require("./Panel.helpers.cjs.js"),H=require("../../FloatingUI/FloatingUI.root.cjs.js"),M=require("../../FloatingUI/FloatingUI.content.cjs.js"),E=require("../../Divider/Divider.cjs.js"),n=require("../../../chunks/panel.module.BX1x4FlX.js"),{baseClassNamePrefix:s}=U.getBEMClassNames("panel"),a=({position:o,className:d})=>e.jsx(E.Divider,{borderColor:"01",orientation:o==="bottom"?"horizontal":"vertical",className:d}),l=({children:o,className:d,padding:j="md",onOpenChange:q,open:v,size:c,dismissible:C=!0,closeButtonAriaLabel:$="Close panel",kind:r="inline",position:p,divider:h=!0,isAnimated:P=!0,onBeforeClose:I,...y})=>{const i=t.getResolvedPanelPosition(p),x=u(n.styles[s],n.styles[`${s}--${r}`],c&&n.styles[`${s}--size-${c}`],n.styles[`${s}--padding-${j}`],n.styles[`${s}--position-${i}`],d),f=u(n.styles[`${s}__inline-wrapper`],c==="full"&&n.styles[`${s}__inline-wrapper--full`]),{requestClose:w,handleOverlayOpenChange:D}=t.usePanelClose(I,q),m={dismissible:C,closeButtonAriaLabel:$,position:p,requestClose:w},{inlineStatus:F,isInlineVisible:b}=t.useInlineTransition(r==="inline"?v:void 0,P),{showDivider:g,dividerBefore:S,dividerAfter:O}=t.getPanelDividerState(h,i),R=r==="overlay"?u(n.styles[`${s}__overlay-divider`],n.styles[`${s}__overlay-divider--${i}`]):void 0,_=g&&b;return r==="inline"?b?e.jsxs(N.PanelContext.Provider,{value:m,children:[S&&_&&e.jsx(a,{position:i}),e.jsx("div",{className:f,"data-position":i,"data-status":F,children:e.jsxs("div",{className:n.styles[`${s}__inline-wrapper-content`],children:[i==="bottom"&&_&&e.jsx(a,{position:i}),e.jsx("aside",{className:x,...y,children:o})]})}),O&&_&&e.jsx(a,{position:i})]}):null:e.jsx(N.PanelContext.Provider,{value:m,children:e.jsx(H.FloatingUIRoot,{open:v,onOpenChange:D,portalled:!0,transitionConfig:{duration:P?t.PANEL_TRANSITION_DURATION_MS:0},children:e.jsxs(M.Content,{className:x,skipFloatingStyles:!0,overlay:!0,...y,"data-position":i,children:[o,g&&e.jsx(a,{position:i,className:R})]})})})};l.displayName="Panel";l.Header=B.Header;l.Body=T.Body;l.Footer=A.Footer;exports.Panel=l;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PanelPosition } from './Panel.types';
|
|
1
|
+
import { PanelCloseReason, PanelPosition } from './Panel.types';
|
|
2
2
|
export interface PanelContextValue {
|
|
3
3
|
/**
|
|
4
4
|
* Whether to show a dismissible button
|
|
@@ -8,14 +8,15 @@ export interface PanelContextValue {
|
|
|
8
8
|
* Aria label for the dismissible button
|
|
9
9
|
*/
|
|
10
10
|
closeButtonAriaLabel?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Callback when panel open state changes
|
|
13
|
-
*/
|
|
14
|
-
onOpenChange?: (open: boolean) => void;
|
|
15
11
|
/**
|
|
16
12
|
* Panel position (determines divider placement)
|
|
17
13
|
*/
|
|
18
14
|
position?: PanelPosition;
|
|
15
|
+
/**
|
|
16
|
+
* Request the panel to close for the given reason. Runs `onBeforeClose` if
|
|
17
|
+
* provided and only calls `onOpenChange(false)` when the guard returns `true`.
|
|
18
|
+
*/
|
|
19
|
+
requestClose: (reason: PanelCloseReason) => void;
|
|
19
20
|
}
|
|
20
21
|
export declare const PanelContext: import('react').Context<PanelContextValue | undefined>;
|
|
21
22
|
export declare const usePanelContext: () => PanelContextValue;
|
package/lib/wip/Panel/Panel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PanelProps } from './Panel.types';
|
|
2
2
|
export declare const Panel: {
|
|
3
|
-
({ children, className: _className, padding, onOpenChange, open, size, dismissible, closeButtonAriaLabel, kind, position, divider, isAnimated, ...props }: PanelProps): JSX.Element | null;
|
|
3
|
+
({ children, className: _className, padding, onOpenChange, open, size, dismissible, closeButtonAriaLabel, kind, position, divider, isAnimated, onBeforeClose, ...props }: PanelProps): JSX.Element | null;
|
|
4
4
|
displayName: string;
|
|
5
5
|
Header: {
|
|
6
6
|
({ children, className: _className, divider, ...props }: import('./Panel.Header').PanelHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,105 +1,106 @@
|
|
|
1
1
|
import { jsxs as p, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import v from "clsx";
|
|
3
|
-
import { g as
|
|
3
|
+
import { g as A } from "../../../chunks/classNames.BTJmrO_L.js";
|
|
4
4
|
import "../../../chunks/constants.CKKGf1-i.js";
|
|
5
|
-
import { PanelContext as
|
|
6
|
-
import { Header as
|
|
7
|
-
import { Body as
|
|
8
|
-
import { Footer as
|
|
9
|
-
import { useInlineTransition as
|
|
10
|
-
import { FloatingUIRoot as
|
|
11
|
-
import { Content as
|
|
12
|
-
import { Divider as
|
|
13
|
-
import { s as
|
|
14
|
-
const { baseClassNamePrefix:
|
|
5
|
+
import { PanelContext as h } from "./Panel.context.es.js";
|
|
6
|
+
import { Header as j } from "./Panel.Header.es.js";
|
|
7
|
+
import { Body as E } from "./Panel.Body.es.js";
|
|
8
|
+
import { Footer as H } from "./Panel.Footer.es.js";
|
|
9
|
+
import { usePanelClose as M, useInlineTransition as U, getPanelDividerState as V, PANEL_TRANSITION_DURATION_MS as q, getResolvedPanelPosition as L } from "./Panel.helpers.es.js";
|
|
10
|
+
import { FloatingUIRoot as W } from "../../FloatingUI/FloatingUI.root.es.js";
|
|
11
|
+
import { Content as z } from "../../FloatingUI/FloatingUI.content.es.js";
|
|
12
|
+
import { Divider as G } from "../../Divider/Divider.es.js";
|
|
13
|
+
import { s as o } from "../../../chunks/panel.module.BVm3KvDs.js";
|
|
14
|
+
const { baseClassNamePrefix: i } = A("panel"), a = ({
|
|
15
15
|
position: t,
|
|
16
|
-
className:
|
|
16
|
+
className: s
|
|
17
17
|
}) => /* @__PURE__ */ r(
|
|
18
|
-
|
|
18
|
+
G,
|
|
19
19
|
{
|
|
20
20
|
borderColor: "01",
|
|
21
21
|
orientation: t === "bottom" ? "horizontal" : "vertical",
|
|
22
|
-
className:
|
|
22
|
+
className: s
|
|
23
23
|
}
|
|
24
|
-
),
|
|
24
|
+
), l = ({
|
|
25
25
|
children: t,
|
|
26
|
-
className:
|
|
27
|
-
padding:
|
|
28
|
-
onOpenChange:
|
|
29
|
-
open:
|
|
26
|
+
className: s,
|
|
27
|
+
padding: y = "md",
|
|
28
|
+
onOpenChange: g,
|
|
29
|
+
open: c,
|
|
30
30
|
size: d,
|
|
31
|
-
dismissible:
|
|
31
|
+
dismissible: I = !0,
|
|
32
32
|
closeButtonAriaLabel: x = "Close panel",
|
|
33
33
|
kind: n = "inline",
|
|
34
34
|
position: u,
|
|
35
35
|
divider: D = !0,
|
|
36
|
-
isAnimated:
|
|
37
|
-
|
|
36
|
+
isAnimated: f = !0,
|
|
37
|
+
onBeforeClose: b,
|
|
38
|
+
...N
|
|
38
39
|
}) => {
|
|
39
|
-
const e =
|
|
40
|
-
i
|
|
41
|
-
|
|
42
|
-
d &&
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
),
|
|
47
|
-
|
|
48
|
-
d === "full" &&
|
|
49
|
-
),
|
|
50
|
-
dismissible:
|
|
40
|
+
const e = L(u), $ = v(
|
|
41
|
+
o[i],
|
|
42
|
+
o[`${i}--${n}`],
|
|
43
|
+
d && o[`${i}--size-${d}`],
|
|
44
|
+
o[`${i}--padding-${y}`],
|
|
45
|
+
o[`${i}--position-${e}`],
|
|
46
|
+
s
|
|
47
|
+
), O = v(
|
|
48
|
+
o[`${i}__inline-wrapper`],
|
|
49
|
+
d === "full" && o[`${i}__inline-wrapper--full`]
|
|
50
|
+
), { requestClose: R, handleOverlayOpenChange: S } = M(b, g), C = {
|
|
51
|
+
dismissible: I,
|
|
51
52
|
closeButtonAriaLabel: x,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, { inlineStatus:
|
|
55
|
-
n === "inline" ?
|
|
56
|
-
|
|
57
|
-
), { showDivider:
|
|
53
|
+
position: u,
|
|
54
|
+
requestClose: R
|
|
55
|
+
}, { inlineStatus: w, isInlineVisible: _ } = U(
|
|
56
|
+
n === "inline" ? c : void 0,
|
|
57
|
+
f
|
|
58
|
+
), { showDivider: P, dividerBefore: B, dividerAfter: F } = V(
|
|
58
59
|
D,
|
|
59
60
|
e
|
|
60
|
-
),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
) : void 0, m =
|
|
64
|
-
return n === "inline" ?
|
|
65
|
-
|
|
61
|
+
), T = n === "overlay" ? v(
|
|
62
|
+
o[`${i}__overlay-divider`],
|
|
63
|
+
o[`${i}__overlay-divider--${e}`]
|
|
64
|
+
) : void 0, m = P && _;
|
|
65
|
+
return n === "inline" ? _ ? /* @__PURE__ */ p(h.Provider, { value: C, children: [
|
|
66
|
+
B && m && /* @__PURE__ */ r(a, { position: e }),
|
|
66
67
|
/* @__PURE__ */ r(
|
|
67
68
|
"div",
|
|
68
69
|
{
|
|
69
|
-
className:
|
|
70
|
+
className: O,
|
|
70
71
|
"data-position": e,
|
|
71
|
-
"data-status":
|
|
72
|
-
children: /* @__PURE__ */ p("div", { className:
|
|
73
|
-
e === "bottom" && m && /* @__PURE__ */ r(
|
|
74
|
-
/* @__PURE__ */ r("aside", { className:
|
|
72
|
+
"data-status": w,
|
|
73
|
+
children: /* @__PURE__ */ p("div", { className: o[`${i}__inline-wrapper-content`], children: [
|
|
74
|
+
e === "bottom" && m && /* @__PURE__ */ r(a, { position: e }),
|
|
75
|
+
/* @__PURE__ */ r("aside", { className: $, ...N, children: t })
|
|
75
76
|
] })
|
|
76
77
|
}
|
|
77
78
|
),
|
|
78
|
-
|
|
79
|
-
] }) : null : /* @__PURE__ */ r(
|
|
80
|
-
|
|
79
|
+
F && m && /* @__PURE__ */ r(a, { position: e })
|
|
80
|
+
] }) : null : /* @__PURE__ */ r(h.Provider, { value: C, children: /* @__PURE__ */ r(
|
|
81
|
+
W,
|
|
81
82
|
{
|
|
82
|
-
open:
|
|
83
|
-
onOpenChange:
|
|
83
|
+
open: c,
|
|
84
|
+
onOpenChange: S,
|
|
84
85
|
portalled: !0,
|
|
85
86
|
transitionConfig: {
|
|
86
|
-
duration:
|
|
87
|
+
duration: f ? q : 0
|
|
87
88
|
},
|
|
88
89
|
children: /* @__PURE__ */ p(
|
|
89
|
-
|
|
90
|
+
z,
|
|
90
91
|
{
|
|
91
|
-
className:
|
|
92
|
+
className: $,
|
|
92
93
|
skipFloatingStyles: !0,
|
|
93
94
|
overlay: !0,
|
|
94
|
-
|
|
95
|
+
...N,
|
|
95
96
|
"data-position": e,
|
|
96
97
|
children: [
|
|
97
98
|
t,
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
P && /* @__PURE__ */ r(
|
|
100
|
+
a,
|
|
100
101
|
{
|
|
101
102
|
position: e,
|
|
102
|
-
className:
|
|
103
|
+
className: T
|
|
103
104
|
}
|
|
104
105
|
)
|
|
105
106
|
]
|
|
@@ -108,10 +109,10 @@ const { baseClassNamePrefix: o } = F("panel"), l = ({
|
|
|
108
109
|
}
|
|
109
110
|
) });
|
|
110
111
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
l.displayName = "Panel";
|
|
113
|
+
l.Header = j;
|
|
114
|
+
l.Body = E;
|
|
115
|
+
l.Footer = H;
|
|
115
116
|
export {
|
|
116
|
-
|
|
117
|
+
l as Panel
|
|
117
118
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),a=400,f=e=>e||"end",o=(e,t)=>{const s=e&&t!=="full";return{showDivider:s,dividerBefore:s&&t!=="start"&&t!=="bottom",dividerAfter:s&&t==="start"}},m=e=>e==="escape-key"?"escapeKey":e==="outside-press"?"outsidePress":"programmatic",v=(e,t)=>{const s=c.useCallback(u=>{if(!e){t==null||t(!1);return}const r=e(u);r instanceof Promise?r.then(i=>{i&&(t==null||t(!1))}).catch(()=>{}):r&&(t==null||t(!1))},[e,t]),l=c.useCallback((u,r,i)=>{u?t==null||t(!0):s(m(i))},[t,s]);return{requestClose:s,handleOverlayOpenChange:l}},I=(e,t)=>{const[s,l]=c.useState(void 0),[u,r]=c.useState(e!==!1);return c.useEffect(()=>{if(!t){r(e!==!1),l(void 0);return}if(e!==void 0)if(e){r(!0),l("close");let i;const d=requestAnimationFrame(()=>{i=requestAnimationFrame(()=>l("open"))});return()=>{cancelAnimationFrame(d),cancelAnimationFrame(i)}}else{l("close");const i=setTimeout(()=>{r(!1),l(void 0)},a);return()=>clearTimeout(i)}},[t,e]),{inlineStatus:s,isInlineVisible:u}};exports.PANEL_TRANSITION_DURATION_MS=a;exports.getPanelDividerState=o;exports.getResolvedPanelPosition=f;exports.useInlineTransition=I;exports.usePanelClose=v;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenChangeReason } from '@floating-ui/react';
|
|
2
|
+
import { PanelCloseReason, PanelPosition, PanelProps } from './Panel.types';
|
|
2
3
|
export declare const PANEL_TRANSITION_DURATION_MS = 400;
|
|
3
4
|
export type PanelInlineStatus = 'open' | 'close' | undefined;
|
|
4
5
|
export declare const getResolvedPanelPosition: (position?: PanelPosition) => PanelPosition;
|
|
@@ -7,6 +8,10 @@ export declare const getPanelDividerState: (divider: boolean, position?: PanelPo
|
|
|
7
8
|
dividerBefore: boolean;
|
|
8
9
|
dividerAfter: boolean;
|
|
9
10
|
};
|
|
11
|
+
export declare const usePanelClose: (onBeforeClose: PanelProps["onBeforeClose"], onOpenChange: PanelProps["onOpenChange"]) => {
|
|
12
|
+
requestClose: (reason: PanelCloseReason) => void;
|
|
13
|
+
handleOverlayOpenChange: (nextOpen: boolean, _event?: Event, floatingReason?: OpenChangeReason) => void;
|
|
14
|
+
};
|
|
10
15
|
export declare const useInlineTransition: (open: boolean | undefined, isAnimated: boolean) => {
|
|
11
16
|
inlineStatus: PanelInlineStatus;
|
|
12
17
|
isInlineVisible: boolean;
|
|
@@ -1,40 +1,62 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
import { useState as c, useEffect as m, useCallback as f } from "react";
|
|
2
|
+
const a = 400, I = (s) => s || "end", A = (s, t) => {
|
|
3
|
+
const r = s && t !== "full";
|
|
4
4
|
return {
|
|
5
|
-
showDivider:
|
|
6
|
-
dividerBefore:
|
|
7
|
-
dividerAfter:
|
|
5
|
+
showDivider: r,
|
|
6
|
+
dividerBefore: r && t !== "start" && t !== "bottom",
|
|
7
|
+
dividerAfter: r && t === "start"
|
|
8
8
|
};
|
|
9
|
-
},
|
|
10
|
-
const
|
|
11
|
-
|
|
9
|
+
}, v = (s) => s === "escape-key" ? "escapeKey" : s === "outside-press" ? "outsidePress" : "programmatic", P = (s, t) => {
|
|
10
|
+
const r = f(
|
|
11
|
+
(u) => {
|
|
12
|
+
if (!s) {
|
|
13
|
+
t == null || t(!1);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const e = s(u);
|
|
17
|
+
e instanceof Promise ? e.then((i) => {
|
|
18
|
+
i && (t == null || t(!1));
|
|
19
|
+
}).catch(() => {
|
|
20
|
+
}) : e && (t == null || t(!1));
|
|
21
|
+
},
|
|
22
|
+
[s, t]
|
|
23
|
+
), l = f(
|
|
24
|
+
(u, e, i) => {
|
|
25
|
+
u ? t == null || t(!0) : r(v(i));
|
|
26
|
+
},
|
|
27
|
+
[t, r]
|
|
28
|
+
);
|
|
29
|
+
return { requestClose: r, handleOverlayOpenChange: l };
|
|
30
|
+
}, S = (s, t) => {
|
|
31
|
+
const [r, l] = c(void 0), [u, e] = c(s !== !1);
|
|
32
|
+
return m(() => {
|
|
12
33
|
if (!t) {
|
|
13
|
-
s
|
|
34
|
+
e(s !== !1), l(void 0);
|
|
14
35
|
return;
|
|
15
36
|
}
|
|
16
|
-
if (
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
const
|
|
21
|
-
|
|
37
|
+
if (s !== void 0)
|
|
38
|
+
if (s) {
|
|
39
|
+
e(!0), l("close");
|
|
40
|
+
let i;
|
|
41
|
+
const d = requestAnimationFrame(() => {
|
|
42
|
+
i = requestAnimationFrame(() => l("open"));
|
|
22
43
|
});
|
|
23
44
|
return () => {
|
|
24
|
-
cancelAnimationFrame(
|
|
45
|
+
cancelAnimationFrame(d), cancelAnimationFrame(i);
|
|
25
46
|
};
|
|
26
47
|
} else {
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
return () => clearTimeout(
|
|
48
|
+
l("close");
|
|
49
|
+
const i = setTimeout(() => {
|
|
50
|
+
e(!1), l(void 0);
|
|
51
|
+
}, a);
|
|
52
|
+
return () => clearTimeout(i);
|
|
32
53
|
}
|
|
33
|
-
}, [t,
|
|
54
|
+
}, [t, s]), { inlineStatus: r, isInlineVisible: u };
|
|
34
55
|
};
|
|
35
56
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
a as PANEL_TRANSITION_DURATION_MS,
|
|
58
|
+
A as getPanelDividerState,
|
|
59
|
+
I as getResolvedPanelPosition,
|
|
60
|
+
S as useInlineTransition,
|
|
61
|
+
P as usePanelClose
|
|
40
62
|
};
|
|
@@ -4,6 +4,15 @@ export type PanelPosition = 'start' | 'end' | 'bottom' | 'full';
|
|
|
4
4
|
export type PanelModalType = 'nonModal' | 'isModal' | 'alert';
|
|
5
5
|
export type PanelSize = 'sm' | 'md' | 'lg' | 'full' | 'custom';
|
|
6
6
|
export type PanelPadding = 'sm' | 'md';
|
|
7
|
+
/**
|
|
8
|
+
* The reason a Panel close was requested via user interaction.
|
|
9
|
+
*
|
|
10
|
+
* - `'escapeKey'` — user pressed Escape (overlay panels only)
|
|
11
|
+
* - `'outsidePress'` — user clicked outside the panel (overlay panels only)
|
|
12
|
+
* - `'closeButton'` — user clicked the header close button
|
|
13
|
+
* - `'programmatic'` — close was triggered by another interaction not covered above
|
|
14
|
+
*/
|
|
15
|
+
export type PanelCloseReason = 'escapeKey' | 'outsidePress' | 'closeButton' | 'programmatic';
|
|
7
16
|
interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
|
|
8
17
|
/**
|
|
9
18
|
* Specify the content of the Panel
|
|
@@ -54,6 +63,31 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
|
|
|
54
63
|
* @default 'end'
|
|
55
64
|
*/
|
|
56
65
|
position?: PanelPosition;
|
|
66
|
+
/**
|
|
67
|
+
* Called before the Panel closes due to a user interaction. Return `false` (or
|
|
68
|
+
* `Promise<false>`) to cancel the close — for example, when the panel contains
|
|
69
|
+
* a form with unsaved changes.
|
|
70
|
+
*
|
|
71
|
+
* This callback is **not** invoked when the `open` prop is changed programmatically
|
|
72
|
+
* by the parent; it only fires for UI-triggered close events (close button, Escape
|
|
73
|
+
* key, or outside press).
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* // Use a stateful confirmation dialog — avoid window.confirm (blocking, breaks iframes).
|
|
78
|
+
* // See the `onBeforeClose (Unsaved Changes Guard)` story for a full reference implementation.
|
|
79
|
+
* <Panel
|
|
80
|
+
* onBeforeClose={(reason) => {
|
|
81
|
+
* if (!isDirty) return true;
|
|
82
|
+
* return new Promise(resolve => {
|
|
83
|
+
* setResolveClose(() => resolve);
|
|
84
|
+
* setShowConfirmDialog(true);
|
|
85
|
+
* });
|
|
86
|
+
* }}
|
|
87
|
+
* />
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
onBeforeClose?: (reason: PanelCloseReason) => boolean | Promise<boolean>;
|
|
57
91
|
}
|
|
58
92
|
export interface InlinePanelProps extends BasePanelProps {
|
|
59
93
|
/**
|
package/lib/wip/Panel/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Panel } from './Panel';
|
|
2
|
-
export type { PanelProps, InlinePanelProps, OverlayPanelProps, PanelKind, PanelPosition, PanelModalType, PanelSize, PanelPadding, } from './Panel.types';
|
|
2
|
+
export type { PanelProps, InlinePanelProps, OverlayPanelProps, PanelKind, PanelPosition, PanelModalType, PanelSize, PanelPadding, PanelCloseReason, } from './Panel.types';
|
|
3
3
|
export type { PanelHeaderProps } from './Panel.Header';
|
|
4
4
|
export type { PanelHeaderRowProps } from './Panel.Header.Row';
|
|
5
5
|
export type { PanelHeaderContentBeforeProps } from './Panel.Header.ContentBefore';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.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.11.0",
|
|
63
|
+
"@viasat/beam-shared": "2.11.0",
|
|
64
|
+
"@viasat/beam-styles": "2.11.0",
|
|
65
|
+
"@viasat/beam-tokens": "2.11.0",
|
|
66
|
+
"@viasat/beam-icons": "2.11.0",
|
|
67
67
|
"clsx": "^1.2.1",
|
|
68
68
|
"@floating-ui/react": "^0.26.18",
|
|
69
69
|
"@stepperize/react": "^5.1.5",
|