@signiphi/page-assembly 0.2.0-beta.4 → 0.2.0-beta.6

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.d.mts CHANGED
@@ -354,4 +354,4 @@ declare function mapFieldPositionsAfterAssembly<T extends {
354
354
  position: FormFieldPosition;
355
355
  }>(fields: T[], pageMapping: Map<string, number>): T[];
356
356
 
357
- export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, type TrackedFormField, addFormFieldsToPdf, createPdfBlobUrl, PageAssembler as default, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, mapFieldPositionsAfterAssembly, pdfToImages, setSigniphiMetadata };
357
+ export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, type TrackedFormField, addFormFieldsToPdf, createPdfBlobUrl, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, mapFieldPositionsAfterAssembly, pdfToImages, setSigniphiMetadata };
package/dist/index.d.ts CHANGED
@@ -354,4 +354,4 @@ declare function mapFieldPositionsAfterAssembly<T extends {
354
354
  position: FormFieldPosition;
355
355
  }>(fields: T[], pageMapping: Map<string, number>): T[];
356
356
 
357
- export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, type TrackedFormField, addFormFieldsToPdf, createPdfBlobUrl, PageAssembler as default, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, mapFieldPositionsAfterAssembly, pdfToImages, setSigniphiMetadata };
357
+ export { type AssembleOptions, Button, type ExtractedField, type FileExtractedFields, type FileInfo, type FormFieldForPdf, type FormFieldPosition, FormFieldType, PageAssembler, type PageAssemblerHandle, type PageAssemblerProps, type PageAssemblerState, type PageImage, type PageInfo, type TrackedFormField, addFormFieldsToPdf, createPdfBlobUrl, downloadPdf, extractFieldsFromPdf, getSigniphiMetadata, imageToPdf, mapFieldPositionsAfterAssembly, pdfToImages, setSigniphiMetadata };
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var React7 = require('react');
6
4
  var reactDnd = require('react-dnd');
7
5
  var reactDndHtml5Backend = require('react-dnd-html5-backend');
@@ -1048,8 +1046,7 @@ async function addFormFieldsToPdf(pdfBytes, formFields, options = {}) {
1048
1046
  try {
1049
1047
  const fieldType = typeof field.type === "string" ? field.type : field.type;
1050
1048
  switch (fieldType) {
1051
- case "text" /* TEXT */:
1052
- case "text": {
1049
+ case "text" /* TEXT */: {
1053
1050
  const encodedName = encodeFieldNameWithSigner(uniqueFieldName, field.assignedSignerEmail);
1054
1051
  const textField = form.createTextField(encodedName);
1055
1052
  textField.addToPage(page, {
@@ -1094,8 +1091,7 @@ async function addFormFieldsToPdf(pdfBytes, formFields, options = {}) {
1094
1091
  }
1095
1092
  break;
1096
1093
  }
1097
- case "checkbox" /* CHECKBOX */:
1098
- case "checkbox": {
1094
+ case "checkbox" /* CHECKBOX */: {
1099
1095
  const encodedName = encodeFieldNameWithSigner(uniqueFieldName, field.assignedSignerEmail);
1100
1096
  const checkBox = form.createCheckBox(encodedName);
1101
1097
  checkBox.addToPage(page, {
@@ -1126,8 +1122,7 @@ async function addFormFieldsToPdf(pdfBytes, formFields, options = {}) {
1126
1122
  }
1127
1123
  break;
1128
1124
  }
1129
- case "signature" /* SIGNATURE */:
1130
- case "signature": {
1125
+ case "signature" /* SIGNATURE */: {
1131
1126
  const baseWithSuffix = field.name.endsWith("_signature") ? field.name : `${field.name}_signature`;
1132
1127
  const finalName = conflictingNames.has(field.name) ? `${baseWithSuffix}_p${field.position.page}` : baseWithSuffix;
1133
1128
  const encodedName = encodeFieldNameWithLabelAndSigner(finalName, field.label, field.assignedSignerEmail);
@@ -1149,8 +1144,7 @@ async function addFormFieldsToPdf(pdfBytes, formFields, options = {}) {
1149
1144
  }
1150
1145
  break;
1151
1146
  }
1152
- case "initials" /* INITIALS */:
1153
- case "initials": {
1147
+ case "initials" /* INITIALS */: {
1154
1148
  const baseWithSuffix = field.name.endsWith("_initials") ? field.name : `${field.name}_initials`;
1155
1149
  const finalName = conflictingNames.has(field.name) ? `${baseWithSuffix}_p${field.position.page}` : baseWithSuffix;
1156
1150
  const encodedName = encodeFieldNameWithLabelAndSigner(finalName, field.label, field.assignedSignerEmail);
@@ -1172,8 +1166,7 @@ async function addFormFieldsToPdf(pdfBytes, formFields, options = {}) {
1172
1166
  }
1173
1167
  break;
1174
1168
  }
1175
- case "date" /* DATE */:
1176
- case "date": {
1169
+ case "date" /* DATE */: {
1177
1170
  const baseWithSuffix = field.name.endsWith("_date") ? field.name : `${field.name}_date`;
1178
1171
  const finalName = conflictingNames.has(field.name) ? `${baseWithSuffix}_p${field.position.page}` : baseWithSuffix;
1179
1172
  const encodedName = encodeFieldNameWithLabelAndSigner(finalName, field.label, field.assignedSignerEmail);
@@ -1194,8 +1187,7 @@ async function addFormFieldsToPdf(pdfBytes, formFields, options = {}) {
1194
1187
  }
1195
1188
  break;
1196
1189
  }
1197
- case "dropdown" /* DROPDOWN */:
1198
- case "dropdown": {
1190
+ case "dropdown" /* DROPDOWN */: {
1199
1191
  const encodedName = encodeFieldNameWithSigner(uniqueFieldName, field.assignedSignerEmail);
1200
1192
  const dropdown = form.createDropdown(encodedName);
1201
1193
  dropdown.addToPage(page, {
@@ -1228,8 +1220,7 @@ async function addFormFieldsToPdf(pdfBytes, formFields, options = {}) {
1228
1220
  }
1229
1221
  break;
1230
1222
  }
1231
- case "radio" /* RADIO */:
1232
- case "radio": {
1223
+ case "radio" /* RADIO */: {
1233
1224
  const encodedName = encodeFieldNameWithSigner(uniqueFieldName, field.assignedSignerEmail);
1234
1225
  const radioGroup = form.createRadioGroup(encodedName);
1235
1226
  if (field.options && field.options.length > 0) {
@@ -1692,6 +1683,7 @@ var FileCard = ({
1692
1683
  const [newName, setNewName] = React7.useState(file.name);
1693
1684
  const fileSelectedPages = file.pages.filter((p) => selectedPageIds.includes(p.id));
1694
1685
  const allPagesSelected = file.pages.length > 0 && fileSelectedPages.length === file.pages.length;
1686
+ const pendingDropdownAction = React7.useRef(null);
1695
1687
  const [{ isDraggingFile }, dragFile] = reactDnd.useDrag({
1696
1688
  type: DND_TYPES.FILE,
1697
1689
  item: () => {
@@ -1796,23 +1788,38 @@ var FileCard = ({
1796
1788
  ] }) }),
1797
1789
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1798
1790
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "hover:bg-gray-100 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "h-4 w-4" }) }) }),
1799
- /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align: "end", className: "w-52", children: [
1800
- /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => setIsRenaming(true), children: [
1801
- /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-4 w-4 mr-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" }) }),
1802
- "Rename File"
1803
- ] }),
1804
- /* @__PURE__ */ jsxRuntime.jsxs(
1805
- DropdownMenuItem,
1806
- {
1807
- onClick: () => onRemoveFile(file.id),
1808
- className: "text-red-600 hover:text-red-700 hover:bg-red-50 focus:text-red-700 focus:bg-red-50",
1809
- children: [
1810
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "h-4 w-4 mr-2" }),
1811
- "Remove File"
1812
- ]
1813
- }
1814
- )
1815
- ] })
1791
+ /* @__PURE__ */ jsxRuntime.jsxs(
1792
+ DropdownMenuContent,
1793
+ {
1794
+ align: "end",
1795
+ className: "w-52",
1796
+ onCloseAutoFocus: () => {
1797
+ pendingDropdownAction.current?.();
1798
+ pendingDropdownAction.current = null;
1799
+ },
1800
+ children: [
1801
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onSelect: () => {
1802
+ pendingDropdownAction.current = () => setIsRenaming(true);
1803
+ }, children: [
1804
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-4 w-4 mr-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" }) }),
1805
+ "Rename File"
1806
+ ] }),
1807
+ /* @__PURE__ */ jsxRuntime.jsxs(
1808
+ DropdownMenuItem,
1809
+ {
1810
+ onSelect: () => {
1811
+ pendingDropdownAction.current = () => onRemoveFile(file.id);
1812
+ },
1813
+ className: "text-red-600 hover:text-red-700 hover:bg-red-50 focus:text-red-700 focus:bg-red-50",
1814
+ children: [
1815
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "h-4 w-4 mr-2" }),
1816
+ "Remove File"
1817
+ ]
1818
+ }
1819
+ )
1820
+ ]
1821
+ }
1822
+ )
1816
1823
  ] })
1817
1824
  ] })
1818
1825
  ] }) }),
@@ -2671,14 +2678,12 @@ function debounce(func, wait) {
2671
2678
  timeout = setTimeout(() => func(...args), wait);
2672
2679
  });
2673
2680
  }
2674
- var PageAssembler_default = PageAssembler;
2675
2681
 
2676
2682
  exports.Button = Button;
2677
2683
  exports.FormFieldType = FormFieldType;
2678
2684
  exports.PageAssembler = PageAssembler;
2679
2685
  exports.addFormFieldsToPdf = addFormFieldsToPdf;
2680
2686
  exports.createPdfBlobUrl = createPdfBlobUrl;
2681
- exports.default = PageAssembler_default;
2682
2687
  exports.downloadPdf = downloadPdf;
2683
2688
  exports.extractFieldsFromPdf = extractFieldsFromPdf;
2684
2689
  exports.getSigniphiMetadata = getSigniphiMetadata;