@etsoo/materialui 1.6.73 → 1.6.75

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.
@@ -0,0 +1,30 @@
1
+ import { ButtonProps } from "@mui/material/Button";
2
+ import { DialogProps } from "@mui/material/Dialog";
3
+ import React from "react";
4
+ /**
5
+ * Image preview button props
6
+ */
7
+ export type ImagePreviewButtonProps = {
8
+ /**
9
+ * Button props
10
+ */
11
+ buttonProps?: Omit<ButtonProps, "onClick" | "disabled">;
12
+ /**
13
+ * Dialog props
14
+ */
15
+ dialogProps?: Omit<DialogProps, "open" | "onClose">;
16
+ /**
17
+ * Image
18
+ */
19
+ image?: string;
20
+ /**
21
+ * Size
22
+ */
23
+ size?: number | [number, number];
24
+ };
25
+ /**
26
+ * Image preview button
27
+ * @param props Props
28
+ * @returns Component
29
+ */
30
+ export declare function ImagePreviewButton(props: ImagePreviewButtonProps): React.JSX.Element;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ImagePreviewButton = ImagePreviewButton;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const Avatar_1 = __importDefault(require("@mui/material/Avatar"));
9
+ const Button_1 = __importDefault(require("@mui/material/Button"));
10
+ const Dialog_1 = __importDefault(require("@mui/material/Dialog"));
11
+ const DialogContent_1 = __importDefault(require("@mui/material/DialogContent"));
12
+ const react_1 = __importDefault(require("react"));
13
+ /**
14
+ * Image preview button
15
+ * @param props Props
16
+ * @returns Component
17
+ */
18
+ function ImagePreviewButton(props) {
19
+ // Destruct
20
+ const { buttonProps, dialogProps, image, size = 32 } = props;
21
+ const [open, setOpen] = react_1.default.useState(false);
22
+ const [width, height] = typeof size === "number" ? [size, size] : size;
23
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default, { onClick: () => setOpen(true), variant: "text", disabled: !image, sx: {
24
+ p: 0,
25
+ minWidth: 0
26
+ }, ...buttonProps, children: (0, jsx_runtime_1.jsx)(Avatar_1.default, { src: image, variant: "rounded", sx: { width, height } }) }), (0, jsx_runtime_1.jsx)(Dialog_1.default, { open: open, onClose: () => setOpen(false), maxWidth: "sm", ...dialogProps, children: (0, jsx_runtime_1.jsx)(DialogContent_1.default, { children: image && ((0, jsx_runtime_1.jsx)("img", { src: image, style: { maxWidth: "100%", height: "auto" } })) }) })] }));
27
+ }
@@ -5,7 +5,7 @@ import { INotificationBaseReact, INotificationReact, NotificationReact, Notifier
5
5
  * MU notification data methods
6
6
  */
7
7
  export interface NotificationMUDataMethods {
8
- getValue(): unknown;
8
+ getValue(): unknown | PromiseLike<unknown>;
9
9
  }
10
10
  /**
11
11
  * MU notification data props
@@ -110,7 +110,7 @@ class NotificationMU extends react_2.NotificationReact {
110
110
  return true;
111
111
  };
112
112
  const base = () => primaryButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { ...setupProps, onClick: callback, autoFocus: true, ...primaryButtonProps, children: okLabel }));
113
- return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [icon, (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
113
+ return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [icon, (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
114
114
  }
115
115
  // Create confirm
116
116
  createConfirm(_props, className) {
@@ -124,7 +124,7 @@ class NotificationMU extends react_2.NotificationReact {
124
124
  return true;
125
125
  };
126
126
  const base = () => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [cancelButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { color: "secondary", onClick: async (event) => await callback(event, false), children: cancelLabel })), primaryButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { color: "primary", onClick: async (event) => await callback(event, true), autoFocus: true, ...primaryButtonProps, children: okLabel }))] }));
127
- return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [(0, jsx_runtime_1.jsx)(Help_1.default, { color: "action" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
127
+ return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Help_1.default, { color: "action" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), inputs] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
128
128
  }
129
129
  createMessageColor() {
130
130
  if (this.type === notificationbase_1.NotificationMessageType.Danger)
@@ -168,13 +168,12 @@ class NotificationMU extends react_2.NotificationReact {
168
168
  setError(undefined);
169
169
  if (this.onReturn) {
170
170
  // Get the value
171
- const value = mRef.current?.getValue();
171
+ const value = await mRef.current?.getValue();
172
172
  if (value == null) {
173
173
  return false;
174
174
  }
175
- const result = this.onReturn(value);
175
+ const v = await this.onReturn(value);
176
176
  // returns false to prevent default dismiss
177
- const v = await result;
178
177
  if (v === false) {
179
178
  return false;
180
179
  }
@@ -191,7 +190,7 @@ class NotificationMU extends react_2.NotificationReact {
191
190
  this.onReturn(undefined);
192
191
  this.dismiss();
193
192
  }, children: cancelLabel })), primaryButton && ((0, jsx_runtime_1.jsx)(LoadingButton_1.LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, name: "okButton", ...primaryButtonProps, children: okLabel }))] }));
194
- return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { ...inputProps, children: [content, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
193
+ return ((0, jsx_runtime_1.jsxs)(Dialog_1.default, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent_1.DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { ...inputProps, children: [content, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
195
194
  }
196
195
  // Create prompt
197
196
  createPrompt(_props, className) {
@@ -275,7 +274,7 @@ class NotificationMU extends react_2.NotificationReact {
275
274
  return false;
276
275
  }
277
276
  }
278
- }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { dividers: true, children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), localInputs, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
277
+ }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [(0, jsx_runtime_1.jsxs)(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [(0, jsx_runtime_1.jsx)(Info_1.default, { color: "primary" }), (0, jsx_runtime_1.jsx)("span", { className: "dialogTitle", children: title }), closable && ((0, jsx_runtime_1.jsx)(IconButton_1.default, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }))] }), (0, jsx_runtime_1.jsxs)(DialogContent_1.default, { dividers: true, children: [typeof this.content === "string" ? ((0, jsx_runtime_1.jsx)(DialogContentText_1.default, { children: this.content })) : (this.content), localInputs, (0, jsx_runtime_1.jsx)(Typography_1.default, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), (0, jsx_runtime_1.jsx)(DialogActions_1.default, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
279
278
  }
280
279
  createPopup(_props, className) {
281
280
  // Destruct
@@ -73,6 +73,7 @@ export * from "./GridUtils";
73
73
  export * from "./HiSelector";
74
74
  export * from "./HiSelectorTL";
75
75
  export * from "./IconButtonLink";
76
+ export * from "./ImagePreviewButton";
76
77
  export * from "./InputField";
77
78
  export * from "./InputTipField";
78
79
  export * from "./IntInputField";
package/lib/cjs/index.js CHANGED
@@ -93,6 +93,7 @@ __exportStar(require("./GridUtils"), exports);
93
93
  __exportStar(require("./HiSelector"), exports);
94
94
  __exportStar(require("./HiSelectorTL"), exports);
95
95
  __exportStar(require("./IconButtonLink"), exports);
96
+ __exportStar(require("./ImagePreviewButton"), exports);
96
97
  __exportStar(require("./InputField"), exports);
97
98
  __exportStar(require("./InputTipField"), exports);
98
99
  __exportStar(require("./IntInputField"), exports);
@@ -0,0 +1,30 @@
1
+ import { ButtonProps } from "@mui/material/Button";
2
+ import { DialogProps } from "@mui/material/Dialog";
3
+ import React from "react";
4
+ /**
5
+ * Image preview button props
6
+ */
7
+ export type ImagePreviewButtonProps = {
8
+ /**
9
+ * Button props
10
+ */
11
+ buttonProps?: Omit<ButtonProps, "onClick" | "disabled">;
12
+ /**
13
+ * Dialog props
14
+ */
15
+ dialogProps?: Omit<DialogProps, "open" | "onClose">;
16
+ /**
17
+ * Image
18
+ */
19
+ image?: string;
20
+ /**
21
+ * Size
22
+ */
23
+ size?: number | [number, number];
24
+ };
25
+ /**
26
+ * Image preview button
27
+ * @param props Props
28
+ * @returns Component
29
+ */
30
+ export declare function ImagePreviewButton(props: ImagePreviewButtonProps): React.JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Avatar from "@mui/material/Avatar";
3
+ import Button from "@mui/material/Button";
4
+ import Dialog from "@mui/material/Dialog";
5
+ import DialogContent from "@mui/material/DialogContent";
6
+ import React from "react";
7
+ /**
8
+ * Image preview button
9
+ * @param props Props
10
+ * @returns Component
11
+ */
12
+ export function ImagePreviewButton(props) {
13
+ // Destruct
14
+ const { buttonProps, dialogProps, image, size = 32 } = props;
15
+ const [open, setOpen] = React.useState(false);
16
+ const [width, height] = typeof size === "number" ? [size, size] : size;
17
+ return (_jsxs(React.Fragment, { children: [_jsx(Button, { onClick: () => setOpen(true), variant: "text", disabled: !image, sx: {
18
+ p: 0,
19
+ minWidth: 0
20
+ }, ...buttonProps, children: _jsx(Avatar, { src: image, variant: "rounded", sx: { width, height } }) }), _jsx(Dialog, { open: open, onClose: () => setOpen(false), maxWidth: "sm", ...dialogProps, children: _jsx(DialogContent, { children: image && (_jsx("img", { src: image, style: { maxWidth: "100%", height: "auto" } })) }) })] }));
21
+ }
@@ -5,7 +5,7 @@ import { INotificationBaseReact, INotificationReact, NotificationReact, Notifier
5
5
  * MU notification data methods
6
6
  */
7
7
  export interface NotificationMUDataMethods {
8
- getValue(): unknown;
8
+ getValue(): unknown | PromiseLike<unknown>;
9
9
  }
10
10
  /**
11
11
  * MU notification data props
@@ -104,7 +104,7 @@ export class NotificationMU extends NotificationReact {
104
104
  return true;
105
105
  };
106
106
  const base = () => primaryButton && (_jsx(LoadingButton, { ...setupProps, onClick: callback, autoFocus: true, ...primaryButtonProps, children: okLabel }));
107
- return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [icon, _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
107
+ return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [icon, _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
108
108
  }
109
109
  // Create confirm
110
110
  createConfirm(_props, className) {
@@ -118,7 +118,7 @@ export class NotificationMU extends NotificationReact {
118
118
  return true;
119
119
  };
120
120
  const base = () => (_jsxs(React.Fragment, { children: [cancelButton && (_jsx(LoadingButton, { color: "secondary", onClick: async (event) => await callback(event, false), children: cancelLabel })), primaryButton && (_jsx(LoadingButton, { color: "primary", onClick: async (event) => await callback(event, true), autoFocus: true, ...primaryButtonProps, children: okLabel }))] }));
121
- return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [_jsx(HelpIcon, { color: "action" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
121
+ return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(HelpIcon, { color: "action" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), inputs] }), _jsx(DialogActions, { children: buttons ? buttons(this, callback, base) : base() })] }, this.id));
122
122
  }
123
123
  createMessageColor() {
124
124
  if (this.type === NotificationMessageType.Danger)
@@ -162,13 +162,12 @@ export class NotificationMU extends NotificationReact {
162
162
  setError(undefined);
163
163
  if (this.onReturn) {
164
164
  // Get the value
165
- const value = mRef.current?.getValue();
165
+ const value = await mRef.current?.getValue();
166
166
  if (value == null) {
167
167
  return false;
168
168
  }
169
- const result = this.onReturn(value);
169
+ const v = await this.onReturn(value);
170
170
  // returns false to prevent default dismiss
171
- const v = await result;
172
171
  if (v === false) {
173
172
  return false;
174
173
  }
@@ -185,7 +184,7 @@ export class NotificationMU extends NotificationReact {
185
184
  this.onReturn(undefined);
186
185
  this.dismiss();
187
186
  }, children: cancelLabel })), primaryButton && (_jsx(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, name: "okButton", ...primaryButtonProps, children: okLabel }))] }));
188
- return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { ...inputProps, children: [content, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
187
+ return (_jsxs(Dialog, { open: this.open, PaperComponent: draggable ? DraggablePaperComponent : undefined, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { ...inputProps, children: [content, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
189
188
  }
190
189
  // Create prompt
191
190
  createPrompt(_props, className) {
@@ -269,7 +268,7 @@ export class NotificationMU extends NotificationReact {
269
268
  return false;
270
269
  }
271
270
  }
272
- }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: draggable ? "dialog-title draggable-dialog-title" : "dialog-title", children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { dividers: true, children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), localInputs, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
271
+ }, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen, scroll: "paper", ...options, children: [_jsxs(IconDialogTitle, { draggable: draggable, className: `dialog-title${draggable ? " draggable-dialog-title" : ""}`, children: [_jsx(InfoIcon, { color: "primary" }), _jsx("span", { className: "dialogTitle", children: title }), closable && (_jsx(IconButton, { className: "MuiDialogContent-root-close-button", size: "small", onClick: () => this.returnValue("CLOSE"), children: _jsx(CloseIcon, {}) }))] }), _jsxs(DialogContent, { dividers: true, children: [typeof this.content === "string" ? (_jsx(DialogContentText, { children: this.content })) : (this.content), localInputs, _jsx(Typography, { component: "div", variant: "caption", ref: errorRef, color: "error", align: "center" })] }), _jsx(DialogActions, { children: buttons ? buttons(this, handleSubmit, base) : base() })] }, this.id));
273
272
  }
274
273
  createPopup(_props, className) {
275
274
  // Destruct
@@ -73,6 +73,7 @@ export * from "./GridUtils";
73
73
  export * from "./HiSelector";
74
74
  export * from "./HiSelectorTL";
75
75
  export * from "./IconButtonLink";
76
+ export * from "./ImagePreviewButton";
76
77
  export * from "./InputField";
77
78
  export * from "./InputTipField";
78
79
  export * from "./IntInputField";
package/lib/mjs/index.js CHANGED
@@ -73,6 +73,7 @@ export * from "./GridUtils";
73
73
  export * from "./HiSelector";
74
74
  export * from "./HiSelectorTL";
75
75
  export * from "./IconButtonLink";
76
+ export * from "./ImagePreviewButton";
76
77
  export * from "./InputField";
77
78
  export * from "./InputTipField";
78
79
  export * from "./IntInputField";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.6.73",
3
+ "version": "1.6.75",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,9 +40,9 @@
40
40
  "@dnd-kit/react": "^0.5.0",
41
41
  "@emotion/react": "^11.14.0",
42
42
  "@emotion/styled": "^11.14.1",
43
- "@etsoo/appscript": "^1.6.69",
43
+ "@etsoo/appscript": "^1.6.70",
44
44
  "@etsoo/notificationbase": "^1.1.72",
45
- "@etsoo/react": "^1.8.92",
45
+ "@etsoo/react": "^1.8.94",
46
46
  "@etsoo/shared": "^1.2.87",
47
47
  "@mui/icons-material": "^9.1.1",
48
48
  "@mui/material": "^9.1.2",
@@ -0,0 +1,73 @@
1
+ import Avatar from "@mui/material/Avatar";
2
+ import Button, { ButtonProps } from "@mui/material/Button";
3
+ import Dialog, { DialogProps } from "@mui/material/Dialog";
4
+ import DialogContent from "@mui/material/DialogContent";
5
+ import React from "react";
6
+
7
+ /**
8
+ * Image preview button props
9
+ */
10
+ export type ImagePreviewButtonProps = {
11
+ /**
12
+ * Button props
13
+ */
14
+ buttonProps?: Omit<ButtonProps, "onClick" | "disabled">;
15
+
16
+ /**
17
+ * Dialog props
18
+ */
19
+ dialogProps?: Omit<DialogProps, "open" | "onClose">;
20
+
21
+ /**
22
+ * Image
23
+ */
24
+ image?: string;
25
+
26
+ /**
27
+ * Size
28
+ */
29
+ size?: number | [number, number];
30
+ };
31
+
32
+ /**
33
+ * Image preview button
34
+ * @param props Props
35
+ * @returns Component
36
+ */
37
+ export function ImagePreviewButton(props: ImagePreviewButtonProps) {
38
+ // Destruct
39
+ const { buttonProps, dialogProps, image, size = 32 } = props;
40
+
41
+ const [open, setOpen] = React.useState(false);
42
+
43
+ const [width, height] = typeof size === "number" ? [size, size] : size;
44
+
45
+ return (
46
+ <React.Fragment>
47
+ <Button
48
+ onClick={() => setOpen(true)}
49
+ variant="text"
50
+ disabled={!image}
51
+ sx={{
52
+ p: 0,
53
+ minWidth: 0
54
+ }}
55
+ {...buttonProps}
56
+ >
57
+ <Avatar src={image} variant="rounded" sx={{ width, height }} />
58
+ </Button>
59
+ <Dialog
60
+ open={open}
61
+ onClose={() => setOpen(false)}
62
+ maxWidth="sm"
63
+ {...dialogProps}
64
+ >
65
+ <DialogContent>
66
+ {image && (
67
+ <img src={image} style={{ maxWidth: "100%", height: "auto" }} />
68
+ )}
69
+ </DialogContent>
70
+ </Dialog>
71
+ </React.Fragment>
72
+ );
73
+ }
@@ -80,7 +80,7 @@ const setError = (div?: HTMLDivElement | null, error?: string) => {
80
80
  * MU notification data methods
81
81
  */
82
82
  export interface NotificationMUDataMethods {
83
- getValue(): unknown;
83
+ getValue(): unknown | PromiseLike<unknown>;
84
84
  }
85
85
 
86
86
  /**
@@ -181,9 +181,7 @@ export class NotificationMU extends NotificationReact {
181
181
  >
182
182
  <IconDialogTitle
183
183
  draggable={draggable}
184
- className={
185
- draggable ? "dialog-title draggable-dialog-title" : "dialog-title"
186
- }
184
+ className={`dialog-title${draggable ? " draggable-dialog-title" : ""}`}
187
185
  >
188
186
  {icon}
189
187
  <span className="dialogTitle">{title}</span>
@@ -279,9 +277,7 @@ export class NotificationMU extends NotificationReact {
279
277
  >
280
278
  <IconDialogTitle
281
279
  draggable={draggable}
282
- className={
283
- draggable ? "dialog-title draggable-dialog-title" : "dialog-title"
284
- }
280
+ className={`dialog-title${draggable ? " draggable-dialog-title" : ""}`}
285
281
  >
286
282
  <HelpIcon color="action" />
287
283
  <span className="dialogTitle">{title}</span>
@@ -398,15 +394,14 @@ export class NotificationMU extends NotificationReact {
398
394
 
399
395
  if (this.onReturn) {
400
396
  // Get the value
401
- const value = mRef.current?.getValue();
397
+ const value = await mRef.current?.getValue();
402
398
  if (value == null) {
403
399
  return false;
404
400
  }
405
401
 
406
- const result = this.onReturn(value);
402
+ const v = await this.onReturn(value);
407
403
 
408
404
  // returns false to prevent default dismiss
409
- const v = await result;
410
405
  if (v === false) {
411
406
  return false;
412
407
  }
@@ -462,9 +457,7 @@ export class NotificationMU extends NotificationReact {
462
457
  >
463
458
  <IconDialogTitle
464
459
  draggable={draggable}
465
- className={
466
- draggable ? "dialog-title draggable-dialog-title" : "dialog-title"
467
- }
460
+ className={`dialog-title${draggable ? " draggable-dialog-title" : ""}`}
468
461
  >
469
462
  <InfoIcon color="primary" />
470
463
  <span className="dialogTitle">{title}</span>
@@ -664,9 +657,7 @@ export class NotificationMU extends NotificationReact {
664
657
  >
665
658
  <IconDialogTitle
666
659
  draggable={draggable}
667
- className={
668
- draggable ? "dialog-title draggable-dialog-title" : "dialog-title"
669
- }
660
+ className={`dialog-title${draggable ? " draggable-dialog-title" : ""}`}
670
661
  >
671
662
  <InfoIcon color="primary" />
672
663
  <span className="dialogTitle">{title}</span>
package/src/index.ts CHANGED
@@ -79,6 +79,7 @@ export * from "./GridUtils";
79
79
  export * from "./HiSelector";
80
80
  export * from "./HiSelectorTL";
81
81
  export * from "./IconButtonLink";
82
+ export * from "./ImagePreviewButton";
82
83
  export * from "./InputField";
83
84
  export * from "./InputTipField";
84
85
  export * from "./IntInputField";