@verdocs/js-sdk 6.4.4 → 6.4.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.js +4 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -7
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1783,13 +1783,11 @@ function sortFields(fields) {
|
|
|
1783
1783
|
if (aPage !== bPage) {
|
|
1784
1784
|
return aPage - bPage;
|
|
1785
1785
|
}
|
|
1786
|
-
// NOTE: Logic looks a little strange X vs Y. It's because we go top down,
|
|
1787
|
-
// left to right. But Y coordinates are inverted in PDFs. The reason for
|
|
1788
|
-
// the division is because no human makes perfect templates and frequently
|
|
1789
|
-
// two fields on the "same line" will be slightly offset vertically.
|
|
1790
1786
|
const divaY = Math.floor(aY / 5);
|
|
1791
1787
|
const divbY = Math.floor(bY / 5);
|
|
1792
1788
|
if (divaY !== divbY) {
|
|
1789
|
+
// Unlike the other properties, Y coordinates have 0,0 at the BOTTOM LEFT corner, so
|
|
1790
|
+
// we need to sort descending (b first) on this one.
|
|
1793
1791
|
return divbY - divaY;
|
|
1794
1792
|
}
|
|
1795
1793
|
return aX - bX;
|
|
@@ -1801,17 +1799,16 @@ function sortFields(fields) {
|
|
|
1801
1799
|
* NOTE: This function mutates the input array.
|
|
1802
1800
|
*/
|
|
1803
1801
|
function sortDocuments(documents) {
|
|
1804
|
-
return documents.sort((a, b) =>
|
|
1805
1802
|
// The Date conversion is unnecessary 90% of the time but is safer, and this isn't something
|
|
1806
1803
|
// we do much of so in reality it has almmost no impact.
|
|
1807
|
-
a
|
|
1804
|
+
return documents.sort((a, b) => a.order - b.order || new Date(a.created_at).getTime() - new Date(b.created_at).getTime());
|
|
1808
1805
|
}
|
|
1809
1806
|
/**
|
|
1810
1807
|
* Utility function to sort documents by their order, falling back to created_at.
|
|
1811
1808
|
* NOTE: This function mutates the input array.
|
|
1812
1809
|
*/
|
|
1813
1810
|
function sortRecipients(recipients) {
|
|
1814
|
-
return recipients?.sort((a, b) =>
|
|
1811
|
+
return recipients?.sort((a, b) => a.sequence - b.sequence || a.order - b.order);
|
|
1815
1812
|
}
|
|
1816
1813
|
|
|
1817
1814
|
const canPerformTemplateAction = (profile, action, template) => {
|