shareneus 1.6.9 → 1.6.10

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.
@@ -327,6 +327,10 @@ function buildBarcodeStack(code) {
327
327
  ];
328
328
  }
329
329
  function hasAddress(address) {
330
+ const lines = normalizeAddressLines(address);
331
+ if (lines.length > 0) {
332
+ return true;
333
+ }
330
334
  const normalizedAddress = normalizeAddress(address);
331
335
  if (!normalizedAddress) {
332
336
  return false;
@@ -334,6 +338,10 @@ function hasAddress(address) {
334
338
  return !!(0, pdf_shared_utils_1.firstValue)(getAddressFieldValue(normalizedAddress, ['A1', 'Addr1', 'Address1', 'Adrs1', 'Line1', 'Street1']), getAddressFieldValue(normalizedAddress, ['A2', 'Addr2', 'Address2', 'Adrs2', 'Line2', 'Street2']), getAddressFieldValue(normalizedAddress, ['Ct', 'City', 'Town', 'District']), getAddressFieldValue(normalizedAddress, ['St', 'State', 'StateName', 'Province']), getAddressFieldValue(normalizedAddress, ['Pin', 'PIN', 'Zip', 'ZipCode', 'PostalCode', 'Pincode']));
335
339
  }
336
340
  function buildAddressLines(address) {
341
+ const lines = normalizeAddressLines(address);
342
+ if (lines.length > 0) {
343
+ return lines;
344
+ }
337
345
  const normalizedAddress = normalizeAddress(address);
338
346
  if (!normalizedAddress) {
339
347
  return [];
@@ -349,6 +357,15 @@ function buildAddressLines(address) {
349
357
  .join(', ');
350
358
  return [line1, line2, cityStatePin].filter((value) => !!value);
351
359
  }
360
+ function normalizeAddressLines(address) {
361
+ if (!Array.isArray(address)) {
362
+ return [];
363
+ }
364
+ return address
365
+ .filter((line) => typeof line === 'string')
366
+ .map((line) => line.trim())
367
+ .filter((line) => !!line);
368
+ }
352
369
  function normalizeAddress(address) {
353
370
  if (!address) {
354
371
  return null;
@@ -362,7 +379,7 @@ function normalizeAddress(address) {
362
379
  return null;
363
380
  }
364
381
  const preferred = address.find((entry) => (entry === null || entry === void 0 ? void 0 : entry.DefBill) || (entry === null || entry === void 0 ? void 0 : entry.DefShip) || (entry === null || entry === void 0 ? void 0 : entry.Def));
365
- return preferred || address[0] || null;
382
+ return preferred || address || null;
366
383
  }
367
384
  if (typeof address === 'object') {
368
385
  if ((address === null || address === void 0 ? void 0 : address.Adrs) && typeof address.Adrs === 'object') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.09",
3
+ "version": "1.6.10",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",