@viasat/beam-react 2.10.2 → 2.12.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=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"),l=require("../../../chunks/panel.module.BX1x4FlX.js"),{subElementClassPrefix:x}=m.getBEMClassNames("panel"),t=`${x}header`,o=({children:a,className:n,...r})=>{const{dismissible:i,closeButtonAriaLabel:c,onOpenChange:e}=b.usePanelContext(),u=d(l.styles[`${t}__row`],n);return s.jsxs("div",{className:u,...r,children:[a,i&&s.jsx("div",{className:l.styles[`${t}__close-button`],children:s.jsx(_.CloseButton,{"aria-label":c,onClick:()=>e==null?void 0:e(!1),size:"lg"})})]})};o.displayName="Panel.Header.Row";exports.Row=o;
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 n, jsx as e } from "react/jsx-runtime";
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 f } from "../../CloseButton/CloseButton.es.js";
6
- import { usePanelContext as b } from "./Panel.context.es.js";
7
- import { s as o } from "../../../chunks/panel.module.BVm3KvDs.js";
8
- const { subElementClassPrefix: u } = d("panel"), a = `${u}header`, x = ({
9
- children: l,
10
- className: t,
11
- ...r
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: i, closeButtonAriaLabel: m, onOpenChange: s } = b(), c = p(o[`${a}__row`], t);
14
- return /* @__PURE__ */ n("div", { className: c, ...r, children: [
15
- l,
16
- i && /* @__PURE__ */ e("div", { className: o[`${a}__close-button`], children: /* @__PURE__ */ e(
17
- f,
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": m,
20
- onClick: () => s == null ? void 0 : s(!1),
19
+ "aria-label": i,
20
+ onClick: () => m("closeButton"),
21
21
  size: "lg"
22
22
  }
23
23
  ) })
24
24
  ] });
25
25
  };
26
- x.displayName = "Panel.Header.Row";
26
+ b.displayName = "Panel.Header.Row";
27
27
  export {
28
- x as Row
28
+ b as Row
29
29
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("@floating-ui/react"),I=require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");const b=require("./Panel.context.cjs.js"),q=require("../../FloatingUI/FloatingUI.root.cjs.js"),v=require("../../../chunks/FloatingUI.context.Du9g2lSg.js"),f=require("../../Divider/Divider.cjs.js"),C=require("../../../chunks/panel.module.BX1x4FlX.js"),{baseClassNamePrefix:F}=I.getBEMClassNames("panel"),a=({position:n,className:i})=>e.jsx(f.Divider,{borderColor:"01",orientation:n==="bottom"?"horizontal":"vertical",className:i}),U=({children:n,panelClassName:i,inlineWrapperClassName:o,resolvedPosition:t,dividerBefore:r,dividerInner:l,dividerAfter:c,alwaysVisible:s,...u})=>{const{context:d,transitionConfig:x,refs:g}=v.useBmFloatingUIContext(),{isMounted:j,status:_}=p.useTransitionStatus(d,x),m=s&&_==="initial"?"open":_;return j?e.jsxs(e.Fragment,{children:[r&&e.jsx(a,{position:t}),e.jsx("div",{ref:g.setFloating,className:o,"data-position":t,"data-status":m,children:e.jsxs("div",{className:C.styles[`${F}__inline-wrapper-content`],children:[l&&e.jsx(a,{position:t}),e.jsx("aside",{...u,className:i,children:n})]})}),c&&e.jsx(a,{position:t})]}):null},h=({contextValue:n,panelClassName:i,inlineWrapperClassName:o,resolvedPosition:t,dividerBefore:r,dividerInner:l,dividerAfter:c,open:s,transitionConfig:u,children:d,...x})=>e.jsx(b.PanelContext.Provider,{value:n,children:e.jsx(q.FloatingUIRoot,{open:s??!0,portalled:!1,transitionConfig:u,children:e.jsx(U,{panelClassName:i,inlineWrapperClassName:o,resolvedPosition:t,dividerBefore:r,dividerInner:l,dividerAfter:c,alwaysVisible:s===void 0,...x,children:d})})});exports.InlineDivider=a;exports.InlinePanel=h;
@@ -0,0 +1,21 @@
1
+ import { UseTransitionStylesProps } from '@floating-ui/react';
2
+ import { PanelPosition } from './Panel.types';
3
+ import { PanelContextValue } from './Panel.context';
4
+ export declare const InlineDivider: ({ position, className, }: {
5
+ position?: PanelPosition;
6
+ className?: string;
7
+ }) => import("react/jsx-runtime").JSX.Element;
8
+ type InlinePanelProps = {
9
+ contextValue: PanelContextValue;
10
+ panelClassName: string;
11
+ inlineWrapperClassName: string;
12
+ resolvedPosition: PanelPosition;
13
+ dividerBefore: boolean;
14
+ dividerInner: boolean;
15
+ dividerAfter: boolean;
16
+ open?: boolean;
17
+ transitionConfig: UseTransitionStylesProps;
18
+ children: React.ReactNode;
19
+ } & React.ComponentPropsWithoutRef<'aside'>;
20
+ export declare const InlinePanel: ({ contextValue, panelClassName, inlineWrapperClassName, resolvedPosition, dividerBefore, dividerInner, dividerAfter, open, transitionConfig, children, ...props }: InlinePanelProps) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1,93 @@
1
+ import { jsx as t, jsxs as u, Fragment as h } from "react/jsx-runtime";
2
+ import { useTransitionStatus as I } from "@floating-ui/react";
3
+ import { g as v } from "../../../chunks/classNames.BTJmrO_L.js";
4
+ import "../../../chunks/constants.CKKGf1-i.js";
5
+ import { PanelContext as N } from "./Panel.context.es.js";
6
+ import { FloatingUIRoot as b } from "../../FloatingUI/FloatingUI.root.es.js";
7
+ import { a as F } from "../../../chunks/FloatingUI.context.DtJA57si.js";
8
+ import { Divider as w } from "../../Divider/Divider.es.js";
9
+ import { s as U } from "../../../chunks/panel.module.BVm3KvDs.js";
10
+ const { baseClassNamePrefix: j } = v("panel"), f = ({
11
+ position: n,
12
+ className: i
13
+ }) => /* @__PURE__ */ t(
14
+ w,
15
+ {
16
+ borderColor: "01",
17
+ orientation: n === "bottom" ? "horizontal" : "vertical",
18
+ className: i
19
+ }
20
+ ), y = ({
21
+ children: n,
22
+ panelClassName: i,
23
+ inlineWrapperClassName: e,
24
+ resolvedPosition: o,
25
+ dividerBefore: r,
26
+ dividerInner: s,
27
+ dividerAfter: l,
28
+ alwaysVisible: a,
29
+ ...m
30
+ }) => {
31
+ const {
32
+ context: p,
33
+ transitionConfig: c,
34
+ refs: g
35
+ } = F(), { isMounted: x, status: d } = I(
36
+ p,
37
+ c
38
+ ), C = a && d === "initial" ? "open" : d;
39
+ return x ? /* @__PURE__ */ u(h, { children: [
40
+ r && /* @__PURE__ */ t(f, { position: o }),
41
+ /* @__PURE__ */ t(
42
+ "div",
43
+ {
44
+ ref: g.setFloating,
45
+ className: e,
46
+ "data-position": o,
47
+ "data-status": C,
48
+ children: /* @__PURE__ */ u("div", { className: U[`${j}__inline-wrapper-content`], children: [
49
+ s && /* @__PURE__ */ t(f, { position: o }),
50
+ /* @__PURE__ */ t("aside", { ...m, className: i, children: n })
51
+ ] })
52
+ }
53
+ ),
54
+ l && /* @__PURE__ */ t(f, { position: o })
55
+ ] }) : null;
56
+ }, T = ({
57
+ contextValue: n,
58
+ panelClassName: i,
59
+ inlineWrapperClassName: e,
60
+ resolvedPosition: o,
61
+ dividerBefore: r,
62
+ dividerInner: s,
63
+ dividerAfter: l,
64
+ open: a,
65
+ transitionConfig: m,
66
+ children: p,
67
+ ...c
68
+ }) => /* @__PURE__ */ t(N.Provider, { value: n, children: /* @__PURE__ */ t(
69
+ b,
70
+ {
71
+ open: a ?? !0,
72
+ portalled: !1,
73
+ transitionConfig: m,
74
+ children: /* @__PURE__ */ t(
75
+ y,
76
+ {
77
+ panelClassName: i,
78
+ inlineWrapperClassName: e,
79
+ resolvedPosition: o,
80
+ dividerBefore: r,
81
+ dividerInner: s,
82
+ dividerAfter: l,
83
+ alwaysVisible: a === void 0,
84
+ ...c,
85
+ children: p
86
+ }
87
+ )
88
+ }
89
+ ) });
90
+ export {
91
+ f as InlineDivider,
92
+ T as InlinePanel
93
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("clsx"),y=require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");const g=require("./Panel.context.cjs.js"),m=require("../../FloatingUI/FloatingUI.root.cjs.js"),p=require("../../FloatingUI/FloatingUI.content.cjs.js"),q=require("./Panel.Inline.cjs.js"),t=require("../../../chunks/panel.module.BX1x4FlX.js"),{baseClassNamePrefix:n}=y.getBEMClassNames("panel"),x=({contextValue:r,panelClassName:i,resolvedPosition:l,showDivider:a,open:s,onOpenChange:o,transitionConfig:c,children:u,..._})=>{const d=v(t.styles[`${n}__overlay-divider`],t.styles[`${n}__overlay-divider--${l}`]);return e.jsx(g.PanelContext.Provider,{value:r,children:e.jsx(m.FloatingUIRoot,{open:s,onOpenChange:o,portalled:!0,transitionConfig:c,children:e.jsxs(p.Content,{className:i,skipFloatingStyles:!0,overlay:!0,..._,"data-position":l,children:[u,a&&e.jsx(q.InlineDivider,{position:l,className:d})]})})})};exports.OverlayPanel=x;
@@ -0,0 +1,16 @@
1
+ import { UseTransitionStylesProps } from '@floating-ui/react';
2
+ import { PanelPosition } from './Panel.types';
3
+ import { PanelContextValue } from './Panel.context';
4
+ import { FloatingUIProps } from '../../FloatingUI/FloatingUI.context';
5
+ type OverlayPanelProps = {
6
+ contextValue: PanelContextValue;
7
+ panelClassName: string;
8
+ resolvedPosition: PanelPosition;
9
+ showDivider: boolean;
10
+ open?: boolean;
11
+ onOpenChange?: FloatingUIProps['onOpenChange'];
12
+ transitionConfig: UseTransitionStylesProps;
13
+ children: React.ReactNode;
14
+ } & React.ComponentPropsWithoutRef<'aside'>;
15
+ export declare const OverlayPanel: ({ contextValue, panelClassName, resolvedPosition, showDivider, open, onOpenChange, transitionConfig, children, ...props }: OverlayPanelProps) => import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,51 @@
1
+ import { jsx as e, jsxs as f } from "react/jsx-runtime";
2
+ import v from "clsx";
3
+ import { g as y } from "../../../chunks/classNames.BTJmrO_L.js";
4
+ import "../../../chunks/constants.CKKGf1-i.js";
5
+ import { PanelContext as x } from "./Panel.context.es.js";
6
+ import { FloatingUIRoot as u } from "../../FloatingUI/FloatingUI.root.es.js";
7
+ import { Content as C } from "../../FloatingUI/FloatingUI.content.es.js";
8
+ import { InlineDivider as N } from "./Panel.Inline.es.js";
9
+ import { s as o } from "../../../chunks/panel.module.BVm3KvDs.js";
10
+ const { baseClassNamePrefix: t } = y("panel"), b = ({
11
+ contextValue: a,
12
+ panelClassName: i,
13
+ resolvedPosition: r,
14
+ showDivider: s,
15
+ open: l,
16
+ onOpenChange: m,
17
+ transitionConfig: n,
18
+ children: p,
19
+ ...d
20
+ }) => {
21
+ const c = v(
22
+ o[`${t}__overlay-divider`],
23
+ o[`${t}__overlay-divider--${r}`]
24
+ );
25
+ return /* @__PURE__ */ e(x.Provider, { value: a, children: /* @__PURE__ */ e(
26
+ u,
27
+ {
28
+ open: l,
29
+ onOpenChange: m,
30
+ portalled: !0,
31
+ transitionConfig: n,
32
+ children: /* @__PURE__ */ f(
33
+ C,
34
+ {
35
+ className: i,
36
+ skipFloatingStyles: !0,
37
+ overlay: !0,
38
+ ...d,
39
+ "data-position": r,
40
+ children: [
41
+ p,
42
+ s && /* @__PURE__ */ e(N, { position: r, className: c })
43
+ ]
44
+ }
45
+ )
46
+ }
47
+ ) });
48
+ };
49
+ export {
50
+ b as OverlayPanel
51
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("clsx"),S=require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");const $=require("./Panel.context.cjs.js"),R=require("./Panel.Header.cjs.js"),U=require("./Panel.Body.cjs.js"),B=require("./Panel.Footer.cjs.js"),r=require("./Panel.helpers.cjs.js"),T=require("../../FloatingUI/FloatingUI.root.cjs.js"),A=require("../../FloatingUI/FloatingUI.content.cjs.js"),H=require("../../Divider/Divider.cjs.js"),s=require("../../../chunks/panel.module.BX1x4FlX.js"),{baseClassNamePrefix:t}=S.getBEMClassNames("panel"),a=({position:l,className:d})=>e.jsx(H.Divider,{borderColor:"01",orientation:l==="bottom"?"horizontal":"vertical",className:d}),n=({children:l,className:d,padding:q="md",onOpenChange:v,open:p,size:c,dismissible:g=!0,closeButtonAriaLabel:I="Close panel",kind:o="inline",position:P,divider:f=!0,isAnimated:y=!0,...x})=>{const i=r.getResolvedPanelPosition(P),m=u(s.styles[t],s.styles[`${t}--${o}`],c&&s.styles[`${t}--size-${c}`],s.styles[`${t}--padding-${q}`],s.styles[`${t}--position-${i}`],d),w=u(s.styles[`${t}__inline-wrapper`],c==="full"&&s.styles[`${t}__inline-wrapper--full`]),b={dismissible:g,closeButtonAriaLabel:I,onOpenChange:v,position:P},{inlineStatus:C,isInlineVisible:N}=r.useInlineTransition(o==="inline"?p:void 0,y),{showDivider:j,dividerBefore:D,dividerAfter:F}=r.getPanelDividerState(f,i),h=o==="overlay"?u(s.styles[`${t}__overlay-divider`],s.styles[`${t}__overlay-divider--${i}`]):void 0,_=j&&N;return o==="inline"?N?e.jsxs($.PanelContext.Provider,{value:b,children:[D&&_&&e.jsx(a,{position:i}),e.jsx("div",{className:w,"data-position":i,"data-status":C,children:e.jsxs("div",{className:s.styles[`${t}__inline-wrapper-content`],children:[i==="bottom"&&_&&e.jsx(a,{position:i}),e.jsx("aside",{className:m,...x,children:l})]})}),F&&_&&e.jsx(a,{position:i})]}):null:e.jsx($.PanelContext.Provider,{value:b,children:e.jsx(T.FloatingUIRoot,{open:p,onOpenChange:v,portalled:!0,transitionConfig:{duration:y?r.PANEL_TRANSITION_DURATION_MS:0},children:e.jsxs(A.Content,{className:m,skipFloatingStyles:!0,overlay:!0,...x,"data-position":i,children:[l,j&&e.jsx(a,{position:i,className:h})]})})})};n.displayName="Panel";n.Header=R.Header;n.Body=U.Body;n.Footer=B.Footer;exports.Panel=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react/jsx-runtime"),v=require("clsx"),C=require("react"),h=require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");const j=require("./Panel.Header.cjs.js"),B=require("./Panel.Body.cjs.js"),T=require("./Panel.Footer.cjs.js"),a=require("./Panel.helpers.cjs.js"),D=require("./Panel.Inline.cjs.js"),F=require("./Panel.Overlay.cjs.js"),e=require("../../../chunks/panel.module.BX1x4FlX.js"),{baseClassNamePrefix:n}=h.getBEMClassNames("panel"),l=({children:i,className:$,padding:g="md",onOpenChange:w,open:o,size:r,dismissible:_=!0,closeButtonAriaLabel:u="Close panel",kind:c="inline",position:t,divider:f=!0,isAnimated:P=!0,onBeforeClose:O,...d})=>{const s=a.getResolvedPanelPosition(t),p=v(e.styles[n],e.styles[`${n}--${c}`],r&&e.styles[`${n}--size-${r}`],e.styles[`${n}--padding-${g}`],e.styles[`${n}--position-${s}`],$),b=v(e.styles[`${n}__inline-wrapper`],r==="full"&&e.styles[`${n}__inline-wrapper--full`]),{requestClose:y,handleOverlayOpenChange:x}=a.usePanelClose(O,w),m=C.useMemo(()=>({dismissible:_,closeButtonAriaLabel:u,position:t,requestClose:y}),[_,u,t,y]),{showDivider:I,dividerBefore:M,dividerInner:R,dividerAfter:S}=a.getPanelDividerState(f,s),q=C.useMemo(()=>({duration:P?a.PANEL_TRANSITION_DURATION_MS:0}),[P]);return c==="inline"?N.jsx(D.InlinePanel,{contextValue:m,panelClassName:p,inlineWrapperClassName:b,resolvedPosition:s,dividerBefore:M,dividerInner:R,dividerAfter:S,open:o,transitionConfig:q,...d,children:i}):N.jsx(F.OverlayPanel,{contextValue:m,panelClassName:p,resolvedPosition:s,showDivider:I,open:o,onOpenChange:x,transitionConfig:q,...d,children:i})};l.displayName="Panel";l.Header=j.Header;l.Body=B.Body;l.Footer=T.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;
@@ -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;
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,117 +1,85 @@
1
- import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
- import v from "clsx";
3
- import { g as F } from "../../../chunks/classNames.BTJmrO_L.js";
1
+ import { jsx as P } from "react/jsx-runtime";
2
+ import $ from "clsx";
3
+ import { useMemo as v } from "react";
4
+ import { g as R } from "../../../chunks/classNames.BTJmrO_L.js";
4
5
  import "../../../chunks/constants.CKKGf1-i.js";
5
- import { PanelContext as I } from "./Panel.context.es.js";
6
- import { Header as T } from "./Panel.Header.es.js";
7
- import { Body as A } from "./Panel.Body.es.js";
8
- import { Footer as j } from "./Panel.Footer.es.js";
9
- import { useInlineTransition as E, getPanelDividerState as H, PANEL_TRANSITION_DURATION_MS as M, getResolvedPanelPosition as U } from "./Panel.helpers.es.js";
10
- import { FloatingUIRoot as V } from "../../FloatingUI/FloatingUI.root.es.js";
11
- import { Content as L } from "../../FloatingUI/FloatingUI.content.es.js";
12
- import { Divider as O } from "../../Divider/Divider.es.js";
13
- import { s as i } from "../../../chunks/panel.module.BVm3KvDs.js";
14
- const { baseClassNamePrefix: o } = F("panel"), l = ({
6
+ import { Header as S } from "./Panel.Header.es.js";
7
+ import { Body as T } from "./Panel.Body.es.js";
8
+ import { Footer as A } from "./Panel.Footer.es.js";
9
+ import { usePanelClose as E, getPanelDividerState as F, PANEL_TRANSITION_DURATION_MS as H, getResolvedPanelPosition as j } from "./Panel.helpers.es.js";
10
+ import { InlinePanel as q } from "./Panel.Inline.es.js";
11
+ import { OverlayPanel as U } from "./Panel.Overlay.es.js";
12
+ import { s as e } from "../../../chunks/panel.module.BVm3KvDs.js";
13
+ const { baseClassNamePrefix: r } = R("panel"), n = ({
14
+ children: s,
15
+ className: g,
16
+ padding: _ = "md",
17
+ onOpenChange: y,
18
+ open: l,
19
+ size: a,
20
+ dismissible: i = !0,
21
+ closeButtonAriaLabel: m = "Close panel",
22
+ kind: p = "inline",
15
23
  position: t,
16
- className: a
17
- }) => /* @__PURE__ */ r(
18
- O,
19
- {
20
- borderColor: "01",
21
- orientation: t === "bottom" ? "horizontal" : "vertical",
22
- className: a
23
- }
24
- ), s = ({
25
- children: t,
26
- className: a,
27
- padding: g = "md",
28
- onOpenChange: c,
29
- open: f,
30
- size: d,
31
- dismissible: h = !0,
32
- closeButtonAriaLabel: x = "Close panel",
33
- kind: n = "inline",
34
- position: u,
35
- divider: D = !0,
36
- isAnimated: N = !0,
37
- ...$
24
+ divider: O = !0,
25
+ isAnimated: f = !0,
26
+ onBeforeClose: x,
27
+ ...d
38
28
  }) => {
39
- const e = U(u), _ = v(
40
- i[o],
41
- i[`${o}--${n}`],
42
- d && i[`${o}--size-${d}`],
43
- i[`${o}--padding-${g}`],
44
- i[`${o}--position-${e}`],
45
- a
46
- ), b = v(
47
- i[`${o}__inline-wrapper`],
48
- d === "full" && i[`${o}__inline-wrapper--full`]
49
- ), P = {
50
- dismissible: h,
51
- closeButtonAriaLabel: x,
52
- onOpenChange: c,
53
- position: u
54
- }, { inlineStatus: R, isInlineVisible: y } = E(
55
- n === "inline" ? f : void 0,
56
- N
57
- ), { showDivider: C, dividerBefore: S, dividerAfter: w } = H(
58
- D,
59
- e
60
- ), B = n === "overlay" ? v(
61
- i[`${o}__overlay-divider`],
62
- i[`${o}__overlay-divider--${e}`]
63
- ) : void 0, m = C && y;
64
- return n === "inline" ? y ? /* @__PURE__ */ p(I.Provider, { value: P, children: [
65
- S && m && /* @__PURE__ */ r(l, { position: e }),
66
- /* @__PURE__ */ r(
67
- "div",
68
- {
69
- className: b,
70
- "data-position": e,
71
- "data-status": R,
72
- children: /* @__PURE__ */ p("div", { className: i[`${o}__inline-wrapper-content`], children: [
73
- e === "bottom" && m && /* @__PURE__ */ r(l, { position: e }),
74
- /* @__PURE__ */ r("aside", { className: _, ...$, children: t })
75
- ] })
76
- }
77
- ),
78
- w && m && /* @__PURE__ */ r(l, { position: e })
79
- ] }) : null : /* @__PURE__ */ r(I.Provider, { value: P, children: /* @__PURE__ */ r(
80
- V,
29
+ const o = j(t), N = $(
30
+ e[r],
31
+ e[`${r}--${p}`],
32
+ a && e[`${r}--size-${a}`],
33
+ e[`${r}--padding-${_}`],
34
+ e[`${r}--position-${o}`],
35
+ g
36
+ ), I = $(
37
+ e[`${r}__inline-wrapper`],
38
+ a === "full" && e[`${r}__inline-wrapper--full`]
39
+ ), { requestClose: c, handleOverlayOpenChange: h } = E(
40
+ x,
41
+ y
42
+ ), u = v(
43
+ () => ({ dismissible: i, closeButtonAriaLabel: m, position: t, requestClose: c }),
44
+ [i, m, t, c]
45
+ ), { showDivider: w, dividerBefore: B, dividerInner: D, dividerAfter: M } = F(O, o), C = v(
46
+ () => ({ duration: f ? H : 0 }),
47
+ [f]
48
+ );
49
+ return p === "inline" ? /* @__PURE__ */ P(
50
+ q,
81
51
  {
82
- open: f,
83
- onOpenChange: c,
84
- portalled: !0,
85
- transitionConfig: {
86
- duration: N ? M : 0
87
- },
88
- children: /* @__PURE__ */ p(
89
- L,
90
- {
91
- className: _,
92
- skipFloatingStyles: !0,
93
- overlay: !0,
94
- ...$,
95
- "data-position": e,
96
- children: [
97
- t,
98
- C && /* @__PURE__ */ r(
99
- l,
100
- {
101
- position: e,
102
- className: B
103
- }
104
- )
105
- ]
106
- }
107
- )
52
+ contextValue: u,
53
+ panelClassName: N,
54
+ inlineWrapperClassName: I,
55
+ resolvedPosition: o,
56
+ dividerBefore: B,
57
+ dividerInner: D,
58
+ dividerAfter: M,
59
+ open: l,
60
+ transitionConfig: C,
61
+ ...d,
62
+ children: s
108
63
  }
109
- ) });
64
+ ) : /* @__PURE__ */ P(
65
+ U,
66
+ {
67
+ contextValue: u,
68
+ panelClassName: N,
69
+ resolvedPosition: o,
70
+ showDivider: w,
71
+ open: l,
72
+ onOpenChange: h,
73
+ transitionConfig: C,
74
+ ...d,
75
+ children: s
76
+ }
77
+ );
110
78
  };
111
- s.displayName = "Panel";
112
- s.Header = T;
113
- s.Body = A;
114
- s.Footer = j;
79
+ n.displayName = "Panel";
80
+ n.Header = S;
81
+ n.Body = T;
82
+ n.Footer = A;
115
83
  export {
116
- s as Panel
84
+ n as Panel
117
85
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),o=400,c=e=>e||"end",d=(e,t)=>{const n=e&&t!=="full";return{showDivider:n,dividerBefore:n&&t!=="start"&&t!=="bottom",dividerAfter:n&&t==="start"}},I=(e,t)=>{const[n,i]=a.useState(void 0),[l,s]=a.useState(e!==!1);return a.useEffect(()=>{if(!t){s(e!==!1),i(void 0);return}if(e!==void 0)if(e){s(!0),i("close");let r;const u=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>i("open"))});return()=>{cancelAnimationFrame(u),cancelAnimationFrame(r)}}else{i("close");const r=setTimeout(()=>{s(!1),i(void 0)},o);return()=>clearTimeout(r)}},[t,e]),{inlineStatus:n,isInlineVisible:l}};exports.PANEL_TRANSITION_DURATION_MS=o;exports.getPanelDividerState=d;exports.getResolvedPanelPosition=c;exports.useInlineTransition=I;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),d=400,P=s=>s||"end",f=(s,t)=>{const r=s&&t!=="full";return{showDivider:r,dividerBefore:r&&t!=="start"&&t!=="bottom",dividerInner:r&&t==="bottom",dividerAfter:r&&t==="start"}},v=s=>s==="escape-key"?"escapeKey":s==="outside-press"?"outsidePress":"programmatic",N=(s,t)=>{const r=c.useCallback(l=>{if(!s){t==null||t(!1);return}const e=s(l);e instanceof Promise?e.then(i=>{i&&(t==null||t(!1))}).catch(()=>{}):e&&(t==null||t(!1))},[s,t]),u=c.useCallback((l,e,i)=>{l?t==null||t(!0):r(v(i))},[t,r]);return{requestClose:r,handleOverlayOpenChange:u}};exports.PANEL_TRANSITION_DURATION_MS=d;exports.getPanelDividerState=f;exports.getResolvedPanelPosition=P;exports.usePanelClose=N;
@@ -1,13 +1,14 @@
1
- import { PanelPosition } from './Panel.types';
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
- export type PanelInlineStatus = 'open' | 'close' | undefined;
4
4
  export declare const getResolvedPanelPosition: (position?: PanelPosition) => PanelPosition;
5
5
  export declare const getPanelDividerState: (divider: boolean, position?: PanelPosition) => {
6
6
  showDivider: boolean;
7
7
  dividerBefore: boolean;
8
+ dividerInner: boolean;
8
9
  dividerAfter: boolean;
9
10
  };
10
- export declare const useInlineTransition: (open: boolean | undefined, isAnimated: boolean) => {
11
- inlineStatus: PanelInlineStatus;
12
- isInlineVisible: boolean;
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;
13
14
  };
@@ -1,40 +1,39 @@
1
- import { useState as o, useEffect as u } from "react";
2
- const c = 400, m = (e) => e || "end", f = (e, t) => {
3
- const n = e && t !== "full";
1
+ import { useCallback as u } from "react";
2
+ const v = 400, m = (r) => r || "end", P = (r, t) => {
3
+ const s = r && t !== "full";
4
4
  return {
5
- showDivider: n,
6
- dividerBefore: n && t !== "start" && t !== "bottom",
7
- dividerAfter: n && t === "start"
5
+ showDivider: s,
6
+ dividerBefore: s && t !== "start" && t !== "bottom",
7
+ // For 'bottom' panels the divider must sit inside the scrollable wrapper (above the content),
8
+ // not outside it — so it is rendered via dividerInner rather than dividerBefore.
9
+ dividerInner: s && t === "bottom",
10
+ dividerAfter: s && t === "start"
8
11
  };
9
- }, I = (e, t) => {
10
- const [n, i] = o(void 0), [a, s] = o(e !== !1);
11
- return u(() => {
12
- if (!t) {
13
- s(e !== !1), i(void 0);
14
- return;
15
- }
16
- if (e !== void 0)
17
- if (e) {
18
- s(!0), i("close");
19
- let r;
20
- const l = requestAnimationFrame(() => {
21
- r = requestAnimationFrame(() => i("open"));
22
- });
23
- return () => {
24
- cancelAnimationFrame(l), cancelAnimationFrame(r);
25
- };
26
- } else {
27
- i("close");
28
- const r = setTimeout(() => {
29
- s(!1), i(void 0);
30
- }, c);
31
- return () => clearTimeout(r);
12
+ }, e = (r) => r === "escape-key" ? "escapeKey" : r === "outside-press" ? "outsidePress" : "programmatic", A = (r, t) => {
13
+ const s = u(
14
+ (i) => {
15
+ if (!r) {
16
+ t == null || t(!1);
17
+ return;
32
18
  }
33
- }, [t, e]), { inlineStatus: n, isInlineVisible: a };
19
+ const c = r(i);
20
+ c instanceof Promise ? c.then((l) => {
21
+ l && (t == null || t(!1));
22
+ }).catch(() => {
23
+ }) : c && (t == null || t(!1));
24
+ },
25
+ [r, t]
26
+ ), d = u(
27
+ (i, c, l) => {
28
+ i ? t == null || t(!0) : s(e(l));
29
+ },
30
+ [t, s]
31
+ );
32
+ return { requestClose: s, handleOverlayOpenChange: d };
34
33
  };
35
34
  export {
36
- c as PANEL_TRANSITION_DURATION_MS,
37
- f as getPanelDividerState,
35
+ v as PANEL_TRANSITION_DURATION_MS,
36
+ P as getPanelDividerState,
38
37
  m as getResolvedPanelPosition,
39
- I as useInlineTransition
38
+ A as usePanelClose
40
39
  };
@@ -4,13 +4,23 @@ 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
10
19
  */
11
20
  children: React.ReactNode;
12
21
  /**
13
- * Specify if the Panel is open (controlled)
22
+ * Controls the Panel's visibility. For inline panels, omitting this prop
23
+ * renders the panel as always-visible (uncontrolled).
14
24
  */
15
25
  open?: boolean;
16
26
  /**
@@ -54,6 +64,31 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
54
64
  * @default 'end'
55
65
  */
56
66
  position?: PanelPosition;
67
+ /**
68
+ * Called before the Panel closes due to a user interaction. Return `false` (or
69
+ * `Promise<false>`) to cancel the close — for example, when the panel contains
70
+ * a form with unsaved changes.
71
+ *
72
+ * This callback is **not** invoked when the `open` prop is changed programmatically
73
+ * by the parent; it only fires for UI-triggered close events (close button, Escape
74
+ * key, or outside press).
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * // Use a stateful confirmation dialog — avoid window.confirm (blocking, breaks iframes).
79
+ * // See the `onBeforeClose (Unsaved Changes Guard)` story for a full reference implementation.
80
+ * <Panel
81
+ * onBeforeClose={(reason) => {
82
+ * if (!isDirty) return true;
83
+ * return new Promise(resolve => {
84
+ * setResolveClose(() => resolve);
85
+ * setShowConfirmDialog(true);
86
+ * });
87
+ * }}
88
+ * />
89
+ * ```
90
+ */
91
+ onBeforeClose?: (reason: PanelCloseReason) => boolean | Promise<boolean>;
57
92
  }
58
93
  export interface InlinePanelProps extends BasePanelProps {
59
94
  /**
@@ -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.10.2",
3
+ "version": "2.12.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.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",
62
+ "@viasat/beam-fonts": "2.12.0",
63
+ "@viasat/beam-shared": "2.12.0",
64
+ "@viasat/beam-styles": "2.12.0",
65
+ "@viasat/beam-tokens": "2.12.0",
66
+ "@viasat/beam-icons": "2.12.0",
67
67
  "clsx": "^1.2.1",
68
68
  "@floating-ui/react": "^0.26.18",
69
69
  "@stepperize/react": "^5.1.5",