@stackone/malachite 2.118.0 → 2.119.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/COMPONENTS.md +1 -1
- package/dist/components/PageLayout/index.js +7 -6
- package/dist/components/PageLayout/index.js.map +1 -1
- package/dist/components/PageLayout/pageColumn.js +35 -0
- package/dist/components/PageLayout/pageColumn.js.map +1 -0
- package/dist/components/PageLayout/regularLayout.js +57 -75
- package/dist/components/PageLayout/regularLayout.js.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/tailwind.css.js +1 -1
- package/dist/theme.js +2 -2
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
package/COMPONENTS.md
CHANGED
|
@@ -17,7 +17,7 @@ The catalog of components exported from `@stackone/malachite`. **Reach for one o
|
|
|
17
17
|
- **`SelectableCard`** — A card that is one option in a radio group — eyebrow, optional status tag, title, description, a count label and a top-right action slot. Use inside a `CardStrip`. Selection is controlled by the consumer: pass `selected`, which drives both the visual treatment and `aria-checked`. A selected card meets the sheet below the way a browser tab meets its toolbar — its bottom corners flare outward onto the strip’s rule — so its outline is one SVG path rather than borders, which would split into two lines at the tangent. `variant` picks the palette: `profile` (green), `library` (neutral) or `editing` (amber, for a profile with unsaved changes). `actions` stands in the card’s top-right corner, on the eyebrow row, and renders outside the control so a menu or icon button inside it stays clickable and keeps its own tab stop. Nothing else marks that corner: the flared outline, the tint and the green eyebrow already say which card is selected, so a radio there would only repeat them. `onDismiss` adds an x after `actions`, tinted like the eyebrow so it reads as part of the card — for discarding a draft card; `dismissDisabledReason` disables it and explains why in its tooltip. `isDefault` marks the card as the account default with a pin beside the title, named for assistive tech and tooltipped for everyone else — it belongs with the name it qualifies rather than among the actions, which read as things to press. `address` puts a one-line chip above the count for a copyable address such as a server URL: its `label` is cut short with an ellipsis, and its full `value` shows in a tooltip and is copied on click, without selecting the card. It takes the place of `description`, since the card has room for one or the other. For a row-shaped selectable use `Surface.Row` instead. _Key props:_ `value`, `title`, `titleIcon`, `isDefault`, `variant` (`profile` | `library` | `editing`), `eyebrow`, `status` (`label`, `type`, `tooltip`), `description`, `address` (`label`, `value`), `countLabel`, `actions`, `onDismiss` (`dismissLabel`, `dismissDisabledReason`), `selected`, `loading` (`loadingLabel`, `loadingHint`), `disabled`, `dimmed`, `onSelect`, `tabIndex`, `aria-label`, `className`, `style`.
|
|
18
18
|
- **`CardStrip`** — Horizontally scrolling radio group of cards, with edge arrows that appear only when the content overflows, an edge fade, scroll-snap and arrow-key navigation matching `SegmentedControl`. Owns interaction only: it finds its options by looking for `role="radio"` descendants carrying `data-value`, so any such child works (`SelectableCard` emits both). Pass a non-selectable terminal tile as `CardStrip.AddTile` — it sits inside the group but outside the radio set, and must be a direct child or it scrolls with the cards. Use `leading` to pin a card that should not scroll away; the strip tells the cards which slot they are in, so a pinned `SelectableCard` drops the left rule the scrolling ones draw. A strip too narrow to show a card beside `leading` scrolls it with the cards rather than squeezing them, so the selected card always has its full width. Set `bleed` when the strip sits in a `PageLayout`: the strip stretches past the horizontal padding of the layout so its bottom rule runs the full width of the page card, while the cards stay aligned to the gutter. With no cards at all the strip degenerates to its pinned slots alone — no trough, no scroller and no arrows — with the add tile standing beside `leading` and taking `primary` emphasis automatically, since adding the first card is the only thing on offer. _Key props:_ `value`, `tone` (`profile` | `library` | `editing` — read off the selected card unless set), `onChange`, `children`, `leading`, `arrows`, `fadeEdges`, `snap`, `bleed`, `scrollSelectedIntoView`, `aria-label`, `aria-labelledby`, `className`, `style`. `CardStrip.AddTile`: `label`, `icon`, `onClick`, `disabled`, `emphasis` (`primary` | `secondary` — left to the strip unless set: `primary` while there are no cards, `secondary` once there are), `className`.
|
|
19
19
|
- **`SplitScreenLayout`** — Two-pane full-screen layout (content + preview/aside) with an optional dismiss button.
|
|
20
|
-
- **`PageLayout`** — Standard page chrome: a bordered card holding a breadcrumb bar, an optional alert strip, and a header block (subtitle, title + suffix, description) above the page body. Used as `PageLayout.Regular`; `PageLayout.Empty` is the chrome-only variant for pre-auth and error screens, with `headerActions` and `background` slots. Actions are declared as data (`buttons`) rather than children, and any that do not fit collapse into an overflow `ActionMenu` via `OverflowRow`. A client-side-routed app must pass `renderLink` so crumbs and the back button go through its router instead of reloading the document. Both layouts render a `main` landmark, demoted via `role` when the app owns its own. Deliberately not a `Surface` — the page card is 16px and carries no shadow. _Key props:_ `PageLayout.Regular`: `breadcrumbLinks`, `breadcrumbActions`, `renderLink`, `title`, `titleSuffix`, `subtitle`, `description`, `buttons`, `loading`, `centered`, `noPadding`, `contentGap` (`small` | `medium` | `large` | `xlarge`, default `small`), `contentWidth` (`narrow`: caps and centres the header and body column for a single-column form), `alert`, `role`, `aria-label`, `aria-labelledby`, `className`, `style`. `PageLayout.Empty`: `title`, `centered`, `uniformPadding`, `headerActions`, `background`, `role`, `aria-label`, `aria-labelledby`, `className`, `style`.
|
|
20
|
+
- **`PageLayout`** — Standard page chrome: a bordered card holding a breadcrumb bar, an optional alert strip, and a header block (subtitle, title + suffix, description) above the page body. Used as `PageLayout.Regular`; `PageLayout.Empty` is the chrome-only variant for pre-auth and error screens, with `headerActions` and `background` slots. `PageLayout.Column` is the capped, centred column that `contentWidth` uses, on its own; set `standalone` for a page with no layout around it. Actions are declared as data (`buttons`) rather than children, and any that do not fit collapse into an overflow `ActionMenu` via `OverflowRow`. A client-side-routed app must pass `renderLink` so crumbs and the back button go through its router instead of reloading the document. Both layouts render a `main` landmark, demoted via `role` when the app owns its own. Deliberately not a `Surface` — the page card is 16px and carries no shadow. _Key props:_ `PageLayout.Regular`: `breadcrumbLinks`, `breadcrumbActions`, `renderLink`, `title`, `titleSuffix`, `subtitle`, `description`, `buttons`, `loading`, `centered`, `noPadding`, `contentGap` (`small` | `medium` | `large` | `xlarge`, default `small`), `contentWidth` (`narrow`: caps and centres the header and body column for a single-column form), `alert`, `role`, `aria-label`, `aria-labelledby`, `className`, `style`. `PageLayout.Empty`: `title`, `centered`, `uniformPadding`, `headerActions`, `background`, `role`, `aria-label`, `aria-labelledby`, `className`, `style`. `PageLayout.Column`: `width` (`narrow`), `gap`, `standalone`, `className`.
|
|
21
21
|
- **`WizardLayout`** — Full-screen wizard scaffold: top bar (back button, right-aligned stepper, trailing slot), pinned `header` slot, centered scrolling content column, and a pinned footer (above sticky body content). `footerGlass` gives the footer a frosted translucent + backdrop-blur treatment. `banner` pins a page-wide notice under the top bar, above `header` and outside the content column, so a warning about the whole page is not squeezed to the column's width — pair it with `Alert layout="banner"`. `topBarSize="large"` draws a 60px top bar with 28px insets (52px and 16px below 640px). `footerAlign="content"` holds the footer to the content column, inside its gutter, so a full-width action lines up with the list above it. `reserveBack={false}` drops the square held for a hidden back button, so `leading` sits at the same inset as `trailing`; the default keeps it so `leading` does not move as the wizard steps. _Key props:_ `showBack`, `onBack`, `reserveBack`, `topBarSize` (`default` | `large`), `footerAlign` (`full` | `content`), `leading`, `stepper`, `trailing`, `banner`, `header`, `footer`, `footerGlass`, `center`, `contentWidth`, `minWidth`.
|
|
22
22
|
- **`PageActions`** — A page's action buttons, collapsing into an overflow menu as the row narrows. `PageLayout.Regular` renders these from its `buttons` prop; import it directly when a page builds its own header block (e.g. one that scrolls the title away) so the collapse, the dividers and the href handling come with it rather than being hand-rolled. _Key props:_ `buttons` (`PageAction[]`).
|
|
23
23
|
- **`Toolbar`** — Flat, opaque horizontal bar for a sub-header / filter row (e.g. a Search). Owns its chrome — an opaque ground (`card-background`, or the sunken page ground with `surface="page"` for a bar above a card), so it can pin over scrolling content, plus an optional bottom `divider` — so consumers don’t hand-roll background/border tokens. Its `TOOLBAR_FILTER_WIDTH_PX` / `TOOLBAR_FILTER_MIN_WIDTH_PX` / `TOOLBAR_FILL_BASIS_PX` / `TOOLBAR_FILL_MIN_WIDTH_PX` are exported so a control outside the bar can line up with one inside it without re-typing the number. `sticky` pins it to the top of its scroll container; any other positioning is left to the consumer, as is the gutter when `padding="none"` — use that when the bar must sit flush with the content it pins over. `layout="filters"` makes it own the layout too, which consumers were each re-deriving and getting wrong the same way: a `flex: 1` search with no floor collapses to nothing on a narrow viewport, and a row that cannot wrap runs off the page. Compose it as `Toolbar.Fill` for the search and `Toolbar.Item` per filter, as flat siblings; `grow={false}` stops a slot growing past its basis, for a row that already spaces its children, though it can still shrink toward its `minWidth`. The row packs greedily from its basis widths and each line's spare space is shared out by grow factor, which is deliberately lopsided: the search outweighs the filters a hundred to one, so a shared line leaves them at their 200px while a filter left alone on a wrapped line grows into the whole width instead of stranding beside a gap. A filter drops to the next line once its full 200px basis will not fit, and the filters sharing a line then compress toward a 160px floor. A search and a filter are laid out differently rather than uniformly, because a search field's useful width is "as much as you can spare" where a filter's is the width of a value. _Key props:_ `divider`, `padding` (`none` | `compact` | `default`), `layout` (`plain` | `filters`), `surface` (`card` | `page` — `page` paints the sunken page ground, for a bar that sits above a card rather than inside it), `sticky` (pins it to the top of its scroll container above the rows under it), `className`, `style`. `Fill`: `minWidth`. `Item`: `width`, `minWidth`, `grow`.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { EmptyLayout as o } from "./emptyLayout.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { PageColumn as t } from "./pageColumn.js";
|
|
3
|
+
import { RegularLayout as m } from "./regularLayout.js";
|
|
4
|
+
import { PageActions as g } from "./regularLayout.js";
|
|
5
|
+
const u = { Regular: m, Empty: o, Column: t };
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
g as PageActions,
|
|
8
|
+
u as PageLayout,
|
|
9
|
+
u as default
|
|
9
10
|
};
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/PageLayout/index.tsx"],"sourcesContent":["import Empty from './emptyLayout';\nimport Regular from './regularLayout';\n\nexport const PageLayout = { Regular, Empty };\n\nexport default PageLayout;\nexport type { BreadcrumbLink, PageAction, RenderLink } from './types';\nexport { PageActions } from './regularLayout';\nexport type { PageContentGap, PageContentWidth, RegularLayoutProps } from './regularLayout';\nexport type { EmptyLayoutProps } from './emptyLayout';\n"],"names":["PageLayout","Regular","Empty"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/PageLayout/index.tsx"],"sourcesContent":["import Empty from './emptyLayout';\nimport Column from './pageColumn';\nimport Regular from './regularLayout';\n\nexport const PageLayout = { Regular, Empty, Column };\n\nexport default PageLayout;\nexport type { BreadcrumbLink, PageAction, RenderLink } from './types';\nexport { PageActions } from './regularLayout';\nexport type { PageContentGap, PageContentWidth, RegularLayoutProps } from './regularLayout';\nexport type { EmptyLayoutProps } from './emptyLayout';\nexport type { PageColumnProps } from './pageColumn';\n"],"names":["PageLayout","Regular","Empty","Column"],"mappings":";;;;AAIO,MAAMA,IAAa,EAAA,SAAEC,GAAA,OAASC,WAAOC,EAAA;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { CONTENT_INSET_VAR as s } from "./constants.js";
|
|
3
|
+
const t = {
|
|
4
|
+
narrow: 520
|
|
5
|
+
}, x = {
|
|
6
|
+
small: 8,
|
|
7
|
+
medium: 16,
|
|
8
|
+
large: 24,
|
|
9
|
+
xlarge: 40
|
|
10
|
+
}, i = 40, N = 16, f = ({
|
|
11
|
+
width: a,
|
|
12
|
+
gap: l,
|
|
13
|
+
standalone: o = !1,
|
|
14
|
+
children: e,
|
|
15
|
+
className: T = ""
|
|
16
|
+
}) => /* @__PURE__ */ m(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
className: `flex flex-col flex-1 w-full ${T}`,
|
|
20
|
+
style: {
|
|
21
|
+
maxWidth: t[a],
|
|
22
|
+
marginInline: "auto",
|
|
23
|
+
gap: l ? x[l] : void 0,
|
|
24
|
+
padding: o ? `${i}px ${N}px` : void 0,
|
|
25
|
+
[s]: o ? `${N}px` : "0px"
|
|
26
|
+
},
|
|
27
|
+
children: e
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
export {
|
|
31
|
+
x as CONTENT_GAPS,
|
|
32
|
+
f as PageColumn,
|
|
33
|
+
f as default
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=pageColumn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageColumn.js","sources":["../../../src/components/PageLayout/pageColumn.tsx"],"sourcesContent":["import React from 'react';\nimport { CONTENT_INSET_VAR } from './constants';\n\nexport type PageContentGap = 'small' | 'medium' | 'large' | 'xlarge';\n\nexport type PageContentWidth = 'narrow';\n\nconst CONTENT_WIDTHS: Record<PageContentWidth, number> = {\n narrow: 520,\n};\n\nexport const CONTENT_GAPS: Record<PageContentGap, number> = {\n small: 8,\n medium: 16,\n large: 24,\n xlarge: 40,\n};\n\nconst STANDALONE_BLOCK_PADDING = 40;\nconst STANDALONE_GUTTER = 16;\n\nexport interface PageColumnProps {\n /** `narrow` fits a single-column form. */\n width: PageContentWidth;\n gap?: PageContentGap;\n /**\n * For a page rendered without `PageLayout.Regular` around it: adds 40px above and below and\n * 16px side gutters, so the column keeps clear of the viewport edges on a phone.\n */\n standalone?: boolean;\n children: React.ReactNode;\n className?: string;\n}\n\n/** A capped, centred column. `PageLayout.Regular`'s `contentWidth` renders its body through it. */\nconst PageColumn: React.FC<PageColumnProps> = ({\n width,\n gap,\n standalone = false,\n children,\n className = '',\n}) => (\n <div\n className={`flex flex-col flex-1 w-full ${className}`}\n style={\n {\n maxWidth: CONTENT_WIDTHS[width],\n marginInline: 'auto',\n gap: gap ? CONTENT_GAPS[gap] : undefined,\n padding: standalone\n ? `${STANDALONE_BLOCK_PADDING}px ${STANDALONE_GUTTER}px`\n : undefined,\n [CONTENT_INSET_VAR]: standalone ? `${STANDALONE_GUTTER}px` : '0px',\n } as React.CSSProperties\n }\n >\n {children}\n </div>\n);\n\nexport default PageColumn;\nexport { PageColumn };\n"],"names":["CONTENT_WIDTHS","CONTENT_GAPS","STANDALONE_BLOCK_PADDING","STANDALONE_GUTTER","PageColumn","width","gap","standalone","children","className","jsx","CONTENT_INSET_VAR"],"mappings":";;AAOA,MAAMA,IAAmD;AAAA,EACrD,QAAQ;AACZ,GAEaC,IAA+C;AAAA,EACxD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACZ,GAEMC,IAA2B,IAC3BC,IAAoB,IAgBpBC,IAAwC,CAAC;AAAA,EAC3C,OAAAC;AAAA,EACA,KAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC;AAAA,EACA,WAAAC,IAAY;AAChB,MACI,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,WAAW,+BAA+BD,CAAS;AAAA,IACnD,OACI;AAAA,MACI,UAAUT,EAAeK,CAAK;AAAA,MAC9B,cAAc;AAAA,MACd,KAAKC,IAAML,EAAaK,CAAG,IAAI;AAAA,MAC/B,SAASC,IACH,GAAGL,CAAwB,MAAMC,CAAiB,OAClD;AAAA,MACN,CAACQ,CAAiB,GAAGJ,IAAa,GAAGJ,CAAiB,OAAO;AAAA,IAAA;AAAA,IAIpE,UAAAK;AAAA,EAAA;AACL;"}
|
|
@@ -1,48 +1,42 @@
|
|
|
1
|
-
import { jsx as l, jsxs as n, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { Alert as
|
|
4
|
-
import { Breadcrumbs as
|
|
5
|
-
import { hasBackButton as
|
|
6
|
-
import { Button as
|
|
7
|
-
import
|
|
1
|
+
import { jsx as l, jsxs as n, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import u from "../ActionMenu.js";
|
|
3
|
+
import { Alert as P } from "../Alert.js";
|
|
4
|
+
import { Breadcrumbs as j } from "../Breadcrumbs.js";
|
|
5
|
+
import { hasBackButton as G } from "../breadcrumbsNav.js";
|
|
6
|
+
import { Button as L } from "../Button.js";
|
|
7
|
+
import z from "../OverflowRow.js";
|
|
8
8
|
import h from "../Skeleton.js";
|
|
9
|
-
import
|
|
9
|
+
import U from "../Typography/PageTitle.js";
|
|
10
10
|
import I from "../Typography/Text.js";
|
|
11
|
-
import { safeHref as
|
|
12
|
-
import { CARD_MIN_HEIGHT as
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
small: 8,
|
|
17
|
-
medium: 16,
|
|
18
|
-
large: 24,
|
|
19
|
-
xlarge: 40
|
|
20
|
-
}, Y = (a) => a.variant === "destructive" || a.variant === "error", Z = (a) => a.flatMap((e, r) => {
|
|
21
|
-
const i = E(e.href), c = {
|
|
11
|
+
import { safeHref as _ } from "../safeHref.js";
|
|
12
|
+
import { CARD_MIN_HEIGHT as V, CARD_RADIUS as F, CARD_CLASSES as K, HEADER_HEIGHT as q, DIVIDER_CLASSES as w, CONTENT_MIN_HEIGHT as J, CONTENT_INSET_VAR as Q } from "./constants.js";
|
|
13
|
+
import { CONTENT_GAPS as X, PageColumn as Y } from "./pageColumn.js";
|
|
14
|
+
const Z = (a) => a.variant === "destructive" || a.variant === "error", W = (a) => a.flatMap((e, r) => {
|
|
15
|
+
const i = _(e.href), c = {
|
|
22
16
|
key: `${r}-${e.label}`,
|
|
23
17
|
label: e.label,
|
|
24
18
|
...i ? { href: i, target: e.target ?? "_blank" } : { onClick: e.onClick },
|
|
25
19
|
disabled: e.disabled,
|
|
26
20
|
icon: e.icon,
|
|
27
21
|
tooltip: e.tooltip,
|
|
28
|
-
danger:
|
|
22
|
+
danger: Z(e)
|
|
29
23
|
};
|
|
30
24
|
return e.dividerBefore && r > 0 ? [{ type: "divider", key: `divider-${r}-${e.label}` }, c] : [c];
|
|
31
25
|
}), b = ({ buttons: a }) => a.length === 0 ? null : /* @__PURE__ */ l("div", { className: "min-w-0", children: /* @__PURE__ */ l(
|
|
32
|
-
|
|
26
|
+
z,
|
|
33
27
|
{
|
|
34
28
|
gap: 8,
|
|
35
29
|
justify: "end",
|
|
36
30
|
renderOverflow: (e) => /* @__PURE__ */ l(
|
|
37
|
-
|
|
31
|
+
u,
|
|
38
32
|
{
|
|
39
|
-
items:
|
|
33
|
+
items: W(
|
|
40
34
|
a.slice(Math.max(0, a.length - e))
|
|
41
35
|
)
|
|
42
36
|
}
|
|
43
37
|
),
|
|
44
38
|
children: a.map((e, r) => {
|
|
45
|
-
const i =
|
|
39
|
+
const i = _(e.href);
|
|
46
40
|
return /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
|
|
47
41
|
e.dividerBefore && r > 0 ? /* @__PURE__ */ l(
|
|
48
42
|
"span",
|
|
@@ -52,7 +46,7 @@ const X = {
|
|
|
52
46
|
}
|
|
53
47
|
) : null,
|
|
54
48
|
/* @__PURE__ */ l(
|
|
55
|
-
|
|
49
|
+
L,
|
|
56
50
|
{
|
|
57
51
|
variant: e.variant ?? "filled",
|
|
58
52
|
size: "medium",
|
|
@@ -69,59 +63,59 @@ const X = {
|
|
|
69
63
|
] }, `${r}-${e.label}`);
|
|
70
64
|
})
|
|
71
65
|
}
|
|
72
|
-
) }), ee = [], le = [],
|
|
66
|
+
) }), ee = [], le = [], ge = ({
|
|
73
67
|
breadcrumbLinks: a = ee,
|
|
74
68
|
breadcrumbActions: e,
|
|
75
69
|
renderLink: r,
|
|
76
70
|
title: i,
|
|
77
71
|
titleSuffix: c,
|
|
78
|
-
subtitle:
|
|
79
|
-
description:
|
|
80
|
-
buttons:
|
|
72
|
+
subtitle: d,
|
|
73
|
+
description: o,
|
|
74
|
+
buttons: t = le,
|
|
81
75
|
loading: s = !1,
|
|
82
|
-
children:
|
|
76
|
+
children: E,
|
|
83
77
|
centered: f = !1,
|
|
84
78
|
noPadding: p = !1,
|
|
85
79
|
contentGap: g = "small",
|
|
86
|
-
contentWidth:
|
|
80
|
+
contentWidth: v,
|
|
87
81
|
alert: m,
|
|
88
|
-
role:
|
|
89
|
-
"aria-label":
|
|
90
|
-
"aria-labelledby":
|
|
91
|
-
className:
|
|
92
|
-
style:
|
|
82
|
+
role: T,
|
|
83
|
+
"aria-label": k,
|
|
84
|
+
"aria-labelledby": C,
|
|
85
|
+
className: S = "",
|
|
86
|
+
style: A
|
|
93
87
|
}) => {
|
|
94
|
-
const
|
|
95
|
-
/* @__PURE__ */ l(
|
|
88
|
+
const H = G(a), B = p ? 0 : f ? "5vh 14vw" : "40px", R = p ? "0px" : f ? "14vw" : "40px", $ = !!(s || i || d || o || t.length > 0), N = d ? s ? /* @__PURE__ */ l(h.Input, { width: 120, height: 24 }) : /* @__PURE__ */ l(I, { color: "secondary", size: "small", children: d }) : null, y = s ? /* @__PURE__ */ l(h.Input, { width: 200, height: 40 }) : i ? /* @__PURE__ */ n("div", { className: "flex items-center", style: { gap: 12 }, children: [
|
|
89
|
+
/* @__PURE__ */ l(U, { children: i }),
|
|
96
90
|
c
|
|
97
|
-
] }) : null,
|
|
98
|
-
|
|
91
|
+
] }) : null, D = o ? s ? /* @__PURE__ */ l(h.Input, { width: 120, height: 24 }) : /* @__PURE__ */ l(I, { color: "secondary", style: { lineHeight: 1.6 }, children: o }) : null, O = $ ? /* @__PURE__ */ n("div", { className: "flex flex-col", style: { gap: 12 }, children: [
|
|
92
|
+
y || N || t.length > 0 ? /* @__PURE__ */ n("div", { className: "flex flex-wrap items-center justify-between", style: { gap: 12 }, children: [
|
|
99
93
|
/* @__PURE__ */ n(
|
|
100
94
|
"div",
|
|
101
95
|
{
|
|
102
96
|
className: "flex flex-col flex-auto min-w-0 overflow-hidden",
|
|
103
97
|
style: { gap: 4 },
|
|
104
98
|
children: [
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
N,
|
|
100
|
+
y
|
|
107
101
|
]
|
|
108
102
|
}
|
|
109
103
|
),
|
|
110
|
-
s ? null : /* @__PURE__ */ l(b, { buttons:
|
|
104
|
+
s ? null : /* @__PURE__ */ l(b, { buttons: t })
|
|
111
105
|
] }) : null,
|
|
112
|
-
|
|
113
|
-
] }) : null,
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
D
|
|
107
|
+
] }) : null, x = /* @__PURE__ */ n(M, { children: [
|
|
108
|
+
O,
|
|
109
|
+
E
|
|
116
110
|
] });
|
|
117
111
|
return /* @__PURE__ */ n(
|
|
118
112
|
"main",
|
|
119
113
|
{
|
|
120
|
-
className: `${
|
|
121
|
-
style: { borderRadius:
|
|
122
|
-
role:
|
|
123
|
-
"aria-label":
|
|
124
|
-
"aria-labelledby":
|
|
114
|
+
className: `${K} ${S}`,
|
|
115
|
+
style: { borderRadius: F, minHeight: V, ...A },
|
|
116
|
+
role: T,
|
|
117
|
+
"aria-label": k,
|
|
118
|
+
"aria-labelledby": C,
|
|
125
119
|
"aria-busy": s || void 0,
|
|
126
120
|
children: [
|
|
127
121
|
/* @__PURE__ */ l(
|
|
@@ -129,12 +123,12 @@ const X = {
|
|
|
129
123
|
{
|
|
130
124
|
className: `flex items-center ${w}`,
|
|
131
125
|
style: {
|
|
132
|
-
height:
|
|
133
|
-
paddingInlineStart:
|
|
126
|
+
height: q,
|
|
127
|
+
paddingInlineStart: H ? 16 : 28,
|
|
134
128
|
paddingInlineEnd: 16
|
|
135
129
|
},
|
|
136
130
|
children: /* @__PURE__ */ l(
|
|
137
|
-
|
|
131
|
+
j,
|
|
138
132
|
{
|
|
139
133
|
links: a,
|
|
140
134
|
actions: e,
|
|
@@ -145,30 +139,18 @@ const X = {
|
|
|
145
139
|
)
|
|
146
140
|
}
|
|
147
141
|
),
|
|
148
|
-
m ? /* @__PURE__ */ l("div", { className: w, style: { padding: "10px 16px" }, children: /* @__PURE__ */ l(
|
|
142
|
+
m ? /* @__PURE__ */ l("div", { className: w, style: { padding: "10px 16px" }, children: /* @__PURE__ */ l(P, { message: m.message, type: m.type, hasMargin: !1 }) }) : null,
|
|
149
143
|
/* @__PURE__ */ l(
|
|
150
144
|
"div",
|
|
151
145
|
{
|
|
152
146
|
className: "flex flex-col",
|
|
153
147
|
style: {
|
|
154
|
-
padding:
|
|
155
|
-
minHeight:
|
|
156
|
-
gap:
|
|
157
|
-
[
|
|
148
|
+
padding: B,
|
|
149
|
+
minHeight: J,
|
|
150
|
+
gap: X[g],
|
|
151
|
+
[Q]: R
|
|
158
152
|
},
|
|
159
|
-
children:
|
|
160
|
-
"div",
|
|
161
|
-
{
|
|
162
|
-
className: "flex flex-col flex-1 w-full",
|
|
163
|
-
style: {
|
|
164
|
-
maxWidth: X[N],
|
|
165
|
-
marginInline: "auto",
|
|
166
|
-
gap: _[g],
|
|
167
|
-
[T]: "0px"
|
|
168
|
-
},
|
|
169
|
-
children: y
|
|
170
|
-
}
|
|
171
|
-
) : y
|
|
153
|
+
children: v ? /* @__PURE__ */ l(Y, { width: v, gap: g, children: x }) : x
|
|
172
154
|
}
|
|
173
155
|
)
|
|
174
156
|
]
|
|
@@ -177,7 +159,7 @@ const X = {
|
|
|
177
159
|
};
|
|
178
160
|
export {
|
|
179
161
|
b as PageActions,
|
|
180
|
-
|
|
181
|
-
|
|
162
|
+
ge as RegularLayout,
|
|
163
|
+
ge as default
|
|
182
164
|
};
|
|
183
165
|
//# sourceMappingURL=regularLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regularLayout.js","sources":["../../../src/components/PageLayout/regularLayout.tsx"],"sourcesContent":["import React from 'react';\nimport ActionMenu, { type ActionMenuItem } from '../ActionMenu';\nimport Alert, { type AlertType } from '../Alert';\nimport Breadcrumbs from '../Breadcrumbs';\nimport { hasBackButton } from '../breadcrumbsNav';\nimport Button from '../Button';\nimport OverflowRow from '../OverflowRow';\nimport Skeleton from '../Skeleton';\nimport PageTitle from '../Typography/PageTitle';\nimport Text from '../Typography/Text';\nimport { safeHref } from '../safeHref';\nimport {\n CARD_CLASSES,\n CARD_MIN_HEIGHT,\n CARD_RADIUS,\n CONTENT_INSET_VAR,\n CONTENT_MIN_HEIGHT,\n DIVIDER_CLASSES,\n HEADER_HEIGHT,\n} from './constants';\nimport type { BreadcrumbLink, PageAction, RenderLink } from './types';\n\nexport type PageContentGap = 'small' | 'medium' | 'large' | 'xlarge';\n\nexport type PageContentWidth = 'narrow';\n\nexport interface RegularLayoutProps {\n breadcrumbLinks?: BreadcrumbLink[];\n breadcrumbActions?: PageAction[];\n renderLink?: RenderLink;\n title?: React.ReactNode;\n titleSuffix?: React.ReactNode;\n subtitle?: string;\n description?: React.ReactNode;\n buttons?: PageAction[];\n /**\n * Hides the buttons and skeletons the title. `subtitle` and `description` are only\n * skeletoned when those props are also passed.\n */\n loading?: boolean;\n children: React.ReactNode;\n centered?: boolean;\n noPadding?: boolean;\n contentGap?: PageContentGap;\n /** Caps the content column and centres it; `narrow` fits a single-column form. */\n contentWidth?: PageContentWidth;\n alert?: { message: string; type?: AlertType };\n /** Demotes the default `main` landmark — pass e.g. `region` when the app owns its own. */\n role?: React.AriaRole;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst CONTENT_WIDTHS: Record<PageContentWidth, number> = {\n narrow: 520,\n};\n\nconst CONTENT_GAPS: Record<PageContentGap, number> = {\n small: 8,\n medium: 16,\n large: 24,\n xlarge: 40,\n};\n\nconst isDanger = (button: PageAction): boolean =>\n button.variant === 'destructive' || button.variant === 'error';\n\nconst toMenuItems = (buttons: PageAction[]): ActionMenuItem[] =>\n buttons.flatMap((button, index) => {\n const href = safeHref(button.href);\n const item: ActionMenuItem = {\n key: `${index}-${button.label}`,\n label: button.label,\n ...(href ? { href, target: button.target ?? '_blank' } : { onClick: button.onClick }),\n disabled: button.disabled,\n icon: button.icon,\n tooltip: button.tooltip,\n danger: isDanger(button),\n };\n return button.dividerBefore && index > 0\n ? [{ type: 'divider' as const, key: `divider-${index}-${button.label}` }, item]\n : [item];\n });\n\n// Not `ActionBar`: it measures by walking ancestors for `clientWidth`, and this chrome\n// mounts on every page. OverflowRow batches its measurement instead.\n// A divider must live in the same OverflowRow child as its button — a standalone child\n// would survive its hidden button and break the child-index-to-button mapping.\n/**\n * The page's action buttons, collapsing into an overflow menu as the row narrows. Exported so\n * a page that renders its own header block — e.g. one that scrolls the title away — keeps the\n * same behaviour instead of hand-rolling `buttons.map(...)` and losing the collapse, the\n * dividers and the href handling.\n */\nexport const PageActions: React.FC<{ buttons: PageAction[] }> = ({ buttons }) => {\n if (buttons.length === 0) {\n return null;\n }\n\n // min-w-0 gives OverflowRow a shrinkable container to collapse against.\n return (\n <div className=\"min-w-0\">\n <OverflowRow\n gap={8}\n justify=\"end\"\n renderOverflow={(hiddenCount) => (\n <ActionMenu\n items={toMenuItems(\n buttons.slice(Math.max(0, buttons.length - hiddenCount)),\n )}\n />\n )}\n >\n {buttons.map((button, index) => {\n const href = safeHref(button.href);\n return (\n <div key={`${index}-${button.label}`} className=\"flex items-center gap-2\">\n {button.dividerBefore && index > 0 ? (\n <span\n aria-hidden=\"true\"\n className=\"h-4 w-px bg-[var(--malachite-card-border)]\"\n />\n ) : null}\n <Button\n variant={button.variant ?? 'filled'}\n size=\"medium\"\n disabled={button.disabled}\n icon={button.icon}\n tooltip={button.tooltip}\n tooltipPlacement={button.tooltipPlacement}\n href={href}\n target={href ? (button.target ?? '_blank') : undefined}\n onClick={href ? undefined : button.onClick}\n >\n {button.label}\n </Button>\n </div>\n );\n })}\n </OverflowRow>\n </div>\n );\n};\n\nconst NO_LINKS: BreadcrumbLink[] = [];\nconst NO_BUTTONS: PageAction[] = [];\n\nconst RegularLayout: React.FC<RegularLayoutProps> = ({\n breadcrumbLinks = NO_LINKS,\n breadcrumbActions,\n renderLink,\n title,\n titleSuffix,\n subtitle,\n description,\n buttons = NO_BUTTONS,\n loading = false,\n children,\n centered = false,\n noPadding = false,\n contentGap = 'small',\n contentWidth,\n alert,\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n style,\n}) => {\n const hasBack = hasBackButton(breadcrumbLinks);\n const contentPadding = noPadding ? 0 : centered ? '5vh 14vw' : '40px';\n // Published so a full-bleed child (CardStrip's bottom rule) can cancel it and re-apply\n // it as its own padding, instead of hardcoding the gutter at the call site.\n const contentInset = noPadding ? '0px' : centered ? '14vw' : '40px';\n const hasHeaderBlock = Boolean(\n loading || title || subtitle || description || buttons.length > 0,\n );\n\n const subtitleNode = subtitle ? (\n loading ? (\n <Skeleton.Input width={120} height={24} />\n ) : (\n <Text color=\"secondary\" size=\"small\">\n {subtitle}\n </Text>\n )\n ) : null;\n\n const titleNode = loading ? (\n <Skeleton.Input width={200} height={40} />\n ) : title ? (\n <div className=\"flex items-center\" style={{ gap: 12 }}>\n <PageTitle>{title}</PageTitle>\n {titleSuffix}\n </div>\n ) : null;\n\n const descriptionNode = description ? (\n loading ? (\n <Skeleton.Input width={120} height={24} />\n ) : (\n <Text color=\"secondary\" style={{ lineHeight: 1.6 }}>\n {description}\n </Text>\n )\n ) : null;\n\n const headerBlock = hasHeaderBlock ? (\n <div className=\"flex flex-col\" style={{ gap: 12 }}>\n {titleNode || subtitleNode || buttons.length > 0 ? (\n <div className=\"flex flex-wrap items-center justify-between\" style={{ gap: 12 }}>\n <div\n className=\"flex flex-col flex-auto min-w-0 overflow-hidden\"\n style={{ gap: 4 }}\n >\n {subtitleNode}\n {titleNode}\n </div>\n {loading ? null : <PageActions buttons={buttons} />}\n </div>\n ) : null}\n {descriptionNode}\n </div>\n ) : null;\n\n const body = (\n <>\n {headerBlock}\n {children}\n </>\n );\n\n return (\n <main\n className={`${CARD_CLASSES} ${className}`}\n style={{ borderRadius: CARD_RADIUS, minHeight: CARD_MIN_HEIGHT, ...style }}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-busy={loading || undefined}\n >\n <div\n className={`flex items-center ${DIVIDER_CLASSES}`}\n style={{\n height: HEADER_HEIGHT,\n paddingInlineStart: hasBack ? 16 : 28,\n paddingInlineEnd: 16,\n }}\n >\n <Breadcrumbs\n links={breadcrumbLinks}\n actions={breadcrumbActions}\n renderLink={renderLink}\n titleElement={title && !loading ? undefined : 'h1'}\n className=\"flex-1 min-w-0\"\n />\n </div>\n\n {alert ? (\n <div className={DIVIDER_CLASSES} style={{ padding: '10px 16px' }}>\n <Alert message={alert.message} type={alert.type} hasMargin={false} />\n </div>\n ) : null}\n\n <div\n className=\"flex flex-col\"\n style={\n {\n padding: contentPadding,\n minHeight: CONTENT_MIN_HEIGHT,\n gap: CONTENT_GAPS[contentGap],\n [CONTENT_INSET_VAR]: contentInset,\n } as React.CSSProperties\n }\n >\n {contentWidth ? (\n <div\n className=\"flex flex-col flex-1 w-full\"\n style={\n {\n maxWidth: CONTENT_WIDTHS[contentWidth],\n marginInline: 'auto',\n gap: CONTENT_GAPS[contentGap],\n [CONTENT_INSET_VAR]: '0px',\n } as React.CSSProperties\n }\n >\n {body}\n </div>\n ) : (\n body\n )}\n </div>\n </main>\n );\n};\n\nexport default RegularLayout;\nexport { RegularLayout };\n"],"names":["CONTENT_WIDTHS","CONTENT_GAPS","isDanger","button","toMenuItems","buttons","index","href","safeHref","item","PageActions","jsx","OverflowRow","hiddenCount","ActionMenu","jsxs","Button","NO_LINKS","NO_BUTTONS","RegularLayout","breadcrumbLinks","breadcrumbActions","renderLink","title","titleSuffix","subtitle","description","loading","children","centered","noPadding","contentGap","contentWidth","alert","role","ariaLabel","ariaLabelledBy","className","style","hasBack","hasBackButton","contentPadding","contentInset","hasHeaderBlock","subtitleNode","Skeleton","Text","titleNode","PageTitle","descriptionNode","headerBlock","body","Fragment","CARD_CLASSES","CARD_RADIUS","CARD_MIN_HEIGHT","DIVIDER_CLASSES","HEADER_HEIGHT","Breadcrumbs","Alert","CONTENT_MIN_HEIGHT","CONTENT_INSET_VAR"],"mappings":";;;;;;;;;;;;AAuDA,MAAMA,IAAmD;AAAA,EACrD,QAAQ;AACZ,GAEMC,IAA+C;AAAA,EACjD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACZ,GAEMC,IAAW,CAACC,MACdA,EAAO,YAAY,iBAAiBA,EAAO,YAAY,SAErDC,IAAc,CAACC,MACjBA,EAAQ,QAAQ,CAACF,GAAQG,MAAU;AA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","sources":["../../../src/components/PageLayout/regularLayout.tsx"],"sourcesContent":["import React from 'react';\nimport ActionMenu, { type ActionMenuItem } from '../ActionMenu';\nimport Alert, { type AlertType } from '../Alert';\nimport Breadcrumbs from '../Breadcrumbs';\nimport { hasBackButton } from '../breadcrumbsNav';\nimport Button from '../Button';\nimport OverflowRow from '../OverflowRow';\nimport Skeleton from '../Skeleton';\nimport PageTitle from '../Typography/PageTitle';\nimport Text from '../Typography/Text';\nimport { safeHref } from '../safeHref';\nimport {\n CARD_CLASSES,\n CARD_MIN_HEIGHT,\n CARD_RADIUS,\n CONTENT_INSET_VAR,\n CONTENT_MIN_HEIGHT,\n DIVIDER_CLASSES,\n HEADER_HEIGHT,\n} from './constants';\nimport { CONTENT_GAPS, PageColumn, type PageContentGap, type PageContentWidth } from './pageColumn';\nimport type { BreadcrumbLink, PageAction, RenderLink } from './types';\n\nexport type { PageContentGap, PageContentWidth };\n\nexport interface RegularLayoutProps {\n breadcrumbLinks?: BreadcrumbLink[];\n breadcrumbActions?: PageAction[];\n renderLink?: RenderLink;\n title?: React.ReactNode;\n titleSuffix?: React.ReactNode;\n subtitle?: string;\n description?: React.ReactNode;\n buttons?: PageAction[];\n /**\n * Hides the buttons and skeletons the title. `subtitle` and `description` are only\n * skeletoned when those props are also passed.\n */\n loading?: boolean;\n children: React.ReactNode;\n centered?: boolean;\n noPadding?: boolean;\n contentGap?: PageContentGap;\n /** Caps the content column and centres it; `narrow` fits a single-column form. */\n contentWidth?: PageContentWidth;\n alert?: { message: string; type?: AlertType };\n /** Demotes the default `main` landmark — pass e.g. `region` when the app owns its own. */\n role?: React.AriaRole;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst isDanger = (button: PageAction): boolean =>\n button.variant === 'destructive' || button.variant === 'error';\n\nconst toMenuItems = (buttons: PageAction[]): ActionMenuItem[] =>\n buttons.flatMap((button, index) => {\n const href = safeHref(button.href);\n const item: ActionMenuItem = {\n key: `${index}-${button.label}`,\n label: button.label,\n ...(href ? { href, target: button.target ?? '_blank' } : { onClick: button.onClick }),\n disabled: button.disabled,\n icon: button.icon,\n tooltip: button.tooltip,\n danger: isDanger(button),\n };\n return button.dividerBefore && index > 0\n ? [{ type: 'divider' as const, key: `divider-${index}-${button.label}` }, item]\n : [item];\n });\n\n// Not `ActionBar`: it measures by walking ancestors for `clientWidth`, and this chrome\n// mounts on every page. OverflowRow batches its measurement instead.\n// A divider must live in the same OverflowRow child as its button — a standalone child\n// would survive its hidden button and break the child-index-to-button mapping.\n/**\n * The page's action buttons, collapsing into an overflow menu as the row narrows. Exported so\n * a page that renders its own header block — e.g. one that scrolls the title away — keeps the\n * same behaviour instead of hand-rolling `buttons.map(...)` and losing the collapse, the\n * dividers and the href handling.\n */\nexport const PageActions: React.FC<{ buttons: PageAction[] }> = ({ buttons }) => {\n if (buttons.length === 0) {\n return null;\n }\n\n // min-w-0 gives OverflowRow a shrinkable container to collapse against.\n return (\n <div className=\"min-w-0\">\n <OverflowRow\n gap={8}\n justify=\"end\"\n renderOverflow={(hiddenCount) => (\n <ActionMenu\n items={toMenuItems(\n buttons.slice(Math.max(0, buttons.length - hiddenCount)),\n )}\n />\n )}\n >\n {buttons.map((button, index) => {\n const href = safeHref(button.href);\n return (\n <div key={`${index}-${button.label}`} className=\"flex items-center gap-2\">\n {button.dividerBefore && index > 0 ? (\n <span\n aria-hidden=\"true\"\n className=\"h-4 w-px bg-[var(--malachite-card-border)]\"\n />\n ) : null}\n <Button\n variant={button.variant ?? 'filled'}\n size=\"medium\"\n disabled={button.disabled}\n icon={button.icon}\n tooltip={button.tooltip}\n tooltipPlacement={button.tooltipPlacement}\n href={href}\n target={href ? (button.target ?? '_blank') : undefined}\n onClick={href ? undefined : button.onClick}\n >\n {button.label}\n </Button>\n </div>\n );\n })}\n </OverflowRow>\n </div>\n );\n};\n\nconst NO_LINKS: BreadcrumbLink[] = [];\nconst NO_BUTTONS: PageAction[] = [];\n\nconst RegularLayout: React.FC<RegularLayoutProps> = ({\n breadcrumbLinks = NO_LINKS,\n breadcrumbActions,\n renderLink,\n title,\n titleSuffix,\n subtitle,\n description,\n buttons = NO_BUTTONS,\n loading = false,\n children,\n centered = false,\n noPadding = false,\n contentGap = 'small',\n contentWidth,\n alert,\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n style,\n}) => {\n const hasBack = hasBackButton(breadcrumbLinks);\n const contentPadding = noPadding ? 0 : centered ? '5vh 14vw' : '40px';\n // Published so a full-bleed child (CardStrip's bottom rule) can cancel it and re-apply\n // it as its own padding, instead of hardcoding the gutter at the call site.\n const contentInset = noPadding ? '0px' : centered ? '14vw' : '40px';\n const hasHeaderBlock = Boolean(\n loading || title || subtitle || description || buttons.length > 0,\n );\n\n const subtitleNode = subtitle ? (\n loading ? (\n <Skeleton.Input width={120} height={24} />\n ) : (\n <Text color=\"secondary\" size=\"small\">\n {subtitle}\n </Text>\n )\n ) : null;\n\n const titleNode = loading ? (\n <Skeleton.Input width={200} height={40} />\n ) : title ? (\n <div className=\"flex items-center\" style={{ gap: 12 }}>\n <PageTitle>{title}</PageTitle>\n {titleSuffix}\n </div>\n ) : null;\n\n const descriptionNode = description ? (\n loading ? (\n <Skeleton.Input width={120} height={24} />\n ) : (\n <Text color=\"secondary\" style={{ lineHeight: 1.6 }}>\n {description}\n </Text>\n )\n ) : null;\n\n const headerBlock = hasHeaderBlock ? (\n <div className=\"flex flex-col\" style={{ gap: 12 }}>\n {titleNode || subtitleNode || buttons.length > 0 ? (\n <div className=\"flex flex-wrap items-center justify-between\" style={{ gap: 12 }}>\n <div\n className=\"flex flex-col flex-auto min-w-0 overflow-hidden\"\n style={{ gap: 4 }}\n >\n {subtitleNode}\n {titleNode}\n </div>\n {loading ? null : <PageActions buttons={buttons} />}\n </div>\n ) : null}\n {descriptionNode}\n </div>\n ) : null;\n\n const body = (\n <>\n {headerBlock}\n {children}\n </>\n );\n\n return (\n <main\n className={`${CARD_CLASSES} ${className}`}\n style={{ borderRadius: CARD_RADIUS, minHeight: CARD_MIN_HEIGHT, ...style }}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-busy={loading || undefined}\n >\n <div\n className={`flex items-center ${DIVIDER_CLASSES}`}\n style={{\n height: HEADER_HEIGHT,\n paddingInlineStart: hasBack ? 16 : 28,\n paddingInlineEnd: 16,\n }}\n >\n <Breadcrumbs\n links={breadcrumbLinks}\n actions={breadcrumbActions}\n renderLink={renderLink}\n titleElement={title && !loading ? undefined : 'h1'}\n className=\"flex-1 min-w-0\"\n />\n </div>\n\n {alert ? (\n <div className={DIVIDER_CLASSES} style={{ padding: '10px 16px' }}>\n <Alert message={alert.message} type={alert.type} hasMargin={false} />\n </div>\n ) : null}\n\n <div\n className=\"flex flex-col\"\n style={\n {\n padding: contentPadding,\n minHeight: CONTENT_MIN_HEIGHT,\n gap: CONTENT_GAPS[contentGap],\n [CONTENT_INSET_VAR]: contentInset,\n } as React.CSSProperties\n }\n >\n {contentWidth ? (\n <PageColumn width={contentWidth} gap={contentGap}>\n {body}\n </PageColumn>\n ) : (\n body\n )}\n </div>\n </main>\n );\n};\n\nexport default RegularLayout;\nexport { RegularLayout };\n"],"names":["isDanger","button","toMenuItems","buttons","index","href","safeHref","item","PageActions","jsx","OverflowRow","hiddenCount","ActionMenu","jsxs","Button","NO_LINKS","NO_BUTTONS","RegularLayout","breadcrumbLinks","breadcrumbActions","renderLink","title","titleSuffix","subtitle","description","loading","children","centered","noPadding","contentGap","contentWidth","alert","role","ariaLabel","ariaLabelledBy","className","style","hasBack","hasBackButton","contentPadding","contentInset","hasHeaderBlock","subtitleNode","Skeleton","Text","titleNode","PageTitle","descriptionNode","headerBlock","body","Fragment","CARD_CLASSES","CARD_RADIUS","CARD_MIN_HEIGHT","DIVIDER_CLASSES","HEADER_HEIGHT","Breadcrumbs","Alert","CONTENT_MIN_HEIGHT","CONTENT_GAPS","CONTENT_INSET_VAR","PageColum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
4609
|
buttons: PageAction[];
|
|
4610
4610
|
}>;
|
|
4611
4611
|
|
|
4612
|
+
export declare interface PageColumnProps {
|
|
4613
|
+
/** `narrow` fits a single-column form. */
|
|
4614
|
+
width: PageContentWidth;
|
|
4615
|
+
gap?: PageContentGap;
|
|
4616
|
+
/**
|
|
4617
|
+
* For a page rendered without `PageLayout.Regular` around it: adds 40px above and below and
|
|
4618
|
+
* 16px side gutters, so the column keeps clear of the viewport edges on a phone.
|
|
4619
|
+
*/
|
|
4620
|
+
standalone?: boolean;
|
|
4621
|
+
children: default_2.ReactNode;
|
|
4622
|
+
className?: string;
|
|
4623
|
+
}
|
|
4624
|
+
|
|
4612
4625
|
export declare type PageContentGap = 'small' | 'medium' | 'large' | 'xlarge';
|
|
4613
4626
|
|
|
4614
4627
|
export declare type PageContentWidth = 'narrow';
|
|
@@ -4616,6 +4629,7 @@ export declare type PageContentWidth = 'narrow';
|
|
|
4616
4629
|
export declare const PageLayout: {
|
|
4617
4630
|
Regular: FC<RegularLayoutProps>;
|
|
4618
4631
|
Empty: FC<EmptyLayoutProps>;
|
|
4632
|
+
Column: FC<PageColumnProps>;
|
|
4619
4633
|
};
|
|
4620
4634
|
|
|
4621
4635
|
declare interface PageTitleProps {
|