@bayonai/mui-design 0.2.1 → 1.1.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/CHANGELOG.md +50 -0
- package/README.md +108 -7
- package/dist/cjs/actions/ActionMenu.js +36 -0
- package/dist/cjs/actions/DialogActionButtons.js +33 -0
- package/dist/cjs/actions/LoadingIconButton.js +10 -0
- package/dist/cjs/actions/StickyActionFooter.js +27 -0
- package/dist/cjs/actions/StickySubmitButton.js +10 -0
- package/dist/cjs/actions/index.js +18 -0
- package/dist/cjs/client.js +1 -0
- package/dist/cjs/components/BayonFlowVisual.js +6 -6
- package/dist/cjs/components/BayonThemeModeToggle.js +34 -0
- package/dist/cjs/components/panels.js +7 -7
- package/dist/cjs/drawers/BottomDrawer.js +43 -0
- package/dist/cjs/drawers/MobileBottomDrawer.js +102 -0
- package/dist/cjs/drawers/MobileBottomDrawerHeader.js +36 -0
- package/dist/cjs/drawers/ResponsiveDrawer.js +22 -0
- package/dist/cjs/drawers/drawerAppearance.js +10 -0
- package/dist/cjs/drawers/index.js +17 -0
- package/dist/cjs/drawers/useVisualViewportBottomInset.js +33 -0
- package/dist/cjs/feedback/StatusNotice.js +62 -0
- package/dist/cjs/feedback/index.js +7 -0
- package/dist/cjs/links/LinkAddressPreview.js +80 -0
- package/dist/cjs/links/index.js +9 -0
- package/dist/cjs/links/useLinkAddressPreview.js +152 -0
- package/dist/cjs/pending/PendingChangesDialogShell.js +16 -0
- package/dist/cjs/pending/PendingChangesDialogView.js +126 -0
- package/dist/cjs/pending/PendingChangesIndicatorView.js +27 -0
- package/dist/cjs/pending/index.js +9 -0
- package/dist/cjs/pending/types.js +2 -0
- package/dist/cjs/providers/BayonThemeProvider.js +83 -4
- package/dist/cjs/sections/ExpandableSectionToggle.js +32 -0
- package/dist/cjs/sections/index.js +7 -0
- package/dist/cjs/styles/pageStyles.js +17 -17
- package/dist/cjs/swipe/SwipeActionRow.js +123 -0
- package/dist/cjs/swipe/index.js +8 -0
- package/dist/cjs/theme/components.js +60 -0
- package/dist/cjs/theme/createBayonTheme.js +23 -2
- package/dist/cjs/toasts/ActionToast.js +12 -0
- package/dist/cjs/toasts/Toast.js +55 -0
- package/dist/cjs/toasts/index.js +12 -0
- package/dist/cjs/toasts/useUpwardToastDismiss.js +73 -0
- package/dist/cjs/uploads/CameraCaptureDialog.js +187 -0
- package/dist/cjs/uploads/FileRow.js +23 -0
- package/dist/cjs/uploads/FileSwipeActionRow.js +11 -0
- package/dist/cjs/uploads/FileThumbnail.js +104 -0
- package/dist/cjs/uploads/FileUpload.js +98 -0
- package/dist/cjs/uploads/FileViewer.js +151 -0
- package/dist/cjs/uploads/ImageCropDialog.js +215 -0
- package/dist/cjs/uploads/UploadProgressRing.js +32 -0
- package/dist/cjs/uploads/cameraCropPresentation.js +12 -0
- package/dist/cjs/uploads/index.js +20 -0
- package/dist/esm/actions/ActionMenu.js +30 -0
- package/dist/esm/actions/DialogActionButtons.js +24 -0
- package/dist/esm/actions/LoadingIconButton.js +7 -0
- package/dist/esm/actions/StickyActionFooter.js +24 -0
- package/dist/esm/actions/StickySubmitButton.js +7 -0
- package/dist/esm/actions/index.js +7 -0
- package/dist/esm/client.js +1 -0
- package/dist/esm/components/BayonFlowVisual.js +6 -6
- package/dist/esm/components/BayonThemeModeToggle.js +28 -0
- package/dist/esm/components/panels.js +7 -7
- package/dist/esm/drawers/BottomDrawer.js +37 -0
- package/dist/esm/drawers/MobileBottomDrawer.js +95 -0
- package/dist/esm/drawers/MobileBottomDrawerHeader.js +30 -0
- package/dist/esm/drawers/ResponsiveDrawer.js +19 -0
- package/dist/esm/drawers/drawerAppearance.js +7 -0
- package/dist/esm/drawers/index.js +7 -0
- package/dist/esm/drawers/useVisualViewportBottomInset.js +29 -0
- package/dist/esm/feedback/StatusNotice.js +56 -0
- package/dist/esm/feedback/index.js +3 -0
- package/dist/esm/links/LinkAddressPreview.js +74 -0
- package/dist/esm/links/index.js +4 -0
- package/dist/esm/links/useLinkAddressPreview.js +149 -0
- package/dist/esm/pending/PendingChangesDialogShell.js +10 -0
- package/dist/esm/pending/PendingChangesDialogView.js +120 -0
- package/dist/esm/pending/PendingChangesIndicatorView.js +21 -0
- package/dist/esm/pending/index.js +4 -0
- package/dist/esm/pending/types.js +1 -0
- package/dist/esm/providers/BayonThemeProvider.js +83 -5
- package/dist/esm/sections/ExpandableSectionToggle.js +26 -0
- package/dist/esm/sections/index.js +3 -0
- package/dist/esm/styles/pageStyles.js +17 -17
- package/dist/esm/swipe/SwipeActionRow.js +116 -0
- package/dist/esm/swipe/index.js +3 -0
- package/dist/esm/theme/components.js +60 -0
- package/dist/esm/theme/createBayonTheme.js +23 -2
- package/dist/esm/toasts/ActionToast.js +9 -0
- package/dist/esm/toasts/Toast.js +52 -0
- package/dist/esm/toasts/index.js +5 -0
- package/dist/esm/toasts/useUpwardToastDismiss.js +69 -0
- package/dist/esm/uploads/CameraCaptureDialog.js +181 -0
- package/dist/esm/uploads/FileRow.js +17 -0
- package/dist/esm/uploads/FileSwipeActionRow.js +7 -0
- package/dist/esm/uploads/FileThumbnail.js +98 -0
- package/dist/esm/uploads/FileUpload.js +92 -0
- package/dist/esm/uploads/FileViewer.js +145 -0
- package/dist/esm/uploads/ImageCropDialog.js +212 -0
- package/dist/esm/uploads/UploadProgressRing.js +29 -0
- package/dist/esm/uploads/cameraCropPresentation.js +5 -0
- package/dist/esm/uploads/index.js +9 -0
- package/dist/types/actions/ActionMenu.d.ts +24 -0
- package/dist/types/actions/DialogActionButtons.d.ts +22 -0
- package/dist/types/actions/LoadingIconButton.d.ts +11 -0
- package/dist/types/actions/StickyActionFooter.d.ts +14 -0
- package/dist/types/actions/StickySubmitButton.d.ts +10 -0
- package/dist/types/actions/index.d.ts +5 -0
- package/dist/types/client.d.ts +1 -0
- package/dist/types/components/BayonThemeModeToggle.d.ts +6 -0
- package/dist/types/drawers/BottomDrawer.d.ts +16 -0
- package/dist/types/drawers/MobileBottomDrawer.d.ts +20 -0
- package/dist/types/drawers/MobileBottomDrawerHeader.d.ts +11 -0
- package/dist/types/drawers/ResponsiveDrawer.d.ts +25 -0
- package/dist/types/drawers/drawerAppearance.d.ts +8 -0
- package/dist/types/drawers/index.d.ts +6 -0
- package/dist/types/drawers/useVisualViewportBottomInset.d.ts +6 -0
- package/dist/types/feedback/StatusNotice.d.ts +13 -0
- package/dist/types/feedback/index.d.ts +1 -0
- package/dist/types/links/LinkAddressPreview.d.ts +19 -0
- package/dist/types/links/index.d.ts +3 -0
- package/dist/types/links/useLinkAddressPreview.d.ts +24 -0
- package/dist/types/pending/PendingChangesDialogShell.d.ts +2 -0
- package/dist/types/pending/PendingChangesDialogView.d.ts +2 -0
- package/dist/types/pending/PendingChangesIndicatorView.d.ts +10 -0
- package/dist/types/pending/index.d.ts +3 -0
- package/dist/types/pending/types.d.ts +48 -0
- package/dist/types/providers/BayonThemeProvider.d.ts +10 -1
- package/dist/types/sections/ExpandableSectionToggle.d.ts +12 -0
- package/dist/types/sections/index.d.ts +2 -0
- package/dist/types/swipe/SwipeActionRow.d.ts +8 -0
- package/dist/types/swipe/index.d.ts +1 -0
- package/dist/types/toasts/ActionToast.d.ts +11 -0
- package/dist/types/toasts/Toast.d.ts +16 -0
- package/dist/types/toasts/index.d.ts +5 -0
- package/dist/types/toasts/useUpwardToastDismiss.d.ts +15 -0
- package/dist/types/uploads/CameraCaptureDialog.d.ts +22 -0
- package/dist/types/uploads/FileRow.d.ts +10 -0
- package/dist/types/uploads/FileSwipeActionRow.d.ts +1 -0
- package/dist/types/uploads/FileThumbnail.d.ts +5 -0
- package/dist/types/uploads/FileUpload.d.ts +26 -0
- package/dist/types/uploads/FileViewer.d.ts +9 -0
- package/dist/types/uploads/ImageCropDialog.d.ts +26 -0
- package/dist/types/uploads/UploadProgressRing.d.ts +24 -0
- package/dist/types/uploads/cameraCropPresentation.d.ts +2 -0
- package/dist/types/uploads/index.d.ts +10 -0
- package/docs/camera-crop-contract.md +50 -0
- package/docs/uploads-contract.md +40 -0
- package/package.json +70 -8
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Box } from "@mui/material";
|
|
4
|
+
import SwipeableDrawer from "@mui/material/SwipeableDrawer";
|
|
5
|
+
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
6
|
+
import { defaultDrawerAppearance, } from "./drawerAppearance.js";
|
|
7
|
+
import { MobileBottomDrawerHeader } from "./MobileBottomDrawerHeader.js";
|
|
8
|
+
export const mobileBottomDrawerDismissDuration = 220;
|
|
9
|
+
export function MobileBottomDrawer({ ariaLabel, appearance = defaultDrawerAppearance, closeTooltip, children, contentScrollMode = "container", dataComponent, dismiss = false, handleBackground = "default", handlePlacement = "above-content", headerLeft, headerRight, maxHeight = "calc(100dvh - 24px)", onClose, }) {
|
|
10
|
+
const dismissTimer = useRef(null);
|
|
11
|
+
const [open, setOpen] = useState(true);
|
|
12
|
+
useEffect(() => () => {
|
|
13
|
+
if (dismissTimer.current) {
|
|
14
|
+
clearTimeout(dismissTimer.current);
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
const requestClose = useCallback(() => {
|
|
18
|
+
if (!open || dismissTimer.current) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
setOpen(false);
|
|
22
|
+
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
23
|
+
dismissTimer.current = setTimeout(onClose, prefersReducedMotion ? 0 : mobileBottomDrawerDismissDuration);
|
|
24
|
+
}, [onClose, open]);
|
|
25
|
+
// Product decision: nested dialogs may layer over a retained drawer; the host
|
|
26
|
+
// decides whether closing that dialog also closes its underlying context.
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!dismiss || !open) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
32
|
+
dismissTimer.current = setTimeout(onClose, prefersReducedMotion ? 0 : mobileBottomDrawerDismissDuration);
|
|
33
|
+
return () => {
|
|
34
|
+
if (dismissTimer.current) {
|
|
35
|
+
clearTimeout(dismissTimer.current);
|
|
36
|
+
dismissTimer.current = null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, [dismiss, onClose, open]);
|
|
40
|
+
const paperSlotProps = {
|
|
41
|
+
"aria-label": ariaLabel,
|
|
42
|
+
"data-component": dataComponent !== null && dataComponent !== void 0 ? dataComponent : "mobile-bottom-drawer",
|
|
43
|
+
sx: {
|
|
44
|
+
backgroundColor: appearance.background,
|
|
45
|
+
borderRadius: "16px 16px 0 0",
|
|
46
|
+
bottom: 0,
|
|
47
|
+
boxShadow: appearance.shadow,
|
|
48
|
+
display: "flex",
|
|
49
|
+
flexDirection: "column",
|
|
50
|
+
height: maxHeight,
|
|
51
|
+
maxHeight,
|
|
52
|
+
overflow: "hidden",
|
|
53
|
+
overscrollBehaviorY: "contain",
|
|
54
|
+
width: "100%",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
const drawerHandle = (_jsx(Box, { "aria-hidden": true, "data-component": "mobile-bottom-drawer-handle", "data-placement": handlePlacement, "data-swipe-surface": "drawer", sx: {
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
bgcolor: handleBackground === "detailChrome"
|
|
60
|
+
? appearance.chrome
|
|
61
|
+
: "transparent",
|
|
62
|
+
display: "flex",
|
|
63
|
+
flex: "0 0 auto",
|
|
64
|
+
justifyContent: "center",
|
|
65
|
+
minHeight: 44,
|
|
66
|
+
// Product decision: header actions sit above this visual handle while
|
|
67
|
+
// MUI SwipeableDrawer owns a natural pull-down gesture across the
|
|
68
|
+
// entire sheet, including its scroll-aware cancellation behavior.
|
|
69
|
+
pointerEvents: handlePlacement === "overlay" ? "none" : "auto",
|
|
70
|
+
position: handlePlacement === "overlay" ? "absolute" : "relative",
|
|
71
|
+
top: handlePlacement === "overlay" ? 0 : "auto",
|
|
72
|
+
width: "100%",
|
|
73
|
+
zIndex: 0,
|
|
74
|
+
}, children: _jsx(Box, { sx: {
|
|
75
|
+
bgcolor: appearance.handle,
|
|
76
|
+
borderRadius: 999,
|
|
77
|
+
height: 4,
|
|
78
|
+
width: 36,
|
|
79
|
+
} }) }));
|
|
80
|
+
return (_jsxs(SwipeableDrawer, { anchor: "bottom", disableBackdropTransition: true, disableDiscovery: true, disableSwipeToOpen: true, hysteresis: 0.16, onClose: requestClose, onOpen: () => undefined, open: dismiss ? false : open, slotProps: {
|
|
81
|
+
backdrop: {
|
|
82
|
+
sx: { backgroundColor: "transparent" },
|
|
83
|
+
},
|
|
84
|
+
paper: paperSlotProps,
|
|
85
|
+
}, transitionDuration: mobileBottomDrawerDismissDuration, children: [headerLeft ? (_jsx(MobileBottomDrawerHeader, { closeLabel: `Close ${ariaLabel}`, closeTooltip: closeTooltip, dragHandle: drawerHandle, left: headerLeft, onClose: requestClose, right: headerRight })) : handlePlacement === "above-content" ? (drawerHandle) : null, _jsxs(Box, { "data-component": "mobile-bottom-drawer-scroll", sx: {
|
|
86
|
+
display: contentScrollMode === "child" ? "flex" : "block",
|
|
87
|
+
flex: 1,
|
|
88
|
+
minHeight: 0,
|
|
89
|
+
overflowY: contentScrollMode === "child" ? "hidden" : "auto",
|
|
90
|
+
overscrollBehaviorY: "contain",
|
|
91
|
+
pb: appearance.safeAreaBottom,
|
|
92
|
+
position: "relative",
|
|
93
|
+
zIndex: handlePlacement === "overlay" ? 1 : "auto",
|
|
94
|
+
}, children: [handlePlacement === "overlay" ? drawerHandle : null, children] })] }));
|
|
95
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
|
|
4
|
+
import { Box, IconButton, Tooltip } from "@mui/material";
|
|
5
|
+
export function MobileBottomDrawerHeader({ closeLabel, closeTooltip, dragHandle, left, onClose, right, }) {
|
|
6
|
+
return (_jsxs(Box, { component: "header", "data-component": "mobile-bottom-drawer-header", sx: {
|
|
7
|
+
flex: "0 0 auto",
|
|
8
|
+
minHeight: 56,
|
|
9
|
+
position: "relative",
|
|
10
|
+
}, children: [_jsx(Box, { sx: {
|
|
11
|
+
inset: 0,
|
|
12
|
+
position: "absolute",
|
|
13
|
+
zIndex: 0,
|
|
14
|
+
}, children: dragHandle }), _jsxs(Box, { sx: {
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
display: "flex",
|
|
17
|
+
gap: 1,
|
|
18
|
+
minHeight: 56,
|
|
19
|
+
px: 2,
|
|
20
|
+
// Product decision: title and actions occupy the same compact row as
|
|
21
|
+
// the drag affordance, avoiding a second band that pushes context
|
|
22
|
+
// away from the top edge of the drawer.
|
|
23
|
+
position: "relative",
|
|
24
|
+
zIndex: 1,
|
|
25
|
+
}, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: left }), _jsxs(Box, { sx: { alignItems: "center", display: "flex", gap: 0.5 }, children: [right, _jsx(Tooltip, { title: closeTooltip !== null && closeTooltip !== void 0 ? closeTooltip : "", children: _jsx(IconButton, { "aria-label": closeLabel, onClick: onClose, sx: {
|
|
26
|
+
minHeight: 48,
|
|
27
|
+
minWidth: 48,
|
|
28
|
+
"& > .MuiSvgIcon-root": { fontSize: 32 },
|
|
29
|
+
}, children: _jsx(CloseRoundedIcon, {}) }) })] })] })] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Typography, useMediaQuery } from "@mui/material";
|
|
4
|
+
import { MobileBottomDrawer } from "./MobileBottomDrawer.js";
|
|
5
|
+
import { BottomDrawer } from "./BottomDrawer.js";
|
|
6
|
+
// Product decision: consumers share responsive drawer chrome but keep
|
|
7
|
+
// navigation and dismissal policies in their owning feature.
|
|
8
|
+
export function ResponsiveDrawer({ ariaLabel, appearance, closeTooltip, children, desktopContentSx, desktopCloseLabel, desktopDataComponent, desktopDisablePortal = false, desktopOpen = true, headerActions, mobileContentScrollMode, mobileDataComponent, mobileDismiss = false, mobileOpen = true, onDesktopClose, onMobileClose, title, }) {
|
|
9
|
+
const isMobileDrawer = useMediaQuery("(max-width:899.95px)", {
|
|
10
|
+
noSsr: true,
|
|
11
|
+
});
|
|
12
|
+
if (isMobileDrawer) {
|
|
13
|
+
if (!mobileOpen) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return (_jsx(MobileBottomDrawer, { appearance: appearance, closeTooltip: closeTooltip, ariaLabel: ariaLabel, contentScrollMode: mobileContentScrollMode, dataComponent: mobileDataComponent, dismiss: mobileDismiss, headerLeft: _jsx(Typography, { component: "h1", sx: { fontWeight: 760 }, children: title }), headerRight: headerActions, onClose: onMobileClose, children: children("mobile") }));
|
|
17
|
+
}
|
|
18
|
+
return (_jsx(BottomDrawer, { appearance: appearance, closeTooltip: closeTooltip, closeLabel: desktopCloseLabel !== null && desktopCloseLabel !== void 0 ? desktopCloseLabel : `Close ${ariaLabel}`, contentSx: desktopContentSx, dataComponent: desktopDataComponent, disablePortal: desktopDisablePortal, headerActions: headerActions, onClose: onDesktopClose, open: desktopOpen, title: title, children: children("desktop") }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// TL-M249: preserve the established MUI presentation under its owning package.
|
|
3
|
+
export { MobileBottomDrawer, mobileBottomDrawerDismissDuration, } from "./MobileBottomDrawer.js";
|
|
4
|
+
export { MobileBottomDrawerHeader } from "./MobileBottomDrawerHeader.js";
|
|
5
|
+
export { BottomDrawer } from "./BottomDrawer.js";
|
|
6
|
+
export { ResponsiveDrawer } from "./ResponsiveDrawer.js";
|
|
7
|
+
export { useVisualViewportBottomInset, getVisualViewportBottomInset, } from "./useVisualViewportBottomInset.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
export function getVisualViewportBottomInset({ layoutViewportHeight, visualViewportHeight, visualViewportOffsetTop, }) {
|
|
4
|
+
return Math.max(0, Math.round(layoutViewportHeight - visualViewportHeight - visualViewportOffsetTop));
|
|
5
|
+
}
|
|
6
|
+
export function useVisualViewportBottomInset() {
|
|
7
|
+
const [bottomInset, setBottomInset] = useState(0);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const visualViewport = window.visualViewport;
|
|
10
|
+
if (!visualViewport) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const updateBottomInset = () => {
|
|
14
|
+
setBottomInset(getVisualViewportBottomInset({
|
|
15
|
+
layoutViewportHeight: window.innerHeight,
|
|
16
|
+
visualViewportHeight: visualViewport.height,
|
|
17
|
+
visualViewportOffsetTop: visualViewport.offsetTop,
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
updateBottomInset();
|
|
21
|
+
visualViewport.addEventListener("resize", updateBottomInset);
|
|
22
|
+
visualViewport.addEventListener("scroll", updateBottomInset);
|
|
23
|
+
return () => {
|
|
24
|
+
visualViewport.removeEventListener("resize", updateBottomInset);
|
|
25
|
+
visualViewport.removeEventListener("scroll", updateBottomInset);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
return bottomInset;
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import ErrorOutlineOutlinedIcon from "@mui/icons-material/ErrorOutlineOutlined";
|
|
4
|
+
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
|
|
5
|
+
import TaskAltOutlinedIcon from "@mui/icons-material/TaskAltOutlined";
|
|
6
|
+
import WarningAmberOutlinedIcon from "@mui/icons-material/WarningAmberOutlined";
|
|
7
|
+
import { Box, Stack, Typography, } from "@mui/material";
|
|
8
|
+
export function StatusNotice({ action, compact = false, dataComponent, message, role, sx, tone = "info", }) {
|
|
9
|
+
const toneConfig = getStatusNoticeTone(tone);
|
|
10
|
+
const Icon = toneConfig.Icon;
|
|
11
|
+
return (_jsxs(Stack, { "data-component": dataComponent, component: compact ? "span" : "div", direction: "row", role: role !== null && role !== void 0 ? role : (tone === "error" ? "status" : undefined), spacing: compact ? 2 : 1.25, sx: [
|
|
12
|
+
{
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
alignSelf: "flex-start",
|
|
15
|
+
borderRadius: 1,
|
|
16
|
+
boxShadow: "0 10px 28px rgba(0, 0, 0, 0.12)",
|
|
17
|
+
maxWidth: "100%",
|
|
18
|
+
minWidth: 0,
|
|
19
|
+
px: compact ? 0 : 1.25,
|
|
20
|
+
py: compact ? 0 : 0.875,
|
|
21
|
+
},
|
|
22
|
+
...(Array.isArray(sx) ? sx : sx ? [sx] : []),
|
|
23
|
+
], children: [_jsx(Box, { "data-status-notice-part": "icon", component: compact ? "span" : "div", sx: {
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
borderRadius: 999,
|
|
26
|
+
color: toneConfig.iconColor,
|
|
27
|
+
display: "flex",
|
|
28
|
+
flex: "0 0 auto",
|
|
29
|
+
height: compact ? 20 : 26,
|
|
30
|
+
justifyContent: "center",
|
|
31
|
+
width: compact ? 20 : 26,
|
|
32
|
+
}, children: _jsx(Icon, { fontSize: compact ? "inherit" : "small" }) }), typeof message === "string" ? (_jsx(Typography, { color: "text.secondary", ...(compact ? { component: "span" } : {}), "data-status-notice-part": "message", sx: {
|
|
33
|
+
fontSize: compact ? "0.75rem" : undefined,
|
|
34
|
+
lineHeight: compact ? 1.35 : 1.55,
|
|
35
|
+
minWidth: 0,
|
|
36
|
+
overflowWrap: "anywhere",
|
|
37
|
+
}, variant: "body2", children: message })) : (_jsx(Box, { "data-status-notice-part": "message", component: compact ? "span" : "div", sx: {
|
|
38
|
+
color: "text.secondary",
|
|
39
|
+
fontSize: compact ? "0.75rem" : undefined,
|
|
40
|
+
lineHeight: compact ? 1.35 : 1.55,
|
|
41
|
+
minWidth: 0,
|
|
42
|
+
overflowWrap: "anywhere",
|
|
43
|
+
}, children: message })), action ? (_jsx(Box, { "data-status-notice-part": "action", sx: { alignItems: "center", display: "flex", flex: "0 0 auto" }, children: action })) : null] }));
|
|
44
|
+
}
|
|
45
|
+
function getStatusNoticeTone(tone) {
|
|
46
|
+
if (tone === "error") {
|
|
47
|
+
return { Icon: ErrorOutlineOutlinedIcon, iconColor: "error.main" };
|
|
48
|
+
}
|
|
49
|
+
if (tone === "warning") {
|
|
50
|
+
return { Icon: WarningAmberOutlinedIcon, iconColor: "warning.main" };
|
|
51
|
+
}
|
|
52
|
+
if (tone === "success") {
|
|
53
|
+
return { Icon: TaskAltOutlinedIcon, iconColor: "success.main" };
|
|
54
|
+
}
|
|
55
|
+
return { Icon: InfoOutlinedIcon, iconColor: "text.secondary" };
|
|
56
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import LinkRoundedIcon from "@mui/icons-material/LinkRounded";
|
|
4
|
+
import OpenInNewRoundedIcon from "@mui/icons-material/OpenInNewRounded";
|
|
5
|
+
import { Box, Tooltip } from "@mui/material";
|
|
6
|
+
/**
|
|
7
|
+
* Shared presentation of the editor's destination card. Hosts own validated
|
|
8
|
+
* URLs, placement, portal/lifecycle and navigation policy; no metadata is fetched.
|
|
9
|
+
*/
|
|
10
|
+
export function LinkAddressPreview({ link, ariaLabel = "Link destination", openLabel = `Open ${link.href} in a new tab`, sx, ...events }) {
|
|
11
|
+
return (_jsxs(Box, { component: "a", href: link.href, target: "_blank", rel: "noopener noreferrer", title: openLabel, "aria-label": ariaLabel, "data-link-address-preview": "true", ...events, sx: [
|
|
12
|
+
{
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
bgcolor: "background.paper",
|
|
15
|
+
border: 1,
|
|
16
|
+
borderColor: "divider",
|
|
17
|
+
borderRadius: "10px",
|
|
18
|
+
boxShadow: 8,
|
|
19
|
+
color: "text.primary",
|
|
20
|
+
display: "flex",
|
|
21
|
+
textDecoration: "none",
|
|
22
|
+
cursor: "pointer",
|
|
23
|
+
"&:focus-visible": {
|
|
24
|
+
outline: "2px solid",
|
|
25
|
+
outlineColor: "primary.main",
|
|
26
|
+
outlineOffset: 2,
|
|
27
|
+
},
|
|
28
|
+
gap: "10px",
|
|
29
|
+
left: link.left,
|
|
30
|
+
maxWidth: "calc(100vw - 24px)",
|
|
31
|
+
minHeight: 64,
|
|
32
|
+
p: "8px 10px",
|
|
33
|
+
position: "fixed",
|
|
34
|
+
top: link.top,
|
|
35
|
+
width: 360,
|
|
36
|
+
boxSizing: "border-box",
|
|
37
|
+
zIndex: (theme) => theme.zIndex.tooltip + 100,
|
|
38
|
+
},
|
|
39
|
+
...(Array.isArray(sx) ? sx : sx ? [sx] : []),
|
|
40
|
+
], children: [_jsx(Box, { "aria-hidden": "true", "data-link-preview-part": "icon", sx: {
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
bgcolor: "action.selected",
|
|
43
|
+
borderRadius: "8px",
|
|
44
|
+
color: "primary.main",
|
|
45
|
+
display: "flex",
|
|
46
|
+
flex: "0 0 36px",
|
|
47
|
+
height: 36,
|
|
48
|
+
justifyContent: "center",
|
|
49
|
+
}, children: _jsx(LinkRoundedIcon, { sx: { fontSize: 16 } }) }), _jsxs(Box, { sx: { flex: 1, minWidth: 0 }, "data-link-preview-part": "text", children: [_jsx(Box, { component: "div", dir: "auto", sx: {
|
|
50
|
+
fontSize: "0.92rem",
|
|
51
|
+
fontWeight: 600,
|
|
52
|
+
lineHeight: 1.35,
|
|
53
|
+
overflow: "hidden",
|
|
54
|
+
textOverflow: "ellipsis",
|
|
55
|
+
whiteSpace: "nowrap",
|
|
56
|
+
}, children: link.label }), _jsx(Box, { component: "div", dir: "ltr", title: link.href, sx: {
|
|
57
|
+
color: "text.secondary",
|
|
58
|
+
fontSize: "0.8rem",
|
|
59
|
+
lineHeight: 1.4,
|
|
60
|
+
overflow: "hidden",
|
|
61
|
+
textAlign: "start",
|
|
62
|
+
textOverflow: "ellipsis",
|
|
63
|
+
whiteSpace: "nowrap",
|
|
64
|
+
}, children: link.href })] }), _jsx(Tooltip, { title: openLabel, children: _jsx(Box, { component: "span", "aria-hidden": "true", "data-link-preview-part": "open", sx: {
|
|
65
|
+
display: "inline-flex",
|
|
66
|
+
alignItems: "center",
|
|
67
|
+
justifyContent: "center",
|
|
68
|
+
color: "text.primary",
|
|
69
|
+
flex: "0 0 44px",
|
|
70
|
+
height: 44,
|
|
71
|
+
width: 44,
|
|
72
|
+
borderRadius: "6px",
|
|
73
|
+
}, children: _jsx(OpenInNewRoundedIcon, { sx: { fontSize: 18 } }) }) })] }));
|
|
74
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { LinkAddressPreview, } from "./LinkAddressPreview.js";
|
|
4
|
+
import { useEffect, useId, useRef, useState, } from "react";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
/** Product decision: hosts own link interaction; the shared UI card only displays
|
|
7
|
+
* a validated destination. The source previews/edits; the card navigates. */
|
|
8
|
+
export function useLinkAddressPreview(enabled = true, onEdit) {
|
|
9
|
+
const id = useId();
|
|
10
|
+
const activated = useRef(null);
|
|
11
|
+
const [preview, setPreview] = useState(null);
|
|
12
|
+
const closeTimer = useRef(null);
|
|
13
|
+
const focusFrame = useRef(null);
|
|
14
|
+
function cancelClose() {
|
|
15
|
+
if (closeTimer.current !== null)
|
|
16
|
+
clearTimeout(closeTimer.current);
|
|
17
|
+
closeTimer.current = null;
|
|
18
|
+
}
|
|
19
|
+
function close() {
|
|
20
|
+
cancelClose();
|
|
21
|
+
setPreview(null);
|
|
22
|
+
activated.current = null;
|
|
23
|
+
}
|
|
24
|
+
function contains(target) {
|
|
25
|
+
var _a;
|
|
26
|
+
return (target instanceof Node &&
|
|
27
|
+
((preview === null || preview === void 0 ? void 0 : preview.anchor.contains(target)) ||
|
|
28
|
+
((_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.contains(target))));
|
|
29
|
+
}
|
|
30
|
+
function show(anchor, href, label) {
|
|
31
|
+
if (!enabled)
|
|
32
|
+
return;
|
|
33
|
+
cancelClose();
|
|
34
|
+
const rect = anchor.getBoundingClientRect();
|
|
35
|
+
const width = Math.min(360, window.innerWidth - 24);
|
|
36
|
+
setPreview({
|
|
37
|
+
anchor,
|
|
38
|
+
href,
|
|
39
|
+
label,
|
|
40
|
+
left: Math.max(12, Math.min(rect.left, window.innerWidth - width - 12)),
|
|
41
|
+
top: Math.max(12, Math.min(rect.bottom + 8, window.innerHeight - 88)),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function scheduleClose() {
|
|
45
|
+
cancelClose();
|
|
46
|
+
// Allow pointer travel between the inline link and its portal card.
|
|
47
|
+
closeTimer.current = setTimeout(() => {
|
|
48
|
+
if (!contains(document.activeElement))
|
|
49
|
+
setPreview(null);
|
|
50
|
+
}, 180);
|
|
51
|
+
}
|
|
52
|
+
function blur(event) {
|
|
53
|
+
if (!contains(event.relatedTarget))
|
|
54
|
+
close();
|
|
55
|
+
}
|
|
56
|
+
function escape(event) {
|
|
57
|
+
if (event.key !== "Escape")
|
|
58
|
+
return;
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
event.stopPropagation();
|
|
61
|
+
preview === null || preview === void 0 ? void 0 : preview.anchor.focus({ preventScroll: true });
|
|
62
|
+
close();
|
|
63
|
+
}
|
|
64
|
+
useEffect(() => () => {
|
|
65
|
+
if (closeTimer.current !== null)
|
|
66
|
+
clearTimeout(closeTimer.current);
|
|
67
|
+
if (focusFrame.current !== null)
|
|
68
|
+
cancelAnimationFrame(focusFrame.current);
|
|
69
|
+
}, []);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!preview)
|
|
72
|
+
return;
|
|
73
|
+
const dismiss = () => setPreview(null);
|
|
74
|
+
const outside = (event) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const target = event.target;
|
|
77
|
+
if (target instanceof Node &&
|
|
78
|
+
!preview.anchor.contains(target) &&
|
|
79
|
+
!((_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.contains(target)))
|
|
80
|
+
dismiss();
|
|
81
|
+
};
|
|
82
|
+
window.addEventListener("resize", dismiss);
|
|
83
|
+
window.addEventListener("scroll", dismiss, true);
|
|
84
|
+
document.addEventListener("pointerdown", outside);
|
|
85
|
+
return () => {
|
|
86
|
+
window.removeEventListener("resize", dismiss);
|
|
87
|
+
window.removeEventListener("scroll", dismiss, true);
|
|
88
|
+
document.removeEventListener("pointerdown", outside);
|
|
89
|
+
};
|
|
90
|
+
}, [preview, id]);
|
|
91
|
+
return {
|
|
92
|
+
linkProps(href, label) {
|
|
93
|
+
return enabled
|
|
94
|
+
? {
|
|
95
|
+
"aria-controls": (preview === null || preview === void 0 ? void 0 : preview.href) === href ? id : undefined,
|
|
96
|
+
"aria-keyshortcuts": "ArrowDown",
|
|
97
|
+
onMouseEnter: (event) => show(event.currentTarget, href, label),
|
|
98
|
+
onMouseLeave: scheduleClose,
|
|
99
|
+
onFocus: (event) => show(event.currentTarget, href, label),
|
|
100
|
+
onBlur: blur,
|
|
101
|
+
onKeyDown: (event) => {
|
|
102
|
+
// Links inside editable titles must not trigger the parent's Enter handler.
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
if (event.key === "ArrowDown") {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
show(event.currentTarget, href, label);
|
|
107
|
+
if (focusFrame.current !== null)
|
|
108
|
+
cancelAnimationFrame(focusFrame.current);
|
|
109
|
+
focusFrame.current = requestAnimationFrame(() => {
|
|
110
|
+
var _a;
|
|
111
|
+
(_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else
|
|
115
|
+
escape(event);
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
: {};
|
|
119
|
+
},
|
|
120
|
+
onClick(event, href, label) {
|
|
121
|
+
event.stopPropagation();
|
|
122
|
+
if (!enabled ||
|
|
123
|
+
event.metaKey ||
|
|
124
|
+
event.ctrlKey ||
|
|
125
|
+
event.shiftKey ||
|
|
126
|
+
event.altKey ||
|
|
127
|
+
event.button !== 0)
|
|
128
|
+
return;
|
|
129
|
+
// The source is an editing affordance after preview; the card owns navigation.
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
if ((preview === null || preview === void 0 ? void 0 : preview.anchor) === event.currentTarget &&
|
|
132
|
+
activated.current === event.currentTarget &&
|
|
133
|
+
onEdit) {
|
|
134
|
+
close();
|
|
135
|
+
onEdit();
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
activated.current = event.currentTarget;
|
|
139
|
+
show(event.currentTarget, href, label);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
card: preview
|
|
143
|
+
? createPortal(_jsx(LinkAddressPreview, { id: id, link: preview, onMouseEnter: cancelClose, onMouseLeave: scheduleClose, onFocusCapture: cancelClose, onBlurCapture: blur, onKeyDown: (event) => {
|
|
144
|
+
event.stopPropagation();
|
|
145
|
+
escape(event);
|
|
146
|
+
}, onClick: (event) => event.stopPropagation() }), document.body)
|
|
147
|
+
: null,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog, DialogTitle, DialogContent, IconButton, Stack, Tooltip, } from "@mui/material";
|
|
4
|
+
import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
export function PendingChangesDialogShell({ children, open, onClose, title, titleIcon, contentHeader, contentTouchHandlers, contentSx, onEntered, closeLabel = "Close pending changes", }) {
|
|
7
|
+
const headerId = useId();
|
|
8
|
+
const titleId = `${headerId}-title`;
|
|
9
|
+
return (_jsxs(Dialog, { open: open, onClose: onClose, fullWidth: true, maxWidth: "sm", "aria-labelledby": titleId, slotProps: { transition: { onEntered } }, children: [_jsx(DialogTitle, { id: headerId, component: "div", children: _jsxs(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, children: [titleIcon, _jsx("span", { id: titleId, style: { flex: 1 }, children: title }), _jsx(Tooltip, { title: closeLabel, children: _jsx(IconButton, { "aria-label": closeLabel, onClick: onClose, sx: { width: 44, height: 44 }, children: _jsx(CloseRoundedIcon, {}) }) })] }) }), contentHeader ? (_jsx("div", { style: { padding: "0 24px 16px" }, children: contentHeader })) : null, _jsx(DialogContent, { ...contentTouchHandlers, sx: contentSx, children: children })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { IconButton, List, ListItem, Pagination, Stack, Typography, Tooltip, } from "@mui/material";
|
|
4
|
+
import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
|
|
5
|
+
import CloudUploadOutlinedIcon from "@mui/icons-material/CloudUploadOutlined";
|
|
6
|
+
import { useRef, useState } from "react";
|
|
7
|
+
import { PendingChangesDialogShell } from "./PendingChangesDialogShell.js";
|
|
8
|
+
const pageSize = 10;
|
|
9
|
+
export function PendingChangesDialogView({ groups, open, onClose, title, summary, emptyMessage = "All changes are saved.", accountKey, onOpenItem, focusGroupKey, navigationError, contentHeader, contentTouchHandlers, shell: Shell = PendingChangesDialogShell, }) {
|
|
10
|
+
const returnItemButton = useRef(null);
|
|
11
|
+
const [page, setPage] = useState(1);
|
|
12
|
+
const [actionPages, setActionPages] = useState({});
|
|
13
|
+
const pages = Math.max(1, Math.ceil(groups.length / pageSize));
|
|
14
|
+
const visiblePage = Math.min(page, pages);
|
|
15
|
+
const [previousGroups, setPreviousGroups] = useState(groups);
|
|
16
|
+
const [previousAccount, setPreviousAccount] = useState(accountKey);
|
|
17
|
+
// Adjust pagination only when the source view changes. Guarded render state
|
|
18
|
+
// keeps the first painted frame bounded and avoids effect-driven page jumps.
|
|
19
|
+
if (previousGroups !== groups || previousAccount !== accountKey) {
|
|
20
|
+
setPreviousGroups(groups);
|
|
21
|
+
setPreviousAccount(accountKey);
|
|
22
|
+
if (previousAccount !== accountKey) {
|
|
23
|
+
setPage(1);
|
|
24
|
+
setActionPages({});
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
setPage((current) => Math.min(current, pages));
|
|
28
|
+
setActionPages((current) => {
|
|
29
|
+
const next = {};
|
|
30
|
+
for (const group of groups)
|
|
31
|
+
if (current[group.key] !== undefined)
|
|
32
|
+
next[group.key] = Math.min(current[group.key], Math.max(1, Math.ceil(group.rows.length / pageSize)));
|
|
33
|
+
return Object.keys(next).length === Object.keys(current).length &&
|
|
34
|
+
Object.keys(next).every((key) => next[key] === current[key])
|
|
35
|
+
? current
|
|
36
|
+
: next;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return (_jsxs(Shell, { autoFocusInput: false, closeLabel: "Close pending changes", closeTooltip: "Close pending changes", contentHeader: contentHeader !== null && contentHeader !== void 0 ? contentHeader : (groups.length ? (
|
|
41
|
+
// Product decision: the sync summary remains distinct and visible
|
|
42
|
+
// while the user scrolls through pending groups.
|
|
43
|
+
_jsx(Stack, { component: "section", "aria-label": "Pending changes summary", spacing: 0.5, sx: { p: 2, borderRadius: 1, bgcolor: "action.selected" }, children: _jsx(Typography, { variant: "body2", sx: { fontWeight: 600 }, children: summary }) })) : undefined), contentTouchHandlers: contentTouchHandlers, contentSx: { pt: 0.5, pb: 3, overscrollBehaviorY: "contain" }, exclusive: false, onClose: onClose, onEntered: () => {
|
|
44
|
+
// Entry focus runs after MUI settles its focus trap, including a reopen
|
|
45
|
+
// of the same inspector. A removed group retains the shell's fallback.
|
|
46
|
+
const target = returnItemButton.current;
|
|
47
|
+
if ((target === null || target === void 0 ? void 0 : target.isConnected) && !target.disabled)
|
|
48
|
+
target.focus();
|
|
49
|
+
}, open: open, title: title, titleIcon: _jsx(CloudUploadOutlinedIcon, {}), children: [navigationError ? (_jsx(Typography, { role: "alert", color: "error", variant: "body2", sx: { mb: 1 }, children: navigationError })) : null, groups.length ? (_jsxs(_Fragment, { children: [_jsx(List, { "aria-label": "Pending changes", disablePadding: true, sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: groups
|
|
50
|
+
.slice((visiblePage - 1) * pageSize, visiblePage * pageSize)
|
|
51
|
+
.map((group) => {
|
|
52
|
+
var _a;
|
|
53
|
+
const title = group.title;
|
|
54
|
+
const unavailableReason = group.unavailableReason;
|
|
55
|
+
const actionPageCount = Math.max(1, Math.ceil(group.rows.length / pageSize));
|
|
56
|
+
const actionPage = Math.min((_a = actionPages[group.key]) !== null && _a !== void 0 ? _a : 1, actionPageCount);
|
|
57
|
+
return (_jsx(ListItem, { disableGutters: true, sx: {
|
|
58
|
+
p: 2,
|
|
59
|
+
alignItems: "flex-start",
|
|
60
|
+
border: 1,
|
|
61
|
+
borderColor: "divider",
|
|
62
|
+
borderRadius: 1,
|
|
63
|
+
}, children: _jsxs(Stack, { spacing: 1, sx: { minWidth: 0, width: "100%" }, children: [_jsxs(Stack, { direction: "row", spacing: 1, sx: {
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
justifyContent: "space-between",
|
|
66
|
+
}, children: [_jsx(Tooltip, { title: title, children: _jsx(Typography, { component: "h3", "aria-label": title, tabIndex: 0, sx: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
minWidth: 0,
|
|
69
|
+
fontWeight: 600,
|
|
70
|
+
// The item name owns one row; CSS handles the
|
|
71
|
+
// available width, while the tooltip retains it all.
|
|
72
|
+
overflow: "hidden",
|
|
73
|
+
textOverflow: "ellipsis",
|
|
74
|
+
whiteSpace: "nowrap",
|
|
75
|
+
}, variant: "body2", children: title }) }), _jsx(Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center", flexShrink: 0 }, children: group.openLabel && onOpenItem ? (_jsx(Tooltip, { title: unavailableReason || group.openLabel, children: _jsx("span", { tabIndex: unavailableReason ? 0 : undefined, "aria-label": unavailableReason
|
|
76
|
+
? `${group.openLabel} unavailable. ${unavailableReason}`
|
|
77
|
+
: undefined, children: _jsx(IconButton, { "aria-label": `${group.openLabel}: ${title}`, disabled: Boolean(unavailableReason), ref: focusGroupKey === group.key
|
|
78
|
+
? returnItemButton
|
|
79
|
+
: undefined, onClick: () => onOpenItem(group.key), size: "small", sx: { width: 44, height: 44 }, children: _jsx(ArrowForwardRoundedIcon, { fontSize: "small" }) }) }) })) : null })] }), _jsx(List, { "aria-label": `Changes for ${group.title}`, disablePadding: true, children: group.rows
|
|
80
|
+
.slice((actionPage - 1) * pageSize, actionPage * pageSize)
|
|
81
|
+
.map((item, index) => {
|
|
82
|
+
const presentation = item;
|
|
83
|
+
const exception = item.exception;
|
|
84
|
+
if (!presentation.action &&
|
|
85
|
+
!exception &&
|
|
86
|
+
!presentation.targetLabel &&
|
|
87
|
+
presentation.attemptedText === undefined)
|
|
88
|
+
return null;
|
|
89
|
+
return (_jsx(ListItem, { disableGutters: true, sx: {
|
|
90
|
+
display: "block",
|
|
91
|
+
py: 1,
|
|
92
|
+
borderTop: index > 0 ? 1 : 0,
|
|
93
|
+
borderColor: "divider",
|
|
94
|
+
}, children: _jsxs(Stack, { spacing: 0.75, children: [_jsxs(Stack, { direction: "row", spacing: 1, sx: {
|
|
95
|
+
alignItems: "baseline",
|
|
96
|
+
justifyContent: "space-between",
|
|
97
|
+
flexWrap: "wrap",
|
|
98
|
+
}, children: [presentation.action ? (_jsx(Typography, { component: "h4", color: "text.secondary", variant: "caption", children: presentation.action })) : null, exception ? (_jsx(Typography, { color: item.needsAttention
|
|
99
|
+
? "error"
|
|
100
|
+
: "text.secondary", variant: "caption", children: exception })) : null] }), presentation.targetLabel ? (_jsx(Typography, { color: "text.secondary", variant: "caption", sx: {
|
|
101
|
+
overflowWrap: "anywhere",
|
|
102
|
+
whiteSpace: "pre-wrap",
|
|
103
|
+
}, children: presentation.targetLabel })) : null, presentation.attemptedText !== undefined ? (_jsx(Typography, { variant: "body1", sx: {
|
|
104
|
+
whiteSpace: "pre-wrap",
|
|
105
|
+
overflowWrap: "anywhere",
|
|
106
|
+
}, children: presentation.attemptedText })) : null] }) }, item.id));
|
|
107
|
+
}) }), actionPageCount > 1 ? (_jsx(Pagination, { "aria-label": `Change pages for ${group.title}`, count: actionPageCount, page: actionPage, onChange: (_event, nextPage) => setActionPages((previous) => ({
|
|
108
|
+
...previous,
|
|
109
|
+
[group.key]: nextPage,
|
|
110
|
+
})), sx: {
|
|
111
|
+
"& .MuiPaginationItem-root": {
|
|
112
|
+
minWidth: 44,
|
|
113
|
+
minHeight: 44,
|
|
114
|
+
},
|
|
115
|
+
} })) : null] }) }, group.key));
|
|
116
|
+
}) }), pages > 1 ? (_jsx(Pagination, { "aria-label": "Pending changes pages", count: pages, onChange: (_event, nextPage) => setPage(nextPage), page: visiblePage, sx: {
|
|
117
|
+
mt: 2,
|
|
118
|
+
"& .MuiPaginationItem-root": { minWidth: 44, minHeight: 44 },
|
|
119
|
+
} })) : null] })) : (_jsx(Typography, { role: "status", sx: { py: 2 }, children: emptyMessage }))] }));
|
|
120
|
+
}
|