@bayonai/mui-design 1.8.0 → 1.10.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 +10 -0
- package/README.md +26 -0
- package/package.json +1 -1
- package/dist/cjs/actions/ActionMenu.d.ts +0 -24
- package/dist/cjs/actions/ActionMenu.js +0 -36
- package/dist/cjs/actions/DialogActionButtons.d.ts +0 -23
- package/dist/cjs/actions/DialogActionButtons.js +0 -33
- package/dist/cjs/actions/LoadingIconButton.d.ts +0 -11
- package/dist/cjs/actions/LoadingIconButton.js +0 -10
- package/dist/cjs/actions/StickyActionFooter.d.ts +0 -14
- package/dist/cjs/actions/StickyActionFooter.js +0 -27
- package/dist/cjs/actions/StickySubmitButton.d.ts +0 -10
- package/dist/cjs/actions/StickySubmitButton.js +0 -10
- package/dist/cjs/actions/index.d.ts +0 -5
- package/dist/cjs/actions/index.js +0 -18
- package/dist/cjs/client.d.ts +0 -4
- package/dist/cjs/client.js +0 -21
- package/dist/cjs/components/BayonFlowVisual.d.ts +0 -12
- package/dist/cjs/components/BayonFlowVisual.js +0 -87
- package/dist/cjs/components/BayonThemeModeToggle.d.ts +0 -6
- package/dist/cjs/components/BayonThemeModeToggle.js +0 -34
- package/dist/cjs/components/IconTooltipButton.d.ts +0 -10
- package/dist/cjs/components/IconTooltipButton.js +0 -50
- package/dist/cjs/components/panels.d.ts +0 -37
- package/dist/cjs/components/panels.js +0 -92
- package/dist/cjs/drawers/BottomDrawer.d.ts +0 -16
- package/dist/cjs/drawers/BottomDrawer.js +0 -43
- package/dist/cjs/drawers/MobileBottomDrawer.d.ts +0 -20
- package/dist/cjs/drawers/MobileBottomDrawer.js +0 -102
- package/dist/cjs/drawers/MobileBottomDrawerHeader.d.ts +0 -11
- package/dist/cjs/drawers/MobileBottomDrawerHeader.js +0 -36
- package/dist/cjs/drawers/ResponsiveDrawer.d.ts +0 -25
- package/dist/cjs/drawers/ResponsiveDrawer.js +0 -22
- package/dist/cjs/drawers/WorkspaceSidePane.d.ts +0 -25
- package/dist/cjs/drawers/WorkspaceSidePane.js +0 -206
- package/dist/cjs/drawers/WorkspaceSidePaneRoot.d.ts +0 -1
- package/dist/cjs/drawers/WorkspaceSidePaneRoot.js +0 -93
- package/dist/cjs/drawers/drawerAppearance.d.ts +0 -8
- package/dist/cjs/drawers/drawerAppearance.js +0 -10
- package/dist/cjs/drawers/index.d.ts +0 -7
- package/dist/cjs/drawers/index.js +0 -19
- package/dist/cjs/drawers/useVisualViewportBottomInset.d.ts +0 -6
- package/dist/cjs/drawers/useVisualViewportBottomInset.js +0 -33
- package/dist/cjs/drawers/workspaceSidePaneGeometry.d.ts +0 -11
- package/dist/cjs/drawers/workspaceSidePaneGeometry.js +0 -15
- package/dist/cjs/feedback/StatusNotice.d.ts +0 -13
- package/dist/cjs/feedback/StatusNotice.js +0 -62
- package/dist/cjs/feedback/index.d.ts +0 -1
- package/dist/cjs/feedback/index.js +0 -7
- package/dist/cjs/index.d.ts +0 -9
- package/dist/cjs/index.js +0 -25
- package/dist/cjs/internal/DialogChoiceTile.d.ts +0 -20
- package/dist/cjs/internal/DialogChoiceTile.js +0 -60
- package/dist/cjs/links/LinkAddressPreview.d.ts +0 -19
- package/dist/cjs/links/LinkAddressPreview.js +0 -80
- package/dist/cjs/links/index.d.ts +0 -3
- package/dist/cjs/links/index.js +0 -9
- package/dist/cjs/links/useLinkAddressPreview.d.ts +0 -26
- package/dist/cjs/links/useLinkAddressPreview.js +0 -162
- package/dist/cjs/location/GeographicLocationField.d.ts +0 -26
- package/dist/cjs/location/GeographicLocationField.js +0 -49
- package/dist/cjs/location/GoogleMapsAttribution.d.ts +0 -1
- package/dist/cjs/location/GoogleMapsAttribution.js +0 -12
- package/dist/cjs/location/MetadataFieldGroup.d.ts +0 -5
- package/dist/cjs/location/MetadataFieldGroup.js +0 -13
- package/dist/cjs/location/MetadataValueField.d.ts +0 -23
- package/dist/cjs/location/MetadataValueField.js +0 -27
- package/dist/cjs/location/SearchInputAction.d.ts +0 -9
- package/dist/cjs/location/SearchInputAction.js +0 -14
- package/dist/cjs/location/TemplateBadge.d.ts +0 -5
- package/dist/cjs/location/TemplateBadge.js +0 -9
- package/dist/cjs/location/VenueSearchDialog.d.ts +0 -33
- package/dist/cjs/location/VenueSearchDialog.js +0 -112
- package/dist/cjs/location/index.d.ts +0 -6
- package/dist/cjs/location/index.js +0 -20
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/pending/PendingChangesDialogShell.d.ts +0 -2
- package/dist/cjs/pending/PendingChangesDialogShell.js +0 -16
- package/dist/cjs/pending/PendingChangesDialogView.d.ts +0 -2
- package/dist/cjs/pending/PendingChangesDialogView.js +0 -140
- package/dist/cjs/pending/PendingChangesIndicatorView.d.ts +0 -10
- package/dist/cjs/pending/PendingChangesIndicatorView.js +0 -27
- package/dist/cjs/pending/index.d.ts +0 -3
- package/dist/cjs/pending/index.js +0 -9
- package/dist/cjs/pending/types.d.ts +0 -55
- package/dist/cjs/pending/types.js +0 -2
- package/dist/cjs/pricing/PlanUpgradeDialog.d.ts +0 -17
- package/dist/cjs/pricing/PlanUpgradeDialog.js +0 -22
- package/dist/cjs/pricing/PricingTable.d.ts +0 -28
- package/dist/cjs/pricing/PricingTable.js +0 -60
- package/dist/cjs/pricing/index.d.ts +0 -3
- package/dist/cjs/pricing/index.js +0 -8
- package/dist/cjs/providers/BayonThemeProvider.d.ts +0 -20
- package/dist/cjs/providers/BayonThemeProvider.js +0 -163
- package/dist/cjs/sections/ExpandableSectionToggle.d.ts +0 -12
- package/dist/cjs/sections/ExpandableSectionToggle.js +0 -32
- package/dist/cjs/sections/index.d.ts +0 -2
- package/dist/cjs/sections/index.js +0 -7
- package/dist/cjs/styles/pageStyles.d.ts +0 -15
- package/dist/cjs/styles/pageStyles.js +0 -103
- package/dist/cjs/swipe/SwipeActionRow.d.ts +0 -8
- package/dist/cjs/swipe/SwipeActionRow.js +0 -123
- package/dist/cjs/swipe/index.d.ts +0 -1
- package/dist/cjs/swipe/index.js +0 -8
- package/dist/cjs/theme/components.d.ts +0 -2
- package/dist/cjs/theme/components.js +0 -123
- package/dist/cjs/theme/createBayonTheme.d.ts +0 -4
- package/dist/cjs/theme/createBayonTheme.js +0 -45
- package/dist/cjs/theme/palette.d.ts +0 -146
- package/dist/cjs/theme/palette.js +0 -109
- package/dist/cjs/theme/shadows.d.ts +0 -2
- package/dist/cjs/theme/shadows.js +0 -21
- package/dist/cjs/theme/types.d.ts +0 -47
- package/dist/cjs/theme/types.js +0 -2
- package/dist/cjs/theme/typography.d.ts +0 -2
- package/dist/cjs/theme/typography.js +0 -58
- package/dist/cjs/toasts/ActionToast.d.ts +0 -11
- package/dist/cjs/toasts/ActionToast.js +0 -12
- package/dist/cjs/toasts/Toast.d.ts +0 -16
- package/dist/cjs/toasts/Toast.js +0 -55
- package/dist/cjs/toasts/index.d.ts +0 -5
- package/dist/cjs/toasts/index.js +0 -12
- package/dist/cjs/toasts/useUpwardToastDismiss.d.ts +0 -15
- package/dist/cjs/toasts/useUpwardToastDismiss.js +0 -73
- package/dist/cjs/uploads/CameraCaptureDialog.d.ts +0 -22
- package/dist/cjs/uploads/CameraCaptureDialog.js +0 -187
- package/dist/cjs/uploads/FileRow.d.ts +0 -10
- package/dist/cjs/uploads/FileRow.js +0 -23
- package/dist/cjs/uploads/FileSwipeActionRow.d.ts +0 -1
- package/dist/cjs/uploads/FileSwipeActionRow.js +0 -11
- package/dist/cjs/uploads/FileThumbnail.d.ts +0 -5
- package/dist/cjs/uploads/FileThumbnail.js +0 -104
- package/dist/cjs/uploads/FileUpload.d.ts +0 -26
- package/dist/cjs/uploads/FileUpload.js +0 -98
- package/dist/cjs/uploads/FileViewer.d.ts +0 -9
- package/dist/cjs/uploads/FileViewer.js +0 -155
- package/dist/cjs/uploads/ImageCropDialog.d.ts +0 -26
- package/dist/cjs/uploads/ImageCropDialog.js +0 -215
- package/dist/cjs/uploads/ImageInfoPanel.d.ts +0 -24
- package/dist/cjs/uploads/ImageInfoPanel.js +0 -41
- package/dist/cjs/uploads/ImageUploadQualityDialog.d.ts +0 -13
- package/dist/cjs/uploads/ImageUploadQualityDialog.js +0 -57
- package/dist/cjs/uploads/UploadProgressRing.d.ts +0 -24
- package/dist/cjs/uploads/UploadProgressRing.js +0 -32
- package/dist/cjs/uploads/cameraCropPresentation.d.ts +0 -2
- package/dist/cjs/uploads/cameraCropPresentation.js +0 -12
- package/dist/cjs/uploads/index.d.ts +0 -12
- package/dist/cjs/uploads/index.js +0 -24
- package/dist/cjs/utils/createBayonEmotionCache.d.ts +0 -1
- package/dist/cjs/utils/createBayonEmotionCache.js +0 -21
- package/dist/esm/actions/ActionMenu.js +0 -30
- package/dist/esm/actions/DialogActionButtons.js +0 -24
- package/dist/esm/actions/LoadingIconButton.js +0 -7
- package/dist/esm/actions/StickyActionFooter.js +0 -24
- package/dist/esm/actions/StickySubmitButton.js +0 -7
- package/dist/esm/actions/index.js +0 -7
- package/dist/esm/client.js +0 -5
- package/dist/esm/components/BayonFlowVisual.js +0 -81
- package/dist/esm/components/BayonThemeModeToggle.js +0 -28
- package/dist/esm/components/IconTooltipButton.js +0 -11
- package/dist/esm/components/panels.js +0 -76
- package/dist/esm/drawers/BottomDrawer.js +0 -37
- package/dist/esm/drawers/MobileBottomDrawer.js +0 -95
- package/dist/esm/drawers/MobileBottomDrawerHeader.js +0 -30
- package/dist/esm/drawers/ResponsiveDrawer.js +0 -19
- package/dist/esm/drawers/WorkspaceSidePane.js +0 -200
- package/dist/esm/drawers/WorkspaceSidePaneRoot.js +0 -90
- package/dist/esm/drawers/drawerAppearance.js +0 -7
- package/dist/esm/drawers/index.js +0 -8
- package/dist/esm/drawers/useVisualViewportBottomInset.js +0 -29
- package/dist/esm/drawers/workspaceSidePaneGeometry.js +0 -11
- package/dist/esm/feedback/StatusNotice.js +0 -56
- package/dist/esm/feedback/index.js +0 -3
- package/dist/esm/index.js +0 -9
- package/dist/esm/internal/DialogChoiceTile.js +0 -54
- package/dist/esm/links/LinkAddressPreview.js +0 -74
- package/dist/esm/links/index.js +0 -4
- package/dist/esm/links/useLinkAddressPreview.js +0 -159
- package/dist/esm/location/GeographicLocationField.js +0 -43
- package/dist/esm/location/GoogleMapsAttribution.js +0 -9
- package/dist/esm/location/MetadataFieldGroup.js +0 -9
- package/dist/esm/location/MetadataValueField.js +0 -23
- package/dist/esm/location/SearchInputAction.js +0 -8
- package/dist/esm/location/TemplateBadge.js +0 -6
- package/dist/esm/location/VenueSearchDialog.js +0 -109
- package/dist/esm/location/index.js +0 -7
- package/dist/esm/pending/PendingChangesDialogShell.js +0 -10
- package/dist/esm/pending/PendingChangesDialogView.js +0 -134
- package/dist/esm/pending/PendingChangesIndicatorView.js +0 -21
- package/dist/esm/pending/index.js +0 -4
- package/dist/esm/pending/types.js +0 -1
- package/dist/esm/pricing/PlanUpgradeDialog.js +0 -19
- package/dist/esm/pricing/PricingTable.js +0 -54
- package/dist/esm/pricing/index.js +0 -3
- package/dist/esm/providers/BayonThemeProvider.js +0 -123
- package/dist/esm/sections/ExpandableSectionToggle.js +0 -26
- package/dist/esm/sections/index.js +0 -3
- package/dist/esm/styles/pageStyles.js +0 -100
- package/dist/esm/swipe/SwipeActionRow.js +0 -116
- package/dist/esm/swipe/index.js +0 -3
- package/dist/esm/theme/components.js +0 -120
- package/dist/esm/theme/createBayonTheme.js +0 -41
- package/dist/esm/theme/palette.js +0 -106
- package/dist/esm/theme/shadows.js +0 -18
- package/dist/esm/theme/types.js +0 -1
- package/dist/esm/theme/typography.js +0 -55
- package/dist/esm/toasts/ActionToast.js +0 -9
- package/dist/esm/toasts/Toast.js +0 -52
- package/dist/esm/toasts/index.js +0 -5
- package/dist/esm/toasts/useUpwardToastDismiss.js +0 -69
- package/dist/esm/uploads/CameraCaptureDialog.js +0 -181
- package/dist/esm/uploads/FileRow.js +0 -17
- package/dist/esm/uploads/FileSwipeActionRow.js +0 -7
- package/dist/esm/uploads/FileThumbnail.js +0 -98
- package/dist/esm/uploads/FileUpload.js +0 -92
- package/dist/esm/uploads/FileViewer.js +0 -149
- package/dist/esm/uploads/ImageCropDialog.js +0 -212
- package/dist/esm/uploads/ImageInfoPanel.js +0 -35
- package/dist/esm/uploads/ImageUploadQualityDialog.js +0 -51
- package/dist/esm/uploads/UploadProgressRing.js +0 -29
- package/dist/esm/uploads/cameraCropPresentation.js +0 -5
- package/dist/esm/uploads/index.js +0 -11
- package/dist/esm/utils/createBayonEmotionCache.js +0 -15
- package/dist/types/actions/ActionMenu.d.ts +0 -24
- package/dist/types/actions/DialogActionButtons.d.ts +0 -23
- package/dist/types/actions/LoadingIconButton.d.ts +0 -11
- package/dist/types/actions/StickyActionFooter.d.ts +0 -14
- package/dist/types/actions/StickySubmitButton.d.ts +0 -10
- package/dist/types/actions/index.d.ts +0 -5
- package/dist/types/client.d.ts +0 -4
- package/dist/types/components/BayonFlowVisual.d.ts +0 -12
- package/dist/types/components/BayonThemeModeToggle.d.ts +0 -6
- package/dist/types/components/IconTooltipButton.d.ts +0 -10
- package/dist/types/components/panels.d.ts +0 -37
- package/dist/types/drawers/BottomDrawer.d.ts +0 -16
- package/dist/types/drawers/MobileBottomDrawer.d.ts +0 -20
- package/dist/types/drawers/MobileBottomDrawerHeader.d.ts +0 -11
- package/dist/types/drawers/ResponsiveDrawer.d.ts +0 -25
- package/dist/types/drawers/WorkspaceSidePane.d.ts +0 -25
- package/dist/types/drawers/WorkspaceSidePaneRoot.d.ts +0 -1
- package/dist/types/drawers/drawerAppearance.d.ts +0 -8
- package/dist/types/drawers/index.d.ts +0 -7
- package/dist/types/drawers/useVisualViewportBottomInset.d.ts +0 -6
- package/dist/types/drawers/workspaceSidePaneGeometry.d.ts +0 -11
- package/dist/types/feedback/StatusNotice.d.ts +0 -13
- package/dist/types/feedback/index.d.ts +0 -1
- package/dist/types/index.d.ts +0 -9
- package/dist/types/internal/DialogChoiceTile.d.ts +0 -20
- package/dist/types/links/LinkAddressPreview.d.ts +0 -19
- package/dist/types/links/index.d.ts +0 -3
- package/dist/types/links/useLinkAddressPreview.d.ts +0 -26
- package/dist/types/location/GeographicLocationField.d.ts +0 -26
- package/dist/types/location/GoogleMapsAttribution.d.ts +0 -1
- package/dist/types/location/MetadataFieldGroup.d.ts +0 -5
- package/dist/types/location/MetadataValueField.d.ts +0 -23
- package/dist/types/location/SearchInputAction.d.ts +0 -9
- package/dist/types/location/TemplateBadge.d.ts +0 -5
- package/dist/types/location/VenueSearchDialog.d.ts +0 -33
- package/dist/types/location/index.d.ts +0 -6
- package/dist/types/pending/PendingChangesDialogShell.d.ts +0 -2
- package/dist/types/pending/PendingChangesDialogView.d.ts +0 -2
- package/dist/types/pending/PendingChangesIndicatorView.d.ts +0 -10
- package/dist/types/pending/index.d.ts +0 -3
- package/dist/types/pending/types.d.ts +0 -55
- package/dist/types/pricing/PlanUpgradeDialog.d.ts +0 -17
- package/dist/types/pricing/PricingTable.d.ts +0 -28
- package/dist/types/pricing/index.d.ts +0 -3
- package/dist/types/providers/BayonThemeProvider.d.ts +0 -20
- package/dist/types/sections/ExpandableSectionToggle.d.ts +0 -12
- package/dist/types/sections/index.d.ts +0 -2
- package/dist/types/styles/pageStyles.d.ts +0 -15
- package/dist/types/swipe/SwipeActionRow.d.ts +0 -8
- package/dist/types/swipe/index.d.ts +0 -1
- package/dist/types/theme/components.d.ts +0 -2
- package/dist/types/theme/createBayonTheme.d.ts +0 -4
- package/dist/types/theme/palette.d.ts +0 -146
- package/dist/types/theme/shadows.d.ts +0 -2
- package/dist/types/theme/types.d.ts +0 -47
- package/dist/types/theme/typography.d.ts +0 -2
- package/dist/types/toasts/ActionToast.d.ts +0 -11
- package/dist/types/toasts/Toast.d.ts +0 -16
- package/dist/types/toasts/index.d.ts +0 -5
- package/dist/types/toasts/useUpwardToastDismiss.d.ts +0 -15
- package/dist/types/uploads/CameraCaptureDialog.d.ts +0 -22
- package/dist/types/uploads/FileRow.d.ts +0 -10
- package/dist/types/uploads/FileSwipeActionRow.d.ts +0 -1
- package/dist/types/uploads/FileThumbnail.d.ts +0 -5
- package/dist/types/uploads/FileUpload.d.ts +0 -26
- package/dist/types/uploads/FileViewer.d.ts +0 -9
- package/dist/types/uploads/ImageCropDialog.d.ts +0 -26
- package/dist/types/uploads/ImageInfoPanel.d.ts +0 -24
- package/dist/types/uploads/ImageUploadQualityDialog.d.ts +0 -13
- package/dist/types/uploads/UploadProgressRing.d.ts +0 -24
- package/dist/types/uploads/cameraCropPresentation.d.ts +0 -2
- package/dist/types/uploads/index.d.ts +0 -12
- package/dist/types/utils/createBayonEmotionCache.d.ts +0 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import type { UploadFile } from "@bayonai/file-uploads";
|
|
3
|
-
export declare function FileRow<T extends UploadFile>({ attachment, canDelete, onDelete, onPreview, thumbnail, sizeLabel, }: {
|
|
4
|
-
attachment: T;
|
|
5
|
-
canDelete: boolean;
|
|
6
|
-
onDelete: (file: T) => void;
|
|
7
|
-
onPreview: (file: T) => void;
|
|
8
|
-
thumbnail: ReactNode;
|
|
9
|
-
sizeLabel: string;
|
|
10
|
-
}): import("react").JSX.Element;
|
|
@@ -1,23 +0,0 @@
|
|
|
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.FileRow = FileRow;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const DeleteOutlineRounded_1 = __importDefault(require("@mui/icons-material/DeleteOutlineRounded"));
|
|
10
|
-
const material_1 = require("@mui/material");
|
|
11
|
-
const FileSwipeActionRow_js_1 = require("./FileSwipeActionRow.js");
|
|
12
|
-
function FileRow({ attachment, canDelete, onDelete, onPreview, thumbnail, sizeLabel, }) {
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(FileSwipeActionRow_js_1.SwipeActionRow, { canDelete: canDelete, onDelete: () => onDelete(attachment), dataComponent: "attachment-row-swipe-container", children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", sx: { alignItems: "center", gap: 1, minHeight: 56, px: 1.5 }, children: [(0, jsx_runtime_1.jsxs)(material_1.ButtonBase, { "aria-label": `Preview attachment ${attachment.fileName}`, "data-component": "attachment-preview-target", onClick: () => onPreview(attachment), sx: {
|
|
14
|
-
alignItems: "center",
|
|
15
|
-
borderRadius: 1,
|
|
16
|
-
flex: 1,
|
|
17
|
-
gap: 1,
|
|
18
|
-
justifyContent: "flex-start",
|
|
19
|
-
minWidth: 0,
|
|
20
|
-
p: 0.5,
|
|
21
|
-
textAlign: "left",
|
|
22
|
-
}, children: [thumbnail, (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { flex: 1, minWidth: 0 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { noWrap: true, sx: { color: "text.primary", fontSize: 14 }, children: attachment.fileName }), (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.secondary", sx: { fontSize: 12 }, children: sizeLabel })] })] }), canDelete ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": `Delete attachment ${attachment.fileName}`, onClick: () => onDelete(attachment), size: "small", children: (0, jsx_runtime_1.jsx)(DeleteOutlineRounded_1.default, { fontSize: "small" }) })) : null] }) }));
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SwipeActionRow } from "../swipe/SwipeActionRow.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SwipeActionRow = void 0;
|
|
5
|
-
// The shared MUI row preserves the file adapter's error.main/common.white delete
|
|
6
|
-
// surface, background.paper content, spacing(2), Delete label, 160ms easing and
|
|
7
|
-
// reduced-motion behavior. Its gesture contract is the same: 12px direction lock,
|
|
8
|
-
// 72px delete threshold, 104px cap, pan-y, cancellation and click suppression.
|
|
9
|
-
// Keep one gesture implementation and the host's existing MUI theme context.
|
|
10
|
-
var SwipeActionRow_js_1 = require("../swipe/SwipeActionRow.js");
|
|
11
|
-
Object.defineProperty(exports, "SwipeActionRow", { enumerable: true, get: function () { return SwipeActionRow_js_1.SwipeActionRow; } });
|
|
@@ -1,104 +0,0 @@
|
|
|
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.FileThumbnail = FileThumbnail;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const InsertDriveFileRounded_1 = __importDefault(require("@mui/icons-material/InsertDriveFileRounded"));
|
|
10
|
-
const material_1 = require("@mui/material");
|
|
11
|
-
const react_1 = require("react");
|
|
12
|
-
const rasterTypes = new Set([
|
|
13
|
-
"image/jpeg",
|
|
14
|
-
"image/png",
|
|
15
|
-
"image/gif",
|
|
16
|
-
"image/webp",
|
|
17
|
-
]);
|
|
18
|
-
function FileThumbnail({ attachment, loadFile, }) {
|
|
19
|
-
var _a;
|
|
20
|
-
const { blobUrl, contentType, id } = attachment;
|
|
21
|
-
const [preview, setPreview] = (0, react_1.useState)(null);
|
|
22
|
-
const [failedSource, setFailedSource] = (0, react_1.useState)(null);
|
|
23
|
-
const source = `${id}/${blobUrl}`;
|
|
24
|
-
const isRaster = rasterTypes.has(contentType);
|
|
25
|
-
const url = failedSource !== source && isRaster
|
|
26
|
-
? blobUrl.startsWith("blob:")
|
|
27
|
-
? blobUrl
|
|
28
|
-
: (preview === null || preview === void 0 ? void 0 : preview.source) === source
|
|
29
|
-
? preview.url
|
|
30
|
-
: null
|
|
31
|
-
: null;
|
|
32
|
-
const loadingPreview = isRaster &&
|
|
33
|
-
!blobUrl.startsWith("blob:") &&
|
|
34
|
-
failedSource !== source &&
|
|
35
|
-
(preview === null || preview === void 0 ? void 0 : preview.source) !== source;
|
|
36
|
-
(0, react_1.useEffect)(() => {
|
|
37
|
-
if (!rasterTypes.has(contentType) || blobUrl.startsWith("blob:"))
|
|
38
|
-
return;
|
|
39
|
-
const controller = new AbortController();
|
|
40
|
-
let objectUrl;
|
|
41
|
-
// Only raster decoders receive authenticated bytes; never embed documents or SVG.
|
|
42
|
-
// Host loaders may fail before returning a promise; both failures use the fallback.
|
|
43
|
-
void (async () => {
|
|
44
|
-
try {
|
|
45
|
-
const blob = await loadFile(attachment, controller.signal);
|
|
46
|
-
if (controller.signal.aborted)
|
|
47
|
-
return;
|
|
48
|
-
objectUrl = URL.createObjectURL(new Blob([blob], { type: contentType }));
|
|
49
|
-
// A successful current attempt supersedes an earlier failure for this source.
|
|
50
|
-
setFailedSource(null);
|
|
51
|
-
setPreview({ source, url: objectUrl });
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
if (!controller.signal.aborted) {
|
|
55
|
-
console.error("[AttachmentPreview] Unable to load image thumbnail.", {
|
|
56
|
-
attachmentId: id,
|
|
57
|
-
error,
|
|
58
|
-
});
|
|
59
|
-
setFailedSource(source);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
})();
|
|
63
|
-
return () => {
|
|
64
|
-
controller.abort();
|
|
65
|
-
if (objectUrl)
|
|
66
|
-
URL.revokeObjectURL(objectUrl);
|
|
67
|
-
};
|
|
68
|
-
}, [attachment, blobUrl, contentType, id, source, loadFile]);
|
|
69
|
-
return url ? ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "img", src: url, alt: "", onError: () => {
|
|
70
|
-
console.error("[AttachmentPreview] Unable to decode image thumbnail.", {
|
|
71
|
-
attachmentId: id,
|
|
72
|
-
});
|
|
73
|
-
setFailedSource(source);
|
|
74
|
-
}, sx: {
|
|
75
|
-
width: 40,
|
|
76
|
-
height: 40,
|
|
77
|
-
flexShrink: 0,
|
|
78
|
-
objectFit: "cover",
|
|
79
|
-
borderRadius: 1,
|
|
80
|
-
outline: "1px solid",
|
|
81
|
-
outlineColor: (theme) => theme.palette.mode === "dark"
|
|
82
|
-
? "rgba(255,255,255,0.1)"
|
|
83
|
-
: "rgba(0,0,0,0.1)",
|
|
84
|
-
} })) : loadingPreview ? ((0, jsx_runtime_1.jsx)(material_1.Stack, { "aria-label": "Loading attachment preview", sx: {
|
|
85
|
-
alignItems: "center",
|
|
86
|
-
bgcolor: "action.hover",
|
|
87
|
-
borderRadius: 1,
|
|
88
|
-
flexShrink: 0,
|
|
89
|
-
height: 40,
|
|
90
|
-
justifyContent: "center",
|
|
91
|
-
width: 40,
|
|
92
|
-
}, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 18 }) })) : ((0, jsx_runtime_1.jsxs)(material_1.Stack, { "aria-hidden": true, sx: {
|
|
93
|
-
width: 40,
|
|
94
|
-
height: 40,
|
|
95
|
-
flexShrink: 0,
|
|
96
|
-
alignItems: "center",
|
|
97
|
-
justifyContent: "center",
|
|
98
|
-
bgcolor: "action.hover",
|
|
99
|
-
borderRadius: 1,
|
|
100
|
-
color: "text.secondary",
|
|
101
|
-
}, children: [(0, jsx_runtime_1.jsx)(InsertDriveFileRounded_1.default, { sx: { fontSize: 20 } }), (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: { fontSize: 9, fontWeight: 600, maxWidth: 36 }, noWrap: true, children: attachment.fileName.includes(".")
|
|
102
|
-
? (_a = attachment.fileName.split(".").pop()) === null || _a === void 0 ? void 0 : _a.slice(0, 5).toUpperCase()
|
|
103
|
-
: "FILE" })] }));
|
|
104
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type ReactNode, type ComponentType } from "react";
|
|
2
|
-
import type { UploadFile } from "@bayonai/file-uploads";
|
|
3
|
-
export declare function FileUpload<T extends UploadFile>({ attachments, canUpload, onUploadAttachment, label, accept, errorMessage, renderFile, renderViewer, RowShell, FieldIcon, colors, }: {
|
|
4
|
-
attachments: T[];
|
|
5
|
-
canUpload?: boolean;
|
|
6
|
-
onUploadAttachment: (file: File) => Promise<void> | void;
|
|
7
|
-
label: string;
|
|
8
|
-
accept: string;
|
|
9
|
-
errorMessage: (error: unknown) => string | null;
|
|
10
|
-
renderFile: (file: T, onPreview: (file: T) => void) => ReactNode;
|
|
11
|
-
renderViewer: (file: T | null, onClose: () => void) => ReactNode;
|
|
12
|
-
RowShell: ComponentType<{
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
hasBottomBorder?: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
FieldIcon: ComponentType<{
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
ariaLabel?: string;
|
|
19
|
-
onClick?: () => void;
|
|
20
|
-
}>;
|
|
21
|
-
colors: {
|
|
22
|
-
text: string;
|
|
23
|
-
divider: string;
|
|
24
|
-
transition: string;
|
|
25
|
-
};
|
|
26
|
-
}): import("react").JSX.Element | null;
|
|
@@ -1,98 +0,0 @@
|
|
|
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.FileUpload = FileUpload;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const hooks_1 = require("@bayonai/file-uploads/hooks");
|
|
10
|
-
const AddRounded_1 = __importDefault(require("@mui/icons-material/AddRounded"));
|
|
11
|
-
const AttachFileRounded_1 = __importDefault(require("@mui/icons-material/AttachFileRounded"));
|
|
12
|
-
const material_1 = require("@mui/material");
|
|
13
|
-
const react_1 = require("react");
|
|
14
|
-
function FileUpload({ attachments, canUpload = true, onUploadAttachment, label, accept, errorMessage, renderFile, renderViewer, RowShell, FieldIcon, colors, }) {
|
|
15
|
-
const inputRef = (0, react_1.useRef)(null);
|
|
16
|
-
const [previewAttachment, setPreviewAttachment] = (0, react_1.useState)(null);
|
|
17
|
-
const [uploadError, setUploadError] = (0, react_1.useState)(null);
|
|
18
|
-
const { busy: uploading, tryStart, finish } = (0, hooks_1.useUploadLock)();
|
|
19
|
-
const countLabel = attachments.length
|
|
20
|
-
? `${attachments.length} attached file${attachments.length === 1 ? "" : "s"}`
|
|
21
|
-
: canUpload
|
|
22
|
-
? "Add a file"
|
|
23
|
-
: "No files";
|
|
24
|
-
if (!canUpload && attachments.length === 0) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
async function handleFileChange(fileList) {
|
|
28
|
-
if (!canUpload)
|
|
29
|
-
return;
|
|
30
|
-
const file = fileList === null || fileList === void 0 ? void 0 : fileList[0];
|
|
31
|
-
if (!file) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!tryStart())
|
|
35
|
-
return;
|
|
36
|
-
setUploadError(null);
|
|
37
|
-
try {
|
|
38
|
-
await onUploadAttachment(file);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
console.error("[AttachmentSection] Attachment upload failed.", {
|
|
42
|
-
error,
|
|
43
|
-
fileName: file.name,
|
|
44
|
-
});
|
|
45
|
-
setUploadError(errorMessage(error));
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
finish();
|
|
49
|
-
if (inputRef.current) {
|
|
50
|
-
inputRef.current.value = "";
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function openFilePicker() {
|
|
55
|
-
var _a;
|
|
56
|
-
if (!canUpload || uploading)
|
|
57
|
-
return;
|
|
58
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
59
|
-
}
|
|
60
|
-
function handlePreviewAttachment(attachment) {
|
|
61
|
-
setUploadError(null);
|
|
62
|
-
setPreviewAttachment(attachment);
|
|
63
|
-
}
|
|
64
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { position: "relative" }, children: [(0, jsx_runtime_1.jsxs)(RowShell, { hasBottomBorder: attachments.length === 0, children: [(0, jsx_runtime_1.jsx)(FieldIcon, { ariaLabel: `Add a file to ${label}`, onClick: canUpload && !uploading ? openFilePicker : undefined, children: (0, jsx_runtime_1.jsx)(AttachFileRounded_1.default, {}) }), canUpload && uploading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { "aria-label": "Uploading attachment", size: 16, sx: { color: "primary.main" } })) : null, canUpload ? ((0, jsx_runtime_1.jsx)(material_1.ButtonBase, { "aria-label": `Add a file to ${label}`, component: "button", disabled: uploading, onClick: openFilePicker, sx: {
|
|
65
|
-
color: colors.text,
|
|
66
|
-
display: "block",
|
|
67
|
-
flex: 1,
|
|
68
|
-
fontSize: 13,
|
|
69
|
-
minWidth: 0,
|
|
70
|
-
overflow: "hidden",
|
|
71
|
-
textAlign: "left",
|
|
72
|
-
textOverflow: "ellipsis",
|
|
73
|
-
transition: `color ${colors.transition}`,
|
|
74
|
-
whiteSpace: "nowrap",
|
|
75
|
-
"&:hover": { color: "text.primary" },
|
|
76
|
-
"&.Mui-disabled": {
|
|
77
|
-
color: colors.text,
|
|
78
|
-
},
|
|
79
|
-
}, children: uploading ? "Uploading file..." : countLabel })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { noWrap: true, sx: {
|
|
80
|
-
color: colors.text,
|
|
81
|
-
flex: 1,
|
|
82
|
-
fontSize: 13,
|
|
83
|
-
}, children: countLabel })), canUpload ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": `Upload attachment to ${label}`, disabled: uploading, onClick: openFilePicker, size: "small", sx: { color: colors.text }, children: (0, jsx_runtime_1.jsx)(AddRounded_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { accept: accept, component: "input", onChange: (event) => void handleFileChange(event.target.files), ref: inputRef, sx: { display: "none" }, type: "file" })] })) : null] }), canUpload && uploading ? ((0, jsx_runtime_1.jsx)(material_1.LinearProgress, { "aria-label": "Attachment upload progress", "data-component": "attachment-upload-progress", sx: {
|
|
84
|
-
bottom: 0,
|
|
85
|
-
height: 2,
|
|
86
|
-
left: 0,
|
|
87
|
-
position: "absolute",
|
|
88
|
-
right: 0,
|
|
89
|
-
} })) : null] }), attachments.length ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { "aria-hidden": true, sx: {
|
|
90
|
-
borderTop: 1,
|
|
91
|
-
borderColor: colors.divider,
|
|
92
|
-
mx: "10%",
|
|
93
|
-
} }), (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: {
|
|
94
|
-
borderBottom: 1,
|
|
95
|
-
borderColor: colors.divider,
|
|
96
|
-
py: 0.5,
|
|
97
|
-
}, children: attachments.map((attachment) => ((0, jsx_runtime_1.jsx)(material_1.Box, { children: renderFile(attachment, handlePreviewAttachment) }, attachment.id))) })] })) : null, uploadError ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", sx: { fontSize: 12, px: 1.5, py: 0.75 }, children: uploadError })) : null, renderViewer(previewAttachment, () => setPreviewAttachment(null))] }));
|
|
98
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LoadFile, UploadFile } from "@bayonai/file-uploads";
|
|
2
|
-
type FileViewerProps<T extends UploadFile> = {
|
|
3
|
-
attachment: T | null;
|
|
4
|
-
onClose: () => void;
|
|
5
|
-
loadFile: LoadFile<T>;
|
|
6
|
-
onDownload: (file: T) => Promise<void>;
|
|
7
|
-
};
|
|
8
|
-
export declare function FileViewer<T extends UploadFile>(props: FileViewerProps<T>): import("react").JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,155 +0,0 @@
|
|
|
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.FileViewer = FileViewer;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
const CloseRounded_1 = __importDefault(require("@mui/icons-material/CloseRounded"));
|
|
11
|
-
const DownloadRounded_1 = __importDefault(require("@mui/icons-material/DownloadRounded"));
|
|
12
|
-
const material_1 = require("@mui/material");
|
|
13
|
-
const react_2 = require("react");
|
|
14
|
-
const rasterImageTypes = new Set([
|
|
15
|
-
"image/jpeg",
|
|
16
|
-
"image/png",
|
|
17
|
-
"image/gif",
|
|
18
|
-
"image/webp",
|
|
19
|
-
]);
|
|
20
|
-
function getPreviewKind(contentType) {
|
|
21
|
-
if (rasterImageTypes.has(contentType))
|
|
22
|
-
return "image";
|
|
23
|
-
if (contentType === "application/pdf")
|
|
24
|
-
return "pdf";
|
|
25
|
-
if (contentType.startsWith("text/") || contentType === "application/json") {
|
|
26
|
-
return "text";
|
|
27
|
-
}
|
|
28
|
-
if (contentType.startsWith("audio/"))
|
|
29
|
-
return "audio";
|
|
30
|
-
if (contentType.startsWith("video/"))
|
|
31
|
-
return "video";
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
function FileViewer(props) {
|
|
35
|
-
const { attachment } = props;
|
|
36
|
-
const fileKey = attachment
|
|
37
|
-
? `${attachment.id}/${attachment.blobUrl}`
|
|
38
|
-
: "closed";
|
|
39
|
-
// Product decision: file-specific loading and error state belongs to the
|
|
40
|
-
// viewer. Consumers may replace the selected file without coordinating a
|
|
41
|
-
// React key or clearing state from the previous selection.
|
|
42
|
-
return (0, react_1.createElement)(FileViewerState, { ...props, key: fileKey });
|
|
43
|
-
}
|
|
44
|
-
function FileViewerState({ attachment, onClose, loadFile, onDownload, }) {
|
|
45
|
-
const [downloadError, setDownloadError] = (0, react_2.useState)(null);
|
|
46
|
-
const [downloading, setDownloading] = (0, react_2.useState)(false);
|
|
47
|
-
async function download() {
|
|
48
|
-
if (!attachment || downloading)
|
|
49
|
-
return;
|
|
50
|
-
setDownloading(true);
|
|
51
|
-
setDownloadError(null);
|
|
52
|
-
try {
|
|
53
|
-
await onDownload(attachment);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
console.error("[FileViewer] Download failed.", {
|
|
57
|
-
fileId: attachment.id,
|
|
58
|
-
error,
|
|
59
|
-
});
|
|
60
|
-
setDownloadError("Could not download this file. Check your connection and try downloading again.");
|
|
61
|
-
}
|
|
62
|
-
finally {
|
|
63
|
-
setDownloading(false);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const previewKind = attachment
|
|
67
|
-
? getPreviewKind(attachment.contentType)
|
|
68
|
-
: null;
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { fullWidth: true, maxWidth: "md", onClose: onClose, open: Boolean(attachment), children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { sx: { pr: 6 }, children: [attachment === null || attachment === void 0 ? void 0 : attachment.fileName, (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": "Close attachment preview", onClick: onClose, sx: { position: "absolute", right: 8, top: 8 }, children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, {}) })] }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { dividers: true, sx: { minHeight: 240 }, 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: { px: 3 }, children: downloadError })) : null, (0, jsx_runtime_1.jsx)(material_1.DialogActions, { children: attachment ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": "Download attachment", disabled: downloading, onClick: () => void download(), children: (0, jsx_runtime_1.jsx)(DownloadRounded_1.default, {}) })) : null })] }));
|
|
70
|
-
}
|
|
71
|
-
function AttachmentViewerContent({ attachment, previewKind, loadFile, }) {
|
|
72
|
-
if (!previewKind) {
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.secondary", children: "This file type can\u2019t be displayed here. Download it to open it in a compatible app." }));
|
|
74
|
-
}
|
|
75
|
-
return ((0, jsx_runtime_1.jsx)(LoadableAttachmentPreview, { attachment: attachment, previewKind: previewKind, loadFile: loadFile }));
|
|
76
|
-
}
|
|
77
|
-
function LoadableAttachmentPreview({ attachment, previewKind, loadFile, }) {
|
|
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;
|
|
84
|
-
function handleMediaDecodeError() {
|
|
85
|
-
console.error("[FileViewer] Browser could not decode the file preview.", {
|
|
86
|
-
contentType: attachment.contentType,
|
|
87
|
-
fileId: attachment.id,
|
|
88
|
-
previewKind,
|
|
89
|
-
});
|
|
90
|
-
setAttempt({ attachment, loadFile, result: { kind: "error" } });
|
|
91
|
-
}
|
|
92
|
-
(0, react_2.useEffect)(() => {
|
|
93
|
-
let objectUrl = null;
|
|
94
|
-
const controller = new AbortController();
|
|
95
|
-
const { signal } = controller;
|
|
96
|
-
const publish = (result) => {
|
|
97
|
-
if (!signal.aborted)
|
|
98
|
-
setAttempt({ attachment, loadFile, result });
|
|
99
|
-
};
|
|
100
|
-
void (async () => {
|
|
101
|
-
try {
|
|
102
|
-
const blob = attachment.blobUrl.startsWith("blob:")
|
|
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)
|
|
110
|
-
return;
|
|
111
|
-
if (previewKind === "text") {
|
|
112
|
-
const content = await blob.text();
|
|
113
|
-
publish({ kind: "text", value: content });
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
objectUrl = attachment.blobUrl.startsWith("blob:")
|
|
117
|
-
? attachment.blobUrl
|
|
118
|
-
: URL.createObjectURL(new Blob([blob], { type: attachment.contentType }));
|
|
119
|
-
publish({ kind: "url", value: objectUrl });
|
|
120
|
-
}
|
|
121
|
-
catch (caughtError) {
|
|
122
|
-
if (!signal.aborted) {
|
|
123
|
-
console.error("[FileViewer] Unable to load the file preview.", {
|
|
124
|
-
contentType: attachment.contentType,
|
|
125
|
-
error: caughtError,
|
|
126
|
-
fileId: attachment.id,
|
|
127
|
-
});
|
|
128
|
-
publish({ kind: "error" });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
})();
|
|
132
|
-
return () => {
|
|
133
|
-
controller.abort();
|
|
134
|
-
if (objectUrl && !attachment.blobUrl.startsWith("blob:")) {
|
|
135
|
-
URL.revokeObjectURL(objectUrl);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}, [attachment, previewKind, loadFile]);
|
|
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: {
|
|
140
|
-
display: "block",
|
|
141
|
-
maxHeight: "65vh",
|
|
142
|
-
maxWidth: "100%",
|
|
143
|
-
mx: "auto",
|
|
144
|
-
} })) : previewKind === "pdf" ? ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "iframe", referrerPolicy: "no-referrer",
|
|
145
|
-
// Product decision: PDFs are collaborator-controlled active-format
|
|
146
|
-
// documents. Keep their browsing context opaque and block scripts,
|
|
147
|
-
// forms, popups and top-level navigation while retaining preview.
|
|
148
|
-
sandbox: "", src: previewUrl !== null && previewUrl !== void 0 ? previewUrl : undefined, title: "Attachment preview", sx: { border: 0, height: "65vh", width: "100%" } })) : previewKind === "text" ? ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "pre", sx: {
|
|
149
|
-
fontFamily: "monospace",
|
|
150
|
-
fontSize: 13,
|
|
151
|
-
m: 0,
|
|
152
|
-
overflow: "auto",
|
|
153
|
-
whiteSpace: "pre-wrap",
|
|
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%" } })) }));
|
|
155
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|