@ballistix.digital/react-components 0.5.1 → 0.5.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
@@ -37,15 +37,15 @@ PERFORMANCE OF THIS SOFTWARE.
37
37
  /* global Reflect, Promise, SuppressedError, Symbol */
38
38
 
39
39
 
40
- var __assign = function() {
41
- __assign = Object.assign || function __assign(t) {
40
+ var __assign$1 = function() {
41
+ __assign$1 = Object.assign || function __assign(t) {
42
42
  for (var s, i = 1, n = arguments.length; i < n; i++) {
43
43
  s = arguments[i];
44
44
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
45
45
  }
46
46
  return t;
47
47
  };
48
- return __assign.apply(this, arguments);
48
+ return __assign$1.apply(this, arguments);
49
49
  };
50
50
 
51
51
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -1324,14 +1324,14 @@ var TableList = function (props) {
1324
1324
  }).map(function (key) {
1325
1325
  var _a;
1326
1326
  return (_a = {}, _a[key] = false, _a);
1327
- }).reduce(function (a, b) { return (__assign(__assign({}, a), b)); });
1327
+ }).reduce(function (a, b) { return (__assign$1(__assign$1({}, a), b)); });
1328
1328
  var current = defaultVisibility
1329
1329
  .map(function (key) {
1330
1330
  var _a;
1331
1331
  return (_a = {}, _a[key] = true, _a);
1332
1332
  })
1333
- .reduce(function (a, b) { return (__assign(__assign({}, a), b)); });
1334
- return setVisibility(__assign(__assign({}, base), current));
1333
+ .reduce(function (a, b) { return (__assign$1(__assign$1({}, a), b)); });
1334
+ return setVisibility(__assign$1(__assign$1({}, base), current));
1335
1335
  }
1336
1336
  }
1337
1337
  var savedColumnOrder = (_a = state === null || state === void 0 ? void 0 : state.split(',').map(function (id) { return id.replace('-', ''); })) !== null && _a !== void 0 ? _a : [];
@@ -1979,7 +1979,7 @@ var List$1 = function (props) {
1979
1979
  var handleCalculateActiveAccessor = function (items) {
1980
1980
  var _a;
1981
1981
  var result = active;
1982
- var currentItem = (_a = React.Children.map(children, function (child) { return (__assign({}, child.props)); })) === null || _a === void 0 ? void 0 : _a.find(function (tab) { return tab === null || tab === void 0 ? void 0 : tab.isCurrent; });
1982
+ var currentItem = (_a = React.Children.map(children, function (child) { return (__assign$1({}, child.props)); })) === null || _a === void 0 ? void 0 : _a.find(function (tab) { return tab === null || tab === void 0 ? void 0 : tab.isCurrent; });
1983
1983
  if (currentItem === null || currentItem === void 0 ? void 0 : currentItem.href) {
1984
1984
  result = currentItem === null || currentItem === void 0 ? void 0 : currentItem.accessor;
1985
1985
  }
@@ -3774,7 +3774,7 @@ var FILES_TO_IGNORE = [
3774
3774
  function fromEvent(evt) {
3775
3775
  return __awaiter(this, void 0, void 0, function () {
3776
3776
  return __generator(this, function (_a) {
3777
- if (isObject(evt) && isDataTransfer(evt.dataTransfer)) {
3777
+ if (isObject$1(evt) && isDataTransfer(evt.dataTransfer)) {
3778
3778
  return [2 , getDataTransferFiles(evt.dataTransfer, evt.type)];
3779
3779
  }
3780
3780
  else if (isChangeEvt(evt)) {
@@ -3788,12 +3788,12 @@ function fromEvent(evt) {
3788
3788
  });
3789
3789
  }
3790
3790
  function isDataTransfer(value) {
3791
- return isObject(value);
3791
+ return isObject$1(value);
3792
3792
  }
3793
3793
  function isChangeEvt(value) {
3794
- return isObject(value) && isObject(value.target);
3794
+ return isObject$1(value) && isObject$1(value.target);
3795
3795
  }
3796
- function isObject(v) {
3796
+ function isObject$1(v) {
3797
3797
  return typeof v === 'object' && v !== null;
3798
3798
  }
3799
3799
  function getInputFiles(evt) {
@@ -4709,7 +4709,7 @@ var FileInputGroupForm = function (props) {
4709
4709
  };
4710
4710
  var styles = handleGenerateStyle();
4711
4711
  var input = getInputProps();
4712
- return (jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.jsxs("div", { className: styles.head, children: [label && (jsxRuntime.jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsxRuntime.jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxRuntime.jsxs("div", __assign({ className: styles.body }, getRootProps(), { children: [children && children({ value: value, isDragging: isDragging }), jsxRuntime.jsx("input", { name: name, accept: input.accept, multiple: input.multiple, onChange: input.onChange, ref: input === null || input === void 0 ? void 0 : input.ref, style: input.style, tabIndex: input.tabIndex, type: input.type, onBlur: onBlur })] })), jsxRuntime.jsxs("div", { className: styles.foot, children: [description && !(error && isTouched) && (jsxRuntime.jsx("p", { className: styles.description, children: description })), error && isTouched && jsxRuntime.jsx("p", { className: styles.error, children: error })] })] }));
4712
+ return (jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.jsxs("div", { className: styles.head, children: [label && (jsxRuntime.jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsxRuntime.jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxRuntime.jsxs("div", __assign$1({ className: styles.body }, getRootProps(), { children: [children && children({ value: value, isDragging: isDragging }), jsxRuntime.jsx("input", { name: name, accept: input.accept, multiple: input.multiple, onChange: input.onChange, ref: input === null || input === void 0 ? void 0 : input.ref, style: input.style, tabIndex: input.tabIndex, type: input.type, onBlur: onBlur })] })), jsxRuntime.jsxs("div", { className: styles.foot, children: [description && !(error && isTouched) && (jsxRuntime.jsx("p", { className: styles.description, children: description })), error && isTouched && jsxRuntime.jsx("p", { className: styles.error, children: error })] })] }));
4713
4713
  };
4714
4714
 
4715
4715
  var base$2 = {
@@ -9680,16 +9680,899 @@ var styles$1 = {
9680
9680
  disabled: disabled$1,
9681
9681
  };
9682
9682
 
9683
+ var classnames$1 = {exports: {}};
9684
+
9685
+ (function (module) {
9686
+ (function () {
9687
+ var hasOwn = {}.hasOwnProperty;
9688
+ function classNames() {
9689
+ var classes = [];
9690
+ for (var i = 0; i < arguments.length; i++) {
9691
+ var arg = arguments[i];
9692
+ if (!arg) continue;
9693
+ var argType = typeof arg;
9694
+ if (argType === 'string' || argType === 'number') {
9695
+ classes.push(arg);
9696
+ } else if (Array.isArray(arg)) {
9697
+ if (arg.length) {
9698
+ var inner = classNames.apply(null, arg);
9699
+ if (inner) {
9700
+ classes.push(inner);
9701
+ }
9702
+ }
9703
+ } else if (argType === 'object') {
9704
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
9705
+ classes.push(arg.toString());
9706
+ continue;
9707
+ }
9708
+ for (var key in arg) {
9709
+ if (hasOwn.call(arg, key) && arg[key]) {
9710
+ classes.push(key);
9711
+ }
9712
+ }
9713
+ }
9714
+ }
9715
+ return classes.join(' ');
9716
+ }
9717
+ if (module.exports) {
9718
+ classNames.default = classNames;
9719
+ module.exports = classNames;
9720
+ } else {
9721
+ window.classNames = classNames;
9722
+ }
9723
+ }());
9724
+ } (classnames$1));
9725
+ var classnamesExports = classnames$1.exports;
9726
+ var classnames = getDefaultExportFromCjs(classnamesExports);
9727
+
9728
+ var FUNC_ERROR_TEXT = 'Expected a function';
9729
+ var NAN = 0 / 0;
9730
+ var symbolTag = '[object Symbol]';
9731
+ var reTrim = /^\s+|\s+$/g;
9732
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
9733
+ var reIsBinary = /^0b[01]+$/i;
9734
+ var reIsOctal = /^0o[0-7]+$/i;
9735
+ var freeParseInt = parseInt;
9736
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
9737
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
9738
+ var root = freeGlobal || freeSelf || Function('return this')();
9739
+ var objectProto = Object.prototype;
9740
+ var objectToString = objectProto.toString;
9741
+ var nativeMax = Math.max,
9742
+ nativeMin = Math.min;
9743
+ var now = function() {
9744
+ return root.Date.now();
9745
+ };
9746
+ function debounce(func, wait, options) {
9747
+ var lastArgs,
9748
+ lastThis,
9749
+ maxWait,
9750
+ result,
9751
+ timerId,
9752
+ lastCallTime,
9753
+ lastInvokeTime = 0,
9754
+ leading = false,
9755
+ maxing = false,
9756
+ trailing = true;
9757
+ if (typeof func != 'function') {
9758
+ throw new TypeError(FUNC_ERROR_TEXT);
9759
+ }
9760
+ wait = toNumber(wait) || 0;
9761
+ if (isObject(options)) {
9762
+ leading = !!options.leading;
9763
+ maxing = 'maxWait' in options;
9764
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
9765
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
9766
+ }
9767
+ function invokeFunc(time) {
9768
+ var args = lastArgs,
9769
+ thisArg = lastThis;
9770
+ lastArgs = lastThis = undefined;
9771
+ lastInvokeTime = time;
9772
+ result = func.apply(thisArg, args);
9773
+ return result;
9774
+ }
9775
+ function leadingEdge(time) {
9776
+ lastInvokeTime = time;
9777
+ timerId = setTimeout(timerExpired, wait);
9778
+ return leading ? invokeFunc(time) : result;
9779
+ }
9780
+ function remainingWait(time) {
9781
+ var timeSinceLastCall = time - lastCallTime,
9782
+ timeSinceLastInvoke = time - lastInvokeTime,
9783
+ result = wait - timeSinceLastCall;
9784
+ return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
9785
+ }
9786
+ function shouldInvoke(time) {
9787
+ var timeSinceLastCall = time - lastCallTime,
9788
+ timeSinceLastInvoke = time - lastInvokeTime;
9789
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
9790
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
9791
+ }
9792
+ function timerExpired() {
9793
+ var time = now();
9794
+ if (shouldInvoke(time)) {
9795
+ return trailingEdge(time);
9796
+ }
9797
+ timerId = setTimeout(timerExpired, remainingWait(time));
9798
+ }
9799
+ function trailingEdge(time) {
9800
+ timerId = undefined;
9801
+ if (trailing && lastArgs) {
9802
+ return invokeFunc(time);
9803
+ }
9804
+ lastArgs = lastThis = undefined;
9805
+ return result;
9806
+ }
9807
+ function cancel() {
9808
+ if (timerId !== undefined) {
9809
+ clearTimeout(timerId);
9810
+ }
9811
+ lastInvokeTime = 0;
9812
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
9813
+ }
9814
+ function flush() {
9815
+ return timerId === undefined ? result : trailingEdge(now());
9816
+ }
9817
+ function debounced() {
9818
+ var time = now(),
9819
+ isInvoking = shouldInvoke(time);
9820
+ lastArgs = arguments;
9821
+ lastThis = this;
9822
+ lastCallTime = time;
9823
+ if (isInvoking) {
9824
+ if (timerId === undefined) {
9825
+ return leadingEdge(lastCallTime);
9826
+ }
9827
+ if (maxing) {
9828
+ timerId = setTimeout(timerExpired, wait);
9829
+ return invokeFunc(lastCallTime);
9830
+ }
9831
+ }
9832
+ if (timerId === undefined) {
9833
+ timerId = setTimeout(timerExpired, wait);
9834
+ }
9835
+ return result;
9836
+ }
9837
+ debounced.cancel = cancel;
9838
+ debounced.flush = flush;
9839
+ return debounced;
9840
+ }
9841
+ function isObject(value) {
9842
+ var type = typeof value;
9843
+ return !!value && (type == 'object' || type == 'function');
9844
+ }
9845
+ function isObjectLike(value) {
9846
+ return !!value && typeof value == 'object';
9847
+ }
9848
+ function isSymbol(value) {
9849
+ return typeof value == 'symbol' ||
9850
+ (isObjectLike(value) && objectToString.call(value) == symbolTag);
9851
+ }
9852
+ function toNumber(value) {
9853
+ if (typeof value == 'number') {
9854
+ return value;
9855
+ }
9856
+ if (isSymbol(value)) {
9857
+ return NAN;
9858
+ }
9859
+ if (isObject(value)) {
9860
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
9861
+ value = isObject(other) ? (other + '') : other;
9862
+ }
9863
+ if (typeof value != 'string') {
9864
+ return value === 0 ? value : +value;
9865
+ }
9866
+ value = value.replace(reTrim, '');
9867
+ var isBinary = reIsBinary.test(value);
9868
+ return (isBinary || reIsOctal.test(value))
9869
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
9870
+ : (reIsBadHex.test(value) ? NAN : +value);
9871
+ }
9872
+ var lodash_debounce = debounce;
9873
+ var debounce$1 = getDefaultExportFromCjs(lodash_debounce);
9874
+
9875
+ var extendStatics = function(d, b) {
9876
+ extendStatics = Object.setPrototypeOf ||
9877
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9878
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9879
+ return extendStatics(d, b);
9880
+ };
9881
+ function __extends(d, b) {
9882
+ extendStatics(d, b);
9883
+ function __() { this.constructor = d; }
9884
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9885
+ }
9886
+ var __assign = function() {
9887
+ __assign = Object.assign || function __assign(t) {
9888
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9889
+ s = arguments[i];
9890
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9891
+ }
9892
+ return t;
9893
+ };
9894
+ return __assign.apply(this, arguments);
9895
+ };
9896
+ var defaults = {
9897
+ autoActivateFirstSuggest: false,
9898
+ disabled: false,
9899
+ fixtures: [],
9900
+ getSuggestLabel: function (suggest) { return suggest.description; },
9901
+ highlightMatch: true,
9902
+ ignoreEnter: false,
9903
+ ignoreTab: false,
9904
+ initialValue: '',
9905
+ maxFixtures: 10,
9906
+ minLength: 1,
9907
+ onKeyDown: function () { },
9908
+ onKeyPress: function () { },
9909
+ placeholder: 'Search places',
9910
+ queryDelay: 250,
9911
+ skipSuggest: function () { return false; },
9912
+ style: {},
9913
+ inputType: 'text'
9914
+ };
9915
+ var allowedAttributes = [
9916
+ 'autoCapitalize',
9917
+ 'autoComplete',
9918
+ 'autoCorrect',
9919
+ 'autoFocus',
9920
+ 'disabled',
9921
+ 'form',
9922
+ 'formAction',
9923
+ 'formEncType',
9924
+ 'formMethod',
9925
+ 'formNoValidate',
9926
+ 'formTarget',
9927
+ 'height',
9928
+ 'inputMode',
9929
+ 'maxLength',
9930
+ 'name',
9931
+ 'onClick',
9932
+ 'onContextMenu',
9933
+ 'onCopy',
9934
+ 'onCut',
9935
+ 'onDoubleClick',
9936
+ 'onMouseDown',
9937
+ 'onMouseEnter',
9938
+ 'onMouseLeave',
9939
+ 'onMouseMove',
9940
+ 'onMouseOut',
9941
+ 'onMouseOver',
9942
+ 'onMouseUp',
9943
+ 'onPaste',
9944
+ 'pattern',
9945
+ 'placeholder',
9946
+ 'readOnly',
9947
+ 'required',
9948
+ 'size',
9949
+ 'spellCheck',
9950
+ 'tabIndex',
9951
+ 'title',
9952
+ 'aria-atomic',
9953
+ 'aria-busy',
9954
+ 'aria-controls',
9955
+ 'aria-current',
9956
+ 'aria-describedby',
9957
+ 'aria-details',
9958
+ 'aria-disabled',
9959
+ 'aria-dropeffect',
9960
+ 'aria-errormessage',
9961
+ 'aria-flowto',
9962
+ 'aria-grabbed',
9963
+ 'aria-haspopup',
9964
+ 'aria-hidden',
9965
+ 'aria-invalid',
9966
+ 'aria-keyshortcuts',
9967
+ 'aria-label',
9968
+ 'aria-labelledby',
9969
+ 'aria-live',
9970
+ 'aria-owns',
9971
+ 'aria-relevant',
9972
+ 'aria-roledescription',
9973
+ 'aria-activedescendant',
9974
+ 'aria-autocomplete',
9975
+ 'aria-multiline',
9976
+ 'aria-placeholder',
9977
+ 'aria-readonly',
9978
+ 'aria-required'
9979
+ ];
9980
+ function filterInputAttributes (props) {
9981
+ var attributes = {};
9982
+ Object.keys(props).forEach(function (attribute) {
9983
+ var isDataAttribute = attribute.startsWith('data-');
9984
+ var isAllowedAttribute = allowedAttributes.includes(attribute);
9985
+ if (isAllowedAttribute || isDataAttribute) {
9986
+ attributes[attribute] = props[attribute];
9987
+ }
9988
+ });
9989
+ return attributes;
9990
+ }
9991
+ var Input = (function (_super) {
9992
+ __extends(Input, _super);
9993
+ function Input(props) {
9994
+ var _this = _super.call(this, props) || this;
9995
+ _this.input = null;
9996
+ _this.onChange = _this.onChange.bind(_this);
9997
+ _this.onInputKeyDown = _this.onInputKeyDown.bind(_this);
9998
+ return _this;
9999
+ }
10000
+ Input.prototype.onChange = function () {
10001
+ if (this.input) {
10002
+ this.props.onChange(this.input.value);
10003
+ }
10004
+ };
10005
+ Input.prototype.onInputKeyDown = function (event) {
10006
+ if (this.props.onKeyDown) {
10007
+ this.props.onKeyDown(event);
10008
+ }
10009
+ switch (event.which) {
10010
+ case 40:
10011
+ if (!event.shiftKey) {
10012
+ event.preventDefault();
10013
+ this.props.onNext();
10014
+ }
10015
+ break;
10016
+ case 38:
10017
+ if (!event.shiftKey) {
10018
+ event.preventDefault();
10019
+ this.props.onPrev();
10020
+ }
10021
+ break;
10022
+ case 13:
10023
+ if (this.props.doNotSubmitOnEnter) {
10024
+ event.preventDefault();
10025
+ }
10026
+ if (!this.props.ignoreEnter) {
10027
+ this.props.onSelect();
10028
+ }
10029
+ break;
10030
+ case 9:
10031
+ if (!this.props.ignoreTab) {
10032
+ this.props.onSelect();
10033
+ }
10034
+ break;
10035
+ case 27:
10036
+ this.props.onEscape();
10037
+ break;
10038
+ }
10039
+ };
10040
+ Input.prototype.focus = function () {
10041
+ if (this.input) {
10042
+ this.input.focus();
10043
+ }
10044
+ };
10045
+ Input.prototype.blur = function () {
10046
+ if (this.input) {
10047
+ this.input.blur();
10048
+ }
10049
+ };
10050
+ Input.prototype.render = function () {
10051
+ var _this = this;
10052
+ var attributes = filterInputAttributes(this.props);
10053
+ var classes = classnames('geosuggest__input', this.props.className);
10054
+ var shouldRenderLabel = this.props.label && this.props.id;
10055
+ if (!attributes.tabIndex) {
10056
+ attributes.tabIndex = 0;
10057
+ }
10058
+ return (React.createElement(React.Fragment, null,
10059
+ shouldRenderLabel && (React.createElement("label", { className: "geosuggest__label", htmlFor: this.props.id }, this.props.label)),
10060
+ React.createElement("input", __assign({ className: classes, id: "geosuggest__input" + (this.props.id ? "--" + this.props.id : ''), ref: function (i) { return (_this.input = i); }, type: this.props.inputType }, attributes, { value: this.props.value, style: this.props.style, onKeyDown: this.onInputKeyDown, onChange: this.onChange, onKeyPress: this.props.onKeyPress, onFocus: this.props.onFocus, onBlur: this.props.onBlur, role: "combobox", "aria-expanded": !this.props.isSuggestsHidden, "aria-activedescendant": this.props.activeSuggest
10061
+ ? this.props.activeSuggest.placeId
10062
+ :
10063
+ undefined, "aria-owns": this.props.listId }))));
10064
+ };
10065
+ Input.defaultProps = {
10066
+ activeSuggest: null,
10067
+ autoComplete: 'nope',
10068
+ className: '',
10069
+ isSuggestsHidden: true,
10070
+ listId: '',
10071
+ inputType: 'text',
10072
+ onBlur: function () { },
10073
+ onChange: function () { },
10074
+ onEscape: function () { },
10075
+ onFocus: function () { },
10076
+ onKeyDown: function () { },
10077
+ onKeyPress: function () { },
10078
+ onNext: function () { },
10079
+ onPrev: function () { },
10080
+ onSelect: function () { },
10081
+ value: ''
10082
+ };
10083
+ return Input;
10084
+ }(React.PureComponent));
10085
+ var default_1 = (function (_super) {
10086
+ __extends(default_1, _super);
10087
+ function default_1(props) {
10088
+ var _this = _super.call(this, props) || this;
10089
+ _this.ref = null;
10090
+ _this.onClick = _this.onClick.bind(_this);
10091
+ return _this;
10092
+ }
10093
+ default_1.prototype.makeBold = function (element, key) {
10094
+ return (React.createElement("b", { className: "geosuggest__item__matched-text", key: key }, element));
10095
+ };
10096
+ default_1.prototype.formatMatchedText = function (userInput, suggest) {
10097
+ if (!userInput || !suggest.matchedSubstrings) {
10098
+ return suggest.label;
10099
+ }
10100
+ var start = suggest.matchedSubstrings.offset;
10101
+ var length = suggest.matchedSubstrings.length;
10102
+ var end = start + length;
10103
+ var boldPart = this.makeBold(suggest.label.substring(start, end), suggest.label);
10104
+ var pre = '';
10105
+ var post = '';
10106
+ if (start > 0) {
10107
+ pre = suggest.label.slice(0, start);
10108
+ }
10109
+ if (end < suggest.label.length) {
10110
+ post = suggest.label.slice(end);
10111
+ }
10112
+ return (React.createElement("span", null,
10113
+ pre,
10114
+ boldPart,
10115
+ post));
10116
+ };
10117
+ default_1.prototype.componentDidUpdate = function (prevProps) {
10118
+ if (!prevProps.isActive && this.props.isActive) {
10119
+ this.scrollIfNeeded();
10120
+ }
10121
+ };
10122
+ default_1.prototype.scrollIfNeeded = function () {
10123
+ var element = this.ref;
10124
+ var parent = element && element.parentElement;
10125
+ if (!element || !parent) {
10126
+ return;
10127
+ }
10128
+ var overTop = element.offsetTop - parent.offsetTop < parent.scrollTop;
10129
+ var overBottom = element.offsetTop - parent.offsetTop + element.clientHeight >
10130
+ parent.scrollTop + parent.clientHeight;
10131
+ if (overTop || overBottom) {
10132
+ parent.scrollTop =
10133
+ element.offsetTop -
10134
+ parent.offsetTop -
10135
+ parent.clientHeight / 2 +
10136
+ element.clientHeight / 2;
10137
+ }
10138
+ };
10139
+ default_1.prototype.onClick = function (event) {
10140
+ event.preventDefault();
10141
+ this.props.onSelect(this.props.suggest);
10142
+ };
10143
+ default_1.prototype.render = function () {
10144
+ var _a;
10145
+ var _this = this;
10146
+ var suggest = this.props.suggest;
10147
+ var classes = classnames('geosuggest__item', this.props.className, this.props.suggestItemClassName, { 'geosuggest__item--active': this.props.isActive }, (_a = {},
10148
+ _a[this.props.activeClassName || ''] = this.props.activeClassName
10149
+ ? this.props.isActive
10150
+ : null,
10151
+ _a));
10152
+ var content = suggest.label;
10153
+ if (this.props.renderSuggestItem) {
10154
+ content = this.props.renderSuggestItem(suggest, this.props.userInput);
10155
+ }
10156
+ else if (this.props.isHighlightMatch) {
10157
+ content = this.formatMatchedText(this.props.userInput, suggest);
10158
+ }
10159
+ return (React.createElement("li", { className: classes, ref: function (li) { return (_this.ref = li); }, style: this.props.style, onMouseDown: this.props.onMouseDown, onMouseOut: this.props.onMouseOut, onClick: this.onClick, role: "option", "aria-selected": this.props.isActive, id: suggest.placeId }, content));
10160
+ };
10161
+ return default_1;
10162
+ }(React.PureComponent));
10163
+ var default_1$1 = (function (_super) {
10164
+ __extends(default_1$1, _super);
10165
+ function default_1$1() {
10166
+ return _super !== null && _super.apply(this, arguments) || this;
10167
+ }
10168
+ default_1$1.prototype.isHidden = function () {
10169
+ return this.props.isHidden || this.props.suggests.length === 0;
10170
+ };
10171
+ default_1$1.prototype.componentDidUpdate = function (prevProps) {
10172
+ if (prevProps.suggests !== this.props.suggests) {
10173
+ if (this.props.suggests.length === 0) {
10174
+ this.props.onSuggestNoResults();
10175
+ }
10176
+ }
10177
+ };
10178
+ default_1$1.prototype.render = function () {
10179
+ var _a;
10180
+ var _this = this;
10181
+ var classes = classnames('geosuggest__suggests', this.props.suggestsClassName, { 'geosuggest__suggests--hidden': this.isHidden() }, (_a = {},
10182
+ _a[this.props.hiddenClassName || ''] = this.props.hiddenClassName
10183
+ ? this.isHidden()
10184
+ : null,
10185
+ _a));
10186
+ return (React.createElement("ul", { className: classes, style: this.props.style, role: "listbox", id: this.props.listId }, this.props.suggests.map(function (suggest) {
10187
+ var isActive = (_this.props.activeSuggest &&
10188
+ suggest.placeId === _this.props.activeSuggest.placeId) ||
10189
+ false;
10190
+ return (React.createElement(default_1, { key: suggest.placeId, className: suggest.className || '', userInput: _this.props.userInput, isHighlightMatch: _this.props.isHighlightMatch, suggest: suggest, style: _this.props.suggestItemStyle, suggestItemClassName: _this.props.suggestItemClassName, isActive: isActive, activeClassName: _this.props.suggestItemActiveClassName, onMouseDown: _this.props.onSuggestMouseDown, onMouseOut: _this.props.onSuggestMouseOut, onSelect: _this.props.onSuggestSelect, renderSuggestItem: _this.props.renderSuggestItem }));
10191
+ })));
10192
+ };
10193
+ return default_1$1;
10194
+ }(React.PureComponent));
10195
+ function escapeRegExp(str) {
10196
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
10197
+ }
10198
+ var default_1$2 = (function (_super) {
10199
+ __extends(default_1, _super);
10200
+ function default_1(props) {
10201
+ var _this = _super.call(this, props) || this;
10202
+ _this.googleMaps = null;
10203
+ _this.autocompleteService = null;
10204
+ _this.placesService = null;
10205
+ _this.sessionToken = undefined;
10206
+ _this.geocoder = null;
10207
+ _this.input = null;
10208
+ _this.state = {
10209
+ activeSuggest: null,
10210
+ ignoreBlur: false,
10211
+ isLoading: false,
10212
+ isSuggestsHidden: true,
10213
+ suggests: [],
10214
+ userInput: props.initialValue || ''
10215
+ };
10216
+ _this.onInputChange = _this.onInputChange.bind(_this);
10217
+ _this.onAfterInputChange = _this.onAfterInputChange.bind(_this);
10218
+ _this.onInputFocus = _this.onInputFocus.bind(_this);
10219
+ _this.onInputBlur = _this.onInputBlur.bind(_this);
10220
+ _this.onNext = _this.onNext.bind(_this);
10221
+ _this.onPrev = _this.onPrev.bind(_this);
10222
+ _this.onSelect = _this.onSelect.bind(_this);
10223
+ _this.onSuggestMouseDown = _this.onSuggestMouseDown.bind(_this);
10224
+ _this.onSuggestMouseOut = _this.onSuggestMouseOut.bind(_this);
10225
+ _this.onSuggestNoResults = _this.onSuggestNoResults.bind(_this);
10226
+ _this.hideSuggests = _this.hideSuggests.bind(_this);
10227
+ _this.selectSuggest = _this.selectSuggest.bind(_this);
10228
+ _this.listId = "geosuggest__list" + (props.id ? "--" + props.id : '');
10229
+ if (props.queryDelay) {
10230
+ _this.onAfterInputChange = debounce$1(_this.onAfterInputChange, props.queryDelay);
10231
+ }
10232
+ return _this;
10233
+ }
10234
+ default_1.prototype.componentDidUpdate = function (prevProps) {
10235
+ if (prevProps.initialValue !== this.props.initialValue) {
10236
+ this.setState({ userInput: this.props.initialValue || '' });
10237
+ }
10238
+ if (JSON.stringify(prevProps.fixtures) !== JSON.stringify(this.props.fixtures)) {
10239
+ this.searchSuggests();
10240
+ }
10241
+ };
10242
+ default_1.prototype.componentDidMount = function () {
10243
+ if (typeof window === 'undefined') {
10244
+ return;
10245
+ }
10246
+ var googleMaps = this.props.googleMaps ||
10247
+ (window.google && window.google.maps) ||
10248
+ this.googleMaps;
10249
+ if (!googleMaps) {
10250
+ if (console) {
10251
+ console.error('Google maps API was not found in the page.');
10252
+ }
10253
+ return;
10254
+ }
10255
+ this.googleMaps = googleMaps;
10256
+ this.autocompleteService = new googleMaps.places.AutocompleteService();
10257
+ this.placesService = new googleMaps.places.PlacesService(document.createElement('div'));
10258
+ this.sessionToken = new googleMaps.places.AutocompleteSessionToken();
10259
+ this.geocoder = new googleMaps.Geocoder();
10260
+ };
10261
+ default_1.prototype.componentWillUnmount = function () {
10262
+ clearTimeout(this.timer);
10263
+ };
10264
+ default_1.prototype.onInputChange = function (userInput) {
10265
+ if (!userInput) {
10266
+ if (this.props.onSuggestSelect) {
10267
+ this.props.onSuggestSelect();
10268
+ }
10269
+ }
10270
+ this.setState({ userInput: userInput }, this.onAfterInputChange);
10271
+ };
10272
+ default_1.prototype.onAfterInputChange = function () {
10273
+ this.showSuggests();
10274
+ if (this.props.onChange) {
10275
+ this.props.onChange(this.state.userInput);
10276
+ }
10277
+ };
10278
+ default_1.prototype.onInputFocus = function () {
10279
+ if (this.props.onFocus) {
10280
+ this.props.onFocus();
10281
+ }
10282
+ this.showSuggests();
10283
+ };
10284
+ default_1.prototype.onInputBlur = function () {
10285
+ if (!this.state.ignoreBlur) {
10286
+ this.hideSuggests();
10287
+ }
10288
+ };
10289
+ default_1.prototype.onNext = function () {
10290
+ this.activateSuggest('next');
10291
+ };
10292
+ default_1.prototype.onPrev = function () {
10293
+ this.activateSuggest('prev');
10294
+ };
10295
+ default_1.prototype.onSelect = function () {
10296
+ this.selectSuggest(this.state.activeSuggest);
10297
+ };
10298
+ default_1.prototype.onSuggestMouseDown = function () {
10299
+ this.setState({ ignoreBlur: true });
10300
+ };
10301
+ default_1.prototype.onSuggestMouseOut = function () {
10302
+ this.setState({ ignoreBlur: false });
10303
+ };
10304
+ default_1.prototype.onSuggestNoResults = function () {
10305
+ if (this.props.onSuggestNoResults) {
10306
+ this.props.onSuggestNoResults(this.state.userInput);
10307
+ }
10308
+ };
10309
+ default_1.prototype.focus = function () {
10310
+ if (this.input) {
10311
+ this.input.focus();
10312
+ }
10313
+ };
10314
+ default_1.prototype.blur = function () {
10315
+ if (this.input) {
10316
+ this.input.blur();
10317
+ }
10318
+ };
10319
+ default_1.prototype.update = function (userInput) {
10320
+ this.setState({ userInput: userInput });
10321
+ if (this.props.onChange) {
10322
+ this.props.onChange(userInput);
10323
+ }
10324
+ };
10325
+ default_1.prototype.clear = function () {
10326
+ this.setState({ userInput: '' }, this.hideSuggests);
10327
+ };
10328
+ default_1.prototype.searchSuggests = function () {
10329
+ var _this = this;
10330
+ if (!this.state.userInput) {
10331
+ this.updateSuggests();
10332
+ return;
10333
+ }
10334
+ var options = {
10335
+ input: this.state.userInput,
10336
+ sessionToken: this.sessionToken
10337
+ };
10338
+ var inputLength = this.state.userInput.length;
10339
+ var isShorterThanMinLength = this.props.minLength && inputLength < this.props.minLength;
10340
+ if (isShorterThanMinLength) {
10341
+ this.updateSuggests();
10342
+ return;
10343
+ }
10344
+ var _a = this.props, location = _a.location, radius = _a.radius, bounds = _a.bounds, types = _a.types, country = _a.country;
10345
+ if (location)
10346
+ options.location = location;
10347
+ if (radius)
10348
+ options.radius = Number(this.props.radius);
10349
+ if (bounds)
10350
+ options.bounds = bounds;
10351
+ if (types)
10352
+ options.types = types;
10353
+ if (country)
10354
+ options.componentRestrictions = { country: country };
10355
+ this.setState({ isLoading: true }, function () {
10356
+ if (!_this.autocompleteService) {
10357
+ _this.setState({ isLoading: false });
10358
+ return;
10359
+ }
10360
+ _this.autocompleteService.getPlacePredictions(options, function (suggestsGoogle) {
10361
+ _this.setState({ isLoading: false });
10362
+ _this.updateSuggests(suggestsGoogle || [],
10363
+ function () {
10364
+ if (_this.props.autoActivateFirstSuggest &&
10365
+ !_this.state.activeSuggest) {
10366
+ _this.activateSuggest('next');
10367
+ }
10368
+ });
10369
+ });
10370
+ });
10371
+ };
10372
+ default_1.prototype.updateSuggests = function (suggestsGoogle,
10373
+ callback) {
10374
+ var _this = this;
10375
+ if (suggestsGoogle === void 0) { suggestsGoogle = []; }
10376
+ if (callback === void 0) { callback = function () { }; }
10377
+ var suggests = [];
10378
+ var userInput = this.state.userInput;
10379
+ var _a = this.props, skipSuggest = _a.skipSuggest, maxFixtures = _a.maxFixtures, fixtures = _a.fixtures;
10380
+ var regex = new RegExp(escapeRegExp(userInput), 'gim');
10381
+ var fixturesSearched = 0;
10382
+ var activeSuggest = null;
10383
+ if (fixtures) {
10384
+ fixtures.forEach(function (fixture) {
10385
+ if (maxFixtures && fixturesSearched >= maxFixtures) {
10386
+ return;
10387
+ }
10388
+ if (skipSuggest &&
10389
+ !skipSuggest(fixture) &&
10390
+ fixture.label.match(regex)) {
10391
+ fixturesSearched++;
10392
+ suggests.push(__assign(__assign({}, fixture), { isFixture: true, matchedSubstrings: {
10393
+ length: userInput.length,
10394
+ offset: fixture.label.indexOf(userInput)
10395
+ }, placeId: fixture.placeId || fixture.label }));
10396
+ }
10397
+ });
10398
+ }
10399
+ suggestsGoogle.forEach(function (suggest) {
10400
+ if (skipSuggest && !skipSuggest(suggest)) {
10401
+ suggests.push({
10402
+ description: suggest.description,
10403
+ isFixture: false,
10404
+ label: _this.props.getSuggestLabel
10405
+ ? _this.props.getSuggestLabel(suggest)
10406
+ : '',
10407
+ matchedSubstrings: suggest.matched_substrings[0],
10408
+ placeId: suggest.place_id
10409
+ });
10410
+ }
10411
+ });
10412
+ activeSuggest = this.updateActiveSuggest(suggests);
10413
+ if (this.props.onUpdateSuggests) {
10414
+ this.props.onUpdateSuggests(suggests, activeSuggest);
10415
+ }
10416
+ this.setState({ suggests: suggests, activeSuggest: activeSuggest }, callback);
10417
+ };
10418
+ default_1.prototype.updateActiveSuggest = function (suggests) {
10419
+ if (suggests === void 0) { suggests = []; }
10420
+ var activeSuggest = this.state.activeSuggest;
10421
+ if (activeSuggest) {
10422
+ var newSuggest = suggests.filter(function (listedSuggest) {
10423
+ return activeSuggest &&
10424
+ activeSuggest.placeId === listedSuggest.placeId &&
10425
+ activeSuggest.isFixture === listedSuggest.isFixture;
10426
+ })[0];
10427
+ activeSuggest = newSuggest || null;
10428
+ }
10429
+ return activeSuggest;
10430
+ };
10431
+ default_1.prototype.showSuggests = function () {
10432
+ this.searchSuggests();
10433
+ this.setState({ isSuggestsHidden: false });
10434
+ };
10435
+ default_1.prototype.hideSuggests = function () {
10436
+ var _this = this;
10437
+ if (this.props.onBlur) {
10438
+ this.props.onBlur(this.state.userInput);
10439
+ }
10440
+ this.timer = window.setTimeout(function () {
10441
+ _this.setState({
10442
+ activeSuggest: null,
10443
+ isSuggestsHidden: true
10444
+ });
10445
+ }, 100);
10446
+ };
10447
+ default_1.prototype.activateSuggest = function (direction) {
10448
+ if (this.state.isSuggestsHidden) {
10449
+ this.showSuggests();
10450
+ return;
10451
+ }
10452
+ var suggestsCount = this.state.suggests.length - 1;
10453
+ var next = direction === 'next';
10454
+ var newActiveSuggest = null;
10455
+ var newIndex = 0;
10456
+ var i = 0;
10457
+ for (i; i <= suggestsCount; i++) {
10458
+ if (this.state.suggests[i] === this.state.activeSuggest) {
10459
+ newIndex = next ? i + 1 : i - 1;
10460
+ }
10461
+ }
10462
+ if (!this.state.activeSuggest) {
10463
+ newIndex = next ? 0 : suggestsCount;
10464
+ }
10465
+ if (newIndex >= 0 && newIndex <= suggestsCount) {
10466
+ newActiveSuggest = this.state.suggests[newIndex];
10467
+ }
10468
+ if (this.props.onActivateSuggest) {
10469
+ this.props.onActivateSuggest(newActiveSuggest);
10470
+ }
10471
+ this.setState({ activeSuggest: newActiveSuggest });
10472
+ };
10473
+ default_1.prototype.selectSuggest = function (suggestToSelect) {
10474
+ var suggest = suggestToSelect || {
10475
+ isFixture: true,
10476
+ label: this.state.userInput,
10477
+ placeId: this.state.userInput
10478
+ };
10479
+ if (!suggestToSelect &&
10480
+ this.props.autoActivateFirstSuggest &&
10481
+ this.state.suggests.length > 0) {
10482
+ suggest = this.state.suggests[0];
10483
+ }
10484
+ this.setState({
10485
+ isSuggestsHidden: true,
10486
+ userInput: typeof suggest.label !== 'object'
10487
+ ? suggest.label
10488
+ : suggest.description || ''
10489
+ });
10490
+ if (suggest.location) {
10491
+ this.setState({ ignoreBlur: false });
10492
+ if (this.props.onSuggestSelect) {
10493
+ this.props.onSuggestSelect(suggest);
10494
+ }
10495
+ return;
10496
+ }
10497
+ this.geocodeSuggest(suggest);
10498
+ };
10499
+ default_1.prototype.geocodeSuggest = function (suggestToGeocode) {
10500
+ var _this = this;
10501
+ if (!this.geocoder) {
10502
+ return;
10503
+ }
10504
+ if (suggestToGeocode.placeId &&
10505
+ !suggestToGeocode.isFixture &&
10506
+ this.placesService) {
10507
+ var options = {
10508
+ placeId: suggestToGeocode.placeId,
10509
+ sessionToken: this.sessionToken
10510
+ };
10511
+ if (this.props.placeDetailFields) {
10512
+ options.fields = this.props.placeDetailFields;
10513
+ options.fields.unshift('geometry');
10514
+ }
10515
+ this.placesService.getDetails(options, function (results, status) {
10516
+ if (status === _this.googleMaps.places.PlacesServiceStatus.OK) {
10517
+ var gmaps = results;
10518
+ var location_1 = (gmaps.geometry &&
10519
+ gmaps.geometry.location);
10520
+ var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: {
10521
+ lat: location_1.lat(),
10522
+ lng: location_1.lng()
10523
+ } });
10524
+ _this.sessionToken = new google.maps.places.AutocompleteSessionToken();
10525
+ if (_this.props.onSuggestSelect) {
10526
+ _this.props.onSuggestSelect(suggest);
10527
+ }
10528
+ }
10529
+ });
10530
+ }
10531
+ else {
10532
+ var options = {
10533
+ address: suggestToGeocode.label,
10534
+ bounds: this.props.bounds,
10535
+ componentRestrictions: this.props.country
10536
+ ? { country: this.props.country }
10537
+ :
10538
+ undefined,
10539
+ location: this.props.location
10540
+ };
10541
+ this.geocoder.geocode(options, function (results, status) {
10542
+ if (status === _this.googleMaps.GeocoderStatus.OK) {
10543
+ var gmaps = results[0];
10544
+ var location_2 = (gmaps.geometry &&
10545
+ gmaps.geometry.location);
10546
+ var suggest = __assign(__assign({}, suggestToGeocode), { gmaps: gmaps, location: {
10547
+ lat: location_2.lat(),
10548
+ lng: location_2.lng()
10549
+ } });
10550
+ if (_this.props.onSuggestSelect) {
10551
+ _this.props.onSuggestSelect(suggest);
10552
+ }
10553
+ }
10554
+ });
10555
+ }
10556
+ };
10557
+ default_1.prototype.render = function () {
10558
+ var _this = this;
10559
+ var attributes = filterInputAttributes(this.props);
10560
+ var classes = classnames('geosuggest', this.props.className, {
10561
+ 'geosuggest--loading': this.state.isLoading
10562
+ });
10563
+ var input = (React.createElement(Input, __assign({ className: this.props.inputClassName, ref: function (i) { return (_this.input = i); }, value: this.state.userInput, doNotSubmitOnEnter: !this.state.isSuggestsHidden, ignoreTab: this.props.ignoreTab, ignoreEnter: this.props.ignoreEnter, style: this.props.style && this.props.style.input, onChange: this.onInputChange, onFocus: this.onInputFocus, onBlur: this.onInputBlur, onKeyDown: this.props.onKeyDown, onKeyPress: this.props.onKeyPress, inputType: this.props.inputType, onNext: this.onNext, onPrev: this.onPrev, onSelect: this.onSelect, onEscape: this.hideSuggests, isSuggestsHidden: this.state.isSuggestsHidden, activeSuggest: this.state.activeSuggest, label: this.props.label, id: this.props.id, listId: this.listId }, attributes)));
10564
+ var suggestionsList = (React.createElement(default_1$1, { isHidden: this.state.isSuggestsHidden, style: this.props.style && this.props.style.suggests, suggestItemStyle: this.props.style && this.props.style.suggestItem, userInput: this.state.userInput, isHighlightMatch: Boolean(this.props.highlightMatch), suggestsClassName: this.props.suggestsClassName, suggestItemClassName: this.props.suggestItemClassName, suggests: this.state.suggests, hiddenClassName: this.props.suggestsHiddenClassName, suggestItemActiveClassName: this.props.suggestItemActiveClassName, activeSuggest: this.state.activeSuggest, onSuggestNoResults: this.onSuggestNoResults, onSuggestMouseDown: this.onSuggestMouseDown, onSuggestMouseOut: this.onSuggestMouseOut, onSuggestSelect: this.selectSuggest, renderSuggestItem: this.props.renderSuggestItem, listId: this.listId }));
10565
+ return (React.createElement("div", { className: classes, id: this.props.id },
10566
+ React.createElement("div", { className: "geosuggest__input-wrapper" }, input),
10567
+ React.createElement("div", { className: "geosuggest__suggests-wrapper" }, suggestionsList)));
10568
+ };
10569
+ default_1.defaultProps = defaults;
10570
+ return default_1;
10571
+ }(React.Component));
10572
+
9683
10573
  var AddressInputGroupForm = function (props) {
9684
- var _a = props.name, name = _a === void 0 ? 'address-input' : _a, label = props.label, description = props.description,
9685
- // placeholder,
9686
- required = props.required,
9687
- // value,
9688
- error = props.error, _b = props.type, type = _b === void 0 ? 'normal' : _b, isDisabled = props.isDisabled, _c = props.isRequired, isRequired = _c === void 0 ? false : _c, _d = props.isTouched, isTouched = _d === void 0 ? false : _d,
9689
- // onChange,
9690
- // onFocus,
9691
- // onBlur,
9692
- stylesOverrides = props.styles;
10574
+ var _a, _b, _c;
10575
+ var _d = props.name, name = _d === void 0 ? 'address-input' : _d, label = props.label, description = props.description, placeholder = props.placeholder, required = props.required, value = props.value, error = props.error, _e = props.type, type = _e === void 0 ? 'normal' : _e, isDisabled = props.isDisabled, _f = props.isRequired, isRequired = _f === void 0 ? false : _f, _g = props.isTouched, isTouched = _g === void 0 ? false : _g, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, stylesOverrides = props.styles;
9693
10576
  var isValid = error === undefined;
9694
10577
  var handleGenerateStyle = function () {
9695
10578
  var result = deepCopyObject(styles.base);
@@ -9700,23 +10583,80 @@ var AddressInputGroupForm = function (props) {
9700
10583
  return result;
9701
10584
  };
9702
10585
  var styles$1 = handleGenerateStyle();
9703
- // const mapValueToAddress = (
9704
- // value: TAddressInputGroupFormValue | undefined,
9705
- // ) => {
9706
- // if (!value) {
9707
- // return undefined;
9708
- // }
9709
- // const { country, city, street, houseNumber } = value;
9710
- // return `${street ?? ''}${houseNumber ? ' ' + houseNumber : ''}${
9711
- // city ? ', ' + city : ''
9712
- // }${country ? ', ' + country : ''}`;
9713
- // };
10586
+ var mapValueToAddress = function (value) {
10587
+ if (!value) {
10588
+ return undefined;
10589
+ }
10590
+ var country = value.country, city = value.city, street = value.street, houseNumber = value.houseNumber;
10591
+ return "".concat(street !== null && street !== void 0 ? street : '').concat(houseNumber ? ' ' + houseNumber : '').concat(city ? ', ' + city : '').concat(country ? ', ' + country : '');
10592
+ };
9714
10593
  // useEffect(() => {
9715
10594
  // if (form.values[name]) {
9716
10595
  // onChange && onChange(form.values[name]);
9717
10596
  // }
9718
10597
  // }, [form.values, name, onChange]);
9719
- return (jsxRuntime.jsxs("div", { className: styles$1.container, children: [jsxRuntime.jsxs("div", { className: styles$1.head, children: [label && (jsxRuntime.jsx("label", { htmlFor: name, className: styles$1.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsxRuntime.jsx("span", { className: styles$1.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxRuntime.jsx("div", { className: styles$1.body }), jsxRuntime.jsxs("div", { className: styles$1.foot, children: [description && !(error && isTouched) && (jsxRuntime.jsx("p", { className: styles$1.description, children: description })), error && isTouched && jsxRuntime.jsx("p", { className: styles$1.error, children: error })] })] }));
10598
+ return (jsxRuntime.jsxs("div", { className: styles$1.container, children: [jsxRuntime.jsxs("div", { className: styles$1.head, children: [label && (jsxRuntime.jsx("label", { htmlFor: name, className: styles$1.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsxRuntime.jsx("span", { className: styles$1.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxRuntime.jsx("div", { className: styles$1.body, children: jsxRuntime.jsx(default_1$2, { types: ['address'], queryDelay: 100, placeholder: placeholder, initialValue: mapValueToAddress(value), inputClassName: styles$1 === null || styles$1 === void 0 ? void 0 : styles$1.input, suggestsClassName: (_a = styles$1.geosuggest) === null || _a === void 0 ? void 0 : _a.suggestsClassName, suggestItemClassName: (_b = styles$1.geosuggest) === null || _b === void 0 ? void 0 : _b.suggestItemClassName, suggestsHiddenClassName: (_c = styles$1.geosuggest) === null || _c === void 0 ? void 0 : _c.suggestsHiddenClassName, onChange: function (value) {
10599
+ if (value === '') {
10600
+ onChange(null);
10601
+ }
10602
+ }, onFocus: onFocus,
10603
+ // suggestItemActiveClassName={
10604
+ // styles.geosuggest?.suggestItemActiveClassName
10605
+ // }
10606
+ autoComplete: "off", placeDetailFields: ['address_components'], onSuggestSelect: function (e) {
10607
+ var _a, _b, _c, _d, _e;
10608
+ var components = (_a = e === null || e === void 0 ? void 0 : e.gmaps) === null || _a === void 0 ? void 0 : _a.address_components;
10609
+ var handleExtractValueWithKey = function (key) {
10610
+ var _a;
10611
+ return (_a = components === null || components === void 0 ? void 0 : components.find(function (component) {
10612
+ return component.types.includes(key);
10613
+ })) === null || _a === void 0 ? void 0 : _a.long_name;
10614
+ };
10615
+ var street = handleExtractValueWithKey('route');
10616
+ var city = handleExtractValueWithKey('locality');
10617
+ var country = handleExtractValueWithKey('country');
10618
+ var zipCode = handleExtractValueWithKey('postal_code');
10619
+ var houseNumber = handleExtractValueWithKey('street_number');
10620
+ var busNumber = handleExtractValueWithKey('post_box');
10621
+ var location = {
10622
+ street: street,
10623
+ city: city,
10624
+ country: country,
10625
+ zipCode: zipCode,
10626
+ houseNumber: houseNumber,
10627
+ busNumber: busNumber,
10628
+ lat: (_c = (_b = e === null || e === void 0 ? void 0 : e.location) === null || _b === void 0 ? void 0 : _b.lat) !== null && _c !== void 0 ? _c : 0,
10629
+ lng: (_e = (_d = e === null || e === void 0 ? void 0 : e.location) === null || _d === void 0 ? void 0 : _d.lng) !== null && _e !== void 0 ? _e : 0,
10630
+ };
10631
+ onChange && onChange(location);
10632
+ }, onBlur: function (e) {
10633
+ var _a, _b, _c, _d, _e;
10634
+ var components = (_a = e === null || e === void 0 ? void 0 : e.gmaps) === null || _a === void 0 ? void 0 : _a.address_components;
10635
+ var handleExtractValueWithKey = function (key) {
10636
+ var _a;
10637
+ return (_a = components === null || components === void 0 ? void 0 : components.find(function (component) {
10638
+ return component.types.includes(key);
10639
+ })) === null || _a === void 0 ? void 0 : _a.long_name;
10640
+ };
10641
+ var street = handleExtractValueWithKey('route');
10642
+ var city = handleExtractValueWithKey('locality');
10643
+ var country = handleExtractValueWithKey('country');
10644
+ var zipCode = handleExtractValueWithKey('postal_code');
10645
+ var houseNumber = handleExtractValueWithKey('street_number');
10646
+ var busNumber = handleExtractValueWithKey('post_box');
10647
+ var location = {
10648
+ street: street,
10649
+ city: city,
10650
+ country: country,
10651
+ zipCode: zipCode,
10652
+ houseNumber: houseNumber,
10653
+ busNumber: busNumber,
10654
+ lat: (_c = (_b = e === null || e === void 0 ? void 0 : e.location) === null || _b === void 0 ? void 0 : _b.lat) !== null && _c !== void 0 ? _c : 0,
10655
+ lng: (_e = (_d = e === null || e === void 0 ? void 0 : e.location) === null || _d === void 0 ? void 0 : _d.lng) !== null && _e !== void 0 ? _e : 0,
10656
+ info: value === null || value === void 0 ? void 0 : value.info,
10657
+ };
10658
+ onBlur && onBlur(location);
10659
+ }, children: jsxRuntime.jsx(jsxRuntime.Fragment, {}) }) }), jsxRuntime.jsxs("div", { className: styles$1.foot, children: [description && !(error && isTouched) && (jsxRuntime.jsx("p", { className: styles$1.description, children: description })), error && isTouched && jsxRuntime.jsx("p", { className: styles$1.error, children: error })] })] }));
9720
10660
  };
9721
10661
 
9722
10662
  var base = {