@ballistix.digital/react-components 0.5.1 → 0.5.3

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