@bayonai/mui-design 1.6.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.0 — 2026-11-20
4
+
5
+ - Add a controlled image quality dialog with a local preview and quality tiles.
6
+ - Add a host-configured plan upgrade dialog with selectable plan cards.
7
+ - Let dialog consumers opt into a labeled primary button.
8
+
3
9
  ## 1.6.0 — 2026-11-20
4
10
 
5
11
  - Add the read-only `ImageInfoPanel` to `@bayonai/mui-design/uploads`.
@@ -3,6 +3,7 @@ import type { ReactNode } from "react";
3
3
  export declare const compactDialogPaperSx: SxProps<Theme>;
4
4
  export type DialogActionButtonsProps = {
5
5
  confirmLabel: string;
6
+ confirmText?: string;
6
7
  confirmDisabled?: boolean;
7
8
  confirmColor?: "error" | "primary" | "secondary" | "success" | "warning";
8
9
  confirmIcon?: ReactNode;
@@ -11,7 +12,7 @@ export type DialogActionButtonsProps = {
11
12
  sx?: SxProps<Theme>;
12
13
  };
13
14
  /** Keeps the modal's primary decision compact and explicitly labelled. */
14
- export declare function DialogActionButtons({ confirmColor, confirmDisabled, confirmIcon, confirmLabel, confirmType, onConfirm, sx, }: DialogActionButtonsProps): import("react").JSX.Element;
15
+ export declare function DialogActionButtons({ confirmColor, confirmDisabled, confirmIcon, confirmLabel, confirmText, confirmType, onConfirm, sx, }: DialogActionButtonsProps): import("react").JSX.Element;
15
16
  export declare function DialogActionProgress(): import("react").JSX.Element;
16
17
  export type DialogCloseButtonProps = {
17
18
  disabled?: boolean;
@@ -21,8 +21,8 @@ exports.compactDialogPaperSx = {
21
21
  overflowWrap: "anywhere",
22
22
  };
23
23
  /** Keeps the modal's primary decision compact and explicitly labelled. */
24
- function DialogActionButtons({ confirmColor = "success", confirmDisabled = false, confirmIcon, confirmLabel, confirmType = "button", onConfirm, sx, }) {
25
- return ((0, jsx_runtime_1.jsx)(material_1.DialogActions, { sx: sx, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 1, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: confirmLabel, children: (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": confirmLabel, color: confirmColor, disabled: confirmDisabled, onClick: confirmType === "submit" ? undefined : onConfirm, type: confirmType, children: confirmIcon !== null && confirmIcon !== void 0 ? confirmIcon : (0, jsx_runtime_1.jsx)(Check_1.default, {}) }) }) }) }) }));
24
+ function DialogActionButtons({ confirmColor = "success", confirmDisabled = false, confirmIcon, confirmLabel, confirmText, confirmType = "button", onConfirm, sx, }) {
25
+ return ((0, jsx_runtime_1.jsx)(material_1.DialogActions, { sx: sx, children: confirmText ? ((0, jsx_runtime_1.jsx)(material_1.Button, { "aria-label": confirmLabel, color: confirmColor, disabled: confirmDisabled, onClick: confirmType === "submit" ? undefined : onConfirm, startIcon: confirmIcon, type: confirmType, variant: "contained", children: confirmText })) : ((0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 1, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: confirmLabel, children: (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": confirmLabel, color: confirmColor, disabled: confirmDisabled, onClick: confirmType === "submit" ? undefined : onConfirm, type: confirmType, children: confirmIcon !== null && confirmIcon !== void 0 ? confirmIcon : (0, jsx_runtime_1.jsx)(Check_1.default, {}) }) }) }) })) }));
26
26
  }
27
27
  function DialogActionProgress() {
28
28
  return (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "inherit", size: 20 });
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from "react";
2
+ type DialogChoiceTileProps = {
3
+ label: string;
4
+ description?: ReactNode;
5
+ icon?: ReactNode;
6
+ selected: boolean;
7
+ autoFocus?: boolean;
8
+ } & ({
9
+ name: string;
10
+ disabled?: boolean;
11
+ onSelect: () => void;
12
+ onLockedClick?: never;
13
+ } | {
14
+ onLockedClick: () => void;
15
+ name?: never;
16
+ disabled?: never;
17
+ onSelect?: never;
18
+ });
19
+ export declare function DialogChoiceTile(props: DialogChoiceTileProps): import("react").JSX.Element;
20
+ export {};
@@ -0,0 +1,60 @@
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.DialogChoiceTile = DialogChoiceTile;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const CheckCircle_1 = __importDefault(require("@mui/icons-material/CheckCircle"));
10
+ const LockOutlined_1 = __importDefault(require("@mui/icons-material/LockOutlined"));
11
+ const material_1 = require("@mui/material");
12
+ function DialogChoiceTile(props) {
13
+ const { label, description, icon, selected, autoFocus } = props;
14
+ const sx = {
15
+ position: "relative",
16
+ display: "flex",
17
+ flexDirection: "column",
18
+ alignItems: icon ? "center" : "flex-start",
19
+ justifyContent: "center",
20
+ textAlign: icon ? "center" : "start",
21
+ gap: 0.5,
22
+ p: 1.5,
23
+ minWidth: 0,
24
+ minHeight: 80,
25
+ border: "1px solid",
26
+ borderColor: selected ? "success.main" : "divider",
27
+ borderRadius: 2,
28
+ backgroundColor: selected ? "action.selected" : "background.paper",
29
+ overflowWrap: "anywhere",
30
+ "&:hover": { backgroundColor: "action.hover" },
31
+ "&:has(input:focus-visible), &.Mui-focusVisible": {
32
+ outline: "2px solid",
33
+ outlineColor: "success.main",
34
+ outlineOffset: 2,
35
+ },
36
+ };
37
+ const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [selected || props.onLockedClick ? ((0, jsx_runtime_1.jsx)(material_1.Box, { "aria-hidden": true, sx: {
38
+ position: "absolute",
39
+ top: 8,
40
+ right: 8,
41
+ color: selected ? "success.main" : "text.secondary",
42
+ lineHeight: 0,
43
+ }, children: selected ? ((0, jsx_runtime_1.jsx)(CheckCircle_1.default, { fontSize: "small" })) : ((0, jsx_runtime_1.jsx)(LockOutlined_1.default, { fontSize: "small" })) })) : null, icon ? ((0, jsx_runtime_1.jsx)(material_1.Box, { "aria-hidden": true, sx: { lineHeight: 0 }, children: icon })) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "span", variant: "subtitle2", sx: { pr: icon ? 0 : 3 }, children: label }), description ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "span", variant: "body2", color: "text.secondary", children: description })) : null] }));
44
+ if (props.onLockedClick) {
45
+ return ((0, jsx_runtime_1.jsx)(material_1.ButtonBase, { "aria-label": label, "aria-haspopup": "dialog", autoFocus: autoFocus, onClick: props.onLockedClick, sx: sx, type: "button", children: content }));
46
+ }
47
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { component: "label", sx: {
48
+ ...sx,
49
+ cursor: props.disabled ? "default" : "pointer",
50
+ opacity: props.disabled ? 0.6 : 1,
51
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: "input", type: "radio", name: props.name, "aria-label": label, autoFocus: autoFocus, checked: selected, disabled: props.disabled, onChange: props.onSelect, sx: {
52
+ position: "absolute",
53
+ inset: 0,
54
+ opacity: 0,
55
+ width: "100%",
56
+ height: "100%",
57
+ m: 0,
58
+ cursor: "inherit",
59
+ } }), content] }));
60
+ }
@@ -0,0 +1,17 @@
1
+ export type UpgradePlan<Id extends string = string> = {
2
+ id: Id;
3
+ name: string;
4
+ details: readonly string[];
5
+ };
6
+ export type PlanUpgradeDialogProps<Id extends string> = {
7
+ title: string;
8
+ message: string;
9
+ plans: readonly UpgradePlan<Id>[];
10
+ selectedPlanId: Id;
11
+ confirmLabel: string;
12
+ closeLabel?: string;
13
+ onSelectPlan: (id: Id) => void;
14
+ onViewPlan: (id: Id) => void;
15
+ onClose: () => void;
16
+ };
17
+ export declare function PlanUpgradeDialog<Id extends string>({ title, message, plans, selectedPlanId, confirmLabel, closeLabel, onSelectPlan, onViewPlan, onClose, }: PlanUpgradeDialogProps<Id>): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ "use client";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PlanUpgradeDialog = PlanUpgradeDialog;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const material_1 = require("@mui/material");
7
+ const react_1 = require("react");
8
+ const DialogActionButtons_js_1 = require("../actions/DialogActionButtons.js");
9
+ const DialogChoiceTile_js_1 = require("../internal/DialogChoiceTile.js");
10
+ function PlanUpgradeDialog({ title, message, plans, selectedPlanId, confirmLabel, closeLabel = "Close upgrade dialog", onSelectPlan, onViewPlan, onClose, }) {
11
+ const titleId = (0, react_1.useId)();
12
+ const messageId = (0, react_1.useId)();
13
+ const radioName = (0, react_1.useId)();
14
+ return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: true, fullWidth: true, maxWidth: "sm", onClose: onClose, "aria-labelledby": titleId, "aria-describedby": messageId, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { id: titleId, sx: { pr: 7 }, children: [title, (0, jsx_runtime_1.jsx)(DialogActionButtons_js_1.DialogCloseButton, { label: closeLabel, onClose: onClose })] }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { id: messageId, variant: "body2", color: "text.secondary", children: message }), (0, jsx_runtime_1.jsx)(material_1.Box, { role: "radiogroup", "aria-label": "Upgrade plan", sx: {
15
+ display: "grid",
16
+ gridTemplateColumns: {
17
+ xs: "1fr",
18
+ sm: "repeat(2, minmax(0, 1fr))",
19
+ },
20
+ gap: 1,
21
+ }, children: plans.map((plan) => ((0, jsx_runtime_1.jsx)(DialogChoiceTile_js_1.DialogChoiceTile, { name: radioName, label: plan.name, description: plan.details.map((detail) => ((0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: { display: "block" }, children: detail }, detail))), selected: selectedPlanId === plan.id, autoFocus: selectedPlanId === plan.id, onSelect: () => onSelectPlan(plan.id) }, plan.id))) })] }) }), (0, jsx_runtime_1.jsx)(DialogActionButtons_js_1.DialogActionButtons, { confirmLabel: confirmLabel, confirmText: confirmLabel, onConfirm: () => onViewPlan(selectedPlanId) })] }));
22
+ }
@@ -1,2 +1,3 @@
1
1
  export { PricingTable } from "./PricingTable.js";
2
2
  export type { PricingTablePlan, PricingTableProps } from "./PricingTable.js";
3
+ export { PlanUpgradeDialog, type PlanUpgradeDialogProps, type UpgradePlan } from "./PlanUpgradeDialog.js";
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  "use client";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PricingTable = void 0;
4
+ exports.PlanUpgradeDialog = exports.PricingTable = void 0;
5
5
  var PricingTable_js_1 = require("./PricingTable.js");
6
6
  Object.defineProperty(exports, "PricingTable", { enumerable: true, get: function () { return PricingTable_js_1.PricingTable; } });
7
+ var PlanUpgradeDialog_js_1 = require("./PlanUpgradeDialog.js");
8
+ Object.defineProperty(exports, "PlanUpgradeDialog", { enumerable: true, get: function () { return PlanUpgradeDialog_js_1.PlanUpgradeDialog; } });
@@ -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
+ }
@@ -9,3 +9,4 @@ export type { UploadFile, LoadFile } from "@bayonai/file-uploads";
9
9
  export type { UploadProgressRingProps } from "./UploadProgressRing.js";
10
10
  export { CameraCaptureDialog, type CameraCaptureDialogProps, type CameraCaptureLabels } from "./CameraCaptureDialog.js";
11
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.ImageInfoPanel = 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");
@@ -20,3 +20,5 @@ var CameraCaptureDialog_js_1 = require("./CameraCaptureDialog.js");
20
20
  Object.defineProperty(exports, "CameraCaptureDialog", { enumerable: true, get: function () { return CameraCaptureDialog_js_1.CameraCaptureDialog; } });
21
21
  var ImageCropDialog_js_1 = require("./ImageCropDialog.js");
22
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; } });
@@ -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
+ }
@@ -1,2 +1,3 @@
1
1
  "use client";
2
2
  export { PricingTable } from "./PricingTable.js";
3
+ export { PlanUpgradeDialog } from "./PlanUpgradeDialog.js";
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import CompressIcon from "@mui/icons-material/Compress";
4
+ import ImageSearchIcon from "@mui/icons-material/ImageSearch";
5
+ import { Box, Dialog, DialogContent, DialogTitle, Stack, Typography, } from "@mui/material";
6
+ import { useEffect, useId, useState } from "react";
7
+ import { DialogActionButtons, DialogCloseButton, } from "../actions/DialogActionButtons.js";
8
+ import { DialogChoiceTile } from "../internal/DialogChoiceTile.js";
9
+ export function ImageUploadQualityDialog({ file, quality, highQualityAccess, focusLockedChoice = false, hint, onQualityChange, onLockedChoice, onClose, onConfirm, }) {
10
+ const titleId = useId();
11
+ const hintId = useId();
12
+ const radioName = useId();
13
+ const [preview, setPreview] = useState();
14
+ const [failedFile, setFailedFile] = useState();
15
+ const previewFailed = failedFile === file;
16
+ const url = (preview === null || preview === void 0 ? void 0 : preview.file) === file && !previewFailed ? preview.url : undefined;
17
+ useEffect(() => {
18
+ if (previewFailed)
19
+ return;
20
+ try {
21
+ const url = URL.createObjectURL(file);
22
+ setPreview({ file, url });
23
+ return () => URL.revokeObjectURL(url);
24
+ }
25
+ catch (error) {
26
+ console.error("[ImageUploadQualityDialog] Could not open a preview for the selected file.", error);
27
+ setFailedFile(file);
28
+ }
29
+ }, [file, previewFailed]);
30
+ const highQualityTile = {
31
+ label: "High quality",
32
+ description: "Original file",
33
+ icon: _jsx(ImageSearchIcon, {}),
34
+ selected: quality === "high",
35
+ };
36
+ return (_jsxs(Dialog, { open: true, onClose: onClose, fullWidth: true, maxWidth: "xs", "aria-labelledby": titleId, children: [_jsxs(DialogTitle, { id: titleId, sx: { pr: 7 }, children: ["Upload image", _jsx(DialogCloseButton, { label: "Cancel image upload", onClose: onClose })] }), _jsx(DialogContent, { children: _jsxs(Stack, { spacing: 1.5, children: [url ? (_jsx(Box, { component: "img", src: url, alt: "Selected image preview", onError: () => {
37
+ console.warn("[ImageUploadQualityDialog] Could not display the selected image preview.", { type: file.type });
38
+ setFailedFile(file);
39
+ }, sx: {
40
+ display: "block",
41
+ width: "100%",
42
+ maxHeight: "min(32dvh, 230px)",
43
+ objectFit: "contain",
44
+ borderRadius: 2,
45
+ } })) : null, _jsx(Typography, { variant: "body2", sx: { overflowWrap: "anywhere" }, children: file.name }), previewFailed ? (_jsx(Typography, { variant: "caption", color: "text.secondary", children: "Preview unavailable." })) : null, _jsxs(Box, { role: highQualityAccess === "locked" ? "group" : "radiogroup", "aria-label": "Image quality", "aria-describedby": hint ? hintId : undefined, sx: {
46
+ display: "grid",
47
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
48
+ "@media (max-width: 350px)": { gridTemplateColumns: "1fr" },
49
+ gap: 1,
50
+ }, children: [_jsx(DialogChoiceTile, { label: "Compressed", description: "Smaller file", icon: _jsx(CompressIcon, {}), name: radioName, selected: quality === "compressed", autoFocus: !focusLockedChoice, onSelect: () => onQualityChange("compressed") }), highQualityAccess === "locked" ? (_jsx(DialogChoiceTile, { ...highQualityTile, autoFocus: focusLockedChoice, onLockedClick: onLockedChoice })) : (_jsx(DialogChoiceTile, { ...highQualityTile, name: radioName, disabled: highQualityAccess === "unavailable", onSelect: () => onQualityChange("high") }))] }), hint ? (_jsx(Typography, { id: hintId, variant: "caption", color: "text.secondary", children: hint })) : null] }) }), _jsx(DialogActionButtons, { confirmLabel: "Upload image", confirmText: "Upload", onConfirm: onConfirm })] }));
51
+ }
@@ -8,3 +8,4 @@ export { UploadProgressRing } from "./UploadProgressRing.js";
8
8
  export { useUploadLock } from "@bayonai/file-uploads/hooks";
9
9
  export { CameraCaptureDialog } from "./CameraCaptureDialog.js";
10
10
  export { ImageCropDialog } from "./ImageCropDialog.js";
11
+ export { ImageUploadQualityDialog } from "./ImageUploadQualityDialog.js";
@@ -3,6 +3,7 @@ import type { ReactNode } from "react";
3
3
  export declare const compactDialogPaperSx: SxProps<Theme>;
4
4
  export type DialogActionButtonsProps = {
5
5
  confirmLabel: string;
6
+ confirmText?: string;
6
7
  confirmDisabled?: boolean;
7
8
  confirmColor?: "error" | "primary" | "secondary" | "success" | "warning";
8
9
  confirmIcon?: ReactNode;
@@ -11,7 +12,7 @@ export type DialogActionButtonsProps = {
11
12
  sx?: SxProps<Theme>;
12
13
  };
13
14
  /** Keeps the modal's primary decision compact and explicitly labelled. */
14
- export declare function DialogActionButtons({ confirmColor, confirmDisabled, confirmIcon, confirmLabel, confirmType, onConfirm, sx, }: DialogActionButtonsProps): import("react").JSX.Element;
15
+ export declare function DialogActionButtons({ confirmColor, confirmDisabled, confirmIcon, confirmLabel, confirmText, confirmType, onConfirm, sx, }: DialogActionButtonsProps): import("react").JSX.Element;
15
16
  export declare function DialogActionProgress(): import("react").JSX.Element;
16
17
  export type DialogCloseButtonProps = {
17
18
  disabled?: boolean;
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from "react";
2
+ type DialogChoiceTileProps = {
3
+ label: string;
4
+ description?: ReactNode;
5
+ icon?: ReactNode;
6
+ selected: boolean;
7
+ autoFocus?: boolean;
8
+ } & ({
9
+ name: string;
10
+ disabled?: boolean;
11
+ onSelect: () => void;
12
+ onLockedClick?: never;
13
+ } | {
14
+ onLockedClick: () => void;
15
+ name?: never;
16
+ disabled?: never;
17
+ onSelect?: never;
18
+ });
19
+ export declare function DialogChoiceTile(props: DialogChoiceTileProps): import("react").JSX.Element;
20
+ export {};
@@ -0,0 +1,17 @@
1
+ export type UpgradePlan<Id extends string = string> = {
2
+ id: Id;
3
+ name: string;
4
+ details: readonly string[];
5
+ };
6
+ export type PlanUpgradeDialogProps<Id extends string> = {
7
+ title: string;
8
+ message: string;
9
+ plans: readonly UpgradePlan<Id>[];
10
+ selectedPlanId: Id;
11
+ confirmLabel: string;
12
+ closeLabel?: string;
13
+ onSelectPlan: (id: Id) => void;
14
+ onViewPlan: (id: Id) => void;
15
+ onClose: () => void;
16
+ };
17
+ export declare function PlanUpgradeDialog<Id extends string>({ title, message, plans, selectedPlanId, confirmLabel, closeLabel, onSelectPlan, onViewPlan, onClose, }: PlanUpgradeDialogProps<Id>): import("react").JSX.Element;
@@ -1,2 +1,3 @@
1
1
  export { PricingTable } from "./PricingTable.js";
2
2
  export type { PricingTablePlan, PricingTableProps } from "./PricingTable.js";
3
+ export { PlanUpgradeDialog, type PlanUpgradeDialogProps, type UpgradePlan } from "./PlanUpgradeDialog.js";
@@ -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;
@@ -9,3 +9,4 @@ export type { UploadFile, LoadFile } from "@bayonai/file-uploads";
9
9
  export type { UploadProgressRingProps } from "./UploadProgressRing.js";
10
10
  export { CameraCaptureDialog, type CameraCaptureDialogProps, type CameraCaptureLabels } from "./CameraCaptureDialog.js";
11
11
  export { ImageCropDialog, type ImageCropDialogProps, type ImageCropLabels } from "./ImageCropDialog.js";
12
+ export { ImageUploadQualityDialog, type ImageUploadQuality, type ImageUploadQualityDialogProps } from "./ImageUploadQualityDialog.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bayonai/mui-design",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Shared Bayon AI Material UI theme, style recipes, and reusable design components.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",