@etsoo/materialui 1.6.74 → 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.
- package/lib/cjs/ImagePreviewButton.d.ts +34 -0
- package/lib/cjs/ImagePreviewButton.js +33 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/mjs/ImagePreviewButton.d.ts +34 -0
- package/lib/mjs/ImagePreviewButton.js +27 -0
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.js +1 -0
- package/package.json +3 -3
- package/src/ImagePreviewButton.tsx +94 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ButtonProps } from "@mui/material/Button";
|
|
2
|
+
import { DialogProps } from "@mui/material/Dialog";
|
|
3
|
+
import React, { CSSProperties } 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
|
+
* Object fit style
|
|
22
|
+
*/
|
|
23
|
+
objectFit?: CSSProperties["objectFit"];
|
|
24
|
+
/**
|
|
25
|
+
* Size
|
|
26
|
+
*/
|
|
27
|
+
size?: number | [number, number];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Image preview button
|
|
31
|
+
* @param props Props
|
|
32
|
+
* @returns Component
|
|
33
|
+
*/
|
|
34
|
+
export declare function ImagePreviewButton(props: ImagePreviewButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
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, objectFit = "contain", 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: {
|
|
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" } })) }) })] }));
|
|
33
|
+
}
|
package/lib/cjs/index.d.ts
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/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,34 @@
|
|
|
1
|
+
import { ButtonProps } from "@mui/material/Button";
|
|
2
|
+
import { DialogProps } from "@mui/material/Dialog";
|
|
3
|
+
import React, { CSSProperties } 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
|
+
* Object fit style
|
|
22
|
+
*/
|
|
23
|
+
objectFit?: CSSProperties["objectFit"];
|
|
24
|
+
/**
|
|
25
|
+
* Size
|
|
26
|
+
*/
|
|
27
|
+
size?: number | [number, number];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Image preview button
|
|
31
|
+
* @param props Props
|
|
32
|
+
* @returns Component
|
|
33
|
+
*/
|
|
34
|
+
export declare function ImagePreviewButton(props: ImagePreviewButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
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, objectFit = "contain", 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: {
|
|
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" } })) }) })] }));
|
|
27
|
+
}
|
package/lib/mjs/index.d.ts
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/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.
|
|
3
|
+
"version": "1.6.76",
|
|
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.
|
|
43
|
+
"@etsoo/appscript": "^1.6.70",
|
|
44
44
|
"@etsoo/notificationbase": "^1.1.72",
|
|
45
|
-
"@etsoo/react": "^1.8.
|
|
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,94 @@
|
|
|
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, { CSSProperties } 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
|
+
* Object fit style
|
|
28
|
+
*/
|
|
29
|
+
objectFit?: CSSProperties["objectFit"];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Size
|
|
33
|
+
*/
|
|
34
|
+
size?: number | [number, number];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Image preview button
|
|
39
|
+
* @param props Props
|
|
40
|
+
* @returns Component
|
|
41
|
+
*/
|
|
42
|
+
export function ImagePreviewButton(props: ImagePreviewButtonProps) {
|
|
43
|
+
// Destruct
|
|
44
|
+
const {
|
|
45
|
+
buttonProps,
|
|
46
|
+
dialogProps,
|
|
47
|
+
image,
|
|
48
|
+
objectFit = "contain",
|
|
49
|
+
size = 32
|
|
50
|
+
} = props;
|
|
51
|
+
|
|
52
|
+
const [open, setOpen] = React.useState(false);
|
|
53
|
+
|
|
54
|
+
const [width, height] = typeof size === "number" ? [size, size] : size;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<React.Fragment>
|
|
58
|
+
<Button
|
|
59
|
+
onClick={() => setOpen(true)}
|
|
60
|
+
variant="text"
|
|
61
|
+
disabled={!image}
|
|
62
|
+
sx={{
|
|
63
|
+
p: 0,
|
|
64
|
+
minWidth: 0
|
|
65
|
+
}}
|
|
66
|
+
{...buttonProps}
|
|
67
|
+
>
|
|
68
|
+
<Avatar
|
|
69
|
+
src={image}
|
|
70
|
+
variant="rounded"
|
|
71
|
+
sx={{
|
|
72
|
+
width,
|
|
73
|
+
height,
|
|
74
|
+
"& img": {
|
|
75
|
+
objectFit
|
|
76
|
+
}
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
</Button>
|
|
80
|
+
<Dialog
|
|
81
|
+
open={open}
|
|
82
|
+
onClose={() => setOpen(false)}
|
|
83
|
+
maxWidth="sm"
|
|
84
|
+
{...dialogProps}
|
|
85
|
+
>
|
|
86
|
+
<DialogContent>
|
|
87
|
+
{image && (
|
|
88
|
+
<img src={image} style={{ maxWidth: "100%", height: "auto" }} />
|
|
89
|
+
)}
|
|
90
|
+
</DialogContent>
|
|
91
|
+
</Dialog>
|
|
92
|
+
</React.Fragment>
|
|
93
|
+
);
|
|
94
|
+
}
|
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";
|