@kne/react-pdf-sign 1.0.5 → 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.css +1 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +620 -694
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +438 -693
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +3 -1
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +3 -1
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +3 -1
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +3 -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);
|
|
@@ -154,8 +154,10 @@ const locale$1 = {
|
|
|
154
154
|
signatureDefaultTitle: '签名',
|
|
155
155
|
signatureConfirmText: '确认',
|
|
156
156
|
signatureCancelText: '取消',
|
|
157
|
+
signatureCleanText: '清空',
|
|
157
158
|
signatureEmptyError: '签名内容不能为空',
|
|
158
|
-
signatureSuccess: '签名成功'
|
|
159
|
+
signatureSuccess: '签名成功',
|
|
160
|
+
signatureAdd: '请添加签名'
|
|
159
161
|
};
|
|
160
162
|
|
|
161
163
|
const locale = {
|
|
@@ -164,8 +166,10 @@ const locale = {
|
|
|
164
166
|
signatureDefaultTitle: 'Signature',
|
|
165
167
|
signatureConfirmText: 'Confirm',
|
|
166
168
|
signatureCancelText: 'Cancel',
|
|
169
|
+
signatureCleanText: 'Clean',
|
|
167
170
|
signatureEmptyError: 'Signature content cannot be empty',
|
|
168
|
-
signatureSuccess: 'Signature Success'
|
|
171
|
+
signatureSuccess: 'Signature Success',
|
|
172
|
+
signatureAdd: 'Please add signature'
|
|
169
173
|
};
|
|
170
174
|
|
|
171
175
|
const withLocale = reactIntl.createWithIntlProvider({
|
|
@@ -177,8 +181,30 @@ const withLocale = reactIntl.createWithIntlProvider({
|
|
|
177
181
|
namespace: 'react-pdf-sign'
|
|
178
182
|
});
|
|
179
183
|
|
|
180
|
-
const
|
|
181
|
-
|
|
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 => {
|
|
182
208
|
const {
|
|
183
209
|
formatMessage
|
|
184
210
|
} = reactIntl.useIntl();
|
|
@@ -191,9 +217,12 @@ const LocationLayer = withLocale(p => {
|
|
|
191
217
|
placeholder = formatMessage({
|
|
192
218
|
id: 'locationLayerPlaceholder'
|
|
193
219
|
}),
|
|
194
|
-
signature
|
|
220
|
+
signature,
|
|
221
|
+
active,
|
|
222
|
+
onClose,
|
|
223
|
+
onClick
|
|
195
224
|
} = p,
|
|
196
|
-
props = _objectWithoutPropertiesLoose(p, _excluded$
|
|
225
|
+
props = _objectWithoutPropertiesLoose(p, _excluded$3);
|
|
197
226
|
const [value, setValue] = useControlValue__default["default"](props);
|
|
198
227
|
const [isInit, setIsInit] = react.useState(false);
|
|
199
228
|
const [signatureImage] = useImage__default["default"](signature);
|
|
@@ -203,7 +232,7 @@ const LocationLayer = withLocale(p => {
|
|
|
203
232
|
const computedSignLocation = () => {
|
|
204
233
|
const absolutePosition = signRef.current.absolutePosition();
|
|
205
234
|
const size = signRef.current.getClientRect();
|
|
206
|
-
setValue({
|
|
235
|
+
setValue(value => Object.assign({}, value, {
|
|
207
236
|
size: {
|
|
208
237
|
width: Math.round(size.width),
|
|
209
238
|
height: Math.round(size.height),
|
|
@@ -214,22 +243,16 @@ const LocationLayer = withLocale(p => {
|
|
|
214
243
|
scaleY: Number(groupRef.current.attrs.scaleY.toFixed(2)),
|
|
215
244
|
x: Math.round(groupRef.current.attrs.x),
|
|
216
245
|
y: Math.round(groupRef.current.attrs.y)
|
|
217
|
-
});
|
|
246
|
+
}));
|
|
218
247
|
};
|
|
219
248
|
const initValue = useRefCallback__default["default"](() => {
|
|
220
249
|
if (['scaleX', 'scaleY', 'x', 'y', 'size'].some(name => !Object.assign({}, value).hasOwnProperty(name))) {
|
|
221
|
-
setValue({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
width,
|
|
228
|
-
height,
|
|
229
|
-
x: Math.round((stageWidth - width) / 2),
|
|
230
|
-
y: Math.round((stageHeight - height) / 2)
|
|
231
|
-
}
|
|
232
|
-
});
|
|
250
|
+
setValue(value => Object.assign({}, value, getInitLocation({
|
|
251
|
+
stageWidth,
|
|
252
|
+
stageHeight,
|
|
253
|
+
width,
|
|
254
|
+
height
|
|
255
|
+
})));
|
|
233
256
|
}
|
|
234
257
|
setIsInit(true);
|
|
235
258
|
});
|
|
@@ -252,607 +275,354 @@ const LocationLayer = withLocale(p => {
|
|
|
252
275
|
if (!(isInit && value)) {
|
|
253
276
|
return null;
|
|
254
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);
|
|
255
358
|
return /*#__PURE__*/jsxRuntime.jsx(reactKonva.Stage, {
|
|
256
359
|
width: stageWidth,
|
|
257
360
|
height: stageHeight,
|
|
258
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
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
|
+
}));
|
|
300
422
|
})
|
|
301
423
|
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
305
|
-
|
|
306
|
-
function createCommonjsModule(fn) {
|
|
307
|
-
var module = { exports: {} };
|
|
308
|
-
return fn(module, module.exports), module.exports;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/** Detect free variable `global` from Node.js. */
|
|
312
|
-
|
|
313
|
-
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
314
|
-
|
|
315
|
-
var _freeGlobal = freeGlobal;
|
|
316
|
-
|
|
317
|
-
/** Detect free variable `self`. */
|
|
318
|
-
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
319
|
-
|
|
320
|
-
/** Used as a reference to the global object. */
|
|
321
|
-
var root = _freeGlobal || freeSelf || Function('return this')();
|
|
322
|
-
|
|
323
|
-
var _root = root;
|
|
324
|
-
|
|
325
|
-
/** Built-in value references. */
|
|
326
|
-
var Symbol = _root.Symbol;
|
|
327
|
-
|
|
328
|
-
var _Symbol = Symbol;
|
|
329
|
-
|
|
330
|
-
/** Used for built-in method references. */
|
|
331
|
-
var objectProto$3 = Object.prototype;
|
|
332
|
-
|
|
333
|
-
/** Used to check objects for own properties. */
|
|
334
|
-
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Used to resolve the
|
|
338
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
339
|
-
* of values.
|
|
340
|
-
*/
|
|
341
|
-
var nativeObjectToString$1 = objectProto$3.toString;
|
|
342
|
-
|
|
343
|
-
/** Built-in value references. */
|
|
344
|
-
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
348
|
-
*
|
|
349
|
-
* @private
|
|
350
|
-
* @param {*} value The value to query.
|
|
351
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
352
|
-
*/
|
|
353
|
-
function getRawTag(value) {
|
|
354
|
-
var isOwn = hasOwnProperty$2.call(value, symToStringTag$1),
|
|
355
|
-
tag = value[symToStringTag$1];
|
|
356
|
-
|
|
357
|
-
try {
|
|
358
|
-
value[symToStringTag$1] = undefined;
|
|
359
|
-
var unmasked = true;
|
|
360
|
-
} catch (e) {}
|
|
424
|
+
};
|
|
361
425
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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);
|
|
368
449
|
}
|
|
369
450
|
}
|
|
370
|
-
return result;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
var _getRawTag = getRawTag;
|
|
374
|
-
|
|
375
|
-
/** Used for built-in method references. */
|
|
376
|
-
var objectProto$2 = Object.prototype;
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Used to resolve the
|
|
380
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
381
|
-
* of values.
|
|
382
|
-
*/
|
|
383
|
-
var nativeObjectToString = objectProto$2.toString;
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Converts `value` to a string using `Object.prototype.toString`.
|
|
387
|
-
*
|
|
388
|
-
* @private
|
|
389
|
-
* @param {*} value The value to convert.
|
|
390
|
-
* @returns {string} Returns the converted string.
|
|
391
|
-
*/
|
|
392
|
-
function objectToString(value) {
|
|
393
|
-
return nativeObjectToString.call(value);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
var _objectToString = objectToString;
|
|
397
|
-
|
|
398
|
-
/** `Object#toString` result references. */
|
|
399
|
-
var nullTag = '[object Null]',
|
|
400
|
-
undefinedTag = '[object Undefined]';
|
|
401
|
-
|
|
402
|
-
/** Built-in value references. */
|
|
403
|
-
var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
407
|
-
*
|
|
408
|
-
* @private
|
|
409
|
-
* @param {*} value The value to query.
|
|
410
|
-
* @returns {string} Returns the `toStringTag`.
|
|
411
|
-
*/
|
|
412
|
-
function baseGetTag(value) {
|
|
413
|
-
if (value == null) {
|
|
414
|
-
return value === undefined ? undefinedTag : nullTag;
|
|
415
|
-
}
|
|
416
|
-
return (symToStringTag && symToStringTag in Object(value))
|
|
417
|
-
? _getRawTag(value)
|
|
418
|
-
: _objectToString(value);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
var _baseGetTag = baseGetTag;
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Checks if `value` is the
|
|
425
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
426
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
427
|
-
*
|
|
428
|
-
* @static
|
|
429
|
-
* @memberOf _
|
|
430
|
-
* @since 0.1.0
|
|
431
|
-
* @category Lang
|
|
432
|
-
* @param {*} value The value to check.
|
|
433
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
434
|
-
* @example
|
|
435
|
-
*
|
|
436
|
-
* _.isObject({});
|
|
437
|
-
* // => true
|
|
438
|
-
*
|
|
439
|
-
* _.isObject([1, 2, 3]);
|
|
440
|
-
* // => true
|
|
441
|
-
*
|
|
442
|
-
* _.isObject(_.noop);
|
|
443
|
-
* // => true
|
|
444
|
-
*
|
|
445
|
-
* _.isObject(null);
|
|
446
|
-
* // => false
|
|
447
|
-
*/
|
|
448
|
-
function isObject(value) {
|
|
449
|
-
var type = typeof value;
|
|
450
|
-
return value != null && (type == 'object' || type == 'function');
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
var isObject_1 = isObject;
|
|
454
|
-
|
|
455
|
-
/** `Object#toString` result references. */
|
|
456
|
-
var asyncTag = '[object AsyncFunction]',
|
|
457
|
-
funcTag = '[object Function]',
|
|
458
|
-
genTag = '[object GeneratorFunction]',
|
|
459
|
-
proxyTag = '[object Proxy]';
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Checks if `value` is classified as a `Function` object.
|
|
463
|
-
*
|
|
464
|
-
* @static
|
|
465
|
-
* @memberOf _
|
|
466
|
-
* @since 0.1.0
|
|
467
|
-
* @category Lang
|
|
468
|
-
* @param {*} value The value to check.
|
|
469
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
470
|
-
* @example
|
|
471
|
-
*
|
|
472
|
-
* _.isFunction(_);
|
|
473
|
-
* // => true
|
|
474
|
-
*
|
|
475
|
-
* _.isFunction(/abc/);
|
|
476
|
-
* // => false
|
|
477
|
-
*/
|
|
478
|
-
function isFunction(value) {
|
|
479
|
-
if (!isObject_1(value)) {
|
|
480
|
-
return false;
|
|
481
|
-
}
|
|
482
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
483
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
484
|
-
var tag = _baseGetTag(value);
|
|
485
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
486
451
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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;
|
|
510
490
|
}
|
|
511
|
-
|
|
512
|
-
var
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
/** Used to resolve the decompiled source of functions. */
|
|
518
|
-
var funcToString$1 = funcProto$1.toString;
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Converts `func` to its source code.
|
|
522
|
-
*
|
|
523
|
-
* @private
|
|
524
|
-
* @param {Function} func The function to convert.
|
|
525
|
-
* @returns {string} Returns the source code.
|
|
526
|
-
*/
|
|
527
|
-
function toSource(func) {
|
|
528
|
-
if (func != null) {
|
|
529
|
-
try {
|
|
530
|
-
return funcToString$1.call(func);
|
|
531
|
-
} catch (e) {}
|
|
491
|
+
function _forTo(array, body, check) {
|
|
492
|
+
var i = -1,
|
|
493
|
+
pact,
|
|
494
|
+
reject;
|
|
495
|
+
function _cycle(result) {
|
|
532
496
|
try {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
objectProto$1 = Object.prototype;
|
|
553
|
-
|
|
554
|
-
/** Used to resolve the decompiled source of functions. */
|
|
555
|
-
var funcToString = funcProto.toString;
|
|
556
|
-
|
|
557
|
-
/** Used to check objects for own properties. */
|
|
558
|
-
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
559
|
-
|
|
560
|
-
/** Used to detect if a method is native. */
|
|
561
|
-
var reIsNative = RegExp('^' +
|
|
562
|
-
funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
|
|
563
|
-
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
564
|
-
);
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
568
|
-
*
|
|
569
|
-
* @private
|
|
570
|
-
* @param {*} value The value to check.
|
|
571
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
572
|
-
* else `false`.
|
|
573
|
-
*/
|
|
574
|
-
function baseIsNative(value) {
|
|
575
|
-
if (!isObject_1(value) || _isMasked(value)) {
|
|
576
|
-
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
|
+
}
|
|
577
516
|
}
|
|
578
|
-
|
|
579
|
-
return
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
var _baseIsNative = baseIsNative;
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* Gets the value at `key` of `object`.
|
|
586
|
-
*
|
|
587
|
-
* @private
|
|
588
|
-
* @param {Object} [object] The object to query.
|
|
589
|
-
* @param {string} key The key of the property to get.
|
|
590
|
-
* @returns {*} Returns the property value.
|
|
591
|
-
*/
|
|
592
|
-
function getValue(object, key) {
|
|
593
|
-
return object == null ? undefined : object[key];
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
var _getValue = getValue;
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Gets the native function at `key` of `object`.
|
|
600
|
-
*
|
|
601
|
-
* @private
|
|
602
|
-
* @param {Object} object The object to query.
|
|
603
|
-
* @param {string} key The key of the method to get.
|
|
604
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
605
|
-
*/
|
|
606
|
-
function getNative(object, key) {
|
|
607
|
-
var value = _getValue(object, key);
|
|
608
|
-
return _baseIsNative(value) ? value : undefined;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
var _getNative = getNative;
|
|
612
|
-
|
|
613
|
-
/* Built-in method references that are verified to be native. */
|
|
614
|
-
var Map = _getNative(_root, 'Map');
|
|
615
|
-
|
|
616
|
-
var _Map = Map;
|
|
617
|
-
|
|
618
|
-
/* Built-in method references that are verified to be native. */
|
|
619
|
-
_getNative(Object, 'create');
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
623
|
-
* and has a `typeof` result of "object".
|
|
624
|
-
*
|
|
625
|
-
* @static
|
|
626
|
-
* @memberOf _
|
|
627
|
-
* @since 4.0.0
|
|
628
|
-
* @category Lang
|
|
629
|
-
* @param {*} value The value to check.
|
|
630
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
631
|
-
* @example
|
|
632
|
-
*
|
|
633
|
-
* _.isObjectLike({});
|
|
634
|
-
* // => true
|
|
635
|
-
*
|
|
636
|
-
* _.isObjectLike([1, 2, 3]);
|
|
637
|
-
* // => true
|
|
638
|
-
*
|
|
639
|
-
* _.isObjectLike(_.noop);
|
|
640
|
-
* // => false
|
|
641
|
-
*
|
|
642
|
-
* _.isObjectLike(null);
|
|
643
|
-
* // => false
|
|
644
|
-
*/
|
|
645
|
-
function isObjectLike(value) {
|
|
646
|
-
return value != null && typeof value == 'object';
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
var isObjectLike_1 = isObjectLike;
|
|
650
|
-
|
|
651
|
-
/** `Object#toString` result references. */
|
|
652
|
-
var argsTag = '[object Arguments]';
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* The base implementation of `_.isArguments`.
|
|
656
|
-
*
|
|
657
|
-
* @private
|
|
658
|
-
* @param {*} value The value to check.
|
|
659
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
660
|
-
*/
|
|
661
|
-
function baseIsArguments(value) {
|
|
662
|
-
return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
|
|
517
|
+
_cycle();
|
|
518
|
+
return pact;
|
|
663
519
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
* _.isArguments([1, 2, 3]);
|
|
692
|
-
* // => false
|
|
693
|
-
*/
|
|
694
|
-
_baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
|
|
695
|
-
return isObjectLike_1(value) && hasOwnProperty.call(value, 'callee') &&
|
|
696
|
-
!propertyIsEnumerable.call(value, 'callee');
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* This method returns `false`.
|
|
701
|
-
*
|
|
702
|
-
* @static
|
|
703
|
-
* @memberOf _
|
|
704
|
-
* @since 4.13.0
|
|
705
|
-
* @category Util
|
|
706
|
-
* @returns {boolean} Returns `false`.
|
|
707
|
-
* @example
|
|
708
|
-
*
|
|
709
|
-
* _.times(2, _.stubFalse);
|
|
710
|
-
* // => [false, false]
|
|
711
|
-
*/
|
|
712
|
-
function stubFalse() {
|
|
713
|
-
return false;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
var stubFalse_1 = stubFalse;
|
|
717
|
-
|
|
718
|
-
createCommonjsModule(function (module, exports) {
|
|
719
|
-
/** Detect free variable `exports`. */
|
|
720
|
-
var freeExports = exports && !exports.nodeType && exports;
|
|
721
|
-
|
|
722
|
-
/** Detect free variable `module`. */
|
|
723
|
-
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
724
|
-
|
|
725
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
726
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
727
|
-
|
|
728
|
-
/** Built-in value references. */
|
|
729
|
-
var Buffer = moduleExports ? _root.Buffer : undefined;
|
|
730
|
-
|
|
731
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
732
|
-
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
733
|
-
|
|
734
|
-
/**
|
|
735
|
-
* Checks if `value` is a buffer.
|
|
736
|
-
*
|
|
737
|
-
* @static
|
|
738
|
-
* @memberOf _
|
|
739
|
-
* @since 4.3.0
|
|
740
|
-
* @category Lang
|
|
741
|
-
* @param {*} value The value to check.
|
|
742
|
-
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
743
|
-
* @example
|
|
744
|
-
*
|
|
745
|
-
* _.isBuffer(new Buffer(2));
|
|
746
|
-
* // => true
|
|
747
|
-
*
|
|
748
|
-
* _.isBuffer(new Uint8Array(2));
|
|
749
|
-
* // => false
|
|
750
|
-
*/
|
|
751
|
-
var isBuffer = nativeIsBuffer || stubFalse_1;
|
|
752
|
-
|
|
753
|
-
module.exports = isBuffer;
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
createCommonjsModule(function (module, exports) {
|
|
757
|
-
/** Detect free variable `exports`. */
|
|
758
|
-
var freeExports = exports && !exports.nodeType && exports;
|
|
759
|
-
|
|
760
|
-
/** Detect free variable `module`. */
|
|
761
|
-
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
762
|
-
|
|
763
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
764
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
765
|
-
|
|
766
|
-
/** Detect free variable `process` from Node.js. */
|
|
767
|
-
var freeProcess = moduleExports && _freeGlobal.process;
|
|
768
|
-
|
|
769
|
-
/** Used to access faster Node.js helpers. */
|
|
770
|
-
var nodeUtil = (function() {
|
|
771
|
-
try {
|
|
772
|
-
// Use `util.types` for Node.js 10+.
|
|
773
|
-
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
774
|
-
|
|
775
|
-
if (types) {
|
|
776
|
-
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
|
+
}
|
|
777
547
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
})
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
/* Built-in method references that are verified to be native. */
|
|
793
|
-
var Promise$1 = _getNative(_root, 'Promise');
|
|
794
|
-
|
|
795
|
-
var _Promise = Promise$1;
|
|
796
|
-
|
|
797
|
-
/* Built-in method references that are verified to be native. */
|
|
798
|
-
var Set = _getNative(_root, 'Set');
|
|
799
|
-
|
|
800
|
-
var _Set = Set;
|
|
801
|
-
|
|
802
|
-
/* Built-in method references that are verified to be native. */
|
|
803
|
-
var WeakMap = _getNative(_root, 'WeakMap');
|
|
804
|
-
|
|
805
|
-
var _WeakMap = WeakMap;
|
|
806
|
-
|
|
807
|
-
/** `Object#toString` result references. */
|
|
808
|
-
var mapTag = '[object Map]',
|
|
809
|
-
objectTag = '[object Object]',
|
|
810
|
-
promiseTag = '[object Promise]',
|
|
811
|
-
setTag = '[object Set]',
|
|
812
|
-
weakMapTag = '[object WeakMap]';
|
|
813
|
-
|
|
814
|
-
var dataViewTag = '[object DataView]';
|
|
815
|
-
|
|
816
|
-
/** Used to detect maps, sets, and weakmaps. */
|
|
817
|
-
var dataViewCtorString = _toSource(_DataView),
|
|
818
|
-
mapCtorString = _toSource(_Map),
|
|
819
|
-
promiseCtorString = _toSource(_Promise),
|
|
820
|
-
setCtorString = _toSource(_Set),
|
|
821
|
-
weakMapCtorString = _toSource(_WeakMap);
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* Gets the `toStringTag` of `value`.
|
|
825
|
-
*
|
|
826
|
-
* @private
|
|
827
|
-
* @param {*} value The value to query.
|
|
828
|
-
* @returns {string} Returns the `toStringTag`.
|
|
829
|
-
*/
|
|
830
|
-
var getTag = _baseGetTag;
|
|
831
|
-
|
|
832
|
-
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
833
|
-
if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|
834
|
-
(_Map && getTag(new _Map) != mapTag) ||
|
|
835
|
-
(_Promise && getTag(_Promise.resolve()) != promiseTag) ||
|
|
836
|
-
(_Set && getTag(new _Set) != setTag) ||
|
|
837
|
-
(_WeakMap && getTag(new _WeakMap) != weakMapTag)) {
|
|
838
|
-
getTag = function(value) {
|
|
839
|
-
var result = _baseGetTag(value),
|
|
840
|
-
Ctor = result == objectTag ? value.constructor : undefined,
|
|
841
|
-
ctorString = Ctor ? _toSource(Ctor) : '';
|
|
842
|
-
|
|
843
|
-
if (ctorString) {
|
|
844
|
-
switch (ctorString) {
|
|
845
|
-
case dataViewCtorString: return dataViewTag;
|
|
846
|
-
case mapCtorString: return mapTag;
|
|
847
|
-
case promiseCtorString: return promiseTag;
|
|
848
|
-
case setCtorString: return setTag;
|
|
849
|
-
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
|
+
});
|
|
850
562
|
}
|
|
563
|
+
_fixup();
|
|
851
564
|
}
|
|
852
|
-
return
|
|
853
|
-
}
|
|
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);
|
|
854
579
|
}
|
|
855
|
-
|
|
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
|
+
};
|
|
856
626
|
const signPdfFile = function (pdfSignature) {
|
|
857
627
|
try {
|
|
858
628
|
const {
|
|
@@ -865,34 +635,46 @@ const signPdfFile = function (pdfSignature) {
|
|
|
865
635
|
url,
|
|
866
636
|
filename
|
|
867
637
|
} = pdfSignature;
|
|
868
|
-
return
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
});
|
|
880
|
-
return Promise.resolve(pdfDoc.save()).then(function (modifiedPdfBytes) {
|
|
881
|
-
return new window.File([modifiedPdfBytes], filename, {
|
|
882
|
-
type: 'application/pdf'
|
|
883
|
-
});
|
|
884
|
-
});
|
|
885
|
-
});
|
|
886
|
-
});
|
|
887
|
-
});
|
|
888
|
-
});
|
|
638
|
+
return signMultiPdfFile({
|
|
639
|
+
filename,
|
|
640
|
+
url,
|
|
641
|
+
signatureList: [{
|
|
642
|
+
x,
|
|
643
|
+
y,
|
|
644
|
+
page,
|
|
645
|
+
signature,
|
|
646
|
+
width,
|
|
647
|
+
height
|
|
648
|
+
}]
|
|
889
649
|
});
|
|
890
650
|
} catch (e) {
|
|
891
651
|
return Promise.reject(e);
|
|
892
652
|
}
|
|
893
653
|
};
|
|
894
654
|
|
|
895
|
-
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"];
|
|
896
678
|
const PDFSignInner = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
897
679
|
let {
|
|
898
680
|
size,
|
|
@@ -908,42 +690,29 @@ const PDFSignInner = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
908
690
|
onChange
|
|
909
691
|
} = _ref;
|
|
910
692
|
const initLocation = react.useMemo(() => {
|
|
911
|
-
return {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
width,
|
|
918
|
-
height,
|
|
919
|
-
x: Math.round((size.width - width) / 2),
|
|
920
|
-
y: Math.round((size.height - height) / 2)
|
|
921
|
-
}
|
|
922
|
-
};
|
|
693
|
+
return getInitLocation({
|
|
694
|
+
stageWidth: size.width,
|
|
695
|
+
stageHeight: size.height,
|
|
696
|
+
width,
|
|
697
|
+
height
|
|
698
|
+
});
|
|
923
699
|
}, [size, width, height]);
|
|
924
700
|
const [location, setLocationOrigin] = react.useState(Object.assign({}, initLocation, defaultLocation));
|
|
925
701
|
const setLocation = useRefCallback__default["default"](value => {
|
|
926
702
|
setLocationOrigin(Object.assign({}, initLocation, value));
|
|
927
703
|
});
|
|
928
704
|
const pdfSignature = react.useMemo(() => {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
const signWidth = Math.round(location.size.width / scaleX);
|
|
934
|
-
const signHeight = Math.round(location.size.height / scaleY);
|
|
935
|
-
return {
|
|
936
|
-
x: pdfX,
|
|
937
|
-
y: pdfY - signHeight,
|
|
938
|
-
page: currentPage,
|
|
939
|
-
pageWidth: Math.round(size.originalWidth),
|
|
940
|
-
pageHeight: Math.round(size.originalHeight),
|
|
941
|
-
width: signWidth,
|
|
942
|
-
height: signHeight,
|
|
705
|
+
return Object.assign({}, computedPDFSignLocation({
|
|
706
|
+
location,
|
|
707
|
+
size
|
|
708
|
+
}), {
|
|
943
709
|
signature,
|
|
944
710
|
url,
|
|
945
|
-
filename
|
|
946
|
-
|
|
711
|
+
filename,
|
|
712
|
+
page: currentPage,
|
|
713
|
+
pageWidth: Math.round(size.originalWidth),
|
|
714
|
+
pageHeight: Math.round(size.originalHeight)
|
|
715
|
+
});
|
|
947
716
|
}, [location, signature, url, filename, size, currentPage]);
|
|
948
717
|
const signPdf = react.useCallback(function () {
|
|
949
718
|
try {
|
|
@@ -989,7 +758,7 @@ const PDFSign = withLocale(/*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
989
758
|
defaultLocation,
|
|
990
759
|
onChange
|
|
991
760
|
} = _ref2,
|
|
992
|
-
props = _objectWithoutPropertiesLoose(_ref2, _excluded$
|
|
761
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
|
|
993
762
|
return /*#__PURE__*/jsxRuntime.jsx(PDFViewer, _extends({}, props, {
|
|
994
763
|
url: url,
|
|
995
764
|
children: _ref3 => {
|
|
@@ -1015,7 +784,146 @@ const PDFSign = withLocale(/*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
1015
784
|
}));
|
|
1016
785
|
}));
|
|
1017
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
|
+
|
|
1018
915
|
const _excluded = ["filename", "onSuccess", "width", "height", "mask"];
|
|
916
|
+
function _catch(body, recover) {
|
|
917
|
+
try {
|
|
918
|
+
var result = body();
|
|
919
|
+
} catch (e) {
|
|
920
|
+
return recover(e);
|
|
921
|
+
}
|
|
922
|
+
if (result && result.then) {
|
|
923
|
+
return result.then(void 0, recover);
|
|
924
|
+
}
|
|
925
|
+
return result;
|
|
926
|
+
}
|
|
1019
927
|
const dataURLtoBlob = dataURL => {
|
|
1020
928
|
let arr = dataURL.split(',');
|
|
1021
929
|
// 注意base64的最后面中括号和引号是不转译的
|
|
@@ -1048,6 +956,7 @@ const Signature = withLocale(_ref => {
|
|
|
1048
956
|
} = antd.App.useApp();
|
|
1049
957
|
const signatureCanvasRef = react.useRef(null);
|
|
1050
958
|
const maskRef = react.useRef(null);
|
|
959
|
+
const [loading, setLoading] = react.useState(false);
|
|
1051
960
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
1052
961
|
vertical: true,
|
|
1053
962
|
gap: 12,
|
|
@@ -1055,7 +964,7 @@ const Signature = withLocale(_ref => {
|
|
|
1055
964
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1056
965
|
className: classnames__default["default"](style['signature-container'], 'signature-container'),
|
|
1057
966
|
style: {
|
|
1058
|
-
width: '
|
|
967
|
+
width: '100%',
|
|
1059
968
|
height: Math.round(height * 368 / width) + "px"
|
|
1060
969
|
},
|
|
1061
970
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -1074,51 +983,64 @@ const Signature = withLocale(_ref => {
|
|
|
1074
983
|
gap: 10,
|
|
1075
984
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
1076
985
|
onClick: () => {
|
|
1077
|
-
|
|
986
|
+
signatureCanvasRef.current.clear();
|
|
1078
987
|
},
|
|
1079
988
|
children: formatMessage({
|
|
1080
|
-
id: '
|
|
989
|
+
id: 'signatureCleanText'
|
|
1081
990
|
})
|
|
1082
991
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
992
|
+
loading: loading,
|
|
1083
993
|
type: "primary",
|
|
1084
994
|
onClick: function () {
|
|
1085
995
|
try {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1099
|
-
let result = signatureCanvasRef.current.toDataURL('image/png');
|
|
1100
|
-
const _temp = function () {
|
|
1101
|
-
if (mask) {
|
|
1102
|
-
return Promise.resolve(snapdom.snapdom.toPng(maskRef.current, {
|
|
1103
|
-
scale: 2
|
|
1104
|
-
})).then(function (maskPng) {
|
|
1105
|
-
const canvas = document.createElement('canvas');
|
|
1106
|
-
canvas.width = width * 2;
|
|
1107
|
-
canvas.height = height * 2;
|
|
1108
|
-
const ctx = canvas.getContext('2d');
|
|
1109
|
-
ctx.drawImage(maskPng, 0, 0, canvas.width, canvas.height);
|
|
1110
|
-
const resultImage = new Image();
|
|
1111
|
-
resultImage.src = result;
|
|
1112
|
-
return Promise.resolve(new Promise(resolve => {
|
|
1113
|
-
resultImage.onload = resolve;
|
|
1114
|
-
})).then(function () {
|
|
1115
|
-
ctx.drawImage(resultImage, 0, 0, canvas.width, canvas.height);
|
|
1116
|
-
result = canvas.toDataURL('image/png');
|
|
1117
|
-
});
|
|
996
|
+
setLoading(true);
|
|
997
|
+
return Promise.resolve(_catch(function () {
|
|
998
|
+
function _temp3() {
|
|
999
|
+
function _temp(successResult) {
|
|
1000
|
+
setLoading(false);
|
|
1001
|
+
if (successResult === false) {
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
onClose();
|
|
1005
|
+
}
|
|
1006
|
+
const file = new window.File([dataURLtoBlob(result)], filename, {
|
|
1007
|
+
type: 'image/png'
|
|
1118
1008
|
});
|
|
1009
|
+
return onSuccess ? Promise.resolve(onSuccess(file)).then(_temp) : _temp(onSuccess);
|
|
1119
1010
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1011
|
+
if (signatureCanvasRef.current.isEmpty()) {
|
|
1012
|
+
message.error(formatMessage({
|
|
1013
|
+
id: 'signatureEmptyError'
|
|
1014
|
+
}));
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
let result = signatureCanvasRef.current.toDataURL('image/png');
|
|
1018
|
+
const _temp2 = function () {
|
|
1019
|
+
if (mask) {
|
|
1020
|
+
return Promise.resolve(snapdom.snapdom.toPng(maskRef.current, {
|
|
1021
|
+
scale: 2
|
|
1022
|
+
})).then(function (maskPng) {
|
|
1023
|
+
const canvas = document.createElement('canvas');
|
|
1024
|
+
canvas.width = width * 2;
|
|
1025
|
+
canvas.height = height * 2;
|
|
1026
|
+
const ctx = canvas.getContext('2d');
|
|
1027
|
+
ctx.drawImage(maskPng, 0, 0, canvas.width, canvas.height);
|
|
1028
|
+
const resultImage = new Image();
|
|
1029
|
+
resultImage.src = result;
|
|
1030
|
+
return Promise.resolve(new Promise(resolve => {
|
|
1031
|
+
resultImage.onload = resolve;
|
|
1032
|
+
})).then(function () {
|
|
1033
|
+
ctx.drawImage(resultImage, 0, 0, canvas.width, canvas.height);
|
|
1034
|
+
result = canvas.toDataURL('image/png');
|
|
1035
|
+
});
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}();
|
|
1039
|
+
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
1040
|
+
}, function (e) {
|
|
1041
|
+
message.error(e.message);
|
|
1042
|
+
setLoading(false);
|
|
1043
|
+
}));
|
|
1122
1044
|
} catch (e) {
|
|
1123
1045
|
return Promise.reject(e);
|
|
1124
1046
|
}
|
|
@@ -1158,6 +1080,7 @@ const useSignature = () => {
|
|
|
1158
1080
|
title: /*#__PURE__*/jsxRuntime.jsx(Title, {}),
|
|
1159
1081
|
icon: null,
|
|
1160
1082
|
footer: null,
|
|
1083
|
+
closable: true,
|
|
1161
1084
|
wrapClassName: style['signature-modal'],
|
|
1162
1085
|
classNames: {
|
|
1163
1086
|
content: style['signature-modal']
|
|
@@ -1178,9 +1101,12 @@ const useSignature = () => {
|
|
|
1178
1101
|
};
|
|
1179
1102
|
};
|
|
1180
1103
|
|
|
1104
|
+
exports.LocationGroup = LocationGroup;
|
|
1181
1105
|
exports.LocationLayer = LocationLayer;
|
|
1182
1106
|
exports.PDFSign = PDFSign;
|
|
1107
|
+
exports.PDFSignMulti = PDFSignMulti;
|
|
1183
1108
|
exports.PDFViewer = PDFViewer;
|
|
1184
1109
|
exports["default"] = PDFSign;
|
|
1110
|
+
exports.signPdfFile = signPdfFile;
|
|
1185
1111
|
exports.useSignature = useSignature;
|
|
1186
1112
|
//# sourceMappingURL=index.js.map
|