@flipdish/ui-library 0.53.0 → 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/atoms/CloseButton/index.cjs +1 -0
- package/dist/components/atoms/CloseButton/index.cjs.map +1 -1
- package/dist/components/atoms/CloseButton/index.d.ts.map +1 -1
- package/dist/components/atoms/CloseButton/index.js +1 -0
- package/dist/components/atoms/CloseButton/index.js.map +1 -1
- 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/molecules/Dropdown/components/DropdownSelectionIndicator.cjs +29 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.cjs.map +1 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.d.ts +9 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.d.ts.map +1 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.js +27 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.js.map +1 -0
- package/dist/components/molecules/Dropdown/index.cjs +4 -30
- package/dist/components/molecules/Dropdown/index.cjs.map +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts.map +1 -1
- package/dist/components/molecules/Dropdown/index.js +6 -32
- package/dist/components/molecules/Dropdown/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.cjs +24 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.cjs.map +1 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.d.ts +10 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.d.ts.map +1 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.js +22 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.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,29 @@
|
|
|
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 DefaultPageError = ({ testId }) => (jsxs("div", { role: "alert", "data-testid": testId, className: "flex w-full flex-col items-center gap-2 py-2xl text-center", children: [jsx("h2", { className: "text-lg font-semibold text-primary", children: "Something went wrong" }), jsx("p", { className: "text-md text-tertiary", children: "An unexpected error occurred while loading this page." })] }));
|
|
8
|
+
/**
|
|
9
|
+
* Page-shaped layout for app page chrome: a full-width `<main>` that owns the gutters (16px
|
|
10
|
+
* on mobile, 24px from `lg`) and the header-to-content gap, an optional header region and an
|
|
11
|
+
* error boundary keyed by `pageName`. The boundary wraps `children` only, so the header's
|
|
12
|
+
* breadcrumbs stay usable when content throws; an app-level boundary still catches header
|
|
13
|
+
* errors.
|
|
14
|
+
*
|
|
15
|
+
* @summary app-shell page layout with a page-scoped error boundary
|
|
16
|
+
*/
|
|
17
|
+
const PageLayout = ({ pageName, header, children, renderError, onError, className, 'data-testid': dataTestId, }) => {
|
|
18
|
+
const pageLayoutTestId = useResolvedTestId({ testId: dataTestId, segment: 'page-layout', rootName: 'page-layout' });
|
|
19
|
+
return (jsxs("main", { "data-testid": pageLayoutTestId, className: cx('flex w-full flex-col gap-md p-md lg:p-xl', className), children: [header, jsx(ErrorBoundary, { identifier: pageName, onError: onError, renderFallback: (error) => {
|
|
20
|
+
// `undefined`, not nullish: an explicit `null` from `renderError` is honoured as "render nothing".
|
|
21
|
+
const customFallback = renderError?.({ error, pageName });
|
|
22
|
+
if (customFallback !== undefined)
|
|
23
|
+
return customFallback;
|
|
24
|
+
return jsx(DefaultPageError, { testId: joinTestId(pageLayoutTestId, 'error') });
|
|
25
|
+
}, children: children }, pageName)] }));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { PageLayout };
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/layouts/PageLayout/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;AAqCA;AACA,MAAM,gBAAgB,GAAG,CAAC,EAAE,MAAM,EAAuB,MACvDA,IAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAC,OAAO,iBAAc,MAAM,EAAE,SAAS,EAAC,4DAA4D,EAAA,QAAA,EAAA,CAC3GC,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,uDAAA,EAAA,CAA0D,CAAA,EAAA,CAC1F,CACP;AAED;;;;;;;;AAQG;MACU,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,aAAa,EAAE,UAAU,GACT,KAAe;AAC/B,IAAA,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAEnH,IAAA,QACED,IAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAmB,gBAAgB,EAAE,SAAS,EAAE,EAAE,CAAC,0CAA0C,EAAE,SAAS,CAAC,aACtG,MAAM,EAGPC,GAAA,CAAC,aAAa,EAAA,EAEZ,UAAU,EAAE,QAAQ,EACpB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,KAAK,KAAI;;oBAExB,MAAM,cAAc,GAAG,WAAW,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;oBACzD,IAAI,cAAc,KAAK,SAAS;AAAE,wBAAA,OAAO,cAAc;AACvD,oBAAA,OAAOA,GAAA,CAAC,gBAAgB,EAAA,EAAC,MAAM,EAAE,UAAU,CAAC,gBAAgB,EAAE,OAAO,CAAC,EAAA,CAAI;AAC5E,gBAAA,CAAC,YAEA,QAAQ,EAAA,EAVJ,QAAQ,CAWC,CAAA,EAAA,CACX;AAEX;;"}
|
|
@@ -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;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
6
|
+
var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
7
|
+
var Toggle = require('@flipdish/ui-library/components/atoms/Toggle');
|
|
8
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
9
|
+
|
|
10
|
+
const DropdownSelectionIndicator = ({ selectionIndicator, isSelected, hasSubmenu, className }) => {
|
|
11
|
+
if (selectionIndicator === 'checkmark') {
|
|
12
|
+
return (jsxRuntime.jsx(uiIcons.Check, { "aria-hidden": "true", className: cx.cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !isSelected && 'invisible', className) }));
|
|
13
|
+
}
|
|
14
|
+
if (selectionIndicator === 'checkbox') {
|
|
15
|
+
return (jsxRuntime.jsx(Checkbox.CheckboxBase, { isSelected: isSelected && !hasSubmenu,
|
|
16
|
+
// A selected item that opens a submenu is only partly chosen, so the box is mixed rather than checked.
|
|
17
|
+
isIndeterminate: isSelected && hasSubmenu, size: "sm", className: cx.cx('shrink-0', className) }));
|
|
18
|
+
}
|
|
19
|
+
if (selectionIndicator === 'radio') {
|
|
20
|
+
return jsxRuntime.jsx(RadioButton.RadioButtonBase, { isSelected: isSelected, className: cx.cx('shrink-0', className) });
|
|
21
|
+
}
|
|
22
|
+
if (selectionIndicator === 'toggle') {
|
|
23
|
+
return jsxRuntime.jsx(Toggle.ToggleBase, { slim: true, size: "sm", isSelected: isSelected, className: cx.cx('shrink-0', className) });
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.DropdownSelectionIndicator = DropdownSelectionIndicator;
|
|
29
|
+
//# sourceMappingURL=DropdownSelectionIndicator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.cjs","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"sourcesContent":[null],"names":["_jsx","Check","cx","CheckboxBase","RadioButtonBase","ToggleBase"],"mappings":";;;;;;;;;AAeO,MAAM,0BAA0B,GAAG,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAmC,KAAI;AACvI,IAAA,IAAI,kBAAkB,KAAK,WAAW,EAAE;QACtC,QACEA,eAACC,aAAK,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAEC,KAAE,CAAC,uDAAuD,EAAE,CAAC,UAAU,IAAI,WAAW,EAAE,SAAS,CAAC,EAAA,CAAI;IAE/I;AACA,IAAA,IAAI,kBAAkB,KAAK,UAAU,EAAE;QACrC,QACEF,eAACG,qBAAY,EAAA,EACX,UAAU,EAAE,UAAU,IAAI,CAAC,UAAU;;AAErC,YAAA,eAAe,EAAE,UAAU,IAAI,UAAU,EACzC,IAAI,EAAC,IAAI,EACT,SAAS,EAAED,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CACpC;IAEN;AACA,IAAA,IAAI,kBAAkB,KAAK,OAAO,EAAE;AAClC,QAAA,OAAOF,eAACI,2BAAe,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAEF,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,GAAI;IAC1F;AACA,IAAA,IAAI,kBAAkB,KAAK,QAAQ,EAAE;QACnC,OAAOF,cAAA,CAACK,iBAAU,EAAA,EAAC,IAAI,QAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAEH,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CAAI;IACpG;AACA,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DropdownSelectionIndicatorProps {
|
|
2
|
+
selectionIndicator: 'checkmark' | 'checkbox' | 'radio' | 'toggle' | 'none';
|
|
3
|
+
isSelected: boolean;
|
|
4
|
+
hasSubmenu?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DropdownSelectionIndicator: ({ selectionIndicator, isSelected, hasSubmenu, className }: DropdownSelectionIndicatorProps) => import("react").JSX.Element | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=DropdownSelectionIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"names":[],"mappings":"AAQA,UAAU,+BAA+B;IACvC,kBAAkB,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3E,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,0BAA0B,GAAI,2DAA2D,+BAA+B,uCAwBpI,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Check } from '@flipdish/ui-icons';
|
|
3
|
+
import { CheckboxBase } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
4
|
+
import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButton';
|
|
5
|
+
import { ToggleBase } from '@flipdish/ui-library/components/atoms/Toggle';
|
|
6
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
7
|
+
|
|
8
|
+
const DropdownSelectionIndicator = ({ selectionIndicator, isSelected, hasSubmenu, className }) => {
|
|
9
|
+
if (selectionIndicator === 'checkmark') {
|
|
10
|
+
return (jsx(Check, { "aria-hidden": "true", className: cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !isSelected && 'invisible', className) }));
|
|
11
|
+
}
|
|
12
|
+
if (selectionIndicator === 'checkbox') {
|
|
13
|
+
return (jsx(CheckboxBase, { isSelected: isSelected && !hasSubmenu,
|
|
14
|
+
// A selected item that opens a submenu is only partly chosen, so the box is mixed rather than checked.
|
|
15
|
+
isIndeterminate: isSelected && hasSubmenu, size: "sm", className: cx('shrink-0', className) }));
|
|
16
|
+
}
|
|
17
|
+
if (selectionIndicator === 'radio') {
|
|
18
|
+
return jsx(RadioButtonBase, { isSelected: isSelected, className: cx('shrink-0', className) });
|
|
19
|
+
}
|
|
20
|
+
if (selectionIndicator === 'toggle') {
|
|
21
|
+
return jsx(ToggleBase, { slim: true, size: "sm", isSelected: isSelected, className: cx('shrink-0', className) });
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { DropdownSelectionIndicator };
|
|
27
|
+
//# sourceMappingURL=DropdownSelectionIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.js","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAeO,MAAM,0BAA0B,GAAG,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAmC,KAAI;AACvI,IAAA,IAAI,kBAAkB,KAAK,WAAW,EAAE;QACtC,QACEA,IAAC,KAAK,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,uDAAuD,EAAE,CAAC,UAAU,IAAI,WAAW,EAAE,SAAS,CAAC,EAAA,CAAI;IAE/I;AACA,IAAA,IAAI,kBAAkB,KAAK,UAAU,EAAE;QACrC,QACEA,IAAC,YAAY,EAAA,EACX,UAAU,EAAE,UAAU,IAAI,CAAC,UAAU;;AAErC,YAAA,eAAe,EAAE,UAAU,IAAI,UAAU,EACzC,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CACpC;IAEN;AACA,IAAA,IAAI,kBAAkB,KAAK,OAAO,EAAE;AAClC,QAAA,OAAOA,IAAC,eAAe,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,GAAI;IAC1F;AACA,IAAA,IAAI,kBAAkB,KAAK,QAAQ,EAAE;QACnC,OAAOA,GAAA,CAAC,UAAU,EAAA,EAAC,IAAI,QAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CAAI;IACpG;AACA,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -4,47 +4,21 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var uiIcons = require('@flipdish/ui-icons');
|
|
5
5
|
var Avatar = require('@flipdish/ui-library/components/atoms/Avatar');
|
|
6
6
|
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
7
|
-
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
8
|
-
var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
9
|
-
var Toggle = require('@flipdish/ui-library/components/atoms/Toggle');
|
|
10
7
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
11
8
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
12
|
-
var React = require('react');
|
|
13
9
|
var reactAriaComponents = require('react-aria-components');
|
|
14
10
|
var ScrollClosingPopover = require('../../__internal__/popover/ScrollClosingPopover.cjs');
|
|
11
|
+
var DropdownSelectionIndicator = require('./components/DropdownSelectionIndicator.cjs');
|
|
12
|
+
var dropdown_utils = require('./utilities/dropdown.utils.cjs');
|
|
15
13
|
|
|
16
14
|
const DropdownItem = ({ label, children, addon, icon: Icon, avatarUrl, unstyled, selectionIndicator = 'checkmark', 'data-testid': dataTestId, ...props }) => {
|
|
17
15
|
const prefix = testIdUtils.useTestIdPrefix();
|
|
18
|
-
const
|
|
19
|
-
if (props.id !== undefined)
|
|
20
|
-
return testIdUtils.slugifyTestId(String(props.id));
|
|
21
|
-
if (typeof label === 'string')
|
|
22
|
-
return testIdUtils.slugifyTestId(label);
|
|
23
|
-
if (typeof children === 'string')
|
|
24
|
-
return testIdUtils.slugifyTestId(children);
|
|
25
|
-
return 'item';
|
|
26
|
-
};
|
|
27
|
-
const idPart = resolveIdPart();
|
|
16
|
+
const idPart = dropdown_utils.dropdownItemSegment(props.id, label, children);
|
|
28
17
|
const itemTestId = dataTestId ?? (prefix ? testIdUtils.joinTestId(prefix, `item-${idPart}`) : undefined);
|
|
29
|
-
const SelectionIndicator = React.useCallback((state) => {
|
|
30
|
-
if (selectionIndicator === 'checkmark') {
|
|
31
|
-
return (jsxRuntime.jsx(uiIcons.Check, { "aria-hidden": "true", className: cx.cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !state.isSelected && 'invisible', state.className) }));
|
|
32
|
-
}
|
|
33
|
-
if (selectionIndicator === 'checkbox') {
|
|
34
|
-
return (jsxRuntime.jsx(Checkbox.CheckboxBase, { isSelected: state.isSelected && !state.hasSubmenu, isIndeterminate: state.isSelected && state.hasSubmenu, size: "sm", className: cx.cx('shrink-0', state.className) }));
|
|
35
|
-
}
|
|
36
|
-
if (selectionIndicator === 'radio') {
|
|
37
|
-
return jsxRuntime.jsx(RadioButton.RadioButtonBase, { isSelected: state.isSelected, className: cx.cx('shrink-0', state.className) });
|
|
38
|
-
}
|
|
39
|
-
if (selectionIndicator === 'toggle') {
|
|
40
|
-
return jsxRuntime.jsx(Toggle.ToggleBase, { slim: true, size: "sm", isSelected: state.isSelected, className: cx.cx('shrink-0', state.className) });
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}, [selectionIndicator]);
|
|
44
18
|
if (unstyled) {
|
|
45
19
|
return jsxRuntime.jsx(reactAriaComponents.MenuItem, { id: label, textValue: label, "data-testid": itemTestId, ...props });
|
|
46
20
|
}
|
|
47
|
-
return (jsxRuntime.jsx(reactAriaComponents.MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx.cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && jsxRuntime.jsx(
|
|
21
|
+
return (jsxRuntime.jsx(reactAriaComponents.MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx.cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && (jsxRuntime.jsx(DropdownSelectionIndicator.DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "mr-2" })), avatarUrl && (jsxRuntime.jsx("div", { className: "mr-2 flex size-4 items-center justify-center", children: jsxRuntime.jsx(Avatar.Avatar, { "aria-hidden": "true", size: "xs", src: avatarUrl, alt: label, className: "size-5" }) })), Icon && jsxRuntime.jsx(Icon, { "aria-hidden": "true", className: "mr-2 size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" }), jsxRuntime.jsx("span", { className: cx.cx('grow truncate text-sm font-semibold text-secondary', state.isFocused && 'text-secondary_hover'), children: label || (typeof children === 'function' ? children(state) : children) }), addon && jsxRuntime.jsx("span", { className: "ml-1 shrink-0 pr-1 text-xs font-medium text-quaternary", children: addon }), state.selectionMode !== 'none' && (avatarUrl || Icon) && (jsxRuntime.jsx(DropdownSelectionIndicator.DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "ml-1" })), state.hasSubmenu && jsxRuntime.jsx(uiIcons.ChevronRight, { "aria-hidden": "true", className: "ml-auto size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" })] })) }));
|
|
48
22
|
};
|
|
49
23
|
const DropdownMenu = ({ 'data-testid': dataTestId, ...props }) => {
|
|
50
24
|
const prefix = testIdUtils.useTestIdPrefix();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","dropdownItemSegment","joinTestId","_jsx","AriaMenuItem","cx","_jsxs","DropdownSelectionIndicator","Avatar","ChevronRight","AriaMenu","ScrollClosingPopover","AriaSeparator","useResolvedTestId","Button","DotsVertical","TestIdProvider","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":";;;;;;;;;;;;;AA4CA,MAAM,YAAY,GAAG,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,IAAI,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,GAAG,WAAW,EAChC,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACU,KAAI;AACtB,IAAA,MAAM,MAAM,GAAGA,2BAAe,EAAE;AAChC,IAAA,MAAM,MAAM,GAAGC,kCAAmB,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC;IAC7D,MAAM,UAAU,GAAG,UAAU,KAAK,MAAM,GAAGC,sBAAU,CAAC,MAAM,EAAE,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAE,CAAC,GAAG,SAAS,CAAC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AAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,EAAqB,KAAI;AAC5F,IAAA,MAAM,UAAU,GAAGF,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEvG,IAAA,QACEV,cAAA,CAACa,0BAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/Bb,cAAA,CAACc,+BAAe,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB,EAAA,CACzC;AAErB,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;AACxB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAEC,+BAAe;AACxB,IAAA,aAAa,EAAEC,0BAAU;AACzB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,SAAS,EAAE,iBAAiB;AAC5B,IAAA,UAAU,EAAE,kBAAkB;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ButtonProps } from '@flipdish/ui-library/components/atoms/Button';
|
|
2
|
-
import {
|
|
2
|
+
import type { FC, SVGProps } from 'react';
|
|
3
3
|
import type { MenuItemProps as AriaMenuItemProps, MenuProps as AriaMenuProps, MenuTriggerProps as AriaMenuTriggerProps, PopoverProps as AriaPopoverProps, SeparatorProps as AriaSeparatorProps } from 'react-aria-components';
|
|
4
4
|
interface DropdownItemProps extends AriaMenuItemProps {
|
|
5
5
|
/** The label of the item to be displayed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../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E,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAQD,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAYD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;8DAnBoD,iBAAiB;qBAnD1D,oBAAoB;WAjB9B,CAAC,SAAS,MAAM,2CAA2C,iBAAiB,CAAC,CAAC,CAAC;;;iIA3ElG,iBAAiB;uBAiHc,kBAAkB;uEAgBmD,uBAAuB;CA0C7H,CAAC"}
|
|
@@ -1,48 +1,22 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { DotsVertical,
|
|
2
|
+
import { DotsVertical, ChevronRight } from '@flipdish/ui-icons';
|
|
3
3
|
import { Avatar } from '@flipdish/ui-library/components/atoms/Avatar';
|
|
4
4
|
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
5
|
-
import { CheckboxBase } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
6
|
-
import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButton';
|
|
7
|
-
import { ToggleBase } from '@flipdish/ui-library/components/atoms/Toggle';
|
|
8
5
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
9
|
-
import { useResolvedTestId, useTestIdPrefix, joinTestId, TestIdProvider
|
|
10
|
-
import { useCallback } from 'react';
|
|
6
|
+
import { useResolvedTestId, useTestIdPrefix, joinTestId, TestIdProvider } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
11
7
|
import { Header, MenuSection, Separator, MenuItem, Menu, MenuTrigger } from 'react-aria-components';
|
|
12
8
|
import { ScrollClosingPopover } from '../../__internal__/popover/ScrollClosingPopover.js';
|
|
9
|
+
import { DropdownSelectionIndicator } from './components/DropdownSelectionIndicator.js';
|
|
10
|
+
import { dropdownItemSegment } from './utilities/dropdown.utils.js';
|
|
13
11
|
|
|
14
12
|
const DropdownItem = ({ label, children, addon, icon: Icon, avatarUrl, unstyled, selectionIndicator = 'checkmark', 'data-testid': dataTestId, ...props }) => {
|
|
15
13
|
const prefix = useTestIdPrefix();
|
|
16
|
-
const
|
|
17
|
-
if (props.id !== undefined)
|
|
18
|
-
return slugifyTestId(String(props.id));
|
|
19
|
-
if (typeof label === 'string')
|
|
20
|
-
return slugifyTestId(label);
|
|
21
|
-
if (typeof children === 'string')
|
|
22
|
-
return slugifyTestId(children);
|
|
23
|
-
return 'item';
|
|
24
|
-
};
|
|
25
|
-
const idPart = resolveIdPart();
|
|
14
|
+
const idPart = dropdownItemSegment(props.id, label, children);
|
|
26
15
|
const itemTestId = dataTestId ?? (prefix ? joinTestId(prefix, `item-${idPart}`) : undefined);
|
|
27
|
-
const SelectionIndicator = useCallback((state) => {
|
|
28
|
-
if (selectionIndicator === 'checkmark') {
|
|
29
|
-
return (jsx(Check, { "aria-hidden": "true", className: cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !state.isSelected && 'invisible', state.className) }));
|
|
30
|
-
}
|
|
31
|
-
if (selectionIndicator === 'checkbox') {
|
|
32
|
-
return (jsx(CheckboxBase, { isSelected: state.isSelected && !state.hasSubmenu, isIndeterminate: state.isSelected && state.hasSubmenu, size: "sm", className: cx('shrink-0', state.className) }));
|
|
33
|
-
}
|
|
34
|
-
if (selectionIndicator === 'radio') {
|
|
35
|
-
return jsx(RadioButtonBase, { isSelected: state.isSelected, className: cx('shrink-0', state.className) });
|
|
36
|
-
}
|
|
37
|
-
if (selectionIndicator === 'toggle') {
|
|
38
|
-
return jsx(ToggleBase, { slim: true, size: "sm", isSelected: state.isSelected, className: cx('shrink-0', state.className) });
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}, [selectionIndicator]);
|
|
42
16
|
if (unstyled) {
|
|
43
17
|
return jsx(MenuItem, { id: label, textValue: label, "data-testid": itemTestId, ...props });
|
|
44
18
|
}
|
|
45
|
-
return (jsx(MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxs("div", { className: cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && jsx(
|
|
19
|
+
return (jsx(MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxs("div", { className: cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && (jsx(DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "mr-2" })), avatarUrl && (jsx("div", { className: "mr-2 flex size-4 items-center justify-center", children: jsx(Avatar, { "aria-hidden": "true", size: "xs", src: avatarUrl, alt: label, className: "size-5" }) })), Icon && jsx(Icon, { "aria-hidden": "true", className: "mr-2 size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" }), jsx("span", { className: cx('grow truncate text-sm font-semibold text-secondary', state.isFocused && 'text-secondary_hover'), children: label || (typeof children === 'function' ? children(state) : children) }), addon && jsx("span", { className: "ml-1 shrink-0 pr-1 text-xs font-medium text-quaternary", children: addon }), state.selectionMode !== 'none' && (avatarUrl || Icon) && (jsx(DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "ml-1" })), state.hasSubmenu && jsx(ChevronRight, { "aria-hidden": "true", className: "ml-auto size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" })] })) }));
|
|
46
20
|
};
|
|
47
21
|
const DropdownMenu = ({ 'data-testid': dataTestId, ...props }) => {
|
|
48
22
|
const prefix = useTestIdPrefix();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaMenuItem","_jsxs","AriaMenu","AriaSeparator","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaMenuItem","_jsxs","AriaMenu","AriaSeparator","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":";;;;;;;;;;;AA4CA,MAAM,YAAY,GAAG,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,IAAI,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,GAAG,WAAW,EAChC,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACU,KAAI;AACtB,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;AAChC,IAAA,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC;IAC7D,MAAM,UAAU,GAAG,UAAU,KAAK,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAE,CAAC,GAAG,SAAS,CAAC;IAE5F,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAOA,GAAA,CAACC,QAAY,EAAA,EAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAA,aAAA,EAAe,UAAU,EAA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AAU,EAAE,CAAC;AAEvG,IAAA,QACEA,GAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/BA,GAAA,CAACK,WAAe,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB,EAAA,CACzC;AAErB,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;AACxB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAEC,WAAe;AACxB,IAAA,aAAa,EAAEC,MAAU;AACzB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,SAAS,EAAE,iBAAiB;AAC5B,IAAA,UAAU,EAAE,kBAAkB;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Chooses the test-id segment for a dropdown item.
|
|
7
|
+
*
|
|
8
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
9
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
10
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
11
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
12
|
+
*/
|
|
13
|
+
const dropdownItemSegment = (id, label, children) => {
|
|
14
|
+
if (id !== undefined)
|
|
15
|
+
return testIdUtils.slugifyTestId(String(id));
|
|
16
|
+
if (typeof label === 'string')
|
|
17
|
+
return testIdUtils.slugifyTestId(label);
|
|
18
|
+
if (typeof children === 'string')
|
|
19
|
+
return testIdUtils.slugifyTestId(children);
|
|
20
|
+
return 'item';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.dropdownItemSegment = dropdownItemSegment;
|
|
24
|
+
//# sourceMappingURL=dropdown.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.cjs","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"sourcesContent":[null],"names":["slugifyTestId"],"mappings":";;;;AAEA;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAA+B,EAAE,KAAyB,EAAE,QAAiB,KAAY;IAC3H,IAAI,EAAE,KAAK,SAAS;AAAE,QAAA,OAAOA,yBAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAOA,yBAAa,CAAC,KAAK,CAAC;IAC1D,IAAI,OAAO,QAAQ,KAAK,QAAQ;AAAE,QAAA,OAAOA,yBAAa,CAAC,QAAQ,CAAC;AAChE,IAAA,OAAO,MAAM;AACf;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chooses the test-id segment for a dropdown item.
|
|
3
|
+
*
|
|
4
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
5
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
6
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
7
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
8
|
+
*/
|
|
9
|
+
export declare const dropdownItemSegment: (id: string | number | undefined, label: string | undefined, children: unknown) => string;
|
|
10
|
+
//# sourceMappingURL=dropdown.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,IAAI,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,OAAO,KAAG,MAKnH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Chooses the test-id segment for a dropdown item.
|
|
5
|
+
*
|
|
6
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
7
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
8
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
9
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
10
|
+
*/
|
|
11
|
+
const dropdownItemSegment = (id, label, children) => {
|
|
12
|
+
if (id !== undefined)
|
|
13
|
+
return slugifyTestId(String(id));
|
|
14
|
+
if (typeof label === 'string')
|
|
15
|
+
return slugifyTestId(label);
|
|
16
|
+
if (typeof children === 'string')
|
|
17
|
+
return slugifyTestId(children);
|
|
18
|
+
return 'item';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { dropdownItemSegment };
|
|
22
|
+
//# sourceMappingURL=dropdown.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.js","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAA+B,EAAE,KAAyB,EAAE,QAAiB,KAAY;IAC3H,IAAI,EAAE,KAAK,SAAS;AAAE,QAAA,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,aAAa,CAAC,KAAK,CAAC;IAC1D,IAAI,OAAO,QAAQ,KAAK,QAAQ;AAAE,QAAA,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChE,IAAA,OAAO,MAAM;AACf;;"}
|