@bayonai/mui-design 1.5.0 → 1.7.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 +12 -0
- package/dist/cjs/actions/ActionMenu.d.ts +24 -0
- package/dist/cjs/actions/DialogActionButtons.d.ts +23 -0
- package/dist/cjs/actions/DialogActionButtons.js +2 -2
- package/dist/cjs/actions/LoadingIconButton.d.ts +11 -0
- package/dist/cjs/actions/StickyActionFooter.d.ts +14 -0
- package/dist/cjs/actions/StickySubmitButton.d.ts +10 -0
- package/dist/cjs/actions/index.d.ts +5 -0
- package/dist/cjs/client.d.ts +4 -0
- package/dist/cjs/components/BayonFlowVisual.d.ts +12 -0
- package/dist/cjs/components/BayonThemeModeToggle.d.ts +6 -0
- package/dist/cjs/components/IconTooltipButton.d.ts +10 -0
- package/dist/cjs/components/panels.d.ts +37 -0
- package/dist/cjs/drawers/BottomDrawer.d.ts +16 -0
- package/dist/cjs/drawers/MobileBottomDrawer.d.ts +20 -0
- package/dist/cjs/drawers/MobileBottomDrawerHeader.d.ts +11 -0
- package/dist/cjs/drawers/ResponsiveDrawer.d.ts +25 -0
- package/dist/cjs/drawers/drawerAppearance.d.ts +8 -0
- package/dist/cjs/drawers/index.d.ts +6 -0
- package/dist/cjs/drawers/useVisualViewportBottomInset.d.ts +6 -0
- package/dist/cjs/feedback/StatusNotice.d.ts +13 -0
- package/dist/cjs/feedback/index.d.ts +1 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/internal/DialogChoiceTile.d.ts +20 -0
- package/dist/cjs/internal/DialogChoiceTile.js +60 -0
- package/dist/cjs/links/LinkAddressPreview.d.ts +19 -0
- package/dist/cjs/links/index.d.ts +3 -0
- package/dist/cjs/links/useLinkAddressPreview.d.ts +26 -0
- package/dist/cjs/location/GeographicLocationField.d.ts +26 -0
- package/dist/cjs/location/GoogleMapsAttribution.d.ts +1 -0
- package/dist/cjs/location/MetadataFieldGroup.d.ts +5 -0
- package/dist/cjs/location/MetadataValueField.d.ts +23 -0
- package/dist/cjs/location/SearchInputAction.d.ts +9 -0
- package/dist/cjs/location/TemplateBadge.d.ts +5 -0
- package/dist/cjs/location/VenueSearchDialog.d.ts +33 -0
- package/dist/cjs/location/index.d.ts +6 -0
- package/dist/cjs/pending/PendingChangesDialogShell.d.ts +2 -0
- package/dist/cjs/pending/PendingChangesDialogView.d.ts +2 -0
- package/dist/cjs/pending/PendingChangesIndicatorView.d.ts +10 -0
- package/dist/cjs/pending/index.d.ts +3 -0
- package/dist/cjs/pending/types.d.ts +55 -0
- package/dist/cjs/pricing/PlanUpgradeDialog.d.ts +17 -0
- package/dist/cjs/pricing/PlanUpgradeDialog.js +22 -0
- package/dist/cjs/pricing/PricingTable.d.ts +28 -0
- package/dist/cjs/pricing/index.d.ts +3 -0
- package/dist/cjs/pricing/index.js +3 -1
- package/dist/cjs/providers/BayonThemeProvider.d.ts +20 -0
- package/dist/cjs/sections/ExpandableSectionToggle.d.ts +12 -0
- package/dist/cjs/sections/index.d.ts +2 -0
- package/dist/cjs/styles/pageStyles.d.ts +15 -0
- package/dist/cjs/swipe/SwipeActionRow.d.ts +8 -0
- package/dist/cjs/swipe/index.d.ts +1 -0
- package/dist/cjs/theme/components.d.ts +2 -0
- package/dist/cjs/theme/createBayonTheme.d.ts +4 -0
- package/dist/cjs/theme/palette.d.ts +146 -0
- package/dist/cjs/theme/shadows.d.ts +2 -0
- package/dist/cjs/theme/types.d.ts +47 -0
- package/dist/cjs/theme/typography.d.ts +2 -0
- package/dist/cjs/toasts/ActionToast.d.ts +11 -0
- package/dist/cjs/toasts/Toast.d.ts +16 -0
- package/dist/cjs/toasts/index.d.ts +5 -0
- package/dist/cjs/toasts/useUpwardToastDismiss.d.ts +15 -0
- package/dist/cjs/uploads/CameraCaptureDialog.d.ts +22 -0
- package/dist/cjs/uploads/FileRow.d.ts +10 -0
- package/dist/cjs/uploads/FileSwipeActionRow.d.ts +1 -0
- package/dist/cjs/uploads/FileThumbnail.d.ts +5 -0
- package/dist/cjs/uploads/FileUpload.d.ts +26 -0
- package/dist/cjs/uploads/FileViewer.d.ts +9 -0
- package/dist/cjs/uploads/FileViewer.js +25 -21
- package/dist/cjs/uploads/ImageCropDialog.d.ts +26 -0
- package/dist/cjs/uploads/ImageInfoPanel.d.ts +24 -0
- package/dist/cjs/uploads/ImageInfoPanel.js +41 -0
- package/dist/cjs/uploads/ImageUploadQualityDialog.d.ts +13 -0
- package/dist/cjs/uploads/ImageUploadQualityDialog.js +57 -0
- package/dist/cjs/uploads/UploadProgressRing.d.ts +24 -0
- package/dist/cjs/uploads/cameraCropPresentation.d.ts +2 -0
- package/dist/cjs/uploads/index.d.ts +12 -0
- package/dist/cjs/uploads/index.js +5 -1
- package/dist/cjs/utils/createBayonEmotionCache.d.ts +1 -0
- package/dist/esm/actions/DialogActionButtons.js +3 -3
- package/dist/esm/internal/DialogChoiceTile.js +54 -0
- package/dist/esm/pricing/PlanUpgradeDialog.js +19 -0
- package/dist/esm/pricing/index.js +1 -0
- package/dist/esm/uploads/FileViewer.js +25 -21
- package/dist/esm/uploads/ImageInfoPanel.js +35 -0
- package/dist/esm/uploads/ImageUploadQualityDialog.js +51 -0
- package/dist/esm/uploads/index.js +2 -0
- package/dist/types/actions/DialogActionButtons.d.ts +2 -1
- package/dist/types/internal/DialogChoiceTile.d.ts +20 -0
- package/dist/types/pricing/PlanUpgradeDialog.d.ts +17 -0
- package/dist/types/pricing/index.d.ts +1 -0
- package/dist/types/uploads/ImageInfoPanel.d.ts +24 -0
- package/dist/types/uploads/ImageUploadQualityDialog.d.ts +13 -0
- package/dist/types/uploads/index.d.ts +2 -0
- package/docs/uploads-contract.md +9 -0
- package/package.json +119 -41
|
@@ -75,64 +75,68 @@ function AttachmentViewerContent({ attachment, previewKind, loadFile, }) {
|
|
|
75
75
|
return ((0, jsx_runtime_1.jsx)(LoadableAttachmentPreview, { attachment: attachment, previewKind: previewKind, loadFile: loadFile }));
|
|
76
76
|
}
|
|
77
77
|
function LoadableAttachmentPreview({ attachment, previewKind, loadFile, }) {
|
|
78
|
-
const [
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
78
|
+
const [attempt, setAttempt] = (0, react_2.useState)();
|
|
79
|
+
// A replacement loader starts a fresh attempt even for the same attachment.
|
|
80
|
+
const preview = (attempt === null || attempt === void 0 ? void 0 : attempt.attachment) === attachment && attempt.loadFile === loadFile
|
|
81
|
+
? attempt.result
|
|
82
|
+
: undefined;
|
|
83
|
+
const previewUrl = (preview === null || preview === void 0 ? void 0 : preview.kind) === "url" ? preview.value : undefined;
|
|
82
84
|
function handleMediaDecodeError() {
|
|
83
85
|
console.error("[FileViewer] Browser could not decode the file preview.", {
|
|
84
86
|
contentType: attachment.contentType,
|
|
85
87
|
fileId: attachment.id,
|
|
86
88
|
previewKind,
|
|
87
89
|
});
|
|
88
|
-
|
|
90
|
+
setAttempt({ attachment, loadFile, result: { kind: "error" } });
|
|
89
91
|
}
|
|
90
92
|
(0, react_2.useEffect)(() => {
|
|
91
93
|
let objectUrl = null;
|
|
92
|
-
let cancelled = false;
|
|
93
94
|
const controller = new AbortController();
|
|
95
|
+
const { signal } = controller;
|
|
96
|
+
const publish = (result) => {
|
|
97
|
+
if (!signal.aborted)
|
|
98
|
+
setAttempt({ attachment, loadFile, result });
|
|
99
|
+
};
|
|
94
100
|
void (async () => {
|
|
95
101
|
try {
|
|
96
102
|
const blob = attachment.blobUrl.startsWith("blob:")
|
|
97
|
-
? await fetch(attachment.blobUrl).then((response) =>
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
? await fetch(attachment.blobUrl, { signal }).then((response) => {
|
|
104
|
+
if (!response.ok)
|
|
105
|
+
throw new Error("Local attachment blob is unavailable.");
|
|
106
|
+
return response.blob();
|
|
107
|
+
})
|
|
108
|
+
: await loadFile(attachment, signal);
|
|
109
|
+
if (signal.aborted)
|
|
100
110
|
return;
|
|
101
111
|
if (previewKind === "text") {
|
|
102
112
|
const content = await blob.text();
|
|
103
|
-
|
|
104
|
-
setText(content);
|
|
113
|
+
publish({ kind: "text", value: content });
|
|
105
114
|
return;
|
|
106
115
|
}
|
|
107
116
|
objectUrl = attachment.blobUrl.startsWith("blob:")
|
|
108
117
|
? attachment.blobUrl
|
|
109
118
|
: URL.createObjectURL(new Blob([blob], { type: attachment.contentType }));
|
|
110
|
-
|
|
119
|
+
publish({ kind: "url", value: objectUrl });
|
|
111
120
|
}
|
|
112
121
|
catch (caughtError) {
|
|
113
|
-
if (!
|
|
122
|
+
if (!signal.aborted) {
|
|
114
123
|
console.error("[FileViewer] Unable to load the file preview.", {
|
|
115
124
|
contentType: attachment.contentType,
|
|
116
125
|
error: caughtError,
|
|
117
126
|
fileId: attachment.id,
|
|
118
127
|
});
|
|
119
|
-
|
|
128
|
+
publish({ kind: "error" });
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
|
-
finally {
|
|
123
|
-
if (!cancelled)
|
|
124
|
-
setLoading(false);
|
|
125
|
-
}
|
|
126
131
|
})();
|
|
127
132
|
return () => {
|
|
128
|
-
cancelled = true;
|
|
129
133
|
controller.abort();
|
|
130
134
|
if (objectUrl && !attachment.blobUrl.startsWith("blob:")) {
|
|
131
135
|
URL.revokeObjectURL(objectUrl);
|
|
132
136
|
}
|
|
133
137
|
};
|
|
134
138
|
}, [attachment, previewKind, loadFile]);
|
|
135
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children:
|
|
139
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !preview ? ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: "grid", minHeight: 200, placeItems: "center" }, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { "aria-label": "Loading attachment preview" }) })) : preview.kind === "error" ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", role: "alert", children: "Unable to display this file. You can download it instead." })) : previewKind === "image" ? ((0, jsx_runtime_1.jsx)(material_1.Box, { alt: attachment.fileName, component: "img", onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: {
|
|
136
140
|
display: "block",
|
|
137
141
|
maxHeight: "65vh",
|
|
138
142
|
maxWidth: "100%",
|
|
@@ -147,5 +151,5 @@ function LoadableAttachmentPreview({ attachment, previewKind, loadFile, }) {
|
|
|
147
151
|
m: 0,
|
|
148
152
|
overflow: "auto",
|
|
149
153
|
whiteSpace: "pre-wrap",
|
|
150
|
-
}, children: text })) : previewKind === "audio" ? ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "audio", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { width: "100%" } })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "video", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { maxHeight: "65vh", maxWidth: "100%", width: "100%" } })) }));
|
|
154
|
+
}, children: preview.kind === "text" ? preview.value : undefined })) : previewKind === "audio" ? ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "audio", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { width: "100%" } })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "video", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { maxHeight: "65vh", maxWidth: "100%", width: "100%" } })) }));
|
|
151
155
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ImageCrop } from "@bayonai/file-uploads";
|
|
2
|
+
export type ImageCropLabels = {
|
|
3
|
+
title: string;
|
|
4
|
+
close: string;
|
|
5
|
+
preview: string;
|
|
6
|
+
confirm: string;
|
|
7
|
+
opening: string;
|
|
8
|
+
instruction: string;
|
|
9
|
+
zoom: string;
|
|
10
|
+
horizontal: string;
|
|
11
|
+
vertical: string;
|
|
12
|
+
decodeError: string;
|
|
13
|
+
previewError: string;
|
|
14
|
+
};
|
|
15
|
+
export type ImageCropDialogProps = {
|
|
16
|
+
file: File;
|
|
17
|
+
busy: boolean;
|
|
18
|
+
error: string | null;
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
onConfirm: (crop: ImageCrop) => Promise<void>;
|
|
21
|
+
labels?: Partial<ImageCropLabels>;
|
|
22
|
+
previewShape?: "circle" | "square";
|
|
23
|
+
previewWidth?: string | number;
|
|
24
|
+
};
|
|
25
|
+
/** Emits orientation-correct decoded-pixel coordinates; the host persists them. */
|
|
26
|
+
export declare function ImageCropDialog({ file, busy, error, onClose, onConfirm, labels, previewShape, previewWidth, }: ImageCropDialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type SxProps, type Theme } from "@mui/material";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type ImageDimensions = {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
export type ImageInfoPanelProps = {
|
|
8
|
+
id: string;
|
|
9
|
+
dimensions?: ImageDimensions;
|
|
10
|
+
captureTime?: string;
|
|
11
|
+
captureOffset?: string;
|
|
12
|
+
camera?: string;
|
|
13
|
+
location?: {
|
|
14
|
+
coordinates: string;
|
|
15
|
+
approximateName?: string;
|
|
16
|
+
action?: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
loading: boolean;
|
|
19
|
+
failed: boolean;
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
sx?: SxProps<Theme>;
|
|
22
|
+
};
|
|
23
|
+
/** Read-only image facts. The host supplies data and any map action. */
|
|
24
|
+
export declare function ImageInfoPanel({ id, dimensions, captureTime, captureOffset, camera, location, loading, failed, onClose, sx, }: ImageInfoPanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
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.ImageInfoPanel = ImageInfoPanel;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const CloseRounded_1 = __importDefault(require("@mui/icons-material/CloseRounded"));
|
|
10
|
+
const material_1 = require("@mui/material");
|
|
11
|
+
/** Read-only image facts. The host supplies data and any map action. */
|
|
12
|
+
function ImageInfoPanel({ id, dimensions, captureTime, captureOffset, camera, location, loading, failed, onClose, sx = [], }) {
|
|
13
|
+
var _a;
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { component: "section", id: id, "aria-labelledby": `${id}-title`, sx: [{
|
|
15
|
+
minHeight: 0,
|
|
16
|
+
minWidth: 0,
|
|
17
|
+
overflow: "auto",
|
|
18
|
+
bgcolor: "background.paper",
|
|
19
|
+
borderColor: "divider",
|
|
20
|
+
borderTop: { xs: 1, sm: 0 },
|
|
21
|
+
borderLeft: { xs: 0, sm: 1 },
|
|
22
|
+
borderTopLeftRadius: { xs: 3, sm: 0 },
|
|
23
|
+
borderTopRightRadius: { xs: 3, sm: 0 },
|
|
24
|
+
px: { xs: 2, sm: 3 },
|
|
25
|
+
pt: 1.5,
|
|
26
|
+
pb: "max(16px, env(safe-area-inset-bottom))",
|
|
27
|
+
}, ...(Array.isArray(sx) ? sx : [sx])], children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", sx: { alignItems: "center", justifyContent: "space-between" }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { id: `${id}-title`, component: "h2", variant: "h6", sx: { fontWeight: 700 }, children: "Image info" }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": "Close image info", onClick: onClose, children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, {}) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "dl", sx: {
|
|
28
|
+
m: 0,
|
|
29
|
+
"& > :not(:last-child)": { borderBottom: 1, borderColor: "divider" },
|
|
30
|
+
}, children: [dimensions && ((0, jsx_runtime_1.jsxs)(InfoRow, { label: "Dimensions", children: [dimensions.width, " \u00D7 ", dimensions.height, " px"] })), captureTime && ((0, jsx_runtime_1.jsx)(InfoRow, { label: "Date taken", detail: captureOffset, children: captureTime })), camera && (0, jsx_runtime_1.jsx)(InfoRow, { label: "Camera", children: camera }), location && ((0, jsx_runtime_1.jsx)(InfoRow, { label: "Location", action: location.action, detail: location.approximateName ? location.coordinates : undefined, children: (_a = location.approximateName) !== null && _a !== void 0 ? _a : location.coordinates }))] }), loading || failed ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { role: "status", variant: "body2", color: "text.secondary", sx: { py: 1 }, children: loading
|
|
31
|
+
? "Reading image metadata…"
|
|
32
|
+
: "Could not read image metadata." })) : null, !loading &&
|
|
33
|
+
!failed &&
|
|
34
|
+
!dimensions &&
|
|
35
|
+
!captureTime &&
|
|
36
|
+
!camera &&
|
|
37
|
+
!location ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { role: "status", variant: "body2", color: "text.secondary", sx: { py: 1 }, children: "No image details available." })) : null] }));
|
|
38
|
+
}
|
|
39
|
+
function InfoRow({ label, children, action, detail, }) {
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { py: { xs: 1.25, sm: 1.5 }, minWidth: 0 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "dt", variant: "body2", color: "text.secondary", children: label }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { component: "dd", direction: "row", spacing: 1, sx: { m: 0, alignItems: "center", justifyContent: "space-between" }, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { component: "span", sx: { fontWeight: 650, overflowWrap: "anywhere", minWidth: 0 }, children: [children, detail && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "span", sx: { display: "block" }, color: "text.secondary", variant: "body2", children: detail }))] }), action] })] }));
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ImageUploadQuality = "compressed" | "high";
|
|
2
|
+
export type ImageUploadQualityDialogProps = {
|
|
3
|
+
file: File;
|
|
4
|
+
quality: ImageUploadQuality;
|
|
5
|
+
highQualityAccess: "available" | "locked" | "unavailable";
|
|
6
|
+
focusLockedChoice?: boolean;
|
|
7
|
+
hint?: string;
|
|
8
|
+
onQualityChange: (quality: ImageUploadQuality) => void;
|
|
9
|
+
onLockedChoice: () => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
onConfirm: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function ImageUploadQualityDialog({ file, quality, highQualityAccess, focusLockedChoice, hint, onQualityChange, onLockedChoice, onClose, onConfirm, }: ImageUploadQualityDialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
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.ImageUploadQualityDialog = ImageUploadQualityDialog;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const Compress_1 = __importDefault(require("@mui/icons-material/Compress"));
|
|
10
|
+
const ImageSearch_1 = __importDefault(require("@mui/icons-material/ImageSearch"));
|
|
11
|
+
const material_1 = require("@mui/material");
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const DialogActionButtons_js_1 = require("../actions/DialogActionButtons.js");
|
|
14
|
+
const DialogChoiceTile_js_1 = require("../internal/DialogChoiceTile.js");
|
|
15
|
+
function ImageUploadQualityDialog({ file, quality, highQualityAccess, focusLockedChoice = false, hint, onQualityChange, onLockedChoice, onClose, onConfirm, }) {
|
|
16
|
+
const titleId = (0, react_1.useId)();
|
|
17
|
+
const hintId = (0, react_1.useId)();
|
|
18
|
+
const radioName = (0, react_1.useId)();
|
|
19
|
+
const [preview, setPreview] = (0, react_1.useState)();
|
|
20
|
+
const [failedFile, setFailedFile] = (0, react_1.useState)();
|
|
21
|
+
const previewFailed = failedFile === file;
|
|
22
|
+
const url = (preview === null || preview === void 0 ? void 0 : preview.file) === file && !previewFailed ? preview.url : undefined;
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
if (previewFailed)
|
|
25
|
+
return;
|
|
26
|
+
try {
|
|
27
|
+
const url = URL.createObjectURL(file);
|
|
28
|
+
setPreview({ file, url });
|
|
29
|
+
return () => URL.revokeObjectURL(url);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error("[ImageUploadQualityDialog] Could not open a preview for the selected file.", error);
|
|
33
|
+
setFailedFile(file);
|
|
34
|
+
}
|
|
35
|
+
}, [file, previewFailed]);
|
|
36
|
+
const highQualityTile = {
|
|
37
|
+
label: "High quality",
|
|
38
|
+
description: "Original file",
|
|
39
|
+
icon: (0, jsx_runtime_1.jsx)(ImageSearch_1.default, {}),
|
|
40
|
+
selected: quality === "high",
|
|
41
|
+
};
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: true, onClose: onClose, fullWidth: true, maxWidth: "xs", "aria-labelledby": titleId, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { id: titleId, sx: { pr: 7 }, children: ["Upload image", (0, jsx_runtime_1.jsx)(DialogActionButtons_js_1.DialogCloseButton, { label: "Cancel image upload", onClose: onClose })] }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 1.5, children: [url ? ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "img", src: url, alt: "Selected image preview", onError: () => {
|
|
43
|
+
console.warn("[ImageUploadQualityDialog] Could not display the selected image preview.", { type: file.type });
|
|
44
|
+
setFailedFile(file);
|
|
45
|
+
}, sx: {
|
|
46
|
+
display: "block",
|
|
47
|
+
width: "100%",
|
|
48
|
+
maxHeight: "min(32dvh, 230px)",
|
|
49
|
+
objectFit: "contain",
|
|
50
|
+
borderRadius: 2,
|
|
51
|
+
} })) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { overflowWrap: "anywhere" }, children: file.name }), previewFailed ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", children: "Preview unavailable." })) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, { role: highQualityAccess === "locked" ? "group" : "radiogroup", "aria-label": "Image quality", "aria-describedby": hint ? hintId : undefined, sx: {
|
|
52
|
+
display: "grid",
|
|
53
|
+
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
54
|
+
"@media (max-width: 350px)": { gridTemplateColumns: "1fr" },
|
|
55
|
+
gap: 1,
|
|
56
|
+
}, children: [(0, jsx_runtime_1.jsx)(DialogChoiceTile_js_1.DialogChoiceTile, { label: "Compressed", description: "Smaller file", icon: (0, jsx_runtime_1.jsx)(Compress_1.default, {}), name: radioName, selected: quality === "compressed", autoFocus: !focusLockedChoice, onSelect: () => onQualityChange("compressed") }), highQualityAccess === "locked" ? ((0, jsx_runtime_1.jsx)(DialogChoiceTile_js_1.DialogChoiceTile, { ...highQualityTile, autoFocus: focusLockedChoice, onLockedClick: onLockedChoice })) : ((0, jsx_runtime_1.jsx)(DialogChoiceTile_js_1.DialogChoiceTile, { ...highQualityTile, name: radioName, disabled: highQualityAccess === "unavailable", onSelect: () => onQualityChange("high") }))] }), hint ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { id: hintId, variant: "caption", color: "text.secondary", children: hint })) : null] }) }), (0, jsx_runtime_1.jsx)(DialogActionButtons_js_1.DialogActionButtons, { confirmLabel: "Upload image", confirmText: "Upload", onConfirm: onConfirm })] }));
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type SxProps, type Theme } from "@mui/material";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type UploadProgressRingProps = {
|
|
4
|
+
/** The interactive upload target, such as an avatar picker. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** A short accessible description of the in-flight upload. */
|
|
7
|
+
progressLabel: string;
|
|
8
|
+
/** `null` hides the ring; supplied values are clamped to the valid 0–100 range. */
|
|
9
|
+
progress: number | null;
|
|
10
|
+
/** The diameter of the target and progress ring. */
|
|
11
|
+
size?: number;
|
|
12
|
+
/** The MUI circular-progress stroke width. */
|
|
13
|
+
thickness?: number;
|
|
14
|
+
sx?: SxProps<Theme>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Presents determinate upload progress at the object being changed.
|
|
18
|
+
*
|
|
19
|
+
* Product decision: progress belongs with a compact upload target rather than
|
|
20
|
+
* in a separate status row. The host owns file selection, upload lifecycle,
|
|
21
|
+
* validation, errors, and disabled interaction; this primitive only renders
|
|
22
|
+
* the accessible visual state around its child.
|
|
23
|
+
*/
|
|
24
|
+
export declare function UploadProgressRing({ children, progress, progressLabel, size, sx, thickness, }: UploadProgressRingProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { FileUpload } from "./FileUpload.js";
|
|
2
|
+
export { FileRow } from "./FileRow.js";
|
|
3
|
+
export { FileThumbnail } from "./FileThumbnail.js";
|
|
4
|
+
export { FileViewer } from "./FileViewer.js";
|
|
5
|
+
export { ImageInfoPanel, type ImageDimensions, type ImageInfoPanelProps } from "./ImageInfoPanel.js";
|
|
6
|
+
export { UploadProgressRing } from "./UploadProgressRing.js";
|
|
7
|
+
export { useUploadLock } from "@bayonai/file-uploads/hooks";
|
|
8
|
+
export type { UploadFile, LoadFile } from "@bayonai/file-uploads";
|
|
9
|
+
export type { UploadProgressRingProps } from "./UploadProgressRing.js";
|
|
10
|
+
export { CameraCaptureDialog, type CameraCaptureDialogProps, type CameraCaptureLabels } from "./CameraCaptureDialog.js";
|
|
11
|
+
export { ImageCropDialog, type ImageCropDialogProps, type ImageCropLabels } from "./ImageCropDialog.js";
|
|
12
|
+
export { ImageUploadQualityDialog, type ImageUploadQuality, type ImageUploadQualityDialogProps } from "./ImageUploadQualityDialog.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ImageCropDialog = exports.CameraCaptureDialog = exports.useUploadLock = exports.UploadProgressRing = exports.FileViewer = exports.FileThumbnail = exports.FileRow = exports.FileUpload = void 0;
|
|
4
|
+
exports.ImageUploadQualityDialog = exports.ImageCropDialog = exports.CameraCaptureDialog = exports.useUploadLock = exports.UploadProgressRing = exports.ImageInfoPanel = exports.FileViewer = exports.FileThumbnail = exports.FileRow = exports.FileUpload = void 0;
|
|
5
5
|
var FileUpload_js_1 = require("./FileUpload.js");
|
|
6
6
|
Object.defineProperty(exports, "FileUpload", { enumerable: true, get: function () { return FileUpload_js_1.FileUpload; } });
|
|
7
7
|
var FileRow_js_1 = require("./FileRow.js");
|
|
@@ -10,6 +10,8 @@ var FileThumbnail_js_1 = require("./FileThumbnail.js");
|
|
|
10
10
|
Object.defineProperty(exports, "FileThumbnail", { enumerable: true, get: function () { return FileThumbnail_js_1.FileThumbnail; } });
|
|
11
11
|
var FileViewer_js_1 = require("./FileViewer.js");
|
|
12
12
|
Object.defineProperty(exports, "FileViewer", { enumerable: true, get: function () { return FileViewer_js_1.FileViewer; } });
|
|
13
|
+
var ImageInfoPanel_js_1 = require("./ImageInfoPanel.js");
|
|
14
|
+
Object.defineProperty(exports, "ImageInfoPanel", { enumerable: true, get: function () { return ImageInfoPanel_js_1.ImageInfoPanel; } });
|
|
13
15
|
var UploadProgressRing_js_1 = require("./UploadProgressRing.js");
|
|
14
16
|
Object.defineProperty(exports, "UploadProgressRing", { enumerable: true, get: function () { return UploadProgressRing_js_1.UploadProgressRing; } });
|
|
15
17
|
var hooks_1 = require("@bayonai/file-uploads/hooks");
|
|
@@ -18,3 +20,5 @@ var CameraCaptureDialog_js_1 = require("./CameraCaptureDialog.js");
|
|
|
18
20
|
Object.defineProperty(exports, "CameraCaptureDialog", { enumerable: true, get: function () { return CameraCaptureDialog_js_1.CameraCaptureDialog; } });
|
|
19
21
|
var ImageCropDialog_js_1 = require("./ImageCropDialog.js");
|
|
20
22
|
Object.defineProperty(exports, "ImageCropDialog", { enumerable: true, get: function () { return ImageCropDialog_js_1.ImageCropDialog; } });
|
|
23
|
+
var ImageUploadQualityDialog_js_1 = require("./ImageUploadQualityDialog.js");
|
|
24
|
+
Object.defineProperty(exports, "ImageUploadQualityDialog", { enumerable: true, get: function () { return ImageUploadQualityDialog_js_1.ImageUploadQualityDialog; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createBayonEmotionCache(key?: string): import("@emotion/cache").EmotionCache;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import CheckIcon from "@mui/icons-material/Check";
|
|
4
4
|
import CloseIcon from "@mui/icons-material/Close";
|
|
5
|
-
import { CircularProgress, DialogActions, IconButton, Stack, Tooltip, } from "@mui/material";
|
|
5
|
+
import { Button, CircularProgress, DialogActions, IconButton, Stack, Tooltip, } from "@mui/material";
|
|
6
6
|
// Product decision: concise decisions/info fit content above a readable 320px floor.
|
|
7
7
|
// Keep MUI's readable maxWidth/viewport cap; forms and previews own their sizing.
|
|
8
8
|
export const compactDialogPaperSx = {
|
|
@@ -12,8 +12,8 @@ export const compactDialogPaperSx = {
|
|
|
12
12
|
overflowWrap: "anywhere",
|
|
13
13
|
};
|
|
14
14
|
/** Keeps the modal's primary decision compact and explicitly labelled. */
|
|
15
|
-
export function DialogActionButtons({ confirmColor = "success", confirmDisabled = false, confirmIcon, confirmLabel, confirmType = "button", onConfirm, sx, }) {
|
|
16
|
-
return (_jsx(DialogActions, { sx: sx, children: _jsx(Stack, { direction: "row", spacing: 1, children: _jsx(Tooltip, { title: confirmLabel, children: _jsx("span", { children: _jsx(IconButton, { "aria-label": confirmLabel, color: confirmColor, disabled: confirmDisabled, onClick: confirmType === "submit" ? undefined : onConfirm, type: confirmType, children: confirmIcon !== null && confirmIcon !== void 0 ? confirmIcon : _jsx(CheckIcon, {}) }) }) }) }) }));
|
|
15
|
+
export function DialogActionButtons({ confirmColor = "success", confirmDisabled = false, confirmIcon, confirmLabel, confirmText, confirmType = "button", onConfirm, sx, }) {
|
|
16
|
+
return (_jsx(DialogActions, { sx: sx, children: confirmText ? (_jsx(Button, { "aria-label": confirmLabel, color: confirmColor, disabled: confirmDisabled, onClick: confirmType === "submit" ? undefined : onConfirm, startIcon: confirmIcon, type: confirmType, variant: "contained", children: confirmText })) : (_jsx(Stack, { direction: "row", spacing: 1, children: _jsx(Tooltip, { title: confirmLabel, children: _jsx("span", { children: _jsx(IconButton, { "aria-label": confirmLabel, color: confirmColor, disabled: confirmDisabled, onClick: confirmType === "submit" ? undefined : onConfirm, type: confirmType, children: confirmIcon !== null && confirmIcon !== void 0 ? confirmIcon : _jsx(CheckIcon, {}) }) }) }) })) }));
|
|
17
17
|
}
|
|
18
18
|
export function DialogActionProgress() {
|
|
19
19
|
return _jsx(CircularProgress, { color: "inherit", size: 20 });
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
|
4
|
+
import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
|
|
5
|
+
import { Box, ButtonBase, Typography } from "@mui/material";
|
|
6
|
+
export function DialogChoiceTile(props) {
|
|
7
|
+
const { label, description, icon, selected, autoFocus } = props;
|
|
8
|
+
const sx = {
|
|
9
|
+
position: "relative",
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
alignItems: icon ? "center" : "flex-start",
|
|
13
|
+
justifyContent: "center",
|
|
14
|
+
textAlign: icon ? "center" : "start",
|
|
15
|
+
gap: 0.5,
|
|
16
|
+
p: 1.5,
|
|
17
|
+
minWidth: 0,
|
|
18
|
+
minHeight: 80,
|
|
19
|
+
border: "1px solid",
|
|
20
|
+
borderColor: selected ? "success.main" : "divider",
|
|
21
|
+
borderRadius: 2,
|
|
22
|
+
backgroundColor: selected ? "action.selected" : "background.paper",
|
|
23
|
+
overflowWrap: "anywhere",
|
|
24
|
+
"&:hover": { backgroundColor: "action.hover" },
|
|
25
|
+
"&:has(input:focus-visible), &.Mui-focusVisible": {
|
|
26
|
+
outline: "2px solid",
|
|
27
|
+
outlineColor: "success.main",
|
|
28
|
+
outlineOffset: 2,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const content = (_jsxs(_Fragment, { children: [selected || props.onLockedClick ? (_jsx(Box, { "aria-hidden": true, sx: {
|
|
32
|
+
position: "absolute",
|
|
33
|
+
top: 8,
|
|
34
|
+
right: 8,
|
|
35
|
+
color: selected ? "success.main" : "text.secondary",
|
|
36
|
+
lineHeight: 0,
|
|
37
|
+
}, children: selected ? (_jsx(CheckCircleIcon, { fontSize: "small" })) : (_jsx(LockOutlinedIcon, { fontSize: "small" })) })) : null, icon ? (_jsx(Box, { "aria-hidden": true, sx: { lineHeight: 0 }, children: icon })) : null, _jsx(Typography, { component: "span", variant: "subtitle2", sx: { pr: icon ? 0 : 3 }, children: label }), description ? (_jsx(Typography, { component: "span", variant: "body2", color: "text.secondary", children: description })) : null] }));
|
|
38
|
+
if (props.onLockedClick) {
|
|
39
|
+
return (_jsx(ButtonBase, { "aria-label": label, "aria-haspopup": "dialog", autoFocus: autoFocus, onClick: props.onLockedClick, sx: sx, type: "button", children: content }));
|
|
40
|
+
}
|
|
41
|
+
return (_jsxs(Box, { component: "label", sx: {
|
|
42
|
+
...sx,
|
|
43
|
+
cursor: props.disabled ? "default" : "pointer",
|
|
44
|
+
opacity: props.disabled ? 0.6 : 1,
|
|
45
|
+
}, children: [_jsx(Box, { component: "input", type: "radio", name: props.name, "aria-label": label, autoFocus: autoFocus, checked: selected, disabled: props.disabled, onChange: props.onSelect, sx: {
|
|
46
|
+
position: "absolute",
|
|
47
|
+
inset: 0,
|
|
48
|
+
opacity: 0,
|
|
49
|
+
width: "100%",
|
|
50
|
+
height: "100%",
|
|
51
|
+
m: 0,
|
|
52
|
+
cursor: "inherit",
|
|
53
|
+
} }), content] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Box, Dialog, DialogContent, DialogTitle, Stack, Typography, } from "@mui/material";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { DialogActionButtons, DialogCloseButton, } from "../actions/DialogActionButtons.js";
|
|
6
|
+
import { DialogChoiceTile } from "../internal/DialogChoiceTile.js";
|
|
7
|
+
export function PlanUpgradeDialog({ title, message, plans, selectedPlanId, confirmLabel, closeLabel = "Close upgrade dialog", onSelectPlan, onViewPlan, onClose, }) {
|
|
8
|
+
const titleId = useId();
|
|
9
|
+
const messageId = useId();
|
|
10
|
+
const radioName = useId();
|
|
11
|
+
return (_jsxs(Dialog, { open: true, fullWidth: true, maxWidth: "sm", onClose: onClose, "aria-labelledby": titleId, "aria-describedby": messageId, children: [_jsxs(DialogTitle, { id: titleId, sx: { pr: 7 }, children: [title, _jsx(DialogCloseButton, { label: closeLabel, onClose: onClose })] }), _jsx(DialogContent, { children: _jsxs(Stack, { spacing: 2, children: [_jsx(Typography, { id: messageId, variant: "body2", color: "text.secondary", children: message }), _jsx(Box, { role: "radiogroup", "aria-label": "Upgrade plan", sx: {
|
|
12
|
+
display: "grid",
|
|
13
|
+
gridTemplateColumns: {
|
|
14
|
+
xs: "1fr",
|
|
15
|
+
sm: "repeat(2, minmax(0, 1fr))",
|
|
16
|
+
},
|
|
17
|
+
gap: 1,
|
|
18
|
+
}, children: plans.map((plan) => (_jsx(DialogChoiceTile, { name: radioName, label: plan.name, description: plan.details.map((detail) => (_jsx(Box, { component: "span", sx: { display: "block" }, children: detail }, detail))), selected: selectedPlanId === plan.id, autoFocus: selectedPlanId === plan.id, onSelect: () => onSelectPlan(plan.id) }, plan.id))) })] }) }), _jsx(DialogActionButtons, { confirmLabel: confirmLabel, confirmText: confirmLabel, onConfirm: () => onViewPlan(selectedPlanId) })] }));
|
|
19
|
+
}
|
|
@@ -69,64 +69,68 @@ function AttachmentViewerContent({ attachment, previewKind, loadFile, }) {
|
|
|
69
69
|
return (_jsx(LoadableAttachmentPreview, { attachment: attachment, previewKind: previewKind, loadFile: loadFile }));
|
|
70
70
|
}
|
|
71
71
|
function LoadableAttachmentPreview({ attachment, previewKind, loadFile, }) {
|
|
72
|
-
const [
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
72
|
+
const [attempt, setAttempt] = useState();
|
|
73
|
+
// A replacement loader starts a fresh attempt even for the same attachment.
|
|
74
|
+
const preview = (attempt === null || attempt === void 0 ? void 0 : attempt.attachment) === attachment && attempt.loadFile === loadFile
|
|
75
|
+
? attempt.result
|
|
76
|
+
: undefined;
|
|
77
|
+
const previewUrl = (preview === null || preview === void 0 ? void 0 : preview.kind) === "url" ? preview.value : undefined;
|
|
76
78
|
function handleMediaDecodeError() {
|
|
77
79
|
console.error("[FileViewer] Browser could not decode the file preview.", {
|
|
78
80
|
contentType: attachment.contentType,
|
|
79
81
|
fileId: attachment.id,
|
|
80
82
|
previewKind,
|
|
81
83
|
});
|
|
82
|
-
|
|
84
|
+
setAttempt({ attachment, loadFile, result: { kind: "error" } });
|
|
83
85
|
}
|
|
84
86
|
useEffect(() => {
|
|
85
87
|
let objectUrl = null;
|
|
86
|
-
let cancelled = false;
|
|
87
88
|
const controller = new AbortController();
|
|
89
|
+
const { signal } = controller;
|
|
90
|
+
const publish = (result) => {
|
|
91
|
+
if (!signal.aborted)
|
|
92
|
+
setAttempt({ attachment, loadFile, result });
|
|
93
|
+
};
|
|
88
94
|
void (async () => {
|
|
89
95
|
try {
|
|
90
96
|
const blob = attachment.blobUrl.startsWith("blob:")
|
|
91
|
-
? await fetch(attachment.blobUrl).then((response) =>
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
? await fetch(attachment.blobUrl, { signal }).then((response) => {
|
|
98
|
+
if (!response.ok)
|
|
99
|
+
throw new Error("Local attachment blob is unavailable.");
|
|
100
|
+
return response.blob();
|
|
101
|
+
})
|
|
102
|
+
: await loadFile(attachment, signal);
|
|
103
|
+
if (signal.aborted)
|
|
94
104
|
return;
|
|
95
105
|
if (previewKind === "text") {
|
|
96
106
|
const content = await blob.text();
|
|
97
|
-
|
|
98
|
-
setText(content);
|
|
107
|
+
publish({ kind: "text", value: content });
|
|
99
108
|
return;
|
|
100
109
|
}
|
|
101
110
|
objectUrl = attachment.blobUrl.startsWith("blob:")
|
|
102
111
|
? attachment.blobUrl
|
|
103
112
|
: URL.createObjectURL(new Blob([blob], { type: attachment.contentType }));
|
|
104
|
-
|
|
113
|
+
publish({ kind: "url", value: objectUrl });
|
|
105
114
|
}
|
|
106
115
|
catch (caughtError) {
|
|
107
|
-
if (!
|
|
116
|
+
if (!signal.aborted) {
|
|
108
117
|
console.error("[FileViewer] Unable to load the file preview.", {
|
|
109
118
|
contentType: attachment.contentType,
|
|
110
119
|
error: caughtError,
|
|
111
120
|
fileId: attachment.id,
|
|
112
121
|
});
|
|
113
|
-
|
|
122
|
+
publish({ kind: "error" });
|
|
114
123
|
}
|
|
115
124
|
}
|
|
116
|
-
finally {
|
|
117
|
-
if (!cancelled)
|
|
118
|
-
setLoading(false);
|
|
119
|
-
}
|
|
120
125
|
})();
|
|
121
126
|
return () => {
|
|
122
|
-
cancelled = true;
|
|
123
127
|
controller.abort();
|
|
124
128
|
if (objectUrl && !attachment.blobUrl.startsWith("blob:")) {
|
|
125
129
|
URL.revokeObjectURL(objectUrl);
|
|
126
130
|
}
|
|
127
131
|
};
|
|
128
132
|
}, [attachment, previewKind, loadFile]);
|
|
129
|
-
return (_jsx(_Fragment, { children:
|
|
133
|
+
return (_jsx(_Fragment, { children: !preview ? (_jsx(Box, { sx: { display: "grid", minHeight: 200, placeItems: "center" }, children: _jsx(CircularProgress, { "aria-label": "Loading attachment preview" }) })) : preview.kind === "error" ? (_jsx(Typography, { color: "error", role: "alert", children: "Unable to display this file. You can download it instead." })) : previewKind === "image" ? (_jsx(Box, { alt: attachment.fileName, component: "img", onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: {
|
|
130
134
|
display: "block",
|
|
131
135
|
maxHeight: "65vh",
|
|
132
136
|
maxWidth: "100%",
|
|
@@ -141,5 +145,5 @@ function LoadableAttachmentPreview({ attachment, previewKind, loadFile, }) {
|
|
|
141
145
|
m: 0,
|
|
142
146
|
overflow: "auto",
|
|
143
147
|
whiteSpace: "pre-wrap",
|
|
144
|
-
}, children: text })) : previewKind === "audio" ? (_jsx(Box, { component: "audio", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { width: "100%" } })) : (_jsx(Box, { component: "video", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { maxHeight: "65vh", maxWidth: "100%", width: "100%" } })) }));
|
|
148
|
+
}, children: preview.kind === "text" ? preview.value : undefined })) : previewKind === "audio" ? (_jsx(Box, { component: "audio", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { width: "100%" } })) : (_jsx(Box, { component: "video", controls: true, onError: handleMediaDecodeError, src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, sx: { maxHeight: "65vh", maxWidth: "100%", width: "100%" } })) }));
|
|
145
149
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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, Stack, Typography } from "@mui/material";
|
|
5
|
+
/** Read-only image facts. The host supplies data and any map action. */
|
|
6
|
+
export function ImageInfoPanel({ id, dimensions, captureTime, captureOffset, camera, location, loading, failed, onClose, sx = [], }) {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_jsxs(Box, { component: "section", id: id, "aria-labelledby": `${id}-title`, sx: [{
|
|
9
|
+
minHeight: 0,
|
|
10
|
+
minWidth: 0,
|
|
11
|
+
overflow: "auto",
|
|
12
|
+
bgcolor: "background.paper",
|
|
13
|
+
borderColor: "divider",
|
|
14
|
+
borderTop: { xs: 1, sm: 0 },
|
|
15
|
+
borderLeft: { xs: 0, sm: 1 },
|
|
16
|
+
borderTopLeftRadius: { xs: 3, sm: 0 },
|
|
17
|
+
borderTopRightRadius: { xs: 3, sm: 0 },
|
|
18
|
+
px: { xs: 2, sm: 3 },
|
|
19
|
+
pt: 1.5,
|
|
20
|
+
pb: "max(16px, env(safe-area-inset-bottom))",
|
|
21
|
+
}, ...(Array.isArray(sx) ? sx : [sx])], children: [_jsxs(Stack, { direction: "row", sx: { alignItems: "center", justifyContent: "space-between" }, children: [_jsx(Typography, { id: `${id}-title`, component: "h2", variant: "h6", sx: { fontWeight: 700 }, children: "Image info" }), _jsx(IconButton, { "aria-label": "Close image info", onClick: onClose, children: _jsx(CloseRoundedIcon, {}) })] }), _jsxs(Box, { component: "dl", sx: {
|
|
22
|
+
m: 0,
|
|
23
|
+
"& > :not(:last-child)": { borderBottom: 1, borderColor: "divider" },
|
|
24
|
+
}, children: [dimensions && (_jsxs(InfoRow, { label: "Dimensions", children: [dimensions.width, " \u00D7 ", dimensions.height, " px"] })), captureTime && (_jsx(InfoRow, { label: "Date taken", detail: captureOffset, children: captureTime })), camera && _jsx(InfoRow, { label: "Camera", children: camera }), location && (_jsx(InfoRow, { label: "Location", action: location.action, detail: location.approximateName ? location.coordinates : undefined, children: (_a = location.approximateName) !== null && _a !== void 0 ? _a : location.coordinates }))] }), loading || failed ? (_jsx(Typography, { role: "status", variant: "body2", color: "text.secondary", sx: { py: 1 }, children: loading
|
|
25
|
+
? "Reading image metadata…"
|
|
26
|
+
: "Could not read image metadata." })) : null, !loading &&
|
|
27
|
+
!failed &&
|
|
28
|
+
!dimensions &&
|
|
29
|
+
!captureTime &&
|
|
30
|
+
!camera &&
|
|
31
|
+
!location ? (_jsx(Typography, { role: "status", variant: "body2", color: "text.secondary", sx: { py: 1 }, children: "No image details available." })) : null] }));
|
|
32
|
+
}
|
|
33
|
+
function InfoRow({ label, children, action, detail, }) {
|
|
34
|
+
return (_jsxs(Box, { sx: { py: { xs: 1.25, sm: 1.5 }, minWidth: 0 }, children: [_jsx(Typography, { component: "dt", variant: "body2", color: "text.secondary", children: label }), _jsxs(Stack, { component: "dd", direction: "row", spacing: 1, sx: { m: 0, alignItems: "center", justifyContent: "space-between" }, children: [_jsxs(Typography, { component: "span", sx: { fontWeight: 650, overflowWrap: "anywhere", minWidth: 0 }, children: [children, detail && (_jsx(Typography, { component: "span", sx: { display: "block" }, color: "text.secondary", variant: "body2", children: detail }))] }), action] })] }));
|
|
35
|
+
}
|