@flipdish/ui-library 0.53.1 → 0.54.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/dist/components/layouts/AppShell/hooks/usePageAreaBounds.cjs.map +1 -0
- package/dist/components/layouts/AppShell/hooks/usePageAreaBounds.d.ts.map +1 -0
- package/dist/components/layouts/AppShell/hooks/usePageAreaBounds.js.map +1 -0
- package/dist/components/layouts/AppShell/hooks/usePageCover.cjs.map +1 -0
- package/dist/components/layouts/AppShell/hooks/usePageCover.d.ts.map +1 -0
- package/dist/components/layouts/AppShell/hooks/usePageCover.js.map +1 -0
- package/dist/components/layouts/AppShell/index.cjs +40 -0
- package/dist/components/layouts/AppShell/index.cjs.map +1 -0
- package/dist/components/layouts/AppShell/index.d.ts +40 -0
- package/dist/components/layouts/AppShell/index.d.ts.map +1 -0
- package/dist/components/layouts/AppShell/index.js +38 -0
- package/dist/components/layouts/AppShell/index.js.map +1 -0
- package/dist/components/layouts/PageHubLayout/components/PageHubLayoutSectionNav.cjs.map +1 -0
- package/dist/components/layouts/PageHubLayout/components/PageHubLayoutSectionNav.d.ts.map +1 -0
- package/dist/components/layouts/PageHubLayout/components/PageHubLayoutSectionNav.js.map +1 -0
- package/dist/components/layouts/PageHubLayout/index.cjs +65 -0
- package/dist/components/layouts/PageHubLayout/index.cjs.map +1 -0
- package/dist/components/layouts/PageHubLayout/index.d.ts +56 -0
- package/dist/components/layouts/PageHubLayout/index.d.ts.map +1 -0
- package/dist/components/layouts/PageHubLayout/index.js +63 -0
- package/dist/components/layouts/PageHubLayout/index.js.map +1 -0
- package/dist/components/layouts/PageHubLayout/pageHubLayout.types.d.ts.map +1 -0
- package/dist/components/layouts/PageHubLayout/utilities/pageHubLayout.utils.cjs.map +1 -0
- package/dist/components/{templates/PageHubLayout → layouts/PageHubLayout/utilities}/pageHubLayout.utils.d.ts +1 -1
- package/dist/components/layouts/PageHubLayout/utilities/pageHubLayout.utils.d.ts.map +1 -0
- package/dist/components/layouts/PageHubLayout/utilities/pageHubLayout.utils.js.map +1 -0
- package/dist/components/layouts/PageLayout/index.cjs +31 -0
- package/dist/components/layouts/PageLayout/index.cjs.map +1 -0
- package/dist/components/layouts/PageLayout/index.d.ts +44 -0
- package/dist/components/layouts/PageLayout/index.d.ts.map +1 -0
- package/dist/components/layouts/PageLayout/index.js +29 -0
- package/dist/components/layouts/PageLayout/index.js.map +1 -0
- package/dist/components/layouts/WidgetLayout/index.cjs +42 -0
- package/dist/components/layouts/WidgetLayout/index.cjs.map +1 -0
- package/dist/components/layouts/WidgetLayout/index.d.ts +57 -0
- package/dist/components/layouts/WidgetLayout/index.d.ts.map +1 -0
- package/dist/components/layouts/WidgetLayout/index.js +40 -0
- package/dist/components/layouts/WidgetLayout/index.js.map +1 -0
- package/dist/components/templates/AppShell/index.cjs +3 -34
- package/dist/components/templates/AppShell/index.cjs.map +1 -1
- package/dist/components/templates/AppShell/index.d.ts +7 -39
- package/dist/components/templates/AppShell/index.d.ts.map +1 -1
- package/dist/components/templates/AppShell/index.js +3 -34
- package/dist/components/templates/AppShell/index.js.map +1 -1
- package/dist/components/templates/PageHubLayout/index.cjs +3 -59
- package/dist/components/templates/PageHubLayout/index.cjs.map +1 -1
- package/dist/components/templates/PageHubLayout/index.d.ts +7 -55
- package/dist/components/templates/PageHubLayout/index.d.ts.map +1 -1
- package/dist/components/templates/PageHubLayout/index.js +3 -59
- package/dist/components/templates/PageHubLayout/index.js.map +1 -1
- package/dist/components/templates/PageLayout/index.cjs +3 -25
- package/dist/components/templates/PageLayout/index.cjs.map +1 -1
- package/dist/components/templates/PageLayout/index.d.ts +5 -42
- package/dist/components/templates/PageLayout/index.d.ts.map +1 -1
- package/dist/components/templates/PageLayout/index.js +3 -25
- package/dist/components/templates/PageLayout/index.js.map +1 -1
- package/dist/components/templates/WidgetLayout/index.cjs +3 -36
- package/dist/components/templates/WidgetLayout/index.cjs.map +1 -1
- package/dist/components/templates/WidgetLayout/index.d.ts +7 -56
- package/dist/components/templates/WidgetLayout/index.d.ts.map +1 -1
- package/dist/components/templates/WidgetLayout/index.js +3 -36
- package/dist/components/templates/WidgetLayout/index.js.map +1 -1
- package/dist/native/components/layouts/AppShell/index.d.ts +12 -0
- package/dist/native/components/layouts/PageHubLayout/index.d.ts +12 -0
- package/dist/native/components/layouts/PageLayout/index.d.ts +12 -0
- package/dist/native/components/layouts/WidgetLayout/index.d.ts +12 -0
- package/package.json +10 -1
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.cjs.map +0 -1
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.d.ts.map +0 -1
- package/dist/components/templates/AppShell/hooks/usePageAreaBounds.js.map +0 -1
- package/dist/components/templates/AppShell/hooks/usePageCover.cjs.map +0 -1
- package/dist/components/templates/AppShell/hooks/usePageCover.d.ts.map +0 -1
- package/dist/components/templates/AppShell/hooks/usePageCover.js.map +0 -1
- package/dist/components/templates/PageHubLayout/components/PageHubLayoutSectionNav.cjs.map +0 -1
- package/dist/components/templates/PageHubLayout/components/PageHubLayoutSectionNav.d.ts.map +0 -1
- package/dist/components/templates/PageHubLayout/components/PageHubLayoutSectionNav.js.map +0 -1
- package/dist/components/templates/PageHubLayout/pageHubLayout.types.d.ts.map +0 -1
- package/dist/components/templates/PageHubLayout/pageHubLayout.utils.cjs.map +0 -1
- package/dist/components/templates/PageHubLayout/pageHubLayout.utils.d.ts.map +0 -1
- package/dist/components/templates/PageHubLayout/pageHubLayout.utils.js.map +0 -1
- /package/dist/components/{templates → layouts}/AppShell/hooks/usePageAreaBounds.cjs +0 -0
- /package/dist/components/{templates → layouts}/AppShell/hooks/usePageAreaBounds.d.ts +0 -0
- /package/dist/components/{templates → layouts}/AppShell/hooks/usePageAreaBounds.js +0 -0
- /package/dist/components/{templates → layouts}/AppShell/hooks/usePageCover.cjs +0 -0
- /package/dist/components/{templates → layouts}/AppShell/hooks/usePageCover.d.ts +0 -0
- /package/dist/components/{templates → layouts}/AppShell/hooks/usePageCover.js +0 -0
- /package/dist/components/{templates → layouts}/PageHubLayout/components/PageHubLayoutSectionNav.cjs +0 -0
- /package/dist/components/{templates → layouts}/PageHubLayout/components/PageHubLayoutSectionNav.d.ts +0 -0
- /package/dist/components/{templates → layouts}/PageHubLayout/components/PageHubLayoutSectionNav.js +0 -0
- /package/dist/components/{templates → layouts}/PageHubLayout/pageHubLayout.types.d.ts +0 -0
- /package/dist/components/{templates/PageHubLayout → layouts/PageHubLayout/utilities}/pageHubLayout.utils.cjs +0 -0
- /package/dist/components/{templates/PageHubLayout → layouts/PageHubLayout/utilities}/pageHubLayout.utils.js +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var ErrorBoundary = require('@flipdish/ui-library/providers/ErrorBoundary');
|
|
5
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
|
+
|
|
8
|
+
/** English fallback copy — consumers localise via `renderError`. TODO(i18n): source from ui-library's translation layer once one exists. */
|
|
9
|
+
const DefaultWidgetError = ({ testId }) => (jsxRuntime.jsxs("div", { role: "alert", "data-testid": testId, className: "flex w-full flex-col items-center gap-2 py-xl text-center", children: [jsxRuntime.jsx("h2", { className: "font-semibold text-md text-primary", children: "Something went wrong" }), jsxRuntime.jsx("p", { className: "text-sm text-tertiary", children: "An unexpected error occurred in this widget." })] }));
|
|
10
|
+
/**
|
|
11
|
+
* Widget-shaped layout for a micro-frontend mounted beside a page: a named `region` that fills
|
|
12
|
+
* the height its host gives it, with pinned `header` and `footer` slots around a content area
|
|
13
|
+
* that scrolls internally, and an error boundary keyed by `widgetName`. Reach for it instead of
|
|
14
|
+
* `PageLayout` whenever the host page already owns `<main>` and the document must not scroll.
|
|
15
|
+
*
|
|
16
|
+
* @summary bounded-height widget layout with pinned header and footer
|
|
17
|
+
*/
|
|
18
|
+
const WidgetLayout = ({ widgetName, label, header, footer, children, renderError, onError, scrollAreaProps, className, 'data-testid': dataTestId, }) => {
|
|
19
|
+
const widgetLayoutTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'widget-layout', rootName: 'widget-layout' });
|
|
20
|
+
const scrollAreaTestId = scrollAreaProps?.['data-testid'] ?? testIdUtils.joinTestId(widgetLayoutTestId, 'scroll-area');
|
|
21
|
+
// A `<section>` with an accessible name is a `region` landmark; without a name it is a plain `div`, so a
|
|
22
|
+
// host that already provides the landmark does not get a nested, same-named one.
|
|
23
|
+
const Root = label ? 'section' : 'div';
|
|
24
|
+
return (
|
|
25
|
+
// `h-full`, never a viewport unit: the host supplies the bounded height, and WebView viewport units can
|
|
26
|
+
// disagree with the visible area. `min-h-0` lets the scroll region shrink below its content's height.
|
|
27
|
+
jsxRuntime.jsxs(Root, { "aria-label": label, "data-testid": widgetLayoutTestId, className: cx.cx('flex h-full min-h-0 w-full flex-col gap-md p-md pb-[max(var(--spacing-md),env(safe-area-inset-bottom))]', className), children: [header, jsxRuntime.jsx("div", { id: scrollAreaProps?.id, ref: scrollAreaProps?.ref, "data-testid": scrollAreaTestId,
|
|
28
|
+
// Focusable so keyboard users can scroll content that has no focusable element of its own (axe: scrollable-region-focusable).
|
|
29
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard
|
|
30
|
+
tabIndex: 0,
|
|
31
|
+
// `overscroll-contain` keeps a scroll that reaches the end from chaining to the host page.
|
|
32
|
+
className: cx.cx('min-h-0 flex-1 overflow-y-auto overscroll-contain outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2', scrollAreaProps?.className), children: jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { identifier: widgetName, onError: onError, renderFallback: (error) => {
|
|
33
|
+
// `undefined`, not nullish: an explicit `null` from `renderError` is honoured as "render nothing".
|
|
34
|
+
const customFallback = renderError?.({ error, widgetName });
|
|
35
|
+
if (customFallback !== undefined)
|
|
36
|
+
return customFallback;
|
|
37
|
+
return jsxRuntime.jsx(DefaultWidgetError, { testId: testIdUtils.joinTestId(widgetLayoutTestId, 'error') });
|
|
38
|
+
}, children: children }) }), footer] }));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.WidgetLayout = WidgetLayout;
|
|
42
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/layouts/WidgetLayout/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx","useResolvedTestId","joinTestId","cx","ErrorBoundary"],"mappings":";;;;;;;AAoDA;AACA,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAuB,MACzDA,eAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAC,OAAO,iBAAc,MAAM,EAAE,SAAS,EAAC,2DAA2D,EAAA,QAAA,EAAA,CAC1GC,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,oCAAoC,EAAA,QAAA,EAAA,sBAAA,EAAA,CAA0B,EAC5EA,cAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,uBAAuB,EAAA,QAAA,EAAA,8CAAA,EAAA,CAAiD,CAAA,EAAA,CACjF,CACP;AAED;;;;;;;AAOG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,WAAW,EACX,OAAO,EACP,eAAe,EACf,SAAS,EACT,aAAa,EAAE,UAAU,GACP,KAAe;AACjC,IAAA,MAAM,kBAAkB,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;AACzH,IAAA,MAAM,gBAAgB,GAAG,eAAe,GAAG,aAAa,CAAC,IAAIC,sBAAU,CAAC,kBAAkB,EAAE,aAAa,CAAC;;;IAG1G,MAAM,IAAI,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK;IAEtC;;;AAGE,IAAAH,eAAA,CAAC,IAAI,EAAA,EAAA,YAAA,EACS,KAAK,EAAA,aAAA,EACJ,kBAAkB,EAC/B,SAAS,EAAEI,KAAE,CAAC,yGAAyG,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAElI,MAAM,EAEPH,cAAA,CAAA,KAAA,EAAA,EACE,EAAE,EAAE,eAAe,EAAE,EAAE,EACvB,GAAG,EAAE,eAAe,EAAE,GAAG,iBACZ,gBAAgB;;;AAG7B,gBAAA,QAAQ,EAAE,CAAC;;gBAEX,SAAS,EAAEG,KAAE,CACX,8HAA8H,EAC9H,eAAe,EAAE,SAAS,CAC3B,EAAA,QAAA,EAEDH,cAAA,CAACI,2BAAa,EAAA,EACZ,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,KAAK,KAAI;;wBAExB,MAAM,cAAc,GAAG,WAAW,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;wBAC3D,IAAI,cAAc,KAAK,SAAS;AAAE,4BAAA,OAAO,cAAc;AACvD,wBAAA,OAAOJ,cAAA,CAAC,kBAAkB,EAAA,EAAC,MAAM,EAAEE,sBAAU,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAAA,CAAI;oBAChF,CAAC,EAAA,QAAA,EAEA,QAAQ,EAAA,CACK,EAAA,CACZ,EAEL,MAAM,CAAA,EAAA,CACF;AAEX;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ErrorInfo, ReactNode, Ref } from 'react';
|
|
2
|
+
export interface WidgetLayoutScrollAreaProps {
|
|
3
|
+
/** `id` for the scrolling element, e.g. for a scroll-to-bottom helper that looks it up. */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Ref to the scrolling element, e.g. to keep a chat list pinned to its newest message. */
|
|
6
|
+
ref?: Ref<HTMLDivElement>;
|
|
7
|
+
/** Extra classes merged onto the scrolling element, e.g. a gap between messages. */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Overrides the scrolling element's `data-testid` (defaults to `<root>--scroll-area`). */
|
|
10
|
+
'data-testid'?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface WidgetLayoutProps {
|
|
13
|
+
/**
|
|
14
|
+
* Stable, human-readable name of the widget (e.g. "ChatWidget"). Tags the widget-scoped error
|
|
15
|
+
* boundary so a thrown error can be attributed in logs/RUM, and is forwarded to `renderError`
|
|
16
|
+
* and `onError`.
|
|
17
|
+
*/
|
|
18
|
+
widgetName: string;
|
|
19
|
+
/**
|
|
20
|
+
* Accessible name that makes the root a `region` landmark. Set it when the widget is the landmark,
|
|
21
|
+
* since the host page already owns `<main>`; omit it when the host already wraps the widget in a named
|
|
22
|
+
* landmark such as `SidePanel`, so the root is a plain `div` and no nested region repeats the name.
|
|
23
|
+
*/
|
|
24
|
+
label?: string;
|
|
25
|
+
/** Pinned above the scroll region and rendered OUTSIDE the error boundary, so a title or close control stays usable when content throws. */
|
|
26
|
+
header?: ReactNode;
|
|
27
|
+
/** Pinned below the scroll region and rendered OUTSIDE the error boundary; the composer slot. Keeps clear of the device's bottom safe area. */
|
|
28
|
+
footer?: ReactNode;
|
|
29
|
+
/** Widget content, rendered INSIDE the error boundary and the scroll region. */
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Replaces the default fallback shown when a child throws. Receives the thrown error and `widgetName` so consumers can render
|
|
33
|
+
* localised copy. Return `null` to render nothing, or `undefined` to keep the default fallback.
|
|
34
|
+
*/
|
|
35
|
+
renderError?: (props: {
|
|
36
|
+
error: Error;
|
|
37
|
+
widgetName: string;
|
|
38
|
+
}) => ReactNode;
|
|
39
|
+
/** Called when a child throws — wire app-level reporting (e.g. Datadog RUM) here. */
|
|
40
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
41
|
+
/** Hooks for the element that scrolls the content, since the host's bounded height means the widget never scrolls the document. */
|
|
42
|
+
scrollAreaProps?: WidgetLayoutScrollAreaProps;
|
|
43
|
+
/** Extra classes merged onto the root `<section>`. */
|
|
44
|
+
className?: string;
|
|
45
|
+
/** Overrides the `data-testid` (defaults to `fd-widget-layout`). */
|
|
46
|
+
'data-testid'?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Widget-shaped layout for a micro-frontend mounted beside a page: a named `region` that fills
|
|
50
|
+
* the height its host gives it, with pinned `header` and `footer` slots around a content area
|
|
51
|
+
* that scrolls internally, and an error boundary keyed by `widgetName`. Reach for it instead of
|
|
52
|
+
* `PageLayout` whenever the host page already owns `<main>` and the document must not scroll.
|
|
53
|
+
*
|
|
54
|
+
* @summary bounded-height widget layout with pinned header and footer
|
|
55
|
+
*/
|
|
56
|
+
export declare const WidgetLayout: ({ widgetName, label, header, footer, children, renderError, onError, scrollAreaProps, className, "data-testid": dataTestId, }: WidgetLayoutProps) => ReactNode;
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/WidgetLayout/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,WAAW,2BAA2B;IAC1C,2FAA2F;IAC3F,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2FAA2F;IAC3F,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4IAA4I;IAC5I,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,+IAA+I;IAC/I,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gFAAgF;IAChF,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAC;IACzE,qFAAqF;IACrF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAClD,mIAAmI;IACnI,eAAe,CAAC,EAAE,2BAA2B,CAAC;IAC9C,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,+HAW1B,iBAAiB,KAAG,SA+CtB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ErrorBoundary } from '@flipdish/ui-library/providers/ErrorBoundary';
|
|
3
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
|
+
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
|
+
|
|
6
|
+
/** English fallback copy — consumers localise via `renderError`. TODO(i18n): source from ui-library's translation layer once one exists. */
|
|
7
|
+
const DefaultWidgetError = ({ testId }) => (jsxs("div", { role: "alert", "data-testid": testId, className: "flex w-full flex-col items-center gap-2 py-xl text-center", children: [jsx("h2", { className: "font-semibold text-md text-primary", children: "Something went wrong" }), jsx("p", { className: "text-sm text-tertiary", children: "An unexpected error occurred in this widget." })] }));
|
|
8
|
+
/**
|
|
9
|
+
* Widget-shaped layout for a micro-frontend mounted beside a page: a named `region` that fills
|
|
10
|
+
* the height its host gives it, with pinned `header` and `footer` slots around a content area
|
|
11
|
+
* that scrolls internally, and an error boundary keyed by `widgetName`. Reach for it instead of
|
|
12
|
+
* `PageLayout` whenever the host page already owns `<main>` and the document must not scroll.
|
|
13
|
+
*
|
|
14
|
+
* @summary bounded-height widget layout with pinned header and footer
|
|
15
|
+
*/
|
|
16
|
+
const WidgetLayout = ({ widgetName, label, header, footer, children, renderError, onError, scrollAreaProps, className, 'data-testid': dataTestId, }) => {
|
|
17
|
+
const widgetLayoutTestId = useResolvedTestId({ testId: dataTestId, segment: 'widget-layout', rootName: 'widget-layout' });
|
|
18
|
+
const scrollAreaTestId = scrollAreaProps?.['data-testid'] ?? joinTestId(widgetLayoutTestId, 'scroll-area');
|
|
19
|
+
// A `<section>` with an accessible name is a `region` landmark; without a name it is a plain `div`, so a
|
|
20
|
+
// host that already provides the landmark does not get a nested, same-named one.
|
|
21
|
+
const Root = label ? 'section' : 'div';
|
|
22
|
+
return (
|
|
23
|
+
// `h-full`, never a viewport unit: the host supplies the bounded height, and WebView viewport units can
|
|
24
|
+
// disagree with the visible area. `min-h-0` lets the scroll region shrink below its content's height.
|
|
25
|
+
jsxs(Root, { "aria-label": label, "data-testid": widgetLayoutTestId, className: cx('flex h-full min-h-0 w-full flex-col gap-md p-md pb-[max(var(--spacing-md),env(safe-area-inset-bottom))]', className), children: [header, jsx("div", { id: scrollAreaProps?.id, ref: scrollAreaProps?.ref, "data-testid": scrollAreaTestId,
|
|
26
|
+
// Focusable so keyboard users can scroll content that has no focusable element of its own (axe: scrollable-region-focusable).
|
|
27
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard
|
|
28
|
+
tabIndex: 0,
|
|
29
|
+
// `overscroll-contain` keeps a scroll that reaches the end from chaining to the host page.
|
|
30
|
+
className: cx('min-h-0 flex-1 overflow-y-auto overscroll-contain outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2', scrollAreaProps?.className), children: jsx(ErrorBoundary, { identifier: widgetName, onError: onError, renderFallback: (error) => {
|
|
31
|
+
// `undefined`, not nullish: an explicit `null` from `renderError` is honoured as "render nothing".
|
|
32
|
+
const customFallback = renderError?.({ error, widgetName });
|
|
33
|
+
if (customFallback !== undefined)
|
|
34
|
+
return customFallback;
|
|
35
|
+
return jsx(DefaultWidgetError, { testId: joinTestId(widgetLayoutTestId, 'error') });
|
|
36
|
+
}, children: children }) }), footer] }));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { WidgetLayout };
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/layouts/WidgetLayout/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;AAoDA;AACA,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAuB,MACzDA,IAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAC,OAAO,iBAAc,MAAM,EAAE,SAAS,EAAC,2DAA2D,EAAA,QAAA,EAAA,CAC1GC,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,oCAAoC,EAAA,QAAA,EAAA,sBAAA,EAAA,CAA0B,EAC5EA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,uBAAuB,EAAA,QAAA,EAAA,8CAAA,EAAA,CAAiD,CAAA,EAAA,CACjF,CACP;AAED;;;;;;;AAOG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,WAAW,EACX,OAAO,EACP,eAAe,EACf,SAAS,EACT,aAAa,EAAE,UAAU,GACP,KAAe;AACjC,IAAA,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;AACzH,IAAA,MAAM,gBAAgB,GAAG,eAAe,GAAG,aAAa,CAAC,IAAI,UAAU,CAAC,kBAAkB,EAAE,aAAa,CAAC;;;IAG1G,MAAM,IAAI,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK;IAEtC;;;AAGE,IAAAD,IAAA,CAAC,IAAI,EAAA,EAAA,YAAA,EACS,KAAK,EAAA,aAAA,EACJ,kBAAkB,EAC/B,SAAS,EAAE,EAAE,CAAC,yGAAyG,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAElI,MAAM,EAEPC,GAAA,CAAA,KAAA,EAAA,EACE,EAAE,EAAE,eAAe,EAAE,EAAE,EACvB,GAAG,EAAE,eAAe,EAAE,GAAG,iBACZ,gBAAgB;;;AAG7B,gBAAA,QAAQ,EAAE,CAAC;;gBAEX,SAAS,EAAE,EAAE,CACX,8HAA8H,EAC9H,eAAe,EAAE,SAAS,CAC3B,EAAA,QAAA,EAEDA,GAAA,CAAC,aAAa,EAAA,EACZ,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,KAAK,KAAI;;wBAExB,MAAM,cAAc,GAAG,WAAW,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;wBAC3D,IAAI,cAAc,KAAK,SAAS;AAAE,4BAAA,OAAO,cAAc;AACvD,wBAAA,OAAOA,GAAA,CAAC,kBAAkB,EAAA,EAAC,MAAM,EAAE,UAAU,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAAA,CAAI;oBAChF,CAAC,EAAA,QAAA,EAEA,QAAQ,EAAA,CACK,EAAA,CACZ,EAEL,MAAM,CAAA,EAAA,CACF;AAEX;;"}
|
|
@@ -1,40 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
|
-
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var PageCover_context = require('../../organisms/SidePanel/providers/PageCover.context.cjs');
|
|
8
|
-
var OverlayBounds_context = require('../../organisms/SlideoutMenu/providers/OverlayBounds.context.cjs');
|
|
9
|
-
var PageArea_context = require('../../organisms/SlideoutMenu/providers/PageArea.context.cjs');
|
|
10
|
-
var usePageAreaBounds = require('./hooks/usePageAreaBounds.cjs');
|
|
11
|
-
var usePageCover = require('./hooks/usePageCover.cjs');
|
|
3
|
+
var AppShell$1 = require('@flipdish/ui-library/components/layouts/AppShell');
|
|
12
4
|
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
* above the page, with an optional side panel under the header. The shell is window-height and
|
|
16
|
-
* only the page area scrolls; it holds no state, so the app owns navigation, search and panel
|
|
17
|
-
* state.
|
|
18
|
-
*
|
|
19
|
-
* @summary window-height app shell layout with a scrolling page area
|
|
20
|
-
*/
|
|
21
|
-
const AppShell = ({ sidebar, header, panel, children, scrollAreaProps, className, 'data-testid': dataTestId }) => {
|
|
22
|
-
const appShellTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'app-shell', rootName: 'app-shell' });
|
|
23
|
-
// A `SidePanel` in the `panel` slot calls the setter while it covers the page area below `lg`.
|
|
24
|
-
const { scrollAreaRef, setPageCovered } = usePageCover.usePageCover(scrollAreaProps?.ref);
|
|
25
|
-
// A `SlideoutMenu` anywhere in the shell reads the page area so it covers that box and nothing else, and below `lg` makes the
|
|
26
|
-
// row under that box inert: the page and a side panel covering it, which the slideout then covers in turn.
|
|
27
|
-
const pageAreaBounds = usePageAreaBounds.usePageAreaBounds(scrollAreaRef);
|
|
28
|
-
const pageRowRef = React.useRef(null);
|
|
29
|
-
return (
|
|
30
|
-
// A column below `lg`, so a navigation that renders its own mobile top bar stacks above the content.
|
|
31
|
-
jsxRuntime.jsx("div", { "data-testid": appShellTestId, className: cx.cx('flex h-dvh w-full flex-col overflow-hidden bg-primary lg:flex-row', className), children: jsxRuntime.jsx(OverlayBounds_context.OverlayBoundsContext.Provider, { value: pageAreaBounds, children: jsxRuntime.jsxs(PageArea_context.PageAreaContext.Provider, { value: pageRowRef, children: [sidebar, jsxRuntime.jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [header, jsxRuntime.jsxs("div", { ref: pageRowRef, className: "relative flex min-h-0 flex-1 overflow-clip", children: [jsxRuntime.jsx("div", { id: scrollAreaProps?.id, ref: scrollAreaRef, "data-testid": scrollAreaProps?.['data-testid'] ?? testIdUtils.joinTestId(appShellTestId, 'scroll-area'),
|
|
32
|
-
// Focusable so keyboard users can scroll a page that has no focusable content of its own (axe: scrollable-region-focusable).
|
|
33
|
-
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard
|
|
34
|
-
tabIndex: 0,
|
|
35
|
-
// isolate keeps the page's own stacked content (sticky headers) under a panel that covers it.
|
|
36
|
-
className: "isolate flex min-w-0 flex-1 flex-col overflow-y-auto outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2", children: children }), jsxRuntime.jsx(PageCover_context.PageCoverContext.Provider, { value: setPageCovered, children: panel })] })] })] }) }) }));
|
|
37
|
-
};
|
|
5
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/AppShell`. Removed in the next major. */
|
|
6
|
+
const AppShell = AppShell$1.AppShell;
|
|
38
7
|
|
|
39
8
|
exports.AppShell = AppShell;
|
|
40
9
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/templates/AppShell/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/templates/AppShell/index.tsx"],"sourcesContent":[null],"names":["AppShellNext"],"mappings":";;;;AAUA;AACO,MAAM,QAAQ,GAAGA;;"}
|
|
@@ -1,40 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'data-testid'?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface AppShellProps {
|
|
11
|
-
/** Primary navigation, rendered first beside the content column. Compose `<SidebarNavigation>` here. */
|
|
12
|
-
sidebar?: ReactNode;
|
|
13
|
-
/** Top bar, rendered at the top of the content column. It stays in place while the page area scrolls, outside the box a `SlideoutMenu` covers. Compose `<ApplicationHeader>` here. */
|
|
14
|
-
header?: ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Side panel rendered under the header. From `lg` it sits beside the page area, which narrows to make
|
|
17
|
-
* room. Below `lg` it covers the page area, which is then out of reach of keyboard and assistive
|
|
18
|
-
* technology until the panel closes, as the panel itself is while a `SlideoutMenu` covers both. Compose
|
|
19
|
-
* one `<SidePanel>` here and switch its content.
|
|
20
|
-
*/
|
|
21
|
-
panel?: ReactNode;
|
|
22
|
-
/** Page content, normally a `<PageLayout>`. Rendered inside the shell's scroll area. */
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
/** Hooks for the element that scrolls the page content, since the document itself does not scroll. */
|
|
25
|
-
scrollAreaProps?: AppShellScrollAreaProps;
|
|
26
|
-
/** Extra classes merged onto the root element. */
|
|
27
|
-
className?: string;
|
|
28
|
-
/** Overrides the `data-testid` (defaults to `fd-app-shell`). */
|
|
29
|
-
'data-testid'?: string;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Layout-only template for an app shell: navigation beside a column that stacks the header
|
|
33
|
-
* above the page, with an optional side panel under the header. The shell is window-height and
|
|
34
|
-
* only the page area scrolls; it holds no state, so the app owns navigation, search and panel
|
|
35
|
-
* state.
|
|
36
|
-
*
|
|
37
|
-
* @summary window-height app shell layout with a scrolling page area
|
|
38
|
-
*/
|
|
39
|
-
export declare const AppShell: ({ sidebar, header, panel, children, scrollAreaProps, className, "data-testid": dataTestId }: AppShellProps) => ReactNode;
|
|
1
|
+
import { type AppShellProps as AppShellPropsNext, type AppShellScrollAreaProps as AppShellScrollAreaPropsNext } from '@flipdish/ui-library/components/layouts/AppShell';
|
|
2
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/AppShell`. Removed in the next major. */
|
|
3
|
+
export declare const AppShell: ({ sidebar, header, panel, children, scrollAreaProps, className, "data-testid": dataTestId }: AppShellPropsNext) => import("react").ReactNode;
|
|
4
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/AppShell`. Removed in the next major. */
|
|
5
|
+
export type AppShellProps = AppShellPropsNext;
|
|
6
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/AppShell`. Removed in the next major. */
|
|
7
|
+
export type AppShellScrollAreaProps = AppShellScrollAreaPropsNext;
|
|
40
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/AppShell/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/AppShell/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,uBAAuB,IAAI,2BAA2B,EAC5D,MAAM,kDAAkD,CAAC;AAE1D,6GAA6G;AAC7G,eAAO,MAAM,QAAQ,+IAAe,CAAC;AACrC,6GAA6G;AAC7G,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC9C,6GAA6G;AAC7G,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,CAAC"}
|
|
@@ -1,38 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
|
-
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
-
import { useRef } from 'react';
|
|
5
|
-
import { PageCoverContext } from '../../organisms/SidePanel/providers/PageCover.context.js';
|
|
6
|
-
import { OverlayBoundsContext } from '../../organisms/SlideoutMenu/providers/OverlayBounds.context.js';
|
|
7
|
-
import { PageAreaContext } from '../../organisms/SlideoutMenu/providers/PageArea.context.js';
|
|
8
|
-
import { usePageAreaBounds } from './hooks/usePageAreaBounds.js';
|
|
9
|
-
import { usePageCover } from './hooks/usePageCover.js';
|
|
1
|
+
import { AppShell as AppShell$1 } from '@flipdish/ui-library/components/layouts/AppShell';
|
|
10
2
|
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
* above the page, with an optional side panel under the header. The shell is window-height and
|
|
14
|
-
* only the page area scrolls; it holds no state, so the app owns navigation, search and panel
|
|
15
|
-
* state.
|
|
16
|
-
*
|
|
17
|
-
* @summary window-height app shell layout with a scrolling page area
|
|
18
|
-
*/
|
|
19
|
-
const AppShell = ({ sidebar, header, panel, children, scrollAreaProps, className, 'data-testid': dataTestId }) => {
|
|
20
|
-
const appShellTestId = useResolvedTestId({ testId: dataTestId, segment: 'app-shell', rootName: 'app-shell' });
|
|
21
|
-
// A `SidePanel` in the `panel` slot calls the setter while it covers the page area below `lg`.
|
|
22
|
-
const { scrollAreaRef, setPageCovered } = usePageCover(scrollAreaProps?.ref);
|
|
23
|
-
// A `SlideoutMenu` anywhere in the shell reads the page area so it covers that box and nothing else, and below `lg` makes the
|
|
24
|
-
// row under that box inert: the page and a side panel covering it, which the slideout then covers in turn.
|
|
25
|
-
const pageAreaBounds = usePageAreaBounds(scrollAreaRef);
|
|
26
|
-
const pageRowRef = useRef(null);
|
|
27
|
-
return (
|
|
28
|
-
// A column below `lg`, so a navigation that renders its own mobile top bar stacks above the content.
|
|
29
|
-
jsx("div", { "data-testid": appShellTestId, className: cx('flex h-dvh w-full flex-col overflow-hidden bg-primary lg:flex-row', className), children: jsx(OverlayBoundsContext.Provider, { value: pageAreaBounds, children: jsxs(PageAreaContext.Provider, { value: pageRowRef, children: [sidebar, jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [header, jsxs("div", { ref: pageRowRef, className: "relative flex min-h-0 flex-1 overflow-clip", children: [jsx("div", { id: scrollAreaProps?.id, ref: scrollAreaRef, "data-testid": scrollAreaProps?.['data-testid'] ?? joinTestId(appShellTestId, 'scroll-area'),
|
|
30
|
-
// Focusable so keyboard users can scroll a page that has no focusable content of its own (axe: scrollable-region-focusable).
|
|
31
|
-
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard
|
|
32
|
-
tabIndex: 0,
|
|
33
|
-
// isolate keeps the page's own stacked content (sticky headers) under a panel that covers it.
|
|
34
|
-
className: "isolate flex min-w-0 flex-1 flex-col overflow-y-auto outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2", children: children }), jsx(PageCoverContext.Provider, { value: setPageCovered, children: panel })] })] })] }) }) }));
|
|
35
|
-
};
|
|
3
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/AppShell`. Removed in the next major. */
|
|
4
|
+
const AppShell = AppShell$1;
|
|
36
5
|
|
|
37
6
|
export { AppShell };
|
|
38
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/templates/AppShell/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/templates/AppShell/index.tsx"],"sourcesContent":[null],"names":["AppShellNext"],"mappings":";;AAUA;AACO,MAAM,QAAQ,GAAGA;;"}
|
|
@@ -1,65 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var Skeleton = require('@flipdish/ui-library/components/atoms/Skeleton');
|
|
5
|
-
var Select = require('@flipdish/ui-library/components/molecules/Select');
|
|
6
|
-
var PageLayout = require('@flipdish/ui-library/components/templates/PageLayout');
|
|
7
|
-
var ErrorBoundary = require('@flipdish/ui-library/providers/ErrorBoundary');
|
|
8
|
-
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var PageHubLayoutSectionNav = require('./components/PageHubLayoutSectionNav.cjs');
|
|
11
|
-
var pageHubLayout_utils = require('./pageHubLayout.utils.cjs');
|
|
3
|
+
var PageHubLayout$1 = require('@flipdish/ui-library/components/layouts/PageHubLayout');
|
|
12
4
|
|
|
13
|
-
/**
|
|
14
|
-
const
|
|
15
|
-
/** English status copy — consumers localise via `sectionFallback`. TODO(i18n): source from ui-library's translation layer once one exists. */
|
|
16
|
-
const DEFAULT_SECTION_LOADING_TEXT = 'Loading section';
|
|
17
|
-
const DefaultSectionFallback = ({ testId, onShownChange }) => {
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
onShownChange(true);
|
|
20
|
-
return () => onShownChange(false);
|
|
21
|
-
}, [onShownChange]);
|
|
22
|
-
return (jsxRuntime.jsxs("div", { "aria-busy": "true", "data-testid": testId, className: "flex w-full flex-col gap-4", children: [jsxRuntime.jsx(Skeleton.Skeleton, { width: "40%", height: 20 }), jsxRuntime.jsx(Skeleton.SkeletonText, { lines: 4 })] }));
|
|
23
|
-
};
|
|
24
|
-
/** Runs `render` as a component, so a throw lands in the section boundary rather than in the layout's own render. */
|
|
25
|
-
const PageHubLayoutSectionContent = ({ render }) => render();
|
|
26
|
-
/**
|
|
27
|
-
* Page template for a hub of sections: a `PageLayout` whose content is a section navigation beside
|
|
28
|
-
* the selected section, each section rendered from config inside its own error and Suspense boundary. Reach for
|
|
29
|
-
* it instead of `PageLayout` when one page hosts several feature areas picked from a left-hand list,
|
|
30
|
-
* such as a settings hub; the list becomes a select below `lg`.
|
|
31
|
-
*
|
|
32
|
-
* @summary page template with section navigation and content
|
|
33
|
-
*/
|
|
34
|
-
const PageHubLayout = ({ pageName, sections, navigationLabel, selectedSection, defaultSelectedSection, onSectionChange, sectionFallback, renderError, onError, 'data-testid': dataTestId, ...pageLayoutProps }) => {
|
|
35
|
-
const pageHubLayoutTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'page-hub-layout', rootName: 'page-hub-layout' });
|
|
36
|
-
// Uncontrolled fallback so the desktop navigation and the mobile select always agree on the selection.
|
|
37
|
-
const [internalSelectedSection, setInternalSelectedSection] = React.useState(defaultSelectedSection);
|
|
38
|
-
const [isDefaultFallbackShown, setIsDefaultFallbackShown] = React.useState(false);
|
|
39
|
-
const activeSection = pageHubLayout_utils.resolveSelectedSection(sections, selectedSection ?? internalSelectedSection);
|
|
40
|
-
const selectSection = (id) => {
|
|
41
|
-
setInternalSelectedSection(id);
|
|
42
|
-
// Re-picking the current section is not a change; the select already ignores it, so the navigation does too.
|
|
43
|
-
if (id !== activeSection?.id)
|
|
44
|
-
onSectionChange?.(id);
|
|
45
|
-
};
|
|
46
|
-
const selectFromSelect = (key) => {
|
|
47
|
-
const pickedId = pageHubLayout_utils.resolvePickedSectionId(sections, key);
|
|
48
|
-
if (pickedId !== undefined)
|
|
49
|
-
selectSection(pickedId);
|
|
50
|
-
};
|
|
51
|
-
return (jsxRuntime.jsx(PageLayout.PageLayout, { ...pageLayoutProps, pageName: pageName, renderError: renderError, onError: onError, "data-testid": pageHubLayoutTestId, children: jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-md lg:flex-row lg:items-start", children: [jsxRuntime.jsx(PageHubLayoutSectionNav.PageHubLayoutSectionNav, { className: "max-lg:hidden", sections: sections, selectedSection: activeSection?.id, onSelect: selectSection, "aria-label": navigationLabel, "data-testid": testIdUtils.joinTestId(pageHubLayoutTestId, 'sections') }), jsxRuntime.jsx(Select.Select, { className: "w-full lg:hidden", size: "md", "aria-label": navigationLabel, value: activeSection?.id ?? null, onChange: selectFromSelect, "data-testid": testIdUtils.joinTestId(pageHubLayoutTestId, 'sections-select'), children: sections.map((section) => (
|
|
52
|
-
// Spread, not `href={section.href}`: react-aria copies an `href` key that is present but undefined onto the option as `href=""`.
|
|
53
|
-
jsxRuntime.jsx(Select.Select.Item, { id: section.id, label: section.label, isDisabled: section.isDisabled, ...(section.href ? { href: section.href } : {}) }, section.id))) }), jsxRuntime.jsxs("div", { "data-testid": testIdUtils.joinTestId(pageHubLayoutTestId, 'content'), className: "w-full min-w-0 flex-1", children: [jsxRuntime.jsx("output", { className: "sr-only", children: isDefaultFallbackShown ? DEFAULT_SECTION_LOADING_TEXT : '' }), activeSection && (
|
|
54
|
-
// Keyed by section so a section that threw is replaced, not left showing its fallback, when the user moves on.
|
|
55
|
-
jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { identifier: `${pageName}/${activeSection.id}`, onError: onError, renderFallback: (error) => {
|
|
56
|
-
// `undefined`, not nullish: an explicit `null` from `renderError` is honoured as "render nothing".
|
|
57
|
-
const customFallback = renderError?.({ error, pageName, sectionId: activeSection.id });
|
|
58
|
-
if (customFallback !== undefined)
|
|
59
|
-
return customFallback;
|
|
60
|
-
return jsxRuntime.jsx(DefaultSectionError, { testId: testIdUtils.joinTestId(pageHubLayoutTestId, 'section-error') });
|
|
61
|
-
}, children: jsxRuntime.jsx(React.Suspense, { fallback: sectionFallback !== undefined ? (sectionFallback) : (jsxRuntime.jsx(DefaultSectionFallback, { testId: testIdUtils.joinTestId(pageHubLayoutTestId, 'section-loading'), onShownChange: setIsDefaultFallbackShown })), children: jsxRuntime.jsx(PageHubLayoutSectionContent, { render: activeSection.render }) }) }, activeSection.id))] })] }) }));
|
|
62
|
-
};
|
|
5
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/PageHubLayout`. Removed in the next major. */
|
|
6
|
+
const PageHubLayout = PageHubLayout$1.PageHubLayout;
|
|
63
7
|
|
|
64
8
|
exports.PageHubLayout = PageHubLayout;
|
|
65
9
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/templates/PageHubLayout/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/templates/PageHubLayout/index.tsx"],"sourcesContent":[null],"names":["PageHubLayoutNext"],"mappings":";;;;AAUA;AACO,MAAM,aAAa,GAAGA;;"}
|
|
@@ -1,56 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* `render` for its content; only the selected section's `render` runs.
|
|
9
|
-
*/
|
|
10
|
-
sections: PageHubLayoutSection[];
|
|
11
|
-
/**
|
|
12
|
-
* Accessible name for the section navigation and its mobile select, e.g. "Settings sections". Must
|
|
13
|
-
* differ from the header's title, which already names the `PageHeader` tab navigation.
|
|
14
|
-
*/
|
|
15
|
-
navigationLabel: string;
|
|
16
|
-
/**
|
|
17
|
-
* Controlled selected section id, usually read from the router. An id that matches no enabled
|
|
18
|
-
* section falls back to the first enabled one.
|
|
19
|
-
*/
|
|
20
|
-
selectedSection?: string;
|
|
21
|
-
/** Initially selected section id (uncontrolled). Defaults to the first enabled section. */
|
|
22
|
-
defaultSelectedSection?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Called with the section id when the user picks a different section that has no `href`, from the
|
|
25
|
-
* navigation or the mobile select. Re-picking the current section does not call it, and a section
|
|
26
|
-
* with `href` navigates as a link instead and never calls it.
|
|
27
|
-
*/
|
|
28
|
-
onSectionChange?: (id: string) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Shown in the content pane while the selected section suspends, such as a `React.lazy` section
|
|
31
|
-
* whose chunk is loading. Replaces the default skeleton; the header and navigation stay in place.
|
|
32
|
-
*/
|
|
33
|
-
sectionFallback?: ReactNode;
|
|
34
|
-
/**
|
|
35
|
-
* Replaces the default fallback shown when content throws. Receives the thrown error, `pageName`
|
|
36
|
-
* and, when the selected section threw, its `sectionId`; without one the page-level boundary caught it.
|
|
37
|
-
* Return `null` to render nothing, or `undefined` to keep the default fallback.
|
|
38
|
-
*/
|
|
39
|
-
renderError?: (props: {
|
|
40
|
-
error: Error;
|
|
41
|
-
pageName: string;
|
|
42
|
-
sectionId?: string;
|
|
43
|
-
}) => ReactNode;
|
|
44
|
-
/** Overrides the `data-testid` (defaults to `fd-page-hub-layout`). */
|
|
45
|
-
'data-testid'?: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Page template for a hub of sections: a `PageLayout` whose content is a section navigation beside
|
|
49
|
-
* the selected section, each section rendered from config inside its own error and Suspense boundary. Reach for
|
|
50
|
-
* it instead of `PageLayout` when one page hosts several feature areas picked from a left-hand list,
|
|
51
|
-
* such as a settings hub; the list becomes a select below `lg`.
|
|
52
|
-
*
|
|
53
|
-
* @summary page template with section navigation and content
|
|
54
|
-
*/
|
|
55
|
-
export declare const PageHubLayout: ({ pageName, sections, navigationLabel, selectedSection, defaultSelectedSection, onSectionChange, sectionFallback, renderError, onError, "data-testid": dataTestId, ...pageLayoutProps }: PageHubLayoutProps) => ReactNode;
|
|
1
|
+
import { type PageHubLayoutProps as PageHubLayoutPropsNext, type PageHubLayoutSection as PageHubLayoutSectionNext } from '@flipdish/ui-library/components/layouts/PageHubLayout';
|
|
2
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/PageHubLayout`. Removed in the next major. */
|
|
3
|
+
export declare const PageHubLayout: ({ pageName, sections, navigationLabel, selectedSection, defaultSelectedSection, onSectionChange, sectionFallback, renderError, onError, "data-testid": dataTestId, ...pageLayoutProps }: PageHubLayoutPropsNext) => import("react").ReactNode;
|
|
4
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/PageHubLayout`. Removed in the next major. */
|
|
5
|
+
export type PageHubLayoutProps = PageHubLayoutPropsNext;
|
|
6
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/PageHubLayout`. Removed in the next major. */
|
|
7
|
+
export type PageHubLayoutSection = PageHubLayoutSectionNext;
|
|
56
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/PageHubLayout/index.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/PageHubLayout/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,kBAAkB,IAAI,sBAAsB,EACjD,KAAK,oBAAoB,IAAI,wBAAwB,EACtD,MAAM,uDAAuD,CAAC;AAE/D,kHAAkH;AAClH,eAAO,MAAM,aAAa,gPAAoB,CAAC;AAC/C,kHAAkH;AAClH,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AACxD,kHAAkH;AAClH,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,CAAC"}
|
|
@@ -1,63 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Skeleton, SkeletonText } from '@flipdish/ui-library/components/atoms/Skeleton';
|
|
3
|
-
import { Select } from '@flipdish/ui-library/components/molecules/Select';
|
|
4
|
-
import { PageLayout } from '@flipdish/ui-library/components/templates/PageLayout';
|
|
5
|
-
import { ErrorBoundary } from '@flipdish/ui-library/providers/ErrorBoundary';
|
|
6
|
-
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
-
import { useState, Suspense, useEffect } from 'react';
|
|
8
|
-
import { PageHubLayoutSectionNav } from './components/PageHubLayoutSectionNav.js';
|
|
9
|
-
import { resolveSelectedSection, resolvePickedSectionId } from './pageHubLayout.utils.js';
|
|
1
|
+
import { PageHubLayout as PageHubLayout$1 } from '@flipdish/ui-library/components/layouts/PageHubLayout';
|
|
10
2
|
|
|
11
|
-
/**
|
|
12
|
-
const
|
|
13
|
-
/** English status copy — consumers localise via `sectionFallback`. TODO(i18n): source from ui-library's translation layer once one exists. */
|
|
14
|
-
const DEFAULT_SECTION_LOADING_TEXT = 'Loading section';
|
|
15
|
-
const DefaultSectionFallback = ({ testId, onShownChange }) => {
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
onShownChange(true);
|
|
18
|
-
return () => onShownChange(false);
|
|
19
|
-
}, [onShownChange]);
|
|
20
|
-
return (jsxs("div", { "aria-busy": "true", "data-testid": testId, className: "flex w-full flex-col gap-4", children: [jsx(Skeleton, { width: "40%", height: 20 }), jsx(SkeletonText, { lines: 4 })] }));
|
|
21
|
-
};
|
|
22
|
-
/** Runs `render` as a component, so a throw lands in the section boundary rather than in the layout's own render. */
|
|
23
|
-
const PageHubLayoutSectionContent = ({ render }) => render();
|
|
24
|
-
/**
|
|
25
|
-
* Page template for a hub of sections: a `PageLayout` whose content is a section navigation beside
|
|
26
|
-
* the selected section, each section rendered from config inside its own error and Suspense boundary. Reach for
|
|
27
|
-
* it instead of `PageLayout` when one page hosts several feature areas picked from a left-hand list,
|
|
28
|
-
* such as a settings hub; the list becomes a select below `lg`.
|
|
29
|
-
*
|
|
30
|
-
* @summary page template with section navigation and content
|
|
31
|
-
*/
|
|
32
|
-
const PageHubLayout = ({ pageName, sections, navigationLabel, selectedSection, defaultSelectedSection, onSectionChange, sectionFallback, renderError, onError, 'data-testid': dataTestId, ...pageLayoutProps }) => {
|
|
33
|
-
const pageHubLayoutTestId = useResolvedTestId({ testId: dataTestId, segment: 'page-hub-layout', rootName: 'page-hub-layout' });
|
|
34
|
-
// Uncontrolled fallback so the desktop navigation and the mobile select always agree on the selection.
|
|
35
|
-
const [internalSelectedSection, setInternalSelectedSection] = useState(defaultSelectedSection);
|
|
36
|
-
const [isDefaultFallbackShown, setIsDefaultFallbackShown] = useState(false);
|
|
37
|
-
const activeSection = resolveSelectedSection(sections, selectedSection ?? internalSelectedSection);
|
|
38
|
-
const selectSection = (id) => {
|
|
39
|
-
setInternalSelectedSection(id);
|
|
40
|
-
// Re-picking the current section is not a change; the select already ignores it, so the navigation does too.
|
|
41
|
-
if (id !== activeSection?.id)
|
|
42
|
-
onSectionChange?.(id);
|
|
43
|
-
};
|
|
44
|
-
const selectFromSelect = (key) => {
|
|
45
|
-
const pickedId = resolvePickedSectionId(sections, key);
|
|
46
|
-
if (pickedId !== undefined)
|
|
47
|
-
selectSection(pickedId);
|
|
48
|
-
};
|
|
49
|
-
return (jsx(PageLayout, { ...pageLayoutProps, pageName: pageName, renderError: renderError, onError: onError, "data-testid": pageHubLayoutTestId, children: jsxs("div", { className: "flex w-full flex-col gap-md lg:flex-row lg:items-start", children: [jsx(PageHubLayoutSectionNav, { className: "max-lg:hidden", sections: sections, selectedSection: activeSection?.id, onSelect: selectSection, "aria-label": navigationLabel, "data-testid": joinTestId(pageHubLayoutTestId, 'sections') }), jsx(Select, { className: "w-full lg:hidden", size: "md", "aria-label": navigationLabel, value: activeSection?.id ?? null, onChange: selectFromSelect, "data-testid": joinTestId(pageHubLayoutTestId, 'sections-select'), children: sections.map((section) => (
|
|
50
|
-
// Spread, not `href={section.href}`: react-aria copies an `href` key that is present but undefined onto the option as `href=""`.
|
|
51
|
-
jsx(Select.Item, { id: section.id, label: section.label, isDisabled: section.isDisabled, ...(section.href ? { href: section.href } : {}) }, section.id))) }), jsxs("div", { "data-testid": joinTestId(pageHubLayoutTestId, 'content'), className: "w-full min-w-0 flex-1", children: [jsx("output", { className: "sr-only", children: isDefaultFallbackShown ? DEFAULT_SECTION_LOADING_TEXT : '' }), activeSection && (
|
|
52
|
-
// Keyed by section so a section that threw is replaced, not left showing its fallback, when the user moves on.
|
|
53
|
-
jsx(ErrorBoundary, { identifier: `${pageName}/${activeSection.id}`, onError: onError, renderFallback: (error) => {
|
|
54
|
-
// `undefined`, not nullish: an explicit `null` from `renderError` is honoured as "render nothing".
|
|
55
|
-
const customFallback = renderError?.({ error, pageName, sectionId: activeSection.id });
|
|
56
|
-
if (customFallback !== undefined)
|
|
57
|
-
return customFallback;
|
|
58
|
-
return jsx(DefaultSectionError, { testId: joinTestId(pageHubLayoutTestId, 'section-error') });
|
|
59
|
-
}, children: jsx(Suspense, { fallback: sectionFallback !== undefined ? (sectionFallback) : (jsx(DefaultSectionFallback, { testId: joinTestId(pageHubLayoutTestId, 'section-loading'), onShownChange: setIsDefaultFallbackShown })), children: jsx(PageHubLayoutSectionContent, { render: activeSection.render }) }) }, activeSection.id))] })] }) }));
|
|
60
|
-
};
|
|
3
|
+
/** @deprecated Import from `@flipdish/ui-library/components/layouts/PageHubLayout`. Removed in the next major. */
|
|
4
|
+
const PageHubLayout = PageHubLayout$1;
|
|
61
5
|
|
|
62
6
|
export { PageHubLayout };
|
|
63
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/templates/PageHubLayout/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/templates/PageHubLayout/index.tsx"],"sourcesContent":[null],"names":["PageHubLayoutNext"],"mappings":";;AAUA;AACO,MAAM,aAAa,GAAGA;;"}
|