@kne/react-pdf-sign 1.1.6 → 1.1.7
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/dist/img~cOOFcooA.png +0 -0
- package/dist/index.js +36 -10
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +36 -11
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var useControlValue = require('@kne/use-control-value');
|
|
|
13
13
|
var useRefCallback = require('@kne/use-ref-callback');
|
|
14
14
|
var useImage = require('use-image');
|
|
15
15
|
var reactIntl = require('@kne/react-intl');
|
|
16
|
+
var img = require('./img~cOOFcooA.png');
|
|
16
17
|
var pdfLib = require('pdf-lib');
|
|
17
18
|
var SignatureCanvas = require('react-signature-canvas');
|
|
18
19
|
var snapdom = require('@zumer/snapdom');
|
|
@@ -24,6 +25,7 @@ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
|
24
25
|
var useControlValue__default = /*#__PURE__*/_interopDefaultLegacy(useControlValue);
|
|
25
26
|
var useRefCallback__default = /*#__PURE__*/_interopDefaultLegacy(useRefCallback);
|
|
26
27
|
var useImage__default = /*#__PURE__*/_interopDefaultLegacy(useImage);
|
|
28
|
+
var img__default = /*#__PURE__*/_interopDefaultLegacy(img);
|
|
27
29
|
var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
|
|
28
30
|
|
|
29
31
|
function _extends() {
|
|
@@ -247,12 +249,15 @@ const LocationLayerInner = withLocale(p => {
|
|
|
247
249
|
onClick
|
|
248
250
|
} = p,
|
|
249
251
|
props = _objectWithoutPropertiesLoose(p, _excluded$3);
|
|
252
|
+
const [textWidth, setTextWidth] = react.useState(0);
|
|
250
253
|
const [value, setValue] = useControlValue__default["default"](props);
|
|
251
254
|
const [isInit, setIsInit] = react.useState(false);
|
|
252
255
|
const [signatureImage] = useImage__default["default"](signature);
|
|
256
|
+
const [iconImage] = useImage__default["default"](img__default["default"]);
|
|
253
257
|
const groupRef = react.useRef();
|
|
254
258
|
const signRef = react.useRef();
|
|
255
259
|
const transformerRef = react.useRef();
|
|
260
|
+
const textRef = react.useRef();
|
|
256
261
|
const computedSignLocation = () => {
|
|
257
262
|
const absolutePosition = signRef.current.absolutePosition();
|
|
258
263
|
const size = signRef.current.getClientRect();
|
|
@@ -296,11 +301,29 @@ const LocationLayerInner = withLocale(p => {
|
|
|
296
301
|
transformerRef.current.nodes([groupRef.current]);
|
|
297
302
|
}
|
|
298
303
|
}, [isInit]);
|
|
304
|
+
react.useEffect(() => {
|
|
305
|
+
if (isInit && textRef.current) {
|
|
306
|
+
setTextWidth(textRef.current.width());
|
|
307
|
+
}
|
|
308
|
+
}, [isInit, placeholder]);
|
|
299
309
|
if (!(isInit && value)) {
|
|
300
310
|
return null;
|
|
301
311
|
}
|
|
312
|
+
const textX = value.x + width * value.scaleX / 2 - textWidth / 2;
|
|
313
|
+
const textY = value.y + height * value.scaleY / 2 - 8;
|
|
302
314
|
return /*#__PURE__*/jsxRuntime.jsxs(reactKonva.Layer, {
|
|
303
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(reactKonva.
|
|
315
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
316
|
+
x: value.x,
|
|
317
|
+
y: value.y,
|
|
318
|
+
width: width * value.scaleX,
|
|
319
|
+
height: height * value.scaleY,
|
|
320
|
+
stroke: themeColor,
|
|
321
|
+
strokeWidth: 1,
|
|
322
|
+
dashEnabled: true,
|
|
323
|
+
cornerRadius: 8,
|
|
324
|
+
ref: signRef,
|
|
325
|
+
dash: [5, 5]
|
|
326
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Group, {
|
|
304
327
|
x: value.x,
|
|
305
328
|
y: value.y,
|
|
306
329
|
draggable: active !== false,
|
|
@@ -322,22 +345,25 @@ const LocationLayerInner = withLocale(p => {
|
|
|
322
345
|
}) : /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
323
346
|
width: width,
|
|
324
347
|
height: height,
|
|
325
|
-
fill: "#f0f0f0",
|
|
326
|
-
cornerRadius: 8,
|
|
327
348
|
ref: signRef
|
|
328
349
|
})
|
|
329
|
-
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.
|
|
350
|
+
}), !signatureImage ? /*#__PURE__*/jsxRuntime.jsx(reactKonva.Image, {
|
|
351
|
+
x: textX - 24,
|
|
352
|
+
y: textY,
|
|
353
|
+
width: 16,
|
|
354
|
+
height: 16,
|
|
355
|
+
image: iconImage
|
|
356
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx(reactKonva.Text, {
|
|
357
|
+
ref: textRef,
|
|
330
358
|
listening: false,
|
|
331
|
-
x:
|
|
332
|
-
y:
|
|
359
|
+
x: textX,
|
|
360
|
+
y: textY,
|
|
333
361
|
text: signatureImage ? '' : placeholder,
|
|
334
362
|
fontSize: 16,
|
|
335
|
-
fill:
|
|
363
|
+
fill: themeColor,
|
|
336
364
|
fontFamily: "Arial",
|
|
337
365
|
align: "center",
|
|
338
|
-
verticalAlign: "middle"
|
|
339
|
-
width: width * value.scaleX,
|
|
340
|
-
height: height * value.scaleY
|
|
366
|
+
verticalAlign: "middle"
|
|
341
367
|
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Transformer, {
|
|
342
368
|
ref: transformerRef,
|
|
343
369
|
visible: active !== false,
|