@etsoo/materialui 1.6.75 → 1.6.76
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ButtonProps } from "@mui/material/Button";
|
|
2
2
|
import { DialogProps } from "@mui/material/Dialog";
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { CSSProperties } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Image preview button props
|
|
6
6
|
*/
|
|
@@ -17,6 +17,10 @@ export type ImagePreviewButtonProps = {
|
|
|
17
17
|
* Image
|
|
18
18
|
*/
|
|
19
19
|
image?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Object fit style
|
|
22
|
+
*/
|
|
23
|
+
objectFit?: CSSProperties["objectFit"];
|
|
20
24
|
/**
|
|
21
25
|
* Size
|
|
22
26
|
*/
|
|
@@ -17,11 +17,17 @@ const react_1 = __importDefault(require("react"));
|
|
|
17
17
|
*/
|
|
18
18
|
function ImagePreviewButton(props) {
|
|
19
19
|
// Destruct
|
|
20
|
-
const { buttonProps, dialogProps, image, size = 32 } = props;
|
|
20
|
+
const { buttonProps, dialogProps, image, objectFit = "contain", size = 32 } = props;
|
|
21
21
|
const [open, setOpen] = react_1.default.useState(false);
|
|
22
22
|
const [width, height] = typeof size === "number" ? [size, size] : size;
|
|
23
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
24
|
p: 0,
|
|
25
25
|
minWidth: 0
|
|
26
|
-
}, ...buttonProps, children: (0, jsx_runtime_1.jsx)(Avatar_1.default, { src: image, variant: "rounded", sx: {
|
|
26
|
+
}, ...buttonProps, children: (0, jsx_runtime_1.jsx)(Avatar_1.default, { src: image, variant: "rounded", sx: {
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
"& img": {
|
|
30
|
+
objectFit
|
|
31
|
+
}
|
|
32
|
+
} }) }), (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
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ButtonProps } from "@mui/material/Button";
|
|
2
2
|
import { DialogProps } from "@mui/material/Dialog";
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { CSSProperties } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Image preview button props
|
|
6
6
|
*/
|
|
@@ -17,6 +17,10 @@ export type ImagePreviewButtonProps = {
|
|
|
17
17
|
* Image
|
|
18
18
|
*/
|
|
19
19
|
image?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Object fit style
|
|
22
|
+
*/
|
|
23
|
+
objectFit?: CSSProperties["objectFit"];
|
|
20
24
|
/**
|
|
21
25
|
* Size
|
|
22
26
|
*/
|
|
@@ -11,11 +11,17 @@ import React from "react";
|
|
|
11
11
|
*/
|
|
12
12
|
export function ImagePreviewButton(props) {
|
|
13
13
|
// Destruct
|
|
14
|
-
const { buttonProps, dialogProps, image, size = 32 } = props;
|
|
14
|
+
const { buttonProps, dialogProps, image, objectFit = "contain", size = 32 } = props;
|
|
15
15
|
const [open, setOpen] = React.useState(false);
|
|
16
16
|
const [width, height] = typeof size === "number" ? [size, size] : size;
|
|
17
17
|
return (_jsxs(React.Fragment, { children: [_jsx(Button, { onClick: () => setOpen(true), variant: "text", disabled: !image, sx: {
|
|
18
18
|
p: 0,
|
|
19
19
|
minWidth: 0
|
|
20
|
-
}, ...buttonProps, children: _jsx(Avatar, { src: image, variant: "rounded", sx: {
|
|
20
|
+
}, ...buttonProps, children: _jsx(Avatar, { src: image, variant: "rounded", sx: {
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
23
|
+
"& img": {
|
|
24
|
+
objectFit
|
|
25
|
+
}
|
|
26
|
+
} }) }), _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
27
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import Avatar from "@mui/material/Avatar";
|
|
|
2
2
|
import Button, { ButtonProps } from "@mui/material/Button";
|
|
3
3
|
import Dialog, { DialogProps } from "@mui/material/Dialog";
|
|
4
4
|
import DialogContent from "@mui/material/DialogContent";
|
|
5
|
-
import React from "react";
|
|
5
|
+
import React, { CSSProperties } from "react";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Image preview button props
|
|
@@ -23,6 +23,11 @@ export type ImagePreviewButtonProps = {
|
|
|
23
23
|
*/
|
|
24
24
|
image?: string;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Object fit style
|
|
28
|
+
*/
|
|
29
|
+
objectFit?: CSSProperties["objectFit"];
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* Size
|
|
28
33
|
*/
|
|
@@ -36,7 +41,13 @@ export type ImagePreviewButtonProps = {
|
|
|
36
41
|
*/
|
|
37
42
|
export function ImagePreviewButton(props: ImagePreviewButtonProps) {
|
|
38
43
|
// Destruct
|
|
39
|
-
const {
|
|
44
|
+
const {
|
|
45
|
+
buttonProps,
|
|
46
|
+
dialogProps,
|
|
47
|
+
image,
|
|
48
|
+
objectFit = "contain",
|
|
49
|
+
size = 32
|
|
50
|
+
} = props;
|
|
40
51
|
|
|
41
52
|
const [open, setOpen] = React.useState(false);
|
|
42
53
|
|
|
@@ -54,7 +65,17 @@ export function ImagePreviewButton(props: ImagePreviewButtonProps) {
|
|
|
54
65
|
}}
|
|
55
66
|
{...buttonProps}
|
|
56
67
|
>
|
|
57
|
-
<Avatar
|
|
68
|
+
<Avatar
|
|
69
|
+
src={image}
|
|
70
|
+
variant="rounded"
|
|
71
|
+
sx={{
|
|
72
|
+
width,
|
|
73
|
+
height,
|
|
74
|
+
"& img": {
|
|
75
|
+
objectFit
|
|
76
|
+
}
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
58
79
|
</Button>
|
|
59
80
|
<Dialog
|
|
60
81
|
open={open}
|