@ballistix.digital/react-components 1.0.1 → 1.0.2

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 CHANGED
@@ -10781,6 +10781,26 @@ var AddressInputGroupForm = function (props) {
10781
10781
  var zipCode = handleExtractValueWithKey('postal_code');
10782
10782
  var houseNumber = handleExtractValueWithKey('street_number');
10783
10783
  var busNumber = handleExtractValueWithKey('post_box');
10784
+ if (
10785
+ // if busNumber is not found with the method above, try to find it in the user inputted label
10786
+ !busNumber &&
10787
+ (
10788
+ // if the label contains the houseNumber and city somewhere after the houseNumber
10789
+ e === null || e === void 0 ? void 0 : e.label.includes(houseNumber)) &&
10790
+ (e === null || e === void 0 ? void 0 : e.label.split(houseNumber)[1].includes(city))) {
10791
+ // split the label at the houseNumber and city
10792
+ var splitLabel = e === null || e === void 0 ? void 0 : e.label.split(houseNumber)[1].split(city)[0];
10793
+ // replace the zipCode from the label if it came before the city
10794
+ var replaceZipcode = splitLabel.replace(zipCode, '');
10795
+ // trim the label
10796
+ var trimmedLabel = lodash.trim(replaceZipcode);
10797
+ // if the trimmed label is shorter than 3 characters, it's probably the busNumber. Otherwise, something probably went wrong.
10798
+ if (trimmedLabel.length <= 3) {
10799
+ busNumber = trimmedLabel.includes(',')
10800
+ ? trimmedLabel.substring(0, lodash.lastIndexOf(trimmedLabel, ','))
10801
+ : trimmedLabel;
10802
+ }
10803
+ }
10784
10804
  var location = {
10785
10805
  street: street,
10786
10806
  city: city,