google-maps-react-markers 2.0.1 → 2.0.5

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/README.md CHANGED
@@ -88,7 +88,7 @@ const App = () => {
88
88
 
89
89
  // inside the map instance you can call any google maps method
90
90
  mapRef.current.setCenter({ lat, lng })
91
- // rif. https://developers.google.com/maps/documentation/javascript/reference?hl=it
91
+ // ref. https://developers.google.com/maps/documentation/javascript/reference?hl=it
92
92
  }
93
93
 
94
94
  return (
@@ -189,18 +189,18 @@ const onMapChange = ({ bounds, zoom }) => {
189
189
  To run the project locally, clone the repo and run:
190
190
 
191
191
  ```bash
192
+ # in the root directory
192
193
  yarn install
193
- yarn dev
194
194
  ```
195
195
 
196
196
  ```bash
197
- # in another tab
197
+ # in another tab (with NextJS and SSR)
198
198
  cd docs
199
199
  yarn install
200
200
  yarn dev
201
201
  ```
202
202
 
203
- Do your changes to `src/` or `docs/src` directory, commits all files (ones in `dist` too) and open a PR.
203
+ Do your changes to `src/` or `docs/src` directory, commits all files in the root directory (`yarn.lock` and ones in `dist` too) and open a PR.
204
204
 
205
205
  ## 💻 Built with
206
206
 
package/dist/index.cjs CHANGED
@@ -4,8 +4,6 @@ var react = require('react');
4
4
  var reactDom = require('react-dom');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
 
7
- var x={};function X(e){let r=document.querySelector(`script[src="${e}"]`),n=r==null?void 0:r.getAttribute("data-status");return {node:r,status:n}}function Y(e={src:"",attributes:{},callbacks:{onLoadCallback:()=>{},onErrorCallback:()=>{}},elementIdToAppend:""},r,n={removeOnUnmount:!1,shouldPreventLoad:!1}){let[l,s]=react.useState(()=>!e.src||n!=null&&n.shouldPreventLoad?"idle":typeof window>"u"?"loading":x[e.src]??"loading");return react.useEffect(()=>{var g,a,d;if(r){s(r);return}if(!(e!=null&&e.src)||n!=null&&n.shouldPreventLoad)return;let i=x[e.src];if(i==="ready"||i==="error"){s(i);return}let c=X(e.src),t=c.node;if(t){let p=c.status??i??"loading";switch(p){case"loading":case"ready":(a=e.callbacks)!=null&&a.onLoadCallback&&e.callbacks.onLoadCallback();break;case"error":(d=e.callbacks)!=null&&d.onErrorCallback&&e.callbacks.onErrorCallback();break;}s(p);}else {t=document.createElement("script"),t.src=e.src,t.async=!0,t.setAttribute("data-status","loading"),e.attributes&&Object.entries(e.attributes).length>0&&Object.entries(e.attributes).map(([u,m])=>t==null?void 0:t.setAttribute(u,m)),e.elementIdToAppend&&document.getElementById(e.elementIdToAppend)?(g=document.getElementById(e.elementIdToAppend))==null||g.appendChild(t):document.body.appendChild(t);let p=u=>{let m=u.type==="load"?"ready":"error";t==null||t.setAttribute("data-status",m);};t.addEventListener("load",p),t.addEventListener("error",p);}let o=p=>{var m,f;let u=p.type==="load"?"ready":"error";p.type==="load"?(m=e.callbacks)!=null&&m.onLoadCallback&&e.callbacks.onLoadCallback():(f=e.callbacks)!=null&&f.onErrorCallback&&e.callbacks.onErrorCallback(),s(u),x[e.src]=u;};return t.addEventListener("load",o),t.addEventListener("error",o),()=>{t&&(t.removeEventListener("load",o),t.removeEventListener("error",o)),t&&(n!=null&&n.removeOnUnmount)&&t.remove();}},[e,r,l]),l}var D=Y;var O=({apiKey:e,libraries:r=[],loadScriptExternally:n=!1,status:l="idle",externalApiParams:s,callback:i})=>{var o;typeof window<"u"&&(window.googleMapsCallback=i);let c=(o=new URLSearchParams(s))==null?void 0:o.toString(),t=e?{src:`https://maps.googleapis.com/maps/api/js?key=${e}&callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}${c?`&${c}`:""}`,attributes:{id:"googleMapsApi"}}:{src:`https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}`,attributes:{id:"googleMapsApi"}};return D(t,n?l:void 0)};var R=(e,r,n=1e-6)=>{if(e&&r){for(let l=0;l!==e.length;++l)if(Math.abs(e[l]-r[l])>n)return !1;return !0}return !1};var Q=(e,r)=>{let n=react.useRef(),l=n.current,s=r(l,e);return react.useEffect(()=>{s||(n.current=e);}),s?l:e},T=Q;var h=e=>{try{return {lat:e==null?void 0:e.lat(),lng:e==null?void 0:e.lng()}}catch{return e}},Z=({container:e,pane:r,position:n,maps:l,drag:s})=>{class i extends google.maps.OverlayView{onAdd=()=>{var g;let t=this;s!=null&&s.draggable&&(this.get("map").getDiv().addEventListener("mouseleave",()=>{google.maps.event.trigger(this.container,"mouseup");}),this.container.addEventListener("mousedown",a=>{var d;this.container.style.cursor="grabbing",(d=t.map)==null||d.set("draggable",!1),t.set("origin",a),s.onDragStart(a,{latLng:h(this.position)}),t.moveHandler=this.get("map").getDiv().addEventListener("mousemove",p=>{let u=t.get("origin"),m=u.clientX-p.clientX,f=u.clientY-p.clientY,L=t.getProjection().fromLatLngToDivPixel(t.position);if(L===null)return;let M=t.getProjection().fromDivPixelToLatLng(new l.Point(L.x-m,L.y-f));t.set("position",M),t.set("origin",p),t.draw(),s.onDrag(p,{latLng:h(M)});});}),this.container.addEventListener("mouseup",a=>{var d;(d=t.map)==null||d.set("draggable",!0),this.container.style.cursor="default",t.moveHandler&&(google.maps.event.removeListener(t.moveHandler),t.moveHandler=null),s.onDragEnd(a,{latLng:h(t.position)});}));let o=(g=this.getPanes())==null?void 0:g[this.pane];o==null||o.classList.add("google-map-markers-overlay"),o==null||o.appendChild(this.container);};draw=()=>{let o=this.getProjection().fromLatLngToDivPixel(this.position);o!==null&&(this.container.style.transform=`translate(${o.x}px, ${o.y}px)`,this.container.style.width="0px",this.container.style.height="0px");};onRemove=()=>{this.container.parentNode!==null&&(google.maps.event.clearInstanceListeners(this.container),this.container.parentNode.removeChild(this.container));};container;pane;position;map=this.getMap();moveHandler;constructor(t,o,g){super(),this.container=t,this.pane=o,this.position=g,this.moveHandler=null;}}return new i(e,r,n)},H=Z;var ee=({pane:e="floatPane",position:r,map:n,maps:l,zIndex:s=0,children:i,drag:c})=>{let t=react.useMemo(()=>{let a=document.createElement("div");return a.style.position="absolute",a},[]),o=react.useMemo(()=>H({container:t,pane:e,position:r,maps:l,drag:c}),[t,c,l,e,r]),g=T(i==null?void 0:i.props,(a,d)=>a&&a.lat===d.lat&&a.lng===d.lng);return react.useEffect(()=>!o.map&&n?(o==null||o.setMap(n),()=>{o==null||o.setMap(null);}):()=>{},[n,g]),react.useEffect(()=>{t.style.zIndex=`${s}`;},[s,t]),reactDom.createPortal(i,t)},G=ee;var S=()=>{},ne=({children:e,map:r,maps:n})=>{let l=react.useMemo(()=>!r||!n?[]:react.Children.map(e,s=>{if(react.isValidElement(s)){let i={lat:s.props.lat,lng:s.props.lng},{zIndex:c,draggable:t=!1,onDragStart:o=S,onDrag:g=S,onDragEnd:a=S}=s.props||{};return s=react.cloneElement(s,{...s.props,draggable:void 0,onDragStart:void 0,onDrag:void 0,onDragEnd:void 0}),jsxRuntime.jsx(G,{position:new n.LatLng(i.lat,i.lng),map:r,maps:n,zIndex:c,drag:{draggable:t,onDragStart:o,onDrag:g,onDragEnd:a},children:s})}return null}),[e,r,n]);return jsxRuntime.jsx("div",{children:l})},j=ne;function le({children:e=null,style:r={width:"100%",height:"100%",left:0,top:0,margin:0,padding:0,position:"absolute"},defaultCenter:n,defaultZoom:l,onGoogleApiLoaded:s,onChange:i,options:c={},events:t=[]}){let o=react.useRef(null),g=react.useRef(),[a,d]=react.useState(),[p,u]=react.useState(),[m,f]=react.useState(!1),L=react.useCallback(()=>{var M,b;try{if(!a)return;let y=a.getZoom()??l,v=a.getBounds(),q=[(M=a.getCenter())==null?void 0:M.lng(),(b=a.getCenter())==null?void 0:b.lat()],E=v==null?void 0:v.getNorthEast(),P=v==null?void 0:v.getSouthWest();if(!E||!P||!v)return;let w=[P.lng(),P.lat(),E.lng(),E.lat()];R(w,g.current)||(i&&i({zoom:y,center:q,bounds:v}),g.current=w);}catch(y){console.error(y);}},[a,i]);return react.useEffect(()=>{o.current&&!a&&(d(new google.maps.Map(o.current,{center:n,zoom:l,...c})),u(google.maps));},[n,l,a,o,c]),react.useEffect(()=>{a&&(m||(s&&p&&s({map:a,maps:p,ref:o.current}),f(!0)),google.maps.event.clearListeners(a,"idle"),google.maps.event.addListener(a,"idle",L));},[m,a,p,i,s,L]),react.useEffect(()=>()=>{a&&google.maps.event.clearListeners(a,"idle");},[a]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:r,className:"google-map",...t==null?void 0:t.reduce((M,{name:b,handler:y})=>(M[b]=y,M),{})}),e&&a&&p&&jsxRuntime.jsx(j,{map:a,maps:p,children:e})]})}var V=le;var ge=react.forwardRef(({apiKey:e="",libraries:r=["places","geometry"],children:n=null,loadingContent:l="Google Maps is loading",idleContent:s="Google Maps is on idle",errorContent:i="Google Maps is on error",mapMinHeight:c="unset",containerProps:t={},loadScriptExternally:o=!1,status:g="idle",scriptCallback:a=()=>{},externalApiParams:d={},...p},u)=>{let m={ready:jsxRuntime.jsx(V,{...p,children:n}),loading:l,idle:s,error:i},f=O({apiKey:e,libraries:r,loadScriptExternally:o,status:g,externalApiParams:d,callback:a});return jsxRuntime.jsx("div",{ref:u,style:{height:"100%",width:"100%",overflow:"hidden",position:"relative",minHeight:c},...t,children:m[f]||null})}),z=ge;window.googleMapsCallback=()=>{};window.google=void 0;var Be=z;
7
+ var S={};function Y(e){let r=document.querySelector(`script[src="${e}"]`),a=r==null?void 0:r.getAttribute("data-status");return {node:r,status:a}}function J(e={src:"",attributes:{},callbacks:{onLoadCallback:()=>{},onErrorCallback:()=>{}},elementIdToAppend:""},r,a={removeOnUnmount:!1,shouldPreventLoad:!1}){let[l,s]=react.useState(()=>!e.src||a!=null&&a.shouldPreventLoad?"idle":typeof window>"u"?"loading":S[e.src]??"loading");return react.useEffect(()=>{var u,n,m;if(r){s(r);return}if(!(e!=null&&e.src)||a!=null&&a.shouldPreventLoad)return;let i=S[e.src];if(i==="ready"||i==="error"){s(i);return}let c=Y(e.src),t=c.node;if(t){let p=c.status??i??"loading";switch(p){case"loading":case"ready":(n=e.callbacks)!=null&&n.onLoadCallback&&e.callbacks.onLoadCallback();break;case"error":(m=e.callbacks)!=null&&m.onErrorCallback&&e.callbacks.onErrorCallback();break;}s(p);}else {t=document.createElement("script"),t.src=e.src,t.async=!0,t.setAttribute("data-status","loading"),e.attributes&&Object.entries(e.attributes).length>0&&Object.entries(e.attributes).map(([g,d])=>t==null?void 0:t.setAttribute(g,d)),e.elementIdToAppend&&document.getElementById(e.elementIdToAppend)?(u=document.getElementById(e.elementIdToAppend))==null||u.appendChild(t):document.body.appendChild(t);let p=g=>{let d=g.type==="load"?"ready":"error";t==null||t.setAttribute("data-status",d);};t.addEventListener("load",p),t.addEventListener("error",p);}let o=p=>{var d,f;let g=p.type==="load"?"ready":"error";p.type==="load"?(d=e.callbacks)!=null&&d.onLoadCallback&&e.callbacks.onLoadCallback():(f=e.callbacks)!=null&&f.onErrorCallback&&e.callbacks.onErrorCallback(),s(g),S[e.src]=g;};return t.addEventListener("load",o),t.addEventListener("error",o),()=>{t&&(t.removeEventListener("load",o),t.removeEventListener("error",o)),t&&(a!=null&&a.removeOnUnmount)&&t.remove();}},[e,r,l]),l}var O=J;var T=({apiKey:e,libraries:r=[],loadScriptExternally:a=!1,status:l="idle",externalApiParams:s,callback:i})=>{var o;typeof window<"u"&&(window.googleMapsCallback=i);let c=(o=new URLSearchParams(s))==null?void 0:o.toString(),t=e?{src:`https://maps.googleapis.com/maps/api/js?key=${e}&callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}${c?`&${c}`:""}`,attributes:{id:"googleMapsApi"}}:{src:`https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}`,attributes:{id:"googleMapsApi"}};return O(t,a?l:void 0)};var x=(e,r,a=1e-6)=>{if(e&&r){for(let l=0;l!==e.length;++l)if(Math.abs(e[l]-r[l])>a)return !1;return !0}return !1};var _=(e,r)=>{let a=react.useRef(),l=a.current,s=r(l,e);return react.useEffect(()=>{s||(a.current=e);}),s?l:e},H=_;var k=e=>{try{return {lat:e==null?void 0:e.lat(),lng:e==null?void 0:e.lng()}}catch{return e}},K=({container:e,pane:r,position:a,maps:l,drag:s})=>{class i extends google.maps.OverlayView{onAdd=()=>{var u;let t=this;s!=null&&s.draggable&&(this.get("map").getDiv().addEventListener("mouseleave",()=>{google.maps.event.trigger(this.container,"mouseup");}),this.container.addEventListener("mousedown",n=>{var m;this.container.style.cursor="grabbing",(m=t.map)==null||m.set("draggable",!1),t.set("origin",n),s.onDragStart(n,{latLng:k(this.position)}),t.moveHandler=this.get("map").getDiv().addEventListener("mousemove",p=>{let g=t.get("origin"),d=g.clientX-p.clientX,f=g.clientY-p.clientY,b=t.getProjection().fromLatLngToDivPixel(t.position);if(b===null)return;let v=t.getProjection().fromDivPixelToLatLng(new l.Point(b.x-d,b.y-f));t.set("position",v),t.set("origin",p),t.draw(),s.onDrag(p,{latLng:k(v)});});}),this.container.addEventListener("mouseup",n=>{var m;(m=t.map)==null||m.set("draggable",!0),this.container.style.cursor="default",t.moveHandler&&(google.maps.event.removeListener(t.moveHandler),t.moveHandler=null),s.onDragEnd(n,{latLng:k(t.position)});}));let o=(u=this.getPanes())==null?void 0:u[this.pane];o==null||o.classList.add("google-map-markers-overlay"),o==null||o.appendChild(this.container);};draw=()=>{let o=this.getProjection().fromLatLngToDivPixel(this.position);o!==null&&(this.container.style.transform=`translate(${o.x}px, ${o.y}px)`,this.container.style.width="0px",this.container.style.height="0px");};onRemove=()=>{this.container.parentNode!==null&&(google.maps.event.clearInstanceListeners(this.container),this.container.parentNode.removeChild(this.container));};container;pane;position;map=this.getMap();moveHandler;constructor(t,o,u){super(),this.container=t,this.pane=o,this.position=u,this.moveHandler=null;}}return new i(e,r,a)},U=K;var ee=({pane:e="floatPane",position:r,map:a,maps:l,zIndex:s=0,children:i,drag:c})=>{let t=react.useMemo(()=>{let n=document.createElement("div");return n.style.position="absolute",n},[]),o=react.useMemo(()=>U({container:t,pane:e,position:r,maps:l,drag:c}),[t,c,l,e,r]),u=H(i==null?void 0:i.props,(n,m)=>n&&n.lat===m.lat&&n.lng===m.lng);return react.useEffect(()=>!o.map&&a?(o==null||o.setMap(a),()=>{o==null||o.setMap(null);}):()=>{},[a,u]),react.useEffect(()=>{t.style.zIndex=`${s}`;},[s,t]),reactDom.createPortal(i,t)},R=ee;var P=()=>{},ae=({children:e,map:r,maps:a})=>{let l=react.useMemo(()=>!r||!a?[]:react.Children.map(e,s=>{if(react.isValidElement(s)){let i={lat:s.props.lat,lng:s.props.lng},{zIndex:c,draggable:t=!1,onDragStart:o=P,onDrag:u=P,onDragEnd:n=P}=s.props||{};return s=react.cloneElement(s,{...s.props,draggable:void 0,onDragStart:void 0,onDrag:void 0,onDragEnd:void 0}),jsxRuntime.jsx(R,{position:new a.LatLng(i.lat,i.lng),map:r,maps:a,zIndex:c,drag:{draggable:t,onDragStart:o,onDrag:u,onDragEnd:n},children:s})}return null}),[e,r,a]);return jsxRuntime.jsx("div",{children:l})},j=ae;function le({children:e=null,style:r={width:"100%",height:"100%",left:0,top:0,margin:0,padding:0,position:"absolute"},defaultCenter:a,defaultZoom:l,onGoogleApiLoaded:s,onChange:i,options:c={},events:t=[]}){let o=react.useRef(null),u=react.useRef([]),[n,m]=react.useState(),[p,g]=react.useState(),[d,f]=react.useState(!1),b=react.useCallback(()=>{var v,y;try{if(!n)return;let E=n.getZoom()??l,M=n.getBounds(),F=[(v=n.getCenter())==null?void 0:v.lng(),(y=n.getCenter())==null?void 0:y.lat()],L=M==null?void 0:M.getNorthEast(),h=M==null?void 0:M.getSouthWest();if(!L||!h||!M)return;let D=[h.lng(),h.lat(),L.lng(),L.lat()];x(D,u.current)||(i&&i({zoom:E,center:F,bounds:M}),u.current=D);}catch(E){console.error(E);}},[n,i]);return react.useEffect(()=>{o.current&&!n&&(m(new google.maps.Map(o.current,{center:a,zoom:l,...c})),g(google.maps));},[a,l,n,o,c]),react.useEffect(()=>{n&&(d||(s&&p&&s({map:n,maps:p,ref:o.current}),f(!0)),google.maps.event.clearListeners(n,"idle"),google.maps.event.addListener(n,"idle",b));},[d,n,p,i,s,b]),react.useEffect(()=>()=>{n&&google.maps.event.clearListeners(n,"idle");},[n]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:r,className:"google-map",...t==null?void 0:t.reduce((v,{name:y,handler:E})=>(v[y]=E,v),{})}),e&&n&&p&&jsxRuntime.jsx(j,{map:n,maps:p,children:e})]})}var q=le;var ue=react.forwardRef(({apiKey:e="",libraries:r=["places","geometry"],children:a=null,loadingContent:l="Google Maps is loading",idleContent:s="Google Maps is on idle",errorContent:i="Google Maps is on error",mapMinHeight:c="unset",containerProps:t={},loadScriptExternally:o=!1,status:u="idle",scriptCallback:n=()=>{},externalApiParams:m={},...p},g)=>{let d={ready:jsxRuntime.jsx(q,{...p,children:a}),loading:l,idle:s,error:i},f=T({apiKey:e,libraries:r,loadScriptExternally:o,status:u,externalApiParams:m,callback:n});return jsxRuntime.jsx("div",{ref:g,style:{height:"100%",width:"100%",overflow:"hidden",position:"relative",minHeight:c},...t,children:d[f]||null})}),B=ue;var qe=B;
8
8
 
9
- module.exports = Be;
10
- //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=index.cjs.map
9
+ module.exports = qe;
package/dist/index.js CHANGED
@@ -2,8 +2,6 @@ import { forwardRef, useRef, useState, useCallback, useEffect, useMemo, Children
2
2
  import { createPortal } from 'react-dom';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
 
5
- var x={};function X(e){let r=document.querySelector(`script[src="${e}"]`),n=r==null?void 0:r.getAttribute("data-status");return {node:r,status:n}}function Y(e={src:"",attributes:{},callbacks:{onLoadCallback:()=>{},onErrorCallback:()=>{}},elementIdToAppend:""},r,n={removeOnUnmount:!1,shouldPreventLoad:!1}){let[l,s]=useState(()=>!e.src||n!=null&&n.shouldPreventLoad?"idle":typeof window>"u"?"loading":x[e.src]??"loading");return useEffect(()=>{var g,a,d;if(r){s(r);return}if(!(e!=null&&e.src)||n!=null&&n.shouldPreventLoad)return;let i=x[e.src];if(i==="ready"||i==="error"){s(i);return}let c=X(e.src),t=c.node;if(t){let p=c.status??i??"loading";switch(p){case"loading":case"ready":(a=e.callbacks)!=null&&a.onLoadCallback&&e.callbacks.onLoadCallback();break;case"error":(d=e.callbacks)!=null&&d.onErrorCallback&&e.callbacks.onErrorCallback();break;}s(p);}else {t=document.createElement("script"),t.src=e.src,t.async=!0,t.setAttribute("data-status","loading"),e.attributes&&Object.entries(e.attributes).length>0&&Object.entries(e.attributes).map(([u,m])=>t==null?void 0:t.setAttribute(u,m)),e.elementIdToAppend&&document.getElementById(e.elementIdToAppend)?(g=document.getElementById(e.elementIdToAppend))==null||g.appendChild(t):document.body.appendChild(t);let p=u=>{let m=u.type==="load"?"ready":"error";t==null||t.setAttribute("data-status",m);};t.addEventListener("load",p),t.addEventListener("error",p);}let o=p=>{var m,f;let u=p.type==="load"?"ready":"error";p.type==="load"?(m=e.callbacks)!=null&&m.onLoadCallback&&e.callbacks.onLoadCallback():(f=e.callbacks)!=null&&f.onErrorCallback&&e.callbacks.onErrorCallback(),s(u),x[e.src]=u;};return t.addEventListener("load",o),t.addEventListener("error",o),()=>{t&&(t.removeEventListener("load",o),t.removeEventListener("error",o)),t&&(n!=null&&n.removeOnUnmount)&&t.remove();}},[e,r,l]),l}var D=Y;var O=({apiKey:e,libraries:r=[],loadScriptExternally:n=!1,status:l="idle",externalApiParams:s,callback:i})=>{var o;typeof window<"u"&&(window.googleMapsCallback=i);let c=(o=new URLSearchParams(s))==null?void 0:o.toString(),t=e?{src:`https://maps.googleapis.com/maps/api/js?key=${e}&callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}${c?`&${c}`:""}`,attributes:{id:"googleMapsApi"}}:{src:`https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}`,attributes:{id:"googleMapsApi"}};return D(t,n?l:void 0)};var R=(e,r,n=1e-6)=>{if(e&&r){for(let l=0;l!==e.length;++l)if(Math.abs(e[l]-r[l])>n)return !1;return !0}return !1};var Q=(e,r)=>{let n=useRef(),l=n.current,s=r(l,e);return useEffect(()=>{s||(n.current=e);}),s?l:e},T=Q;var h=e=>{try{return {lat:e==null?void 0:e.lat(),lng:e==null?void 0:e.lng()}}catch{return e}},Z=({container:e,pane:r,position:n,maps:l,drag:s})=>{class i extends google.maps.OverlayView{onAdd=()=>{var g;let t=this;s!=null&&s.draggable&&(this.get("map").getDiv().addEventListener("mouseleave",()=>{google.maps.event.trigger(this.container,"mouseup");}),this.container.addEventListener("mousedown",a=>{var d;this.container.style.cursor="grabbing",(d=t.map)==null||d.set("draggable",!1),t.set("origin",a),s.onDragStart(a,{latLng:h(this.position)}),t.moveHandler=this.get("map").getDiv().addEventListener("mousemove",p=>{let u=t.get("origin"),m=u.clientX-p.clientX,f=u.clientY-p.clientY,L=t.getProjection().fromLatLngToDivPixel(t.position);if(L===null)return;let M=t.getProjection().fromDivPixelToLatLng(new l.Point(L.x-m,L.y-f));t.set("position",M),t.set("origin",p),t.draw(),s.onDrag(p,{latLng:h(M)});});}),this.container.addEventListener("mouseup",a=>{var d;(d=t.map)==null||d.set("draggable",!0),this.container.style.cursor="default",t.moveHandler&&(google.maps.event.removeListener(t.moveHandler),t.moveHandler=null),s.onDragEnd(a,{latLng:h(t.position)});}));let o=(g=this.getPanes())==null?void 0:g[this.pane];o==null||o.classList.add("google-map-markers-overlay"),o==null||o.appendChild(this.container);};draw=()=>{let o=this.getProjection().fromLatLngToDivPixel(this.position);o!==null&&(this.container.style.transform=`translate(${o.x}px, ${o.y}px)`,this.container.style.width="0px",this.container.style.height="0px");};onRemove=()=>{this.container.parentNode!==null&&(google.maps.event.clearInstanceListeners(this.container),this.container.parentNode.removeChild(this.container));};container;pane;position;map=this.getMap();moveHandler;constructor(t,o,g){super(),this.container=t,this.pane=o,this.position=g,this.moveHandler=null;}}return new i(e,r,n)},H=Z;var ee=({pane:e="floatPane",position:r,map:n,maps:l,zIndex:s=0,children:i,drag:c})=>{let t=useMemo(()=>{let a=document.createElement("div");return a.style.position="absolute",a},[]),o=useMemo(()=>H({container:t,pane:e,position:r,maps:l,drag:c}),[t,c,l,e,r]),g=T(i==null?void 0:i.props,(a,d)=>a&&a.lat===d.lat&&a.lng===d.lng);return useEffect(()=>!o.map&&n?(o==null||o.setMap(n),()=>{o==null||o.setMap(null);}):()=>{},[n,g]),useEffect(()=>{t.style.zIndex=`${s}`;},[s,t]),createPortal(i,t)},G=ee;var S=()=>{},ne=({children:e,map:r,maps:n})=>{let l=useMemo(()=>!r||!n?[]:Children.map(e,s=>{if(isValidElement(s)){let i={lat:s.props.lat,lng:s.props.lng},{zIndex:c,draggable:t=!1,onDragStart:o=S,onDrag:g=S,onDragEnd:a=S}=s.props||{};return s=cloneElement(s,{...s.props,draggable:void 0,onDragStart:void 0,onDrag:void 0,onDragEnd:void 0}),jsx(G,{position:new n.LatLng(i.lat,i.lng),map:r,maps:n,zIndex:c,drag:{draggable:t,onDragStart:o,onDrag:g,onDragEnd:a},children:s})}return null}),[e,r,n]);return jsx("div",{children:l})},j=ne;function le({children:e=null,style:r={width:"100%",height:"100%",left:0,top:0,margin:0,padding:0,position:"absolute"},defaultCenter:n,defaultZoom:l,onGoogleApiLoaded:s,onChange:i,options:c={},events:t=[]}){let o=useRef(null),g=useRef(),[a,d]=useState(),[p,u]=useState(),[m,f]=useState(!1),L=useCallback(()=>{var M,b;try{if(!a)return;let y=a.getZoom()??l,v=a.getBounds(),q=[(M=a.getCenter())==null?void 0:M.lng(),(b=a.getCenter())==null?void 0:b.lat()],E=v==null?void 0:v.getNorthEast(),P=v==null?void 0:v.getSouthWest();if(!E||!P||!v)return;let w=[P.lng(),P.lat(),E.lng(),E.lat()];R(w,g.current)||(i&&i({zoom:y,center:q,bounds:v}),g.current=w);}catch(y){console.error(y);}},[a,i]);return useEffect(()=>{o.current&&!a&&(d(new google.maps.Map(o.current,{center:n,zoom:l,...c})),u(google.maps));},[n,l,a,o,c]),useEffect(()=>{a&&(m||(s&&p&&s({map:a,maps:p,ref:o.current}),f(!0)),google.maps.event.clearListeners(a,"idle"),google.maps.event.addListener(a,"idle",L));},[m,a,p,i,s,L]),useEffect(()=>()=>{a&&google.maps.event.clearListeners(a,"idle");},[a]),jsxs(Fragment,{children:[jsx("div",{ref:o,style:r,className:"google-map",...t==null?void 0:t.reduce((M,{name:b,handler:y})=>(M[b]=y,M),{})}),e&&a&&p&&jsx(j,{map:a,maps:p,children:e})]})}var V=le;var ge=forwardRef(({apiKey:e="",libraries:r=["places","geometry"],children:n=null,loadingContent:l="Google Maps is loading",idleContent:s="Google Maps is on idle",errorContent:i="Google Maps is on error",mapMinHeight:c="unset",containerProps:t={},loadScriptExternally:o=!1,status:g="idle",scriptCallback:a=()=>{},externalApiParams:d={},...p},u)=>{let m={ready:jsx(V,{...p,children:n}),loading:l,idle:s,error:i},f=O({apiKey:e,libraries:r,loadScriptExternally:o,status:g,externalApiParams:d,callback:a});return jsx("div",{ref:u,style:{height:"100%",width:"100%",overflow:"hidden",position:"relative",minHeight:c},...t,children:m[f]||null})}),z=ge;window.googleMapsCallback=()=>{};window.google=void 0;var Be=z;
5
+ var S={};function Y(e){let r=document.querySelector(`script[src="${e}"]`),a=r==null?void 0:r.getAttribute("data-status");return {node:r,status:a}}function J(e={src:"",attributes:{},callbacks:{onLoadCallback:()=>{},onErrorCallback:()=>{}},elementIdToAppend:""},r,a={removeOnUnmount:!1,shouldPreventLoad:!1}){let[l,s]=useState(()=>!e.src||a!=null&&a.shouldPreventLoad?"idle":typeof window>"u"?"loading":S[e.src]??"loading");return useEffect(()=>{var u,n,m;if(r){s(r);return}if(!(e!=null&&e.src)||a!=null&&a.shouldPreventLoad)return;let i=S[e.src];if(i==="ready"||i==="error"){s(i);return}let c=Y(e.src),t=c.node;if(t){let p=c.status??i??"loading";switch(p){case"loading":case"ready":(n=e.callbacks)!=null&&n.onLoadCallback&&e.callbacks.onLoadCallback();break;case"error":(m=e.callbacks)!=null&&m.onErrorCallback&&e.callbacks.onErrorCallback();break;}s(p);}else {t=document.createElement("script"),t.src=e.src,t.async=!0,t.setAttribute("data-status","loading"),e.attributes&&Object.entries(e.attributes).length>0&&Object.entries(e.attributes).map(([g,d])=>t==null?void 0:t.setAttribute(g,d)),e.elementIdToAppend&&document.getElementById(e.elementIdToAppend)?(u=document.getElementById(e.elementIdToAppend))==null||u.appendChild(t):document.body.appendChild(t);let p=g=>{let d=g.type==="load"?"ready":"error";t==null||t.setAttribute("data-status",d);};t.addEventListener("load",p),t.addEventListener("error",p);}let o=p=>{var d,f;let g=p.type==="load"?"ready":"error";p.type==="load"?(d=e.callbacks)!=null&&d.onLoadCallback&&e.callbacks.onLoadCallback():(f=e.callbacks)!=null&&f.onErrorCallback&&e.callbacks.onErrorCallback(),s(g),S[e.src]=g;};return t.addEventListener("load",o),t.addEventListener("error",o),()=>{t&&(t.removeEventListener("load",o),t.removeEventListener("error",o)),t&&(a!=null&&a.removeOnUnmount)&&t.remove();}},[e,r,l]),l}var O=J;var T=({apiKey:e,libraries:r=[],loadScriptExternally:a=!1,status:l="idle",externalApiParams:s,callback:i})=>{var o;typeof window<"u"&&(window.googleMapsCallback=i);let c=(o=new URLSearchParams(s))==null?void 0:o.toString(),t=e?{src:`https://maps.googleapis.com/maps/api/js?key=${e}&callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}${c?`&${c}`:""}`,attributes:{id:"googleMapsApi"}}:{src:`https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${r==null?void 0:r.join(",")}`,attributes:{id:"googleMapsApi"}};return O(t,a?l:void 0)};var x=(e,r,a=1e-6)=>{if(e&&r){for(let l=0;l!==e.length;++l)if(Math.abs(e[l]-r[l])>a)return !1;return !0}return !1};var _=(e,r)=>{let a=useRef(),l=a.current,s=r(l,e);return useEffect(()=>{s||(a.current=e);}),s?l:e},H=_;var k=e=>{try{return {lat:e==null?void 0:e.lat(),lng:e==null?void 0:e.lng()}}catch{return e}},K=({container:e,pane:r,position:a,maps:l,drag:s})=>{class i extends google.maps.OverlayView{onAdd=()=>{var u;let t=this;s!=null&&s.draggable&&(this.get("map").getDiv().addEventListener("mouseleave",()=>{google.maps.event.trigger(this.container,"mouseup");}),this.container.addEventListener("mousedown",n=>{var m;this.container.style.cursor="grabbing",(m=t.map)==null||m.set("draggable",!1),t.set("origin",n),s.onDragStart(n,{latLng:k(this.position)}),t.moveHandler=this.get("map").getDiv().addEventListener("mousemove",p=>{let g=t.get("origin"),d=g.clientX-p.clientX,f=g.clientY-p.clientY,b=t.getProjection().fromLatLngToDivPixel(t.position);if(b===null)return;let v=t.getProjection().fromDivPixelToLatLng(new l.Point(b.x-d,b.y-f));t.set("position",v),t.set("origin",p),t.draw(),s.onDrag(p,{latLng:k(v)});});}),this.container.addEventListener("mouseup",n=>{var m;(m=t.map)==null||m.set("draggable",!0),this.container.style.cursor="default",t.moveHandler&&(google.maps.event.removeListener(t.moveHandler),t.moveHandler=null),s.onDragEnd(n,{latLng:k(t.position)});}));let o=(u=this.getPanes())==null?void 0:u[this.pane];o==null||o.classList.add("google-map-markers-overlay"),o==null||o.appendChild(this.container);};draw=()=>{let o=this.getProjection().fromLatLngToDivPixel(this.position);o!==null&&(this.container.style.transform=`translate(${o.x}px, ${o.y}px)`,this.container.style.width="0px",this.container.style.height="0px");};onRemove=()=>{this.container.parentNode!==null&&(google.maps.event.clearInstanceListeners(this.container),this.container.parentNode.removeChild(this.container));};container;pane;position;map=this.getMap();moveHandler;constructor(t,o,u){super(),this.container=t,this.pane=o,this.position=u,this.moveHandler=null;}}return new i(e,r,a)},U=K;var ee=({pane:e="floatPane",position:r,map:a,maps:l,zIndex:s=0,children:i,drag:c})=>{let t=useMemo(()=>{let n=document.createElement("div");return n.style.position="absolute",n},[]),o=useMemo(()=>U({container:t,pane:e,position:r,maps:l,drag:c}),[t,c,l,e,r]),u=H(i==null?void 0:i.props,(n,m)=>n&&n.lat===m.lat&&n.lng===m.lng);return useEffect(()=>!o.map&&a?(o==null||o.setMap(a),()=>{o==null||o.setMap(null);}):()=>{},[a,u]),useEffect(()=>{t.style.zIndex=`${s}`;},[s,t]),createPortal(i,t)},R=ee;var P=()=>{},ae=({children:e,map:r,maps:a})=>{let l=useMemo(()=>!r||!a?[]:Children.map(e,s=>{if(isValidElement(s)){let i={lat:s.props.lat,lng:s.props.lng},{zIndex:c,draggable:t=!1,onDragStart:o=P,onDrag:u=P,onDragEnd:n=P}=s.props||{};return s=cloneElement(s,{...s.props,draggable:void 0,onDragStart:void 0,onDrag:void 0,onDragEnd:void 0}),jsx(R,{position:new a.LatLng(i.lat,i.lng),map:r,maps:a,zIndex:c,drag:{draggable:t,onDragStart:o,onDrag:u,onDragEnd:n},children:s})}return null}),[e,r,a]);return jsx("div",{children:l})},j=ae;function le({children:e=null,style:r={width:"100%",height:"100%",left:0,top:0,margin:0,padding:0,position:"absolute"},defaultCenter:a,defaultZoom:l,onGoogleApiLoaded:s,onChange:i,options:c={},events:t=[]}){let o=useRef(null),u=useRef([]),[n,m]=useState(),[p,g]=useState(),[d,f]=useState(!1),b=useCallback(()=>{var v,y;try{if(!n)return;let E=n.getZoom()??l,M=n.getBounds(),F=[(v=n.getCenter())==null?void 0:v.lng(),(y=n.getCenter())==null?void 0:y.lat()],L=M==null?void 0:M.getNorthEast(),h=M==null?void 0:M.getSouthWest();if(!L||!h||!M)return;let D=[h.lng(),h.lat(),L.lng(),L.lat()];x(D,u.current)||(i&&i({zoom:E,center:F,bounds:M}),u.current=D);}catch(E){console.error(E);}},[n,i]);return useEffect(()=>{o.current&&!n&&(m(new google.maps.Map(o.current,{center:a,zoom:l,...c})),g(google.maps));},[a,l,n,o,c]),useEffect(()=>{n&&(d||(s&&p&&s({map:n,maps:p,ref:o.current}),f(!0)),google.maps.event.clearListeners(n,"idle"),google.maps.event.addListener(n,"idle",b));},[d,n,p,i,s,b]),useEffect(()=>()=>{n&&google.maps.event.clearListeners(n,"idle");},[n]),jsxs(Fragment,{children:[jsx("div",{ref:o,style:r,className:"google-map",...t==null?void 0:t.reduce((v,{name:y,handler:E})=>(v[y]=E,v),{})}),e&&n&&p&&jsx(j,{map:n,maps:p,children:e})]})}var q=le;var ue=forwardRef(({apiKey:e="",libraries:r=["places","geometry"],children:a=null,loadingContent:l="Google Maps is loading",idleContent:s="Google Maps is on idle",errorContent:i="Google Maps is on error",mapMinHeight:c="unset",containerProps:t={},loadScriptExternally:o=!1,status:u="idle",scriptCallback:n=()=>{},externalApiParams:m={},...p},g)=>{let d={ready:jsx(q,{...p,children:a}),loading:l,idle:s,error:i},f=T({apiKey:e,libraries:r,loadScriptExternally:o,status:u,externalApiParams:m,callback:n});return jsx("div",{ref:g,style:{height:"100%",width:"100%",overflow:"hidden",position:"relative",minHeight:c},...t,children:d[f]||null})}),B=ue;var qe=B;
6
6
 
7
- export { Be as default };
8
- //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=index.js.map
7
+ export { qe as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "google-maps-react-markers",
3
- "version": "2.0.1",
4
- "description": "Google Maps library with markers as react components",
3
+ "version": "2.0.5",
4
+ "description": "Google Maps library that accepts markers as react components, works with React 18+ and it is fully typed.",
5
5
  "author": "Giorgia Bosello",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -34,8 +34,6 @@
34
34
  "commit": "cz",
35
35
  "release": "yarn build && yarn release-it",
36
36
  "link:self": "yarn yalc publish && yarn link",
37
- "predeploy": "cd docs && yarn install && yarn build",
38
- "deploy": "gh-pages -d docs/build",
39
37
  "final:publish": "yarn build && npm publish"
40
38
  },
41
39
  "files": [
@@ -70,17 +68,17 @@
70
68
  "@babel/core": "7.23.0",
71
69
  "@babel/preset-env": "7.22.20",
72
70
  "@babel/preset-react": "7.22.15",
73
- "@babel/preset-typescript": "7.22.15",
71
+ "@babel/preset-typescript": "7.23.0",
74
72
  "@commitlint/cli": "17.7.2",
75
73
  "@commitlint/config-conventional": "17.7.0",
76
74
  "@ryansonshine/commitizen": "4.2.8",
77
75
  "@ryansonshine/cz-conventional-changelog": "3.3.4",
78
76
  "@types/google.maps": "^3.54.0",
79
- "@types/node": "20.5.9",
80
- "@types/react": "18.2.24",
81
- "@types/react-dom": "18.2.7",
82
- "@typescript-eslint/eslint-plugin": "6.6.0",
83
- "@typescript-eslint/parser": "6.6.0",
77
+ "@types/node": "^20",
78
+ "@types/react": "^18",
79
+ "@types/react-dom": "^18",
80
+ "@typescript-eslint/eslint-plugin": "6.7.4",
81
+ "@typescript-eslint/parser": "6.7.4",
84
82
  "babel-loader": "9.1.3",
85
83
  "concurrently": "8.2.1",
86
84
  "eslint": "8.50.0",
@@ -93,20 +91,18 @@
93
91
  "eslint-plugin-react": "7.33.2",
94
92
  "eslint-plugin-react-hooks": "4.6.0",
95
93
  "eslint-plugin-sort-class-members": "^1.18.0",
96
- "eslint-plugin-typescript-sort-keys": "3.0.0",
94
+ "eslint-plugin-typescript-sort-keys": "3.1.0",
97
95
  "eslint-plugin-unused-imports": "3.0.0",
98
96
  "gh-pages": "^6.0.0",
99
97
  "husky": "8.0.3",
100
- "lint-staged": "14.0.1",
98
+ "lint-staged": "15.0.2",
101
99
  "prettier": "^3.0.3",
102
100
  "prop-types": "15.8.1",
103
101
  "react": "^18.2.0",
104
102
  "react-dom": "^18.2.0",
105
- "react-scripts": "^5.0.1",
106
- "release-it": "16.1.5",
107
- "storybook": "7.4.0",
103
+ "release-it": "16.2.1",
108
104
  "tsup": "7.2.0",
109
- "typescript": "5.2.2",
105
+ "typescript": "^5",
110
106
  "yalc": "1.0.0-pre.53"
111
107
  },
112
108
  "peerDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/google-map.tsx","../src/map/hooks/useScript.ts","../src/map/hooks/useGoogleMaps.ts","../src/map/map.tsx","../src/utils/utils.ts","../src/map/markers.tsx","../src/map/overlay-view.tsx","../src/map/hooks/useMemoCompare.ts","../src/map/overlay.tsx","../src/utils/types.ts","../src/index.ts"],"names":["forwardRef","useEffect","useState","cachedScriptStatuses","getScriptNode","src","node","status","useScript","script","forcedStatus","options","setStatus","_a","_b","_c","cachedScriptStatus","scriptToAdd","scriptNode","currentScriptStatus","key","value","setAttributeFromEvent","event","scriptStatus","setStateFromEvent","newStatus","useScript_default","useGoogleMaps","apiKey","libraries","loadScriptExternally","externalApiParams","callback","apiParams","useCallback","useRef","isArraysEqualEps","arrayA","arrayB","eps","i","Children","cloneElement","isValidElement","useMemo","createPortal","useMemoCompare","next","compare","previousRef","previous","isEqual","useMemoCompare_default","getLatLng","LatLng","createOverlay","container","pane","position","maps","drag","Overlay","that","e","evt","origin","left","top","pos","latLng","currentPane","point","overlay_default","OverlayView","map","zIndex","children","div","overlay","childrenProps","prev","overlay_view_default","jsx","noop","MapMarkers","markers","child","draggable","onDragStart","onDrag","onDragEnd","markers_default","Fragment","jsxs","MapComponent","style","defaultCenter","defaultZoom","onGoogleApiLoaded","onChange","events","mapRef","prevBoundsRef","setMap","setMaps","googleApiCalled","setGoogleApiCalled","onIdle","zoom","bounds","centerLatLng","ne","sw","boundsArray","acc","name","handler","map_default","GoogleMap","loadingContent","idleContent","errorContent","mapMinHeight","containerProps","statusProp","scriptCallback","props","ref","renderers","google_map_default","src_default"],"mappings":"AAAA,OAAS,cAAAA,OAAkB,QCC3B,OAAS,aAAAC,EAAW,YAAAC,MAAgB,QAIpC,IAAMC,EAAoE,CAAC,EAE3E,SAASC,EAAcC,EAAa,CACnC,IAAMC,EAAiC,SAAS,cAAc,eAAeD,CAAG,IAAI,EAC9EE,EAASD,GAAA,YAAAA,EAAM,aAAa,eAElC,MAAO,CACN,KAAAA,EACA,OAAAC,CACD,CACD,CAyBA,SAASC,EAERC,EAAsB,CACrB,IAAK,GACL,WAAY,CAAC,EACb,UAAW,CAAE,eAAgB,IAAM,CAAC,EAAG,gBAAiB,IAAM,CAAC,CAAE,EACjE,kBAAmB,EACpB,EACAC,EACAC,EAA4B,CAAE,gBAAi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AAA,CAAW,IAAKjB,EAAK,KAAMf,EAC1B,SAAAiB,EACF,GAEF,CAEF,CAEA,IAAOyC,EAAQvB,GHrGL,cAAAZ,MAAA,oBApBV,IAAMoC,GAAYvH,GACjB,CACC,CACC,OAAA6B,EAAS,GACT,UAAAC,EAAY,CAAC,SAAU,UAAU,EACjC,SAAA+C,EAAW,KACX,eAAA2C,EAAiB,yBACjB,YAAAC,EAAc,yBACd,aAAAC,EAAe,0BACf,aAAAC,EAAe,QACf,eAAAC,EAAiB,CAAC,EAClB,qBAAA7F,EAAuB,GACvB,OAAQ8F,EAAa,OACrB,eAAAC,EAAiB,IAAM,CAAC,EACxB,kBAAA9F,EAAoB,CAAC,EACrB,GAAG+F,CACJ,EACAC,IACI,CACJ,IAAMC,EAAY,CACjB,MAAO9C,EAACmC,EAAA,CAAc,GAAGS,EAAQ,SAAAlD,EAAS,EAC1C,QAAS2C,EACT,KAAMC,EACN,MAAOC,CACR,EAEMnH,EAASqB,EAAc,CAC5B,OAAAC,EACA,UAAAC,EACA,qBAAAC,EACA,OAAQ8F,EACR,kBAAA7F,EACA,SAAU8F,CACX,CAAC,EAED,OACC3C,EAAC,OACA,IAAK6C,EACL,MAAO,CAAE,OAAQ,OAAQ,MAAO,OAAQ,SAAU,SAAU,SAAU,WAAY,UAAWL,CAAa,EACzG,GAAGC,EAEH,SAAAK,EAAU1H,CAAM,GAAK,KACvB,CAEF,CACD,EAEO2H,EAAQX,GS3Cf,OAAO,mBAAqB,IAAM,CAAC,EACnC,OAAO,OAAS,OCNhB,IAAOY,GAAQD","sourcesContent":["import { forwardRef } from 'react'\nimport { useGoogleMaps } from './map/hooks/useGoogleMaps'\nimport MapComponent from './map/map'\nimport { GoogleMapProps } from './utils/types'\n\nconst GoogleMap = forwardRef<HTMLDivElement, GoogleMapProps>(\n\t(\n\t\t{\n\t\t\tapiKey = '',\n\t\t\tlibraries = ['places', 'geometry'],\n\t\t\tchildren = null,\n\t\t\tloadingContent = 'Google Maps is loading',\n\t\t\tidleContent = 'Google Maps is on idle',\n\t\t\terrorContent = 'Google Maps is on error',\n\t\t\tmapMinHeight = 'unset',\n\t\t\tcontainerProps = {},\n\t\t\tloadScriptExternally = false,\n\t\t\tstatus: statusProp = 'idle',\n\t\t\tscriptCallback = () => {},\n\t\t\texternalApiParams = {},\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst renderers = {\n\t\t\tready: <MapComponent {...props}>{children}</MapComponent>,\n\t\t\tloading: loadingContent,\n\t\t\tidle: idleContent,\n\t\t\terror: errorContent,\n\t\t}\n\n\t\tconst status = useGoogleMaps({\n\t\t\tapiKey,\n\t\t\tlibraries,\n\t\t\tloadScriptExternally,\n\t\t\tstatus: statusProp,\n\t\t\texternalApiParams,\n\t\t\tcallback: scriptCallback,\n\t\t})\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tstyle={{ height: '100%', width: '100%', overflow: 'hidden', position: 'relative', minHeight: mapMinHeight }}\n\t\t\t\t{...containerProps}\n\t\t\t>\n\t\t\t\t{renderers[status] || null}\n\t\t\t</div>\n\t\t)\n\t},\n)\n\nexport default GoogleMap\n","/* eslint-disable no-unused-expressions */\nimport { useEffect, useState } from 'react'\nimport { ScriptProps, UseScriptOptions, UseScriptStatus } from '../../utils/types'\n\n// Cached script statuses\nconst cachedScriptStatuses: Record<string, UseScriptStatus | undefined> = {}\n\nfunction getScriptNode(src: string) {\n\tconst node: HTMLScriptElement | null = document.querySelector(`script[src=\"${src}\"]`)\n\tconst status = node?.getAttribute('data-status') as UseScriptStatus | undefined\n\n\treturn {\n\t\tnode,\n\t\tstatus,\n\t}\n}\n\n/**\n * @description Hook to load external script.\n * @param {Object} script - Script to load.\n * @param {string} script.src - Script source.\n * @param {Object} [script.attributes] - Attributes to add to the script tag.\n * @param {Object} [script.callbacks] - Callbacks executed on completion.\n * @param {Function} [script.callbacks.onLoadCallback] - Callback executed on completion in case of success.\n * @param {Function} [script.callbacks.onErrorCallback] - Callbacks executed on completion in case of error.\n * @param {string} [script.elementIdToAppend] - HTML element id to append the script to. Default is HTML HEAD.\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n *\n * @example\n * const status = useScript({\n * \t\tsrc: \"https://script-to-load.js\",\n * \t\tattributes: { id: \"scriptId\", class: \"script-class\" },\n * \t\tcallbacks: {\n * \t\t\tonLoadCallback: onLoadFunc,\n * \t\t\tonErrorCallback: onErrorFunc,\n * \t\t},\n * \t\telementIdToAppend: \"script-container\"\n * }, undefined, { removeOnUnmount: true, shouldPreventLoad: false })\n */\n\nfunction useScript(\n\t// eslint-disable-next-line default-param-last\n\tscript: ScriptProps = {\n\t\tsrc: '',\n\t\tattributes: {},\n\t\tcallbacks: { onLoadCallback: () => {}, onErrorCallback: () => {} },\n\t\telementIdToAppend: '',\n\t},\n\tforcedStatus?: UseScriptStatus,\n\toptions: UseScriptOptions = { removeOnUnmount: false, shouldPreventLoad: false },\n): 'idle' | 'loading' | 'ready' | 'error' {\n\tconst [status, setStatus] = useState<UseScriptStatus>(() => {\n\t\tif (!script.src || options?.shouldPreventLoad) {\n\t\t\treturn 'idle'\n\t\t}\n\n\t\tif (typeof window === 'undefined') {\n\t\t\t// SSR Handling - always return 'loading'\n\t\t\treturn 'loading'\n\t\t}\n\n\t\treturn cachedScriptStatuses[script.src] ?? 'loading'\n\t})\n\n\tuseEffect(\n\t\t() => {\n\t\t\tif (forcedStatus) {\n\t\t\t\tsetStatus(forcedStatus)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (!script?.src || options?.shouldPreventLoad) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst cachedScriptStatus = cachedScriptStatuses[script.src]\n\t\t\tif (cachedScriptStatus === 'ready' || cachedScriptStatus === 'error') {\n\t\t\t\t// If the script is already cached, set its status immediately\n\t\t\t\tsetStatus(cachedScriptStatus)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Fetch existing script element by src\n\t\t\t// It may have been added by another instance of this hook\n\t\t\tconst scriptToAdd = getScriptNode(script.src)\n\t\t\tlet scriptNode = scriptToAdd.node\n\n\t\t\tif (!scriptNode) {\n\t\t\t\t// Create script element and add it to document body\n\t\t\t\tscriptNode = document.createElement('script')\n\t\t\t\tscriptNode.src = script.src\n\t\t\t\tscriptNode.async = true\n\t\t\t\tscriptNode.setAttribute('data-status', 'loading')\n\t\t\t\t// Add other script attributes, if they exist\n\t\t\t\tscript.attributes && Object.entries(script.attributes).length > 0\n\t\t\t\t\t? Object.entries(script.attributes).map(([key, value]) => scriptNode?.setAttribute(key, value))\n\t\t\t\t\t: null\n\t\t\t\tif (script.elementIdToAppend && document.getElementById(script.elementIdToAppend)) {\n\t\t\t\t\tdocument.getElementById(script.elementIdToAppend)?.appendChild(scriptNode)\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.appendChild(scriptNode)\n\t\t\t\t}\n\n\t\t\t\t// Store status in attribute on script\n\t\t\t\t// This can be read by other instances of this hook\n\t\t\t\tconst setAttributeFromEvent = (event: Event) => {\n\t\t\t\t\tconst scriptStatus: UseScriptStatus = event.type === 'load' ? 'ready' : 'error'\n\n\t\t\t\t\tscriptNode?.setAttribute('data-status', scriptStatus)\n\t\t\t\t}\n\n\t\t\t\tscriptNode.addEventListener('load', setAttributeFromEvent)\n\t\t\t\tscriptNode.addEventListener('error', setAttributeFromEvent)\n\t\t\t} else {\n\t\t\t\t// Grab existing script status from attribute and set to state.\n\t\t\t\tconst currentScriptStatus = scriptToAdd.status ?? cachedScriptStatus ?? 'loading'\n\n\t\t\t\tswitch (currentScriptStatus) {\n\t\t\t\t\tcase 'loading':\n\t\t\t\t\tcase 'ready':\n\t\t\t\t\t\tscript.callbacks?.onLoadCallback ? script.callbacks.onLoadCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\tscript.callbacks?.onErrorCallback ? script.callbacks.onErrorCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// loading: do nothing\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tsetStatus(currentScriptStatus)\n\t\t\t}\n\n\t\t\t// Script event handler to update status in state\n\t\t\t// Note: Even if the script already exists we still need to add\n\t\t\t// event handlers to update the state for this hook instance.\n\t\t\tconst setStateFromEvent = (event: Event) => {\n\t\t\t\tconst newStatus = event.type === 'load' ? 'ready' : 'error'\n\t\t\t\tevent.type === 'load'\n\t\t\t\t\t? script.callbacks?.onLoadCallback\n\t\t\t\t\t\t? script.callbacks.onLoadCallback()\n\t\t\t\t\t\t: null\n\t\t\t\t\t: script.callbacks?.onErrorCallback\n\t\t\t\t\t? script.callbacks.onErrorCallback()\n\t\t\t\t\t: null\n\n\t\t\t\tsetStatus(newStatus)\n\t\t\t\tcachedScriptStatuses[script.src] = newStatus\n\t\t\t}\n\t\t\t// Add event listeners\n\t\t\tscriptNode.addEventListener('load', setStateFromEvent)\n\t\t\tscriptNode.addEventListener('error', setStateFromEvent)\n\t\t\t// Remove event listeners on cleanup\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\treturn () => {\n\t\t\t\tif (scriptNode) {\n\t\t\t\t\tscriptNode.removeEventListener('load', setStateFromEvent)\n\t\t\t\t\tscriptNode.removeEventListener('error', setStateFromEvent)\n\t\t\t\t}\n\n\t\t\t\tif (scriptNode && options?.removeOnUnmount) {\n\t\t\t\t\tscriptNode.remove()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Re-run useEffect if script changes\n\t\t[script, forcedStatus, status],\n\t)\n\n\treturn status\n}\n\nexport default useScript\n","import { IUseGoogleMaps, UseScriptStatus } from '../../utils/types'\nimport useScript from './useScript'\n\n/**\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n */\nexport const useGoogleMaps = ({\n\tapiKey,\n\tlibraries = [],\n\tloadScriptExternally = false,\n\tstatus = 'idle',\n\texternalApiParams,\n\tcallback,\n}: IUseGoogleMaps): UseScriptStatus => {\n\tif (typeof window !== 'undefined') window.googleMapsCallback = callback\n\tconst apiParams = new URLSearchParams(externalApiParams)?.toString()\n\tconst script = apiKey\n\t\t? {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=googleMapsCallback&libraries=${libraries?.join(\n\t\t\t\t\t',',\n\t\t\t\t)}${apiParams ? `&${apiParams}` : ''}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\t\t: {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${libraries?.join(',')}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\n\treturn useScript(script, loadScriptExternally ? status : undefined)\n}\n","import { useCallback, useEffect, useRef, useState } from 'react'\nimport { EventProps, Map, MapProps, MapsLibrary } from '../utils/types'\nimport { isArraysEqualEps } from '../utils/utils'\nimport MapMarkers from './markers'\n\nfunction MapComponent({\n\tchildren = null,\n\tstyle = {\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tmargin: 0,\n\t\tpadding: 0,\n\t\tposition: 'absolute',\n\t},\n\tdefaultCenter,\n\tdefaultZoom,\n\tonGoogleApiLoaded,\n\tonChange,\n\toptions = {},\n\tevents = [],\n}: MapProps) {\n\tconst mapRef = useRef<HTMLDivElement>(null)\n\tconst prevBoundsRef = useRef<number[] | undefined>()\n\tconst [map, setMap] = useState<Map>()\n\tconst [maps, setMaps] = useState<MapsLibrary>()\n\tconst [googleApiCalled, setGoogleApiCalled] = useState<boolean>(false)\n\n\tconst onIdle = useCallback(() => {\n\t\ttry {\n\t\t\tif (!map) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst zoom = map.getZoom() ?? defaultZoom\n\t\t\tconst bounds = map.getBounds()\n\t\t\tconst centerLatLng = [map.getCenter()?.lng(), map.getCenter()?.lat()]\n\n\t\t\tconst ne = bounds?.getNorthEast()\n\t\t\tconst sw = bounds?.getSouthWest()\n\n\t\t\tif (!ne || !sw || !bounds) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// east, north, south, west\n\t\t\tconst boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]\n\n\t\t\tif (!isArraysEqualEps(boundsArray, prevBoundsRef.current)) {\n\t\t\t\tif (onChange) {\n\t\t\t\t\tonChange({\n\t\t\t\t\t\tzoom,\n\t\t\t\t\t\tcenter: centerLatLng,\n\t\t\t\t\t\tbounds,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tprevBoundsRef.current = boundsArray\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(e)\n\t\t}\n\t}, [map, onChange])\n\n\tuseEffect(() => {\n\t\tif (mapRef.current && !map) {\n\t\t\tsetMap(\n\t\t\t\tnew google.maps.Map(mapRef.current as HTMLElement, {\n\t\t\t\t\tcenter: defaultCenter,\n\t\t\t\t\tzoom: defaultZoom,\n\t\t\t\t\t...(options as google.maps.MapOptions),\n\t\t\t\t}),\n\t\t\t)\n\t\t\tsetMaps(google.maps)\n\t\t}\n\t}, [defaultCenter, defaultZoom, map, mapRef, options])\n\n\tuseEffect(() => {\n\t\tif (map) {\n\t\t\tif (!googleApiCalled) {\n\t\t\t\tif (onGoogleApiLoaded && maps) onGoogleApiLoaded({ map, maps, ref: mapRef.current })\n\t\t\t\tsetGoogleApiCalled(true)\n\t\t\t}\n\n\t\t\tgoogle.maps.event.clearListeners(map, 'idle')\n\t\t\t// Idle event is fired when the map becomes idle after panning or zooming.\n\t\t\tgoogle.maps.event.addListener(map, 'idle', onIdle)\n\t\t}\n\t}, [googleApiCalled, map, maps, onChange, onGoogleApiLoaded, onIdle])\n\n\tuseEffect(\n\t\t() =>\n\t\t\t// clear listeners on unmount\n\t\t\t() => {\n\t\t\t\tif (map) {\n\t\t\t\t\tgoogle.maps.event.clearListeners(map, 'idle')\n\t\t\t\t}\n\t\t\t},\n\t\t[map],\n\t)\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={mapRef}\n\t\t\t\tstyle={style}\n\t\t\t\tclassName=\"google-map\"\n\t\t\t\t// spread the events as props\n\t\t\t\t{...events?.reduce(\n\t\t\t\t\t(acc, { name, handler }: EventProps) => {\n\t\t\t\t\t\tacc[name] = handler\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t},\n\t\t\t\t\t{} as { [key: string]: any },\n\t\t\t\t)}\n\t\t\t/>\n\t\t\t{children && map && maps && (\n\t\t\t\t<MapMarkers map={map} maps={maps}>\n\t\t\t\t\t{children}\n\t\t\t\t</MapMarkers>\n\t\t\t)}\n\t\t</>\n\t)\n}\n\nexport default MapComponent\n","export const isArraysEqualEps = (arrayA: number[], arrayB?: number[], eps = 0.000001): boolean => {\n\tif (arrayA && arrayB) {\n\t\tfor (let i = 0; i !== arrayA.length; ++i) {\n\t\t\tif (Math.abs(arrayA[i] - arrayB[i]) > eps) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n","import { Children, cloneElement, isValidElement, useMemo } from 'react'\nimport { MapMarkersProps } from '../utils/types'\nimport OverlayView from './overlay-view'\n\nconst noop = () => {}\n\nconst MapMarkers = ({ children, map, maps }: MapMarkersProps) => {\n\tconst markers = useMemo(() => {\n\t\tif (!map || !maps) return []\n\n\t\treturn Children.map(children, (child) => {\n\t\t\tif (isValidElement(child)) {\n\t\t\t\tconst latLng = { lat: child.props.lat, lng: child.props.lng } as google.maps.LatLngLiteral\n\t\t\t\tconst { zIndex, draggable = false, onDragStart = noop, onDrag = noop, onDragEnd = noop } = child.props || {}\n\n\t\t\t\t// clone child without draggable props\n\t\t\t\t// eslint-disable-next-line no-param-reassign\n\t\t\t\tchild = cloneElement(child, {\n\t\t\t\t\t...child.props,\n\t\t\t\t\tdraggable: undefined,\n\t\t\t\t\tonDragStart: undefined,\n\t\t\t\t\tonDrag: undefined,\n\t\t\t\t\tonDragEnd: undefined,\n\t\t\t\t})\n\n\t\t\t\treturn (\n\t\t\t\t\t<OverlayView\n\t\t\t\t\t\tposition={new maps.LatLng(latLng.lat, latLng.lng)}\n\t\t\t\t\t\tmap={map}\n\t\t\t\t\t\tmaps={maps}\n\t\t\t\t\t\tzIndex={zIndex}\n\t\t\t\t\t\tdrag={{\n\t\t\t\t\t\t\tdraggable,\n\t\t\t\t\t\t\tonDragStart,\n\t\t\t\t\t\t\tonDrag,\n\t\t\t\t\t\t\tonDragEnd,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{child}\n\t\t\t\t\t</OverlayView>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn null\n\t\t})\n\t}, [children, map, maps])\n\n\treturn <div>{markers}</div>\n}\n\nexport default MapMarkers\n","import { useEffect, useMemo } from 'react'\nimport { createPortal } from 'react-dom'\nimport { OverlayViewProps } from '../utils/types'\nimport useMemoCompare from './hooks/useMemoCompare'\nimport createOverlay from './overlay'\n\nconst OverlayView = ({ pane = 'floatPane', position, map, maps, zIndex = 0, children, drag }: OverlayViewProps) => {\n\tconst container = useMemo<HTMLDivElement>(() => {\n\t\t// eslint-disable-next-line no-undef\n\t\tconst div = document.createElement('div') as HTMLDivElement\n\t\tdiv.style.position = 'absolute'\n\t\treturn div as HTMLDivElement\n\t}, [])\n\n\tconst overlay = useMemo(\n\t\t() => createOverlay({ container, pane, position, maps, drag }),\n\t\t[container, drag, maps, pane, position],\n\t)\n\n\t// Because React does not do deep comparisons, a custom hook is used.\n\t// This fixes the issue where the overlay is not updated when the position changes.\n\tconst childrenProps = useMemoCompare(\n\t\tchildren?.props as any,\n\t\t(prev: { lat: any; lng: any }, next: { lat: any; lng: any }) =>\n\t\t\tprev && prev.lat === next.lat && prev.lng === next.lng,\n\t)\n\n\tuseEffect(() => {\n\t\tif (!overlay.map && map) {\n\t\t\toverlay?.setMap(map)\n\t\t\treturn () => {\n\t\t\t\toverlay?.setMap(null)\n\t\t\t}\n\t\t}\n\t\treturn () => {}\n\t\t// overlay depends on map, so we don't need to add it to the dependency array\n\t\t// otherwise, it will re-render the overlay every time the map changes\n\t\t// ? added childrenProps to the dependency array to re-render the overlay when the children props change.\n\t}, [map, childrenProps])\n\n\t// to move the container to the foreground and background\n\tuseEffect(() => {\n\t\tcontainer.style.zIndex = `${zIndex}`\n\t}, [zIndex, container])\n\n\treturn createPortal(children, container)\n}\n\nexport default OverlayView\n","import { useEffect, useRef } from 'react'\n\n/**\n * A hook that compares the previous and current values of a reference.\n * @param {any} next - the current value of the reference\n * @param {function} compare - a function that compares the previous and current values\n * @returns {any} the previous value of the reference\n * @ref https://usehooks.com/useMemoCompare/\n */\nconst useMemoCompare = (next: any, compare: Function): any => {\n\t// Ref for storing previous value\n\tconst previousRef = useRef()\n\tconst previous = previousRef.current\n\t// Pass previous and next value to compare function\n\t// to determine whether to consider them equal.\n\tconst isEqual = compare(previous, next)\n\t// If not equal update previousRef to next value.\n\t// We only update if not equal so that this hook continues to return\n\t// the same old value if compare keeps returning true.\n\tuseEffect(() => {\n\t\tif (!isEqual) {\n\t\t\tpreviousRef.current = next\n\t\t}\n\t})\n\t// Finally, if equal then return the previous value\n\treturn isEqual ? previous : next\n}\n\nexport default useMemoCompare\n","import { Pane, createOverlayProps } from '../utils/types'\n\n// return lat, lng from LatLngLiteral\nconst getLatLng = (LatLng: google.maps.LatLng | null) => {\n\ttry {\n\t\tconst latLng = { lat: LatLng?.lat(), lng: LatLng?.lng() } as google.maps.LatLngLiteral\n\t\treturn latLng\n\t} catch (e) {\n\t\treturn LatLng\n\t}\n}\n\nconst createOverlay = ({ container, pane, position, maps, drag }: createOverlayProps) => {\n\tclass Overlay extends google.maps.OverlayView {\n\t\t/**\n\t\t * onAdd is called when the map's panes are ready and the overlay has been\n\t\t * added to the map.\n\t\t */\n\t\tonAdd = () => {\n\t\t\tconst that = this\n\t\t\t// manage draggable\n\t\t\tif (drag?.draggable) {\n\t\t\t\tthis.get('map')\n\t\t\t\t\t.getDiv()\n\t\t\t\t\t.addEventListener('mouseleave', () => {\n\t\t\t\t\t\tgoogle.maps.event.trigger(this.container, 'mouseup')\n\t\t\t\t\t})\n\t\t\t\tthis.container.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\t\t\tthis.container.style.cursor = 'grabbing'\n\t\t\t\t\tthat.map?.set('draggable', false)\n\t\t\t\t\tthat.set('origin', e)\n\n\t\t\t\t\tdrag.onDragStart(e, { latLng: getLatLng(this.position) })\n\n\t\t\t\t\t// eslint-disable-next-line no-shadow\n\t\t\t\t\tthat.moveHandler = this.get('map')\n\t\t\t\t\t\t.getDiv()\n\t\t\t\t\t\t.addEventListener('mousemove', (evt: MouseEvent) => {\n\t\t\t\t\t\t\tconst origin = that.get('origin')\n\t\t\t\t\t\t\tconst left = origin.clientX - evt.clientX\n\t\t\t\t\t\t\tconst top = origin.clientY - evt.clientY\n\t\t\t\t\t\t\tconst pos = that.getProjection().fromLatLngToDivPixel(that.position)\n\t\t\t\t\t\t\tif (pos === null) return\n\t\t\t\t\t\t\tconst latLng = that.getProjection().fromDivPixelToLatLng(new maps.Point(pos.x - left, pos.y - top))\n\t\t\t\t\t\t\tthat.set('position', latLng)\n\t\t\t\t\t\t\tthat.set('origin', evt)\n\t\t\t\t\t\t\tthat.draw()\n\t\t\t\t\t\t\tdrag.onDrag(evt, { latLng: getLatLng(latLng) })\n\t\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tthis.container.addEventListener('mouseup', (e) => {\n\t\t\t\t\tthat.map?.set('draggable', true)\n\t\t\t\t\tthis.container.style.cursor = 'default'\n\t\t\t\t\tif (that.moveHandler) {\n\t\t\t\t\t\tgoogle.maps.event.removeListener(that.moveHandler)\n\t\t\t\t\t\tthat.moveHandler = null\n\t\t\t\t\t}\n\t\t\t\t\tdrag.onDragEnd(e, { latLng: getLatLng(that.position) })\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Add the element to the pane.\n\t\t\tconst currentPane = this.getPanes()?.[this.pane] as HTMLElement\n\t\t\tcurrentPane?.classList.add('google-map-markers-overlay')\n\t\t\tcurrentPane?.appendChild(this.container)\n\t\t}\n\n\t\tdraw = () => {\n\t\t\tconst projection = this.getProjection() as google.maps.MapCanvasProjection\n\t\t\t// Computes the pixel coordinates of the given geographical location in the DOM element that holds the draggable map.\n\t\t\tconst point = projection.fromLatLngToDivPixel(this.position) as google.maps.Point\n\t\t\tif (point === null) return\n\t\t\tthis.container.style.transform = `translate(${point.x}px, ${point.y}px)`\n\t\t\tthis.container.style.width = '0px'\n\t\t\tthis.container.style.height = '0px'\n\t\t}\n\n\t\t/**\n\t\t * The onRemove() method will be called automatically from the API if\n\t\t * we ever set the overlay's map property to 'null'.\n\t\t */\n\t\tonRemove = () => {\n\t\t\tif (this.container.parentNode !== null) {\n\t\t\t\t// remove DOM listeners\n\t\t\t\tgoogle.maps.event.clearInstanceListeners(this.container)\n\t\t\t\tthis.container.parentNode.removeChild(this.container)\n\t\t\t}\n\t\t}\n\n\t\tpublic container: HTMLDivElement\n\n\t\tpublic pane: Pane\n\n\t\tpublic position: google.maps.LatLng\n\n\t\tpublic map = this.getMap()\n\n\t\tpublic moveHandler: google.maps.MapsEventListener | null\n\n\t\t// eslint-disable-next-line no-shadow\n\t\tconstructor(container: HTMLDivElement, pane: Pane, position: google.maps.LatLng) {\n\t\t\tsuper()\n\n\t\t\t// Initialize all properties.\n\t\t\tthis.container = container\n\t\t\tthis.pane = pane\n\t\t\tthis.position = position\n\n\t\t\tthis.moveHandler = null\n\t\t}\n\t}\n\n\treturn new Overlay(container, pane, position)\n}\n\nexport default createOverlay\n","import React from 'react'\n\ndeclare global {\n\tinterface Window {\n\t\tgoogle?: any\n\t\tgoogleMapsCallback?: () => void\n\t}\n}\n\nwindow.googleMapsCallback = () => {}\nwindow.google = undefined\n\nexport type MapMouseEvent = google.maps.MapMouseEvent\nexport type Map = google.maps.Map\nexport type MapsLibrary = typeof google.maps\nexport type MapPanes = google.maps.MapPanes\nexport type MapOptions = google.maps.MapOptions\nexport type LatLng = google.maps.LatLng\nexport type LatLngLiteral = google.maps.LatLngLiteral\nexport type LatLngBounds = google.maps.LatLngBounds\nexport type LatLngBoundsLiteral = google.maps.LatLngBoundsLiteral\n\n/**\n * The drag configuration of the overlay.\n */\nexport type Drag = {\n\t/**\n\t * Whether the overlay is draggable.\n\t * @default false\n\t */\n\tdraggable: boolean\n\t/**\n\t * Callback fired repeatedly when the overlay is dragged.\n\t * @param e The event.\n\t * @param props The props.\n\t */\n\tonDrag: (e: MouseEvent, props: {}) => void\n\t/**\n\t * Callback fired when the drag has ended.\n\t * @param e The event.\n\t * @param props The props.\n\t */\n\tonDragEnd: (e: MouseEvent, props: {}) => void\n\t/**\n\t * Callback fired when the drag has started.\n\t * @param e The event.\n\t * @param props The props.\n\t */\n\tonDragStart: (e: MouseEvent, props: {}) => void\n}\n\nexport type UseScriptStatus = 'idle' | 'loading' | 'ready' | 'error'\n\nexport type Pane = 'floatPane' | 'mapPane' | 'markerLayer' | 'overlayLayer' | 'overlayMouseTarget'\n\nexport interface IUseGoogleMaps {\n\t/**\n\t * The Google Maps API key.\n\t */\n\tapiKey?: string\n\t/**\n\t * The Google Maps API callback.\n\t */\n\tcallback?: () => void\n\t/**\n\t * The Google Maps API params to be appended to the script URL.\n\t * @example\n\t * {\n\t * language: 'en',\n\t * region: 'GB',\n\t * }\n\t */\n\texternalApiParams?: { [key: string]: any }\n\t/**\n\t * The Google Maps API libraries to be loaded.\n\t * @default ['places', 'geometry']\n\t */\n\tlibraries?: string[]\n\t/**\n\t * Whether to manage the script loading externally.\n\t * @default false\n\t */\n\tloadScriptExternally?: boolean\n\t/**\n\t * The status of the script loading.\n\t * To be used only if `loadScriptExternally` is `true`.\n\t */\n\tstatus?: UseScriptStatus\n}\n\nexport interface ScriptProps {\n\t/**\n\t * The attributes to be passed to the script element.\n\t */\n\tattributes?: { [key: string]: string }\n\t/**\n\t * The callback to be called when the script has loaded\n\t * successfully or has failed to load.\n\t */\n\tcallbacks?: {\n\t\tonErrorCallback?: () => void\n\t\tonLoadCallback?: () => void\n\t}\n\t/**\n\t * The ID of the HTML element where the script will be appended.\n\t * If not provided, the script will be appended to the `body` element.\n\t */\n\telementIdToAppend?: string\n\t/**\n\t * The URL of the script to be loaded.\n\t */\n\tsrc: string\n}\n\nexport interface UseScriptOptions {\n\t/**\n\t * Whether to remove the script when the component unmounts.\n\t */\n\tremoveOnUnmount?: boolean\n\t/**\n\t * Whether to prevent the script from loading.\n\t * @default false\n\t */\n\tshouldPreventLoad?: boolean\n}\n\nexport interface MapContextProps {\n\t/**\n\t * The Google Maps instance.\n\t */\n\tmap: Map\n\t/**\n\t * The Google Maps API object.\n\t */\n\tmaps: MapsLibrary\n}\n\nexport interface OverlayViewProps extends MapContextProps {\n\t/**\n\t * The children to be rendered within the overlay.\n\t */\n\tchildren?: React.ReactElement\n\t/**\n\t * The drag configuration of the overlay.\n\t * @default { draggable: false }\n\t */\n\tdrag?: Drag\n\t/**\n\t * The map pane in which to render the overlay.\n\t * @default 'floatPane'\n\t */\n\tpane?: Pane | undefined\n\t/**\n\t * The geographical coordinates of the overlay.\n\t */\n\tposition: LatLng\n\t/**\n\t * The z-index of the overlay.\n\t * @default 0\n\t */\n\tzIndex?: number | 0\n}\n\nexport interface createOverlayProps {\n\t/**\n\t * The HTML container element in which to render the overlay.\n\t */\n\tcontainer: HTMLDivElement\n\t/**\n\t * The drag configuration of the overlay.\n\t * @default { draggable: false }\n\t */\n\tdrag?: Drag\n\t/**\n\t * The Google Maps API object.\n\t */\n\tmaps: MapContextProps['maps']\n\t/**\n\t * The map pane in which to render the overlay.\n\t * @default 'floatPane'\n\t */\n\tpane: Pane\n\t/**\n\t * The geographical coordinates of the overlay.\n\t */\n\tposition: LatLng\n}\n\nexport interface EventProps {\n\t/**\n\t * The event handler.\n\t * @param e The event.\n\t */\n\thandler: (e: any) => void\n\t/**\n\t * The HTML Event attribute name.\n\t * @reference https://www.w3schools.com/tags/ref_eventattributes.asp\n\t * @example\n\t * 'onClick'\n\t */\n\tname: string\n}\n\nexport interface onGoogleApiLoadedProps extends MapContextProps {\n\t/**\n\t * The ref of the Map.\n\t */\n\tref: HTMLDivElement | null\n}\n\nexport interface MapMarkersProps extends MapContextProps {\n\t/**\n\t * The Markers to be rendered on the map.\n\t */\n\tchildren: React.ReactNode\n}\n\nexport interface MapProps {\n\t/**\n\t * The Markers to be rendered on the map\n\t */\n\tchildren?: React.ReactNode\n\t/**\n\t * The default center of the map.\n\t */\n\tdefaultCenter: LatLngLiteral\n\t/**\n\t * The default zoom of the map.\n\t */\n\tdefaultZoom: number\n\t/**\n\t * The events to pass to the Google Maps instance (`div`).\n\t * @type {Array}\n\t * @example\n\t * [\n\t * {\n\t * name: 'onClick',\n\t * handler: (event) => { ... }\n\t * }\n\t * ]\n\t */\n\tevents?: EventProps[]\n\t/**\n\t * The callback fired when the map changes (center, zoom, bounds).\n\t */\n\tonChange?: (options: { bounds: LatLngBounds; center: (number | undefined)[]; zoom: number }) => void\n\t/**\n\t * The callback fired when the map is loaded.\n\t */\n\tonGoogleApiLoaded?: (props: onGoogleApiLoadedProps) => void\n\t/**\n\t * The options to pass to the Google Maps instance.\n\t * @reference https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions\n\t */\n\toptions?: MapOptions\n\t/**\n\t * The style of the map container.\n\t * @default {\n\t * width: '100%',\n\t * height: '100%',\n\t * left: 0,\n\t * top: 0,\n\t * margin: 0,\n\t * padding: 0,\n\t * position: 'absolute'\n\t * }\n\t */\n\tstyle?: React.CSSProperties\n}\n\nexport interface GoogleMapProps extends MapProps, IUseGoogleMaps {\n\t/**\n\t * The props to pass to the `div` container element.\n\t */\n\tcontainerProps?: React.HTMLAttributes<HTMLDivElement>\n\t/**\n\t * The content to be rendered when the script fails to load.\n\t * @default 'Google Maps is on error'\n\t */\n\terrorContent?: React.ReactNode\n\t/**\n\t * The content to be rendered when the script is on idle.\n\t * @default 'Google Maps is on idle'\n\t */\n\tidleContent?: React.ReactNode\n\t/**\n\t * The content to be rendered while the script is loading.\n\t * @default 'Google Maps is loading'\n\t */\n\tloadingContent?: React.ReactNode\n\t/**\n\t * The minimum height of the map container.\n\t * @default 'unset'\n\t */\n\tmapMinHeight?: string\n\t/**\n\t * The Google Maps API script callback\n\t */\n\tscriptCallback?: () => void\n}\n","import GoogleMap from './google-map'\n\nexport * from './utils/types'\n\nexport default GoogleMap\n"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/google-map.tsx","../src/map/hooks/useScript.ts","../src/map/hooks/useGoogleMaps.ts","../src/map/map.tsx","../src/utils/utils.ts","../src/map/markers.tsx","../src/map/overlay-view.tsx","../src/map/hooks/useMemoCompare.ts","../src/map/overlay.tsx","../src/utils/types.ts","../src/index.ts"],"names":["forwardRef","useEffect","useState","cachedScriptStatuses","getScriptNode","src","node","status","useScript","script","forcedStatus","options","setStatus","_a","_b","_c","cachedScriptStatus","scriptToAdd","scriptNode","currentScriptStatus","key","value","setAttributeFromEvent","event","scriptStatus","setStateFromEvent","newStatus","useScript_default","useGoogleMaps","apiKey","libraries","loadScriptExternally","externalApiParams","callback","apiParams","useCallback","useRef","isArraysEqualEps","arrayA","arrayB","eps","i","Children","cloneElement","isValidElement","useMemo","createPortal","useMemoCompare","next","compare","previousRef","previous","isEqual","useMemoCompare_default","getLatLng","LatLng","createOverlay","container","pane","position","maps","drag","Overlay","that","e","evt","origin","left","top","pos","latLng","currentPane","point","overlay_default","OverlayView","map","zIndex","children","div","overlay","childrenProps","prev","overlay_view_default","jsx","noop","MapMarkers","markers","child","draggable","onDragStart","onDrag","onDragEnd","markers_default","Fragment","jsxs","MapComponent","style","defaultCenter","defaultZoom","onGoogleApiLoaded","onChange","events","mapRef","prevBoundsRef","setMap","setMaps","googleApiCalled","setGoogleApiCalled","onIdle","zoom","bounds","centerLatLng","ne","sw","boundsArray","acc","name","handler","map_default","GoogleMap","loadingContent","idleContent","errorContent","mapMinHeight","containerProps","statusProp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,OAAQ,MAAO,OAAQ,SAAU,SAAU,SAAU,WAAY,UAAWL,CAAa,EACzG,GAAGC,EAEH,SAAAK,EAAU1H,CAAM,GAAK,KACvB,CAEF,CACD,EAEO2H,EAAQX,GS3Cf,OAAO,mBAAqB,IAAM,CAAC,EACnC,OAAO,OAAS,OCNhB,IAAOY,GAAQD","sourcesContent":["import { forwardRef } from 'react'\nimport { useGoogleMaps } from './map/hooks/useGoogleMaps'\nimport MapComponent from './map/map'\nimport { GoogleMapProps } from './utils/types'\n\nconst GoogleMap = forwardRef<HTMLDivElement, GoogleMapProps>(\n\t(\n\t\t{\n\t\t\tapiKey = '',\n\t\t\tlibraries = ['places', 'geometry'],\n\t\t\tchildren = null,\n\t\t\tloadingContent = 'Google Maps is loading',\n\t\t\tidleContent = 'Google Maps is on idle',\n\t\t\terrorContent = 'Google Maps is on error',\n\t\t\tmapMinHeight = 'unset',\n\t\t\tcontainerProps = {},\n\t\t\tloadScriptExternally = false,\n\t\t\tstatus: statusProp = 'idle',\n\t\t\tscriptCallback = () => {},\n\t\t\texternalApiParams = {},\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst renderers = {\n\t\t\tready: <MapComponent {...props}>{children}</MapComponent>,\n\t\t\tloading: loadingContent,\n\t\t\tidle: idleContent,\n\t\t\terror: errorContent,\n\t\t}\n\n\t\tconst status = useGoogleMaps({\n\t\t\tapiKey,\n\t\t\tlibraries,\n\t\t\tloadScriptExternally,\n\t\t\tstatus: statusProp,\n\t\t\texternalApiParams,\n\t\t\tcallback: scriptCallback,\n\t\t})\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tstyle={{ height: '100%', width: '100%', overflow: 'hidden', position: 'relative', minHeight: mapMinHeight }}\n\t\t\t\t{...containerProps}\n\t\t\t>\n\t\t\t\t{renderers[status] || null}\n\t\t\t</div>\n\t\t)\n\t},\n)\n\nexport default GoogleMap\n","/* eslint-disable no-unused-expressions */\nimport { useEffect, useState } from 'react'\nimport { ScriptProps, UseScriptOptions, UseScriptStatus } from '../../utils/types'\n\n// Cached script statuses\nconst cachedScriptStatuses: Record<string, UseScriptStatus | undefined> = {}\n\nfunction getScriptNode(src: string) {\n\tconst node: HTMLScriptElement | null = document.querySelector(`script[src=\"${src}\"]`)\n\tconst status = node?.getAttribute('data-status') as UseScriptStatus | undefined\n\n\treturn {\n\t\tnode,\n\t\tstatus,\n\t}\n}\n\n/**\n * @description Hook to load external script.\n * @param {Object} script - Script to load.\n * @param {string} script.src - Script source.\n * @param {Object} [script.attributes] - Attributes to add to the script tag.\n * @param {Object} [script.callbacks] - Callbacks executed on completion.\n * @param {Function} [script.callbacks.onLoadCallback] - Callback executed on completion in case of success.\n * @param {Function} [script.callbacks.onErrorCallback] - Callbacks executed on completion in case of error.\n * @param {string} [script.elementIdToAppend] - HTML element id to append the script to. Default is HTML HEAD.\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n *\n * @example\n * const status = useScript({\n * \t\tsrc: \"https://script-to-load.js\",\n * \t\tattributes: { id: \"scriptId\", class: \"script-class\" },\n * \t\tcallbacks: {\n * \t\t\tonLoadCallback: onLoadFunc,\n * \t\t\tonErrorCallback: onErrorFunc,\n * \t\t},\n * \t\telementIdToAppend: \"script-container\"\n * }, undefined, { removeOnUnmount: true, shouldPreventLoad: false })\n */\n\nfunction useScript(\n\t// eslint-disable-next-line default-param-last\n\tscript: ScriptProps = {\n\t\tsrc: '',\n\t\tattributes: {},\n\t\tcallbacks: { onLoadCallback: () => {}, onErrorCallback: () => {} },\n\t\telementIdToAppend: '',\n\t},\n\tforcedStatus?: UseScriptStatus,\n\toptions: UseScriptOptions = { removeOnUnmount: false, shouldPreventLoad: false },\n): 'idle' | 'loading' | 'ready' | 'error' {\n\tconst [status, setStatus] = useState<UseScriptStatus>(() => {\n\t\tif (!script.src || options?.shouldPreventLoad) {\n\t\t\treturn 'idle'\n\t\t}\n\n\t\tif (typeof window === 'undefined') {\n\t\t\t// SSR Handling - always return 'loading'\n\t\t\treturn 'loading'\n\t\t}\n\n\t\treturn cachedScriptStatuses[script.src] ?? 'loading'\n\t})\n\n\tuseEffect(\n\t\t() => {\n\t\t\tif (forcedStatus) {\n\t\t\t\tsetStatus(forcedStatus)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (!script?.src || options?.shouldPreventLoad) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst cachedScriptStatus = cachedScriptStatuses[script.src]\n\t\t\tif (cachedScriptStatus === 'ready' || cachedScriptStatus === 'error') {\n\t\t\t\t// If the script is already cached, set its status immediately\n\t\t\t\tsetStatus(cachedScriptStatus)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Fetch existing script element by src\n\t\t\t// It may have been added by another instance of this hook\n\t\t\tconst scriptToAdd = getScriptNode(script.src)\n\t\t\tlet scriptNode = scriptToAdd.node\n\n\t\t\tif (!scriptNode) {\n\t\t\t\t// Create script element and add it to document body\n\t\t\t\tscriptNode = document.createElement('script')\n\t\t\t\tscriptNode.src = script.src\n\t\t\t\tscriptNode.async = true\n\t\t\t\tscriptNode.setAttribute('data-status', 'loading')\n\t\t\t\t// Add other script attributes, if they exist\n\t\t\t\tscript.attributes && Object.entries(script.attributes).length > 0\n\t\t\t\t\t? Object.entries(script.attributes).map(([key, value]) => scriptNode?.setAttribute(key, value))\n\t\t\t\t\t: null\n\t\t\t\tif (script.elementIdToAppend && document.getElementById(script.elementIdToAppend)) {\n\t\t\t\t\tdocument.getElementById(script.elementIdToAppend)?.appendChild(scriptNode)\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.appendChild(scriptNode)\n\t\t\t\t}\n\n\t\t\t\t// Store status in attribute on script\n\t\t\t\t// This can be read by other instances of this hook\n\t\t\t\tconst setAttributeFromEvent = (event: Event) => {\n\t\t\t\t\tconst scriptStatus: UseScriptStatus = event.type === 'load' ? 'ready' : 'error'\n\n\t\t\t\t\tscriptNode?.setAttribute('data-status', scriptStatus)\n\t\t\t\t}\n\n\t\t\t\tscriptNode.addEventListener('load', setAttributeFromEvent)\n\t\t\t\tscriptNode.addEventListener('error', setAttributeFromEvent)\n\t\t\t} else {\n\t\t\t\t// Grab existing script status from attribute and set to state.\n\t\t\t\tconst currentScriptStatus = scriptToAdd.status ?? cachedScriptStatus ?? 'loading'\n\n\t\t\t\tswitch (currentScriptStatus) {\n\t\t\t\t\tcase 'loading':\n\t\t\t\t\tcase 'ready':\n\t\t\t\t\t\tscript.callbacks?.onLoadCallback ? script.callbacks.onLoadCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\tscript.callbacks?.onErrorCallback ? script.callbacks.onErrorCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// loading: do nothing\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tsetStatus(currentScriptStatus)\n\t\t\t}\n\n\t\t\t// Script event handler to update status in state\n\t\t\t// Note: Even if the script already exists we still need to add\n\t\t\t// event handlers to update the state for this hook instance.\n\t\t\tconst setStateFromEvent = (event: Event) => {\n\t\t\t\tconst newStatus = event.type === 'load' ? 'ready' : 'error'\n\t\t\t\tevent.type === 'load'\n\t\t\t\t\t? script.callbacks?.onLoadCallback\n\t\t\t\t\t\t? script.callbacks.onLoadCallback()\n\t\t\t\t\t\t: null\n\t\t\t\t\t: script.callbacks?.onErrorCallback\n\t\t\t\t\t? script.callbacks.onErrorCallback()\n\t\t\t\t\t: null\n\n\t\t\t\tsetStatus(newStatus)\n\t\t\t\tcachedScriptStatuses[script.src] = newStatus\n\t\t\t}\n\t\t\t// Add event listeners\n\t\t\tscriptNode.addEventListener('load', setStateFromEvent)\n\t\t\tscriptNode.addEventListener('error', setStateFromEvent)\n\t\t\t// Remove event listeners on cleanup\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\treturn () => {\n\t\t\t\tif (scriptNode) {\n\t\t\t\t\tscriptNode.removeEventListener('load', setStateFromEvent)\n\t\t\t\t\tscriptNode.removeEventListener('error', setStateFromEvent)\n\t\t\t\t}\n\n\t\t\t\tif (scriptNode && options?.removeOnUnmount) {\n\t\t\t\t\tscriptNode.remove()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Re-run useEffect if script changes\n\t\t[script, forcedStatus, status],\n\t)\n\n\treturn status\n}\n\nexport default useScript\n","import { IUseGoogleMaps, UseScriptStatus } from '../../utils/types'\nimport useScript from './useScript'\n\n/**\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n */\nexport const useGoogleMaps = ({\n\tapiKey,\n\tlibraries = [],\n\tloadScriptExternally = false,\n\tstatus = 'idle',\n\texternalApiParams,\n\tcallback,\n}: IUseGoogleMaps): UseScriptStatus => {\n\tif (typeof window !== 'undefined') window.googleMapsCallback = callback\n\tconst apiParams = new URLSearchParams(externalApiParams)?.toString()\n\tconst script = apiKey\n\t\t? {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=googleMapsCallback&libraries=${libraries?.join(\n\t\t\t\t\t',',\n\t\t\t\t)}${apiParams ? `&${apiParams}` : ''}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\t\t: {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${libraries?.join(',')}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\n\treturn useScript(script, loadScriptExternally ? status : undefined)\n}\n","import { useCallback, useEffect, useRef, useState } from 'react'\nimport { EventProps, Map, MapProps, MapsLibrary } from '../utils/types'\nimport { isArraysEqualEps } from '../utils/utils'\nimport MapMarkers from './markers'\n\nfunction MapComponent({\n\tchildren = null,\n\tstyle = {\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tmargin: 0,\n\t\tpadding: 0,\n\t\tposition: 'absolute',\n\t},\n\tdefaultCenter,\n\tdefaultZoom,\n\tonGoogleApiLoaded,\n\tonChange,\n\toptions = {},\n\tevents = [],\n}: MapProps) {\n\tconst mapRef = useRef<HTMLDivElement>(null)\n\tconst prevBoundsRef = useRef<number[] | undefined>()\n\tconst [map, setMap] = useState<Map>()\n\tconst [maps, setMaps] = useState<MapsLibrary>()\n\tconst [googleApiCalled, setGoogleApiCalled] = useState<boolean>(false)\n\n\tconst onIdle = useCallback(() => {\n\t\ttry {\n\t\t\tif (!map) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst zoom = map.getZoom() ?? defaultZoom\n\t\t\tconst bounds = map.getBounds()\n\t\t\tconst centerLatLng = [map.getCenter()?.lng(), map.getCenter()?.lat()]\n\n\t\t\tconst ne = bounds?.getNorthEast()\n\t\t\tconst sw = bounds?.getSouthWest()\n\n\t\t\tif (!ne || !sw || !bounds) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// east, north, south, west\n\t\t\tconst boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]\n\n\t\t\tif (!isArraysEqualEps(boundsArray, prevBoundsRef.current)) {\n\t\t\t\tif (onChange) {\n\t\t\t\t\tonChange({\n\t\t\t\t\t\tzoom,\n\t\t\t\t\t\tcenter: centerLatLng,\n\t\t\t\t\t\tbounds,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tprevBoundsRef.current = boundsArray\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(e)\n\t\t}\n\t}, [map, onChange])\n\n\tuseEffect(() => {\n\t\tif (mapRef.current && !map) {\n\t\t\tsetMap(\n\t\t\t\tnew google.maps.Map(mapRef.current as HTMLElement, {\n\t\t\t\t\tcenter: defaultCenter,\n\t\t\t\t\tzoom: defaultZoom,\n\t\t\t\t\t...(options as google.maps.MapOptions),\n\t\t\t\t}),\n\t\t\t)\n\t\t\tsetMaps(google.maps)\n\t\t}\n\t}, [defaultCenter, defaultZoom, map, mapRef, options])\n\n\tuseEffect(() => {\n\t\tif (map) {\n\t\t\tif (!googleApiCalled) {\n\t\t\t\tif (onGoogleApiLoaded && maps) onGoogleApiLoaded({ map, maps, ref: mapRef.current })\n\t\t\t\tsetGoogleApiCalled(true)\n\t\t\t}\n\n\t\t\tgoogle.maps.event.clearListeners(map, 'idle')\n\t\t\t// Idle event is fired when the map becomes idle after panning or zooming.\n\t\t\tgoogle.maps.event.addListener(map, 'idle', onIdle)\n\t\t}\n\t}, [googleApiCalled, map, maps, onChange, onGoogleApiLoaded, onIdle])\n\n\tuseEffect(\n\t\t() =>\n\t\t\t// clear listeners on unmount\n\t\t\t() => {\n\t\t\t\tif (map) {\n\t\t\t\t\tgoogle.maps.event.clearListeners(map, 'idle')\n\t\t\t\t}\n\t\t\t},\n\t\t[map],\n\t)\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={mapRef}\n\t\t\t\tstyle={style}\n\t\t\t\tclassName=\"google-map\"\n\t\t\t\t// spread the events as props\n\t\t\t\t{...events?.reduce(\n\t\t\t\t\t(acc, { name, handler }: EventProps) => {\n\t\t\t\t\t\tacc[name] = handler\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t},\n\t\t\t\t\t{} as { [key: string]: any },\n\t\t\t\t)}\n\t\t\t/>\n\t\t\t{children && map && maps && (\n\t\t\t\t<MapMarkers map={map} maps={maps}>\n\t\t\t\t\t{children}\n\t\t\t\t</MapMarkers>\n\t\t\t)}\n\t\t</>\n\t)\n}\n\nexport default MapComponent\n","export const isArraysEqualEps = (arrayA: number[], arrayB?: number[], eps = 0.000001): boolean => {\n\tif (arrayA && arrayB) {\n\t\tfor (let i = 0; i !== arrayA.length; ++i) {\n\t\t\tif (Math.abs(arrayA[i] - arrayB[i]) > eps) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n","import { Children, cloneElement, isValidElement, useMemo } from 'react'\nimport { MapMarkersProps } from '../utils/types'\nimport OverlayView from './overlay-view'\n\nconst noop = () => {}\n\nconst MapMarkers = ({ children, map, maps }: MapMarkersProps) => {\n\tconst markers = useMemo(() => {\n\t\tif (!map || !maps) return []\n\n\t\treturn Children.map(children, (child) => {\n\t\t\tif (isValidElement(child)) {\n\t\t\t\tconst latLng = { lat: child.props.lat, lng: child.props.lng } as google.maps.LatLngLiteral\n\t\t\t\tconst { zIndex, draggable = false, onDragStart = noop, onDrag = noop, onDragEnd = noop } = child.props || {}\n\n\t\t\t\t// clone child without draggable props\n\t\t\t\t// eslint-disable-next-line no-param-reassign\n\t\t\t\tchild = cloneElement(child, {\n\t\t\t\t\t...child.props,\n\t\t\t\t\tdraggable: undefined,\n\t\t\t\t\tonDragStart: undefined,\n\t\t\t\t\tonDrag: undefined,\n\t\t\t\t\tonDragEnd: undefined,\n\t\t\t\t})\n\n\t\t\t\treturn (\n\t\t\t\t\t<OverlayView\n\t\t\t\t\t\tposition={new maps.LatLng(latLng.lat, latLng.lng)}\n\t\t\t\t\t\tmap={map}\n\t\t\t\t\t\tmaps={maps}\n\t\t\t\t\t\tzIndex={zIndex}\n\t\t\t\t\t\tdrag={{\n\t\t\t\t\t\t\tdraggable,\n\t\t\t\t\t\t\tonDragStart,\n\t\t\t\t\t\t\tonDrag,\n\t\t\t\t\t\t\tonDragEnd,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{child}\n\t\t\t\t\t</OverlayView>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn null\n\t\t})\n\t}, [children, map, maps])\n\n\treturn <div>{markers}</div>\n}\n\nexport default MapMarkers\n","import { useEffect, useMemo } from 'react'\nimport { createPortal } from 'react-dom'\nimport { OverlayViewProps } from '../utils/types'\nimport useMemoCompare from './hooks/useMemoCompare'\nimport createOverlay from './overlay'\n\nconst OverlayView = ({ pane = 'floatPane', position, map, maps, zIndex = 0, children, drag }: OverlayViewProps) => {\n\tconst container = useMemo<HTMLDivElement>(() => {\n\t\t// eslint-disable-next-line no-undef\n\t\tconst div = document.createElement('div') as HTMLDivElement\n\t\tdiv.style.position = 'absolute'\n\t\treturn div as HTMLDivElement\n\t}, [])\n\n\tconst overlay = useMemo(\n\t\t() => createOverlay({ container, pane, position, maps, drag }),\n\t\t[container, drag, maps, pane, position],\n\t)\n\n\t// Because React does not do deep comparisons, a custom hook is used.\n\t// This fixes the issue where the overlay is not updated when the position changes.\n\tconst childrenProps = useMemoCompare(\n\t\tchildren?.props as any,\n\t\t(prev: { lat: any; lng: any }, next: { lat: any; lng: any }) =>\n\t\t\tprev && prev.lat === next.lat && prev.lng === next.lng,\n\t)\n\n\tuseEffect(() => {\n\t\tif (!overlay.map && map) {\n\t\t\toverlay?.setMap(map)\n\t\t\treturn () => {\n\t\t\t\toverlay?.setMap(null)\n\t\t\t}\n\t\t}\n\t\treturn () => {}\n\t\t// overlay depends on map, so we don't need to add it to the dependency array\n\t\t// otherwise, it will re-render the overlay every time the map changes\n\t\t// ? added childrenProps to the dependency array to re-render the overlay when the children props change.\n\t}, [map, childrenProps])\n\n\t// to move the container to the foreground and background\n\tuseEffect(() => {\n\t\tcontainer.style.zIndex = `${zIndex}`\n\t}, [zIndex, container])\n\n\treturn createPortal(children, container)\n}\n\nexport default OverlayView\n","import { useEffect, useRef } from 'react'\n\n/**\n * A hook that compares the previous and current values of a reference.\n * @param {any} next - the current value of the reference\n * @param {function} compare - a function that compares the previous and current values\n * @returns {any} the previous value of the reference\n * @ref https://usehooks.com/useMemoCompare/\n */\nconst useMemoCompare = (next: any, compare: Function): any => {\n\t// Ref for storing previous value\n\tconst previousRef = useRef()\n\tconst previous = previousRef.current\n\t// Pass previous and next value to compare function\n\t// to determine whether to consider them equal.\n\tconst isEqual = compare(previous, next)\n\t// If not equal update previousRef to next value.\n\t// We only update if not equal so that this hook continues to return\n\t// the same old value if compare keeps returning true.\n\tuseEffect(() => {\n\t\tif (!isEqual) {\n\t\t\tpreviousRef.current = next\n\t\t}\n\t})\n\t// Finally, if equal then return the previous value\n\treturn isEqual ? previous : next\n}\n\nexport default useMemoCompare\n","import { Pane, createOverlayProps } from '../utils/types'\n\n// return lat, lng from LatLngLiteral\nconst getLatLng = (LatLng: google.maps.LatLng | null) => {\n\ttry {\n\t\tconst latLng = { lat: LatLng?.lat(), lng: LatLng?.lng() } as google.maps.LatLngLiteral\n\t\treturn latLng\n\t} catch (e) {\n\t\treturn LatLng\n\t}\n}\n\nconst createOverlay = ({ container, pane, position, maps, drag }: createOverlayProps) => {\n\tclass Overlay extends google.maps.OverlayView {\n\t\t/**\n\t\t * onAdd is called when the map's panes are ready and the overlay has been\n\t\t * added to the map.\n\t\t */\n\t\tonAdd = () => {\n\t\t\tconst that = this\n\t\t\t// manage draggable\n\t\t\tif (drag?.draggable) {\n\t\t\t\tthis.get('map')\n\t\t\t\t\t.getDiv()\n\t\t\t\t\t.addEventListener('mouseleave', () => {\n\t\t\t\t\t\tgoogle.maps.event.trigger(this.container, 'mouseup')\n\t\t\t\t\t})\n\t\t\t\tthis.container.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\t\t\tthis.container.style.cursor = 'grabbing'\n\t\t\t\t\tthat.map?.set('draggable', false)\n\t\t\t\t\tthat.set('origin', e)\n\n\t\t\t\t\tdrag.onDragStart(e, { latLng: getLatLng(this.position) })\n\n\t\t\t\t\t// eslint-disable-next-line no-shadow\n\t\t\t\t\tthat.moveHandler = this.get('map')\n\t\t\t\t\t\t.getDiv()\n\t\t\t\t\t\t.addEventListener('mousemove', (evt: MouseEvent) => {\n\t\t\t\t\t\t\tconst origin = that.get('origin')\n\t\t\t\t\t\t\tconst left = origin.clientX - evt.clientX\n\t\t\t\t\t\t\tconst top = origin.clientY - evt.clientY\n\t\t\t\t\t\t\tconst pos = that.getProjection().fromLatLngToDivPixel(that.position)\n\t\t\t\t\t\t\tif (pos === null) return\n\t\t\t\t\t\t\tconst latLng = that.getProjection().fromDivPixelToLatLng(new maps.Point(pos.x - left, pos.y - top))\n\t\t\t\t\t\t\tthat.set('position', latLng)\n\t\t\t\t\t\t\tthat.set('origin', evt)\n\t\t\t\t\t\t\tthat.draw()\n\t\t\t\t\t\t\tdrag.onDrag(evt, { latLng: getLatLng(latLng) })\n\t\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tthis.container.addEventListener('mouseup', (e) => {\n\t\t\t\t\tthat.map?.set('draggable', true)\n\t\t\t\t\tthis.container.style.cursor = 'default'\n\t\t\t\t\tif (that.moveHandler) {\n\t\t\t\t\t\tgoogle.maps.event.removeListener(that.moveHandler)\n\t\t\t\t\t\tthat.moveHandler = null\n\t\t\t\t\t}\n\t\t\t\t\tdrag.onDragEnd(e, { latLng: getLatLng(that.position) })\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Add the element to the pane.\n\t\t\tconst currentPane = this.getPanes()?.[this.pane] as HTMLElement\n\t\t\tcurrentPane?.classList.add('google-map-markers-overlay')\n\t\t\tcurrentPane?.appendChild(this.container)\n\t\t}\n\n\t\tdraw = () => {\n\t\t\tconst projection = this.getProjection() as google.maps.MapCanvasProjection\n\t\t\t// Computes the pixel coordinates of the given geographical location in the DOM element that holds the draggable map.\n\t\t\tconst point = projection.fromLatLngToDivPixel(this.position) as google.maps.Point\n\t\t\tif (point === null) return\n\t\t\tthis.container.style.transform = `translate(${point.x}px, ${point.y}px)`\n\t\t\tthis.container.style.width = '0px'\n\t\t\tthis.container.style.height = '0px'\n\t\t}\n\n\t\t/**\n\t\t * The onRemove() method will be called automatically from the API if\n\t\t * we ever set the overlay's map property to 'null'.\n\t\t */\n\t\tonRemove = () => {\n\t\t\tif (this.container.parentNode !== null) {\n\t\t\t\t// remove DOM listeners\n\t\t\t\tgoogle.maps.event.clearInstanceListeners(this.container)\n\t\t\t\tthis.container.parentNode.removeChild(this.container)\n\t\t\t}\n\t\t}\n\n\t\tpublic container: HTMLDivElement\n\n\t\tpublic pane: Pane\n\n\t\tpublic position: google.maps.LatLng\n\n\t\tpublic map = this.getMap()\n\n\t\tpublic moveHandler: google.maps.MapsEventListener | null\n\n\t\t// eslint-disable-next-line no-shadow\n\t\tconstructor(container: HTMLDivElement, pane: Pane, position: google.maps.LatLng) {\n\t\t\tsuper()\n\n\t\t\t// Initialize all properties.\n\t\t\tthis.container = container\n\t\t\tthis.pane = pane\n\t\t\tthis.position = position\n\n\t\t\tthis.moveHandler = null\n\t\t}\n\t}\n\n\treturn new Overlay(container, pane, position)\n}\n\nexport default createOverlay\n","import React from 'react'\n\ndeclare global {\n\tinterface Window {\n\t\tgoogle?: any\n\t\tgoogleMapsCallback?: () => void\n\t}\n}\n\nwindow.googleMapsCallback = () => {}\nwindow.google = undefined\n\nexport type MapMouseEvent = google.maps.MapMouseEvent\nexport type Map = google.maps.Map\nexport type MapsLibrary = typeof google.maps\nexport type MapPanes = google.maps.MapPanes\nexport type MapOptions = google.maps.MapOptions\nexport type LatLng = google.maps.LatLng\nexport type LatLngLiteral = google.maps.LatLngLiteral\nexport type LatLngBounds = google.maps.LatLngBounds\nexport type LatLngBoundsLiteral = google.maps.LatLngBoundsLiteral\n\n/**\n * The drag configuration of the overlay.\n */\nexport type Drag = {\n\t/**\n\t * Whether the overlay is draggable.\n\t * @default false\n\t */\n\tdraggable: boolean\n\t/**\n\t * Callback fired repeatedly when the overlay is dragged.\n\t * @param e The event.\n\t * @param props The props.\n\t */\n\tonDrag: (e: MouseEvent, props: {}) => void\n\t/**\n\t * Callback fired when the drag has ended.\n\t * @param e The event.\n\t * @param props The props.\n\t */\n\tonDragEnd: (e: MouseEvent, props: {}) => void\n\t/**\n\t * Callback fired when the drag has started.\n\t * @param e The event.\n\t * @param props The props.\n\t */\n\tonDragStart: (e: MouseEvent, props: {}) => void\n}\n\nexport type UseScriptStatus = 'idle' | 'loading' | 'ready' | 'error'\n\nexport type Pane = 'floatPane' | 'mapPane' | 'markerLayer' | 'overlayLayer' | 'overlayMouseTarget'\n\nexport interface IUseGoogleMaps {\n\t/**\n\t * The Google Maps API key.\n\t */\n\tapiKey?: string\n\t/**\n\t * The Google Maps API callback.\n\t */\n\tcallback?: () => void\n\t/**\n\t * The Google Maps API params to be appended to the script URL.\n\t * @example\n\t * {\n\t * language: 'en',\n\t * region: 'GB',\n\t * }\n\t */\n\texternalApiParams?: { [key: string]: any }\n\t/**\n\t * The Google Maps API libraries to be loaded.\n\t * @default ['places', 'geometry']\n\t */\n\tlibraries?: string[]\n\t/**\n\t * Whether to manage the script loading externally.\n\t * @default false\n\t */\n\tloadScriptExternally?: boolean\n\t/**\n\t * The status of the script loading.\n\t * To be used only if `loadScriptExternally` is `true`.\n\t */\n\tstatus?: UseScriptStatus\n}\n\nexport interface ScriptProps {\n\t/**\n\t * The attributes to be passed to the script element.\n\t */\n\tattributes?: { [key: string]: string }\n\t/**\n\t * The callback to be called when the script has loaded\n\t * successfully or has failed to load.\n\t */\n\tcallbacks?: {\n\t\tonErrorCallback?: () => void\n\t\tonLoadCallback?: () => void\n\t}\n\t/**\n\t * The ID of the HTML element where the script will be appended.\n\t * If not provided, the script will be appended to the `body` element.\n\t */\n\telementIdToAppend?: string\n\t/**\n\t * The URL of the script to be loaded.\n\t */\n\tsrc: string\n}\n\nexport interface UseScriptOptions {\n\t/**\n\t * Whether to remove the script when the component unmounts.\n\t */\n\tremoveOnUnmount?: boolean\n\t/**\n\t * Whether to prevent the script from loading.\n\t * @default false\n\t */\n\tshouldPreventLoad?: boolean\n}\n\nexport interface MapContextProps {\n\t/**\n\t * The Google Maps instance.\n\t */\n\tmap: Map\n\t/**\n\t * The Google Maps API object.\n\t */\n\tmaps: MapsLibrary\n}\n\nexport interface OverlayViewProps extends MapContextProps {\n\t/**\n\t * The children to be rendered within the overlay.\n\t */\n\tchildren?: React.ReactElement\n\t/**\n\t * The drag configuration of the overlay.\n\t * @default { draggable: false }\n\t */\n\tdrag?: Drag\n\t/**\n\t * The map pane in which to render the overlay.\n\t * @default 'floatPane'\n\t */\n\tpane?: Pane | undefined\n\t/**\n\t * The geographical coordinates of the overlay.\n\t */\n\tposition: LatLng\n\t/**\n\t * The z-index of the overlay.\n\t * @default 0\n\t */\n\tzIndex?: number | 0\n}\n\nexport interface createOverlayProps {\n\t/**\n\t * The HTML container element in which to render the overlay.\n\t */\n\tcontainer: HTMLDivElement\n\t/**\n\t * The drag configuration of the overlay.\n\t * @default { draggable: false }\n\t */\n\tdrag?: Drag\n\t/**\n\t * The Google Maps API object.\n\t */\n\tmaps: MapContextProps['maps']\n\t/**\n\t * The map pane in which to render the overlay.\n\t * @default 'floatPane'\n\t */\n\tpane: Pane\n\t/**\n\t * The geographical coordinates of the overlay.\n\t */\n\tposition: LatLng\n}\n\nexport interface EventProps {\n\t/**\n\t * The event handler.\n\t * @param e The event.\n\t */\n\thandler: (e: any) => void\n\t/**\n\t * The HTML Event attribute name.\n\t * @reference https://www.w3schools.com/tags/ref_eventattributes.asp\n\t * @example\n\t * 'onClick'\n\t */\n\tname: string\n}\n\nexport interface onGoogleApiLoadedProps extends MapContextProps {\n\t/**\n\t * The ref of the Map.\n\t */\n\tref: HTMLDivElement | null\n}\n\nexport interface MapMarkersProps extends MapContextProps {\n\t/**\n\t * The Markers to be rendered on the map.\n\t */\n\tchildren: React.ReactNode\n}\n\nexport interface MapProps {\n\t/**\n\t * The Markers to be rendered on the map\n\t */\n\tchildren?: React.ReactNode\n\t/**\n\t * The default center of the map.\n\t */\n\tdefaultCenter: LatLngLiteral\n\t/**\n\t * The default zoom of the map.\n\t */\n\tdefaultZoom: number\n\t/**\n\t * The events to pass to the Google Maps instance (`div`).\n\t * @type {Array}\n\t * @example\n\t * [\n\t * {\n\t * name: 'onClick',\n\t * handler: (event) => { ... }\n\t * }\n\t * ]\n\t */\n\tevents?: EventProps[]\n\t/**\n\t * The callback fired when the map changes (center, zoom, bounds).\n\t */\n\tonChange?: (options: { bounds: LatLngBounds; center: (number | undefined)[]; zoom: number }) => void\n\t/**\n\t * The callback fired when the map is loaded.\n\t */\n\tonGoogleApiLoaded?: (props: onGoogleApiLoadedProps) => void\n\t/**\n\t * The options to pass to the Google Maps instance.\n\t * @reference https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions\n\t */\n\toptions?: MapOptions\n\t/**\n\t * The style of the map container.\n\t * @default {\n\t * width: '100%',\n\t * height: '100%',\n\t * left: 0,\n\t * top: 0,\n\t * margin: 0,\n\t * padding: 0,\n\t * position: 'absolute'\n\t * }\n\t */\n\tstyle?: React.CSSProperties\n}\n\nexport interface GoogleMapProps extends MapProps, IUseGoogleMaps {\n\t/**\n\t * The props to pass to the `div` container element.\n\t */\n\tcontainerProps?: React.HTMLAttributes<HTMLDivElement>\n\t/**\n\t * The content to be rendered when the script fails to load.\n\t * @default 'Google Maps is on error'\n\t */\n\terrorContent?: React.ReactNode\n\t/**\n\t * The content to be rendered when the script is on idle.\n\t * @default 'Google Maps is on idle'\n\t */\n\tidleContent?: React.ReactNode\n\t/**\n\t * The content to be rendered while the script is loading.\n\t * @default 'Google Maps is loading'\n\t */\n\tloadingContent?: React.ReactNode\n\t/**\n\t * The minimum height of the map container.\n\t * @default 'unset'\n\t */\n\tmapMinHeight?: string\n\t/**\n\t * The Google Maps API script callback\n\t */\n\tscriptCallback?: () => void\n}\n","import GoogleMap from './google-map'\n\nexport * from './utils/types'\n\nexport default GoogleMap\n"]}