@flipdish/ui-library 0.32.0 → 0.33.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/Avatar/components/AvatarLabelGroup.cjs +6 -4
- package/dist/components/atoms/Avatar/components/AvatarLabelGroup.cjs.map +1 -1
- package/dist/components/atoms/Avatar/components/AvatarLabelGroup.d.ts +7 -1
- package/dist/components/atoms/Avatar/components/AvatarLabelGroup.d.ts.map +1 -1
- package/dist/components/atoms/Avatar/components/AvatarLabelGroup.js +6 -4
- package/dist/components/atoms/Avatar/components/AvatarLabelGroup.js.map +1 -1
- package/dist/components/atoms/Badge/badge.types.cjs.map +1 -1
- package/dist/components/atoms/Badge/badge.types.d.ts +2 -1
- package/dist/components/atoms/Badge/badge.types.d.ts.map +1 -1
- package/dist/components/atoms/Badge/badge.types.js.map +1 -1
- package/dist/components/atoms/Badge/index.cjs +2 -1
- package/dist/components/atoms/Badge/index.cjs.map +1 -1
- package/dist/components/atoms/Badge/index.d.ts.map +1 -1
- package/dist/components/atoms/Badge/index.js +2 -1
- package/dist/components/atoms/Badge/index.js.map +1 -1
- package/dist/components/atoms/Card/index.cjs +28 -0
- package/dist/components/atoms/Card/index.cjs.map +1 -0
- package/dist/components/atoms/Card/index.d.ts +20 -0
- package/dist/components/atoms/Card/index.d.ts.map +1 -0
- package/dist/components/atoms/Card/index.js +26 -0
- package/dist/components/atoms/Card/index.js.map +1 -0
- package/dist/components/atoms/CopyButton/index.cjs +27 -0
- package/dist/components/atoms/CopyButton/index.cjs.map +1 -0
- package/dist/components/atoms/CopyButton/index.d.ts +28 -0
- package/dist/components/atoms/CopyButton/index.d.ts.map +1 -0
- package/dist/components/atoms/CopyButton/index.js +25 -0
- package/dist/components/atoms/CopyButton/index.js.map +1 -0
- package/dist/components/atoms/Flag/flag.types.d.ts +6 -0
- package/dist/components/atoms/Flag/flag.types.d.ts.map +1 -0
- package/dist/components/atoms/Flag/flag.utils.cjs +45 -0
- package/dist/components/atoms/Flag/flag.utils.cjs.map +1 -0
- package/dist/components/atoms/Flag/flag.utils.d.ts +15 -0
- package/dist/components/atoms/Flag/flag.utils.d.ts.map +1 -0
- package/dist/components/atoms/Flag/flag.utils.js +42 -0
- package/dist/components/atoms/Flag/flag.utils.js.map +1 -0
- package/dist/components/atoms/Flag/index.cjs +47 -0
- package/dist/components/atoms/Flag/index.cjs.map +1 -0
- package/dist/components/atoms/Flag/index.d.ts +27 -0
- package/dist/components/atoms/Flag/index.d.ts.map +1 -0
- package/dist/components/atoms/Flag/index.js +45 -0
- package/dist/components/atoms/Flag/index.js.map +1 -0
- package/dist/components/atoms/SearchInput/index.cjs +32 -0
- package/dist/components/atoms/SearchInput/index.cjs.map +1 -0
- package/dist/components/atoms/SearchInput/index.d.ts +40 -0
- package/dist/components/atoms/SearchInput/index.d.ts.map +1 -0
- package/dist/components/atoms/SearchInput/index.js +30 -0
- package/dist/components/atoms/SearchInput/index.js.map +1 -0
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.cjs +81 -0
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.cjs.map +1 -0
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.d.ts +46 -0
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.d.ts.map +1 -0
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.js +79 -0
- package/dist/components/molecules/Carousel/hooks/useCarouselScroll.js.map +1 -0
- package/dist/components/molecules/Carousel/index.cjs +8 -55
- package/dist/components/molecules/Carousel/index.cjs.map +1 -1
- package/dist/components/molecules/Carousel/index.d.ts +3 -7
- package/dist/components/molecules/Carousel/index.d.ts.map +1 -1
- package/dist/components/molecules/Carousel/index.js +9 -56
- package/dist/components/molecules/Carousel/index.js.map +1 -1
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.cjs +17 -0
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.cjs.map +1 -0
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.d.ts +8 -0
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.d.ts.map +1 -0
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.js +15 -0
- package/dist/components/molecules/CodeSnippet/codeSnippet.utils.js.map +1 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.cjs +29 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.cjs.map +1 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.d.ts +29 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.d.ts.map +1 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.js +27 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetCollapse.js.map +1 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetHighlight.cjs +23 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetHighlight.cjs.map +1 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetHighlight.d.ts +21 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetHighlight.d.ts.map +1 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetHighlight.js +21 -0
- package/dist/components/molecules/CodeSnippet/hooks/useCodeSnippetHighlight.js.map +1 -0
- package/dist/components/molecules/CodeSnippet/index.cjs +7 -22
- package/dist/components/molecules/CodeSnippet/index.cjs.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.d.ts.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.js +8 -23
- package/dist/components/molecules/CodeSnippet/index.js.map +1 -1
- package/dist/components/molecules/DetailList/detailList.types.d.ts +15 -0
- package/dist/components/molecules/DetailList/detailList.types.d.ts.map +1 -0
- package/dist/components/molecules/DetailList/index.cjs +32 -0
- package/dist/components/molecules/DetailList/index.cjs.map +1 -0
- package/dist/components/molecules/DetailList/index.d.ts +26 -0
- package/dist/components/molecules/DetailList/index.d.ts.map +1 -0
- package/dist/components/molecules/DetailList/index.js +30 -0
- package/dist/components/molecules/DetailList/index.js.map +1 -0
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.cjs +43 -0
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.cjs.map +1 -0
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.d.ts +24 -0
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.d.ts.map +1 -0
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.js +41 -0
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.js.map +1 -0
- package/dist/components/molecules/RadioGroup/index.cjs +2 -0
- package/dist/components/molecules/RadioGroup/index.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/index.d.ts +2 -0
- package/dist/components/molecules/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/index.js +1 -0
- package/dist/components/molecules/RadioGroup/index.js.map +1 -1
- package/dist/components/molecules/RadioGroup/radioGroup.types.d.ts +17 -1
- package/dist/components/molecules/RadioGroup/radioGroup.types.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/applicationHeader.types.d.ts +8 -2
- package/dist/components/organisms/ApplicationHeader/applicationHeader.types.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/components/AvatarButton.cjs +4 -1
- package/dist/components/organisms/ApplicationHeader/components/AvatarButton.cjs.map +1 -1
- package/dist/components/organisms/ApplicationHeader/components/AvatarButton.d.ts +2 -1
- package/dist/components/organisms/ApplicationHeader/components/AvatarButton.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/components/AvatarButton.js +4 -1
- package/dist/components/organisms/ApplicationHeader/components/AvatarButton.js.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.cjs +1 -1
- package/dist/components/organisms/ApplicationHeader/index.cjs.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.js +1 -1
- package/dist/components/organisms/ApplicationHeader/index.js.map +1 -1
- package/dist/components/organisms/DatePicker/calendarCell.utils.cjs +53 -0
- package/dist/components/organisms/DatePicker/calendarCell.utils.cjs.map +1 -0
- package/dist/components/organisms/DatePicker/calendarCell.utils.d.ts +70 -0
- package/dist/components/organisms/DatePicker/calendarCell.utils.d.ts.map +1 -0
- package/dist/components/organisms/DatePicker/calendarCell.utils.js +49 -0
- package/dist/components/organisms/DatePicker/calendarCell.utils.js.map +1 -0
- package/dist/components/organisms/DatePicker/components/Cell.cjs +24 -30
- package/dist/components/organisms/DatePicker/components/Cell.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/components/Cell.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/components/Cell.js +25 -31
- package/dist/components/organisms/DatePicker/components/Cell.js.map +1 -1
- package/dist/components/organisms/FileUpload/fileUpload.utils.cjs +69 -0
- package/dist/components/organisms/FileUpload/fileUpload.utils.cjs.map +1 -0
- package/dist/components/organisms/FileUpload/fileUpload.utils.d.ts +46 -0
- package/dist/components/organisms/FileUpload/fileUpload.utils.d.ts.map +1 -0
- package/dist/components/organisms/FileUpload/fileUpload.utils.js +65 -0
- package/dist/components/organisms/FileUpload/fileUpload.utils.js.map +1 -0
- package/dist/components/organisms/FileUpload/index.cjs +15 -66
- package/dist/components/organisms/FileUpload/index.cjs.map +1 -1
- package/dist/components/organisms/FileUpload/index.d.ts.map +1 -1
- package/dist/components/organisms/FileUpload/index.js +13 -64
- package/dist/components/organisms/FileUpload/index.js.map +1 -1
- package/dist/components/organisms/HeaderNavigation/index.cjs +2 -3
- package/dist/components/organisms/HeaderNavigation/index.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/index.d.ts.map +1 -1
- package/dist/components/organisms/HeaderNavigation/index.js +2 -3
- package/dist/components/organisms/HeaderNavigation/index.js.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.cjs +3 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.js +3 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.js.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.cjs +3 -3
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.d.ts +7 -2
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.js +3 -3
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.js.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.cjs +7 -3
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.d.ts +6 -2
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.js +7 -3
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.js.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.cjs +8 -3
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.d.ts +2 -1
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.js +8 -3
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.js.map +1 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.cjs +12 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.d.ts +3 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.js +13 -2
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.js.map +1 -1
- package/dist/components/organisms/SidePanel/index.cjs +2 -2
- package/dist/components/organisms/SidePanel/index.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/index.d.ts +3 -1
- package/dist/components/organisms/SidePanel/index.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/index.js +2 -2
- package/dist/components/organisms/SidePanel/index.js.map +1 -1
- package/dist/components/organisms/TreeView/index.cjs +11 -26
- package/dist/components/organisms/TreeView/index.cjs.map +1 -1
- package/dist/components/organisms/TreeView/index.d.ts.map +1 -1
- package/dist/components/organisms/TreeView/index.js +12 -27
- package/dist/components/organisms/TreeView/index.js.map +1 -1
- package/dist/components/organisms/TreeView/treeView.utils.cjs +40 -0
- package/dist/components/organisms/TreeView/treeView.utils.cjs.map +1 -1
- package/dist/components/organisms/TreeView/treeView.utils.d.ts +37 -0
- package/dist/components/organisms/TreeView/treeView.utils.d.ts.map +1 -1
- package/dist/components/organisms/TreeView/treeView.utils.js +39 -1
- package/dist/components/organisms/TreeView/treeView.utils.js.map +1 -1
- package/dist/native/components/atoms/Card/index.d.ts +12 -0
- package/dist/native/components/atoms/CopyButton/index.d.ts +12 -0
- package/dist/native/components/atoms/Flag/index.d.ts +12 -0
- package/dist/native/components/atoms/SearchInput/index.d.ts +12 -0
- package/dist/native/components/molecules/DetailList/index.d.ts +12 -0
- package/package.json +3 -2
|
@@ -6,9 +6,12 @@ import { useClipboard } from '@flipdish/ui-library/hooks/useClipboard';
|
|
|
6
6
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
7
7
|
import { useResolvedTestId, TestIdProvider, joinTestId, useTestIdPrefix, slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
8
8
|
import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
|
|
9
|
-
import { createContext,
|
|
9
|
+
import { createContext, useContext, Fragment, useRef } from 'react';
|
|
10
10
|
import { Tabs, TabList, Tab, TabPanel } from 'react-aria-components';
|
|
11
11
|
import { codeToHast } from 'shiki/bundle/web';
|
|
12
|
+
import { getActiveTabPanelText } from './codeSnippet.utils.js';
|
|
13
|
+
import { useCodeSnippetCollapse } from './hooks/useCodeSnippetCollapse.js';
|
|
14
|
+
import { useCodeSnippetHighlight } from './hooks/useCodeSnippetHighlight.js';
|
|
12
15
|
|
|
13
16
|
const highlight = async (code, lang) => {
|
|
14
17
|
const out = await codeToHast(code, {
|
|
@@ -54,31 +57,17 @@ const gradientStyles = {
|
|
|
54
57
|
'--gradient-dark': 'rgba(12, 14, 18, 0) 0%, rgba(12, 14, 18, 0.02) 4.7%, rgba(12, 14, 18, 0.04) 8.9%, rgba(12, 14, 18, 0.07) 12.8%, rgba(12, 14, 18, 0.10) 16.56%, rgba(12, 14, 18, 0.14) 20.37%, rgba(12, 14, 18, 0.18) 24.4%, rgba(12, 14, 18, 0.23) 28.83%, rgba(12, 14, 18, 0.29) 33.84%, rgba(12, 14, 18, 0.35) 39.6%, rgba(12, 14, 18, 0.43) 46.3%, rgba(12, 14, 18, 0.52) 54.1%, rgba(12, 14, 18, 0.62) 63.2%, rgba(12, 14, 18, 0.73) 73.76%, rgba(12, 14, 18, 0.86) 85.97%, rgb(12, 14, 18) 100%',
|
|
55
58
|
};
|
|
56
59
|
const CodeSnippetComponent = ({ children, code, language, showLineNumbers = true, maxHeight, onExpand, className, modern = true, 'data-testid': dataTestId, ...otherProps }) => {
|
|
57
|
-
const
|
|
60
|
+
const nodes = useCodeSnippetHighlight({ code, language, fallback: children, highlightCode: highlight });
|
|
58
61
|
const { copy, copied } = useClipboard();
|
|
59
|
-
const contentRef =
|
|
60
|
-
const [expanded, setExpanded] = useState(false);
|
|
61
|
-
const [exceedsMaxHeight, setExceedsMaxHeight] = useState(false);
|
|
62
|
+
const { contentRef, expanded, exceedsMaxHeight, toggleExpanded } = useCodeSnippetCollapse({ maxHeight, nodes, children });
|
|
62
63
|
const isInsideTabs = useContext(TabsRefContext) !== null;
|
|
63
64
|
const codeSnippetTestId = useResolvedTestId({ testId: dataTestId, segment: 'code-snippet', rootName: 'code-snippet' });
|
|
64
|
-
useLayoutEffect(() => {
|
|
65
|
-
if (!code)
|
|
66
|
-
return;
|
|
67
|
-
void highlight(code, language).then(setNodes);
|
|
68
|
-
}, [code, language]);
|
|
69
|
-
// Measure whether content exceeds maxHeight
|
|
70
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: We need to include maxHeight, nodes, and children in the dependency array to re-measure the content height
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (!maxHeight || !contentRef.current)
|
|
73
|
-
return;
|
|
74
|
-
setExceedsMaxHeight(contentRef.current.scrollHeight > maxHeight - 10);
|
|
75
|
-
}, [maxHeight, nodes, children]);
|
|
76
65
|
const codeText = code ?? '';
|
|
77
66
|
const isCollapsible = maxHeight != null && exceedsMaxHeight;
|
|
78
67
|
const isModern = isInsideTabs || modern;
|
|
79
68
|
const codeBlock = (jsx(TestIdProvider, { value: codeSnippetTestId, children: jsxs("div", { ...otherProps, "data-testid": codeSnippetTestId, className: cx('group/code-snippet relative max-w-full overflow-clip rounded-xl bg-primary ring-1', isModern ? 'shadow-lg ring-secondary_alt' : 'ring-secondary', className), children: [jsx("div", { ref: contentRef, className: cx('[&>.shiki]:overflow-x-auto [&>code]:w-full', 'font-mono text-sm leading-[22px] whitespace-pre', showLineNumbers ? 'line-numbers' : 'p-4', !expanded && isCollapsible && 'overflow-y-hidden', isCollapsible && 'pb-12'), style: {
|
|
80
69
|
maxHeight: expanded || !maxHeight ? 'none' : maxHeight,
|
|
81
|
-
}, children: nodes ?? code ?? jsx("p", { children: "Loading..." }) }), isCollapsible && (jsx("div", { style: gradientStyles, className: cx('inset-x-0 bottom-0 flex items-end justify-center bg-linear-(--gradient-light) pb-6 dark:bg-linear-(--gradient-dark)', expanded ? 'sticky h-17' : 'absolute h-47'), children: jsx(Button, { color: "secondary", size: "sm", onClick:
|
|
70
|
+
}, children: nodes ?? code ?? jsx("p", { children: "Loading..." }) }), isCollapsible && (jsx("div", { style: gradientStyles, className: cx('inset-x-0 bottom-0 flex items-end justify-center bg-linear-(--gradient-light) pb-6 dark:bg-linear-(--gradient-dark)', expanded ? 'sticky h-17' : 'absolute h-47'), children: jsx(Button, { color: "secondary", size: "sm", onClick: toggleExpanded, children: expanded ? 'Show less' : 'Show more' }) })), (codeText || onExpand) && (jsxs("div", { className: "absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 transition duration-100 ease-linear group-hover/code-snippet:opacity-100 has-[:focus-visible]:opacity-100", children: [onExpand && (jsx(ButtonUtility, { size: "xs", color: "tertiary", icon: Expand06, tooltip: "Expand", onClick: onExpand, "data-testid": joinTestId(codeSnippetTestId, 'expand') })), codeText && (jsx(ButtonUtility, { size: "xs", color: "tertiary", icon: copied ? Check : Copy01, tooltip: "Copy", onClick: () => copy(codeText), "data-testid": joinTestId(codeSnippetTestId, 'copy') }))] }))] }) }));
|
|
82
71
|
// Inside tabs: tabs component already provides the outer wrapper
|
|
83
72
|
if (isInsideTabs)
|
|
84
73
|
return codeBlock;
|
|
@@ -98,11 +87,7 @@ const CodeSnippetTabList = ({ children, className, ...otherProps }) => {
|
|
|
98
87
|
const { copy, copied } = useClipboard();
|
|
99
88
|
const tabsRef = useContext(TabsRefContext);
|
|
100
89
|
const handleCopy = () => {
|
|
101
|
-
const
|
|
102
|
-
if (!root)
|
|
103
|
-
return;
|
|
104
|
-
const activePanel = root.querySelector('[role="tabpanel"]:not([hidden])');
|
|
105
|
-
const text = activePanel?.textContent?.trim() ?? '';
|
|
90
|
+
const text = getActiveTabPanelText(tabsRef?.current ?? null);
|
|
106
91
|
if (text)
|
|
107
92
|
copy(text);
|
|
108
93
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/CodeSnippet/index.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","AriaTabs","AriaTabList","AriaTab","AriaTabPanel"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/CodeSnippet/index.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","AriaTabs","AriaTabList","AriaTab","AriaTabPanel"],"mappings":";;;;;;;;;;;;;;;AAsBO,MAAM,SAAS,GAAG,OAAO,IAAY,EAAE,IAAe,KAAI;AAC/D,IAAA,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE;AACjC,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,YAAY,EAAE,OAAO;AACrB,QAAA,MAAM,EAAE;AACN,YAAA,KAAK,EAAE,cAAc;AACrB,YAAA,IAAI,EAAE,aAAa;AACpB,SAAA;AACD,QAAA,iBAAiB,EAAE;AACjB,YAAA,cAAc,EAAE;AACd,gBAAA,SAAS,EAAE,2BAA2B;AACtC,gBAAA,SAAS,EAAE,+BAA+B;AAC1C,gBAAA,SAAS,EAAE,+BAA+B;AAC1C,gBAAA,SAAS,EAAE,gCAAgC;AAC3C,gBAAA,SAAS,EAAE,sBAAsB;AAClC,aAAA;AACD,YAAA,aAAa,EAAE;AACb,gBAAA,SAAS,EAAE,2BAA2B;AACtC,gBAAA,SAAS,EAAE,+BAA+B;AAC1C,gBAAA,SAAS,EAAE,+BAA+B;AAC1C,gBAAA,SAAS,EAAE,gCAAgC;AAC3C,gBAAA,SAAS,EAAE,sBAAsB;AAClC,aAAA;AACF,SAAA;AACF,KAAA,CAAC;IAEF,OAAO,YAAY,CAAC,GAAG,EAAE;QACvB,QAAQ;QACR,GAAG;QACH,IAAI;AACL,KAAA,CAAC;AACJ;AAEA;;;AAGG;AACH,MAAM,cAAc,GAAG,aAAa,CAA0C,IAAI,CAAC;AAEnF;;AAEG;AACH,MAAM,cAAc,GAAG;AACrB,IAAA,kBAAkB,EAChB,2fAA2f;AAC7f,IAAA,iBAAiB,EACf,sdAAsd;CACxc;AAmDlB,MAAM,oBAAoB,GAAG,CAAC,EAC5B,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,eAAe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AAE,CACA,2NAA2N,EAC3N,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,SAAS,KAAK,cAAc,EACvD,KAAK,CAAC,cAAc,IAAI,WAAW,EACnC,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAC/D,EAAA,QAAA,EAGF,QAAQ,EAAA,CACD;AAEd,CAAC;AAED,MAAM,mBAAmB,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,UAAU,EAAiB,KAAI;AACpF,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;IAChC,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,KAAK,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO;AAC3F,IAAA,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA,MAAA,EAAS,MAAM,CAAA,CAAE,CAAC,GAAG,SAAS;AAE9E,IAAA,QACEJ,GAAA,CAACK,QAAY,EAAA,EAAA,GACP,UAAU,iBACD,WAAW,EACxB,SAAS,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,WAAW,EAAE,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,YAEpG,QAAQ,EAAA,CACI;AAEnB,CAAC;AAED;;;;;AAKG;AACI,MAAM,WAAW,GAAG;AAO3B,WAAW,CAAC,IAAI,GAAG,eAAe;AAClC,WAAW,CAAC,OAAO,GAAG,kBAAkB;AACxC,WAAW,CAAC,GAAG,GAAG,cAAc;AAChC,WAAW,CAAC,QAAQ,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FC, ReactElement, ReactNode } from 'react';
|
|
2
|
+
/** One row of a `DetailList`: an icon, the label and the value it describes. */
|
|
3
|
+
export type DetailListItemType = {
|
|
4
|
+
/** Stable key and test-id segment; the slugified `label` is used when absent. */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Icon component, or a ready element such as a `Flag`, centred in the row's `FeaturedIcon`. */
|
|
7
|
+
icon: FC<{
|
|
8
|
+
className?: string;
|
|
9
|
+
}> | ReactElement;
|
|
10
|
+
/** What the value is, rendered as the term. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** The value itself: text, or an element such as a `Badge`. */
|
|
13
|
+
value: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=detailList.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detailList.types.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/DetailList/detailList.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzD,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iFAAiF;IACjF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gGAAgG;IAChG,IAAI,EAAE,EAAE,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,YAAY,CAAC;IAChD,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var FeaturedIcon = require('@flipdish/ui-library/components/atoms/FeaturedIcon');
|
|
5
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
|
+
|
|
8
|
+
// Row padding equals the icon width plus the gap, so the term and value sit beside the centred icon.
|
|
9
|
+
const sizes = {
|
|
10
|
+
sm: { list: 'gap-4', row: 'pl-11', icon: 'sm', text: 'text-sm' },
|
|
11
|
+
md: { list: 'gap-5', row: 'pl-14', icon: 'md', text: 'text-md' },
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Read-only facts about one record, each row an icon, a label and its value, such as an
|
|
15
|
+
* organisation's type, contact email and country. Use it on summary panels and detail pages
|
|
16
|
+
* where the values are shown, not edited.
|
|
17
|
+
*
|
|
18
|
+
* @summary icon-led label and value rows for one record
|
|
19
|
+
*/
|
|
20
|
+
const DetailList = ({ items, size = 'sm', iconColor = 'brand', iconTheme = 'light', className, 'data-testid': dataTestId, }) => {
|
|
21
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'detail-list', rootName: 'detail-list' });
|
|
22
|
+
const styles = sizes[size];
|
|
23
|
+
const renderItem = (item) => {
|
|
24
|
+
const key = item.id ?? testIdUtils.slugifyTestId(item.label);
|
|
25
|
+
// The icon lives inside the term and is positioned against the group, so the group holds only `dt` and `dd` as the `dl` content model requires.
|
|
26
|
+
return (jsxRuntime.jsxs("div", { "data-testid": testIdUtils.joinTestId(rootTestId, `item-${key}`), className: cx.cx('relative flex flex-col gap-1', styles.row), children: [jsxRuntime.jsxs("dt", { className: cx.cx('truncate text-primary', styles.text), children: [jsxRuntime.jsx("span", { "aria-hidden": "true", className: "contents", children: jsxRuntime.jsx(FeaturedIcon.FeaturedIcon, { icon: item.icon, size: styles.icon, color: iconColor, theme: iconTheme, className: "absolute top-1/2 left-0 -translate-y-1/2" }) }), item.label] }), jsxRuntime.jsx("dd", { className: cx.cx('truncate font-semibold text-primary', styles.text), children: item.value })] }, key));
|
|
27
|
+
};
|
|
28
|
+
return (jsxRuntime.jsx("dl", { "data-testid": rootTestId, className: cx.cx('flex flex-col', styles.list, className), children: items.map(renderItem) }));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.DetailList = DetailList;
|
|
32
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/DetailList/index.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","slugifyTestId","_jsxs","joinTestId","cx","_jsx","FeaturedIcon"],"mappings":";;;;;;;AASA;AACA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;AAChE,IAAA,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;CACxD;AAiBV;;;;;;AAMG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,OAAO,EACnB,SAAS,GAAG,OAAO,EACnB,SAAS,EACT,aAAa,EAAE,UAAU,GACT,KAAI;AACpB,IAAA,MAAM,UAAU,GAAGA,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7G,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;AAE1B,IAAA,MAAM,UAAU,GAAG,CAAC,IAAwB,KAAI;AAC9C,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,IAAIC,yBAAa,CAAC,IAAI,CAAC,KAAK,CAAC;;QAGhD,QACEC,wCAA4BC,sBAAU,CAAC,UAAU,EAAE,CAAA,KAAA,EAAQ,GAAG,CAAA,CAAE,CAAC,EAAE,SAAS,EAAEC,KAAE,CAAC,8BAA8B,EAAE,MAAM,CAAC,GAAG,CAAC,EAAA,QAAA,EAAA,CAC1HF,wBAAI,SAAS,EAAEE,KAAE,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,EAAA,QAAA,EAAA,CAErDC,wCAAkB,MAAM,EAAC,SAAS,EAAC,UAAU,YAC3CA,cAAA,CAACC,yBAAY,EAAA,EACX,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAC,0CAA0C,EAAA,CACpD,EAAA,CACG,EACN,IAAI,CAAC,KAAK,CAAA,EAAA,CACR,EACLD,uBAAI,SAAS,EAAED,KAAE,CAAC,qCAAqC,EAAE,MAAM,CAAC,IAAI,CAAC,EAAA,QAAA,EAAG,IAAI,CAAC,KAAK,GAAM,CAAA,EAAA,EAdhF,GAAG,CAeP;AAEV,IAAA,CAAC;IAED,QACEC,cAAA,CAAA,IAAA,EAAA,EAAA,aAAA,EAAiB,UAAU,EAAE,SAAS,EAAED,KAAE,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,EAAA,QAAA,EAChF,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAA,CACnB;AAET;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type FeaturedIconProps } from '@flipdish/ui-library/components/atoms/FeaturedIcon';
|
|
2
|
+
import type { DetailListItemType } from './detailList.types';
|
|
3
|
+
export type { DetailListItemType } from './detailList.types';
|
|
4
|
+
export interface DetailListProps {
|
|
5
|
+
/** Rows to show, in order; each `id` (or slugified `label`) must be unique. */
|
|
6
|
+
items: DetailListItemType[];
|
|
7
|
+
/** Icon size and text scale of every row. */
|
|
8
|
+
size?: 'sm' | 'md';
|
|
9
|
+
/** Semantic colour of every row's `FeaturedIcon`. */
|
|
10
|
+
iconColor?: FeaturedIconProps['color'];
|
|
11
|
+
/** Container style of every row's `FeaturedIcon`. */
|
|
12
|
+
iconTheme?: FeaturedIconProps['theme'];
|
|
13
|
+
/** Extra classes merged onto the `<dl>`. */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Overrides the root `data-testid` (defaults to `fd-detail-list`). Rows derive `<root>--item-<id>` from it. */
|
|
16
|
+
'data-testid'?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Read-only facts about one record, each row an icon, a label and its value, such as an
|
|
20
|
+
* organisation's type, contact email and country. Use it on summary panels and detail pages
|
|
21
|
+
* where the values are shown, not edited.
|
|
22
|
+
*
|
|
23
|
+
* @summary icon-led label and value rows for one record
|
|
24
|
+
*/
|
|
25
|
+
export declare const DetailList: ({ items, size, iconColor, iconTheme, className, "data-testid": dataTestId, }: DetailListProps) => import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/DetailList/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAG1G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAQ7D,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvC,qDAAqD;IACrD,SAAS,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gHAAgH;IAChH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,8EAOxB,eAAe,gCAiCjB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { FeaturedIcon } from '@flipdish/ui-library/components/atoms/FeaturedIcon';
|
|
3
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
|
+
import { useResolvedTestId, slugifyTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
|
+
|
|
6
|
+
// Row padding equals the icon width plus the gap, so the term and value sit beside the centred icon.
|
|
7
|
+
const sizes = {
|
|
8
|
+
sm: { list: 'gap-4', row: 'pl-11', icon: 'sm', text: 'text-sm' },
|
|
9
|
+
md: { list: 'gap-5', row: 'pl-14', icon: 'md', text: 'text-md' },
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Read-only facts about one record, each row an icon, a label and its value, such as an
|
|
13
|
+
* organisation's type, contact email and country. Use it on summary panels and detail pages
|
|
14
|
+
* where the values are shown, not edited.
|
|
15
|
+
*
|
|
16
|
+
* @summary icon-led label and value rows for one record
|
|
17
|
+
*/
|
|
18
|
+
const DetailList = ({ items, size = 'sm', iconColor = 'brand', iconTheme = 'light', className, 'data-testid': dataTestId, }) => {
|
|
19
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'detail-list', rootName: 'detail-list' });
|
|
20
|
+
const styles = sizes[size];
|
|
21
|
+
const renderItem = (item) => {
|
|
22
|
+
const key = item.id ?? slugifyTestId(item.label);
|
|
23
|
+
// The icon lives inside the term and is positioned against the group, so the group holds only `dt` and `dd` as the `dl` content model requires.
|
|
24
|
+
return (jsxs("div", { "data-testid": joinTestId(rootTestId, `item-${key}`), className: cx('relative flex flex-col gap-1', styles.row), children: [jsxs("dt", { className: cx('truncate text-primary', styles.text), children: [jsx("span", { "aria-hidden": "true", className: "contents", children: jsx(FeaturedIcon, { icon: item.icon, size: styles.icon, color: iconColor, theme: iconTheme, className: "absolute top-1/2 left-0 -translate-y-1/2" }) }), item.label] }), jsx("dd", { className: cx('truncate font-semibold text-primary', styles.text), children: item.value })] }, key));
|
|
25
|
+
};
|
|
26
|
+
return (jsx("dl", { "data-testid": rootTestId, className: cx('flex flex-col', styles.list, className), children: items.map(renderItem) }));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { DetailList };
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/DetailList/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;AASA;AACA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;AAChE,IAAA,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;CACxD;AAiBV;;;;;;AAMG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,OAAO,EACnB,SAAS,GAAG,OAAO,EACnB,SAAS,EACT,aAAa,EAAE,UAAU,GACT,KAAI;AACpB,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7G,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;AAE1B,IAAA,MAAM,UAAU,GAAG,CAAC,IAAwB,KAAI;AAC9C,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;;QAGhD,QACEA,6BAA4B,UAAU,CAAC,UAAU,EAAE,CAAA,KAAA,EAAQ,GAAG,CAAA,CAAE,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,8BAA8B,EAAE,MAAM,CAAC,GAAG,CAAC,EAAA,QAAA,EAAA,CAC1HA,aAAI,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,EAAA,QAAA,EAAA,CAErDC,6BAAkB,MAAM,EAAC,SAAS,EAAC,UAAU,YAC3CA,GAAA,CAAC,YAAY,EAAA,EACX,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAC,0CAA0C,EAAA,CACpD,EAAA,CACG,EACN,IAAI,CAAC,KAAK,CAAA,EAAA,CACR,EACLA,YAAI,SAAS,EAAE,EAAE,CAAC,qCAAqC,EAAE,MAAM,CAAC,IAAI,CAAC,EAAA,QAAA,EAAG,IAAI,CAAC,KAAK,GAAM,CAAA,EAAA,EAdhF,GAAG,CAeP;AAEV,IAAA,CAAC;IAED,QACEA,GAAA,CAAA,IAAA,EAAA,EAAA,aAAA,EAAiB,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,EAAA,QAAA,EAChF,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAA,CACnB;AAET;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Avatar = require('@flipdish/ui-library/components/atoms/Avatar');
|
|
5
|
+
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
6
|
+
var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
7
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
8
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var reactAriaComponents = require('react-aria-components');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Radio group where each option is a card with a square logo, title, ID-style subtitle and
|
|
14
|
+
* an optional footer for a link or action. Use to pick a brand, store or other entity by its
|
|
15
|
+
* logo; the footer sits outside the radio, so a link in it never nests inside the control.
|
|
16
|
+
*
|
|
17
|
+
* @summary pick one entity from logo-led cards
|
|
18
|
+
*/
|
|
19
|
+
const RadioGroupAvatarCard = ({ items, size = 'sm', indicator = 'radio', onOptionPress, className, 'data-testid': dataTestId, ...props }) => {
|
|
20
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'radio-group', rootName: 'radio-group' });
|
|
21
|
+
const Indicator = indicator === 'checkbox' ? Checkbox.CheckboxBase : RadioButton.RadioButtonBase;
|
|
22
|
+
// Ids, not test ids: two groups with the same values on one page must not describe each other's options.
|
|
23
|
+
const groupId = React.useId();
|
|
24
|
+
return (jsxRuntime.jsx(reactAriaComponents.RadioGroup, { ...props, "data-testid": rootTestId, className: (state) => cx.cx('flex flex-col gap-3', typeof className === 'function' ? className(state) : className), children: ({ state, isDisabled: isGroupDisabled }) => items.map((item) => {
|
|
25
|
+
const isSelected = state.selectedValue === item.value;
|
|
26
|
+
const isDisabled = isGroupDisabled || Boolean(item.disabled);
|
|
27
|
+
const optionTestId = testIdUtils.joinTestId(rootTestId, `option-${item.value}`);
|
|
28
|
+
// Slugged: a value with spaces would split `aria-describedby` into several ids.
|
|
29
|
+
const subtitleId = item.subtitle ? `${groupId}-${testIdUtils.slugifyTestId(item.value)}-subtitle` : undefined;
|
|
30
|
+
// The radio is the card's `<label>`; a press in the footer is the footer's own and not an option press. Capture phase,
|
|
31
|
+
// because react-aria stops the radio's click from bubbling. Space on the focused radio fires a native click, so keyboard is covered.
|
|
32
|
+
const handleClickCapture = (event) => {
|
|
33
|
+
if (!isDisabled && event.target instanceof Element && event.target.closest('label'))
|
|
34
|
+
onOptionPress?.(item.value);
|
|
35
|
+
};
|
|
36
|
+
return (
|
|
37
|
+
// The card, not the radio, carries the selected ring so the footer sits inside the same outline.
|
|
38
|
+
jsxRuntime.jsxs("div", { onClickCapture: handleClickCapture, className: cx.cx('flex flex-col rounded-xl bg-primary ring-inset', isSelected ? 'ring-2 ring-brand' : 'ring-1 ring-secondary', isDisabled && 'bg-disabled_subtle ring-disabled_subtle'), children: [jsxRuntime.jsx(reactAriaComponents.Radio, { isDisabled: item.disabled, value: item.value, "aria-label": item.title, "aria-describedby": subtitleId, "data-testid": optionTestId, className: ({ isDisabled, isFocusVisible }) => cx.cx('flex cursor-pointer items-center outline-focus-ring', size === 'md' ? 'gap-4 p-5' : 'gap-3 px-4 py-5', item.footer ? 'rounded-t-xl' : 'rounded-xl', isDisabled && 'cursor-not-allowed', isFocusVisible && 'outline-2 outline-offset-2'), children: ({ isDisabled, isSelected, isFocusVisible }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Avatar.Avatar, { size: size === 'md' ? 'xl' : 'lg', rounded: false, border: true, src: item.src, alt: "", initials: item.initials, placeholderIcon: item.placeholderIcon }), jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [jsxRuntime.jsx("span", { className: cx.cx('truncate font-semibold text-primary', size === 'md' ? 'text-lg' : 'text-md'), children: item.title }), item.subtitle && (jsxRuntime.jsx("span", { id: subtitleId, className: cx.cx('truncate text-tertiary', size === 'md' ? 'text-md' : 'text-sm'), children: item.subtitle }))] }), jsxRuntime.jsx(Indicator, { size: size, isDisabled: isDisabled, isSelected: isSelected, isFocusVisible: isFocusVisible })] })) }), item.footer && jsxRuntime.jsx("div", { className: "flex justify-end border-t border-secondary px-4 py-3", children: item.footer })] }, item.value));
|
|
39
|
+
}) }));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.RadioGroupAvatarCard = RadioGroupAvatarCard;
|
|
43
|
+
//# sourceMappingURL=RadioGroupAvatarCard.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroupAvatarCard.cjs","sources":["../../../../../src/components/molecules/RadioGroup/components/RadioGroupAvatarCard.tsx"],"sourcesContent":[null],"names":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EACN,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,eAAe,EAAE,IAAI,CAAC,eAAe,EAAA,CACrC,EACFH,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,8BAA8B,EAAA,QAAA,EAAA,CAC3CL,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAEE,KAAE,CAAC,qCAAqC,EAAE,IAAI,KAAK,IAAI,GAAG,SAAS,GAAG,SAAS,CAAC,EAAA,QAAA,EAAG,IAAI,CAAC,KAAK,EAAA,CAAQ,EACrH,IAAI,CAAC,QAAQ,KACZF,cAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAE,UAAU,EAAE,SAAS,EAAEE,KAAE,CAAC,wBAAwB,EAAE,IAAI,KAAK,IAAI,GAAG,SAAS,GAAG,SAAS,CAAC,EAAA,QAAA,EACjG,IAAI,CAAC,QAAQ,EAAA,CACT,CACR,CAAA,EAAA,CACG,EACNF,cAAA,CAAC,SAAS,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAA,CAAI,CAAA,EAAA,CACxG,CACJ,EAAA,CACS,EACX,IAAI,CAAC,MAAM,IAAIA,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,sDAAsD,EAAA,QAAA,EAAE,IAAI,CAAC,MAAM,EAAA,CAAO,CAAA,EAAA,EAhDpG,IAAI,CAAC,KAAK,CAiDX;QAEV,CAAC,CAAC,EAAA,CAEW;AAErB;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RadioGroupProps } from 'react-aria-components';
|
|
2
|
+
import type { AvatarCardItemType } from '../radioGroup.types';
|
|
3
|
+
interface RadioGroupAvatarCardProps extends RadioGroupProps {
|
|
4
|
+
/** Avatar, text and indicator size of every option. */
|
|
5
|
+
size?: 'sm' | 'md';
|
|
6
|
+
/** Entities to choose from; each `value` is the option value. */
|
|
7
|
+
items: AvatarCardItemType[];
|
|
8
|
+
/** The selection mark: a radio dot, or the check tile the other flavours use. */
|
|
9
|
+
indicator?: 'radio' | 'checkbox';
|
|
10
|
+
/** Called with the option's value on every press of it, selected or not; `onChange` stays silent for the one already selected. */
|
|
11
|
+
onOptionPress?: (value: string) => void;
|
|
12
|
+
/** Overrides the root `data-testid`. Options derive from it (e.g. `<root>--option-<value>`). */
|
|
13
|
+
'data-testid'?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Radio group where each option is a card with a square logo, title, ID-style subtitle and
|
|
17
|
+
* an optional footer for a link or action. Use to pick a brand, store or other entity by its
|
|
18
|
+
* logo; the footer sits outside the radio, so a link in it never nests inside the control.
|
|
19
|
+
*
|
|
20
|
+
* @summary pick one entity from logo-led cards
|
|
21
|
+
*/
|
|
22
|
+
export declare const RadioGroupAvatarCard: ({ items, size, indicator, onOptionPress, className, "data-testid": dataTestId, ...props }: RadioGroupAvatarCardProps) => import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=RadioGroupAvatarCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroupAvatarCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/RadioGroup/components/RadioGroupAvatarCard.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,UAAU,yBAA0B,SAAQ,eAAe;IACzD,uDAAuD;IACvD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,iEAAiE;IACjE,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,iFAAiF;IACjF,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACjC,kIAAkI;IAClI,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,gGAAgG;IAChG,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,2FAQlC,yBAAyB,gCAoF3B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Avatar } from '@flipdish/ui-library/components/atoms/Avatar';
|
|
3
|
+
import { CheckboxBase } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
4
|
+
import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButton';
|
|
5
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
6
|
+
import { useResolvedTestId, joinTestId, slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
+
import { useId } from 'react';
|
|
8
|
+
import { RadioGroup, Radio } from 'react-aria-components';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Radio group where each option is a card with a square logo, title, ID-style subtitle and
|
|
12
|
+
* an optional footer for a link or action. Use to pick a brand, store or other entity by its
|
|
13
|
+
* logo; the footer sits outside the radio, so a link in it never nests inside the control.
|
|
14
|
+
*
|
|
15
|
+
* @summary pick one entity from logo-led cards
|
|
16
|
+
*/
|
|
17
|
+
const RadioGroupAvatarCard = ({ items, size = 'sm', indicator = 'radio', onOptionPress, className, 'data-testid': dataTestId, ...props }) => {
|
|
18
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'radio-group', rootName: 'radio-group' });
|
|
19
|
+
const Indicator = indicator === 'checkbox' ? CheckboxBase : RadioButtonBase;
|
|
20
|
+
// Ids, not test ids: two groups with the same values on one page must not describe each other's options.
|
|
21
|
+
const groupId = useId();
|
|
22
|
+
return (jsx(RadioGroup, { ...props, "data-testid": rootTestId, className: (state) => cx('flex flex-col gap-3', typeof className === 'function' ? className(state) : className), children: ({ state, isDisabled: isGroupDisabled }) => items.map((item) => {
|
|
23
|
+
const isSelected = state.selectedValue === item.value;
|
|
24
|
+
const isDisabled = isGroupDisabled || Boolean(item.disabled);
|
|
25
|
+
const optionTestId = joinTestId(rootTestId, `option-${item.value}`);
|
|
26
|
+
// Slugged: a value with spaces would split `aria-describedby` into several ids.
|
|
27
|
+
const subtitleId = item.subtitle ? `${groupId}-${slugifyTestId(item.value)}-subtitle` : undefined;
|
|
28
|
+
// The radio is the card's `<label>`; a press in the footer is the footer's own and not an option press. Capture phase,
|
|
29
|
+
// because react-aria stops the radio's click from bubbling. Space on the focused radio fires a native click, so keyboard is covered.
|
|
30
|
+
const handleClickCapture = (event) => {
|
|
31
|
+
if (!isDisabled && event.target instanceof Element && event.target.closest('label'))
|
|
32
|
+
onOptionPress?.(item.value);
|
|
33
|
+
};
|
|
34
|
+
return (
|
|
35
|
+
// The card, not the radio, carries the selected ring so the footer sits inside the same outline.
|
|
36
|
+
jsxs("div", { onClickCapture: handleClickCapture, className: cx('flex flex-col rounded-xl bg-primary ring-inset', isSelected ? 'ring-2 ring-brand' : 'ring-1 ring-secondary', isDisabled && 'bg-disabled_subtle ring-disabled_subtle'), children: [jsx(Radio, { isDisabled: item.disabled, value: item.value, "aria-label": item.title, "aria-describedby": subtitleId, "data-testid": optionTestId, className: ({ isDisabled, isFocusVisible }) => cx('flex cursor-pointer items-center outline-focus-ring', size === 'md' ? 'gap-4 p-5' : 'gap-3 px-4 py-5', item.footer ? 'rounded-t-xl' : 'rounded-xl', isDisabled && 'cursor-not-allowed', isFocusVisible && 'outline-2 outline-offset-2'), children: ({ isDisabled, isSelected, isFocusVisible }) => (jsxs(Fragment, { children: [jsx(Avatar, { size: size === 'md' ? 'xl' : 'lg', rounded: false, border: true, src: item.src, alt: "", initials: item.initials, placeholderIcon: item.placeholderIcon }), jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [jsx("span", { className: cx('truncate font-semibold text-primary', size === 'md' ? 'text-lg' : 'text-md'), children: item.title }), item.subtitle && (jsx("span", { id: subtitleId, className: cx('truncate text-tertiary', size === 'md' ? 'text-md' : 'text-sm'), children: item.subtitle }))] }), jsx(Indicator, { size: size, isDisabled: isDisabled, isSelected: isSelected, isFocusVisible: isFocusVisible })] })) }), item.footer && jsx("div", { className: "flex justify-end border-t border-secondary px-4 py-3", children: item.footer })] }, item.value));
|
|
37
|
+
}) }));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { RadioGroupAvatarCard };
|
|
41
|
+
//# sourceMappingURL=RadioGroupAvatarCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroupAvatarCard.js","sources":["../../../../../src/components/molecules/RadioGroup/components/RadioGroupAvatarCard.tsx"],"sourcesContent":[null],"names":["_jsx","AriaRadioGroup","_jsxs","AriaRadio","_Fragment"],"mappings":";;;;;;;;;AA0BA;;;;;;AAMG;AACI,MAAM,oBAAoB,GAAG,CAAC,EACnC,KAAK,EACL,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,OAAO,EACnB,aAAa,EACb,SAAS,EACT,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACkB,KAAI;AAC9B,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7G,IAAA,MAAM,SAAS,GAAG,SAAS,KAAK,UAAU,GAAG,YAAY,GAAG,eAAe;;AAE3E,IAAA,MAAM,OAAO,GAAG,KAAK,EAAE;IAEvB,QACEA,GAAA,CAACC,UAAc,EAAA,EAAA,GACT,KAAK,iBACI,UAAU,EACvB,SAAS,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,qBAAqB,EAAE,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,EAAA,QAAA,EAE9G,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,KACtC,KAAK,CAAC,GAAG,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A,CAAO,CAAA,EAAA,EAhDpG,IAAI,CAAC,KAAK,CAiDX;QAEV,CAAC,CAAC,EAAA,CAEW;AAErB;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var RadioGroupAvatar = require('./components/RadioGroupAvatar.cjs');
|
|
4
|
+
var RadioGroupAvatarCard = require('./components/RadioGroupAvatarCard.cjs');
|
|
4
5
|
var RadioGroupCheckbox = require('./components/RadioGroupCheckbox.cjs');
|
|
5
6
|
var RadioGroupIconCard = require('./components/RadioGroupIconCard.cjs');
|
|
6
7
|
var RadioGroupIconSimple = require('./components/RadioGroupIconSimple.cjs');
|
|
@@ -10,6 +11,7 @@ var RadioGroupRadioButton = require('./components/RadioGroupRadioButton.cjs');
|
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
exports.Avatar = RadioGroupAvatar.RadioGroupAvatar;
|
|
14
|
+
exports.AvatarCard = RadioGroupAvatarCard.RadioGroupAvatarCard;
|
|
13
15
|
exports.Checkbox = RadioGroupCheckbox.RadioGroupCheckbox;
|
|
14
16
|
exports.IconCard = RadioGroupIconCard.RadioGroupIconCard;
|
|
15
17
|
exports.IconSimple = RadioGroupIconSimple.RadioGroupIconSimple;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { RadioGroupAvatar as Avatar } from './components/RadioGroupAvatar';
|
|
2
|
+
export { RadioGroupAvatarCard as AvatarCard } from './components/RadioGroupAvatarCard';
|
|
2
3
|
export { RadioGroupCheckbox as Checkbox } from './components/RadioGroupCheckbox';
|
|
3
4
|
export { RadioGroupIconCard as IconCard } from './components/RadioGroupIconCard';
|
|
4
5
|
export { RadioGroupIconSimple as IconSimple } from './components/RadioGroupIconSimple';
|
|
5
6
|
export { RadioGroupPaymentIcon as PaymentIcon } from './components/RadioGroupPaymentIcon';
|
|
6
7
|
export { RadioGroupRadioButton as RadioButton } from './components/RadioGroupRadioButton';
|
|
8
|
+
export type { AvatarCardItemType } from './radioGroup.types';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,oBAAoB,IAAI,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,oBAAoB,IAAI,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,oBAAoB,IAAI,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC1F,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { RadioGroupAvatar as Avatar } from './components/RadioGroupAvatar.js';
|
|
2
|
+
export { RadioGroupAvatarCard as AvatarCard } from './components/RadioGroupAvatarCard.js';
|
|
2
3
|
export { RadioGroupCheckbox as Checkbox } from './components/RadioGroupCheckbox.js';
|
|
3
4
|
export { RadioGroupIconCard as IconCard } from './components/RadioGroupIconCard.js';
|
|
4
5
|
export { RadioGroupIconSimple as IconSimple } from './components/RadioGroupIconSimple.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
2
|
export type RadioGroupItemType = {
|
|
3
3
|
value: string;
|
|
4
4
|
title: string;
|
|
@@ -9,4 +9,20 @@ export type RadioGroupItemType = {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
}>;
|
|
11
11
|
};
|
|
12
|
+
/** One option of `RadioGroup.AvatarCard`: an entity shown by its logo, with an optional footer outside the radio. */
|
|
13
|
+
export type AvatarCardItemType = {
|
|
14
|
+
value: string;
|
|
15
|
+
title: string;
|
|
16
|
+
/** Secondary line under the title, such as the entity's ID. */
|
|
17
|
+
subtitle?: string;
|
|
18
|
+
/** Logo URL; `initials`, then `placeholderIcon`, stand in when it is unset or fails to load. */
|
|
19
|
+
src?: string;
|
|
20
|
+
initials?: string;
|
|
21
|
+
placeholderIcon?: FC<{
|
|
22
|
+
className?: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** Rendered under the option, outside the radio, so it may hold a link or button. */
|
|
25
|
+
footer?: ReactNode;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
};
|
|
12
28
|
//# sourceMappingURL=radioGroup.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radioGroup.types.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/radioGroup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"radioGroup.types.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/radioGroup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,EAAE,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClC,CAAC;AAEF,qHAAqH;AACrH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,EAAE,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7C,qFAAqF;IACrF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC"}
|
|
@@ -43,8 +43,9 @@ export interface ApplicationHeaderAssistant extends ApplicationHeaderElement {
|
|
|
43
43
|
onPress: () => void;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* The header
|
|
47
|
-
*
|
|
46
|
+
* The header's own panels (`notifications.isOpen`, `assistant.isOpen`). Use it to type the app's "which one
|
|
47
|
+
* is open" state: `useState<ApplicationHeaderPanel | null>(null)`. When the avatar opens a panel too, extend
|
|
48
|
+
* it: `type PortalPanel = ApplicationHeaderPanel | 'organisation'`.
|
|
48
49
|
*/
|
|
49
50
|
export type ApplicationHeaderPanel = 'notifications' | 'assistant';
|
|
50
51
|
export interface ApplicationHeaderAvatar extends Omit<ApplicationHeaderElement, 'label'> {
|
|
@@ -56,6 +57,11 @@ export interface ApplicationHeaderAvatar extends Omit<ApplicationHeaderElement,
|
|
|
56
57
|
initials?: string;
|
|
57
58
|
/** Accessible name for the button. Defaults to `name`. */
|
|
58
59
|
label?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the panel or menu this button opens is open. Highlights the button and sets `aria-expanded`.
|
|
62
|
+
* Leave `undefined` when the button navigates instead of opening something.
|
|
63
|
+
*/
|
|
64
|
+
isOpen?: boolean;
|
|
59
65
|
/** Called when the avatar button is pressed. */
|
|
60
66
|
onPress: () => void;
|
|
61
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationHeader.types.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/ApplicationHeader/applicationHeader.types.ts"],"names":[],"mappings":"AAAA,UAAU,wBAAwB;IAChC,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,qGAAqG;IACrG,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,8BAA+B,SAAQ,wBAAwB;IAC9E,sFAAsF;IACtF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAC1E;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"applicationHeader.types.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/ApplicationHeader/applicationHeader.types.ts"],"names":[],"mappings":"AAAA,UAAU,wBAAwB;IAChC,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,qGAAqG;IACrG,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,8BAA+B,SAAQ,wBAAwB;IAC9E,sFAAsF;IACtF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAC1E;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG,WAAW,CAAC;AAEnE,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC;IACtF,8GAA8G;IAC9G,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE,kEAAkE;IAClE,MAAM,EAAE,OAAO,CAAC;IAChB,kEAAkE;IAClE,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var Avatar = require('@flipdish/ui-library/components/atoms/Avatar');
|
|
5
5
|
var Tooltip = require('@flipdish/ui-library/components/atoms/Tooltip');
|
|
6
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
7
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
8
|
var reactAriaComponents = require('react-aria-components');
|
|
8
9
|
|
|
9
|
-
const AvatarButton = ({ name, src, initials, label, onPress, 'data-testid': dataTestId }) => (jsxRuntime.jsx(Tooltip.Tooltip, { title: label, placement: "bottom", "data-testid": testIdUtils.joinTestId(dataTestId, 'tooltip'), children: jsxRuntime.jsx(reactAriaComponents.Button, { "aria-label": label, "data-testid": dataTestId, onPress: onPress, className:
|
|
10
|
+
const AvatarButton = ({ name, src, initials, label, isOpen, onPress, 'data-testid': dataTestId }) => (jsxRuntime.jsx(Tooltip.Tooltip, { title: label, placement: "bottom", "data-testid": testIdUtils.joinTestId(dataTestId, 'tooltip'), children: jsxRuntime.jsx(reactAriaComponents.Button, { "aria-label": label, "aria-expanded": isOpen, "data-testid": dataTestId, onPress: onPress, className: cx.cx('group flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-md outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2',
|
|
11
|
+
// Only a button that opens something shows the hover and open treatment the other actions have.
|
|
12
|
+
isOpen !== undefined && 'transition duration-100 ease-linear hover:bg-primary_hover', isOpen && 'bg-brand-primary hover:bg-brand-primary'), children: jsxRuntime.jsx(Avatar.Avatar, { size: "sm", rounded: false, src: src, initials: initials ?? Avatar.getInitials(name).toUpperCase(),
|
|
10
13
|
// The design's square avatar uses a 4px radius, tighter than Avatar's unrounded default.
|
|
11
14
|
className: "rounded-sm", contentClassName: "rounded-sm", "data-testid": testIdUtils.joinTestId(dataTestId, 'image') }) }) }));
|
|
12
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarButton.cjs","sources":["../../../../../src/components/organisms/ApplicationHeader/components/AvatarButton.tsx"],"sourcesContent":[null],"names":["_jsx","Tooltip","joinTestId","AriaButton","Avatar","getInitials"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AvatarButton.cjs","sources":["../../../../../src/components/organisms/ApplicationHeader/components/AvatarButton.tsx"],"sourcesContent":[null],"names":["_jsx","Tooltip","joinTestId","AriaButton","cx","Avatar","getInitials"],"mappings":";;;;;;;;;AAkBO,MAAM,YAAY,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAqB,MACxHA,cAAA,CAACC,eAAO,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAC,QAAQ,EAAA,aAAA,EAAcC,sBAAU,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,QAAA,EACtFF,cAAA,CAACG,0BAAU,EAAA,EAAA,YAAA,EACG,KAAK,EAAA,eAAA,EACF,MAAM,EAAA,aAAA,EACR,UAAU,EACvB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAEC,KAAE,CACX,4JAA4J;;AAE5J,QAAA,MAAM,KAAK,SAAS,IAAI,4DAA4D,EACpF,MAAM,IAAI,yCAAyC,CACpD,YAEDJ,cAAA,CAACK,aAAM,EAAA,EACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,KAAK,EACd,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,IAAIC,kBAAW,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;;AAErD,YAAA,SAAS,EAAC,YAAY,EACtB,gBAAgB,EAAC,YAAY,EAAA,aAAA,EAChBJ,sBAAU,CAAC,UAAU,EAAE,OAAO,CAAC,GAC5C,EAAA,CACS,EAAA,CACL;;"}
|
|
@@ -3,9 +3,10 @@ interface AvatarButtonProps {
|
|
|
3
3
|
src?: string;
|
|
4
4
|
initials?: string;
|
|
5
5
|
label: string;
|
|
6
|
+
isOpen?: boolean;
|
|
6
7
|
onPress: () => void;
|
|
7
8
|
'data-testid': string;
|
|
8
9
|
}
|
|
9
|
-
export declare const AvatarButton: ({ name, src, initials, label, onPress, "data-testid": dataTestId }: AvatarButtonProps) => import("react").JSX.Element;
|
|
10
|
+
export declare const AvatarButton: ({ name, src, initials, label, isOpen, onPress, "data-testid": dataTestId }: AvatarButtonProps) => import("react").JSX.Element;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=AvatarButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/ApplicationHeader/components/AvatarButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AvatarButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/ApplicationHeader/components/AvatarButton.tsx"],"names":[],"mappings":"AAQA,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,GAAI,4EAA4E,iBAAiB,gCA0BzH,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Avatar, getInitials } from '@flipdish/ui-library/components/atoms/Avatar';
|
|
3
3
|
import { Tooltip } from '@flipdish/ui-library/components/atoms/Tooltip';
|
|
4
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
5
|
import { joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
6
|
import { Button } from 'react-aria-components';
|
|
6
7
|
|
|
7
|
-
const AvatarButton = ({ name, src, initials, label, onPress, 'data-testid': dataTestId }) => (jsx(Tooltip, { title: label, placement: "bottom", "data-testid": joinTestId(dataTestId, 'tooltip'), children: jsx(Button, { "aria-label": label, "data-testid": dataTestId, onPress: onPress, className:
|
|
8
|
+
const AvatarButton = ({ name, src, initials, label, isOpen, onPress, 'data-testid': dataTestId }) => (jsx(Tooltip, { title: label, placement: "bottom", "data-testid": joinTestId(dataTestId, 'tooltip'), children: jsx(Button, { "aria-label": label, "aria-expanded": isOpen, "data-testid": dataTestId, onPress: onPress, className: cx('group flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-md outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2',
|
|
9
|
+
// Only a button that opens something shows the hover and open treatment the other actions have.
|
|
10
|
+
isOpen !== undefined && 'transition duration-100 ease-linear hover:bg-primary_hover', isOpen && 'bg-brand-primary hover:bg-brand-primary'), children: jsx(Avatar, { size: "sm", rounded: false, src: src, initials: initials ?? getInitials(name).toUpperCase(),
|
|
8
11
|
// The design's square avatar uses a 4px radius, tighter than Avatar's unrounded default.
|
|
9
12
|
className: "rounded-sm", contentClassName: "rounded-sm", "data-testid": joinTestId(dataTestId, 'image') }) }) }));
|
|
10
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarButton.js","sources":["../../../../../src/components/organisms/ApplicationHeader/components/AvatarButton.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AvatarButton.js","sources":["../../../../../src/components/organisms/ApplicationHeader/components/AvatarButton.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton"],"mappings":";;;;;;;AAkBO,MAAM,YAAY,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAqB,MACxHA,GAAA,CAAC,OAAO,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAC,QAAQ,EAAA,aAAA,EAAc,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,QAAA,EACtFA,GAAA,CAACC,MAAU,EAAA,EAAA,YAAA,EACG,KAAK,EAAA,eAAA,EACF,MAAM,EAAA,aAAA,EACR,UAAU,EACvB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,EAAE,CACX,4JAA4J;;AAE5J,QAAA,MAAM,KAAK,SAAS,IAAI,4DAA4D,EACpF,MAAM,IAAI,yCAAyC,CACpD,YAEDD,GAAA,CAAC,MAAM,EAAA,EACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,KAAK,EACd,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;;AAErD,YAAA,SAAS,EAAC,YAAY,EACtB,gBAAgB,EAAC,YAAY,EAAA,aAAA,EAChB,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,GAC5C,EAAA,CACS,EAAA,CACL;;"}
|
|
@@ -38,7 +38,7 @@ const ApplicationHeader = ({ search, notifications, assistant, avatar, menu, hom
|
|
|
38
38
|
const safeHomeHref = hrefUtils.safeHref(homeHref);
|
|
39
39
|
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsxs("header", { "data-testid": rootTestId, className: cx.cx('sticky top-0 z-30 flex h-14 w-full items-center gap-2 border-b border-secondary bg-primary pr-3 pl-4 lg:h-16 lg:px-6', className), children: [menu && (jsxRuntime.jsx(MenuButton.MenuButton, { isOpen: menu.isOpen, onPress: () => menu.onOpenChange(!menu.isOpen), label: menuLabel, controls: menu.controls, className: "lg:hidden", "data-testid": menu['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'menu') })), jsxRuntime.jsx("div", { className: "flex min-w-0 flex-1 items-center lg:hidden", children: safeHomeHref === undefined ? (
|
|
40
40
|
// A rejected `homeHref` leaves a plain logo: no link role, nothing to activate.
|
|
41
|
-
jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm", "data-testid": testIdUtils.joinTestId(rootTestId, 'logo') })) : (jsxRuntime.jsx(reactAriaComponents.Link, { href: safeHomeHref, "aria-label": "Go to homepage", "data-testid": testIdUtils.joinTestId(rootTestId, 'logo'), className: "rounded-xs outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2", children: jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm", "aria-hidden": "true" }) })) }), search && (jsxRuntime.jsx(SearchTrigger.SearchTrigger, { size: "sm", placeholder: search.placeholder ?? 'Search', label: search.label ?? 'Search', onPress: search.onPress, shortcutHint: shortcutHint, className: "w-80 max-lg:hidden", "data-testid": search['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'search') })), hasActions && (jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-2 lg:ml-auto", children: [notifications && (jsxRuntime.jsx(HeaderAction.HeaderAction, { icon: uiIcons.Bell01, label: applicationHeader_utils.getNotificationsLabel(notificationsLabel, notifications.count), tooltip: notificationsLabel, badge: applicationHeader_utils.formatBadgeCount(notifications.count), isOpen: notifications.isOpen, onPress: notifications.onPress, "data-testid": notifications['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'notifications') })), assistant && (jsxRuntime.jsx(HeaderAction.HeaderAction, { icon: uiIcons.Stars01, label: assistantLabel, tooltip: assistantLabel, isOpen: assistant.isOpen, onPress: assistant.onPress, "data-testid": assistant['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'assistant') })), avatar && (jsxRuntime.jsx(AvatarButton.AvatarButton, { name: avatar.name, src: avatar.src, initials: avatar.initials, label: avatar.label ?? avatar.name, onPress: avatar.onPress, "data-testid": avatar['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'avatar') }))] }))] }) }));
|
|
41
|
+
jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm", "data-testid": testIdUtils.joinTestId(rootTestId, 'logo') })) : (jsxRuntime.jsx(reactAriaComponents.Link, { href: safeHomeHref, "aria-label": "Go to homepage", "data-testid": testIdUtils.joinTestId(rootTestId, 'logo'), className: "rounded-xs outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2", children: jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm", "aria-hidden": "true" }) })) }), search && (jsxRuntime.jsx(SearchTrigger.SearchTrigger, { size: "sm", placeholder: search.placeholder ?? 'Search', label: search.label ?? 'Search', onPress: search.onPress, shortcutHint: shortcutHint, className: "w-80 max-lg:hidden", "data-testid": search['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'search') })), hasActions && (jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-2 lg:ml-auto", children: [notifications && (jsxRuntime.jsx(HeaderAction.HeaderAction, { icon: uiIcons.Bell01, label: applicationHeader_utils.getNotificationsLabel(notificationsLabel, notifications.count), tooltip: notificationsLabel, badge: applicationHeader_utils.formatBadgeCount(notifications.count), isOpen: notifications.isOpen, onPress: notifications.onPress, "data-testid": notifications['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'notifications') })), assistant && (jsxRuntime.jsx(HeaderAction.HeaderAction, { icon: uiIcons.Stars01, label: assistantLabel, tooltip: assistantLabel, isOpen: assistant.isOpen, onPress: assistant.onPress, "data-testid": assistant['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'assistant') })), avatar && (jsxRuntime.jsx(AvatarButton.AvatarButton, { name: avatar.name, src: avatar.src, initials: avatar.initials, label: avatar.label ?? avatar.name, isOpen: avatar.isOpen, onPress: avatar.onPress, "data-testid": avatar['data-testid'] ?? testIdUtils.joinTestId(rootTestId, 'avatar') }))] }))] }) }));
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
exports.ApplicationHeader = ApplicationHeader;
|