@manakind/ui-core 0.26.1 → 0.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/README.md CHANGED
@@ -97,6 +97,7 @@ separately, so an app can load only what it renders.
97
97
  | `@manakind/ui-core/css/slider` | Slider structural CSS |
98
98
  | `@manakind/ui-core/section` | `Section` |
99
99
  | `@manakind/ui-core/split-layout` | `SplitLayout`, `SplitMain`, `SplitAside` |
100
+ | `@manakind/ui-core/side-panel-layout` | `SidePanelLayout`, the drawer a `Dialog` with `presentation="side"` opens in |
100
101
  | `@manakind/ui-core/form-layout` | `FormLayout`, `FormActions` |
101
102
  | `@manakind/ui-core/wizard-layout` | `WizardLayout`, `WizardHeader`, `WizardContent`, `WizardFooter` |
102
103
  | `@manakind/ui-core/centered-layout` | `CenteredLayout` |
@@ -137,6 +138,7 @@ separately, so an app can load only what it renders.
137
138
  | `@manakind/ui-core/css/page-layout` | PageLayout structural CSS; its title and description also need `css/text` |
138
139
  | `@manakind/ui-core/css/section` | Section structural CSS; its title and description also need `css/text` |
139
140
  | `@manakind/ui-core/css/split-layout` | SplitLayout structural CSS |
141
+ | `@manakind/ui-core/css/side-panel-layout` | SidePanelLayout structural CSS |
140
142
  | `@manakind/ui-core/css/form-layout` | FormLayout structural CSS |
141
143
  | `@manakind/ui-core/css/wizard-layout` | WizardLayout structural CSS; its header also needs `css/progress` and `css/text` |
142
144
  | `@manakind/ui-core/css/centered-layout` | CenteredLayout structural CSS |
@@ -53,6 +53,20 @@
53
53
  max-inline-size: var(--ds-dialog-max-inline-size-lg);
54
54
  }
55
55
 
56
+ /*
57
+ * In a SidePanelLayout's slot, which sizes it: a band above the content,
58
+ * or from `lg` a drawer as tall as the viewport below the header. The
59
+ * body scrolls past that height. It sits in the page rather than over it,
60
+ * so it draws no shadow, and its scroll margin keeps it clear of the
61
+ * app's sticky header when it is scrolled into view.
62
+ */
63
+ &.ds-dialog--side {
64
+ max-inline-size: none;
65
+ min-block-size: 0;
66
+ box-shadow: none;
67
+ scroll-margin-block-start: var(--ds-sticky-offset-top);
68
+ }
69
+
56
70
  padding: var(--ds-dialog-padding);
57
71
  border: 1px solid var(--ds-dialog-border);
58
72
  border-radius: var(--ds-dialog-radius);
@@ -102,7 +116,7 @@
102
116
 
103
117
  /*
104
118
  * Only the body scrolls. `min-block-size: 0` lets it shrink below its
105
- * content inside the column, which is what keeps the title and the
119
+ * content inside a side panel, which is what keeps the title and the
106
120
  * actions in view when the content is taller than the viewport.
107
121
  *
108
122
  * A scroll container clips whatever is drawn past its padding, and a
@@ -4,6 +4,8 @@ import './dialog.css';
4
4
  export type DialogRole = 'dialog' | 'alertdialog';
5
5
  /** How wide the panel may grow: a message or short form, or a form with fields side by side. */
6
6
  export type DialogSize = 'md' | 'lg';
7
+ /** Over the page with the rest of it shut off, or in a drawer beside it. */
8
+ export type DialogPresentation = 'modal' | 'side';
7
9
  export interface DialogProps {
8
10
  /**
9
11
  * The dialog's name: rendered as its `<h2>` heading and announced when it
@@ -82,6 +84,23 @@ export interface DialogProps {
82
84
  * form, `lg` for a form with fields side by side.
83
85
  */
84
86
  size?: DialogSize;
87
+ /**
88
+ * `modal` (the default) floats the panel over a dimmed page. `side` opens
89
+ * it in the drawer of the nearest `SidePanelLayout`, beside the content,
90
+ * which stays in view and usable: a form for one item of a list the user
91
+ * may want to browse while filling it in. A side panel traps no focus,
92
+ * locks no scroll and stays open on a click outside. Escape closes it
93
+ * while focus is in it or on no control, and leaves an Escape pressed on a
94
+ * control in the page to that control. On close, focus returns as from a
95
+ * modal unless the user had moved it onto the page. It is as wide as a `md` dialog, so `size`
96
+ * does not apply. Opening another side dialog in the layout closes this
97
+ * one through `onOpenChange`; a controlled dialog should honour it.
98
+ *
99
+ * Outside a `SidePanelLayout`, for `role="alertdialog"`, which must hold
100
+ * the user until they answer, and inside another dialog, the dialog opens
101
+ * as a modal.
102
+ */
103
+ presentation?: DialogPresentation;
85
104
  /** Extra class names appended to the panel's `ds-dialog`. */
86
105
  className?: string;
87
106
  }
@@ -120,5 +139,5 @@ export interface DialogProps {
120
139
  * dialog portals into its panel (see `PortalContainerContext`) and opens at
121
140
  * 60, above it. Nothing is mounted while the dialog is closed.
122
141
  */
123
- export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, finalFocusRef, closeLabel, closeIcon, size, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
142
+ export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, finalFocusRef, closeLabel, closeIcon, size, presentation, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
124
143
  //# sourceMappingURL=dialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,cAAc,CAAC;AAItB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;AAElD,gGAAgG;AAChG,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,uDAAuD;IACvD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EA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
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Dialog as ArkDialog } from '@ark-ui/react/dialog';
2
+ import { Dialog as ArkDialog, useDialogContext } from '@ark-ui/react/dialog';
3
3
  import { Portal } from '@ark-ui/react/portal';
4
- import { useCallback, useRef, useState, } from 'react';
4
+ import { useCallback, useContext, useLayoutEffect, useRef, useState, } from 'react';
5
+ import { createPortal } from 'react-dom';
5
6
  import { IconButton } from '../button/icon-button';
6
7
  import { PortalContainerContext } from '../portal-container';
8
+ import { SidePanelSlotContext } from '../side-panel-layout/side-panel-context';
7
9
  import './dialog.css';
8
10
  import { cx } from '../cx';
9
11
  import { Cross } from '../fallback-glyphs';
@@ -42,16 +44,82 @@ import { Cross } from '../fallback-glyphs';
42
44
  * dialog portals into its panel (see `PortalContainerContext`) and opens at
43
45
  * 60, above it. Nothing is mounted while the dialog is closed.
44
46
  */
45
- export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, finalFocusRef, closeLabel = 'Close', closeIcon = Cross, size = 'md', className, }) {
47
+ export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, finalFocusRef, closeLabel = 'Close', closeIcon = Cross, size = 'md', presentation = 'modal', className, }) {
46
48
  const dismissible = role === 'dialog';
49
+ const slot = useContext(SidePanelSlotContext);
50
+ const side = presentation === 'side' && dismissible && slot ? slot : undefined;
47
51
  const panelRef = useRef(null);
52
+ const triggerRef = useRef(null);
53
+ const [sidePanel, setSidePanel] = useState(null);
54
+ const sidePanelRef = useCallback((element) => {
55
+ panelRef.current = element;
56
+ setSidePanel(element);
57
+ }, []);
48
58
  const handleOpenChange = (details) => onOpenChange?.(details.open);
49
59
  // Zag types this as returning `HTMLElement | null`, but its focus trap
50
60
  // reads undefined as "the first focusable element" and, given null, fails
51
61
  // to start at all, leaving the page reachable by Tab.
52
62
  const initialFocusEl = (() => initialFocusRef?.current ?? undefined);
53
63
  const finalFocusEl = () => finalFocusRef?.current ?? null;
54
- return (_jsxs(ArkDialog.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: handleOpenChange, role: role, closeOnInteractOutside: dismissible, initialFocusEl: initialFocusEl, finalFocusEl: finalFocusEl, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(ArkDialog.Trigger, { asChild: true, children: trigger }), _jsxs(Portal, { children: [_jsx(ArkDialog.Backdrop, { className: "ds-dialog__backdrop" }), _jsx(ArkDialog.Positioner, { className: "ds-dialog__positioner", children: _jsx(ArkDialog.Content, { ref: panelRef, className: cx('ds-dialog', size === 'lg' && 'ds-dialog--lg', className), children: _jsxs(PortalContainerContext.Provider, { value: panelRef, children: [_jsxs("div", { className: "ds-dialog__header", children: [_jsxs("div", { className: "ds-dialog__heading", children: [_jsx(ArkDialog.Title, { className: "ds-dialog__title", children: title }), description && (_jsx(ArkDialog.Description, { className: "ds-dialog__description", children: description }))] }), dismissible && (_jsx(ArkDialog.CloseTrigger, { asChild: true, children: _jsx(IconButton, { icon: closeIcon, "aria-label": closeLabel, variant: "tertiary", size: "sm", className: "ds-dialog__close" }) }))] }), children && _jsx(DialogBody, { children: children }), actions && _jsx("div", { className: "ds-dialog__actions", children: actions })] }) }) })] })] }));
64
+ // Zag's dismiss layer takes Escape anywhere in the document. A side panel
65
+ // leaves the page usable, so an Escape meant for a control on the page,
66
+ // such as a ReorderControl dropping its draft, must not close it too.
67
+ const keepEscapeOnThePage = (event) => {
68
+ const target = event.target;
69
+ const onThePage = target instanceof Node &&
70
+ target !== target.ownerDocument?.body &&
71
+ !panelRef.current?.contains(target);
72
+ if (onThePage)
73
+ event.preventDefault();
74
+ };
75
+ const panel = (_jsxs(PortalContainerContext.Provider, { value: panelRef, children: [_jsxs("div", { className: "ds-dialog__header", children: [_jsxs("div", { className: "ds-dialog__heading", children: [_jsx(ArkDialog.Title, { className: "ds-dialog__title", children: title }), description && (_jsx(ArkDialog.Description, { className: "ds-dialog__description", children: description }))] }), dismissible && (_jsx(ArkDialog.CloseTrigger, { asChild: true, children: _jsx(IconButton, { icon: closeIcon, "aria-label": closeLabel, variant: "tertiary", size: "sm", className: "ds-dialog__close" }) }))] }), children && _jsx(DialogBody, { children: children }), actions && _jsx("div", { className: "ds-dialog__actions", children: actions })] }));
76
+ const content = (_jsx(SidePanelSlotContext.Provider, { value: undefined, children: panel }));
77
+ return (_jsxs(ArkDialog.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: handleOpenChange, role: role, modal: !side, closeOnInteractOutside: dismissible && !side, onEscapeKeyDown: side ? keepEscapeOnThePage : undefined, initialFocusEl: initialFocusEl, finalFocusEl: finalFocusEl, lazyMount: true, unmountOnExit: true, children: [trigger && (_jsx(ArkDialog.Trigger, { ref: triggerRef, asChild: true, children: trigger })), side ? (side.container &&
78
+ createPortal(_jsxs(ArkDialog.Content, { ref: sidePanelRef, className: cx('ds-dialog', 'ds-dialog--side', className), children: [_jsx(SidePanelSeat, { claim: side.claim, panel: sidePanel, triggerRef: triggerRef, finalFocusRef: finalFocusRef }), content] }), side.container)) : (_jsxs(Portal, { children: [_jsx(ArkDialog.Backdrop, { className: "ds-dialog__backdrop" }), _jsx(ArkDialog.Positioner, { className: "ds-dialog__positioner", children: _jsx(ArkDialog.Content, { ref: panelRef, className: cx('ds-dialog', size === 'lg' && 'ds-dialog--lg', className), children: content }) })] }))] }));
79
+ }
80
+ /**
81
+ * What a side panel needs that Ark leaves to a modal's focus trap: the slot,
82
+ * taken on open so any other panel closes; the panel scrolled into view,
83
+ * since below the `lg` step it sits above the content in the page's flow;
84
+ * and focus put back on close. Focus moves when it was inside the panel or
85
+ * on nothing, as after a save whose button disabled itself and so dropped
86
+ * focus, so closing the panel never pulls the user out of the list they
87
+ * moved to but never leaves them on the page's body either.
88
+ * It goes where the trap would send it: `finalFocusRef`'s element, else the
89
+ * trigger, else what had focus when the panel opened. The trigger is named
90
+ * outright because Safari does not focus a button on click.
91
+ *
92
+ * The panel arrives as state from its callback ref: a child's layout effect
93
+ * runs before its parent's ref is attached. A layout effect, because its
94
+ * cleanup runs while the panel is still in the document and can still hold
95
+ * focus, and before Ark moves focus into the panel a frame after it opens.
96
+ * It runs once per opening: the callbacks and refs it reads at close are
97
+ * kept current beside it, so a re-render never closes and reopens the seat.
98
+ */
99
+ function SidePanelSeat({ claim, panel, triggerRef, finalFocusRef, }) {
100
+ const dialog = useDialogContext();
101
+ const latest = useRef({ setOpen: dialog.setOpen, finalFocusRef });
102
+ useLayoutEffect(() => {
103
+ latest.current = { setOpen: dialog.setOpen, finalFocusRef };
104
+ });
105
+ useLayoutEffect(() => {
106
+ if (!panel)
107
+ return;
108
+ const opener = panel.ownerDocument.activeElement;
109
+ const release = claim(() => latest.current.setOpen(false));
110
+ panel.scrollIntoView({ block: 'nearest' });
111
+ return () => {
112
+ release();
113
+ const active = panel.ownerDocument.activeElement;
114
+ const movedToThePage = active && active !== panel.ownerDocument.body && !panel.contains(active);
115
+ if (movedToThePage)
116
+ return;
117
+ const target = [latest.current.finalFocusRef?.current, triggerRef.current, opener].find((element) => element instanceof HTMLElement && element.isConnected);
118
+ if (target instanceof HTMLElement)
119
+ target.focus();
120
+ };
121
+ }, [claim, panel, triggerRef]);
122
+ return null;
55
123
  }
56
124
  /**
57
125
  * The scrolling body. While its content overflows it joins the tab order, so
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAIL,WAAW,EACX,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EA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,aAAa,CAAC,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,CAC7D,CAAC;QACF,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,cAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,YACjF,cAAK,SAAS,EAAC,yBAAyB,YAAE,QAAQ,GAAO,GACrD,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Dialog as ArkDialog } from '@ark-ui/react/dialog';\nimport { Portal } from '@ark-ui/react/portal';\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useRef,\n useState,\n} from 'react';\nimport { IconButton } from '../button/icon-button';\nimport type { IconSource } from '../icon/icon';\nimport { PortalContainerContext } from '../portal-container';\nimport './dialog.css';\nimport { cx } from '../cx';\nimport { Cross } from '../fallback-glyphs';\n\nexport type DialogRole = 'dialog' | 'alertdialog';\n\n/** How wide the panel may grow: a message or short form, or a form with fields side by side. */\nexport type DialogSize = 'md' | 'lg';\n\nexport interface DialogProps {\n /**\n * The dialog's name: rendered as its `<h2>` heading and announced when it\n * opens (`aria-labelledby`). Write it as a short statement or question —\n * \"Remove “Site foreman”?\".\n */\n title: ReactNode;\n /**\n * One or two sentences under the title, announced with it\n * (`aria-describedby`). For a confirmation, say what the action does and\n * what it leaves alone.\n */\n description?: ReactNode;\n /** Body content. Scrolls inside the panel when it outgrows the viewport. */\n children?: ReactNode;\n /**\n * The footer's buttons, end-aligned, in reading order: the dismissive one\n * first, the committing one last. They wrap onto a second line on a narrow\n * screen. Wrap a dismissive button in `DialogClose` to make it close.\n */\n actions?: ReactNode;\n /**\n * The one element that opens the dialog, such as a `Button`. Focus returns\n * to it when the dialog closes, unless `finalFocusRef` names another\n * element. Leave it out to open the dialog with `open` from elsewhere.\n */\n trigger?: ReactElement;\n /** Controlled open state. Pair with `onOpenChange`. */\n open?: boolean;\n /** Initial open state when uncontrolled. */\n defaultOpen?: boolean;\n /**\n * Fired with the requested state whenever the dialog asks to open (its\n * trigger) or close (a `DialogClose`, the close button, Escape, or for\n * `role=\"dialog\"` a click outside). A controlled dialog stays as it is\n * until `open` changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * `dialog` (default) shows a close button and closes on Escape and on a\n * click outside. `alertdialog` is for confirmations: no close button, and a\n * click outside does nothing, so the explicit cancel action is the way\n * out. Escape still cancels.\n */\n role?: DialogRole;\n /**\n * Where focus lands when the dialog opens. Defaults to the first focusable\n * element: the close button of a `dialog`, the first action of an\n * `alertdialog` with no focusable body. Point an alertdialog at its least\n * destructive action.\n */\n initialFocusRef?: RefObject<HTMLElement | null>;\n /**\n * Where focus lands when the dialog closes, in place of the trigger. Use it\n * when the confirmed action removes the trigger, such as a row's Remove\n * button: focus would return to an element that is about to unmount and\n * fall to the page body. Point it at something that stays, such as the\n * list's heading, which needs `tabIndex={-1}` to take focus.\n *\n * The ref is read as the dialog closes, however it closes. Fill it in the\n * committing action, so Cancel and Escape still return focus to the\n * trigger, which is still there. While the ref holds no element, focus\n * returns to the trigger as usual.\n */\n finalFocusRef?: RefObject<HTMLElement | null>;\n /** Accessible name of the close button. Translate it with the rest of the UI. */\n closeLabel?: string;\n /**\n * Glyph for the close button. Defaults to a plain built-in cross so\n * `@manakind/ui-core` renders on its own; products pass their own icon set,\n * as they do for Select's indicators.\n */\n closeIcon?: IconSource;\n /**\n * How wide the panel may grow: `md` (the default) for a message or a short\n * form, `lg` for a form with fields side by side.\n */\n size?: DialogSize;\n /** Extra class names appended to the panel's `ds-dialog`. */\n className?: string;\n}\n\n/**\n * A modal dialog: a raised panel over a dimmed page, built on Ark UI.\n *\n * Ark owns the behaviour: the focus trap, focus returning to the trigger\n * (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and\n * description wiring. This wrapper adds the `ds-` classes, the\n * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.\n *\n * ```tsx\n * <Dialog\n * role=\"alertdialog\"\n * title=\"Remove “Site foreman”?\"\n * description=\"2 people and 1 Landfall lose this type; nothing else is deleted.\"\n * trigger={<Button variant=\"secondary\">Remove</Button>}\n * initialFocusRef={cancelRef}\n * actions={\n * <>\n * <DialogClose>\n * <Button ref={cancelRef} variant=\"secondary\">Cancel</Button>\n * </DialogClose>\n * <Button variant=\"danger\" onClick={remove}>Remove</Button>\n * </>\n * }\n * />\n * ```\n *\n * The committing action is the consumer's own button. To close after it\n * runs, control the dialog with `open` and set it false in the handler, or\n * wrap the button in `DialogClose` when closing at once is right.\n *\n * The backdrop and panel portal into `<body>` at `z-index: 50`, the layer\n * the product apps use for their own overlays. A Select or Menu inside the\n * dialog portals into its panel (see `PortalContainerContext`) and opens at\n * 60, above it. Nothing is mounted while the dialog is closed.\n */\nexport function Dialog({\n title,\n description,\n children,\n actions,\n trigger,\n open,\n defaultOpen,\n onOpenChange,\n role = 'dialog',\n initialFocusRef,\n finalFocusRef,\n closeLabel = 'Close',\n closeIcon = Cross,\n size = 'md',\n className,\n}: DialogProps) {\n const dismissible = role === 'dialog';\n const panelRef = useRef<HTMLDivElement>(null);\n const handleOpenChange = (details: { open: boolean }) => onOpenChange?.(details.open);\n // Zag types this as returning `HTMLElement | null`, but its focus trap\n // reads undefined as \"the first focusable element\" and, given null, fails\n // to start at all, leaving the page reachable by Tab.\n const initialFocusEl = (() => initialFocusRef?.current ?? undefined) as () => HTMLElement | null;\n const finalFocusEl = () => finalFocusRef?.current ?? null;\n\n return (\n <ArkDialog.Root\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n role={role}\n closeOnInteractOutside={dismissible}\n initialFocusEl={initialFocusEl}\n finalFocusEl={finalFocusEl}\n lazyMount\n unmountOnExit\n >\n {trigger && <ArkDialog.Trigger asChild>{trigger}</ArkDialog.Trigger>}\n <Portal>\n <ArkDialog.Backdrop className=\"ds-dialog__backdrop\" />\n <ArkDialog.Positioner className=\"ds-dialog__positioner\">\n <ArkDialog.Content\n ref={panelRef}\n className={cx('ds-dialog', size === 'lg' && 'ds-dialog--lg', className)}\n >\n <PortalContainerContext.Provider value={panelRef}>\n <div className=\"ds-dialog__header\">\n <div className=\"ds-dialog__heading\">\n <ArkDialog.Title className=\"ds-dialog__title\">{title}</ArkDialog.Title>\n {description && (\n <ArkDialog.Description className=\"ds-dialog__description\">\n {description}\n </ArkDialog.Description>\n )}\n </div>\n {dismissible && (\n <ArkDialog.CloseTrigger asChild>\n <IconButton\n icon={closeIcon}\n aria-label={closeLabel}\n variant=\"tertiary\"\n size=\"sm\"\n className=\"ds-dialog__close\"\n />\n </ArkDialog.CloseTrigger>\n )}\n </div>\n {children && <DialogBody>{children}</DialogBody>}\n {actions && <div className=\"ds-dialog__actions\">{actions}</div>}\n </PortalContainerContext.Provider>\n </ArkDialog.Content>\n </ArkDialog.Positioner>\n </Portal>\n </ArkDialog.Root>\n );\n}\n\n/**\n * The scrolling body. While its content overflows it joins the tab order, so\n * a keyboard user can focus it and scroll; a body with nothing to scroll\n * stays out of the way.\n *\n * Two boxes are observed because either can change the answer: the outer one\n * resizes with the viewport, the inner one with the content.\n */\nfunction DialogBody({ children }: { children: ReactNode }) {\n const [scrollable, setScrollable] = useState(false);\n const observe = useCallback((scroller: HTMLDivElement | null) => {\n const content = scroller?.firstElementChild;\n if (!scroller || !content) return;\n const observer = new ResizeObserver(() =>\n setScrollable(scroller.scrollHeight > scroller.clientHeight),\n );\n observer.observe(scroller);\n observer.observe(content);\n return () => observer.disconnect();\n }, []);\n\n return (\n <div ref={observe} className=\"ds-dialog__body\" tabIndex={scrollable ? 0 : undefined}>\n <div className=\"ds-dialog__body-content\">{children}</div>\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AAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,cAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,YACjF,cAAK,SAAS,EAAC,yBAAyB,YAAE,QAAQ,GAAO,GACrD,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Dialog as ArkDialog, useDialogContext } from '@ark-ui/react/dialog';\nimport { Portal } from '@ark-ui/react/portal';\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useContext,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { IconButton } from '../button/icon-button';\nimport type { IconSource } from '../icon/icon';\nimport { PortalContainerContext } from '../portal-container';\nimport { type SidePanelSlot, SidePanelSlotContext } from '../side-panel-layout/side-panel-context';\nimport './dialog.css';\nimport { cx } from '../cx';\nimport { Cross } from '../fallback-glyphs';\n\nexport type DialogRole = 'dialog' | 'alertdialog';\n\n/** How wide the panel may grow: a message or short form, or a form with fields side by side. */\nexport type DialogSize = 'md' | 'lg';\n\n/** Over the page with the rest of it shut off, or in a drawer beside it. */\nexport type DialogPresentation = 'modal' | 'side';\n\nexport interface DialogProps {\n /**\n * The dialog's name: rendered as its `<h2>` heading and announced when it\n * opens (`aria-labelledby`). Write it as a short statement or question —\n * \"Remove “Site foreman”?\".\n */\n title: ReactNode;\n /**\n * One or two sentences under the title, announced with it\n * (`aria-describedby`). For a confirmation, say what the action does and\n * what it leaves alone.\n */\n description?: ReactNode;\n /** Body content. Scrolls inside the panel when it outgrows the viewport. */\n children?: ReactNode;\n /**\n * The footer's buttons, end-aligned, in reading order: the dismissive one\n * first, the committing one last. They wrap onto a second line on a narrow\n * screen. Wrap a dismissive button in `DialogClose` to make it close.\n */\n actions?: ReactNode;\n /**\n * The one element that opens the dialog, such as a `Button`. Focus returns\n * to it when the dialog closes, unless `finalFocusRef` names another\n * element. Leave it out to open the dialog with `open` from elsewhere.\n */\n trigger?: ReactElement;\n /** Controlled open state. Pair with `onOpenChange`. */\n open?: boolean;\n /** Initial open state when uncontrolled. */\n defaultOpen?: boolean;\n /**\n * Fired with the requested state whenever the dialog asks to open (its\n * trigger) or close (a `DialogClose`, the close button, Escape, or for\n * `role=\"dialog\"` a click outside). A controlled dialog stays as it is\n * until `open` changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * `dialog` (default) shows a close button and closes on Escape and on a\n * click outside. `alertdialog` is for confirmations: no close button, and a\n * click outside does nothing, so the explicit cancel action is the way\n * out. Escape still cancels.\n */\n role?: DialogRole;\n /**\n * Where focus lands when the dialog opens. Defaults to the first focusable\n * element: the close button of a `dialog`, the first action of an\n * `alertdialog` with no focusable body. Point an alertdialog at its least\n * destructive action.\n */\n initialFocusRef?: RefObject<HTMLElement | null>;\n /**\n * Where focus lands when the dialog closes, in place of the trigger. Use it\n * when the confirmed action removes the trigger, such as a row's Remove\n * button: focus would return to an element that is about to unmount and\n * fall to the page body. Point it at something that stays, such as the\n * list's heading, which needs `tabIndex={-1}` to take focus.\n *\n * The ref is read as the dialog closes, however it closes. Fill it in the\n * committing action, so Cancel and Escape still return focus to the\n * trigger, which is still there. While the ref holds no element, focus\n * returns to the trigger as usual.\n */\n finalFocusRef?: RefObject<HTMLElement | null>;\n /** Accessible name of the close button. Translate it with the rest of the UI. */\n closeLabel?: string;\n /**\n * Glyph for the close button. Defaults to a plain built-in cross so\n * `@manakind/ui-core` renders on its own; products pass their own icon set,\n * as they do for Select's indicators.\n */\n closeIcon?: IconSource;\n /**\n * How wide the panel may grow: `md` (the default) for a message or a short\n * form, `lg` for a form with fields side by side.\n */\n size?: DialogSize;\n /**\n * `modal` (the default) floats the panel over a dimmed page. `side` opens\n * it in the drawer of the nearest `SidePanelLayout`, beside the content,\n * which stays in view and usable: a form for one item of a list the user\n * may want to browse while filling it in. A side panel traps no focus,\n * locks no scroll and stays open on a click outside. Escape closes it\n * while focus is in it or on no control, and leaves an Escape pressed on a\n * control in the page to that control. On close, focus returns as from a\n * modal unless the user had moved it onto the page. It is as wide as a `md` dialog, so `size`\n * does not apply. Opening another side dialog in the layout closes this\n * one through `onOpenChange`; a controlled dialog should honour it.\n *\n * Outside a `SidePanelLayout`, for `role=\"alertdialog\"`, which must hold\n * the user until they answer, and inside another dialog, the dialog opens\n * as a modal.\n */\n presentation?: DialogPresentation;\n /** Extra class names appended to the panel's `ds-dialog`. */\n className?: string;\n}\n\n/**\n * A modal dialog: a raised panel over a dimmed page, built on Ark UI.\n *\n * Ark owns the behaviour: the focus trap, focus returning to the trigger\n * (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and\n * description wiring. This wrapper adds the `ds-` classes, the\n * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.\n *\n * ```tsx\n * <Dialog\n * role=\"alertdialog\"\n * title=\"Remove “Site foreman”?\"\n * description=\"2 people and 1 Landfall lose this type; nothing else is deleted.\"\n * trigger={<Button variant=\"secondary\">Remove</Button>}\n * initialFocusRef={cancelRef}\n * actions={\n * <>\n * <DialogClose>\n * <Button ref={cancelRef} variant=\"secondary\">Cancel</Button>\n * </DialogClose>\n * <Button variant=\"danger\" onClick={remove}>Remove</Button>\n * </>\n * }\n * />\n * ```\n *\n * The committing action is the consumer's own button. To close after it\n * runs, control the dialog with `open` and set it false in the handler, or\n * wrap the button in `DialogClose` when closing at once is right.\n *\n * The backdrop and panel portal into `<body>` at `z-index: 50`, the layer\n * the product apps use for their own overlays. A Select or Menu inside the\n * dialog portals into its panel (see `PortalContainerContext`) and opens at\n * 60, above it. Nothing is mounted while the dialog is closed.\n */\nexport function Dialog({\n title,\n description,\n children,\n actions,\n trigger,\n open,\n defaultOpen,\n onOpenChange,\n role = 'dialog',\n initialFocusRef,\n finalFocusRef,\n closeLabel = 'Close',\n closeIcon = Cross,\n size = 'md',\n presentation = 'modal',\n className,\n}: DialogProps) {\n const dismissible = role === 'dialog';\n const slot = useContext(SidePanelSlotContext);\n const side = presentation === 'side' && dismissible && slot ? slot : undefined;\n const panelRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [sidePanel, setSidePanel] = useState<HTMLDivElement | null>(null);\n const sidePanelRef = useCallback((element: HTMLDivElement | null) => {\n panelRef.current = element;\n setSidePanel(element);\n }, []);\n const handleOpenChange = (details: { open: boolean }) => onOpenChange?.(details.open);\n // Zag types this as returning `HTMLElement | null`, but its focus trap\n // reads undefined as \"the first focusable element\" and, given null, fails\n // to start at all, leaving the page reachable by Tab.\n const initialFocusEl = (() => initialFocusRef?.current ?? undefined) as () => HTMLElement | null;\n const finalFocusEl = () => finalFocusRef?.current ?? null;\n // Zag's dismiss layer takes Escape anywhere in the document. A side panel\n // leaves the page usable, so an Escape meant for a control on the page,\n // such as a ReorderControl dropping its draft, must not close it too.\n const keepEscapeOnThePage = (event: KeyboardEvent) => {\n const target = event.target;\n const onThePage =\n target instanceof Node &&\n target !== target.ownerDocument?.body &&\n !panelRef.current?.contains(target);\n if (onThePage) event.preventDefault();\n };\n const panel = (\n <PortalContainerContext.Provider value={panelRef}>\n <div className=\"ds-dialog__header\">\n <div className=\"ds-dialog__heading\">\n <ArkDialog.Title className=\"ds-dialog__title\">{title}</ArkDialog.Title>\n {description && (\n <ArkDialog.Description className=\"ds-dialog__description\">\n {description}\n </ArkDialog.Description>\n )}\n </div>\n {dismissible && (\n <ArkDialog.CloseTrigger asChild>\n <IconButton\n icon={closeIcon}\n aria-label={closeLabel}\n variant=\"tertiary\"\n size=\"sm\"\n className=\"ds-dialog__close\"\n />\n </ArkDialog.CloseTrigger>\n )}\n </div>\n {children && <DialogBody>{children}</DialogBody>}\n {actions && <div className=\"ds-dialog__actions\">{actions}</div>}\n </PortalContainerContext.Provider>\n );\n const content = (\n <SidePanelSlotContext.Provider value={undefined}>{panel}</SidePanelSlotContext.Provider>\n );\n\n return (\n <ArkDialog.Root\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n role={role}\n modal={!side}\n closeOnInteractOutside={dismissible && !side}\n onEscapeKeyDown={side ? keepEscapeOnThePage : undefined}\n initialFocusEl={initialFocusEl}\n finalFocusEl={finalFocusEl}\n lazyMount\n unmountOnExit\n >\n {trigger && (\n <ArkDialog.Trigger ref={triggerRef} asChild>\n {trigger}\n </ArkDialog.Trigger>\n )}\n {side ? (\n side.container &&\n createPortal(\n <ArkDialog.Content\n ref={sidePanelRef}\n className={cx('ds-dialog', 'ds-dialog--side', className)}\n >\n <SidePanelSeat\n claim={side.claim}\n panel={sidePanel}\n triggerRef={triggerRef}\n finalFocusRef={finalFocusRef}\n />\n {content}\n </ArkDialog.Content>,\n side.container,\n )\n ) : (\n <Portal>\n <ArkDialog.Backdrop className=\"ds-dialog__backdrop\" />\n <ArkDialog.Positioner className=\"ds-dialog__positioner\">\n <ArkDialog.Content\n ref={panelRef}\n className={cx('ds-dialog', size === 'lg' && 'ds-dialog--lg', className)}\n >\n {content}\n </ArkDialog.Content>\n </ArkDialog.Positioner>\n </Portal>\n )}\n </ArkDialog.Root>\n );\n}\n\n/**\n * What a side panel needs that Ark leaves to a modal's focus trap: the slot,\n * taken on open so any other panel closes; the panel scrolled into view,\n * since below the `lg` step it sits above the content in the page's flow;\n * and focus put back on close. Focus moves when it was inside the panel or\n * on nothing, as after a save whose button disabled itself and so dropped\n * focus, so closing the panel never pulls the user out of the list they\n * moved to but never leaves them on the page's body either.\n * It goes where the trap would send it: `finalFocusRef`'s element, else the\n * trigger, else what had focus when the panel opened. The trigger is named\n * outright because Safari does not focus a button on click.\n *\n * The panel arrives as state from its callback ref: a child's layout effect\n * runs before its parent's ref is attached. A layout effect, because its\n * cleanup runs while the panel is still in the document and can still hold\n * focus, and before Ark moves focus into the panel a frame after it opens.\n * It runs once per opening: the callbacks and refs it reads at close are\n * kept current beside it, so a re-render never closes and reopens the seat.\n */\nfunction SidePanelSeat({\n claim,\n panel,\n triggerRef,\n finalFocusRef,\n}: {\n claim: SidePanelSlot['claim'];\n panel: HTMLDivElement | null;\n triggerRef: RefObject<HTMLElement | null>;\n finalFocusRef?: RefObject<HTMLElement | null>;\n}) {\n const dialog = useDialogContext();\n const latest = useRef({ setOpen: dialog.setOpen, finalFocusRef });\n useLayoutEffect(() => {\n latest.current = { setOpen: dialog.setOpen, finalFocusRef };\n });\n\n useLayoutEffect(() => {\n if (!panel) return;\n const opener = panel.ownerDocument.activeElement;\n const release = claim(() => latest.current.setOpen(false));\n panel.scrollIntoView({ block: 'nearest' });\n return () => {\n release();\n const active = panel.ownerDocument.activeElement;\n const movedToThePage =\n active && active !== panel.ownerDocument.body && !panel.contains(active);\n if (movedToThePage) return;\n const target = [latest.current.finalFocusRef?.current, triggerRef.current, opener].find(\n (element) => element instanceof HTMLElement && element.isConnected,\n );\n if (target instanceof HTMLElement) target.focus();\n };\n }, [claim, panel, triggerRef]);\n\n return null;\n}\n\n/**\n * The scrolling body. While its content overflows it joins the tab order, so\n * a keyboard user can focus it and scroll; a body with nothing to scroll\n * stays out of the way.\n *\n * Two boxes are observed because either can change the answer: the outer one\n * resizes with the viewport, the inner one with the content.\n */\nfunction DialogBody({ children }: { children: ReactNode }) {\n const [scrollable, setScrollable] = useState(false);\n const observe = useCallback((scroller: HTMLDivElement | null) => {\n const content = scroller?.firstElementChild;\n if (!scroller || !content) return;\n const observer = new ResizeObserver(() =>\n setScrollable(scroller.scrollHeight > scroller.clientHeight),\n );\n observer.observe(scroller);\n observer.observe(content);\n return () => observer.disconnect();\n }, []);\n\n return (\n <div ref={observe} className=\"ds-dialog__body\" tabIndex={scrollable ? 0 : undefined}>\n <div className=\"ds-dialog__body-content\">{children}</div>\n </div>\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- export type { DialogProps, DialogRole, DialogSize } from './dialog';
1
+ export type { DialogPresentation, DialogProps, DialogRole, DialogSize } from './dialog';
2
2
  export { Dialog } from './dialog';
3
3
  export type { DialogCloseProps } from './dialog-close';
4
4
  export { DialogClose } from './dialog-close';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export type { DialogProps, DialogRole, DialogSize } from './dialog';\nexport { Dialog } from './dialog';\nexport type { DialogCloseProps } from './dialog-close';\nexport { DialogClose } from './dialog-close';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export type { DialogPresentation, DialogProps, DialogRole, DialogSize } from './dialog';\nexport { Dialog } from './dialog';\nexport type { DialogCloseProps } from './dialog-close';\nexport { DialogClose } from './dialog-close';\n"]}
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ export * from './section';
31
31
  export * from './segment-group';
32
32
  export * from './select';
33
33
  export * from './show';
34
+ export * from './side-panel-layout';
34
35
  export * from './skeleton';
35
36
  export * from './slider';
36
37
  export * from './spinner';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,EACtB,GAAG,IAAI,WAAW,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,c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EAAE,MAAM,kBAAkB,CAAC;AAC3D,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ export * from './section';
30
30
  export * from './segment-group';
31
31
  export * from './select';
32
32
  export * from './show';
33
+ export * from './side-panel-layout';
33
34
  export * from './skeleton';
34
35
  export * from './slider';
35
36
  export * from './spinner';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,EACtB,GAAG,IAAI,WAAW,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './breadcrumb';\nexport * from './button';\nexport * from './calendar';\nexport * from './card';\nexport * from './centered-layout';\nexport * from './checkbox';\nexport * from './combobox';\nexport { cx } from './cx';\nexport * from './date-input';\nexport * from './dialog';\nexport * from './divider';\nexport * from './empty-state';\nexport {\n Check as FallbackCheck,\n ChevronLeft as FallbackChevronLeft,\n ChevronRight as FallbackChevronRight,\n Cross as FallbackCross,\n Pin as FallbackPin,\n} from './fallback-glyphs';\nexport * from './field';\nexport * from './form-layout';\nexport * from './icon';\nexport * from './illustration';\nexport * from './layout';\nexport * from './link';\nexport type { LinkComponentProps } from './link-component';\nexport * from './menu';\nexport * from './page-layout';\nexport * from './popover';\nexport * from './progress';\nexport * from './reorder-control';\nexport * from './scroll-area';\nexport * from './section';\nexport * from './segment-group';\nexport * from './select';\nexport * from './show';\nexport * from './skeleton';\nexport * from './slider';\nexport * from './spinner';\nexport * from './split-layout';\nexport * from './sticky';\nexport * from './switch';\nexport * from './tabs';\nexport * from './text';\nexport * from './tooltip';\nexport * from './visually-hidden';\nexport * from './wizard-layout';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,EACtB,GAAG,IAAI,WAAW,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './breadcrumb';\nexport * from './button';\nexport * from './calendar';\nexport * from './card';\nexport * from './centered-layout';\nexport * from './checkbox';\nexport * from './combobox';\nexport { cx } from './cx';\nexport * from './date-input';\nexport * from './dialog';\nexport * from './divider';\nexport * from './empty-state';\nexport {\n Check as FallbackCheck,\n ChevronLeft as FallbackChevronLeft,\n ChevronRight as FallbackChevronRight,\n Cross as FallbackCross,\n Pin as FallbackPin,\n} from './fallback-glyphs';\nexport * from './field';\nexport * from './form-layout';\nexport * from './icon';\nexport * from './illustration';\nexport * from './layout';\nexport * from './link';\nexport type { LinkComponentProps } from './link-component';\nexport * from './menu';\nexport * from './page-layout';\nexport * from './popover';\nexport * from './progress';\nexport * from './reorder-control';\nexport * from './scroll-area';\nexport * from './section';\nexport * from './segment-group';\nexport * from './select';\nexport * from './show';\nexport * from './side-panel-layout';\nexport * from './skeleton';\nexport * from './slider';\nexport * from './spinner';\nexport * from './split-layout';\nexport * from './sticky';\nexport * from './switch';\nexport * from './tabs';\nexport * from './text';\nexport * from './tooltip';\nexport * from './visually-hidden';\nexport * from './wizard-layout';\n"]}
@@ -0,0 +1,2 @@
1
+ export { SidePanelLayout, type SidePanelLayoutProps } from './side-panel-layout';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/side-panel-layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { SidePanelLayout } from './side-panel-layout';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/side-panel-layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA6B,MAAM,qBAAqB,CAAC","sourcesContent":["export { SidePanelLayout, type SidePanelLayoutProps } from './side-panel-layout';\n"]}
@@ -0,0 +1,20 @@
1
+ export interface SidePanelSlot {
2
+ /**
3
+ * The drawer a `Dialog` with `presentation="side"` portals its panel into.
4
+ * Null until the layout has mounted it: a side dialog open on mount waits
5
+ * for it rather than rendering into `<body>` first.
6
+ */
7
+ container: HTMLDivElement | null;
8
+ /**
9
+ * Takes the slot for a panel that just opened and asks the panel holding
10
+ * it to close, so one panel shows at a time. Returns the release to call
11
+ * when the panel closes.
12
+ */
13
+ claim: (close: () => void) => () => void;
14
+ }
15
+ /**
16
+ * The slot a `SidePanelLayout` keeps beside its content. Outside a layout
17
+ * there is none, and a side dialog opens as a modal.
18
+ */
19
+ export declare const SidePanelSlotContext: import("react").Context<SidePanelSlot | undefined>;
20
+ //# sourceMappingURL=side-panel-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"side-panel-context.d.ts","sourceRoot":"","sources":["../../src/side-panel-layout/side-panel-context.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC;;;;OAIG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CAC1C;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,oDAAsD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { createContext } from 'react';
2
+ /**
3
+ * The slot a `SidePanelLayout` keeps beside its content. Outside a layout
4
+ * there is none, and a side dialog opens as a modal.
5
+ */
6
+ export const SidePanelSlotContext = createContext(undefined);
7
+ //# sourceMappingURL=side-panel-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"side-panel-context.js","sourceRoot":"","sources":["../../src/side-panel-layout/side-panel-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAiBtC;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAA4B,SAAS,CAAC,CAAC","sourcesContent":["import { createContext } from 'react';\n\nexport interface SidePanelSlot {\n /**\n * The drawer a `Dialog` with `presentation=\"side\"` portals its panel into.\n * Null until the layout has mounted it: a side dialog open on mount waits\n * for it rather than rendering into `<body>` first.\n */\n container: HTMLDivElement | null;\n /**\n * Takes the slot for a panel that just opened and asks the panel holding\n * it to close, so one panel shows at a time. Returns the release to call\n * when the panel closes.\n */\n claim: (close: () => void) => () => void;\n}\n\n/**\n * The slot a `SidePanelLayout` keeps beside its content. Outside a layout\n * there is none, and a side dialog opens as a modal.\n */\nexport const SidePanelSlotContext = createContext<SidePanelSlot | undefined>(undefined);\n"]}
@@ -0,0 +1,74 @@
1
+ @layer components {
2
+ /*
3
+ * The panel slot stays empty until a side Dialog portals into it; React
4
+ * leaves no text node, so `:empty` tells whether a panel is open. Below the
5
+ * `lg` step the panel goes above the content, in the flow, as a band across
6
+ * the layout's width: the layout sits outside the page's padding, so the
7
+ * panel squares its corners and keeps only its top and bottom borders, and
8
+ * the page's own padding spaces the content from it. Breakpoints are
9
+ * viewport tokens written as literals (`check:breakpoints`).
10
+ */
11
+ .ds-side-panel-layout {
12
+ display: flex;
13
+ flex-direction: column;
14
+ min-width: 0;
15
+
16
+ & > .ds-side-panel-layout__main {
17
+ min-width: 0;
18
+ }
19
+
20
+ & > .ds-side-panel-layout__panel {
21
+ order: -1;
22
+ display: flex;
23
+ flex-direction: column;
24
+ min-width: 0;
25
+
26
+ &:empty {
27
+ display: none;
28
+ }
29
+
30
+ & > .ds-dialog {
31
+ border-inline-width: 0;
32
+ border-radius: 0;
33
+ }
34
+ }
35
+ }
36
+
37
+ /*
38
+ * From `lg` the panel is a drawer at the layout's end edge, outside the
39
+ * content's own padding: absolutely placed in the layout, which reserves
40
+ * its width with padding, so the content gives up the room rather than
41
+ * being covered. The drawer runs the layout's full height; the dialog in
42
+ * it sticks under the app's header and fills the viewport below it, its
43
+ * body scrolling inside, so the drawer always reaches from the header to
44
+ * the bottom of the screen. While a panel is open the layout is at least
45
+ * that tall, so a short page doesn't cut the drawer off.
46
+ */
47
+ @media (width >= 64rem) {
48
+ .ds-side-panel-layout {
49
+ position: relative;
50
+
51
+ &:has(> .ds-side-panel-layout__panel:not(:empty)) {
52
+ padding-inline-end: var(--ds-dialog-max-inline-size);
53
+ min-block-size: calc(100dvh - var(--ds-sticky-offset-top));
54
+ }
55
+
56
+ & > .ds-side-panel-layout__panel {
57
+ position: absolute;
58
+ inset-block: 0;
59
+ inset-inline-end: 0;
60
+ inline-size: var(--ds-dialog-max-inline-size);
61
+ display: block;
62
+
63
+ & > .ds-dialog {
64
+ position: sticky;
65
+ top: var(--ds-sticky-offset-top);
66
+ block-size: calc(100dvh - var(--ds-sticky-offset-top));
67
+ max-block-size: none;
68
+ border-width: 0;
69
+ border-inline-start-width: 1px;
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,39 @@
1
+ import { ark } from '@ark-ui/react/factory';
2
+ import { type ComponentProps } from 'react';
3
+ import './side-panel-layout.css';
4
+ /**
5
+ * No `asChild`: the layout renders its content and its panel slot, and Ark's
6
+ * `asChild` clones exactly one.
7
+ */
8
+ export type SidePanelLayoutProps = Omit<ComponentProps<typeof ark.div>, 'asChild'>;
9
+ /**
10
+ * Content with room for a side panel: a `Dialog` with `presentation="side"`
11
+ * opened anywhere inside it opens beside the content and narrows it, so the
12
+ * list it was opened from stays in view and usable.
13
+ *
14
+ * From the `lg` viewport step up the panel is a drawer at the layout's end
15
+ * edge, from under the app's header (`--ds-sticky-offset-top`) to the bottom
16
+ * of the viewport, and the content gives up its width rather than being
17
+ * covered. Put the layout outside the page's own padding, around the page
18
+ * template, so the drawer meets the window's edge, directly under the app's
19
+ * header and with nothing after it in the page: the drawer is as tall as the
20
+ * viewport below the header and can't leave the layout, so content above the
21
+ * layout pushes its foot off the screen and content after it lifts its top
22
+ * under the header. Below `lg` the panel goes above the content, in the
23
+ * page's flow, and pushes it down. With no panel open the content takes the
24
+ * whole width. One panel shows at a time: opening another closes the one
25
+ * that was open.
26
+ *
27
+ * ```tsx
28
+ * <SidePanelLayout>
29
+ * <PageLayout>
30
+ * <ActionList />
31
+ * <Dialog presentation="side" title="Add action" trigger={<Button>Add action</Button>}>
32
+ * <ActionForm />
33
+ * </Dialog>
34
+ * </PageLayout>
35
+ * </SidePanelLayout>
36
+ * ```
37
+ */
38
+ export declare function SidePanelLayout({ className, children, ...props }: SidePanelLayoutProps): import("react/jsx-runtime").JSX.Element;
39
+ //# sourceMappingURL=side-panel-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"side-panel-layout.d.ts","sourceRoot":"","sources":["../../src/side-panel-layout/side-panel-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAA0C,MAAM,OAAO,CAAC;AAGpF,OAAO,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,2CAqBtF"}
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ark } from '@ark-ui/react/factory';
3
+ import { useCallback, useMemo, useRef, useState } from 'react';
4
+ import { cx } from '../cx';
5
+ import { SidePanelSlotContext } from './side-panel-context';
6
+ import './side-panel-layout.css';
7
+ /**
8
+ * Content with room for a side panel: a `Dialog` with `presentation="side"`
9
+ * opened anywhere inside it opens beside the content and narrows it, so the
10
+ * list it was opened from stays in view and usable.
11
+ *
12
+ * From the `lg` viewport step up the panel is a drawer at the layout's end
13
+ * edge, from under the app's header (`--ds-sticky-offset-top`) to the bottom
14
+ * of the viewport, and the content gives up its width rather than being
15
+ * covered. Put the layout outside the page's own padding, around the page
16
+ * template, so the drawer meets the window's edge, directly under the app's
17
+ * header and with nothing after it in the page: the drawer is as tall as the
18
+ * viewport below the header and can't leave the layout, so content above the
19
+ * layout pushes its foot off the screen and content after it lifts its top
20
+ * under the header. Below `lg` the panel goes above the content, in the
21
+ * page's flow, and pushes it down. With no panel open the content takes the
22
+ * whole width. One panel shows at a time: opening another closes the one
23
+ * that was open.
24
+ *
25
+ * ```tsx
26
+ * <SidePanelLayout>
27
+ * <PageLayout>
28
+ * <ActionList />
29
+ * <Dialog presentation="side" title="Add action" trigger={<Button>Add action</Button>}>
30
+ * <ActionForm />
31
+ * </Dialog>
32
+ * </PageLayout>
33
+ * </SidePanelLayout>
34
+ * ```
35
+ */
36
+ export function SidePanelLayout({ className, children, ...props }) {
37
+ const [container, setContainer] = useState(null);
38
+ const closeHolder = useRef(null);
39
+ const claim = useCallback((close) => {
40
+ const previous = closeHolder.current;
41
+ closeHolder.current = close;
42
+ previous?.();
43
+ return () => {
44
+ if (closeHolder.current === close)
45
+ closeHolder.current = null;
46
+ };
47
+ }, []);
48
+ const slot = useMemo(() => ({ container, claim }), [container, claim]);
49
+ return (_jsx(SidePanelSlotContext.Provider, { value: slot, children: _jsxs(ark.div, { className: cx('ds-side-panel-layout', className), ...props, children: [_jsx("div", { className: "ds-side-panel-layout__main", children: children }), _jsx("div", { ref: setContainer, className: "ds-side-panel-layout__panel" })] }) }));
50
+ }
51
+ //# sourceMappingURL=side-panel-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"side-panel-layout.js","sourceRoot":"","sources":["../../src/side-panel-layout/side-panel-layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAuB,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAsB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,yBAAyB,CAAC;AAQjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAwB;IACrF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,KAAiB,EAAE,EAAE;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC;QACrC,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;QAC5B,QAAQ,EAAE,EAAE,CAAC;QACb,OAAO,GAAG,EAAE;YACV,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK;gBAAE,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;QAChE,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,IAAI,GAAG,OAAO,CAAgB,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtF,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YACxC,MAAC,GAAG,CAAC,GAAG,IAAC,SAAS,EAAE,EAAE,CAAC,sBAAsB,EAAE,SAAS,CAAC,KAAM,KAAK,aAClE,cAAK,SAAS,EAAC,4BAA4B,YAAE,QAAQ,GAAO,EAC5D,cAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAC,6BAA6B,GAAG,IAC1D,GACoB,CACjC,CAAC;AACJ,CAAC","sourcesContent":["import { ark } from '@ark-ui/react/factory';\nimport { type ComponentProps, useCallback, useMemo, useRef, useState } from 'react';\nimport { cx } from '../cx';\nimport { type SidePanelSlot, SidePanelSlotContext } from './side-panel-context';\nimport './side-panel-layout.css';\n\n/**\n * No `asChild`: the layout renders its content and its panel slot, and Ark's\n * `asChild` clones exactly one.\n */\nexport type SidePanelLayoutProps = Omit<ComponentProps<typeof ark.div>, 'asChild'>;\n\n/**\n * Content with room for a side panel: a `Dialog` with `presentation=\"side\"`\n * opened anywhere inside it opens beside the content and narrows it, so the\n * list it was opened from stays in view and usable.\n *\n * From the `lg` viewport step up the panel is a drawer at the layout's end\n * edge, from under the app's header (`--ds-sticky-offset-top`) to the bottom\n * of the viewport, and the content gives up its width rather than being\n * covered. Put the layout outside the page's own padding, around the page\n * template, so the drawer meets the window's edge, directly under the app's\n * header and with nothing after it in the page: the drawer is as tall as the\n * viewport below the header and can't leave the layout, so content above the\n * layout pushes its foot off the screen and content after it lifts its top\n * under the header. Below `lg` the panel goes above the content, in the\n * page's flow, and pushes it down. With no panel open the content takes the\n * whole width. One panel shows at a time: opening another closes the one\n * that was open.\n *\n * ```tsx\n * <SidePanelLayout>\n * <PageLayout>\n * <ActionList />\n * <Dialog presentation=\"side\" title=\"Add action\" trigger={<Button>Add action</Button>}>\n * <ActionForm />\n * </Dialog>\n * </PageLayout>\n * </SidePanelLayout>\n * ```\n */\nexport function SidePanelLayout({ className, children, ...props }: SidePanelLayoutProps) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const closeHolder = useRef<(() => void) | null>(null);\n const claim = useCallback((close: () => void) => {\n const previous = closeHolder.current;\n closeHolder.current = close;\n previous?.();\n return () => {\n if (closeHolder.current === close) closeHolder.current = null;\n };\n }, []);\n const slot = useMemo<SidePanelSlot>(() => ({ container, claim }), [container, claim]);\n\n return (\n <SidePanelSlotContext.Provider value={slot}>\n <ark.div className={cx('ds-side-panel-layout', className)} {...props}>\n <div className=\"ds-side-panel-layout__main\">{children}</div>\n <div ref={setContainer} className=\"ds-side-panel-layout__panel\" />\n </ark.div>\n </SidePanelSlotContext.Provider>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.26.1",
3
+ "version": "0.28.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -144,6 +144,10 @@
144
144
  "types": "./dist/show/index.d.ts",
145
145
  "import": "./dist/show/index.js"
146
146
  },
147
+ "./side-panel-layout": {
148
+ "types": "./dist/side-panel-layout/index.d.ts",
149
+ "import": "./dist/side-panel-layout/index.js"
150
+ },
147
151
  "./skeleton": {
148
152
  "types": "./dist/skeleton/index.d.ts",
149
153
  "import": "./dist/skeleton/index.js"
@@ -304,6 +308,10 @@
304
308
  "types": "./dist/show/show.css.d.ts",
305
309
  "default": "./dist/show/show.css"
306
310
  },
311
+ "./css/side-panel-layout": {
312
+ "types": "./dist/side-panel-layout/side-panel-layout.css.d.ts",
313
+ "default": "./dist/side-panel-layout/side-panel-layout.css"
314
+ },
307
315
  "./css/skeleton": {
308
316
  "types": "./dist/skeleton/skeleton.css.d.ts",
309
317
  "default": "./dist/skeleton/skeleton.css"
@@ -372,7 +380,7 @@
372
380
  },
373
381
  "devDependencies": {
374
382
  "@manakind/ds-config": "*",
375
- "@manakind/manuia-tokens": "0.25.0",
383
+ "@manakind/manuia-tokens": "0.27.0",
376
384
  "@testing-library/jest-dom": "^6.9.1",
377
385
  "@testing-library/react": "^16.3.2",
378
386
  "@testing-library/user-event": "^14.6.1",