@bayonai/mui-design 1.0.0 → 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/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 +51 -11
- package/dist/cjs/sections/ExpandableSectionToggle.js +32 -0
- package/dist/cjs/sections/index.js +7 -0
- package/dist/cjs/swipe/SwipeActionRow.js +123 -0
- package/dist/cjs/swipe/index.js +8 -0
- 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/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 +51 -11
- package/dist/esm/sections/ExpandableSectionToggle.js +26 -0
- package/dist/esm/sections/index.js +3 -0
- package/dist/esm/swipe/SwipeActionRow.js +116 -0
- package/dist/esm/swipe/index.js +3 -0
- 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/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/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 +110 -48
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.StatusNotice = StatusNotice;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const ErrorOutlineOutlined_1 = __importDefault(require("@mui/icons-material/ErrorOutlineOutlined"));
|
|
10
|
+
const InfoOutlined_1 = __importDefault(require("@mui/icons-material/InfoOutlined"));
|
|
11
|
+
const TaskAltOutlined_1 = __importDefault(require("@mui/icons-material/TaskAltOutlined"));
|
|
12
|
+
const WarningAmberOutlined_1 = __importDefault(require("@mui/icons-material/WarningAmberOutlined"));
|
|
13
|
+
const material_1 = require("@mui/material");
|
|
14
|
+
function StatusNotice({ action, compact = false, dataComponent, message, role, sx, tone = "info", }) {
|
|
15
|
+
const toneConfig = getStatusNoticeTone(tone);
|
|
16
|
+
const Icon = toneConfig.Icon;
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.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: [
|
|
18
|
+
{
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
alignSelf: "flex-start",
|
|
21
|
+
borderRadius: 1,
|
|
22
|
+
boxShadow: "0 10px 28px rgba(0, 0, 0, 0.12)",
|
|
23
|
+
maxWidth: "100%",
|
|
24
|
+
minWidth: 0,
|
|
25
|
+
px: compact ? 0 : 1.25,
|
|
26
|
+
py: compact ? 0 : 0.875,
|
|
27
|
+
},
|
|
28
|
+
...(Array.isArray(sx) ? sx : sx ? [sx] : []),
|
|
29
|
+
], children: [(0, jsx_runtime_1.jsx)(material_1.Box, { "data-status-notice-part": "icon", component: compact ? "span" : "div", sx: {
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
borderRadius: 999,
|
|
32
|
+
color: toneConfig.iconColor,
|
|
33
|
+
display: "flex",
|
|
34
|
+
flex: "0 0 auto",
|
|
35
|
+
height: compact ? 20 : 26,
|
|
36
|
+
justifyContent: "center",
|
|
37
|
+
width: compact ? 20 : 26,
|
|
38
|
+
}, children: (0, jsx_runtime_1.jsx)(Icon, { fontSize: compact ? "inherit" : "small" }) }), typeof message === "string" ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.secondary", ...(compact ? { component: "span" } : {}), "data-status-notice-part": "message", sx: {
|
|
39
|
+
fontSize: compact ? "0.75rem" : undefined,
|
|
40
|
+
lineHeight: compact ? 1.35 : 1.55,
|
|
41
|
+
minWidth: 0,
|
|
42
|
+
overflowWrap: "anywhere",
|
|
43
|
+
}, variant: "body2", children: message })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { "data-status-notice-part": "message", component: compact ? "span" : "div", sx: {
|
|
44
|
+
color: "text.secondary",
|
|
45
|
+
fontSize: compact ? "0.75rem" : undefined,
|
|
46
|
+
lineHeight: compact ? 1.35 : 1.55,
|
|
47
|
+
minWidth: 0,
|
|
48
|
+
overflowWrap: "anywhere",
|
|
49
|
+
}, children: message })), action ? ((0, jsx_runtime_1.jsx)(material_1.Box, { "data-status-notice-part": "action", sx: { alignItems: "center", display: "flex", flex: "0 0 auto" }, children: action })) : null] }));
|
|
50
|
+
}
|
|
51
|
+
function getStatusNoticeTone(tone) {
|
|
52
|
+
if (tone === "error") {
|
|
53
|
+
return { Icon: ErrorOutlineOutlined_1.default, iconColor: "error.main" };
|
|
54
|
+
}
|
|
55
|
+
if (tone === "warning") {
|
|
56
|
+
return { Icon: WarningAmberOutlined_1.default, iconColor: "warning.main" };
|
|
57
|
+
}
|
|
58
|
+
if (tone === "success") {
|
|
59
|
+
return { Icon: TaskAltOutlined_1.default, iconColor: "success.main" };
|
|
60
|
+
}
|
|
61
|
+
return { Icon: InfoOutlined_1.default, iconColor: "text.secondary" };
|
|
62
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.StatusNotice = void 0;
|
|
5
|
+
// TL-M249: preserve the established MUI presentation under its owning package.
|
|
6
|
+
var StatusNotice_js_1 = require("./StatusNotice.js");
|
|
7
|
+
Object.defineProperty(exports, "StatusNotice", { enumerable: true, get: function () { return StatusNotice_js_1.StatusNotice; } });
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LinkAddressPreview = LinkAddressPreview;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const LinkRounded_1 = __importDefault(require("@mui/icons-material/LinkRounded"));
|
|
10
|
+
const OpenInNewRounded_1 = __importDefault(require("@mui/icons-material/OpenInNewRounded"));
|
|
11
|
+
const material_1 = require("@mui/material");
|
|
12
|
+
/**
|
|
13
|
+
* Shared presentation of the editor's destination card. Hosts own validated
|
|
14
|
+
* URLs, placement, portal/lifecycle and navigation policy; no metadata is fetched.
|
|
15
|
+
*/
|
|
16
|
+
function LinkAddressPreview({ link, ariaLabel = "Link destination", openLabel = `Open ${link.href} in a new tab`, sx, ...events }) {
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { component: "a", href: link.href, target: "_blank", rel: "noopener noreferrer", title: openLabel, "aria-label": ariaLabel, "data-link-address-preview": "true", ...events, sx: [
|
|
18
|
+
{
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
bgcolor: "background.paper",
|
|
21
|
+
border: 1,
|
|
22
|
+
borderColor: "divider",
|
|
23
|
+
borderRadius: "10px",
|
|
24
|
+
boxShadow: 8,
|
|
25
|
+
color: "text.primary",
|
|
26
|
+
display: "flex",
|
|
27
|
+
textDecoration: "none",
|
|
28
|
+
cursor: "pointer",
|
|
29
|
+
"&:focus-visible": {
|
|
30
|
+
outline: "2px solid",
|
|
31
|
+
outlineColor: "primary.main",
|
|
32
|
+
outlineOffset: 2,
|
|
33
|
+
},
|
|
34
|
+
gap: "10px",
|
|
35
|
+
left: link.left,
|
|
36
|
+
maxWidth: "calc(100vw - 24px)",
|
|
37
|
+
minHeight: 64,
|
|
38
|
+
p: "8px 10px",
|
|
39
|
+
position: "fixed",
|
|
40
|
+
top: link.top,
|
|
41
|
+
width: 360,
|
|
42
|
+
boxSizing: "border-box",
|
|
43
|
+
zIndex: (theme) => theme.zIndex.tooltip + 100,
|
|
44
|
+
},
|
|
45
|
+
...(Array.isArray(sx) ? sx : sx ? [sx] : []),
|
|
46
|
+
], children: [(0, jsx_runtime_1.jsx)(material_1.Box, { "aria-hidden": "true", "data-link-preview-part": "icon", sx: {
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
bgcolor: "action.selected",
|
|
49
|
+
borderRadius: "8px",
|
|
50
|
+
color: "primary.main",
|
|
51
|
+
display: "flex",
|
|
52
|
+
flex: "0 0 36px",
|
|
53
|
+
height: 36,
|
|
54
|
+
justifyContent: "center",
|
|
55
|
+
}, children: (0, jsx_runtime_1.jsx)(LinkRounded_1.default, { sx: { fontSize: 16 } }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { flex: 1, minWidth: 0 }, "data-link-preview-part": "text", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: "div", dir: "auto", sx: {
|
|
56
|
+
fontSize: "0.92rem",
|
|
57
|
+
fontWeight: 600,
|
|
58
|
+
lineHeight: 1.35,
|
|
59
|
+
overflow: "hidden",
|
|
60
|
+
textOverflow: "ellipsis",
|
|
61
|
+
whiteSpace: "nowrap",
|
|
62
|
+
}, children: link.label }), (0, jsx_runtime_1.jsx)(material_1.Box, { component: "div", dir: "ltr", title: link.href, sx: {
|
|
63
|
+
color: "text.secondary",
|
|
64
|
+
fontSize: "0.8rem",
|
|
65
|
+
lineHeight: 1.4,
|
|
66
|
+
overflow: "hidden",
|
|
67
|
+
textAlign: "start",
|
|
68
|
+
textOverflow: "ellipsis",
|
|
69
|
+
whiteSpace: "nowrap",
|
|
70
|
+
}, children: link.href })] }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: openLabel, children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", "aria-hidden": "true", "data-link-preview-part": "open", sx: {
|
|
71
|
+
display: "inline-flex",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
color: "text.primary",
|
|
75
|
+
flex: "0 0 44px",
|
|
76
|
+
height: 44,
|
|
77
|
+
width: 44,
|
|
78
|
+
borderRadius: "6px",
|
|
79
|
+
}, children: (0, jsx_runtime_1.jsx)(OpenInNewRounded_1.default, { sx: { fontSize: 18 } }) }) })] }));
|
|
80
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useLinkAddressPreview = exports.LinkAddressPreview = void 0;
|
|
5
|
+
// TL-M249: preserve the established MUI presentation under its owning package.
|
|
6
|
+
var LinkAddressPreview_js_1 = require("./LinkAddressPreview.js");
|
|
7
|
+
Object.defineProperty(exports, "LinkAddressPreview", { enumerable: true, get: function () { return LinkAddressPreview_js_1.LinkAddressPreview; } });
|
|
8
|
+
var useLinkAddressPreview_js_1 = require("./useLinkAddressPreview.js");
|
|
9
|
+
Object.defineProperty(exports, "useLinkAddressPreview", { enumerable: true, get: function () { return useLinkAddressPreview_js_1.useLinkAddressPreview; } });
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useLinkAddressPreview = useLinkAddressPreview;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const LinkAddressPreview_js_1 = require("./LinkAddressPreview.js");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_dom_1 = require("react-dom");
|
|
9
|
+
/** Product decision: hosts own link interaction; the shared UI card only displays
|
|
10
|
+
* a validated destination. The source previews/edits; the card navigates. */
|
|
11
|
+
function useLinkAddressPreview(enabled = true, onEdit) {
|
|
12
|
+
const id = (0, react_1.useId)();
|
|
13
|
+
const activated = (0, react_1.useRef)(null);
|
|
14
|
+
const [preview, setPreview] = (0, react_1.useState)(null);
|
|
15
|
+
const closeTimer = (0, react_1.useRef)(null);
|
|
16
|
+
const focusFrame = (0, react_1.useRef)(null);
|
|
17
|
+
function cancelClose() {
|
|
18
|
+
if (closeTimer.current !== null)
|
|
19
|
+
clearTimeout(closeTimer.current);
|
|
20
|
+
closeTimer.current = null;
|
|
21
|
+
}
|
|
22
|
+
function close() {
|
|
23
|
+
cancelClose();
|
|
24
|
+
setPreview(null);
|
|
25
|
+
activated.current = null;
|
|
26
|
+
}
|
|
27
|
+
function contains(target) {
|
|
28
|
+
var _a;
|
|
29
|
+
return (target instanceof Node &&
|
|
30
|
+
((preview === null || preview === void 0 ? void 0 : preview.anchor.contains(target)) ||
|
|
31
|
+
((_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.contains(target))));
|
|
32
|
+
}
|
|
33
|
+
function show(anchor, href, label) {
|
|
34
|
+
if (!enabled)
|
|
35
|
+
return;
|
|
36
|
+
cancelClose();
|
|
37
|
+
const rect = anchor.getBoundingClientRect();
|
|
38
|
+
const width = Math.min(360, window.innerWidth - 24);
|
|
39
|
+
setPreview({
|
|
40
|
+
anchor,
|
|
41
|
+
href,
|
|
42
|
+
label,
|
|
43
|
+
left: Math.max(12, Math.min(rect.left, window.innerWidth - width - 12)),
|
|
44
|
+
top: Math.max(12, Math.min(rect.bottom + 8, window.innerHeight - 88)),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function scheduleClose() {
|
|
48
|
+
cancelClose();
|
|
49
|
+
// Allow pointer travel between the inline link and its portal card.
|
|
50
|
+
closeTimer.current = setTimeout(() => {
|
|
51
|
+
if (!contains(document.activeElement))
|
|
52
|
+
setPreview(null);
|
|
53
|
+
}, 180);
|
|
54
|
+
}
|
|
55
|
+
function blur(event) {
|
|
56
|
+
if (!contains(event.relatedTarget))
|
|
57
|
+
close();
|
|
58
|
+
}
|
|
59
|
+
function escape(event) {
|
|
60
|
+
if (event.key !== "Escape")
|
|
61
|
+
return;
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
preview === null || preview === void 0 ? void 0 : preview.anchor.focus({ preventScroll: true });
|
|
65
|
+
close();
|
|
66
|
+
}
|
|
67
|
+
(0, react_1.useEffect)(() => () => {
|
|
68
|
+
if (closeTimer.current !== null)
|
|
69
|
+
clearTimeout(closeTimer.current);
|
|
70
|
+
if (focusFrame.current !== null)
|
|
71
|
+
cancelAnimationFrame(focusFrame.current);
|
|
72
|
+
}, []);
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
if (!preview)
|
|
75
|
+
return;
|
|
76
|
+
const dismiss = () => setPreview(null);
|
|
77
|
+
const outside = (event) => {
|
|
78
|
+
var _a;
|
|
79
|
+
const target = event.target;
|
|
80
|
+
if (target instanceof Node &&
|
|
81
|
+
!preview.anchor.contains(target) &&
|
|
82
|
+
!((_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.contains(target)))
|
|
83
|
+
dismiss();
|
|
84
|
+
};
|
|
85
|
+
window.addEventListener("resize", dismiss);
|
|
86
|
+
window.addEventListener("scroll", dismiss, true);
|
|
87
|
+
document.addEventListener("pointerdown", outside);
|
|
88
|
+
return () => {
|
|
89
|
+
window.removeEventListener("resize", dismiss);
|
|
90
|
+
window.removeEventListener("scroll", dismiss, true);
|
|
91
|
+
document.removeEventListener("pointerdown", outside);
|
|
92
|
+
};
|
|
93
|
+
}, [preview, id]);
|
|
94
|
+
return {
|
|
95
|
+
linkProps(href, label) {
|
|
96
|
+
return enabled
|
|
97
|
+
? {
|
|
98
|
+
"aria-controls": (preview === null || preview === void 0 ? void 0 : preview.href) === href ? id : undefined,
|
|
99
|
+
"aria-keyshortcuts": "ArrowDown",
|
|
100
|
+
onMouseEnter: (event) => show(event.currentTarget, href, label),
|
|
101
|
+
onMouseLeave: scheduleClose,
|
|
102
|
+
onFocus: (event) => show(event.currentTarget, href, label),
|
|
103
|
+
onBlur: blur,
|
|
104
|
+
onKeyDown: (event) => {
|
|
105
|
+
// Links inside editable titles must not trigger the parent's Enter handler.
|
|
106
|
+
event.stopPropagation();
|
|
107
|
+
if (event.key === "ArrowDown") {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
show(event.currentTarget, href, label);
|
|
110
|
+
if (focusFrame.current !== null)
|
|
111
|
+
cancelAnimationFrame(focusFrame.current);
|
|
112
|
+
focusFrame.current = requestAnimationFrame(() => {
|
|
113
|
+
var _a;
|
|
114
|
+
(_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else
|
|
118
|
+
escape(event);
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
: {};
|
|
122
|
+
},
|
|
123
|
+
onClick(event, href, label) {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
if (!enabled ||
|
|
126
|
+
event.metaKey ||
|
|
127
|
+
event.ctrlKey ||
|
|
128
|
+
event.shiftKey ||
|
|
129
|
+
event.altKey ||
|
|
130
|
+
event.button !== 0)
|
|
131
|
+
return;
|
|
132
|
+
// The source is an editing affordance after preview; the card owns navigation.
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
if ((preview === null || preview === void 0 ? void 0 : preview.anchor) === event.currentTarget &&
|
|
135
|
+
activated.current === event.currentTarget &&
|
|
136
|
+
onEdit) {
|
|
137
|
+
close();
|
|
138
|
+
onEdit();
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
activated.current = event.currentTarget;
|
|
142
|
+
show(event.currentTarget, href, label);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
card: preview
|
|
146
|
+
? (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(LinkAddressPreview_js_1.LinkAddressPreview, { id: id, link: preview, onMouseEnter: cancelClose, onMouseLeave: scheduleClose, onFocusCapture: cancelClose, onBlurCapture: blur, onKeyDown: (event) => {
|
|
147
|
+
event.stopPropagation();
|
|
148
|
+
escape(event);
|
|
149
|
+
}, onClick: (event) => event.stopPropagation() }), document.body)
|
|
150
|
+
: null,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PendingChangesDialogShell = PendingChangesDialogShell;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const material_1 = require("@mui/material");
|
|
10
|
+
const CloseRounded_1 = __importDefault(require("@mui/icons-material/CloseRounded"));
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
function PendingChangesDialogShell({ children, open, onClose, title, titleIcon, contentHeader, contentTouchHandlers, contentSx, onEntered, closeLabel = "Close pending changes", }) {
|
|
13
|
+
const headerId = (0, react_1.useId)();
|
|
14
|
+
const titleId = `${headerId}-title`;
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: open, onClose: onClose, fullWidth: true, maxWidth: "sm", "aria-labelledby": titleId, slotProps: { transition: { onEntered } }, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { id: headerId, component: "div", children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, children: [titleIcon, (0, jsx_runtime_1.jsx)("span", { id: titleId, style: { flex: 1 }, children: title }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: closeLabel, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": closeLabel, onClick: onClose, sx: { width: 44, height: 44 }, children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, {}) }) })] }) }), contentHeader ? ((0, jsx_runtime_1.jsx)("div", { style: { padding: "0 24px 16px" }, children: contentHeader })) : null, (0, jsx_runtime_1.jsx)(material_1.DialogContent, { ...contentTouchHandlers, sx: contentSx, children: children })] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PendingChangesDialogView = PendingChangesDialogView;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const material_1 = require("@mui/material");
|
|
10
|
+
const ArrowForwardRounded_1 = __importDefault(require("@mui/icons-material/ArrowForwardRounded"));
|
|
11
|
+
const CloudUploadOutlined_1 = __importDefault(require("@mui/icons-material/CloudUploadOutlined"));
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const PendingChangesDialogShell_js_1 = require("./PendingChangesDialogShell.js");
|
|
14
|
+
const pageSize = 10;
|
|
15
|
+
function PendingChangesDialogView({ groups, open, onClose, title, summary, emptyMessage = "All changes are saved.", accountKey, onOpenItem, focusGroupKey, navigationError, contentHeader, contentTouchHandlers, shell: Shell = PendingChangesDialogShell_js_1.PendingChangesDialogShell, }) {
|
|
16
|
+
const returnItemButton = (0, react_1.useRef)(null);
|
|
17
|
+
const [page, setPage] = (0, react_1.useState)(1);
|
|
18
|
+
const [actionPages, setActionPages] = (0, react_1.useState)({});
|
|
19
|
+
const pages = Math.max(1, Math.ceil(groups.length / pageSize));
|
|
20
|
+
const visiblePage = Math.min(page, pages);
|
|
21
|
+
const [previousGroups, setPreviousGroups] = (0, react_1.useState)(groups);
|
|
22
|
+
const [previousAccount, setPreviousAccount] = (0, react_1.useState)(accountKey);
|
|
23
|
+
// Adjust pagination only when the source view changes. Guarded render state
|
|
24
|
+
// keeps the first painted frame bounded and avoids effect-driven page jumps.
|
|
25
|
+
if (previousGroups !== groups || previousAccount !== accountKey) {
|
|
26
|
+
setPreviousGroups(groups);
|
|
27
|
+
setPreviousAccount(accountKey);
|
|
28
|
+
if (previousAccount !== accountKey) {
|
|
29
|
+
setPage(1);
|
|
30
|
+
setActionPages({});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
setPage((current) => Math.min(current, pages));
|
|
34
|
+
setActionPages((current) => {
|
|
35
|
+
const next = {};
|
|
36
|
+
for (const group of groups)
|
|
37
|
+
if (current[group.key] !== undefined)
|
|
38
|
+
next[group.key] = Math.min(current[group.key], Math.max(1, Math.ceil(group.rows.length / pageSize)));
|
|
39
|
+
return Object.keys(next).length === Object.keys(current).length &&
|
|
40
|
+
Object.keys(next).every((key) => next[key] === current[key])
|
|
41
|
+
? current
|
|
42
|
+
: next;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)(Shell, { autoFocusInput: false, closeLabel: "Close pending changes", closeTooltip: "Close pending changes", contentHeader: contentHeader !== null && contentHeader !== void 0 ? contentHeader : (groups.length ? (
|
|
47
|
+
// Product decision: the sync summary remains distinct and visible
|
|
48
|
+
// while the user scrolls through pending groups.
|
|
49
|
+
(0, jsx_runtime_1.jsx)(material_1.Stack, { component: "section", "aria-label": "Pending changes summary", spacing: 0.5, sx: { p: 2, borderRadius: 1, bgcolor: "action.selected" }, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { fontWeight: 600 }, children: summary }) })) : undefined), contentTouchHandlers: contentTouchHandlers, contentSx: { pt: 0.5, pb: 3, overscrollBehaviorY: "contain" }, exclusive: false, onClose: onClose, onEntered: () => {
|
|
50
|
+
// Entry focus runs after MUI settles its focus trap, including a reopen
|
|
51
|
+
// of the same inspector. A removed group retains the shell's fallback.
|
|
52
|
+
const target = returnItemButton.current;
|
|
53
|
+
if ((target === null || target === void 0 ? void 0 : target.isConnected) && !target.disabled)
|
|
54
|
+
target.focus();
|
|
55
|
+
}, open: open, title: title, titleIcon: (0, jsx_runtime_1.jsx)(CloudUploadOutlined_1.default, {}), children: [navigationError ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { role: "alert", color: "error", variant: "body2", sx: { mb: 1 }, children: navigationError })) : null, groups.length ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.List, { "aria-label": "Pending changes", disablePadding: true, sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: groups
|
|
56
|
+
.slice((visiblePage - 1) * pageSize, visiblePage * pageSize)
|
|
57
|
+
.map((group) => {
|
|
58
|
+
var _a;
|
|
59
|
+
const title = group.title;
|
|
60
|
+
const unavailableReason = group.unavailableReason;
|
|
61
|
+
const actionPageCount = Math.max(1, Math.ceil(group.rows.length / pageSize));
|
|
62
|
+
const actionPage = Math.min((_a = actionPages[group.key]) !== null && _a !== void 0 ? _a : 1, actionPageCount);
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(material_1.ListItem, { disableGutters: true, sx: {
|
|
64
|
+
p: 2,
|
|
65
|
+
alignItems: "flex-start",
|
|
66
|
+
border: 1,
|
|
67
|
+
borderColor: "divider",
|
|
68
|
+
borderRadius: 1,
|
|
69
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 1, sx: { minWidth: 0, width: "100%" }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, sx: {
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
justifyContent: "space-between",
|
|
72
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: title, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h3", "aria-label": title, tabIndex: 0, sx: {
|
|
73
|
+
flex: 1,
|
|
74
|
+
minWidth: 0,
|
|
75
|
+
fontWeight: 600,
|
|
76
|
+
// The item name owns one row; CSS handles the
|
|
77
|
+
// available width, while the tooltip retains it all.
|
|
78
|
+
overflow: "hidden",
|
|
79
|
+
textOverflow: "ellipsis",
|
|
80
|
+
whiteSpace: "nowrap",
|
|
81
|
+
}, variant: "body2", children: title }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center", flexShrink: 0 }, children: group.openLabel && onOpenItem ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: unavailableReason || group.openLabel, children: (0, jsx_runtime_1.jsx)("span", { tabIndex: unavailableReason ? 0 : undefined, "aria-label": unavailableReason
|
|
82
|
+
? `${group.openLabel} unavailable. ${unavailableReason}`
|
|
83
|
+
: undefined, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": `${group.openLabel}: ${title}`, disabled: Boolean(unavailableReason), ref: focusGroupKey === group.key
|
|
84
|
+
? returnItemButton
|
|
85
|
+
: undefined, onClick: () => onOpenItem(group.key), size: "small", sx: { width: 44, height: 44 }, children: (0, jsx_runtime_1.jsx)(ArrowForwardRounded_1.default, { fontSize: "small" }) }) }) })) : null })] }), (0, jsx_runtime_1.jsx)(material_1.List, { "aria-label": `Changes for ${group.title}`, disablePadding: true, children: group.rows
|
|
86
|
+
.slice((actionPage - 1) * pageSize, actionPage * pageSize)
|
|
87
|
+
.map((item, index) => {
|
|
88
|
+
const presentation = item;
|
|
89
|
+
const exception = item.exception;
|
|
90
|
+
if (!presentation.action &&
|
|
91
|
+
!exception &&
|
|
92
|
+
!presentation.targetLabel &&
|
|
93
|
+
presentation.attemptedText === undefined)
|
|
94
|
+
return null;
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(material_1.ListItem, { disableGutters: true, sx: {
|
|
96
|
+
display: "block",
|
|
97
|
+
py: 1,
|
|
98
|
+
borderTop: index > 0 ? 1 : 0,
|
|
99
|
+
borderColor: "divider",
|
|
100
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 0.75, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, sx: {
|
|
101
|
+
alignItems: "baseline",
|
|
102
|
+
justifyContent: "space-between",
|
|
103
|
+
flexWrap: "wrap",
|
|
104
|
+
}, children: [presentation.action ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h4", color: "text.secondary", variant: "caption", children: presentation.action })) : null, exception ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: item.needsAttention
|
|
105
|
+
? "error"
|
|
106
|
+
: "text.secondary", variant: "caption", children: exception })) : null] }), presentation.targetLabel ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.secondary", variant: "caption", sx: {
|
|
107
|
+
overflowWrap: "anywhere",
|
|
108
|
+
whiteSpace: "pre-wrap",
|
|
109
|
+
}, children: presentation.targetLabel })) : null, presentation.attemptedText !== undefined ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", sx: {
|
|
110
|
+
whiteSpace: "pre-wrap",
|
|
111
|
+
overflowWrap: "anywhere",
|
|
112
|
+
}, children: presentation.attemptedText })) : null] }) }, item.id));
|
|
113
|
+
}) }), actionPageCount > 1 ? ((0, jsx_runtime_1.jsx)(material_1.Pagination, { "aria-label": `Change pages for ${group.title}`, count: actionPageCount, page: actionPage, onChange: (_event, nextPage) => setActionPages((previous) => ({
|
|
114
|
+
...previous,
|
|
115
|
+
[group.key]: nextPage,
|
|
116
|
+
})), sx: {
|
|
117
|
+
"& .MuiPaginationItem-root": {
|
|
118
|
+
minWidth: 44,
|
|
119
|
+
minHeight: 44,
|
|
120
|
+
},
|
|
121
|
+
} })) : null] }) }, group.key));
|
|
122
|
+
}) }), pages > 1 ? ((0, jsx_runtime_1.jsx)(material_1.Pagination, { "aria-label": "Pending changes pages", count: pages, onChange: (_event, nextPage) => setPage(nextPage), page: visiblePage, sx: {
|
|
123
|
+
mt: 2,
|
|
124
|
+
"& .MuiPaginationItem-root": { minWidth: 44, minHeight: 44 },
|
|
125
|
+
} })) : null] })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { role: "status", sx: { py: 2 }, children: emptyMessage }))] }));
|
|
126
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PendingChangesIndicatorView = PendingChangesIndicatorView;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const material_1 = require("@mui/material");
|
|
10
|
+
const styles_1 = require("@mui/material/styles");
|
|
11
|
+
const CloudOffOutlined_1 = __importDefault(require("@mui/icons-material/CloudOffOutlined"));
|
|
12
|
+
const CloudUploadOutlined_1 = __importDefault(require("@mui/icons-material/CloudUploadOutlined"));
|
|
13
|
+
function PendingChangesIndicatorView({ count, isOffline = false, label = `${count} pending ${count === 1 ? "change" : "changes"}`, explanation = "View pending changes", onOpen, sx, }) {
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: `${isOffline ? "Offline. " : ""}${label}. ${explanation}`, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": `${isOffline ? "Offline. " : ""}${label}. View pending changes`, "aria-haspopup": "dialog", onClick: onOpen, sx: [
|
|
15
|
+
{
|
|
16
|
+
width: 44,
|
|
17
|
+
height: 44,
|
|
18
|
+
borderRadius: "50%",
|
|
19
|
+
color: "primary.main",
|
|
20
|
+
bgcolor: "background.paper",
|
|
21
|
+
"&:hover": {
|
|
22
|
+
bgcolor: (theme) => (0, styles_1.alpha)(theme.palette.primary.main, 0.18),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
...(Array.isArray(sx) ? sx : sx ? [sx] : []),
|
|
26
|
+
], children: (0, jsx_runtime_1.jsx)(material_1.Badge, { badgeContent: count, color: "primary", max: Number.MAX_SAFE_INTEGER, slotProps: { badge: { "aria-hidden": true } }, children: isOffline ? (0, jsx_runtime_1.jsx)(CloudOffOutlined_1.default, {}) : (0, jsx_runtime_1.jsx)(CloudUploadOutlined_1.default, {}) }) }) }));
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PendingChangesIndicatorView = exports.PendingChangesDialogView = void 0;
|
|
5
|
+
// TL-M249: preserve the established MUI presentation under its owning package.
|
|
6
|
+
var PendingChangesDialogView_js_1 = require("./PendingChangesDialogView.js");
|
|
7
|
+
Object.defineProperty(exports, "PendingChangesDialogView", { enumerable: true, get: function () { return PendingChangesDialogView_js_1.PendingChangesDialogView; } });
|
|
8
|
+
var PendingChangesIndicatorView_js_1 = require("./PendingChangesIndicatorView.js");
|
|
9
|
+
Object.defineProperty(exports, "PendingChangesIndicatorView", { enumerable: true, get: function () { return PendingChangesIndicatorView_js_1.PendingChangesIndicatorView; } });
|
|
@@ -49,13 +49,45 @@ const createBayonTheme_js_1 = require("../theme/createBayonTheme.js");
|
|
|
49
49
|
const createBayonEmotionCache_js_1 = require("../utils/createBayonEmotionCache.js");
|
|
50
50
|
const clientSideEmotionCache = (0, createBayonEmotionCache_js_1.createBayonEmotionCache)();
|
|
51
51
|
const defaultStorageKey = 'bayon-theme-mode';
|
|
52
|
+
const themeModeChangeEvent = 'bayon-theme-mode-change';
|
|
53
|
+
const clientModeOverrides = new Map();
|
|
52
54
|
const BayonThemeModeContext = React.createContext(undefined);
|
|
53
55
|
function readStoredMode(storageKey, defaultMode) {
|
|
54
56
|
if (typeof window === 'undefined') {
|
|
55
57
|
return defaultMode;
|
|
56
58
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
+
const clientOverride = clientModeOverrides.get(storageKey);
|
|
60
|
+
if (clientOverride) {
|
|
61
|
+
return clientOverride;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const storedMode = window.localStorage.getItem(storageKey);
|
|
65
|
+
return storedMode === 'light' || storedMode === 'dark' ? storedMode : defaultMode;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('[bayon-theme] Failed to read the saved theme mode', { error, storageKey });
|
|
69
|
+
clientModeOverrides.set(storageKey, defaultMode);
|
|
70
|
+
return defaultMode;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function subscribeToStoredMode(storageKey, onStoreChange) {
|
|
74
|
+
const handleStorageChange = (event) => {
|
|
75
|
+
if (event.key === storageKey) {
|
|
76
|
+
clientModeOverrides.delete(storageKey);
|
|
77
|
+
onStoreChange();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const handleLocalChange = (event) => {
|
|
81
|
+
if (event instanceof CustomEvent && event.detail === storageKey) {
|
|
82
|
+
onStoreChange();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
window.addEventListener('storage', handleStorageChange);
|
|
86
|
+
window.addEventListener(themeModeChangeEvent, handleLocalChange);
|
|
87
|
+
return () => {
|
|
88
|
+
window.removeEventListener('storage', handleStorageChange);
|
|
89
|
+
window.removeEventListener(themeModeChangeEvent, handleLocalChange);
|
|
90
|
+
};
|
|
59
91
|
}
|
|
60
92
|
function useBayonThemeMode() {
|
|
61
93
|
const context = React.useContext(BayonThemeModeContext);
|
|
@@ -89,12 +121,26 @@ class BayonThemeErrorBoundary extends React.Component {
|
|
|
89
121
|
}
|
|
90
122
|
}
|
|
91
123
|
function BayonThemeProvider({ children, emotionCache = clientSideEmotionCache, disableEmotionCacheProvider = false, theme, defaultMode = 'dark', storageKey = defaultStorageKey, enableErrorBoundary = true, }) {
|
|
92
|
-
const
|
|
124
|
+
const subscribe = React.useCallback((onStoreChange) => subscribeToStoredMode(storageKey, onStoreChange), [storageKey]);
|
|
125
|
+
const getSnapshot = React.useCallback(() => readStoredMode(storageKey, defaultMode), [defaultMode, storageKey]);
|
|
126
|
+
const getServerSnapshot = React.useCallback(() => defaultMode, [defaultMode]);
|
|
127
|
+
const mode = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
93
128
|
const setMode = React.useCallback((nextMode) => {
|
|
94
|
-
|
|
95
|
-
|
|
129
|
+
if (typeof window === 'undefined') {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
clientModeOverrides.set(storageKey, nextMode);
|
|
133
|
+
try {
|
|
96
134
|
window.localStorage.setItem(storageKey, nextMode);
|
|
97
135
|
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
console.error('[bayon-theme] Failed to persist the selected theme mode', {
|
|
138
|
+
error,
|
|
139
|
+
mode: nextMode,
|
|
140
|
+
storageKey,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
window.dispatchEvent(new CustomEvent(themeModeChangeEvent, { detail: storageKey }));
|
|
98
144
|
}, [storageKey]);
|
|
99
145
|
const toggleMode = React.useCallback(() => {
|
|
100
146
|
setMode(mode === 'dark' ? 'light' : 'dark');
|
|
@@ -105,12 +151,6 @@ function BayonThemeProvider({ children, emotionCache = clientSideEmotionCache, d
|
|
|
105
151
|
setMode,
|
|
106
152
|
toggleMode,
|
|
107
153
|
}), [mode, setMode, toggleMode]);
|
|
108
|
-
React.useEffect(() => {
|
|
109
|
-
const storedMode = readStoredMode(storageKey, defaultMode);
|
|
110
|
-
if (storedMode !== mode) {
|
|
111
|
-
setModeState(storedMode);
|
|
112
|
-
}
|
|
113
|
-
}, [defaultMode, mode, storageKey]);
|
|
114
154
|
React.useEffect(() => {
|
|
115
155
|
document.documentElement.setAttribute('data-theme', mode);
|
|
116
156
|
}, [mode]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ExpandableSectionToggle = ExpandableSectionToggle;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const ExpandMore_1 = __importDefault(require("@mui/icons-material/ExpandMore"));
|
|
10
|
+
const material_1 = require("@mui/material");
|
|
11
|
+
function ExpandableSectionToggle({ ariaControls, ariaLabel, children, endAdornment, expanded, onToggle, showExpandIcon = true, sx, }) {
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.ButtonBase, { "aria-controls": ariaControls, "aria-expanded": expanded, "aria-label": ariaLabel, "data-expandable-section-toggle": "true", onClick: onToggle, sx: {
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
borderRadius: 1,
|
|
15
|
+
color: "text.primary",
|
|
16
|
+
display: "flex",
|
|
17
|
+
gap: 1,
|
|
18
|
+
justifyContent: "space-between",
|
|
19
|
+
minWidth: 0,
|
|
20
|
+
px: 0.75,
|
|
21
|
+
py: 0.5,
|
|
22
|
+
textAlign: "left",
|
|
23
|
+
width: "100%",
|
|
24
|
+
"&:hover": { backgroundColor: "action.hover" },
|
|
25
|
+
"&:focus-visible": {
|
|
26
|
+
outline: "2px solid",
|
|
27
|
+
outlineColor: "primary.main",
|
|
28
|
+
outlineOffset: 2,
|
|
29
|
+
},
|
|
30
|
+
...sx,
|
|
31
|
+
}, type: "button", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { flex: "1 1 auto", minWidth: 0 }, children: children }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 0.5, sx: { alignItems: "center", flex: "0 0 auto" }, children: [endAdornment, showExpandIcon ? ((0, jsx_runtime_1.jsx)(ExpandMore_1.default, { "aria-hidden": "true", fontSize: "small", sx: { transform: expanded ? "rotate(180deg)" : "none" } })) : null] })] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ExpandableSectionToggle = void 0;
|
|
5
|
+
// TL-M249: preserve the established MUI presentation under its owning package.
|
|
6
|
+
var ExpandableSectionToggle_js_1 = require("./ExpandableSectionToggle.js");
|
|
7
|
+
Object.defineProperty(exports, "ExpandableSectionToggle", { enumerable: true, get: function () { return ExpandableSectionToggle_js_1.ExpandableSectionToggle; } });
|