@tripian/react 9.1.44 → 9.1.45

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.
Files changed (3) hide show
  1. package/index.js +11 -45
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -33050,49 +33050,7 @@ __webpack_require__(890);
33050
33050
  const GPlacesAutocomplete2 = ({ onSelectedChanged, initialText, boundry, placeholder, disabled, onFocus, onBlur }) => {
33051
33051
  const [text, setText] = (0, react_1.useState)(initialText);
33052
33052
  const [initialized, setInitialized] = (0, react_1.useState)(false);
33053
- const [hasSelection, setHasSelection] = (0, react_1.useState)(false);
33054
33053
  const placesAutocomplete = (0, react_1.useRef)();
33055
- const isPacItemClick = (0, react_1.useRef)(false);
33056
- (0, react_1.useEffect)(() => {
33057
- const handleMouseDown = (e) => {
33058
- const target = e.target;
33059
- if (target && target.classList && target.classList.contains('pac-item')) {
33060
- isPacItemClick.current = true;
33061
- }
33062
- };
33063
- window.addEventListener('mousedown', handleMouseDown);
33064
- return () => {
33065
- window.removeEventListener('mousedown', handleMouseDown);
33066
- };
33067
- }, []);
33068
- const handleEnterKey = (event) => {
33069
- if (event.key === 'Enter') {
33070
- event.preventDefault();
33071
- const firstPrediction = document.querySelector('.pac-item');
33072
- if (firstPrediction) {
33073
- const input = document.getElementById('google-autocompelete');
33074
- const simulatedDownArrow = new KeyboardEvent('keydown', { keyCode: 40 });
33075
- input.dispatchEvent(simulatedDownArrow);
33076
- const simulatedEnter = new KeyboardEvent('keydown', { keyCode: 13 });
33077
- input.dispatchEvent(simulatedEnter);
33078
- }
33079
- }
33080
- };
33081
- const handleBlur = () => {
33082
- setTimeout(() => {
33083
- if (isPacItemClick.current) {
33084
- isPacItemClick.current = false;
33085
- return;
33086
- }
33087
- if (!hasSelection) {
33088
- setText('');
33089
- onSelectedChanged({ name: '' });
33090
- }
33091
- if (onBlur) {
33092
- onBlur();
33093
- }
33094
- }, 200);
33095
- };
33096
33054
  /**
33097
33055
  * initialize
33098
33056
  */
@@ -33108,15 +33066,20 @@ const GPlacesAutocomplete2 = ({ onSelectedChanged, initialText, boundry, placeho
33108
33066
  strictBounds: true,
33109
33067
  };
33110
33068
  placesAutocomplete.current = new google.maps.places.Autocomplete(document.getElementById('google-autocompelete'), autocompleteOptions);
33069
+ // console.log('setTimeout set 1');
33111
33070
  setTimeout(() => {
33071
+ // if (!unmounted) {
33112
33072
  const pacContainerParent = document.getElementById('pac-container-parent');
33113
33073
  const pacContainer = document.getElementsByClassName('pac-container')[0];
33114
33074
  if (pacContainer)
33115
33075
  pacContainerParent === null || pacContainerParent === void 0 ? void 0 : pacContainerParent.appendChild(pacContainer);
33076
+ // console.log('setTimeout set 2');
33077
+ // }
33116
33078
  }, 1000);
33117
33079
  setInitialized(true);
33118
33080
  };
33119
33081
  init();
33082
+ // console.log('useEffect init');
33120
33083
  return () => {
33121
33084
  const pacContainers = document.getElementsByClassName('pac-container');
33122
33085
  for (let i = 0; i < pacContainers.length; i += 1) {
@@ -33137,7 +33100,6 @@ const GPlacesAutocomplete2 = ({ onSelectedChanged, initialText, boundry, placeho
33137
33100
  const displayText = [place.name, place.formatted_address].filter(Boolean).join(' ');
33138
33101
  setText(displayText || '');
33139
33102
  onSelectedChanged(place);
33140
- setHasSelection(true);
33141
33103
  }
33142
33104
  });
33143
33105
  return () => {
@@ -33150,11 +33112,15 @@ const GPlacesAutocomplete2 = ({ onSelectedChanged, initialText, boundry, placeho
33150
33112
  * setBounds
33151
33113
  */
33152
33114
  (0, react_1.useEffect)(() => {
33115
+ // console.log(boundry);
33153
33116
  if (placesAutocomplete.current && boundry) {
33154
33117
  placesAutocomplete.current.setBounds(boundry);
33155
33118
  }
33119
+ // console.log('initialized, boundry');
33120
+ // console.log('setBounds');
33156
33121
  }, [initialized, boundry]);
33157
33122
  (0, react_1.useEffect)(() => {
33123
+ // console.log('useEffect initialText');
33158
33124
  setText(initialText);
33159
33125
  }, [initialText]);
33160
33126
  return (react_1.default.createElement(react_1.default.Fragment, null,
@@ -33162,9 +33128,9 @@ const GPlacesAutocomplete2 = ({ onSelectedChanged, initialText, boundry, placeho
33162
33128
  if (!newText.target.value) {
33163
33129
  onSelectedChanged({ name: '' });
33164
33130
  }
33131
+ // console.log(newText.target.value);
33165
33132
  setText(newText.target.value);
33166
- setHasSelection(false);
33167
- }, className: "gplaces-autocomplete", disabled: disabled, onFocus: onFocus, onBlur: handleBlur, onKeyDown: handleEnterKey }),
33133
+ }, disabled: disabled, onFocus: onFocus, onBlur: onBlur }),
33168
33134
  react_1.default.createElement("div", { id: "pac-container-parent" })));
33169
33135
  };
33170
33136
  exports.default = GPlacesAutocomplete2;