@kne/react-pdf-sign 1.0.6 → 1.1.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/README.md +287 -48
- package/dist/index.js +554 -657
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +393 -663
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +2 -1
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +2 -1
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +2 -1
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +2 -1
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
47
47
|
|
|
48
48
|
var style = {"pdf-view-container":"_RgZXN","pdf-view":"_PAju1","pdf-view-children":"_N11Pj","pdf-view-page-control-left":"_IbVpf","pdf-view-page-control-right":"_IIgqj","pdf-view-page-control-current":"_JW3CT","signature-container":"_6TDb-","signature-canvas":"_2CGF4","signature-modal":"_kWe3k","signature-mask":"_FSvLv"};
|
|
49
49
|
|
|
50
|
-
const _excluded$
|
|
50
|
+
const _excluded$4 = ["numPages"];
|
|
51
51
|
const PDFViewer = _ref => {
|
|
52
52
|
var _apis$file;
|
|
53
53
|
let {
|
|
@@ -101,7 +101,7 @@ const PDFViewer = _ref => {
|
|
|
101
101
|
let {
|
|
102
102
|
numPages
|
|
103
103
|
} = _ref2;
|
|
104
|
-
_objectWithoutPropertiesLoose(_ref2, _excluded$
|
|
104
|
+
_objectWithoutPropertiesLoose(_ref2, _excluded$4);
|
|
105
105
|
setPageSize(numPages);
|
|
106
106
|
if (!Number.isInteger(defaultPage)) {
|
|
107
107
|
setCurrentPage(numPages);
|
|
@@ -156,7 +156,8 @@ const locale$1 = {
|
|
|
156
156
|
signatureCancelText: '取消',
|
|
157
157
|
signatureCleanText: '清空',
|
|
158
158
|
signatureEmptyError: '签名内容不能为空',
|
|
159
|
-
signatureSuccess: '签名成功'
|
|
159
|
+
signatureSuccess: '签名成功',
|
|
160
|
+
signatureAdd: '请添加签名'
|
|
160
161
|
};
|
|
161
162
|
|
|
162
163
|
const locale = {
|
|
@@ -167,7 +168,8 @@ const locale = {
|
|
|
167
168
|
signatureCancelText: 'Cancel',
|
|
168
169
|
signatureCleanText: 'Clean',
|
|
169
170
|
signatureEmptyError: 'Signature content cannot be empty',
|
|
170
|
-
signatureSuccess: 'Signature Success'
|
|
171
|
+
signatureSuccess: 'Signature Success',
|
|
172
|
+
signatureAdd: 'Please add signature'
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
const withLocale = reactIntl.createWithIntlProvider({
|
|
@@ -179,8 +181,30 @@ const withLocale = reactIntl.createWithIntlProvider({
|
|
|
179
181
|
namespace: 'react-pdf-sign'
|
|
180
182
|
});
|
|
181
183
|
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
+
const getInitLocation = ({
|
|
185
|
+
stageWidth,
|
|
186
|
+
stageHeight,
|
|
187
|
+
width,
|
|
188
|
+
height
|
|
189
|
+
}) => {
|
|
190
|
+
return {
|
|
191
|
+
scaleX: 1,
|
|
192
|
+
scaleY: 1,
|
|
193
|
+
x: Math.round((stageWidth - width) / 2),
|
|
194
|
+
y: Math.round((stageHeight - height) / 2),
|
|
195
|
+
size: {
|
|
196
|
+
width,
|
|
197
|
+
height,
|
|
198
|
+
x: Math.round((stageWidth - width) / 2),
|
|
199
|
+
y: Math.round((stageHeight - height) / 2)
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const _excluded$3 = ["width", "height", "padding", "stageWidth", "stageHeight", "placeholder", "signature", "active", "onClose", "onClick"],
|
|
205
|
+
_excluded2 = ["stageWidth", "stageHeight"],
|
|
206
|
+
_excluded3 = ["stageWidth", "stageHeight", "isEdit", "onClick", "currentPage"];
|
|
207
|
+
const LocationLayerInner = withLocale(p => {
|
|
184
208
|
const {
|
|
185
209
|
formatMessage
|
|
186
210
|
} = reactIntl.useIntl();
|
|
@@ -193,9 +217,12 @@ const LocationLayer = withLocale(p => {
|
|
|
193
217
|
placeholder = formatMessage({
|
|
194
218
|
id: 'locationLayerPlaceholder'
|
|
195
219
|
}),
|
|
196
|
-
signature
|
|
220
|
+
signature,
|
|
221
|
+
active,
|
|
222
|
+
onClose,
|
|
223
|
+
onClick
|
|
197
224
|
} = p,
|
|
198
|
-
props = _objectWithoutPropertiesLoose(p, _excluded$
|
|
225
|
+
props = _objectWithoutPropertiesLoose(p, _excluded$3);
|
|
199
226
|
const [value, setValue] = useControlValue__default["default"](props);
|
|
200
227
|
const [isInit, setIsInit] = react.useState(false);
|
|
201
228
|
const [signatureImage] = useImage__default["default"](signature);
|
|
@@ -205,7 +232,7 @@ const LocationLayer = withLocale(p => {
|
|
|
205
232
|
const computedSignLocation = () => {
|
|
206
233
|
const absolutePosition = signRef.current.absolutePosition();
|
|
207
234
|
const size = signRef.current.getClientRect();
|
|
208
|
-
setValue({
|
|
235
|
+
setValue(value => Object.assign({}, value, {
|
|
209
236
|
size: {
|
|
210
237
|
width: Math.round(size.width),
|
|
211
238
|
height: Math.round(size.height),
|
|
@@ -216,22 +243,16 @@ const LocationLayer = withLocale(p => {
|
|
|
216
243
|
scaleY: Number(groupRef.current.attrs.scaleY.toFixed(2)),
|
|
217
244
|
x: Math.round(groupRef.current.attrs.x),
|
|
218
245
|
y: Math.round(groupRef.current.attrs.y)
|
|
219
|
-
});
|
|
246
|
+
}));
|
|
220
247
|
};
|
|
221
248
|
const initValue = useRefCallback__default["default"](() => {
|
|
222
249
|
if (['scaleX', 'scaleY', 'x', 'y', 'size'].some(name => !Object.assign({}, value).hasOwnProperty(name))) {
|
|
223
|
-
setValue({
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
width,
|
|
230
|
-
height,
|
|
231
|
-
x: Math.round((stageWidth - width) / 2),
|
|
232
|
-
y: Math.round((stageHeight - height) / 2)
|
|
233
|
-
}
|
|
234
|
-
});
|
|
250
|
+
setValue(value => Object.assign({}, value, getInitLocation({
|
|
251
|
+
stageWidth,
|
|
252
|
+
stageHeight,
|
|
253
|
+
width,
|
|
254
|
+
height
|
|
255
|
+
})));
|
|
235
256
|
}
|
|
236
257
|
setIsInit(true);
|
|
237
258
|
});
|
|
@@ -254,607 +275,354 @@ const LocationLayer = withLocale(p => {
|
|
|
254
275
|
if (!(isInit && value)) {
|
|
255
276
|
return null;
|
|
256
277
|
}
|
|
278
|
+
return /*#__PURE__*/jsxRuntime.jsxs(reactKonva.Layer, {
|
|
279
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(reactKonva.Group, {
|
|
280
|
+
x: value.x,
|
|
281
|
+
y: value.y,
|
|
282
|
+
draggable: active !== false,
|
|
283
|
+
ref: groupRef,
|
|
284
|
+
onDragMove: computedSignLocation,
|
|
285
|
+
onDragEnd: computedSignLocation,
|
|
286
|
+
scaleX: value.scaleX,
|
|
287
|
+
scaleY: value.scaleY,
|
|
288
|
+
onTransform: computedSignLocation,
|
|
289
|
+
onTransformEnd: computedSignLocation,
|
|
290
|
+
onTap: onClick,
|
|
291
|
+
onClick: onClick,
|
|
292
|
+
children: signatureImage ? /*#__PURE__*/jsxRuntime.jsx(reactKonva.Image, {
|
|
293
|
+
width: width,
|
|
294
|
+
height: height,
|
|
295
|
+
image: signatureImage,
|
|
296
|
+
cornerRadius: 8,
|
|
297
|
+
ref: signRef
|
|
298
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(reactKonva.Rect, {
|
|
299
|
+
width: width,
|
|
300
|
+
height: height,
|
|
301
|
+
fill: "#f0f0f0",
|
|
302
|
+
cornerRadius: 8,
|
|
303
|
+
ref: signRef
|
|
304
|
+
})
|
|
305
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Text, {
|
|
306
|
+
listening: false,
|
|
307
|
+
x: value.x,
|
|
308
|
+
y: value.y,
|
|
309
|
+
text: signatureImage ? '' : placeholder,
|
|
310
|
+
fontSize: 16,
|
|
311
|
+
fill: "#666666",
|
|
312
|
+
fontFamily: "Arial",
|
|
313
|
+
align: "center",
|
|
314
|
+
verticalAlign: "middle",
|
|
315
|
+
width: width * value.scaleX,
|
|
316
|
+
height: height * value.scaleY
|
|
317
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Transformer, {
|
|
318
|
+
ref: transformerRef,
|
|
319
|
+
visible: active !== false,
|
|
320
|
+
keepRatio: true,
|
|
321
|
+
flipEnabled: false,
|
|
322
|
+
rotateEnabled: false,
|
|
323
|
+
borderStroke: themeColor,
|
|
324
|
+
rotateAnchorStroke: themeColor,
|
|
325
|
+
anchorStroke: themeColor,
|
|
326
|
+
padding: padding
|
|
327
|
+
}), active === true && /*#__PURE__*/jsxRuntime.jsxs(reactKonva.Group, {
|
|
328
|
+
x: value.x + width * value.scaleX - 4,
|
|
329
|
+
y: value.y + 4,
|
|
330
|
+
onClick: () => {
|
|
331
|
+
onClose && onClose();
|
|
332
|
+
},
|
|
333
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(reactKonva.Circle, {
|
|
334
|
+
radius: 6,
|
|
335
|
+
stroke: themeColor,
|
|
336
|
+
strokeWidth: 1,
|
|
337
|
+
fill: "white"
|
|
338
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Line, {
|
|
339
|
+
points: [-2, -2, 2, 2],
|
|
340
|
+
stroke: themeColor,
|
|
341
|
+
strokeWidth: 1,
|
|
342
|
+
lineCap: "round"
|
|
343
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactKonva.Line, {
|
|
344
|
+
points: [-2, 2, 2, -2],
|
|
345
|
+
stroke: themeColor,
|
|
346
|
+
strokeWidth: 1,
|
|
347
|
+
lineCap: "round"
|
|
348
|
+
})]
|
|
349
|
+
})]
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
const LocationLayer = _ref => {
|
|
353
|
+
let {
|
|
354
|
+
stageWidth,
|
|
355
|
+
stageHeight
|
|
356
|
+
} = _ref,
|
|
357
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
257
358
|
return /*#__PURE__*/jsxRuntime.jsx(reactKonva.Stage, {
|
|
258
359
|
width: stageWidth,
|
|
259
360
|
height: stageHeight,
|
|
260
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
361
|
+
children: /*#__PURE__*/jsxRuntime.jsx(LocationLayerInner, _extends({}, props, {
|
|
362
|
+
stageWidth: stageWidth,
|
|
363
|
+
stageHeight: stageHeight
|
|
364
|
+
}))
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
const LocationGroup = _ref2 => {
|
|
368
|
+
let {
|
|
369
|
+
stageWidth,
|
|
370
|
+
stageHeight,
|
|
371
|
+
isEdit = true,
|
|
372
|
+
onClick,
|
|
373
|
+
currentPage
|
|
374
|
+
} = _ref2,
|
|
375
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
376
|
+
const [value, onChange] = useControlValue__default["default"](Object.assign({}, {
|
|
377
|
+
defaultValue: []
|
|
378
|
+
}, props));
|
|
379
|
+
const [active, setActive] = react.useState(0);
|
|
380
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactKonva.Stage, {
|
|
381
|
+
width: stageWidth,
|
|
382
|
+
height: stageHeight,
|
|
383
|
+
children: value.map((item, index) => {
|
|
384
|
+
if (item.page && item.page !== currentPage) {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
return /*#__PURE__*/react.createElement(LocationLayerInner, _extends({}, props, {
|
|
388
|
+
key: index,
|
|
389
|
+
stageWidth: stageWidth,
|
|
390
|
+
stageHeight: stageHeight,
|
|
391
|
+
value: item,
|
|
392
|
+
signature: item.signature,
|
|
393
|
+
active: isEdit && active === index,
|
|
394
|
+
onClick: () => {
|
|
395
|
+
if (isEdit) {
|
|
396
|
+
if (active !== index) {
|
|
397
|
+
setActive(index);
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
onClick && onClick({
|
|
401
|
+
value: value[index],
|
|
402
|
+
index,
|
|
403
|
+
allValue: value
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
onClose: () => {
|
|
408
|
+
onChange(value => {
|
|
409
|
+
const newValue = value.slice(0);
|
|
410
|
+
newValue.splice(index, 1);
|
|
411
|
+
return newValue;
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
onChange: item => {
|
|
415
|
+
onChange(value => {
|
|
416
|
+
const newValue = value.slice(0);
|
|
417
|
+
newValue[index] = item;
|
|
418
|
+
return newValue;
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}));
|
|
302
422
|
})
|
|
303
423
|
});
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
307
|
-
|
|
308
|
-
function createCommonjsModule(fn) {
|
|
309
|
-
var module = { exports: {} };
|
|
310
|
-
return fn(module, module.exports), module.exports;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/** Detect free variable `global` from Node.js. */
|
|
314
|
-
|
|
315
|
-
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
316
|
-
|
|
317
|
-
var _freeGlobal = freeGlobal;
|
|
318
|
-
|
|
319
|
-
/** Detect free variable `self`. */
|
|
320
|
-
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
321
|
-
|
|
322
|
-
/** Used as a reference to the global object. */
|
|
323
|
-
var root = _freeGlobal || freeSelf || Function('return this')();
|
|
324
|
-
|
|
325
|
-
var _root = root;
|
|
326
|
-
|
|
327
|
-
/** Built-in value references. */
|
|
328
|
-
var Symbol = _root.Symbol;
|
|
329
|
-
|
|
330
|
-
var _Symbol = Symbol;
|
|
331
|
-
|
|
332
|
-
/** Used for built-in method references. */
|
|
333
|
-
var objectProto$3 = Object.prototype;
|
|
334
|
-
|
|
335
|
-
/** Used to check objects for own properties. */
|
|
336
|
-
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Used to resolve the
|
|
340
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
341
|
-
* of values.
|
|
342
|
-
*/
|
|
343
|
-
var nativeObjectToString$1 = objectProto$3.toString;
|
|
344
|
-
|
|
345
|
-
/** Built-in value references. */
|
|
346
|
-
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
350
|
-
*
|
|
351
|
-
* @private
|
|
352
|
-
* @param {*} value The value to query.
|
|
353
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
354
|
-
*/
|
|
355
|
-
function getRawTag(value) {
|
|
356
|
-
var isOwn = hasOwnProperty$2.call(value, symToStringTag$1),
|
|
357
|
-
tag = value[symToStringTag$1];
|
|
358
|
-
|
|
359
|
-
try {
|
|
360
|
-
value[symToStringTag$1] = undefined;
|
|
361
|
-
var unmasked = true;
|
|
362
|
-
} catch (e) {}
|
|
424
|
+
};
|
|
363
425
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
426
|
+
const _iteratorSymbol = typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
|
|
427
|
+
function _settle(pact, state, value) {
|
|
428
|
+
if (!pact.s) {
|
|
429
|
+
if (value instanceof _Pact) {
|
|
430
|
+
if (value.s) {
|
|
431
|
+
if (state & 1) {
|
|
432
|
+
state = value.s;
|
|
433
|
+
}
|
|
434
|
+
value = value.v;
|
|
435
|
+
} else {
|
|
436
|
+
value.o = _settle.bind(null, pact, state);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (value && value.then) {
|
|
441
|
+
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
pact.s = state;
|
|
445
|
+
pact.v = value;
|
|
446
|
+
const observer = pact.o;
|
|
447
|
+
if (observer) {
|
|
448
|
+
observer(pact);
|
|
370
449
|
}
|
|
371
450
|
}
|
|
372
|
-
return result;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
var _getRawTag = getRawTag;
|
|
376
|
-
|
|
377
|
-
/** Used for built-in method references. */
|
|
378
|
-
var objectProto$2 = Object.prototype;
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Used to resolve the
|
|
382
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
383
|
-
* of values.
|
|
384
|
-
*/
|
|
385
|
-
var nativeObjectToString = objectProto$2.toString;
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Converts `value` to a string using `Object.prototype.toString`.
|
|
389
|
-
*
|
|
390
|
-
* @private
|
|
391
|
-
* @param {*} value The value to convert.
|
|
392
|
-
* @returns {string} Returns the converted string.
|
|
393
|
-
*/
|
|
394
|
-
function objectToString(value) {
|
|
395
|
-
return nativeObjectToString.call(value);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
var _objectToString = objectToString;
|
|
399
|
-
|
|
400
|
-
/** `Object#toString` result references. */
|
|
401
|
-
var nullTag = '[object Null]',
|
|
402
|
-
undefinedTag = '[object Undefined]';
|
|
403
|
-
|
|
404
|
-
/** Built-in value references. */
|
|
405
|
-
var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
409
|
-
*
|
|
410
|
-
* @private
|
|
411
|
-
* @param {*} value The value to query.
|
|
412
|
-
* @returns {string} Returns the `toStringTag`.
|
|
413
|
-
*/
|
|
414
|
-
function baseGetTag(value) {
|
|
415
|
-
if (value == null) {
|
|
416
|
-
return value === undefined ? undefinedTag : nullTag;
|
|
417
|
-
}
|
|
418
|
-
return (symToStringTag && symToStringTag in Object(value))
|
|
419
|
-
? _getRawTag(value)
|
|
420
|
-
: _objectToString(value);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
var _baseGetTag = baseGetTag;
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Checks if `value` is the
|
|
427
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
428
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
429
|
-
*
|
|
430
|
-
* @static
|
|
431
|
-
* @memberOf _
|
|
432
|
-
* @since 0.1.0
|
|
433
|
-
* @category Lang
|
|
434
|
-
* @param {*} value The value to check.
|
|
435
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
436
|
-
* @example
|
|
437
|
-
*
|
|
438
|
-
* _.isObject({});
|
|
439
|
-
* // => true
|
|
440
|
-
*
|
|
441
|
-
* _.isObject([1, 2, 3]);
|
|
442
|
-
* // => true
|
|
443
|
-
*
|
|
444
|
-
* _.isObject(_.noop);
|
|
445
|
-
* // => true
|
|
446
|
-
*
|
|
447
|
-
* _.isObject(null);
|
|
448
|
-
* // => false
|
|
449
|
-
*/
|
|
450
|
-
function isObject(value) {
|
|
451
|
-
var type = typeof value;
|
|
452
|
-
return value != null && (type == 'object' || type == 'function');
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
var isObject_1 = isObject;
|
|
456
|
-
|
|
457
|
-
/** `Object#toString` result references. */
|
|
458
|
-
var asyncTag = '[object AsyncFunction]',
|
|
459
|
-
funcTag = '[object Function]',
|
|
460
|
-
genTag = '[object GeneratorFunction]',
|
|
461
|
-
proxyTag = '[object Proxy]';
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Checks if `value` is classified as a `Function` object.
|
|
465
|
-
*
|
|
466
|
-
* @static
|
|
467
|
-
* @memberOf _
|
|
468
|
-
* @since 0.1.0
|
|
469
|
-
* @category Lang
|
|
470
|
-
* @param {*} value The value to check.
|
|
471
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
472
|
-
* @example
|
|
473
|
-
*
|
|
474
|
-
* _.isFunction(_);
|
|
475
|
-
* // => true
|
|
476
|
-
*
|
|
477
|
-
* _.isFunction(/abc/);
|
|
478
|
-
* // => false
|
|
479
|
-
*/
|
|
480
|
-
function isFunction(value) {
|
|
481
|
-
if (!isObject_1(value)) {
|
|
482
|
-
return false;
|
|
483
|
-
}
|
|
484
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
485
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
486
|
-
var tag = _baseGetTag(value);
|
|
487
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
488
451
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
452
|
+
const _Pact = /*#__PURE__*/function () {
|
|
453
|
+
function _Pact() {}
|
|
454
|
+
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
455
|
+
const result = new _Pact();
|
|
456
|
+
const state = this.s;
|
|
457
|
+
if (state) {
|
|
458
|
+
const callback = state & 1 ? onFulfilled : onRejected;
|
|
459
|
+
if (callback) {
|
|
460
|
+
try {
|
|
461
|
+
_settle(result, 1, callback(this.v));
|
|
462
|
+
} catch (e) {
|
|
463
|
+
_settle(result, 2, e);
|
|
464
|
+
}
|
|
465
|
+
return result;
|
|
466
|
+
} else {
|
|
467
|
+
return this;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
this.o = function (_this) {
|
|
471
|
+
try {
|
|
472
|
+
const value = _this.v;
|
|
473
|
+
if (_this.s & 1) {
|
|
474
|
+
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
475
|
+
} else if (onRejected) {
|
|
476
|
+
_settle(result, 1, onRejected(value));
|
|
477
|
+
} else {
|
|
478
|
+
_settle(result, 2, value);
|
|
479
|
+
}
|
|
480
|
+
} catch (e) {
|
|
481
|
+
_settle(result, 2, e);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
return result;
|
|
485
|
+
};
|
|
486
|
+
return _Pact;
|
|
487
|
+
}();
|
|
488
|
+
function _isSettledPact(thenable) {
|
|
489
|
+
return thenable instanceof _Pact && thenable.s & 1;
|
|
512
490
|
}
|
|
513
|
-
|
|
514
|
-
var
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
/** Used to resolve the decompiled source of functions. */
|
|
520
|
-
var funcToString$1 = funcProto$1.toString;
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Converts `func` to its source code.
|
|
524
|
-
*
|
|
525
|
-
* @private
|
|
526
|
-
* @param {Function} func The function to convert.
|
|
527
|
-
* @returns {string} Returns the source code.
|
|
528
|
-
*/
|
|
529
|
-
function toSource(func) {
|
|
530
|
-
if (func != null) {
|
|
531
|
-
try {
|
|
532
|
-
return funcToString$1.call(func);
|
|
533
|
-
} catch (e) {}
|
|
491
|
+
function _forTo(array, body, check) {
|
|
492
|
+
var i = -1,
|
|
493
|
+
pact,
|
|
494
|
+
reject;
|
|
495
|
+
function _cycle(result) {
|
|
534
496
|
try {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
objectProto$1 = Object.prototype;
|
|
555
|
-
|
|
556
|
-
/** Used to resolve the decompiled source of functions. */
|
|
557
|
-
var funcToString = funcProto.toString;
|
|
558
|
-
|
|
559
|
-
/** Used to check objects for own properties. */
|
|
560
|
-
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
561
|
-
|
|
562
|
-
/** Used to detect if a method is native. */
|
|
563
|
-
var reIsNative = RegExp('^' +
|
|
564
|
-
funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
|
|
565
|
-
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
566
|
-
);
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
570
|
-
*
|
|
571
|
-
* @private
|
|
572
|
-
* @param {*} value The value to check.
|
|
573
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
574
|
-
* else `false`.
|
|
575
|
-
*/
|
|
576
|
-
function baseIsNative(value) {
|
|
577
|
-
if (!isObject_1(value) || _isMasked(value)) {
|
|
578
|
-
return false;
|
|
497
|
+
while (++i < array.length && (!check || !check())) {
|
|
498
|
+
result = body(i);
|
|
499
|
+
if (result && result.then) {
|
|
500
|
+
if (_isSettledPact(result)) {
|
|
501
|
+
result = result.v;
|
|
502
|
+
} else {
|
|
503
|
+
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (pact) {
|
|
509
|
+
_settle(pact, 1, result);
|
|
510
|
+
} else {
|
|
511
|
+
pact = result;
|
|
512
|
+
}
|
|
513
|
+
} catch (e) {
|
|
514
|
+
_settle(pact || (pact = new _Pact()), 2, e);
|
|
515
|
+
}
|
|
579
516
|
}
|
|
580
|
-
|
|
581
|
-
return
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
var _baseIsNative = baseIsNative;
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Gets the value at `key` of `object`.
|
|
588
|
-
*
|
|
589
|
-
* @private
|
|
590
|
-
* @param {Object} [object] The object to query.
|
|
591
|
-
* @param {string} key The key of the property to get.
|
|
592
|
-
* @returns {*} Returns the property value.
|
|
593
|
-
*/
|
|
594
|
-
function getValue(object, key) {
|
|
595
|
-
return object == null ? undefined : object[key];
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
var _getValue = getValue;
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Gets the native function at `key` of `object`.
|
|
602
|
-
*
|
|
603
|
-
* @private
|
|
604
|
-
* @param {Object} object The object to query.
|
|
605
|
-
* @param {string} key The key of the method to get.
|
|
606
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
607
|
-
*/
|
|
608
|
-
function getNative(object, key) {
|
|
609
|
-
var value = _getValue(object, key);
|
|
610
|
-
return _baseIsNative(value) ? value : undefined;
|
|
517
|
+
_cycle();
|
|
518
|
+
return pact;
|
|
611
519
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
* // => true
|
|
640
|
-
*
|
|
641
|
-
* _.isObjectLike(_.noop);
|
|
642
|
-
* // => false
|
|
643
|
-
*
|
|
644
|
-
* _.isObjectLike(null);
|
|
645
|
-
* // => false
|
|
646
|
-
*/
|
|
647
|
-
function isObjectLike(value) {
|
|
648
|
-
return value != null && typeof value == 'object';
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
var isObjectLike_1 = isObjectLike;
|
|
652
|
-
|
|
653
|
-
/** `Object#toString` result references. */
|
|
654
|
-
var argsTag = '[object Arguments]';
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* The base implementation of `_.isArguments`.
|
|
658
|
-
*
|
|
659
|
-
* @private
|
|
660
|
-
* @param {*} value The value to check.
|
|
661
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
662
|
-
*/
|
|
663
|
-
function baseIsArguments(value) {
|
|
664
|
-
return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
var _baseIsArguments = baseIsArguments;
|
|
668
|
-
|
|
669
|
-
/** Used for built-in method references. */
|
|
670
|
-
var objectProto = Object.prototype;
|
|
671
|
-
|
|
672
|
-
/** Used to check objects for own properties. */
|
|
673
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
674
|
-
|
|
675
|
-
/** Built-in value references. */
|
|
676
|
-
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
* Checks if `value` is likely an `arguments` object.
|
|
680
|
-
*
|
|
681
|
-
* @static
|
|
682
|
-
* @memberOf _
|
|
683
|
-
* @since 0.1.0
|
|
684
|
-
* @category Lang
|
|
685
|
-
* @param {*} value The value to check.
|
|
686
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
687
|
-
* else `false`.
|
|
688
|
-
* @example
|
|
689
|
-
*
|
|
690
|
-
* _.isArguments(function() { return arguments; }());
|
|
691
|
-
* // => true
|
|
692
|
-
*
|
|
693
|
-
* _.isArguments([1, 2, 3]);
|
|
694
|
-
* // => false
|
|
695
|
-
*/
|
|
696
|
-
_baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
|
|
697
|
-
return isObjectLike_1(value) && hasOwnProperty.call(value, 'callee') &&
|
|
698
|
-
!propertyIsEnumerable.call(value, 'callee');
|
|
699
|
-
};
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* This method returns `false`.
|
|
703
|
-
*
|
|
704
|
-
* @static
|
|
705
|
-
* @memberOf _
|
|
706
|
-
* @since 4.13.0
|
|
707
|
-
* @category Util
|
|
708
|
-
* @returns {boolean} Returns `false`.
|
|
709
|
-
* @example
|
|
710
|
-
*
|
|
711
|
-
* _.times(2, _.stubFalse);
|
|
712
|
-
* // => [false, false]
|
|
713
|
-
*/
|
|
714
|
-
function stubFalse() {
|
|
715
|
-
return false;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
var stubFalse_1 = stubFalse;
|
|
719
|
-
|
|
720
|
-
createCommonjsModule(function (module, exports) {
|
|
721
|
-
/** Detect free variable `exports`. */
|
|
722
|
-
var freeExports = exports && !exports.nodeType && exports;
|
|
723
|
-
|
|
724
|
-
/** Detect free variable `module`. */
|
|
725
|
-
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
726
|
-
|
|
727
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
728
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
729
|
-
|
|
730
|
-
/** Built-in value references. */
|
|
731
|
-
var Buffer = moduleExports ? _root.Buffer : undefined;
|
|
732
|
-
|
|
733
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
734
|
-
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* Checks if `value` is a buffer.
|
|
738
|
-
*
|
|
739
|
-
* @static
|
|
740
|
-
* @memberOf _
|
|
741
|
-
* @since 4.3.0
|
|
742
|
-
* @category Lang
|
|
743
|
-
* @param {*} value The value to check.
|
|
744
|
-
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
745
|
-
* @example
|
|
746
|
-
*
|
|
747
|
-
* _.isBuffer(new Buffer(2));
|
|
748
|
-
* // => true
|
|
749
|
-
*
|
|
750
|
-
* _.isBuffer(new Uint8Array(2));
|
|
751
|
-
* // => false
|
|
752
|
-
*/
|
|
753
|
-
var isBuffer = nativeIsBuffer || stubFalse_1;
|
|
754
|
-
|
|
755
|
-
module.exports = isBuffer;
|
|
756
|
-
});
|
|
757
|
-
|
|
758
|
-
createCommonjsModule(function (module, exports) {
|
|
759
|
-
/** Detect free variable `exports`. */
|
|
760
|
-
var freeExports = exports && !exports.nodeType && exports;
|
|
761
|
-
|
|
762
|
-
/** Detect free variable `module`. */
|
|
763
|
-
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
764
|
-
|
|
765
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
766
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
767
|
-
|
|
768
|
-
/** Detect free variable `process` from Node.js. */
|
|
769
|
-
var freeProcess = moduleExports && _freeGlobal.process;
|
|
770
|
-
|
|
771
|
-
/** Used to access faster Node.js helpers. */
|
|
772
|
-
var nodeUtil = (function() {
|
|
773
|
-
try {
|
|
774
|
-
// Use `util.types` for Node.js 10+.
|
|
775
|
-
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
776
|
-
|
|
777
|
-
if (types) {
|
|
778
|
-
return types;
|
|
520
|
+
function _forOf(target, body, check) {
|
|
521
|
+
if (typeof target[_iteratorSymbol] === "function") {
|
|
522
|
+
var iterator = target[_iteratorSymbol](),
|
|
523
|
+
step,
|
|
524
|
+
pact,
|
|
525
|
+
reject;
|
|
526
|
+
function _cycle(result) {
|
|
527
|
+
try {
|
|
528
|
+
while (!(step = iterator.next()).done && (!check || !check())) {
|
|
529
|
+
result = body(step.value);
|
|
530
|
+
if (result && result.then) {
|
|
531
|
+
if (_isSettledPact(result)) {
|
|
532
|
+
result = result.v;
|
|
533
|
+
} else {
|
|
534
|
+
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (pact) {
|
|
540
|
+
_settle(pact, 1, result);
|
|
541
|
+
} else {
|
|
542
|
+
pact = result;
|
|
543
|
+
}
|
|
544
|
+
} catch (e) {
|
|
545
|
+
_settle(pact || (pact = new _Pact()), 2, e);
|
|
546
|
+
}
|
|
779
547
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
})
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
/* Built-in method references that are verified to be native. */
|
|
795
|
-
var Promise$1 = _getNative(_root, 'Promise');
|
|
796
|
-
|
|
797
|
-
var _Promise = Promise$1;
|
|
798
|
-
|
|
799
|
-
/* Built-in method references that are verified to be native. */
|
|
800
|
-
var Set = _getNative(_root, 'Set');
|
|
801
|
-
|
|
802
|
-
var _Set = Set;
|
|
803
|
-
|
|
804
|
-
/* Built-in method references that are verified to be native. */
|
|
805
|
-
var WeakMap = _getNative(_root, 'WeakMap');
|
|
806
|
-
|
|
807
|
-
var _WeakMap = WeakMap;
|
|
808
|
-
|
|
809
|
-
/** `Object#toString` result references. */
|
|
810
|
-
var mapTag = '[object Map]',
|
|
811
|
-
objectTag = '[object Object]',
|
|
812
|
-
promiseTag = '[object Promise]',
|
|
813
|
-
setTag = '[object Set]',
|
|
814
|
-
weakMapTag = '[object WeakMap]';
|
|
815
|
-
|
|
816
|
-
var dataViewTag = '[object DataView]';
|
|
817
|
-
|
|
818
|
-
/** Used to detect maps, sets, and weakmaps. */
|
|
819
|
-
var dataViewCtorString = _toSource(_DataView),
|
|
820
|
-
mapCtorString = _toSource(_Map),
|
|
821
|
-
promiseCtorString = _toSource(_Promise),
|
|
822
|
-
setCtorString = _toSource(_Set),
|
|
823
|
-
weakMapCtorString = _toSource(_WeakMap);
|
|
824
|
-
|
|
825
|
-
/**
|
|
826
|
-
* Gets the `toStringTag` of `value`.
|
|
827
|
-
*
|
|
828
|
-
* @private
|
|
829
|
-
* @param {*} value The value to query.
|
|
830
|
-
* @returns {string} Returns the `toStringTag`.
|
|
831
|
-
*/
|
|
832
|
-
var getTag = _baseGetTag;
|
|
833
|
-
|
|
834
|
-
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
835
|
-
if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
836
|
-
(_Map && getTag(new _Map) != mapTag) ||
|
|
837
|
-
(_Promise && getTag(_Promise.resolve()) != promiseTag) ||
|
|
838
|
-
(_Set && getTag(new _Set) != setTag) ||
|
|
839
|
-
(_WeakMap && getTag(new _WeakMap) != weakMapTag)) {
|
|
840
|
-
getTag = function(value) {
|
|
841
|
-
var result = _baseGetTag(value),
|
|
842
|
-
Ctor = result == objectTag ? value.constructor : undefined,
|
|
843
|
-
ctorString = Ctor ? _toSource(Ctor) : '';
|
|
844
|
-
|
|
845
|
-
if (ctorString) {
|
|
846
|
-
switch (ctorString) {
|
|
847
|
-
case dataViewCtorString: return dataViewTag;
|
|
848
|
-
case mapCtorString: return mapTag;
|
|
849
|
-
case promiseCtorString: return promiseTag;
|
|
850
|
-
case setCtorString: return setTag;
|
|
851
|
-
case weakMapCtorString: return weakMapTag;
|
|
548
|
+
_cycle();
|
|
549
|
+
if (iterator.return) {
|
|
550
|
+
var _fixup = function (value) {
|
|
551
|
+
try {
|
|
552
|
+
if (!step.done) {
|
|
553
|
+
iterator.return();
|
|
554
|
+
}
|
|
555
|
+
} catch (e) {}
|
|
556
|
+
return value;
|
|
557
|
+
};
|
|
558
|
+
if (pact && pact.then) {
|
|
559
|
+
return pact.then(_fixup, function (e) {
|
|
560
|
+
throw _fixup(e);
|
|
561
|
+
});
|
|
852
562
|
}
|
|
563
|
+
_fixup();
|
|
853
564
|
}
|
|
854
|
-
return
|
|
855
|
-
}
|
|
565
|
+
return pact;
|
|
566
|
+
}
|
|
567
|
+
// No support for Symbol.iterator
|
|
568
|
+
if (!("length" in target)) {
|
|
569
|
+
throw new TypeError("Object is not iterable");
|
|
570
|
+
}
|
|
571
|
+
// Handle live collections properly
|
|
572
|
+
var values = [];
|
|
573
|
+
for (var i = 0; i < target.length; i++) {
|
|
574
|
+
values.push(target[i]);
|
|
575
|
+
}
|
|
576
|
+
return _forTo(values, function (i) {
|
|
577
|
+
return body(values[i]);
|
|
578
|
+
}, check);
|
|
856
579
|
}
|
|
857
|
-
|
|
580
|
+
const signMultiPdfFile = function (_ref) {
|
|
581
|
+
let {
|
|
582
|
+
filename,
|
|
583
|
+
url,
|
|
584
|
+
signatureList
|
|
585
|
+
} = _ref;
|
|
586
|
+
try {
|
|
587
|
+
return Promise.resolve(window.fetch(url)).then(function (response) {
|
|
588
|
+
return Promise.resolve(response.arrayBuffer()).then(function (pdfBytes) {
|
|
589
|
+
return Promise.resolve(pdfLib.PDFDocument.load(pdfBytes)).then(function (pdfDoc) {
|
|
590
|
+
function _temp2() {
|
|
591
|
+
return Promise.resolve(pdfDoc.save()).then(function (modifiedPdfBytes) {
|
|
592
|
+
return new window.File([modifiedPdfBytes], filename, {
|
|
593
|
+
type: 'application/pdf'
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
const _temp = _forOf(signatureList, function (item) {
|
|
598
|
+
const {
|
|
599
|
+
x,
|
|
600
|
+
y,
|
|
601
|
+
page,
|
|
602
|
+
signature,
|
|
603
|
+
width,
|
|
604
|
+
height
|
|
605
|
+
} = item;
|
|
606
|
+
const pdfPage = pdfDoc.getPage(page - 1);
|
|
607
|
+
return Promise.resolve(window.fetch(signature).then(res => res.arrayBuffer())).then(function (signatureBytes) {
|
|
608
|
+
return Promise.resolve(pdfDoc.embedPng(signatureBytes)).then(function (signatureImageEmbed) {
|
|
609
|
+
pdfPage.drawImage(signatureImageEmbed, {
|
|
610
|
+
x,
|
|
611
|
+
y,
|
|
612
|
+
width,
|
|
613
|
+
height
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
} catch (e) {
|
|
623
|
+
return Promise.reject(e);
|
|
624
|
+
}
|
|
625
|
+
};
|
|
858
626
|
const signPdfFile = function (pdfSignature) {
|
|
859
627
|
try {
|
|
860
628
|
const {
|
|
@@ -867,34 +635,46 @@ const signPdfFile = function (pdfSignature) {
|
|
|
867
635
|
url,
|
|
868
636
|
filename
|
|
869
637
|
} = pdfSignature;
|
|
870
|
-
return
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
});
|
|
882
|
-
return Promise.resolve(pdfDoc.save()).then(function (modifiedPdfBytes) {
|
|
883
|
-
return new window.File([modifiedPdfBytes], filename, {
|
|
884
|
-
type: 'application/pdf'
|
|
885
|
-
});
|
|
886
|
-
});
|
|
887
|
-
});
|
|
888
|
-
});
|
|
889
|
-
});
|
|
890
|
-
});
|
|
638
|
+
return signMultiPdfFile({
|
|
639
|
+
filename,
|
|
640
|
+
url,
|
|
641
|
+
signatureList: [{
|
|
642
|
+
x,
|
|
643
|
+
y,
|
|
644
|
+
page,
|
|
645
|
+
signature,
|
|
646
|
+
width,
|
|
647
|
+
height
|
|
648
|
+
}]
|
|
891
649
|
});
|
|
892
650
|
} catch (e) {
|
|
893
651
|
return Promise.reject(e);
|
|
894
652
|
}
|
|
895
653
|
};
|
|
896
654
|
|
|
897
|
-
const
|
|
655
|
+
const computedPDFSignLocation = ({
|
|
656
|
+
size,
|
|
657
|
+
location
|
|
658
|
+
}) => {
|
|
659
|
+
const scaleX = size.width / size.originalWidth;
|
|
660
|
+
const scaleY = size.height / size.originalHeight;
|
|
661
|
+
const pdfX = Math.round(location.size.x / scaleX);
|
|
662
|
+
const pdfY = Math.round(size.originalHeight - location.size.y / scaleY);
|
|
663
|
+
const signWidth = Math.round(location.size.width / scaleX);
|
|
664
|
+
const signHeight = Math.round(location.size.height / scaleY);
|
|
665
|
+
return {
|
|
666
|
+
scaleX,
|
|
667
|
+
scaleY,
|
|
668
|
+
pdfX,
|
|
669
|
+
pdfY,
|
|
670
|
+
width: signWidth,
|
|
671
|
+
height: signHeight,
|
|
672
|
+
x: pdfX,
|
|
673
|
+
y: pdfY - signHeight
|
|
674
|
+
};
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
const _excluded$2 = ["placeholder", "signature", "url", "width", "height", "padding", "filename", "defaultLocation", "onChange"];
|
|
898
678
|
const PDFSignInner = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
899
679
|
let {
|
|
900
680
|
size,
|
|
@@ -910,42 +690,29 @@ const PDFSignInner = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
910
690
|
onChange
|
|
911
691
|
} = _ref;
|
|
912
692
|
const initLocation = react.useMemo(() => {
|
|
913
|
-
return {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
width,
|
|
920
|
-
height,
|
|
921
|
-
x: Math.round((size.width - width) / 2),
|
|
922
|
-
y: Math.round((size.height - height) / 2)
|
|
923
|
-
}
|
|
924
|
-
};
|
|
693
|
+
return getInitLocation({
|
|
694
|
+
stageWidth: size.width,
|
|
695
|
+
stageHeight: size.height,
|
|
696
|
+
width,
|
|
697
|
+
height
|
|
698
|
+
});
|
|
925
699
|
}, [size, width, height]);
|
|
926
700
|
const [location, setLocationOrigin] = react.useState(Object.assign({}, initLocation, defaultLocation));
|
|
927
701
|
const setLocation = useRefCallback__default["default"](value => {
|
|
928
702
|
setLocationOrigin(Object.assign({}, initLocation, value));
|
|
929
703
|
});
|
|
930
704
|
const pdfSignature = react.useMemo(() => {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
const signWidth = Math.round(location.size.width / scaleX);
|
|
936
|
-
const signHeight = Math.round(location.size.height / scaleY);
|
|
937
|
-
return {
|
|
938
|
-
x: pdfX,
|
|
939
|
-
y: pdfY - signHeight,
|
|
940
|
-
page: currentPage,
|
|
941
|
-
pageWidth: Math.round(size.originalWidth),
|
|
942
|
-
pageHeight: Math.round(size.originalHeight),
|
|
943
|
-
width: signWidth,
|
|
944
|
-
height: signHeight,
|
|
705
|
+
return Object.assign({}, computedPDFSignLocation({
|
|
706
|
+
location,
|
|
707
|
+
size
|
|
708
|
+
}), {
|
|
945
709
|
signature,
|
|
946
710
|
url,
|
|
947
|
-
filename
|
|
948
|
-
|
|
711
|
+
filename,
|
|
712
|
+
page: currentPage,
|
|
713
|
+
pageWidth: Math.round(size.originalWidth),
|
|
714
|
+
pageHeight: Math.round(size.originalHeight)
|
|
715
|
+
});
|
|
949
716
|
}, [location, signature, url, filename, size, currentPage]);
|
|
950
717
|
const signPdf = react.useCallback(function () {
|
|
951
718
|
try {
|
|
@@ -991,7 +758,7 @@ const PDFSign = withLocale(/*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
991
758
|
defaultLocation,
|
|
992
759
|
onChange
|
|
993
760
|
} = _ref2,
|
|
994
|
-
props = _objectWithoutPropertiesLoose(_ref2, _excluded$
|
|
761
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
|
|
995
762
|
return /*#__PURE__*/jsxRuntime.jsx(PDFViewer, _extends({}, props, {
|
|
996
763
|
url: url,
|
|
997
764
|
children: _ref3 => {
|
|
@@ -1017,6 +784,134 @@ const PDFSign = withLocale(/*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
1017
784
|
}));
|
|
1018
785
|
}));
|
|
1019
786
|
|
|
787
|
+
const _excluded$1 = ["placeholder", "url", "width", "height", "padding", "filename", "defaultSignatureList", "onSign", "onChange", "isEdit"];
|
|
788
|
+
const PDFSignMultiInner = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
789
|
+
let {
|
|
790
|
+
size,
|
|
791
|
+
currentPage,
|
|
792
|
+
placeholder,
|
|
793
|
+
url,
|
|
794
|
+
width = 200,
|
|
795
|
+
height = 80,
|
|
796
|
+
padding,
|
|
797
|
+
filename = 'signed-document.pdf',
|
|
798
|
+
defaultSignatureList,
|
|
799
|
+
isEdit,
|
|
800
|
+
onSign,
|
|
801
|
+
onChange
|
|
802
|
+
} = _ref;
|
|
803
|
+
const [signatureList, setSignatureList] = react.useState(defaultSignatureList || []);
|
|
804
|
+
const {
|
|
805
|
+
formatMessage
|
|
806
|
+
} = reactIntl.useIntl();
|
|
807
|
+
const pdfSignatureList = react.useMemo(() => {
|
|
808
|
+
return signatureList.filter(location => location.signature).map(location => {
|
|
809
|
+
return Object.assign({}, computedPDFSignLocation({
|
|
810
|
+
location,
|
|
811
|
+
size
|
|
812
|
+
}), {
|
|
813
|
+
page: location.page,
|
|
814
|
+
signature: location.signature
|
|
815
|
+
});
|
|
816
|
+
});
|
|
817
|
+
}, [signatureList, size]);
|
|
818
|
+
react.useImperativeHandle(ref, () => ({
|
|
819
|
+
getSignatureList: () => signatureList,
|
|
820
|
+
setSignatureList: value => setSignatureList(value),
|
|
821
|
+
getPdfSignatureList: () => {
|
|
822
|
+
return pdfSignatureList;
|
|
823
|
+
},
|
|
824
|
+
sign: () => {
|
|
825
|
+
if (!pdfSignatureList.length) {
|
|
826
|
+
return Promise.reject(new Error(formatMessage({
|
|
827
|
+
id: 'signatureAdd'
|
|
828
|
+
})));
|
|
829
|
+
}
|
|
830
|
+
return signMultiPdfFile({
|
|
831
|
+
url,
|
|
832
|
+
filename,
|
|
833
|
+
signatureList: pdfSignatureList
|
|
834
|
+
});
|
|
835
|
+
},
|
|
836
|
+
addSignLocation: () => {
|
|
837
|
+
setSignatureList(signatureList => {
|
|
838
|
+
return [...signatureList, {
|
|
839
|
+
page: currentPage
|
|
840
|
+
}];
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
}));
|
|
844
|
+
return /*#__PURE__*/jsxRuntime.jsx(LocationGroup, {
|
|
845
|
+
isEdit: isEdit,
|
|
846
|
+
currentPage: currentPage,
|
|
847
|
+
stageWidth: size.width,
|
|
848
|
+
stageHeight: size.height,
|
|
849
|
+
width: width,
|
|
850
|
+
height: height,
|
|
851
|
+
padding: padding,
|
|
852
|
+
placeholder: placeholder,
|
|
853
|
+
value: signatureList,
|
|
854
|
+
onChange: setSignatureList,
|
|
855
|
+
onClick: _ref2 => {
|
|
856
|
+
let {
|
|
857
|
+
index,
|
|
858
|
+
value
|
|
859
|
+
} = _ref2;
|
|
860
|
+
onSign && onSign({
|
|
861
|
+
size: value.size,
|
|
862
|
+
callback: signature => {
|
|
863
|
+
setSignatureList(value => {
|
|
864
|
+
const newValue = value.slice(0);
|
|
865
|
+
newValue[index] = Object.assign({}, newValue[index], {
|
|
866
|
+
signature
|
|
867
|
+
});
|
|
868
|
+
return newValue;
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
const PDFSignMulti = withLocale(/*#__PURE__*/react.forwardRef((_ref3, ref) => {
|
|
876
|
+
let {
|
|
877
|
+
placeholder,
|
|
878
|
+
url,
|
|
879
|
+
width,
|
|
880
|
+
height,
|
|
881
|
+
padding,
|
|
882
|
+
filename = 'signed-document.pdf',
|
|
883
|
+
defaultSignatureList,
|
|
884
|
+
onSign,
|
|
885
|
+
onChange,
|
|
886
|
+
isEdit
|
|
887
|
+
} = _ref3,
|
|
888
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
|
|
889
|
+
return /*#__PURE__*/jsxRuntime.jsx(PDFViewer, _extends({}, props, {
|
|
890
|
+
url: url,
|
|
891
|
+
children: _ref4 => {
|
|
892
|
+
let {
|
|
893
|
+
size,
|
|
894
|
+
currentPage
|
|
895
|
+
} = _ref4;
|
|
896
|
+
return /*#__PURE__*/jsxRuntime.jsx(PDFSignMultiInner, {
|
|
897
|
+
ref: ref,
|
|
898
|
+
size: size,
|
|
899
|
+
currentPage: currentPage,
|
|
900
|
+
url: url,
|
|
901
|
+
filename: filename,
|
|
902
|
+
defaultSignatureList: defaultSignatureList,
|
|
903
|
+
width: width,
|
|
904
|
+
height: height,
|
|
905
|
+
padding: padding,
|
|
906
|
+
placeholder: placeholder,
|
|
907
|
+
onChange: onChange,
|
|
908
|
+
onSign: onSign,
|
|
909
|
+
isEdit: isEdit
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
}));
|
|
913
|
+
}));
|
|
914
|
+
|
|
1020
915
|
const _excluded = ["filename", "onSuccess", "width", "height", "mask"];
|
|
1021
916
|
function _catch(body, recover) {
|
|
1022
917
|
try {
|
|
@@ -1206,8 +1101,10 @@ const useSignature = () => {
|
|
|
1206
1101
|
};
|
|
1207
1102
|
};
|
|
1208
1103
|
|
|
1104
|
+
exports.LocationGroup = LocationGroup;
|
|
1209
1105
|
exports.LocationLayer = LocationLayer;
|
|
1210
1106
|
exports.PDFSign = PDFSign;
|
|
1107
|
+
exports.PDFSignMulti = PDFSignMulti;
|
|
1211
1108
|
exports.PDFViewer = PDFViewer;
|
|
1212
1109
|
exports["default"] = PDFSign;
|
|
1213
1110
|
exports.signPdfFile = signPdfFile;
|