@bayonai/mui-design 1.10.1 → 1.10.2
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 +5 -0
- package/dist/cjs/uploads/FileViewer.js +19 -1
- package/dist/esm/uploads/FileViewer.js +21 -3
- package/docs/uploads-contract.md +15 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.10.2 — 2026-11-28
|
|
4
|
+
|
|
5
|
+
- Widen the rounded attachment viewer on phone and desktop while preserving its content-driven height and preview limits.
|
|
6
|
+
- Place Download beside Close in the filename header. The full filename remains the accessible dialog name when visually truncated.
|
|
7
|
+
|
|
3
8
|
## 1.10.1 — 2026-11-27
|
|
4
9
|
|
|
5
10
|
- Build the ESM, CommonJS, and TypeScript declaration files automatically before packing. This restores the runtime files missing from the published 1.10.0 archive.
|
|
@@ -11,6 +11,7 @@ const CloseRounded_1 = __importDefault(require("@mui/icons-material/CloseRounded
|
|
|
11
11
|
const DownloadRounded_1 = __importDefault(require("@mui/icons-material/DownloadRounded"));
|
|
12
12
|
const material_1 = require("@mui/material");
|
|
13
13
|
const react_2 = require("react");
|
|
14
|
+
const headerActionSx = { width: 44, height: 44, flexShrink: 0 };
|
|
14
15
|
const rasterImageTypes = new Set([
|
|
15
16
|
"image/jpeg",
|
|
16
17
|
"image/png",
|
|
@@ -42,6 +43,7 @@ function FileViewer(props) {
|
|
|
42
43
|
return (0, react_1.createElement)(FileViewerState, { ...props, key: fileKey });
|
|
43
44
|
}
|
|
44
45
|
function FileViewerState({ attachment, onClose, loadFile, onDownload, }) {
|
|
46
|
+
const titleId = (0, react_2.useId)();
|
|
45
47
|
const [downloadError, setDownloadError] = (0, react_2.useState)(null);
|
|
46
48
|
const [downloading, setDownloading] = (0, react_2.useState)(false);
|
|
47
49
|
async function download() {
|
|
@@ -66,7 +68,23 @@ function FileViewerState({ attachment, onClose, loadFile, onDownload, }) {
|
|
|
66
68
|
const previewKind = attachment
|
|
67
69
|
? getPreviewKind(attachment.contentType)
|
|
68
70
|
: null;
|
|
69
|
-
|
|
71
|
+
// Product decision: give previews more width while retaining the existing
|
|
72
|
+
// media height limits. Keep Download and Close in reading order above the file.
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { "aria-labelledby": titleId, fullWidth: true, maxWidth: "xl", onClose: onClose, open: Boolean(attachment), slotProps: {
|
|
74
|
+
paper: {
|
|
75
|
+
sx: {
|
|
76
|
+
width: { xs: "calc(100% - 16px)", sm: "calc(100% - 64px)" },
|
|
77
|
+
mx: { xs: 1, sm: 4 },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { component: "div", id: `${titleId}-header`, sx: {
|
|
81
|
+
alignItems: "center",
|
|
82
|
+
display: "flex",
|
|
83
|
+
gap: 0.5,
|
|
84
|
+
py: 1,
|
|
85
|
+
pl: { xs: 2, sm: 3 },
|
|
86
|
+
pr: 1,
|
|
87
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", dir: "auto", id: titleId, noWrap: true, sx: { flex: 1, minWidth: 0, textAlign: "start" }, variant: "h6", children: attachment === null || attachment === void 0 ? void 0 : attachment.fileName }), attachment ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": "Download attachment", disabled: downloading, onClick: () => void download(), sx: headerActionSx, children: (0, jsx_runtime_1.jsx)(DownloadRounded_1.default, {}) })) : null, (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": "Close attachment preview", onClick: onClose, sx: headerActionSx, children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, {}) })] }), (0, jsx_runtime_1.jsxs)(material_1.DialogContent, { dividers: true, sx: { borderBottom: 0, minHeight: 240, px: { xs: 1, sm: 2 }, pb: 1.5 }, children: [attachment ? ((0, jsx_runtime_1.jsx)(AttachmentViewerContent, { attachment: attachment, loadFile: loadFile, previewKind: previewKind })) : null, downloadError ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { role: "alert", color: "error", sx: { mt: 1 }, children: downloadError })) : null] })] }));
|
|
70
88
|
}
|
|
71
89
|
function AttachmentViewerContent({ attachment, previewKind, loadFile, }) {
|
|
72
90
|
if (!previewKind) {
|
|
@@ -3,8 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { createElement as _createElement } from "react";
|
|
4
4
|
import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
|
|
5
5
|
import DownloadRoundedIcon from "@mui/icons-material/DownloadRounded";
|
|
6
|
-
import { Box, CircularProgress, Dialog,
|
|
7
|
-
import { useEffect, useState } from "react";
|
|
6
|
+
import { Box, CircularProgress, Dialog, DialogContent, DialogTitle, IconButton, Typography, } from "@mui/material";
|
|
7
|
+
import { useEffect, useId, useState } from "react";
|
|
8
|
+
const headerActionSx = { width: 44, height: 44, flexShrink: 0 };
|
|
8
9
|
const rasterImageTypes = new Set([
|
|
9
10
|
"image/jpeg",
|
|
10
11
|
"image/png",
|
|
@@ -36,6 +37,7 @@ export function FileViewer(props) {
|
|
|
36
37
|
return _createElement(FileViewerState, { ...props, key: fileKey });
|
|
37
38
|
}
|
|
38
39
|
function FileViewerState({ attachment, onClose, loadFile, onDownload, }) {
|
|
40
|
+
const titleId = useId();
|
|
39
41
|
const [downloadError, setDownloadError] = useState(null);
|
|
40
42
|
const [downloading, setDownloading] = useState(false);
|
|
41
43
|
async function download() {
|
|
@@ -60,7 +62,23 @@ function FileViewerState({ attachment, onClose, loadFile, onDownload, }) {
|
|
|
60
62
|
const previewKind = attachment
|
|
61
63
|
? getPreviewKind(attachment.contentType)
|
|
62
64
|
: null;
|
|
63
|
-
|
|
65
|
+
// Product decision: give previews more width while retaining the existing
|
|
66
|
+
// media height limits. Keep Download and Close in reading order above the file.
|
|
67
|
+
return (_jsxs(Dialog, { "aria-labelledby": titleId, fullWidth: true, maxWidth: "xl", onClose: onClose, open: Boolean(attachment), slotProps: {
|
|
68
|
+
paper: {
|
|
69
|
+
sx: {
|
|
70
|
+
width: { xs: "calc(100% - 16px)", sm: "calc(100% - 64px)" },
|
|
71
|
+
mx: { xs: 1, sm: 4 },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
}, children: [_jsxs(DialogTitle, { component: "div", id: `${titleId}-header`, sx: {
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
display: "flex",
|
|
77
|
+
gap: 0.5,
|
|
78
|
+
py: 1,
|
|
79
|
+
pl: { xs: 2, sm: 3 },
|
|
80
|
+
pr: 1,
|
|
81
|
+
}, children: [_jsx(Typography, { component: "h2", dir: "auto", id: titleId, noWrap: true, sx: { flex: 1, minWidth: 0, textAlign: "start" }, variant: "h6", children: attachment === null || attachment === void 0 ? void 0 : attachment.fileName }), attachment ? (_jsx(IconButton, { "aria-label": "Download attachment", disabled: downloading, onClick: () => void download(), sx: headerActionSx, children: _jsx(DownloadRoundedIcon, {}) })) : null, _jsx(IconButton, { "aria-label": "Close attachment preview", onClick: onClose, sx: headerActionSx, children: _jsx(CloseRoundedIcon, {}) })] }), _jsxs(DialogContent, { dividers: true, sx: { borderBottom: 0, minHeight: 240, px: { xs: 1, sm: 2 }, pb: 1.5 }, children: [attachment ? (_jsx(AttachmentViewerContent, { attachment: attachment, loadFile: loadFile, previewKind: previewKind })) : null, downloadError ? (_jsx(Typography, { role: "alert", color: "error", sx: { mt: 1 }, children: downloadError })) : null] })] }));
|
|
64
82
|
}
|
|
65
83
|
function AttachmentViewerContent({ attachment, previewKind, loadFile, }) {
|
|
66
84
|
if (!previewKind) {
|
package/docs/uploads-contract.md
CHANGED
|
@@ -47,3 +47,18 @@ coordinates and a nearby-place label. The host supplies display facts and an
|
|
|
47
47
|
optional location action. The component owns the read-only presentation and
|
|
48
48
|
close control. The host owns viewer lifecycle, authorization, byte access,
|
|
49
49
|
lookup, navigation and focus restoration.
|
|
50
|
+
|
|
51
|
+
## Attachment viewer layout
|
|
52
|
+
|
|
53
|
+
`FileViewer` uses the host dialog theme and a narrow side gutter on phone
|
|
54
|
+
screens. It widens on desktop and keeps a content-driven height within the
|
|
55
|
+
existing media bounds. Images keep their original proportions. The gray
|
|
56
|
+
Download and Close controls share the filename header, in that keyboard
|
|
57
|
+
order, with 44 px targets. The full filename names the accessible dialog
|
|
58
|
+
even when the visible heading truncates. Recoverable download feedback
|
|
59
|
+
appears in the preview body. The host still owns byte access and saving.
|
|
60
|
+
|
|
61
|
+
Package coverage lives in `tests/uploads/FileViewer.test.tsx`. The
|
|
62
|
+
Thunderlist consumer's Chromium regression
|
|
63
|
+
`tests/components/attachment-viewer.spec.ts` exercises the responsive shape,
|
|
64
|
+
keyboard order, focus restoration, and browser download.
|