@unlev/exeq 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +42 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2294,17 +2294,6 @@ function fitFontSize(o) {
|
|
|
2294
2294
|
}
|
|
2295
2295
|
return size;
|
|
2296
2296
|
}
|
|
2297
|
-
var measureCtx = null;
|
|
2298
|
-
function measureTextWidth(text, size, opts) {
|
|
2299
|
-
if (typeof document === "undefined") return text.length * size * 0.5;
|
|
2300
|
-
if (!measureCtx) measureCtx = document.createElement("canvas").getContext("2d");
|
|
2301
|
-
if (!measureCtx) return text.length * size * 0.5;
|
|
2302
|
-
const family = getCssFontFamily(opts?.fontFamily) || "Helvetica, Arial, sans-serif";
|
|
2303
|
-
measureCtx.font = `${opts?.italic ? "italic " : ""}${opts?.bold ? "bold " : ""}${size}px ${family}`;
|
|
2304
|
-
const base = measureCtx.measureText(text).width;
|
|
2305
|
-
const spacing = opts?.letterSpacing ? opts.letterSpacing * Math.max(0, text.length - 1) : 0;
|
|
2306
|
-
return base + spacing;
|
|
2307
|
-
}
|
|
2308
2297
|
|
|
2309
2298
|
// src/utils/pdfFiller.ts
|
|
2310
2299
|
var FONT_VARIANTS = {
|
|
@@ -2658,6 +2647,41 @@ function FieldNavigator({
|
|
|
2658
2647
|
|
|
2659
2648
|
// src/components/pdf-builder/SignerView.tsx
|
|
2660
2649
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2650
|
+
var useIsoLayoutEffect = typeof window !== "undefined" ? import_react7.useLayoutEffect : import_react7.useEffect;
|
|
2651
|
+
function shrinkToFit(el, maxPt, selfBox) {
|
|
2652
|
+
if (!el) return;
|
|
2653
|
+
const box = selfBox ? el : el.parentElement;
|
|
2654
|
+
if (!box) return;
|
|
2655
|
+
let pt = Math.max(1, maxPt);
|
|
2656
|
+
el.style.fontSize = `${pt}pt`;
|
|
2657
|
+
let guard = 0;
|
|
2658
|
+
while (pt > 2 && guard++ < 400 && (el.scrollWidth > box.clientWidth + 0.5 || el.scrollHeight > box.clientHeight + 0.5)) {
|
|
2659
|
+
pt -= 0.5;
|
|
2660
|
+
el.style.fontSize = `${pt}pt`;
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
function FitInput({
|
|
2664
|
+
maxPt,
|
|
2665
|
+
...rest
|
|
2666
|
+
}) {
|
|
2667
|
+
const ref = (0, import_react7.useRef)(null);
|
|
2668
|
+
useIsoLayoutEffect(() => {
|
|
2669
|
+
shrinkToFit(ref.current, maxPt, true);
|
|
2670
|
+
});
|
|
2671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { ref, ...rest });
|
|
2672
|
+
}
|
|
2673
|
+
function FitText({
|
|
2674
|
+
maxPt,
|
|
2675
|
+
className,
|
|
2676
|
+
style,
|
|
2677
|
+
children
|
|
2678
|
+
}) {
|
|
2679
|
+
const ref = (0, import_react7.useRef)(null);
|
|
2680
|
+
useIsoLayoutEffect(() => {
|
|
2681
|
+
shrinkToFit(ref.current, maxPt, false);
|
|
2682
|
+
});
|
|
2683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref, className, style, children });
|
|
2684
|
+
}
|
|
2661
2685
|
function SignerView({
|
|
2662
2686
|
apiKey,
|
|
2663
2687
|
initialPdfUrl,
|
|
@@ -2909,12 +2933,12 @@ ${row.join(",")}`, "csv");
|
|
|
2909
2933
|
setSubmitting(false);
|
|
2910
2934
|
}
|
|
2911
2935
|
}, [pdfSource, fields, callbackUrl, allRequiredFilled, onComplete, isLastSigner, signer, onSignerComplete, includeAuditTrail, exportFormat, onExport, getValues, transforms]);
|
|
2912
|
-
const renderFieldContent = (0, import_react7.useCallback)((field
|
|
2936
|
+
const renderFieldContent = (0, import_react7.useCallback)((field) => {
|
|
2913
2937
|
if (isRedactField(field)) {
|
|
2914
2938
|
return null;
|
|
2915
2939
|
}
|
|
2916
2940
|
if (field.formula) {
|
|
2917
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FitText, { maxPt: field.fontSize, className: "field-overlay-value formula", style: getCssTextStyle(field), children: field.value || "..." });
|
|
2918
2942
|
}
|
|
2919
2943
|
const editable = field.assignee === signer;
|
|
2920
2944
|
if (!editable) {
|
|
@@ -2924,7 +2948,7 @@ ${row.join(",")}`, "csv");
|
|
|
2924
2948
|
if (field.type === "checkbox") {
|
|
2925
2949
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "field-checkbox-display readonly", children: field.value === "true" ? "\u2713" : "" });
|
|
2926
2950
|
}
|
|
2927
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FitText, { maxPt: field.fontSize, className: "field-overlay-placeholder readonly", style: getCssTextStyle(field), children: field.value || field.placeholder });
|
|
2928
2952
|
}
|
|
2929
2953
|
if (isSignatureField(field)) {
|
|
2930
2954
|
if (field.value) {
|
|
@@ -2946,25 +2970,9 @@ ${row.join(",")}`, "csv");
|
|
|
2946
2970
|
);
|
|
2947
2971
|
}
|
|
2948
2972
|
if (field.type === "signed-date") {
|
|
2949
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FitText, { maxPt: field.fontSize, className: "field-overlay-value", style: getCssTextStyle(field), children: field.value || (/* @__PURE__ */ new Date()).toLocaleDateString() });
|
|
2950
2974
|
}
|
|
2951
|
-
const fieldWidthPt = pageWidthPt ? field.width / 100 * pageWidthPt : Infinity;
|
|
2952
|
-
const fieldHeightPt = pageHeightPt ? field.height / 100 * pageHeightPt : 0;
|
|
2953
|
-
const effectiveFontSize = pageWidthPt ? fitFontSize({
|
|
2954
|
-
value: field.value || "",
|
|
2955
|
-
fontSize: field.fontSize,
|
|
2956
|
-
autoShrink: field.autoShrink,
|
|
2957
|
-
fieldWidthPt,
|
|
2958
|
-
fieldHeightPt,
|
|
2959
|
-
measure: (t, s) => measureTextWidth(t, s, {
|
|
2960
|
-
fontFamily: field.fontFamily,
|
|
2961
|
-
bold: field.bold,
|
|
2962
|
-
italic: field.italic,
|
|
2963
|
-
letterSpacing: field.letterSpacing
|
|
2964
|
-
})
|
|
2965
|
-
}) : field.fontSize;
|
|
2966
2975
|
const fontStyle = {
|
|
2967
|
-
fontSize: `${effectiveFontSize}pt`,
|
|
2968
2976
|
letterSpacing: field.letterSpacing ? `${field.letterSpacing}pt` : void 0,
|
|
2969
2977
|
lineHeight: field.lineHeight ? `${field.lineHeight}` : void 0,
|
|
2970
2978
|
...getCssTextStyle(field)
|
|
@@ -2978,7 +2986,7 @@ ${row.join(",")}`, "csv");
|
|
|
2978
2986
|
onChange: (e) => handleFieldUpdate(field.id, e.target.value),
|
|
2979
2987
|
onFocus: () => setSelectedFieldId(field.id),
|
|
2980
2988
|
onClick: (e) => e.stopPropagation(),
|
|
2981
|
-
style: fontStyle,
|
|
2989
|
+
style: { fontSize: `${field.fontSize}pt`, ...fontStyle },
|
|
2982
2990
|
children: [
|
|
2983
2991
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: field.placeholder || "Select..." }),
|
|
2984
2992
|
(field.options || []).map((opt) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: opt, children: opt }, opt))
|
|
@@ -2987,8 +2995,9 @@ ${row.join(",")}`, "csv");
|
|
|
2987
2995
|
);
|
|
2988
2996
|
}
|
|
2989
2997
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2990
|
-
|
|
2998
|
+
FitInput,
|
|
2991
2999
|
{
|
|
3000
|
+
maxPt: field.fontSize,
|
|
2992
3001
|
type: field.textSubtype === "email" ? "email" : field.textSubtype === "number" ? "number" : field.textSubtype === "phone" ? "tel" : field.textSubtype === "date" ? "date" : "text",
|
|
2993
3002
|
className: "field-inline-input",
|
|
2994
3003
|
value: field.value,
|