@vtx/components 2.3.4 → 2.4.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [2.4.0](https://git.cloudhw.cn:3443/front-end/react-components/compare/2.3.4...2.4.0) (2021-09-18)
2
+
3
+
4
+ ### ✨ Features
5
+
6
+ * 新增VtxSignature签名组件 ([9019271](https://git.cloudhw.cn:3443/front-end/react-components/commit/9019271)) by: **gongjinhua**
7
+
8
+
9
+
1
10
  ## [2.3.4](https://git.cloudhw.cn:3443/front-end/react-components/compare/2.3.3...2.3.4) (2021-09-16)
2
11
 
3
12
 
@@ -6,6 +15,11 @@
6
15
  * 数据表格下拉框VtxCombogrid支持主动触发刷新接口数据 ([3c48177](https://git.cloudhw.cn:3443/front-end/react-components/commit/3c48177)) by: **gongjinhua**
7
16
 
8
17
 
18
+ ### 🎫 Chores
19
+
20
+ * release v2.3.4 ([8822b97](https://git.cloudhw.cn:3443/front-end/react-components/commit/8822b97)) by: **gongjinhua**
21
+
22
+
9
23
  ### 🐛 Bug Fixes
10
24
 
11
25
  * 文本域VtxInput.TextArea修复设置默认值为null或undefined时已输入数显示错误的问题 ([4b5d294](https://git.cloudhw.cn:3443/front-end/react-components/commit/4b5d294)) by: **gongjinhua**
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _signature_pad = _interopRequireDefault(require("signature_pad"));
13
+
14
+ var _button = _interopRequireDefault(require("antd/es/button"));
15
+
16
+ var _lodash = _interopRequireDefault(require("lodash.debounce"));
17
+
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
+
22
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
23
+
24
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ var VtxSignature = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
27
+ var canvasRef = (0, _react.useRef)();
28
+ var signaturePad = (0, _react.useRef)();
29
+ var dotSize = props.dotSize,
30
+ minWidth = props.minWidth,
31
+ maxWidth = props.maxWidth,
32
+ throttle = props.throttle,
33
+ minDistance = props.minDistance,
34
+ backgroundColor = props.backgroundColor,
35
+ penColor = props.penColor,
36
+ velocityFilterWeight = props.velocityFilterWeight,
37
+ onBegin = props.onBegin,
38
+ _onEnd = props.onEnd,
39
+ onChange = props.onChange;
40
+ (0, _react.useEffect)(function () {
41
+ signaturePad.current = new _signature_pad["default"](canvasRef.current, {
42
+ dotSize: dotSize,
43
+ minWidth: minWidth,
44
+ maxWidth: maxWidth,
45
+ throttle: throttle,
46
+ minDistance: minDistance,
47
+ backgroundColor: backgroundColor,
48
+ penColor: penColor,
49
+ velocityFilterWeight: velocityFilterWeight,
50
+ onBegin: onBegin,
51
+ onEnd: function onEnd() {
52
+ var dataUri = signaturePad.current.toDataURL();
53
+ var encodedImage = dataUri.split(',')[1];
54
+ onChange && onChange(encodedImage);
55
+ _onEnd && _onEnd();
56
+ }
57
+ });
58
+ resizeCanvas();
59
+ window.addEventListener('resize', (0, _lodash["default"])(resizeCanvas, 150));
60
+ return function () {
61
+ window.removeEventListener('resize', (0, _lodash["default"])(resizeCanvas, 150));
62
+ };
63
+ }, []);
64
+
65
+ function resizeCanvas() {
66
+ var ratio = Math.max(window.devicePixelRatio || 1, 1);
67
+ var canvas = canvasRef.current;
68
+
69
+ if (canvas) {
70
+ canvas.width = canvas.offsetWidth * ratio;
71
+ canvas.height = canvas.offsetHeight * ratio;
72
+ canvas.getContext('2d').scale(ratio, ratio);
73
+ clear();
74
+ }
75
+ } // 清空
76
+
77
+
78
+ var clear = function clear() {
79
+ signaturePad.current.clear();
80
+ }; // 撤销
81
+
82
+
83
+ var undo = function undo() {
84
+ var data = signaturePad.current.toData();
85
+
86
+ if (data) {
87
+ data.pop();
88
+ signaturePad.current.fromData(data);
89
+ }
90
+ };
91
+
92
+ return /*#__PURE__*/_react["default"].createElement("div", {
93
+ className: "vtx-signature",
94
+ ref: ref
95
+ }, /*#__PURE__*/_react["default"].createElement("div", {
96
+ className: "vtx-signature--body"
97
+ }, /*#__PURE__*/_react["default"].createElement("canvas", {
98
+ ref: canvasRef
99
+ })), /*#__PURE__*/_react["default"].createElement("div", {
100
+ className: "vtx-signature--footer"
101
+ }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
102
+ size: "small",
103
+ onClick: clear
104
+ }, "\u6E05\u7A7A"), /*#__PURE__*/_react["default"].createElement(_button["default"], {
105
+ size: "small",
106
+ onClick: undo
107
+ }, "\u64A4\u9500")));
108
+ });
109
+ var _default = VtxSignature;
110
+ exports["default"] = _default;
111
+ VtxSignature.propTypes = {
112
+ dotSize: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].number]),
113
+ minWidth: _propTypes["default"].number,
114
+ maxWidth: _propTypes["default"].number,
115
+ throttle: _propTypes["default"].number,
116
+ minDistance: _propTypes["default"].number,
117
+ backgroundColor: _propTypes["default"].string,
118
+ penColor: _propTypes["default"].string,
119
+ velocityFilterWeight: _propTypes["default"].number,
120
+ onBegin: _propTypes["default"].func,
121
+ onEnd: _propTypes["default"].func,
122
+ onChange: _propTypes["default"].func
123
+ };
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["vtx-signature/index.jsx"],"names":["VtxSignature","props","ref","canvasRef","signaturePad","dotSize","minWidth","maxWidth","throttle","minDistance","backgroundColor","penColor","velocityFilterWeight","onBegin","onEnd","onChange","current","SignaturePad","dataUri","toDataURL","encodedImage","split","resizeCanvas","window","addEventListener","removeEventListener","ratio","Math","max","devicePixelRatio","canvas","width","offsetWidth","height","offsetHeight","getContext","scale","clear","undo","data","toData","pop","fromData","propTypes","PropTypes","oneOfType","func","number","string"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,YAAY,gBAAG,uBAAW,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAC5C,MAAMC,SAAS,GAAG,oBAAlB;AACA,MAAMC,YAAY,GAAG,oBAArB;AAF4C,MAIxCC,OAJwC,GAexCJ,KAfwC,CAIxCI,OAJwC;AAAA,MAKxCC,QALwC,GAexCL,KAfwC,CAKxCK,QALwC;AAAA,MAMxCC,QANwC,GAexCN,KAfwC,CAMxCM,QANwC;AAAA,MAOxCC,QAPwC,GAexCP,KAfwC,CAOxCO,QAPwC;AAAA,MAQxCC,WARwC,GAexCR,KAfwC,CAQxCQ,WARwC;AAAA,MASxCC,eATwC,GAexCT,KAfwC,CASxCS,eATwC;AAAA,MAUxCC,QAVwC,GAexCV,KAfwC,CAUxCU,QAVwC;AAAA,MAWxCC,oBAXwC,GAexCX,KAfwC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,GAAyB;AACrBtC,EAAAA,OAAO,EAAEuC,sBAAUC,SAAV,CAAoB,CAACD,sBAAUE,IAAX,EAAiBF,sBAAUG,MAA3B,CAApB,CADY;AAErBzC,EAAAA,QAAQ,EAAEsC,sBAAUG,MAFC;AAGrBxC,EAAAA,QAAQ,EAAEqC,sBAAUG,MAHC;AAIrBvC,EAAAA,QAAQ,EAAEoC,sBAAUG,MAJC;AAKrBtC,EAAAA,WAAW,EAAEmC,sBAAUG,MALF;AAMrBrC,EAAAA,eAAe,EAAEkC,sBAAUI,MANN;AAOrBrC,EAAAA,QAAQ,EAAEiC,sBAAUI,MAPC;AAQrBpC,EAAAA,oBAAoB,EAAEgC,sBAAUG,MARX;AASrBlC,EAAAA,OAAO,EAAE+B,sBAAUE,IATE;AAUrBhC,EAAAA,KAAK,EAAE8B,sBAAUE,IAVI;AAWrB/B,EAAAA,QAAQ,EAAE6B,sBAAUE;AAXC,CAAzB","sourcesContent":["import React, { forwardRef, useRef, useEffect } from 'react';\nimport SignaturePad from 'signature_pad';\nimport Button from 'antd/es/button';\nimport debounce from 'lodash.debounce';\nimport PropTypes from 'prop-types';\n\nconst VtxSignature = forwardRef((props, ref) => {\n const canvasRef = useRef();\n const signaturePad = useRef();\n const {\n dotSize,\n minWidth,\n maxWidth,\n throttle,\n minDistance,\n backgroundColor,\n penColor,\n velocityFilterWeight,\n onBegin,\n onEnd,\n onChange,\n } = props;\n\n useEffect(() => {\n signaturePad.current = new SignaturePad(canvasRef.current, {\n dotSize,\n minWidth,\n maxWidth,\n throttle,\n minDistance,\n backgroundColor,\n penColor,\n velocityFilterWeight,\n onBegin,\n onEnd() {\n const dataUri = signaturePad.current.toDataURL();\n const encodedImage = dataUri.split(',')[1];\n\n onChange && onChange(encodedImage);\n onEnd && onEnd();\n },\n });\n resizeCanvas();\n window.addEventListener('resize', debounce(resizeCanvas, 150));\n return () => {\n window.removeEventListener('resize', debounce(resizeCanvas, 150));\n };\n }, []);\n\n function resizeCanvas() {\n const ratio = Math.max(window.devicePixelRatio || 1, 1);\n const canvas = canvasRef.current;\n if (canvas) {\n canvas.width = canvas.offsetWidth * ratio;\n canvas.height = canvas.offsetHeight * ratio;\n canvas.getContext('2d').scale(ratio, ratio);\n clear();\n }\n }\n\n // 清空\n const clear = () => {\n signaturePad.current.clear();\n };\n\n // 撤销\n const undo = () => {\n const data = signaturePad.current.toData();\n if (data) {\n data.pop();\n signaturePad.current.fromData(data);\n }\n };\n\n return (\n <div className=\"vtx-signature\" ref={ref}>\n <div className=\"vtx-signature--body\">\n <canvas ref={canvasRef} />\n </div>\n <div className=\"vtx-signature--footer\">\n <Button size=\"small\" onClick={clear}>\n 清空\n </Button>\n <Button size=\"small\" onClick={undo}>\n 撤销\n </Button>\n </div>\n </div>\n );\n});\n\nexport default VtxSignature;\n\nVtxSignature.propTypes = {\n dotSize: PropTypes.oneOfType([PropTypes.func, PropTypes.number]),\n minWidth: PropTypes.number,\n maxWidth: PropTypes.number,\n throttle: PropTypes.number,\n minDistance: PropTypes.number,\n backgroundColor: PropTypes.string,\n penColor: PropTypes.string,\n velocityFilterWeight: PropTypes.number,\n onBegin: PropTypes.func,\n onEnd: PropTypes.func,\n onChange: PropTypes.func,\n};\n"],"file":"index.js"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ require("antd/es/button/style/css");
4
+
5
+ require("antd/es/message/style/css");
6
+
7
+ require("./index.css");
8
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["vtx-signature/style/index.js"],"names":[],"mappings":";;AAAA;;AACA;;AACA","sourcesContent":["import 'antd/es/button/style/css';\nimport 'antd/es/message/style/css';\nimport './index.less';\n"],"file":"css.js"}
@@ -0,0 +1,35 @@
1
+ .vtx-signature {
2
+ position: relative;
3
+ display: -webkit-box;
4
+ display: -ms-flexbox;
5
+ display: flex;
6
+ -webkit-box-orient: vertical;
7
+ -webkit-box-direction: normal;
8
+ -ms-flex-direction: column;
9
+ flex-direction: column;
10
+ height: 300px;
11
+ padding: 16px;
12
+ background-color: #fff;
13
+ border: 1px solid #f4f4f4;
14
+ border-radius: 4px;
15
+ }
16
+ .vtx-signature--body {
17
+ position: relative;
18
+ height: 100%;
19
+ border: 2px dotted #c1c1c1;
20
+ }
21
+ .vtx-signature--body canvas {
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ width: 100%;
26
+ height: 100%;
27
+ border-radius: 4px;
28
+ }
29
+ .vtx-signature--footer {
30
+ margin-top: 8px;
31
+ line-height: 1;
32
+ }
33
+ .vtx-signature--footer button + button {
34
+ margin-left: 8px;
35
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ require("antd/es/button/style/css");
4
+
5
+ require("antd/es/message/style/css");
6
+
7
+ require("./index.less");
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["vtx-signature/style/index.js"],"names":[],"mappings":";;AAAA;;AACA;;AACA","sourcesContent":["import 'antd/es/button/style/css';\nimport 'antd/es/message/style/css';\nimport './index.less';\n"],"file":"index.js"}
@@ -0,0 +1,32 @@
1
+ @prefix-cls: vtx-signature;
2
+
3
+ .@{prefix-cls} {
4
+ position: relative;
5
+ display: flex;
6
+ flex-direction: column;
7
+ height: 300px;
8
+ padding: 16px;
9
+ background-color: #fff;
10
+ border: 1px solid #f4f4f4;
11
+ border-radius: 4px;
12
+ &--body {
13
+ position: relative;
14
+ height: 100%;
15
+ border: 2px dotted #c1c1c1;
16
+ canvas {
17
+ position: absolute;
18
+ top: 0;
19
+ left: 0;
20
+ width: 100%;
21
+ height: 100%;
22
+ border-radius: 4px;
23
+ }
24
+ }
25
+ &--footer {
26
+ margin-top: 8px;
27
+ line-height: 1;
28
+ button + button {
29
+ margin-left: 8px;
30
+ }
31
+ }
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtx/components",
3
- "version": "2.3.4",
3
+ "version": "2.4.0",
4
4
  "description": "React components for Vortex",
5
5
  "keywords": [
6
6
  "react",
@@ -67,6 +67,7 @@
67
67
  "moment": "^2.29.1",
68
68
  "rc-color-picker": "^1.2.6",
69
69
  "react-resizable": "^1.11.1",
70
+ "signature_pad": "3.0.0-beta.4",
70
71
  "viewerjs": "1.3.3",
71
72
  "xgplayer": "2.18.3"
72
73
  },