@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.
@@ -30,6 +30,10 @@ export interface UserAvatarEditorProps {
30
30
  * On done handler
31
31
  */
32
32
  onDone: UserAvatarEditorOnDoneHandler;
33
+ /**
34
+ * Select file label
35
+ */
36
+ selectFileLabel?: string;
33
37
  /**
34
38
  * Return scaled result?
35
39
  */
@@ -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 ComputerIcon from "@mui/icons-material/Computer";
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(ComputerIcon, {}), fullWidth: true, onUploadFiles: handleFileUpload, inputProps: { multiple: false, accept: "image/png, image/jpeg" }, children: labels.upload }), _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 })] }));
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
  }
@@ -45,7 +45,7 @@ export declare namespace Labels {
45
45
  reset: string;
46
46
  rotateLeft: string;
47
47
  rotateRight: string;
48
- upload: string;
48
+ selectFile: string;
49
49
  zoom: string;
50
50
  };
51
51
  /**
package/lib/app/Labels.js CHANGED
@@ -46,7 +46,7 @@ export var Labels;
46
46
  reset: "Reset",
47
47
  rotateLeft: "Rotate left 90°",
48
48
  rotateRight: "Rotate right 90°",
49
- upload: "Upload",
49
+ selectFile: "Select file",
50
50
  zoom: "Zoom"
51
51
  };
52
52
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.27",
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.69",
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",
@@ -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 ComputerIcon from "@mui/icons-material/Computer";
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={<ComputerIcon />}
289
+ startIcon={<ImageIcon />}
284
290
  fullWidth
285
291
  onUploadFiles={handleFileUpload}
286
292
  inputProps={{ multiple: false, accept: "image/png, image/jpeg" }}
287
293
  >
288
- {labels.upload}
294
+ {selectFileLabel}
289
295
  </FileUploadButton>
290
296
  <Stack direction="row" spacing={0.5}>
291
297
  <React.Suspense
package/src/app/Labels.ts CHANGED
@@ -48,7 +48,7 @@ export namespace Labels {
48
48
  reset: "Reset",
49
49
  rotateLeft: "Rotate left 90°",
50
50
  rotateRight: "Rotate right 90°",
51
- upload: "Upload",
51
+ selectFile: "Select file",
52
52
  zoom: "Zoom"
53
53
  };
54
54