@etsoo/materialui 1.6.77 → 1.6.78
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.
|
@@ -16,6 +16,7 @@ const Save_1 = __importDefault(require("@mui/icons-material/Save"));
|
|
|
16
16
|
const CanvasUtils_1 = require("./utils/CanvasUtils");
|
|
17
17
|
const Stack_1 = __importDefault(require("@mui/material/Stack"));
|
|
18
18
|
const ButtonGroup_1 = __importDefault(require("@mui/material/ButtonGroup"));
|
|
19
|
+
const ReactApp_1 = require("./app/ReactApp");
|
|
19
20
|
/**
|
|
20
21
|
* Extended SignaturePad class with trim method
|
|
21
22
|
*/
|
|
@@ -49,8 +50,15 @@ function SignaturePadComponent(props) {
|
|
|
49
50
|
if (!canvas)
|
|
50
51
|
return;
|
|
51
52
|
ref.current = new SignaturePadEx(canvas, options);
|
|
53
|
+
const observer = new ResizeObserver((entries) => {
|
|
54
|
+
const { width, height } = entries[0].contentRect;
|
|
55
|
+
canvas.width = width;
|
|
56
|
+
canvas.height = height;
|
|
57
|
+
});
|
|
58
|
+
observer.observe(canvas.parentElement);
|
|
52
59
|
return () => {
|
|
53
60
|
ref.current?.off();
|
|
61
|
+
observer.disconnect();
|
|
54
62
|
};
|
|
55
63
|
}, [options, ref]);
|
|
56
64
|
return (0, jsx_runtime_1.jsx)("canvas", { ref: canvasRef, width: width, height: height });
|
|
@@ -62,8 +70,11 @@ function SignaturePadComponent(props) {
|
|
|
62
70
|
* @returns Component
|
|
63
71
|
*/
|
|
64
72
|
function SignaturePadFull(props) {
|
|
73
|
+
// Global app
|
|
74
|
+
const app = (0, ReactApp_1.useAppContext)();
|
|
75
|
+
const { clear, save } = app?.getLabels("clear", "save") ?? {};
|
|
65
76
|
// Destruct
|
|
66
|
-
const { clearLabel = "Clear", saveLabel = "Save", width =
|
|
77
|
+
const { clearLabel = clear || "Clear", saveLabel = save || "Save", width = "100%", height = 300, mRef, onSave, options, placement = ["right", "flex-start"], spacing = 0.5 } = props;
|
|
67
78
|
// Ref
|
|
68
79
|
const signaturePadRef = react_1.default.useRef(null);
|
|
69
80
|
react_1.default.useImperativeHandle(mRef, () => ({
|
|
@@ -8,6 +8,7 @@ import SaveIcon from "@mui/icons-material/Save";
|
|
|
8
8
|
import { CanvasUtils } from "./utils/CanvasUtils";
|
|
9
9
|
import Stack from "@mui/material/Stack";
|
|
10
10
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
11
|
+
import { useAppContext } from "./app/ReactApp";
|
|
11
12
|
/**
|
|
12
13
|
* Extended SignaturePad class with trim method
|
|
13
14
|
*/
|
|
@@ -40,8 +41,15 @@ export function SignaturePadComponent(props) {
|
|
|
40
41
|
if (!canvas)
|
|
41
42
|
return;
|
|
42
43
|
ref.current = new SignaturePadEx(canvas, options);
|
|
44
|
+
const observer = new ResizeObserver((entries) => {
|
|
45
|
+
const { width, height } = entries[0].contentRect;
|
|
46
|
+
canvas.width = width;
|
|
47
|
+
canvas.height = height;
|
|
48
|
+
});
|
|
49
|
+
observer.observe(canvas.parentElement);
|
|
43
50
|
return () => {
|
|
44
51
|
ref.current?.off();
|
|
52
|
+
observer.disconnect();
|
|
45
53
|
};
|
|
46
54
|
}, [options, ref]);
|
|
47
55
|
return _jsx("canvas", { ref: canvasRef, width: width, height: height });
|
|
@@ -53,8 +61,11 @@ export function SignaturePadComponent(props) {
|
|
|
53
61
|
* @returns Component
|
|
54
62
|
*/
|
|
55
63
|
export function SignaturePadFull(props) {
|
|
64
|
+
// Global app
|
|
65
|
+
const app = useAppContext();
|
|
66
|
+
const { clear, save } = app?.getLabels("clear", "save") ?? {};
|
|
56
67
|
// Destruct
|
|
57
|
-
const { clearLabel = "Clear", saveLabel = "Save", width =
|
|
68
|
+
const { clearLabel = clear || "Clear", saveLabel = save || "Save", width = "100%", height = 300, mRef, onSave, options, placement = ["right", "flex-start"], spacing = 0.5 } = props;
|
|
58
69
|
// Ref
|
|
59
70
|
const signaturePadRef = React.useRef(null);
|
|
60
71
|
React.useImperativeHandle(mRef, () => ({
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import { ResponsiveStyleValue } from "@mui/system";
|
|
|
8
8
|
import { CanvasUtils } from "./utils/CanvasUtils";
|
|
9
9
|
import Stack from "@mui/material/Stack";
|
|
10
10
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
11
|
+
import { useAppContext } from "./app/ReactApp";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Extended SignaturePad class with trim method
|
|
@@ -36,7 +37,7 @@ export type SignaturePadComponentProps = {
|
|
|
36
37
|
/**
|
|
37
38
|
* Width of the canvas
|
|
38
39
|
*/
|
|
39
|
-
width: number;
|
|
40
|
+
width: number | string;
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* Height of the canvas
|
|
@@ -72,8 +73,18 @@ export function SignaturePadComponent(props: SignaturePadComponentProps) {
|
|
|
72
73
|
|
|
73
74
|
ref.current = new SignaturePadEx(canvas, options);
|
|
74
75
|
|
|
76
|
+
const observer = new ResizeObserver((entries) => {
|
|
77
|
+
const { width, height } = entries[0].contentRect;
|
|
78
|
+
|
|
79
|
+
canvas.width = width;
|
|
80
|
+
canvas.height = height;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
observer.observe(canvas.parentElement!);
|
|
84
|
+
|
|
75
85
|
return () => {
|
|
76
86
|
ref.current?.off();
|
|
87
|
+
observer.disconnect();
|
|
77
88
|
};
|
|
78
89
|
}, [options, ref]);
|
|
79
90
|
|
|
@@ -140,11 +151,15 @@ export type SignaturePadFullProps = Partial<
|
|
|
140
151
|
* @returns Component
|
|
141
152
|
*/
|
|
142
153
|
export function SignaturePadFull(props: SignaturePadFullProps) {
|
|
154
|
+
// Global app
|
|
155
|
+
const app = useAppContext();
|
|
156
|
+
const { clear, save } = app?.getLabels("clear", "save") ?? {};
|
|
157
|
+
|
|
143
158
|
// Destruct
|
|
144
159
|
const {
|
|
145
|
-
clearLabel = "Clear",
|
|
146
|
-
saveLabel = "Save",
|
|
147
|
-
width =
|
|
160
|
+
clearLabel = clear || "Clear",
|
|
161
|
+
saveLabel = save || "Save",
|
|
162
|
+
width = "100%",
|
|
148
163
|
height = 300,
|
|
149
164
|
mRef,
|
|
150
165
|
onSave,
|