@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.d.ts CHANGED
@@ -1135,7 +1135,7 @@ type TAddressInputGroupFormValue = {
1135
1135
  street: string;
1136
1136
  houseNumber: string;
1137
1137
  zipCode: string;
1138
- busNumber: string;
1138
+ busNumber?: string;
1139
1139
  lat: number;
1140
1140
  lng: number;
1141
1141
  info?: string;
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
2
  import { ArrowPathIcon, ChevronDownIcon, EllipsisVerticalIcon, ExclamationCircleIcon, ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon, ChevronUpIcon, ChevronUpDownIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
3
- import { isArray, map, set, get, noop as noop$1, indexOf, toSafeInteger, pick, isEmpty, some, forEach, assign, intersection } from 'lodash';
3
+ import { isArray, map, set, get, noop as noop$1, indexOf, toSafeInteger, pick, isEmpty, some, forEach, assign, intersection, trim, lastIndexOf } from 'lodash';
4
4
  import get$1 from 'lodash/get';
5
5
  import React, { useState, useMemo, Children, Fragment, useEffect, useCallback, useRef, forwardRef, useImperativeHandle, useReducer, createElement, PureComponent, Component } from 'react';
6
6
  import { library } from '@fortawesome/fontawesome-svg-core';
@@ -10779,6 +10779,26 @@ var AddressInputGroupForm = function (props) {
10779
10779
  var zipCode = handleExtractValueWithKey('postal_code');
10780
10780
  var houseNumber = handleExtractValueWithKey('street_number');
10781
10781
  var busNumber = handleExtractValueWithKey('post_box');
10782
+ if (
10783
+ // if busNumber is not found with the method above, try to find it in the user inputted label
10784
+ !busNumber &&
10785
+ (
10786
+ // if the label contains the houseNumber and city somewhere after the houseNumber
10787
+ e === null || e === void 0 ? void 0 : e.label.includes(houseNumber)) &&
10788
+ (e === null || e === void 0 ? void 0 : e.label.split(houseNumber)[1].includes(city))) {
10789
+ // split the label at the houseNumber and city
10790
+ var splitLabel = e === null || e === void 0 ? void 0 : e.label.split(houseNumber)[1].split(city)[0];
10791
+ // replace the zipCode from the label if it came before the city
10792
+ var replaceZipcode = splitLabel.replace(zipCode, '');
10793
+ // trim the label
10794
+ var trimmedLabel = trim(replaceZipcode);
10795
+ // if the trimmed label is shorter than 3 characters, it's probably the busNumber. Otherwise, something probably went wrong.
10796
+ if (trimmedLabel.length <= 3) {
10797
+ busNumber = trimmedLabel.includes(',')
10798
+ ? trimmedLabel.substring(0, lastIndexOf(trimmedLabel, ','))
10799
+ : trimmedLabel;
10800
+ }
10801
+ }
10782
10802
  var location = {
10783
10803
  street: street,
10784
10804
  city: city,