@etsoo/materialui 1.6.77 → 1.6.79
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/HtmlDescriptionBase.d.ts +25 -0
- package/lib/cjs/HtmlDescriptionBase.js +36 -0
- package/lib/cjs/SignaturePadComponent.d.ts +1 -1
- package/lib/cjs/SignaturePadComponent.js +12 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/mjs/HtmlDescriptionBase.d.ts +25 -0
- package/lib/mjs/HtmlDescriptionBase.js +30 -0
- package/lib/mjs/SignaturePadComponent.d.ts +1 -1
- package/lib/mjs/SignaturePadComponent.js +12 -1
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.js +1 -0
- package/package.json +3 -3
- package/src/HtmlDescriptionBase.tsx +79 -0
- package/src/SignaturePadComponent.tsx +19 -4
- package/src/index.ts +1 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InputFieldProps } from "./InputField";
|
|
3
|
+
/**
|
|
4
|
+
* HTML Description component base props
|
|
5
|
+
* HTML 描述组件基础属性
|
|
6
|
+
*/
|
|
7
|
+
export type HtmlDescriptionBaseProps = Omit<InputFieldProps, "multiline"> & {
|
|
8
|
+
/**
|
|
9
|
+
* Maximum length of the input
|
|
10
|
+
* 输入的最大长度
|
|
11
|
+
*/
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Edit handler
|
|
15
|
+
* 编辑处理器
|
|
16
|
+
*/
|
|
17
|
+
onEdit: (input: HTMLInputElement) => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* HTML Description component base
|
|
21
|
+
* HTML 描述组件属性基础
|
|
22
|
+
* @param props Props
|
|
23
|
+
* @returns Component
|
|
24
|
+
*/
|
|
25
|
+
export declare function HtmlDescriptionBase(props: HtmlDescriptionBaseProps): React.JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
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.HtmlDescriptionBase = HtmlDescriptionBase;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const InputField_1 = require("./InputField");
|
|
10
|
+
const react_2 = require("@etsoo/react");
|
|
11
|
+
const InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
|
|
12
|
+
const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
|
|
13
|
+
const Edit_1 = __importDefault(require("@mui/icons-material/Edit"));
|
|
14
|
+
/**
|
|
15
|
+
* HTML Description component base
|
|
16
|
+
* HTML 描述组件属性基础
|
|
17
|
+
* @param props Props
|
|
18
|
+
* @returns Component
|
|
19
|
+
*/
|
|
20
|
+
function HtmlDescriptionBase(props) {
|
|
21
|
+
// Destruct
|
|
22
|
+
const { fullWidth = true, inputRef, label, maxLength = 1280, name = "description", onEdit, rows = 3, ...rest } = props;
|
|
23
|
+
const localRef = react_1.default.useRef(null);
|
|
24
|
+
const refs = (0, react_2.useCombinedRefs)(localRef, inputRef);
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { fullWidth: fullWidth, inputRef: refs, name: name, slotProps: {
|
|
26
|
+
htmlInput: { maxLength },
|
|
27
|
+
input: {
|
|
28
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "end", children: (0, jsx_runtime_1.jsx)(IconButton_1.default, { edge: "end", onClick: () => {
|
|
29
|
+
const input = localRef.current;
|
|
30
|
+
if (input == null)
|
|
31
|
+
return;
|
|
32
|
+
onEdit(input);
|
|
33
|
+
}, children: (0, jsx_runtime_1.jsx)(Edit_1.default, {}) }) }))
|
|
34
|
+
}
|
|
35
|
+
}, label: label, multiline: true, rows: rows, ...rest }));
|
|
36
|
+
}
|
|
@@ -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, () => ({
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export * from "./GridDataFormat";
|
|
|
73
73
|
export * from "./GridUtils";
|
|
74
74
|
export * from "./HiSelector";
|
|
75
75
|
export * from "./HiSelectorTL";
|
|
76
|
+
export * from "./HtmlDescriptionBase";
|
|
76
77
|
export * from "./IconButtonLink";
|
|
77
78
|
export * from "./ImagePreviewButton";
|
|
78
79
|
export * from "./InputField";
|
package/lib/cjs/index.js
CHANGED
|
@@ -93,6 +93,7 @@ __exportStar(require("./GridDataFormat"), exports);
|
|
|
93
93
|
__exportStar(require("./GridUtils"), exports);
|
|
94
94
|
__exportStar(require("./HiSelector"), exports);
|
|
95
95
|
__exportStar(require("./HiSelectorTL"), exports);
|
|
96
|
+
__exportStar(require("./HtmlDescriptionBase"), exports);
|
|
96
97
|
__exportStar(require("./IconButtonLink"), exports);
|
|
97
98
|
__exportStar(require("./ImagePreviewButton"), exports);
|
|
98
99
|
__exportStar(require("./InputField"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InputFieldProps } from "./InputField";
|
|
3
|
+
/**
|
|
4
|
+
* HTML Description component base props
|
|
5
|
+
* HTML 描述组件基础属性
|
|
6
|
+
*/
|
|
7
|
+
export type HtmlDescriptionBaseProps = Omit<InputFieldProps, "multiline"> & {
|
|
8
|
+
/**
|
|
9
|
+
* Maximum length of the input
|
|
10
|
+
* 输入的最大长度
|
|
11
|
+
*/
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Edit handler
|
|
15
|
+
* 编辑处理器
|
|
16
|
+
*/
|
|
17
|
+
onEdit: (input: HTMLInputElement) => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* HTML Description component base
|
|
21
|
+
* HTML 描述组件属性基础
|
|
22
|
+
* @param props Props
|
|
23
|
+
* @returns Component
|
|
24
|
+
*/
|
|
25
|
+
export declare function HtmlDescriptionBase(props: HtmlDescriptionBaseProps): React.JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { InputField } from "./InputField";
|
|
4
|
+
import { useCombinedRefs } from "@etsoo/react";
|
|
5
|
+
import InputAdornment from "@mui/material/InputAdornment";
|
|
6
|
+
import IconButton from "@mui/material/IconButton";
|
|
7
|
+
import EditIcon from "@mui/icons-material/Edit";
|
|
8
|
+
/**
|
|
9
|
+
* HTML Description component base
|
|
10
|
+
* HTML 描述组件属性基础
|
|
11
|
+
* @param props Props
|
|
12
|
+
* @returns Component
|
|
13
|
+
*/
|
|
14
|
+
export function HtmlDescriptionBase(props) {
|
|
15
|
+
// Destruct
|
|
16
|
+
const { fullWidth = true, inputRef, label, maxLength = 1280, name = "description", onEdit, rows = 3, ...rest } = props;
|
|
17
|
+
const localRef = React.useRef(null);
|
|
18
|
+
const refs = useCombinedRefs(localRef, inputRef);
|
|
19
|
+
return (_jsx(InputField, { fullWidth: fullWidth, inputRef: refs, name: name, slotProps: {
|
|
20
|
+
htmlInput: { maxLength },
|
|
21
|
+
input: {
|
|
22
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: _jsx(IconButton, { edge: "end", onClick: () => {
|
|
23
|
+
const input = localRef.current;
|
|
24
|
+
if (input == null)
|
|
25
|
+
return;
|
|
26
|
+
onEdit(input);
|
|
27
|
+
}, children: _jsx(EditIcon, {}) }) }))
|
|
28
|
+
}
|
|
29
|
+
}, label: label, multiline: true, rows: rows, ...rest }));
|
|
30
|
+
}
|
|
@@ -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/lib/mjs/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export * from "./GridDataFormat";
|
|
|
73
73
|
export * from "./GridUtils";
|
|
74
74
|
export * from "./HiSelector";
|
|
75
75
|
export * from "./HiSelectorTL";
|
|
76
|
+
export * from "./HtmlDescriptionBase";
|
|
76
77
|
export * from "./IconButtonLink";
|
|
77
78
|
export * from "./ImagePreviewButton";
|
|
78
79
|
export * from "./InputField";
|
package/lib/mjs/index.js
CHANGED
|
@@ -73,6 +73,7 @@ export * from "./GridDataFormat";
|
|
|
73
73
|
export * from "./GridUtils";
|
|
74
74
|
export * from "./HiSelector";
|
|
75
75
|
export * from "./HiSelectorTL";
|
|
76
|
+
export * from "./HtmlDescriptionBase";
|
|
76
77
|
export * from "./IconButtonLink";
|
|
77
78
|
export * from "./ImagePreviewButton";
|
|
78
79
|
export * from "./InputField";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.79",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@etsoo/shared": "^1.2.87",
|
|
47
47
|
"@mui/icons-material": "^9.2.0",
|
|
48
48
|
"@mui/material": "^9.2.0",
|
|
49
|
-
"@mui/x-data-grid": "^9.
|
|
49
|
+
"@mui/x-data-grid": "^9.9.0",
|
|
50
50
|
"chart.js": "^4.5.1",
|
|
51
51
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
52
52
|
"dompurify": "^3.4.11",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@vitejs/plugin-react": "^6.0.3",
|
|
84
84
|
"jsdom": "^29.1.1",
|
|
85
85
|
"typescript": "^6.0.3",
|
|
86
|
-
"vitest": "^4.1.
|
|
86
|
+
"vitest": "^4.1.10"
|
|
87
87
|
},
|
|
88
88
|
"allowScripts": {
|
|
89
89
|
"core-js-pure@3.49.0": true
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InputField, InputFieldProps } from "./InputField";
|
|
3
|
+
import { useCombinedRefs } from "@etsoo/react";
|
|
4
|
+
import InputAdornment from "@mui/material/InputAdornment";
|
|
5
|
+
import IconButton from "@mui/material/IconButton";
|
|
6
|
+
import EditIcon from "@mui/icons-material/Edit";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* HTML Description component base props
|
|
10
|
+
* HTML 描述组件基础属性
|
|
11
|
+
*/
|
|
12
|
+
export type HtmlDescriptionBaseProps = Omit<InputFieldProps, "multiline"> & {
|
|
13
|
+
/**
|
|
14
|
+
* Maximum length of the input
|
|
15
|
+
* 输入的最大长度
|
|
16
|
+
*/
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Edit handler
|
|
21
|
+
* 编辑处理器
|
|
22
|
+
*/
|
|
23
|
+
onEdit: (input: HTMLInputElement) => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* HTML Description component base
|
|
28
|
+
* HTML 描述组件属性基础
|
|
29
|
+
* @param props Props
|
|
30
|
+
* @returns Component
|
|
31
|
+
*/
|
|
32
|
+
export function HtmlDescriptionBase(props: HtmlDescriptionBaseProps) {
|
|
33
|
+
// Destruct
|
|
34
|
+
const {
|
|
35
|
+
fullWidth = true,
|
|
36
|
+
inputRef,
|
|
37
|
+
label,
|
|
38
|
+
maxLength = 1280,
|
|
39
|
+
name = "description",
|
|
40
|
+
onEdit,
|
|
41
|
+
rows = 3,
|
|
42
|
+
...rest
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
45
|
+
const localRef = React.useRef<HTMLInputElement>(null);
|
|
46
|
+
const refs = useCombinedRefs(localRef, inputRef);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<InputField
|
|
50
|
+
fullWidth={fullWidth}
|
|
51
|
+
inputRef={refs}
|
|
52
|
+
name={name}
|
|
53
|
+
slotProps={{
|
|
54
|
+
htmlInput: { maxLength },
|
|
55
|
+
input: {
|
|
56
|
+
endAdornment: (
|
|
57
|
+
<InputAdornment position="end">
|
|
58
|
+
<IconButton
|
|
59
|
+
edge="end"
|
|
60
|
+
onClick={() => {
|
|
61
|
+
const input = localRef.current;
|
|
62
|
+
if (input == null) return;
|
|
63
|
+
|
|
64
|
+
onEdit(input);
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<EditIcon />
|
|
68
|
+
</IconButton>
|
|
69
|
+
</InputAdornment>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
}}
|
|
73
|
+
label={label}
|
|
74
|
+
multiline
|
|
75
|
+
rows={rows}
|
|
76
|
+
{...rest}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -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,
|
package/src/index.ts
CHANGED
|
@@ -80,6 +80,7 @@ export * from "./GridDataFormat";
|
|
|
80
80
|
export * from "./GridUtils";
|
|
81
81
|
export * from "./HiSelector";
|
|
82
82
|
export * from "./HiSelectorTL";
|
|
83
|
+
export * from "./HtmlDescriptionBase";
|
|
83
84
|
export * from "./IconButtonLink";
|
|
84
85
|
export * from "./ImagePreviewButton";
|
|
85
86
|
export * from "./InputField";
|