@etsoo/materialui 1.6.74 → 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
+ }
@@ -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
+ }
@@ -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.74",
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.93",
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
+ }
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";