@etsoo/materialui 1.4.27 → 1.4.28
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/UserAvatarEditor.d.ts +4 -0
- package/lib/UserAvatarEditor.js +5 -5
- package/lib/app/Labels.d.ts +1 -1
- package/lib/app/Labels.js +1 -1
- package/package.json +2 -2
- package/src/UserAvatarEditor.tsx +13 -7
- package/src/app/Labels.ts +1 -1
package/lib/UserAvatarEditor.js
CHANGED
|
@@ -4,7 +4,7 @@ import React from "react";
|
|
|
4
4
|
import RotateLeftIcon from "@mui/icons-material/RotateLeft";
|
|
5
5
|
import RotateRightIcon from "@mui/icons-material/RotateRight";
|
|
6
6
|
import ClearAllIcon from "@mui/icons-material/ClearAll";
|
|
7
|
-
import
|
|
7
|
+
import ImageIcon from "@mui/icons-material/Image";
|
|
8
8
|
import DoneIcon from "@mui/icons-material/Done";
|
|
9
9
|
import RemoveIcon from "@mui/icons-material/Remove";
|
|
10
10
|
import AddIcon from "@mui/icons-material/Add";
|
|
@@ -22,14 +22,14 @@ const defaultState = {
|
|
|
22
22
|
* @returns Component
|
|
23
23
|
*/
|
|
24
24
|
export function UserAvatarEditor(props) {
|
|
25
|
+
// Labels
|
|
26
|
+
const labels = Labels.UserAvatarEditor;
|
|
25
27
|
// Destruct
|
|
26
|
-
const { border = 30, image, maxWidth, onDone, scaledResult = false, width = defaultSize, height = defaultSize, range = [0.1, 2, 0.1] } = props;
|
|
28
|
+
const { border = 30, image, maxWidth, onDone, scaledResult = false, width = defaultSize, height = defaultSize, range = [0.1, 2, 0.1], selectFileLabel = labels.selectFile + "..." } = props;
|
|
27
29
|
// Container width
|
|
28
30
|
const containerWidth = width + 2 * border + 44 + 4;
|
|
29
31
|
// Calculated max width
|
|
30
32
|
const maxWidthCalculated = maxWidth == null || maxWidth < defaultSize ? 2 * width : maxWidth;
|
|
31
|
-
// Labels
|
|
32
|
-
const labels = Labels.UserAvatarEditor;
|
|
33
33
|
// Ref
|
|
34
34
|
const ref = React.createRef();
|
|
35
35
|
// Image type
|
|
@@ -144,5 +144,5 @@ export function UserAvatarEditor(props) {
|
|
|
144
144
|
};
|
|
145
145
|
// Load the component
|
|
146
146
|
const AE = React.lazy(() => import("react-avatar-editor"));
|
|
147
|
-
return (_jsxs(Stack, { direction: "column", spacing: 0.5, width: containerWidth, children: [_jsx(FileUploadButton, { variant: "outlined", size: "medium", startIcon: _jsx(
|
|
147
|
+
return (_jsxs(Stack, { direction: "column", spacing: 0.5, width: containerWidth, children: [_jsx(FileUploadButton, { variant: "outlined", size: "medium", startIcon: _jsx(ImageIcon, {}), fullWidth: true, onUploadFiles: handleFileUpload, inputProps: { multiple: false, accept: "image/png, image/jpeg" }, children: selectFileLabel }), _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(React.Suspense, { fallback: _jsx(Skeleton, { variant: "rounded", width: width, height: localHeight }), children: _jsx(AE, { ref: ref, border: border, width: width, height: localHeight, onLoadSuccess: handleLoad, image: previewImage ?? "", scale: editorState.scale, rotate: editorState.rotate }) }), _jsxs(ButtonGroup, { size: "small", orientation: "vertical", disabled: !ready, children: [_jsx(Button, { onClick: () => handleRotate(90), title: labels.rotateRight, children: _jsx(RotateRightIcon, {}) }), _jsx(Button, { onClick: () => handleRotate(-90), title: labels.rotateLeft, children: _jsx(RotateLeftIcon, {}) }), _jsx(Button, { onClick: handleReset, title: labels.reset, children: _jsx(ClearAllIcon, {}) })] })] }), _jsxs(Stack, { spacing: 0.5, direction: "row", sx: { paddingBottom: 2 }, alignItems: "center", children: [_jsx(IconButton, { size: "small", disabled: !ready || editorState.scale <= min, onClick: () => adjustScale(false), children: _jsx(RemoveIcon, {}) }), _jsx(Slider, { title: labels.zoom, disabled: !ready, min: min, max: max, step: step, value: editorState.scale, valueLabelDisplay: "auto", valueLabelFormat: (value) => `${Math.round(100 * value) / 100}`, marks: marks, onChange: handleZoom }), _jsx(IconButton, { size: "small", disabled: !ready || editorState.scale >= max, onClick: () => adjustScale(true), children: _jsx(AddIcon, {}) })] }), _jsx(Button, { ref: buttonRef, variant: "contained", startIcon: _jsx(DoneIcon, {}), disabled: !ready, onClick: handleDone, children: labels.done })] }));
|
|
148
148
|
}
|
package/lib/app/Labels.d.ts
CHANGED
package/lib/app/Labels.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.28",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@emotion/css": "^11.13.5",
|
|
36
36
|
"@emotion/react": "^11.13.5",
|
|
37
37
|
"@emotion/styled": "^11.13.5",
|
|
38
|
-
"@etsoo/appscript": "^1.5.
|
|
38
|
+
"@etsoo/appscript": "^1.5.70",
|
|
39
39
|
"@etsoo/notificationbase": "^1.1.54",
|
|
40
40
|
"@etsoo/react": "^1.8.3",
|
|
41
41
|
"@etsoo/shared": "^1.2.55",
|
package/src/UserAvatarEditor.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import type AvatarEditor from "react-avatar-editor";
|
|
|
11
11
|
import RotateLeftIcon from "@mui/icons-material/RotateLeft";
|
|
12
12
|
import RotateRightIcon from "@mui/icons-material/RotateRight";
|
|
13
13
|
import ClearAllIcon from "@mui/icons-material/ClearAll";
|
|
14
|
-
import
|
|
14
|
+
import ImageIcon from "@mui/icons-material/Image";
|
|
15
15
|
import DoneIcon from "@mui/icons-material/Done";
|
|
16
16
|
import RemoveIcon from "@mui/icons-material/Remove";
|
|
17
17
|
import AddIcon from "@mui/icons-material/Add";
|
|
@@ -67,6 +67,11 @@ export interface UserAvatarEditorProps {
|
|
|
67
67
|
*/
|
|
68
68
|
onDone: UserAvatarEditorOnDoneHandler;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Select file label
|
|
72
|
+
*/
|
|
73
|
+
selectFileLabel?: string;
|
|
74
|
+
|
|
70
75
|
/**
|
|
71
76
|
* Return scaled result?
|
|
72
77
|
*/
|
|
@@ -105,6 +110,9 @@ const defaultState: EditorState = {
|
|
|
105
110
|
* @returns Component
|
|
106
111
|
*/
|
|
107
112
|
export function UserAvatarEditor(props: UserAvatarEditorProps) {
|
|
113
|
+
// Labels
|
|
114
|
+
const labels = Labels.UserAvatarEditor;
|
|
115
|
+
|
|
108
116
|
// Destruct
|
|
109
117
|
const {
|
|
110
118
|
border = 30,
|
|
@@ -114,7 +122,8 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
|
|
|
114
122
|
scaledResult = false,
|
|
115
123
|
width = defaultSize,
|
|
116
124
|
height = defaultSize,
|
|
117
|
-
range = [0.1, 2, 0.1]
|
|
125
|
+
range = [0.1, 2, 0.1],
|
|
126
|
+
selectFileLabel = labels.selectFile + "..."
|
|
118
127
|
} = props;
|
|
119
128
|
|
|
120
129
|
// Container width
|
|
@@ -124,9 +133,6 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
|
|
|
124
133
|
const maxWidthCalculated =
|
|
125
134
|
maxWidth == null || maxWidth < defaultSize ? 2 * width : maxWidth;
|
|
126
135
|
|
|
127
|
-
// Labels
|
|
128
|
-
const labels = Labels.UserAvatarEditor;
|
|
129
|
-
|
|
130
136
|
// Ref
|
|
131
137
|
const ref = React.createRef<AvatarEditor>();
|
|
132
138
|
|
|
@@ -280,12 +286,12 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
|
|
|
280
286
|
<FileUploadButton
|
|
281
287
|
variant="outlined"
|
|
282
288
|
size="medium"
|
|
283
|
-
startIcon={<
|
|
289
|
+
startIcon={<ImageIcon />}
|
|
284
290
|
fullWidth
|
|
285
291
|
onUploadFiles={handleFileUpload}
|
|
286
292
|
inputProps={{ multiple: false, accept: "image/png, image/jpeg" }}
|
|
287
293
|
>
|
|
288
|
-
{
|
|
294
|
+
{selectFileLabel}
|
|
289
295
|
</FileUploadButton>
|
|
290
296
|
<Stack direction="row" spacing={0.5}>
|
|
291
297
|
<React.Suspense
|