@sanity/google-maps-input 3.0.0 → 3.0.1
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/LICENSE +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +2 -3
- package/src/loader/GoogleMapsLoadProxy.tsx +44 -37
- package/src/loader/LoadError.tsx +1 -1
- package/src/loader/loadGoogleMapsApi.ts +40 -64
package/LICENSE
CHANGED
package/lib/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e,t,n,o,r;function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}import{jsxs as c,jsx as d,Fragment as p}from"react/jsx-runtime";import*as h from"react";import u from"react";import{uniqueId as m}from"lodash";import{Card as f,Box as g,Text as v,Code as C,TextInput as y,Grid as k,Button as b,Dialog as w}from"@sanity/ui";import{EditIcon as M,TrashIcon as P}from"@sanity/icons";import{setIfMissing as x,set as O,unset as I,ChangeIndicator as S,useUserColor as E,getAnnotationAtPath as H,DiffTooltip as R,definePlugin as j}from"sanity";import{BehaviorSubject as L}from"rxjs";import z from"styled-components";const T="___sanity_googleMapsApiCallback",A="undefined"!=typeof window&&window.navigator.language||"en";let D;function V(e,t){return t||("string"==typeof e?new Error(e):new Error(function(e){if("object"!=typeof e||null===e)return!1;if(!("message"in e))return!1;return"string"==typeof e.message}(e)?e.message:"Failed to load Google Maps API"))}function B(e){var t;return c(f,{tone:"critical",radius:1,children:[d(g,{as:"header",paddingX:4,paddingTop:4,paddingBottom:1,children:d(v,{as:"h2",weight:"bold",children:"Google Maps failed to load"})}),d(g,{paddingX:4,paddingTop:4,paddingBottom:1,children:e.isAuthError?d(_,{}):c(p,{children:[d(v,{as:"h3",children:"Error details:"}),d("pre",{children:d(C,{size:1,children:"error"in e&&(null==(t=e.error)?void 0:t.message)})})]})})]})}function _(){return c(v,{children:[d("p",{children:"The error appears to be related to authentication"}),d("p",{children:"Common causes include:"}),c("ul",{children:[d("li",{children:"Incorrect API key"}),d("li",{children:"Referer not allowed"}),d("li",{children:"Missing authentication scope"})]}),d("p",{children:"Check the browser developer tools for more information."})]})}class W extends u.Component{constructor(e){super(e),this.state={loadState:"loading"};let t=!0;this.loadSubscription=function(e){const t=e.defaultLocale||A||"en-US";if(D)return D;D=new L({loadState:"loading"}),window.gm_authFailure=()=>{delete window.gm_authFailure,D.next({loadState:"authError"})},window[T]=()=>{delete window[T],D.next({loadState:"loaded",api:window.google.maps})};const n=document.createElement("script");return n.onerror=(e,t,n,o,r)=>D.next({loadState:"loadError",error:V(e,r)}),n.src="https://maps.googleapis.com/maps/api/js?key=".concat(e.apiKey,"&libraries=places&callback=").concat(T,"&language=").concat(t),document.getElementsByTagName("head")[0].appendChild(n),D}(e.config).subscribe((e=>{t?this.state=e:this.setState(e)})),t=!1}componentWillUnmount(){this.loadSubscription&&this.loadSubscription.unsubscribe()}render(){switch(this.state.loadState){case"loadError":return d(B,{error:this.state.error,isAuthError:!1});case"authError":return d(B,{isAuthError:!0});case"loading":return d("div",{children:"Loading Google Maps API"});case"loaded":return this.props.children(this.state.api)||null;default:return null}}}const U=z.div(e||(e=s(["\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n"])));class G extends h.PureComponent{constructor(){super(...arguments),this.searchInputRef=h.createRef(),this.handleChange=()=>{this.autoComplete&&(this.props.onChange(this.autoComplete.getPlace()),this.searchInputRef.current&&(this.searchInputRef.current.value=""))}}componentDidMount(){const e=this.searchInputRef.current;if(!e)return;const{api:t,map:n}=this.props,{Circle:o,places:r,event:i}=t,a=new o({center:n.getCenter(),radius:100}).getBounds();this.autoComplete=new r.Autocomplete(e,{bounds:a,types:[]}),i.addListener(this.autoComplete,"place_changed",this.handleChange)}render(){return d(U,{children:d(y,{name:"place",ref:this.searchInputRef,placeholder:"Search for place or address",padding:4})})}}function Z(e,t){const n="function"==typeof e.lat?e.lat():e.lat,o="function"==typeof e.lng?e.lng():e.lng,r="function"==typeof t.lat?t.lat():t.lat,i="function"==typeof t.lng?t.lng():t.lng;return n===r&&o===i}const F=z.div(t||(t=s(["\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n"])));class N extends u.PureComponent{constructor(){super(...arguments),this.state={map:void 0},this.mapRef=u.createRef(),this.mapEl=null,this.attachClickHandler=()=>{const e=this.state.map;if(!e)return;const{api:t,onClick:n}=this.props,{event:o}=t;this.clickHandler&&this.clickHandler.remove(),n&&(this.clickHandler=o.addListener(e,"click",n))},this.setMapElement=e=>{if(e&&e!==this.mapEl){const t=this.constructMap(e);this.setState({map:t},this.attachClickHandler)}this.mapEl=e}}componentDidMount(){this.attachClickHandler()}componentDidUpdate(e){const t=this.state.map;if(!t)return;const{onClick:n,location:o,bounds:r}=this.props;e.onClick!==n&&this.attachClickHandler(),Z(e.location,o)||t.panTo(this.getCenter()),!r||e.bounds&&r.equals(e.bounds)||t.fitBounds(r)}componentWillUnmount(){this.clickHandler&&this.clickHandler.remove()}getCenter(){const{location:e,api:t}=this.props;return new t.LatLng(e.lat,e.lng)}constructMap(e){const{defaultZoom:t,api:n,mapTypeControl:o,controlSize:r,bounds:i,scrollWheel:a}=this.props,l=new n.Map(e,{zoom:t,center:this.getCenter(),scrollwheel:a,streetViewControl:!1,mapTypeControl:o,controlSize:r});return i&&l.fitBounds(i),l}render(){const{children:e}=this.props,{map:t}=this.state;return c(p,{children:[d(F,{ref:this.setMapElement}),e&&t?e(t):null]})}}N.defaultProps={defaultZoom:8,scrollWheel:!0};class J extends h.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{position:e,api:t,map:n,onMove:o,zIndex:r,opacity:i,label:a,markerRef:l,color:s}=this.props,{Marker:c}=t;let d;s&&(d={path:"M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z",fillOpacity:1,fillColor:s.background,strokeColor:s.border,strokeWeight:2,anchor:new t.Point(10,35),labelOrigin:new t.Point(10,11)}),this.marker=new c({draggable:Boolean(o),position:e,map:n,zIndex:r,opacity:i,label:a,icon:d}),l&&(l.current=this.marker),this.attachMoveHandler(),this.attachClickHandler()}componentDidUpdate(e){if(!this.marker)return;const{position:t,onMove:n,label:o,zIndex:r,opacity:i,map:a}=this.props;e.onMove!==n&&this.attachMoveHandler(),Z(e.position,t)||this.marker.setPosition(t),e.label!==o&&this.marker.setLabel(o||null),e.zIndex!==r&&this.marker.setZIndex(r||null),e.opacity!==i&&this.marker.setOpacity(i||null),e.map!==a&&this.marker.setMap(a)}componentWillUnmount(){this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&this.marker.setMap(null)}attachMoveHandler(){const{api:e,onMove:t}=this.props;this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&t&&(this.eventHandlers.move=e.event.addListener(this.marker,"dragend",t))}attachClickHandler(){const{api:e,onClick:t}=this.props;this.eventHandlers.click&&this.eventHandlers.click.remove(),this.marker&&t&&(this.eventHandlers.click=e.event.addListener(this.marker,"click",t))}render(){return null}}const K={lat:40.7058254,lng:-74.1180863};class X extends u.PureComponent{constructor(){super(...arguments),this.mapRef=u.createRef(),this.handlePlaceChanged=e=>{var t;(null==(t=e.geometry)?void 0:t.location)&&this.setValue(e.geometry.location)},this.handleMarkerDragEnd=e=>{e.latLng&&this.setValue(e.latLng)},this.handleMapClick=e=>{e.latLng&&this.setValue(e.latLng)}}getCenter(){const{value:e={},defaultLocation:t={}}=this.props;return a(a(a({},K),t),e)}setValue(e){this.props.onChange&&this.props.onChange(e)}render(){const{api:e,defaultZoom:t,value:n,onChange:o}=this.props;return d(N,{api:e,location:this.getCenter(),onClick:this.handleMapClick,defaultZoom:t,children:t=>c(p,{children:[d(G,{api:e,map:t,onChange:this.handlePlaceChanged}),n&&d(J,{api:e,map:t,position:n,onMove:o?this.handleMarkerDragEnd:void 0})]})})}}X.defaultProps={defaultZoom:8,defaultLocation:{lng:10.74609,lat:59.91273}};const q=z.img(n||(n=s(["\n width: 100%;\n height: auto;\n vertical-align: top;\n"]))),Q=z.div(o||(o=s(["\n height: 40rem;\n width: 50rem;\n"])));let Y;function $(){return Y}function ee(e){Y=e}const te=(e,t)=>{const n="".concat(e.lat,",").concat(e.lng),o={key:t,center:n,markers:n,zoom:13,scale:2,size:"640x300"},r=Object.keys(o).reduce(((e,t)=>e.concat("".concat(t,"=").concat(encodeURIComponent(o[t])))),[]);return"https://maps.googleapis.com/maps/api/staticmap?".concat(r.join("&"))};class ne extends u.PureComponent{constructor(e){super(e),this._geopointInputId=m("GeopointInput"),this.setEditButton=e=>{this.editButton=e},this.handleToggleModal=()=>{this.setState((e=>({modalOpen:!e.modalOpen})))},this.handleCloseModal=()=>{this.setState({modalOpen:!1})},this.handleChange=e=>{const{schemaType:t,onChange:n}=this.props;n([x({_type:t.name}),O(e.lat(),["lat"]),O(e.lng(),["lng"])])},this.handleClear=()=>{const{onChange:e}=this.props;e(I())},this.state={modalOpen:!1}}focus(){this.editButton&&this.editButton.focus()}render(){const{value:e,readOnly:t,geoConfig:n,path:o,changed:r,focused:i}=this.props,{modalOpen:a}=this.state;return n&&n.apiKey?c(p,{children:[e&&d(S,{path:o,isChanged:r,hasFocus:!!i,children:d(q,{src:te(e,n.apiKey),alt:"Map location"})}),!t&&d(g,{marginTop:4,children:c(k,{columns:2,gap:2,children:[d(b,{mode:"ghost",icon:e&&M,padding:3,ref:this.setEditButton,text:e?"Edit":"Set location",onClick:this.handleToggleModal}),e&&d(b,{tone:"critical",icon:P,padding:3,mode:"ghost",text:"Remove",onClick:this.handleClear})]})}),a&&d(w,{id:"".concat(this._geopointInputId,"_dialog"),onClose:this.handleCloseModal,header:"Place the marker on the map",width:1,children:d(Q,{children:d(W,{config:$(),children:o=>d(X,{api:o,value:e||void 0,onChange:t?void 0:this.handleChange,defaultLocation:n.defaultLocation,defaultZoom:n.defaultZoom})})})})]}):c("div",{children:[c("p",{children:["The ",d("a",{href:"https://sanity.io/docs/schema-types/geopoint-type",children:"Geopoint type"})," needs a Google Maps API key with access to:"]}),c("ul",{children:[d("li",{children:"Google Maps JavaScript API"}),d("li",{children:"Google Places API Web Service"}),d("li",{children:"Google Static Maps API"})]}),d("p",{children:"Please enter the API key with access to these services in your googleMapsInput plugin config."})]})}}class oe extends h.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{from:e,to:t,api:n,map:o,zIndex:r,onClick:i,color:a,arrowRef:l}=this.props,s={path:n.SymbolPath.FORWARD_OPEN_ARROW};this.line=new n.Polyline({map:o,zIndex:r,path:[e,t],icons:[{icon:s,offset:"50%"}],strokeOpacity:.55,strokeColor:a?a.text:"black"}),i&&(this.eventHandlers.click=n.event.addListener(this.line,"click",i)),l&&(l.current=this.line)}componentDidUpdate(e){if(!this.line)return;const{from:t,to:n,map:o}=this.props;Z(e.from,t)&&Z(e.to,n)||this.line.setPath([t,n]),e.map!==o&&this.line.setMap(o)}componentWillUnmount(){this.line&&this.line.setMap(null),this.eventHandlers.click&&this.eventHandlers.click.remove()}render(){return null}}function re(e){let{diff:t,api:n,map:o,label:r}=e;const{fromValue:i,toValue:a}=t,l=t.isChanged?t.annotation:void 0,s=E(l?l.author:null)||void 0,u=h.useRef(),m=h.useRef();return c(p,{children:[i&&d(J,{api:n,map:o,position:i,zIndex:0,opacity:.55,markerRef:u,color:s}),i&&a&&d(oe,{api:n,map:o,from:i,to:a,zIndex:1,color:s}),a&&d(J,{api:n,map:o,position:a,zIndex:2,markerRef:m,label:r,color:s})]})}const ie=z.div(r||(r=s(["\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n"]))),ae=e=>{let{diff:t,schemaType:n}=e;return d(ie,{children:d(W,{config:$(),children:e=>d(le,{api:e,diff:t,schemaType:n})})})};function le(e){let{api:t,diff:n}=e;const o=(n.fromValue||[]).filter(se),r=(n.toValue||[]).filter(se);if(0===o.length&&0===r.length)return null;const i=function(e,t,n){const o=new n.LatLngBounds;return[...e||[],...t||[]].forEach((e=>o.extend(e))),o}(o,r,t);return d(N,{api:t,location:i.getCenter().toJSON(),mapTypeControl:!1,controlSize:20,bounds:i,children:e=>d(p,{children:n.items.map((n=>{let{toIndex:o,diff:r}=n;return function(e){return"unchanged"!==e.action&&"object"===e.type}(r)?d(re,{api:t,map:e,diff:r,label:"".concat(o)},o):null}))})})}function se(e){return"number"==typeof e.lat&&"number"==typeof e.lng}const ce=e=>{let{diff:t,schemaType:n}=e;return d(ie,{children:d(W,{config:$(),children:e=>d(de,{api:e,diff:t,schemaType:n})})})};function de(e){let{api:t,diff:n}=e;const{fromValue:o,toValue:r}=n,i=H(n,["lat"])||H(n,["lng"])||H(n,[]),a=function(e,t){const{fromValue:n,toValue:o}=e;if(n&&o)return pe(n,o,t).getCenter().toJSON();if(n)return n;if(o)return o;throw new Error("Neither a from or a to value present")}(n,t),l=o&&r?pe(o,r,t):void 0;return d(R,{annotations:i?[i]:[],description:he(n),children:d("div",{children:d(N,{api:t,location:a,mapTypeControl:!1,controlSize:20,bounds:l,scrollWheel:!1,children:e=>d(re,{api:t,map:e,diff:n})})})})}function pe(e,t,n){return(new n.LatLngBounds).extend(e).extend(t)}function he(e){const{fromValue:t,toValue:n}=e;return t&&n?"Moved":t?"Removed":n?"Added":"Unchanged"}const ue=j((e=>(ee(e),{name:"google-maps-input",form:{components:{input(t){if(me("geopoint",t.schemaType)){return d(ne,a(a({},t),{},{geoConfig:e}))}return t.renderDefault(t)}}}})));function me(e,t){return(null==t?void 0:t.name)===e||!!(null==t?void 0:t.name)&&me(e,null==t?void 0:t.type)}export{ae as GeopointArrayDiff,ce as GeopointFieldDiff,ne as GeopointInput,ue as googleMapsInput};
|
|
1
|
+
var e,t,n,o,r;function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}import{jsxs as c,jsx as p,Fragment as d}from"react/jsx-runtime";import*as h from"react";import u,{useState as m,useEffect as f}from"react";import{uniqueId as g}from"lodash";import{Card as v,Box as y,Text as C,Code as k,TextInput as b,Grid as w,Button as M,Dialog as P}from"@sanity/ui";import{EditIcon as O,TrashIcon as x}from"@sanity/icons";import{setIfMissing as I,set as H,unset as E,ChangeIndicator as R,useUserColor as L,getAnnotationAtPath as j,DiffTooltip as z,definePlugin as T}from"sanity";import S from"styled-components";const A="___sanity_googleMapsApiCallback";class D extends Error{}function V(e){return new Promise(((t,n)=>{window.gm_authFailure=()=>{n(new D("Authentication error when loading Google Maps API."))},window[A]=()=>{t(window.google.maps)};const o=document.createElement("script");o.onerror=(e,t,o,r,i)=>n(new Error(function(e,t){if(t)return t.message;if("string"==typeof e)return e;return function(e){if("object"!=typeof e||null===e)return!1;if(!("message"in e))return!1;return"string"==typeof e.message}(e)?e.message:"Failed to load Google Maps API"}(e,i))),o.src="https://maps.googleapis.com/maps/api/js?key=".concat(e.apiKey,"&libraries=places&callback=").concat(A,"&language=").concat(e.locale),document.getElementsByTagName("head")[0].appendChild(o)})).finally((()=>{delete window[A],delete window.gm_authFailure}))}let B=null;function _(e){var t;return c(v,{tone:"critical",radius:1,children:[p(y,{as:"header",paddingX:4,paddingTop:4,paddingBottom:1,children:p(C,{as:"h2",weight:"bold",children:"Google Maps failed to load"})}),p(y,{paddingX:4,paddingTop:4,paddingBottom:1,children:e.isAuthError?p(G,{}):c(d,{children:[p(C,{as:"h3",children:"Error details:"}),p("pre",{children:p(k,{size:1,children:"error"in e&&(null==(t=e.error)?void 0:t.message)})})]})})]})}function G(){return c(C,{children:[p("p",{children:"The error appears to be related to authentication"}),p("p",{children:"Common causes include:"}),c("ul",{children:[p("li",{children:"Incorrect API key"}),p("li",{children:"Referer not allowed"}),p("li",{children:"Missing authentication scope"})]}),p("p",{children:"Check the browser developer tools for more information."})]})}const W="undefined"!=typeof window&&window.navigator.language||"en";function U(e){const t=e.defaultLocale||W||"en-US",[n,o]=m({type:"loading"});return f((()=>{(function(e){return B||(B=V(e),B.catch((()=>{B=null})),B)})({locale:t,apiKey:e.apiKey}).then((e=>o({type:"loaded",api:e})),(e=>o({type:"error",error:{type:e instanceof D?"authError":"loadError",message:e.message}})))}),[t,e.apiKey]),n}function Z(e){const t=U(e.config);switch(t.type){case"error":return p(_,{error:t.error,isAuthError:"authError"===t.error.type});case"loading":return p("div",{children:"Loading Google Maps API"});case"loaded":return e.children(t.api);default:return null}}const K=S.div(e||(e=s(["\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n"])));class F extends h.PureComponent{constructor(){super(...arguments),this.searchInputRef=h.createRef(),this.handleChange=()=>{this.autoComplete&&(this.props.onChange(this.autoComplete.getPlace()),this.searchInputRef.current&&(this.searchInputRef.current.value=""))}}componentDidMount(){const e=this.searchInputRef.current;if(!e)return;const{api:t,map:n}=this.props,{Circle:o,places:r,event:i}=t,a=new o({center:n.getCenter(),radius:100}).getBounds();this.autoComplete=new r.Autocomplete(e,{bounds:a,types:[]}),i.addListener(this.autoComplete,"place_changed",this.handleChange)}render(){return p(K,{children:p(b,{name:"place",ref:this.searchInputRef,placeholder:"Search for place or address",padding:4})})}}function N(e,t){const n="function"==typeof e.lat?e.lat():e.lat,o="function"==typeof e.lng?e.lng():e.lng,r="function"==typeof t.lat?t.lat():t.lat,i="function"==typeof t.lng?t.lng():t.lng;return n===r&&o===i}const J=S.div(t||(t=s(["\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n"])));class X extends u.PureComponent{constructor(){super(...arguments),this.state={map:void 0},this.mapRef=u.createRef(),this.mapEl=null,this.attachClickHandler=()=>{const e=this.state.map;if(!e)return;const{api:t,onClick:n}=this.props,{event:o}=t;this.clickHandler&&this.clickHandler.remove(),n&&(this.clickHandler=o.addListener(e,"click",n))},this.setMapElement=e=>{if(e&&e!==this.mapEl){const t=this.constructMap(e);this.setState({map:t},this.attachClickHandler)}this.mapEl=e}}componentDidMount(){this.attachClickHandler()}componentDidUpdate(e){const t=this.state.map;if(!t)return;const{onClick:n,location:o,bounds:r}=this.props;e.onClick!==n&&this.attachClickHandler(),N(e.location,o)||t.panTo(this.getCenter()),!r||e.bounds&&r.equals(e.bounds)||t.fitBounds(r)}componentWillUnmount(){this.clickHandler&&this.clickHandler.remove()}getCenter(){const{location:e,api:t}=this.props;return new t.LatLng(e.lat,e.lng)}constructMap(e){const{defaultZoom:t,api:n,mapTypeControl:o,controlSize:r,bounds:i,scrollWheel:a}=this.props,l=new n.Map(e,{zoom:t,center:this.getCenter(),scrollwheel:a,streetViewControl:!1,mapTypeControl:o,controlSize:r});return i&&l.fitBounds(i),l}render(){const{children:e}=this.props,{map:t}=this.state;return c(d,{children:[p(J,{ref:this.setMapElement}),e&&t?e(t):null]})}}X.defaultProps={defaultZoom:8,scrollWheel:!0};class q extends h.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{position:e,api:t,map:n,onMove:o,zIndex:r,opacity:i,label:a,markerRef:l,color:s}=this.props,{Marker:c}=t;let p;s&&(p={path:"M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z",fillOpacity:1,fillColor:s.background,strokeColor:s.border,strokeWeight:2,anchor:new t.Point(10,35),labelOrigin:new t.Point(10,11)}),this.marker=new c({draggable:Boolean(o),position:e,map:n,zIndex:r,opacity:i,label:a,icon:p}),l&&(l.current=this.marker),this.attachMoveHandler(),this.attachClickHandler()}componentDidUpdate(e){if(!this.marker)return;const{position:t,onMove:n,label:o,zIndex:r,opacity:i,map:a}=this.props;e.onMove!==n&&this.attachMoveHandler(),N(e.position,t)||this.marker.setPosition(t),e.label!==o&&this.marker.setLabel(o||null),e.zIndex!==r&&this.marker.setZIndex(r||null),e.opacity!==i&&this.marker.setOpacity(i||null),e.map!==a&&this.marker.setMap(a)}componentWillUnmount(){this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&this.marker.setMap(null)}attachMoveHandler(){const{api:e,onMove:t}=this.props;this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&t&&(this.eventHandlers.move=e.event.addListener(this.marker,"dragend",t))}attachClickHandler(){const{api:e,onClick:t}=this.props;this.eventHandlers.click&&this.eventHandlers.click.remove(),this.marker&&t&&(this.eventHandlers.click=e.event.addListener(this.marker,"click",t))}render(){return null}}const Q={lat:40.7058254,lng:-74.1180863};class Y extends u.PureComponent{constructor(){super(...arguments),this.mapRef=u.createRef(),this.handlePlaceChanged=e=>{var t;(null==(t=e.geometry)?void 0:t.location)&&this.setValue(e.geometry.location)},this.handleMarkerDragEnd=e=>{e.latLng&&this.setValue(e.latLng)},this.handleMapClick=e=>{e.latLng&&this.setValue(e.latLng)}}getCenter(){const{value:e={},defaultLocation:t={}}=this.props;return a(a(a({},Q),t),e)}setValue(e){this.props.onChange&&this.props.onChange(e)}render(){const{api:e,defaultZoom:t,value:n,onChange:o}=this.props;return p(X,{api:e,location:this.getCenter(),onClick:this.handleMapClick,defaultZoom:t,children:t=>c(d,{children:[p(F,{api:e,map:t,onChange:this.handlePlaceChanged}),n&&p(q,{api:e,map:t,position:n,onMove:o?this.handleMarkerDragEnd:void 0})]})})}}Y.defaultProps={defaultZoom:8,defaultLocation:{lng:10.74609,lat:59.91273}};const $=S.img(n||(n=s(["\n width: 100%;\n height: auto;\n vertical-align: top;\n"]))),ee=S.div(o||(o=s(["\n height: 40rem;\n width: 50rem;\n"])));let te;function ne(){return te}function oe(e){te=e}const re=(e,t)=>{const n="".concat(e.lat,",").concat(e.lng),o={key:t,center:n,markers:n,zoom:13,scale:2,size:"640x300"},r=Object.keys(o).reduce(((e,t)=>e.concat("".concat(t,"=").concat(encodeURIComponent(o[t])))),[]);return"https://maps.googleapis.com/maps/api/staticmap?".concat(r.join("&"))};class ie extends u.PureComponent{constructor(e){super(e),this._geopointInputId=g("GeopointInput"),this.setEditButton=e=>{this.editButton=e},this.handleToggleModal=()=>{this.setState((e=>({modalOpen:!e.modalOpen})))},this.handleCloseModal=()=>{this.setState({modalOpen:!1})},this.handleChange=e=>{const{schemaType:t,onChange:n}=this.props;n([I({_type:t.name}),H(e.lat(),["lat"]),H(e.lng(),["lng"])])},this.handleClear=()=>{const{onChange:e}=this.props;e(E())},this.state={modalOpen:!1}}focus(){this.editButton&&this.editButton.focus()}render(){const{value:e,readOnly:t,geoConfig:n,path:o,changed:r,focused:i}=this.props,{modalOpen:a}=this.state;return n&&n.apiKey?c(d,{children:[e&&p(R,{path:o,isChanged:r,hasFocus:!!i,children:p($,{src:re(e,n.apiKey),alt:"Map location"})}),!t&&p(y,{marginTop:4,children:c(w,{columns:2,gap:2,children:[p(M,{mode:"ghost",icon:e&&O,padding:3,ref:this.setEditButton,text:e?"Edit":"Set location",onClick:this.handleToggleModal}),e&&p(M,{tone:"critical",icon:x,padding:3,mode:"ghost",text:"Remove",onClick:this.handleClear})]})}),a&&p(P,{id:"".concat(this._geopointInputId,"_dialog"),onClose:this.handleCloseModal,header:"Place the marker on the map",width:1,children:p(ee,{children:p(Z,{config:ne(),children:o=>p(Y,{api:o,value:e||void 0,onChange:t?void 0:this.handleChange,defaultLocation:n.defaultLocation,defaultZoom:n.defaultZoom})})})})]}):c("div",{children:[c("p",{children:["The ",p("a",{href:"https://sanity.io/docs/schema-types/geopoint-type",children:"Geopoint type"})," needs a Google Maps API key with access to:"]}),c("ul",{children:[p("li",{children:"Google Maps JavaScript API"}),p("li",{children:"Google Places API Web Service"}),p("li",{children:"Google Static Maps API"})]}),p("p",{children:"Please enter the API key with access to these services in your googleMapsInput plugin config."})]})}}class ae extends h.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{from:e,to:t,api:n,map:o,zIndex:r,onClick:i,color:a,arrowRef:l}=this.props,s={path:n.SymbolPath.FORWARD_OPEN_ARROW};this.line=new n.Polyline({map:o,zIndex:r,path:[e,t],icons:[{icon:s,offset:"50%"}],strokeOpacity:.55,strokeColor:a?a.text:"black"}),i&&(this.eventHandlers.click=n.event.addListener(this.line,"click",i)),l&&(l.current=this.line)}componentDidUpdate(e){if(!this.line)return;const{from:t,to:n,map:o}=this.props;N(e.from,t)&&N(e.to,n)||this.line.setPath([t,n]),e.map!==o&&this.line.setMap(o)}componentWillUnmount(){this.line&&this.line.setMap(null),this.eventHandlers.click&&this.eventHandlers.click.remove()}render(){return null}}function le(e){let{diff:t,api:n,map:o,label:r}=e;const{fromValue:i,toValue:a}=t,l=t.isChanged?t.annotation:void 0,s=L(l?l.author:null)||void 0,u=h.useRef(),m=h.useRef();return c(d,{children:[i&&p(q,{api:n,map:o,position:i,zIndex:0,opacity:.55,markerRef:u,color:s}),i&&a&&p(ae,{api:n,map:o,from:i,to:a,zIndex:1,color:s}),a&&p(q,{api:n,map:o,position:a,zIndex:2,markerRef:m,label:r,color:s})]})}const se=S.div(r||(r=s(["\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n"]))),ce=e=>{let{diff:t,schemaType:n}=e;return p(se,{children:p(Z,{config:ne(),children:e=>p(pe,{api:e,diff:t,schemaType:n})})})};function pe(e){let{api:t,diff:n}=e;const o=(n.fromValue||[]).filter(de),r=(n.toValue||[]).filter(de);if(0===o.length&&0===r.length)return null;const i=function(e,t,n){const o=new n.LatLngBounds;return[...e||[],...t||[]].forEach((e=>o.extend(e))),o}(o,r,t);return p(X,{api:t,location:i.getCenter().toJSON(),mapTypeControl:!1,controlSize:20,bounds:i,children:e=>p(d,{children:n.items.map((n=>{let{toIndex:o,diff:r}=n;return function(e){return"unchanged"!==e.action&&"object"===e.type}(r)?p(le,{api:t,map:e,diff:r,label:"".concat(o)},o):null}))})})}function de(e){return"number"==typeof e.lat&&"number"==typeof e.lng}const he=e=>{let{diff:t,schemaType:n}=e;return p(se,{children:p(Z,{config:ne(),children:e=>p(ue,{api:e,diff:t,schemaType:n})})})};function ue(e){let{api:t,diff:n}=e;const{fromValue:o,toValue:r}=n,i=j(n,["lat"])||j(n,["lng"])||j(n,[]),a=function(e,t){const{fromValue:n,toValue:o}=e;if(n&&o)return me(n,o,t).getCenter().toJSON();if(n)return n;if(o)return o;throw new Error("Neither a from or a to value present")}(n,t),l=o&&r?me(o,r,t):void 0;return p(z,{annotations:i?[i]:[],description:fe(n),children:p("div",{children:p(X,{api:t,location:a,mapTypeControl:!1,controlSize:20,bounds:l,scrollWheel:!1,children:e=>p(le,{api:t,map:e,diff:n})})})})}function me(e,t,n){return(new n.LatLngBounds).extend(e).extend(t)}function fe(e){const{fromValue:t,toValue:n}=e;return t&&n?"Moved":t?"Removed":n?"Added":"Unchanged"}const ge=T((e=>(oe(e),{name:"google-maps-input",form:{components:{input(t){if(ve("geopoint",t.schemaType)){return p(ie,a(a({},t),{},{geoConfig:e}))}return t.renderDefault(t)}}}})));function ve(e,t){return(null==t?void 0:t.name)===e||!!(null==t?void 0:t.name)&&ve(e,null==t?void 0:t.type)}export{ce as GeopointArrayDiff,he as GeopointFieldDiff,ie as GeopointInput,ge as googleMapsInput};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/lib/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/loader/loadGoogleMapsApi.ts","../src/loader/LoadError.tsx","../src/loader/GoogleMapsLoadProxy.tsx","../src/map/SearchInput.styles.tsx","../src/map/SearchInput.tsx","../src/map/util.ts","../src/map/Map.styles.tsx","../src/map/Map.tsx","../src/map/Marker.tsx","../src/input/GeopointSelect.tsx","../src/input/GeopointInput.styles.tsx","../src/global-workaround.ts","../src/input/GeopointInput.tsx","../src/map/Arrow.tsx","../src/diff/GeopointMove.tsx","../src/diff/GeopointFieldDiff.styles.tsx","../src/diff/GeopointArrayDiff.tsx","../src/diff/GeopointFieldDiff.tsx","../src/plugin.tsx"],"sourcesContent":["import {Observable, BehaviorSubject} from 'rxjs'\nimport {GoogleMapsInputConfig} from '../index'\n\ndeclare global {\n interface Window {\n gm_authFailure: any\n ___sanity_googleMapsApiCallback: any\n }\n}\n\nconst callbackName = '___sanity_googleMapsApiCallback'\nconst authFailureCallbackName = 'gm_authFailure'\nconst locale = (typeof window !== 'undefined' && window.navigator.language) || 'en'\n\nexport interface LoadingState {\n loadState: 'loading'\n}\n\nexport interface LoadedState {\n loadState: 'loaded'\n api: typeof window.google.maps\n}\n\nexport interface LoadErrorState {\n loadState: 'loadError'\n error: Error\n}\n\nexport interface AuthErrorState {\n loadState: 'authError'\n}\n\nexport type GoogleLoadState = LoadingState | LoadedState | LoadErrorState | AuthErrorState\n\nlet subject: BehaviorSubject<GoogleLoadState>\n\nexport function loadGoogleMapsApi(config: GoogleMapsInputConfig): Observable<GoogleLoadState> {\n const selectedLocale = config.defaultLocale || locale || 'en-US'\n\n if (subject) {\n return subject\n }\n\n subject = new BehaviorSubject<GoogleLoadState>({loadState: 'loading'})\n\n window[authFailureCallbackName] = () => {\n delete window[authFailureCallbackName]\n subject.next({loadState: 'authError'})\n }\n\n window[callbackName] = () => {\n delete window[callbackName]\n subject.next({loadState: 'loaded', api: window.google.maps})\n }\n\n const script = document.createElement('script')\n script.onerror = (\n event: Event | string,\n source?: string,\n lineno?: number,\n colno?: number,\n error?: Error\n ) =>\n subject.next({\n loadState: 'loadError',\n error: coeerceError(event, error),\n } as LoadErrorState)\n\n script.src = `https://maps.googleapis.com/maps/api/js?key=${config.apiKey}&libraries=places&callback=${callbackName}&language=${selectedLocale}`\n document.getElementsByTagName('head')[0].appendChild(script)\n\n return subject\n}\n\nfunction coeerceError(event: Event | string, error?: Error): Error {\n if (error) {\n return error\n }\n\n if (typeof event === 'string') {\n return new Error(event)\n }\n\n return new Error(isErrorEvent(event) ? event.message : 'Failed to load Google Maps API')\n}\n\nfunction isErrorEvent(event: unknown): event is ErrorEvent {\n if (typeof event !== 'object' || event === null) {\n return false\n }\n\n if (!('message' in event)) {\n return false\n }\n\n return typeof (event as ErrorEvent).message === 'string'\n}\n","import * as React from 'react'\nimport {Card, Box, Text, Code} from '@sanity/ui'\n\ntype Props = {error: Error; isAuthError: false} | {isAuthError: true}\n\nexport function LoadError(props: Props) {\n return (\n <Card tone=\"critical\" radius={1}>\n <Box as=\"header\" paddingX={4} paddingTop={4} paddingBottom={1}>\n <Text as=\"h2\" weight=\"bold\">\n Google Maps failed to load\n </Text>\n </Box>\n\n <Box paddingX={4} paddingTop={4} paddingBottom={1}>\n {props.isAuthError ? (\n <AuthError />\n ) : (\n <>\n <Text as=\"h3\">Error details:</Text>\n <pre>\n <Code size={1}>{'error' in props && props.error?.message}</Code>\n </pre>\n </>\n )}\n </Box>\n </Card>\n )\n}\n\nfunction AuthError() {\n return (\n <Text>\n <p>The error appears to be related to authentication</p>\n <p>Common causes include:</p>\n <ul>\n <li>Incorrect API key</li>\n <li>Referer not allowed</li>\n <li>Missing authentication scope</li>\n </ul>\n <p>Check the browser developer tools for more information.</p>\n </Text>\n )\n}\n","import React from 'react'\nimport {Subscription} from 'rxjs'\nimport {loadGoogleMapsApi, GoogleLoadState} from './loadGoogleMapsApi'\nimport {LoadError} from './LoadError'\nimport {GoogleMapsInputConfig} from '../index'\n\ninterface LoadProps {\n children: (api: typeof window.google.maps) => React.ReactElement\n config: GoogleMapsInputConfig\n}\n\nexport class GoogleMapsLoadProxy extends React.Component<LoadProps, GoogleLoadState> {\n loadSubscription: Subscription | undefined\n\n constructor(props: LoadProps) {\n super(props)\n\n this.state = {loadState: 'loading'}\n\n let sync = true\n this.loadSubscription = loadGoogleMapsApi(props.config).subscribe((loadState) => {\n if (sync) {\n this.state = loadState\n } else {\n this.setState(loadState)\n }\n })\n sync = false\n }\n\n componentWillUnmount() {\n if (this.loadSubscription) {\n this.loadSubscription.unsubscribe()\n }\n }\n\n render() {\n switch (this.state.loadState) {\n case 'loadError':\n return <LoadError error={this.state.error} isAuthError={false} />\n case 'authError':\n return <LoadError isAuthError />\n case 'loading':\n return <div>Loading Google Maps API</div>\n case 'loaded':\n return this.props.children(this.state.api) || null\n default:\n return null\n }\n }\n}\n","import styled from 'styled-components'\n\nexport const WrapperContainer = styled.div`\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n`\n","import * as React from 'react'\nimport {TextInput} from '@sanity/ui'\nimport {WrapperContainer} from './SearchInput.styles'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onChange: (result: google.maps.places.PlaceResult) => void\n}\n\nexport class SearchInput extends React.PureComponent<Props> {\n searchInputRef = React.createRef<HTMLInputElement>()\n autoComplete: google.maps.places.Autocomplete | undefined\n\n handleChange = () => {\n if (!this.autoComplete) {\n return\n }\n\n this.props.onChange(this.autoComplete.getPlace())\n\n if (this.searchInputRef.current) {\n this.searchInputRef.current.value = ''\n }\n }\n\n componentDidMount() {\n const input = this.searchInputRef.current\n if (!input) {\n return\n }\n\n const {api, map} = this.props\n const {Circle, places, event} = api\n const searchBounds = new Circle({center: map.getCenter(), radius: 100}).getBounds()!\n this.autoComplete = new places.Autocomplete(input, {\n bounds: searchBounds,\n types: [], // return all kinds of places\n })\n\n event.addListener(this.autoComplete, 'place_changed', this.handleChange)\n }\n\n render() {\n return (\n <WrapperContainer>\n <TextInput\n name=\"place\"\n ref={this.searchInputRef}\n placeholder=\"Search for place or address\"\n padding={4}\n />\n </WrapperContainer>\n )\n }\n}\n","import {LatLng} from '../types'\n\nexport function latLngAreEqual(\n latLng1: LatLng | google.maps.LatLng,\n latLng2: LatLng | google.maps.LatLng\n): boolean {\n const lat1 = typeof latLng1.lat === 'function' ? latLng1.lat() : latLng1.lat\n const lng1 = typeof latLng1.lng === 'function' ? latLng1.lng() : latLng1.lng\n\n const lat2 = typeof latLng2.lat === 'function' ? latLng2.lat() : latLng2.lat\n const lng2 = typeof latLng2.lng === 'function' ? latLng2.lng() : latLng2.lng\n\n return lat1 === lat2 && lng1 === lng2\n}\n","import styled from 'styled-components'\n\nexport const MapContainer = styled.div`\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n`\n","import React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\nimport {MapContainer} from './Map.styles'\n\ninterface MapProps {\n api: typeof window.google.maps\n location: LatLng\n bounds?: google.maps.LatLngBounds\n defaultZoom?: number\n mapTypeControl?: boolean\n scrollWheel?: boolean\n controlSize?: number\n onClick?: (event: google.maps.MapMouseEvent) => void\n children?: (map: google.maps.Map) => React.ReactElement\n}\n\ninterface MapState {\n map: google.maps.Map | undefined\n}\n\nexport class GoogleMap extends React.PureComponent<MapProps, MapState> {\n static defaultProps = {\n defaultZoom: 8,\n scrollWheel: true,\n }\n\n state: MapState = {map: undefined}\n clickHandler: google.maps.MapsEventListener | undefined\n mapRef = React.createRef<HTMLDivElement>()\n mapEl: HTMLDivElement | null = null\n\n componentDidMount() {\n this.attachClickHandler()\n }\n\n attachClickHandler = () => {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {api, onClick} = this.props\n const {event} = api\n\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n\n if (onClick) {\n this.clickHandler = event.addListener(map, 'click', onClick)\n }\n }\n\n componentDidUpdate(prevProps: MapProps) {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {onClick, location, bounds} = this.props\n\n if (prevProps.onClick !== onClick) {\n this.attachClickHandler()\n }\n\n if (!latLngAreEqual(prevProps.location, location)) {\n map.panTo(this.getCenter())\n }\n\n if (bounds && (!prevProps.bounds || !bounds.equals(prevProps.bounds))) {\n map.fitBounds(bounds)\n }\n }\n\n componentWillUnmount() {\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n }\n\n getCenter(): google.maps.LatLng {\n const {location, api} = this.props\n return new api.LatLng(location.lat, location.lng)\n }\n\n constructMap(el: HTMLDivElement) {\n const {defaultZoom, api, mapTypeControl, controlSize, bounds, scrollWheel} = this.props\n\n const map = new api.Map(el, {\n zoom: defaultZoom,\n center: this.getCenter(),\n scrollwheel: scrollWheel,\n streetViewControl: false,\n mapTypeControl,\n controlSize,\n })\n\n if (bounds) {\n map.fitBounds(bounds)\n }\n\n return map\n }\n\n setMapElement = (element: HTMLDivElement | null) => {\n if (element && element !== this.mapEl) {\n const map = this.constructMap(element)\n this.setState({map}, this.attachClickHandler)\n }\n\n this.mapEl = element\n }\n\n render() {\n const {children} = this.props\n const {map} = this.state\n return (\n <>\n <MapContainer ref={this.setMapElement} />\n {children && map ? children(map) : null}\n </>\n )\n }\n}\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\nconst markerPath =\n 'M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onMove?: (event: google.maps.MapMouseEvent) => void\n onClick?: (event: google.maps.MapMouseEvent) => void\n position: LatLng | google.maps.LatLng\n zIndex?: number\n opacity?: number\n label?: string\n markerRef?: React.MutableRefObject<google.maps.Marker | undefined>\n color?: {background: string; border: string; text: string}\n}\n\nexport class Marker extends React.PureComponent<Props> {\n marker: google.maps.Marker | undefined\n\n eventHandlers: {\n move?: google.maps.MapsEventListener\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {position, api, map, onMove, zIndex, opacity, label, markerRef, color} = this.props\n const {Marker: GMarker} = api\n\n let icon: google.maps.Symbol | undefined\n if (color) {\n icon = {\n path: markerPath,\n fillOpacity: 1,\n fillColor: color.background,\n strokeColor: color.border,\n strokeWeight: 2,\n anchor: new api.Point(10, 35),\n labelOrigin: new api.Point(10, 11),\n }\n }\n\n this.marker = new GMarker({\n draggable: Boolean(onMove),\n position,\n map,\n zIndex,\n opacity,\n label,\n icon,\n })\n\n if (markerRef) {\n markerRef.current = this.marker\n }\n\n this.attachMoveHandler()\n this.attachClickHandler()\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.marker) {\n return\n }\n\n const {position, onMove, label, zIndex, opacity, map} = this.props\n\n if (prevProps.onMove !== onMove) {\n this.attachMoveHandler()\n }\n\n if (!latLngAreEqual(prevProps.position, position)) {\n this.marker.setPosition(position)\n }\n\n if (prevProps.label !== label) {\n this.marker.setLabel(label || null)\n }\n\n if (prevProps.zIndex !== zIndex) {\n this.marker.setZIndex(zIndex || null)\n }\n\n if (prevProps.opacity !== opacity) {\n this.marker.setOpacity(opacity || null)\n }\n\n if (prevProps.map !== map) {\n this.marker.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n\n if (this.marker) {\n this.marker.setMap(null)\n }\n }\n\n attachMoveHandler() {\n const {api, onMove} = this.props\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n if (this.marker && onMove) {\n this.eventHandlers.move = api.event.addListener(this.marker, 'dragend', onMove)\n }\n }\n\n attachClickHandler() {\n const {api, onClick} = this.props\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n if (this.marker && onClick) {\n this.eventHandlers.click = api.event.addListener(this.marker, 'click', onClick)\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import React from 'react'\nimport {SearchInput} from '../map/SearchInput'\nimport {GoogleMap} from '../map/Map'\nimport {Marker} from '../map/Marker'\nimport {LatLng, Geopoint} from '../types'\n\nconst fallbackLatLng: LatLng = {lat: 40.7058254, lng: -74.1180863}\n\ninterface SelectProps {\n api: typeof window.google.maps\n value?: Geopoint\n onChange?: (latLng: google.maps.LatLng) => void\n defaultLocation?: LatLng\n defaultZoom?: number\n}\n\nexport class GeopointSelect extends React.PureComponent<SelectProps> {\n static defaultProps = {\n defaultZoom: 8,\n defaultLocation: {lng: 10.74609, lat: 59.91273},\n }\n\n mapRef = React.createRef<HTMLDivElement>()\n\n getCenter() {\n const {value = {}, defaultLocation = {}} = this.props\n const point: LatLng = {...fallbackLatLng, ...defaultLocation, ...value}\n return point\n }\n\n handlePlaceChanged = (place: google.maps.places.PlaceResult) => {\n if (!place.geometry?.location) {\n return\n }\n\n this.setValue(place.geometry.location)\n }\n\n handleMarkerDragEnd = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n handleMapClick = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n setValue(geoPoint: google.maps.LatLng) {\n if (this.props.onChange) {\n this.props.onChange(geoPoint)\n }\n }\n\n render() {\n const {api, defaultZoom, value, onChange} = this.props\n return (\n <GoogleMap\n api={api}\n location={this.getCenter()}\n onClick={this.handleMapClick}\n defaultZoom={defaultZoom}\n >\n {(map) => (\n <>\n <SearchInput api={api} map={map} onChange={this.handlePlaceChanged} />\n {value && (\n <Marker\n api={api}\n map={map}\n position={value}\n onMove={onChange ? this.handleMarkerDragEnd : undefined}\n />\n )}\n </>\n )}\n </GoogleMap>\n )\n }\n}\n","import styled from 'styled-components'\n\nexport const PreviewImage = styled.img`\n width: 100%;\n height: auto;\n vertical-align: top;\n`\n\nexport const DialogInnerContainer = styled.div`\n height: 40rem;\n width: 50rem;\n`\n","import {GoogleMapsInputConfig} from './index'\n\nlet config: GoogleMapsInputConfig\n\nexport function getGeoConfig(): GoogleMapsInputConfig {\n return config as GoogleMapsInputConfig\n}\n\nexport function setGeoConfig(newConfig: GoogleMapsInputConfig): void {\n config = newConfig\n}\n","import React from 'react'\nimport {uniqueId} from 'lodash'\nimport {Box, Button, Dialog, Grid} from '@sanity/ui'\nimport {EditIcon, TrashIcon} from '@sanity/icons'\nimport {ObjectInputProps, set, setIfMissing, unset, ChangeIndicator} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {Geopoint, GeopointSchemaType, LatLng} from '../types'\nimport {GeopointSelect} from './GeopointSelect'\nimport {DialogInnerContainer, PreviewImage} from './GeopointInput.styles'\nimport {GoogleMapsInputConfig} from '../index'\nimport {getGeoConfig} from '../global-workaround'\n\nconst getStaticImageUrl = (value: LatLng, apiKey: string) => {\n const loc = `${value.lat},${value.lng}`\n const params = {\n key: apiKey,\n center: loc,\n markers: loc,\n zoom: 13,\n scale: 2,\n size: '640x300',\n } as const\n const qs = Object.keys(params).reduce((res, param) => {\n return res.concat(`${param}=${encodeURIComponent(params[param as keyof typeof params])}`)\n }, [] as string[])\n\n return `https://maps.googleapis.com/maps/api/staticmap?${qs.join('&')}`\n}\n\nexport type GeopointInputProps = ObjectInputProps<Geopoint, GeopointSchemaType> & {\n geoConfig: GoogleMapsInputConfig\n}\n\ntype Focusable = any\n\ninterface InputState {\n modalOpen: boolean\n}\n\nclass GeopointInput extends React.PureComponent<GeopointInputProps, InputState> {\n _geopointInputId = uniqueId('GeopointInput')\n\n editButton: Focusable | undefined\n\n constructor(props: GeopointInputProps) {\n super(props)\n\n this.state = {\n modalOpen: false,\n }\n }\n\n setEditButton = (el: Focusable) => {\n this.editButton = el\n }\n\n focus() {\n if (this.editButton) {\n this.editButton.focus()\n }\n }\n\n handleToggleModal = () => {\n this.setState((prevState) => ({modalOpen: !prevState.modalOpen}))\n }\n\n handleCloseModal = () => {\n this.setState({modalOpen: false})\n }\n\n handleChange = (latLng: google.maps.LatLng) => {\n const {schemaType, onChange} = this.props\n onChange([\n setIfMissing({\n _type: schemaType.name,\n }),\n set(latLng.lat(), ['lat']),\n set(latLng.lng(), ['lng']),\n ])\n }\n\n handleClear = () => {\n const {onChange} = this.props\n onChange(unset())\n }\n\n render() {\n const {value, readOnly, geoConfig: config, path, changed, focused} = this.props\n\n const {modalOpen} = this.state\n\n if (!config || !config.apiKey) {\n return (\n <div>\n <p>\n The <a href=\"https://sanity.io/docs/schema-types/geopoint-type\">Geopoint type</a> needs\n a Google Maps API key with access to:\n </p>\n <ul>\n <li>Google Maps JavaScript API</li>\n <li>Google Places API Web Service</li>\n <li>Google Static Maps API</li>\n </ul>\n <p>\n Please enter the API key with access to these services in your googleMapsInput plugin\n config.\n </p>\n </div>\n )\n }\n\n return (\n <>\n {value && (\n <ChangeIndicator path={path} isChanged={changed} hasFocus={!!focused}>\n <PreviewImage src={getStaticImageUrl(value, config.apiKey)} alt=\"Map location\" />\n </ChangeIndicator>\n )}\n\n {!readOnly && (\n <Box marginTop={4}>\n <Grid columns={2} gap={2}>\n <Button\n mode=\"ghost\"\n icon={value && EditIcon}\n padding={3}\n ref={this.setEditButton}\n text={value ? 'Edit' : 'Set location'}\n onClick={this.handleToggleModal}\n />\n\n {value && (\n <Button\n tone=\"critical\"\n icon={TrashIcon}\n padding={3}\n mode=\"ghost\"\n text={'Remove'}\n onClick={this.handleClear}\n />\n )}\n </Grid>\n </Box>\n )}\n\n {modalOpen && (\n <Dialog\n id={`${this._geopointInputId}_dialog`}\n onClose={this.handleCloseModal}\n header=\"Place the marker on the map\"\n width={1}\n >\n <DialogInnerContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => (\n <GeopointSelect\n api={api}\n value={value || undefined}\n onChange={readOnly ? undefined : this.handleChange}\n defaultLocation={config.defaultLocation}\n defaultZoom={config.defaultZoom}\n />\n )}\n </GoogleMapsLoadProxy>\n </DialogInnerContainer>\n </Dialog>\n )}\n </>\n )\n }\n}\n\nexport default GeopointInput\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n from: LatLng\n to: LatLng\n color?: {background: string; border: string; text: string}\n zIndex?: number\n arrowRef?: React.MutableRefObject<google.maps.Polyline | undefined>\n onClick?: (event: google.maps.MapMouseEvent) => void\n}\n\nexport class Arrow extends React.PureComponent<Props> {\n line: google.maps.Polyline | undefined\n\n eventHandlers: {\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {from, to, api, map, zIndex, onClick, color, arrowRef} = this.props\n const lineSymbol = {\n path: api.SymbolPath.FORWARD_OPEN_ARROW,\n }\n\n this.line = new api.Polyline({\n map,\n zIndex,\n path: [from, to],\n icons: [{icon: lineSymbol, offset: '50%'}],\n strokeOpacity: 0.55,\n strokeColor: color ? color.text : 'black',\n })\n\n if (onClick) {\n this.eventHandlers.click = api.event.addListener(this.line, 'click', onClick)\n }\n\n if (arrowRef) {\n arrowRef.current = this.line\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.line) {\n return\n }\n\n const {from, to, map} = this.props\n if (!latLngAreEqual(prevProps.from, from) || !latLngAreEqual(prevProps.to, to)) {\n this.line.setPath([from, to])\n }\n\n if (prevProps.map !== map) {\n this.line.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.line) {\n this.line.setMap(null)\n }\n\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import * as React from 'react'\nimport {useUserColor, ObjectDiff} from 'sanity'\nimport {Marker} from '../map/Marker'\nimport {Arrow} from '../map/Arrow'\nimport {Geopoint} from '../types'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n diff: ObjectDiff<Geopoint>\n label?: string\n}\n\nexport function GeopointMove({diff, api, map, label}: Props) {\n const {fromValue: from, toValue: to} = diff\n const annotation = diff.isChanged ? diff.annotation : undefined\n const userColor = useUserColor(annotation ? annotation.author : null) || undefined\n const fromRef = React.useRef<google.maps.Marker>()\n const toRef = React.useRef<google.maps.Marker>()\n\n return (\n <>\n {from && (\n <Marker\n api={api}\n map={map}\n position={from}\n zIndex={0}\n opacity={0.55}\n markerRef={fromRef}\n color={userColor}\n />\n )}\n {from && to && <Arrow api={api} map={map} from={from} to={to} zIndex={1} color={userColor} />}\n {to && (\n <Marker\n api={api}\n map={map}\n position={to}\n zIndex={2}\n markerRef={toRef}\n label={label}\n color={userColor}\n />\n )}\n </>\n )\n}\n","import styled from 'styled-components'\n\nexport const RootContainer = styled.div`\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n`\n","import * as React from 'react'\nimport {ArrayDiff, ObjectDiff, Diff, DiffProps as GenericDiffProps, DiffComponent} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ArrayDiff<Geopoint>>\n\nexport const GeopointArrayDiff: DiffComponent<ArrayDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof google.maps}) {\n const fromValue = (diff.fromValue || []).filter(hasCoordinates)\n const toValue = (diff.toValue || []).filter(hasCoordinates)\n if (fromValue.length === 0 && toValue.length === 0) {\n return null\n }\n\n const bounds = getBounds(fromValue, toValue, api)\n return (\n <GoogleMap\n api={api}\n location={bounds.getCenter().toJSON()}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n >\n {(map) => (\n <>\n {diff.items.map(({toIndex, diff: pointDiff}) => {\n if (!isChangeDiff(pointDiff)) {\n return null\n }\n\n return (\n <GeopointMove\n key={toIndex}\n api={api}\n map={map}\n diff={pointDiff}\n label={`${toIndex}`}\n />\n )\n })}\n </>\n )}\n </GoogleMap>\n )\n}\n\nfunction isChangeDiff(diff: Diff): diff is ObjectDiff<Geopoint> {\n return diff.action !== 'unchanged' && diff.type === 'object'\n}\n\nfunction hasCoordinates(point: Partial<Geopoint>): point is Geopoint {\n return typeof point.lat === 'number' && typeof point.lng === 'number'\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral[] | null | undefined,\n toValue: google.maps.LatLngLiteral[] | null | undefined,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n const bounds = new api.LatLngBounds()\n const points = [...(fromValue || []), ...(toValue || [])]\n points.forEach((point) => bounds.extend(point))\n return bounds\n}\n","import * as React from 'react'\nimport {\n DiffComponent,\n ObjectDiff,\n DiffProps as GenericDiffProps,\n DiffTooltip,\n getAnnotationAtPath,\n} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ObjectDiff<Geopoint>>\n\nexport const GeopointFieldDiff: DiffComponent<ObjectDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof window.google.maps}) {\n const {fromValue, toValue} = diff\n const annotation =\n getAnnotationAtPath(diff, ['lat']) ||\n getAnnotationAtPath(diff, ['lng']) ||\n getAnnotationAtPath(diff, [])\n\n const center = getCenter(diff, api)\n const bounds = fromValue && toValue ? getBounds(fromValue, toValue, api) : undefined\n\n return (\n <DiffTooltip annotations={annotation ? [annotation] : []} description={getAction(diff)}>\n <div>\n <GoogleMap\n api={api}\n location={center}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n scrollWheel={false}\n >\n {(map) => <GeopointMove api={api} map={map} diff={diff} />}\n </GoogleMap>\n </div>\n </DiffTooltip>\n )\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral,\n toValue: google.maps.LatLngLiteral,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n return new api.LatLngBounds().extend(fromValue).extend(toValue)\n}\n\nfunction getCenter(\n diff: DiffProps['diff'],\n api: typeof window.google.maps\n): google.maps.LatLngLiteral {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return getBounds(fromValue, toValue, api).getCenter().toJSON()\n }\n\n if (fromValue) {\n return fromValue\n }\n\n if (toValue) {\n return toValue\n }\n\n throw new Error('Neither a from or a to value present')\n}\n\nfunction getAction(diff: ObjectDiff<Geopoint>) {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return 'Moved'\n } else if (fromValue) {\n return 'Removed'\n } else if (toValue) {\n return 'Added'\n }\n\n return 'Unchanged'\n}\n","import React from 'react'\nimport {definePlugin, SchemaType} from 'sanity'\nimport GeopointInput, {GeopointInputProps} from './input/GeopointInput'\nimport {setGeoConfig} from './global-workaround'\nimport {GeopointSchemaType} from './types'\n\nexport interface GoogleMapsInputConfig {\n apiKey: string\n defaultZoom?: number\n defaultLocale?: string\n defaultLocation?: {\n lat: number\n lng: number\n }\n}\n\nexport const googleMapsInput = definePlugin<GoogleMapsInputConfig>((config) => {\n setGeoConfig(config)\n return {\n name: 'google-maps-input',\n form: {\n components: {\n input(props) {\n if (isGeopoint(props.schemaType)) {\n const castedProps = props as unknown as Omit<GeopointInputProps, 'geoConfig'>\n return <GeopointInput {...castedProps} geoConfig={config} />\n }\n return props.renderDefault(props)\n },\n },\n },\n }\n})\n\nfunction isGeopoint(schemaType: SchemaType): schemaType is GeopointSchemaType {\n return isType('geopoint', schemaType)\n}\n\nfunction isType(name: string, schema?: SchemaType): boolean {\n if (schema?.name === name) {\n return true\n // eslint-disable-next-line no-negated-condition\n } else if (!schema?.name) {\n return false\n }\n return isType(name, schema?.type)\n}\n"],"names":["callbackName","locale","window","navigator","language","subject","coeerceError","event","error","Error","message","isErrorEvent","LoadError","props","_a","jsxs","Card","tone","radius","children","jsx","Box","as","paddingX","paddingTop","paddingBottom","Text","weight","isAuthError","AuthError","Fragment","Code","size","GoogleMapsLoadProxy","React","Component","constructor","super","this","state","loadState","sync","loadSubscription","config","selectedLocale","defaultLocale","BehaviorSubject","next","api","google","maps","script","document","createElement","onerror","source","lineno","colno","src","concat","apiKey","getElementsByTagName","appendChild","loadGoogleMapsApi","subscribe","setState","componentWillUnmount","unsubscribe","render","WrapperContainer","styled","div","_templateObject","_taggedTemplateLiteral","SearchInput","PureComponent","arguments","searchInputRef","createRef","handleChange","autoComplete","onChange","getPlace","current","value","componentDidMount","input","map","Circle","places","searchBounds","center","getCenter","getBounds","Autocomplete","bounds","types","addListener","TextInput","name","ref","placeholder","padding","latLngAreEqual","latLng1","latLng2","lat1","lat","lng1","lng","lat2","lng2","MapContainer","_templateObject2","GoogleMap","mapRef","mapEl","attachClickHandler","onClick","clickHandler","remove","setMapElement","element","constructMap","componentDidUpdate","prevProps","location","panTo","equals","fitBounds","LatLng","el","defaultZoom","mapTypeControl","controlSize","scrollWheel","Map","zoom","scrollwheel","streetViewControl","defaultProps","Marker","eventHandlers","position","onMove","zIndex","opacity","label","markerRef","color","GMarker","icon","path","fillOpacity","fillColor","background","strokeColor","border","strokeWeight","anchor","Point","labelOrigin","marker","draggable","Boolean","attachMoveHandler","setPosition","setLabel","setZIndex","setOpacity","setMap","move","click","fallbackLatLng","GeopointSelect","handlePlaceChanged","place","geometry","setValue","handleMarkerDragEnd","latLng","handleMapClick","defaultLocation","geoPoint","PreviewImage","img","_templateObject3","DialogInnerContainer","_templateObject4","getGeoConfig","setGeoConfig","newConfig","getStaticImageUrl","loc","params","key","markers","scale","qs","Object","keys","reduce","res","param","encodeURIComponent","join","GeopointInput","_geopointInputId","uniqueId","setEditButton","editButton","handleToggleModal","prevState","modalOpen","handleCloseModal","schemaType","setIfMissing","_type","set","handleClear","unset","focus","readOnly","geoConfig","changed","focused","ChangeIndicator","isChanged","hasFocus","alt","marginTop","Grid","columns","gap","Button","mode","EditIcon","text","TrashIcon","Dialog","id","onClose","header","width","href","Arrow","from","to","arrowRef","lineSymbol","SymbolPath","FORWARD_OPEN_ARROW","line","Polyline","icons","offset","strokeOpacity","setPath","GeopointMove","_ref","diff","fromValue","toValue","annotation","userColor","useUserColor","author","fromRef","useRef","toRef","RootContainer","_templateObject5","GeopointArrayDiff","_ref2","GeopointDiff","_ref3","filter","hasCoordinates","length","LatLngBounds","forEach","point","extend","toJSON","items","_ref4","toIndex","pointDiff","action","type","isChangeDiff","GeopointFieldDiff","_ref5","_ref6","getAnnotationAtPath","DiffTooltip","annotations","description","getAction","googleMapsInput","definePlugin","form","components","isType","renderDefault","schema"],"mappings":"m1CAUA,MAAMA,EAAe,kCAEfC,EAA4B,oBAAXC,QAA0BA,OAAOC,UAAUC,UAAa,KAsB/E,IAAIC,EAwCJ,SAASC,EAAaC,EAAuBC,GAC3C,OAAIA,IAIiB,iBAAVD,EACF,IAAIE,MAAMF,GAGZ,IAAIE,MAGb,SAAsBF,GACpB,GAAqB,iBAAVA,GAAgC,OAAVA,EACxB,OAAA,EAGL,KAAE,YAAaA,GACV,OAAA,EAGF,MAAyC,iBAAjCA,EAAqBG,OACtC,CAbmBC,CAAaJ,GAASA,EAAMG,QAAU,kCACzD,CC/EO,SAASE,EAAUC,GAL1B,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AGF,WACT,CC9Ea,MAAAqC,GAAkBC,GAAqCjQ,IAClEmJ,GAAanJ,GACN,CACLwD,KAAM,oBACN0M,KAAM,CACJC,WAAY,CACVxN,MAAMzE,GACA,GAYLkS,GAAO,WAZSlS,EAAM0M,YAAa,CAEhC,OAAQnM,EAAA0L,UADYjM,GACM,CAAA,EAAA,CAAakN,UAAWpL,IACpD,CACO,OAAA9B,EAAMmS,cAAcnS,EAC7B,QAUR,SAASkS,GAAO5M,EAAc8M,GACxB,OAAA,MAAAA,OAAA,EAAAA,EAAQ9M,QAASA,MAGT,MAAA8M,OAAA,EAAAA,EAAQ9M,OAGb4M,GAAO5M,EAAM,MAAA8M,OAAA,EAAAA,EAAQhB,KAC9B"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/loader/loadGoogleMapsApi.ts","../src/loader/LoadError.tsx","../src/loader/GoogleMapsLoadProxy.tsx","../src/map/SearchInput.styles.tsx","../src/map/SearchInput.tsx","../src/map/util.ts","../src/map/Map.styles.tsx","../src/map/Map.tsx","../src/map/Marker.tsx","../src/input/GeopointSelect.tsx","../src/input/GeopointInput.styles.tsx","../src/global-workaround.ts","../src/input/GeopointInput.tsx","../src/map/Arrow.tsx","../src/diff/GeopointMove.tsx","../src/diff/GeopointFieldDiff.styles.tsx","../src/diff/GeopointArrayDiff.tsx","../src/diff/GeopointFieldDiff.tsx","../src/plugin.tsx"],"sourcesContent":["declare global {\n interface Window {\n gm_authFailure: any\n ___sanity_googleMapsApiCallback: any\n }\n}\n\nconst callbackName = '___sanity_googleMapsApiCallback'\nconst authFailureCallbackName = 'gm_authFailure'\n\nexport class AuthError extends Error {}\n\nfunction _loadGoogleMapsApi(config: {locale: string; apiKey: string}) {\n return new Promise<typeof window.google.maps>((resolve, reject) => {\n window[authFailureCallbackName] = () => {\n reject(new AuthError('Authentication error when loading Google Maps API.'))\n }\n\n window[callbackName] = () => {\n resolve(window.google.maps)\n }\n\n const script = document.createElement('script')\n script.onerror = (\n event: Event | string,\n source?: string,\n lineno?: number,\n colno?: number,\n error?: Error\n ) => reject(new Error(coeerceError(event, error)))\n\n script.src = `https://maps.googleapis.com/maps/api/js?key=${config.apiKey}&libraries=places&callback=${callbackName}&language=${config.locale}`\n document.getElementsByTagName('head')[0].appendChild(script)\n }).finally(() => {\n delete window[callbackName]\n delete window[authFailureCallbackName]\n })\n}\n\nlet memo: Promise<typeof window.google.maps> | null = null\nexport function loadGoogleMapsApi(config: {locale: string; apiKey: string}) {\n if (memo) {\n return memo\n }\n memo = _loadGoogleMapsApi(config)\n memo.catch(() => {\n memo = null\n })\n return memo\n}\nfunction coeerceError(event: Event | string, error?: Error): string {\n if (error) {\n return error.message\n }\n\n if (typeof event === 'string') {\n return event\n }\n\n return isErrorEvent(event) ? event.message : 'Failed to load Google Maps API'\n}\n\nfunction isErrorEvent(event: unknown): event is ErrorEvent {\n if (typeof event !== 'object' || event === null) {\n return false\n }\n\n if (!('message' in event)) {\n return false\n }\n\n return typeof (event as ErrorEvent).message === 'string'\n}\n","import * as React from 'react'\nimport {Card, Box, Text, Code} from '@sanity/ui'\n\ntype Props = {error: {message?: string}; isAuthError: false} | {isAuthError: true}\n\nexport function LoadError(props: Props) {\n return (\n <Card tone=\"critical\" radius={1}>\n <Box as=\"header\" paddingX={4} paddingTop={4} paddingBottom={1}>\n <Text as=\"h2\" weight=\"bold\">\n Google Maps failed to load\n </Text>\n </Box>\n\n <Box paddingX={4} paddingTop={4} paddingBottom={1}>\n {props.isAuthError ? (\n <AuthError />\n ) : (\n <>\n <Text as=\"h3\">Error details:</Text>\n <pre>\n <Code size={1}>{'error' in props && props.error?.message}</Code>\n </pre>\n </>\n )}\n </Box>\n </Card>\n )\n}\n\nfunction AuthError() {\n return (\n <Text>\n <p>The error appears to be related to authentication</p>\n <p>Common causes include:</p>\n <ul>\n <li>Incorrect API key</li>\n <li>Referer not allowed</li>\n <li>Missing authentication scope</li>\n </ul>\n <p>Check the browser developer tools for more information.</p>\n </Text>\n )\n}\n","import React, {useEffect, useState} from 'react'\nimport {AuthError, loadGoogleMapsApi} from './loadGoogleMapsApi'\nimport {LoadError as LoadErrorView} from './LoadError'\nimport {GoogleMapsInputConfig} from '../index'\n\ninterface LoadProps {\n children: (api: typeof window.google.maps) => React.ReactElement\n config: GoogleMapsInputConfig\n}\n\nconst browserLocale = (typeof window !== 'undefined' && window.navigator.language) || 'en'\n\ntype LoadState =\n | {\n type: 'loading'\n }\n | {\n type: 'loaded'\n api: typeof window.google.maps\n }\n | {\n type: 'error'\n error: {type: 'loadError' | 'authError'; message: string}\n }\n\nfunction useLoadGoogleMapsApi(config: {defaultLocale?: string; apiKey: string}): LoadState {\n const locale = config.defaultLocale || browserLocale || 'en-US'\n\n const [state, setState] = useState<LoadState>({type: 'loading'})\n\n useEffect(() => {\n loadGoogleMapsApi({locale, apiKey: config.apiKey}).then(\n (api) => setState({type: 'loaded', api}),\n (err) =>\n setState({\n type: 'error',\n error: {type: err instanceof AuthError ? 'authError' : 'loadError', message: err.message},\n })\n )\n }, [locale, config.apiKey])\n return state\n}\n\nexport function GoogleMapsLoadProxy(props: LoadProps) {\n const loadState = useLoadGoogleMapsApi(props.config)\n switch (loadState.type) {\n case 'error':\n return (\n <LoadErrorView error={loadState.error} isAuthError={loadState.error.type === 'authError'} />\n )\n case 'loading':\n return <div>Loading Google Maps API</div>\n case 'loaded':\n return props.children(loadState.api)\n default:\n return null\n }\n}\n","import styled from 'styled-components'\n\nexport const WrapperContainer = styled.div`\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n`\n","import * as React from 'react'\nimport {TextInput} from '@sanity/ui'\nimport {WrapperContainer} from './SearchInput.styles'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onChange: (result: google.maps.places.PlaceResult) => void\n}\n\nexport class SearchInput extends React.PureComponent<Props> {\n searchInputRef = React.createRef<HTMLInputElement>()\n autoComplete: google.maps.places.Autocomplete | undefined\n\n handleChange = () => {\n if (!this.autoComplete) {\n return\n }\n\n this.props.onChange(this.autoComplete.getPlace())\n\n if (this.searchInputRef.current) {\n this.searchInputRef.current.value = ''\n }\n }\n\n componentDidMount() {\n const input = this.searchInputRef.current\n if (!input) {\n return\n }\n\n const {api, map} = this.props\n const {Circle, places, event} = api\n const searchBounds = new Circle({center: map.getCenter(), radius: 100}).getBounds()!\n this.autoComplete = new places.Autocomplete(input, {\n bounds: searchBounds,\n types: [], // return all kinds of places\n })\n\n event.addListener(this.autoComplete, 'place_changed', this.handleChange)\n }\n\n render() {\n return (\n <WrapperContainer>\n <TextInput\n name=\"place\"\n ref={this.searchInputRef}\n placeholder=\"Search for place or address\"\n padding={4}\n />\n </WrapperContainer>\n )\n }\n}\n","import {LatLng} from '../types'\n\nexport function latLngAreEqual(\n latLng1: LatLng | google.maps.LatLng,\n latLng2: LatLng | google.maps.LatLng\n): boolean {\n const lat1 = typeof latLng1.lat === 'function' ? latLng1.lat() : latLng1.lat\n const lng1 = typeof latLng1.lng === 'function' ? latLng1.lng() : latLng1.lng\n\n const lat2 = typeof latLng2.lat === 'function' ? latLng2.lat() : latLng2.lat\n const lng2 = typeof latLng2.lng === 'function' ? latLng2.lng() : latLng2.lng\n\n return lat1 === lat2 && lng1 === lng2\n}\n","import styled from 'styled-components'\n\nexport const MapContainer = styled.div`\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n`\n","import React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\nimport {MapContainer} from './Map.styles'\n\ninterface MapProps {\n api: typeof window.google.maps\n location: LatLng\n bounds?: google.maps.LatLngBounds\n defaultZoom?: number\n mapTypeControl?: boolean\n scrollWheel?: boolean\n controlSize?: number\n onClick?: (event: google.maps.MapMouseEvent) => void\n children?: (map: google.maps.Map) => React.ReactElement\n}\n\ninterface MapState {\n map: google.maps.Map | undefined\n}\n\nexport class GoogleMap extends React.PureComponent<MapProps, MapState> {\n static defaultProps = {\n defaultZoom: 8,\n scrollWheel: true,\n }\n\n state: MapState = {map: undefined}\n clickHandler: google.maps.MapsEventListener | undefined\n mapRef = React.createRef<HTMLDivElement>()\n mapEl: HTMLDivElement | null = null\n\n componentDidMount() {\n this.attachClickHandler()\n }\n\n attachClickHandler = () => {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {api, onClick} = this.props\n const {event} = api\n\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n\n if (onClick) {\n this.clickHandler = event.addListener(map, 'click', onClick)\n }\n }\n\n componentDidUpdate(prevProps: MapProps) {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {onClick, location, bounds} = this.props\n\n if (prevProps.onClick !== onClick) {\n this.attachClickHandler()\n }\n\n if (!latLngAreEqual(prevProps.location, location)) {\n map.panTo(this.getCenter())\n }\n\n if (bounds && (!prevProps.bounds || !bounds.equals(prevProps.bounds))) {\n map.fitBounds(bounds)\n }\n }\n\n componentWillUnmount() {\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n }\n\n getCenter(): google.maps.LatLng {\n const {location, api} = this.props\n return new api.LatLng(location.lat, location.lng)\n }\n\n constructMap(el: HTMLDivElement) {\n const {defaultZoom, api, mapTypeControl, controlSize, bounds, scrollWheel} = this.props\n\n const map = new api.Map(el, {\n zoom: defaultZoom,\n center: this.getCenter(),\n scrollwheel: scrollWheel,\n streetViewControl: false,\n mapTypeControl,\n controlSize,\n })\n\n if (bounds) {\n map.fitBounds(bounds)\n }\n\n return map\n }\n\n setMapElement = (element: HTMLDivElement | null) => {\n if (element && element !== this.mapEl) {\n const map = this.constructMap(element)\n this.setState({map}, this.attachClickHandler)\n }\n\n this.mapEl = element\n }\n\n render() {\n const {children} = this.props\n const {map} = this.state\n return (\n <>\n <MapContainer ref={this.setMapElement} />\n {children && map ? children(map) : null}\n </>\n )\n }\n}\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\nconst markerPath =\n 'M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onMove?: (event: google.maps.MapMouseEvent) => void\n onClick?: (event: google.maps.MapMouseEvent) => void\n position: LatLng | google.maps.LatLng\n zIndex?: number\n opacity?: number\n label?: string\n markerRef?: React.MutableRefObject<google.maps.Marker | undefined>\n color?: {background: string; border: string; text: string}\n}\n\nexport class Marker extends React.PureComponent<Props> {\n marker: google.maps.Marker | undefined\n\n eventHandlers: {\n move?: google.maps.MapsEventListener\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {position, api, map, onMove, zIndex, opacity, label, markerRef, color} = this.props\n const {Marker: GMarker} = api\n\n let icon: google.maps.Symbol | undefined\n if (color) {\n icon = {\n path: markerPath,\n fillOpacity: 1,\n fillColor: color.background,\n strokeColor: color.border,\n strokeWeight: 2,\n anchor: new api.Point(10, 35),\n labelOrigin: new api.Point(10, 11),\n }\n }\n\n this.marker = new GMarker({\n draggable: Boolean(onMove),\n position,\n map,\n zIndex,\n opacity,\n label,\n icon,\n })\n\n if (markerRef) {\n markerRef.current = this.marker\n }\n\n this.attachMoveHandler()\n this.attachClickHandler()\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.marker) {\n return\n }\n\n const {position, onMove, label, zIndex, opacity, map} = this.props\n\n if (prevProps.onMove !== onMove) {\n this.attachMoveHandler()\n }\n\n if (!latLngAreEqual(prevProps.position, position)) {\n this.marker.setPosition(position)\n }\n\n if (prevProps.label !== label) {\n this.marker.setLabel(label || null)\n }\n\n if (prevProps.zIndex !== zIndex) {\n this.marker.setZIndex(zIndex || null)\n }\n\n if (prevProps.opacity !== opacity) {\n this.marker.setOpacity(opacity || null)\n }\n\n if (prevProps.map !== map) {\n this.marker.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n\n if (this.marker) {\n this.marker.setMap(null)\n }\n }\n\n attachMoveHandler() {\n const {api, onMove} = this.props\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n if (this.marker && onMove) {\n this.eventHandlers.move = api.event.addListener(this.marker, 'dragend', onMove)\n }\n }\n\n attachClickHandler() {\n const {api, onClick} = this.props\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n if (this.marker && onClick) {\n this.eventHandlers.click = api.event.addListener(this.marker, 'click', onClick)\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import React from 'react'\nimport {SearchInput} from '../map/SearchInput'\nimport {GoogleMap} from '../map/Map'\nimport {Marker} from '../map/Marker'\nimport {LatLng, Geopoint} from '../types'\n\nconst fallbackLatLng: LatLng = {lat: 40.7058254, lng: -74.1180863}\n\ninterface SelectProps {\n api: typeof window.google.maps\n value?: Geopoint\n onChange?: (latLng: google.maps.LatLng) => void\n defaultLocation?: LatLng\n defaultZoom?: number\n}\n\nexport class GeopointSelect extends React.PureComponent<SelectProps> {\n static defaultProps = {\n defaultZoom: 8,\n defaultLocation: {lng: 10.74609, lat: 59.91273},\n }\n\n mapRef = React.createRef<HTMLDivElement>()\n\n getCenter() {\n const {value = {}, defaultLocation = {}} = this.props\n const point: LatLng = {...fallbackLatLng, ...defaultLocation, ...value}\n return point\n }\n\n handlePlaceChanged = (place: google.maps.places.PlaceResult) => {\n if (!place.geometry?.location) {\n return\n }\n\n this.setValue(place.geometry.location)\n }\n\n handleMarkerDragEnd = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n handleMapClick = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n setValue(geoPoint: google.maps.LatLng) {\n if (this.props.onChange) {\n this.props.onChange(geoPoint)\n }\n }\n\n render() {\n const {api, defaultZoom, value, onChange} = this.props\n return (\n <GoogleMap\n api={api}\n location={this.getCenter()}\n onClick={this.handleMapClick}\n defaultZoom={defaultZoom}\n >\n {(map) => (\n <>\n <SearchInput api={api} map={map} onChange={this.handlePlaceChanged} />\n {value && (\n <Marker\n api={api}\n map={map}\n position={value}\n onMove={onChange ? this.handleMarkerDragEnd : undefined}\n />\n )}\n </>\n )}\n </GoogleMap>\n )\n }\n}\n","import styled from 'styled-components'\n\nexport const PreviewImage = styled.img`\n width: 100%;\n height: auto;\n vertical-align: top;\n`\n\nexport const DialogInnerContainer = styled.div`\n height: 40rem;\n width: 50rem;\n`\n","import {GoogleMapsInputConfig} from './index'\n\nlet config: GoogleMapsInputConfig\n\nexport function getGeoConfig(): GoogleMapsInputConfig {\n return config as GoogleMapsInputConfig\n}\n\nexport function setGeoConfig(newConfig: GoogleMapsInputConfig): void {\n config = newConfig\n}\n","import React from 'react'\nimport {uniqueId} from 'lodash'\nimport {Box, Button, Dialog, Grid} from '@sanity/ui'\nimport {EditIcon, TrashIcon} from '@sanity/icons'\nimport {ObjectInputProps, set, setIfMissing, unset, ChangeIndicator} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {Geopoint, GeopointSchemaType, LatLng} from '../types'\nimport {GeopointSelect} from './GeopointSelect'\nimport {DialogInnerContainer, PreviewImage} from './GeopointInput.styles'\nimport {GoogleMapsInputConfig} from '../index'\nimport {getGeoConfig} from '../global-workaround'\n\nconst getStaticImageUrl = (value: LatLng, apiKey: string) => {\n const loc = `${value.lat},${value.lng}`\n const params = {\n key: apiKey,\n center: loc,\n markers: loc,\n zoom: 13,\n scale: 2,\n size: '640x300',\n } as const\n const qs = Object.keys(params).reduce((res, param) => {\n return res.concat(`${param}=${encodeURIComponent(params[param as keyof typeof params])}`)\n }, [] as string[])\n\n return `https://maps.googleapis.com/maps/api/staticmap?${qs.join('&')}`\n}\n\nexport type GeopointInputProps = ObjectInputProps<Geopoint, GeopointSchemaType> & {\n geoConfig: GoogleMapsInputConfig\n}\n\ntype Focusable = any\n\ninterface InputState {\n modalOpen: boolean\n}\n\nclass GeopointInput extends React.PureComponent<GeopointInputProps, InputState> {\n _geopointInputId = uniqueId('GeopointInput')\n\n editButton: Focusable | undefined\n\n constructor(props: GeopointInputProps) {\n super(props)\n\n this.state = {\n modalOpen: false,\n }\n }\n\n setEditButton = (el: Focusable) => {\n this.editButton = el\n }\n\n focus() {\n if (this.editButton) {\n this.editButton.focus()\n }\n }\n\n handleToggleModal = () => {\n this.setState((prevState) => ({modalOpen: !prevState.modalOpen}))\n }\n\n handleCloseModal = () => {\n this.setState({modalOpen: false})\n }\n\n handleChange = (latLng: google.maps.LatLng) => {\n const {schemaType, onChange} = this.props\n onChange([\n setIfMissing({\n _type: schemaType.name,\n }),\n set(latLng.lat(), ['lat']),\n set(latLng.lng(), ['lng']),\n ])\n }\n\n handleClear = () => {\n const {onChange} = this.props\n onChange(unset())\n }\n\n render() {\n const {value, readOnly, geoConfig: config, path, changed, focused} = this.props\n\n const {modalOpen} = this.state\n\n if (!config || !config.apiKey) {\n return (\n <div>\n <p>\n The <a href=\"https://sanity.io/docs/schema-types/geopoint-type\">Geopoint type</a> needs\n a Google Maps API key with access to:\n </p>\n <ul>\n <li>Google Maps JavaScript API</li>\n <li>Google Places API Web Service</li>\n <li>Google Static Maps API</li>\n </ul>\n <p>\n Please enter the API key with access to these services in your googleMapsInput plugin\n config.\n </p>\n </div>\n )\n }\n\n return (\n <>\n {value && (\n <ChangeIndicator path={path} isChanged={changed} hasFocus={!!focused}>\n <PreviewImage src={getStaticImageUrl(value, config.apiKey)} alt=\"Map location\" />\n </ChangeIndicator>\n )}\n\n {!readOnly && (\n <Box marginTop={4}>\n <Grid columns={2} gap={2}>\n <Button\n mode=\"ghost\"\n icon={value && EditIcon}\n padding={3}\n ref={this.setEditButton}\n text={value ? 'Edit' : 'Set location'}\n onClick={this.handleToggleModal}\n />\n\n {value && (\n <Button\n tone=\"critical\"\n icon={TrashIcon}\n padding={3}\n mode=\"ghost\"\n text={'Remove'}\n onClick={this.handleClear}\n />\n )}\n </Grid>\n </Box>\n )}\n\n {modalOpen && (\n <Dialog\n id={`${this._geopointInputId}_dialog`}\n onClose={this.handleCloseModal}\n header=\"Place the marker on the map\"\n width={1}\n >\n <DialogInnerContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => (\n <GeopointSelect\n api={api}\n value={value || undefined}\n onChange={readOnly ? undefined : this.handleChange}\n defaultLocation={config.defaultLocation}\n defaultZoom={config.defaultZoom}\n />\n )}\n </GoogleMapsLoadProxy>\n </DialogInnerContainer>\n </Dialog>\n )}\n </>\n )\n }\n}\n\nexport default GeopointInput\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n from: LatLng\n to: LatLng\n color?: {background: string; border: string; text: string}\n zIndex?: number\n arrowRef?: React.MutableRefObject<google.maps.Polyline | undefined>\n onClick?: (event: google.maps.MapMouseEvent) => void\n}\n\nexport class Arrow extends React.PureComponent<Props> {\n line: google.maps.Polyline | undefined\n\n eventHandlers: {\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {from, to, api, map, zIndex, onClick, color, arrowRef} = this.props\n const lineSymbol = {\n path: api.SymbolPath.FORWARD_OPEN_ARROW,\n }\n\n this.line = new api.Polyline({\n map,\n zIndex,\n path: [from, to],\n icons: [{icon: lineSymbol, offset: '50%'}],\n strokeOpacity: 0.55,\n strokeColor: color ? color.text : 'black',\n })\n\n if (onClick) {\n this.eventHandlers.click = api.event.addListener(this.line, 'click', onClick)\n }\n\n if (arrowRef) {\n arrowRef.current = this.line\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.line) {\n return\n }\n\n const {from, to, map} = this.props\n if (!latLngAreEqual(prevProps.from, from) || !latLngAreEqual(prevProps.to, to)) {\n this.line.setPath([from, to])\n }\n\n if (prevProps.map !== map) {\n this.line.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.line) {\n this.line.setMap(null)\n }\n\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import * as React from 'react'\nimport {useUserColor, ObjectDiff} from 'sanity'\nimport {Marker} from '../map/Marker'\nimport {Arrow} from '../map/Arrow'\nimport {Geopoint} from '../types'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n diff: ObjectDiff<Geopoint>\n label?: string\n}\n\nexport function GeopointMove({diff, api, map, label}: Props) {\n const {fromValue: from, toValue: to} = diff\n const annotation = diff.isChanged ? diff.annotation : undefined\n const userColor = useUserColor(annotation ? annotation.author : null) || undefined\n const fromRef = React.useRef<google.maps.Marker>()\n const toRef = React.useRef<google.maps.Marker>()\n\n return (\n <>\n {from && (\n <Marker\n api={api}\n map={map}\n position={from}\n zIndex={0}\n opacity={0.55}\n markerRef={fromRef}\n color={userColor}\n />\n )}\n {from && to && <Arrow api={api} map={map} from={from} to={to} zIndex={1} color={userColor} />}\n {to && (\n <Marker\n api={api}\n map={map}\n position={to}\n zIndex={2}\n markerRef={toRef}\n label={label}\n color={userColor}\n />\n )}\n </>\n )\n}\n","import styled from 'styled-components'\n\nexport const RootContainer = styled.div`\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n`\n","import * as React from 'react'\nimport {ArrayDiff, ObjectDiff, Diff, DiffProps as GenericDiffProps, DiffComponent} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ArrayDiff<Geopoint>>\n\nexport const GeopointArrayDiff: DiffComponent<ArrayDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof google.maps}) {\n const fromValue = (diff.fromValue || []).filter(hasCoordinates)\n const toValue = (diff.toValue || []).filter(hasCoordinates)\n if (fromValue.length === 0 && toValue.length === 0) {\n return null\n }\n\n const bounds = getBounds(fromValue, toValue, api)\n return (\n <GoogleMap\n api={api}\n location={bounds.getCenter().toJSON()}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n >\n {(map) => (\n <>\n {diff.items.map(({toIndex, diff: pointDiff}) => {\n if (!isChangeDiff(pointDiff)) {\n return null\n }\n\n return (\n <GeopointMove\n key={toIndex}\n api={api}\n map={map}\n diff={pointDiff}\n label={`${toIndex}`}\n />\n )\n })}\n </>\n )}\n </GoogleMap>\n )\n}\n\nfunction isChangeDiff(diff: Diff): diff is ObjectDiff<Geopoint> {\n return diff.action !== 'unchanged' && diff.type === 'object'\n}\n\nfunction hasCoordinates(point: Partial<Geopoint>): point is Geopoint {\n return typeof point.lat === 'number' && typeof point.lng === 'number'\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral[] | null | undefined,\n toValue: google.maps.LatLngLiteral[] | null | undefined,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n const bounds = new api.LatLngBounds()\n const points = [...(fromValue || []), ...(toValue || [])]\n points.forEach((point) => bounds.extend(point))\n return bounds\n}\n","import * as React from 'react'\nimport {\n DiffComponent,\n ObjectDiff,\n DiffProps as GenericDiffProps,\n DiffTooltip,\n getAnnotationAtPath,\n} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ObjectDiff<Geopoint>>\n\nexport const GeopointFieldDiff: DiffComponent<ObjectDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof window.google.maps}) {\n const {fromValue, toValue} = diff\n const annotation =\n getAnnotationAtPath(diff, ['lat']) ||\n getAnnotationAtPath(diff, ['lng']) ||\n getAnnotationAtPath(diff, [])\n\n const center = getCenter(diff, api)\n const bounds = fromValue && toValue ? getBounds(fromValue, toValue, api) : undefined\n\n return (\n <DiffTooltip annotations={annotation ? [annotation] : []} description={getAction(diff)}>\n <div>\n <GoogleMap\n api={api}\n location={center}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n scrollWheel={false}\n >\n {(map) => <GeopointMove api={api} map={map} diff={diff} />}\n </GoogleMap>\n </div>\n </DiffTooltip>\n )\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral,\n toValue: google.maps.LatLngLiteral,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n return new api.LatLngBounds().extend(fromValue).extend(toValue)\n}\n\nfunction getCenter(\n diff: DiffProps['diff'],\n api: typeof window.google.maps\n): google.maps.LatLngLiteral {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return getBounds(fromValue, toValue, api).getCenter().toJSON()\n }\n\n if (fromValue) {\n return fromValue\n }\n\n if (toValue) {\n return toValue\n }\n\n throw new Error('Neither a from or a to value present')\n}\n\nfunction getAction(diff: ObjectDiff<Geopoint>) {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return 'Moved'\n } else if (fromValue) {\n return 'Removed'\n } else if (toValue) {\n return 'Added'\n }\n\n return 'Unchanged'\n}\n","import React from 'react'\nimport {definePlugin, SchemaType} from 'sanity'\nimport GeopointInput, {GeopointInputProps} from './input/GeopointInput'\nimport {setGeoConfig} from './global-workaround'\nimport {GeopointSchemaType} from './types'\n\nexport interface GoogleMapsInputConfig {\n apiKey: string\n defaultZoom?: number\n defaultLocale?: string\n defaultLocation?: {\n lat: number\n lng: number\n }\n}\n\nexport const googleMapsInput = definePlugin<GoogleMapsInputConfig>((config) => {\n setGeoConfig(config)\n return {\n name: 'google-maps-input',\n form: {\n components: {\n input(props) {\n if (isGeopoint(props.schemaType)) {\n const castedProps = props as unknown as Omit<GeopointInputProps, 'geoConfig'>\n return <GeopointInput {...castedProps} geoConfig={config} />\n }\n return props.renderDefault(props)\n },\n },\n },\n }\n})\n\nfunction isGeopoint(schemaType: SchemaType): schemaType is GeopointSchemaType {\n return isType('geopoint', schemaType)\n}\n\nfunction isType(name: string, schema?: SchemaType): boolean {\n if (schema?.name === name) {\n return true\n // eslint-disable-next-line no-negated-condition\n } else if (!schema?.name) {\n return false\n }\n return isType(name, schema?.type)\n}\n"],"names":["callbackName","AuthError","Error","_loadGoogleMapsApi","config","Promise","resolve","reject","window","google","maps","script","document","createElement","onerror","event","source","lineno","colno","error","message","isErrorEvent","coeerceError","src","apiKey","locale","getElementsByTagName","appendChild","finally","memo","LoadError","props","_a","jsxs","Card","tone","radius","children","jsx","Box","as","paddingX","paddingTop","paddingBottom","Text","weight","isAuthError","Fragment","Code","size","browserLocale","navigator","language","useLoadGoogleMapsApi","defaultLocale","state","setState","useState","type","useEffect","catch","loadGoogleMapsApi","then","api","err","GoogleMapsLoadProxy","loadState","LoadErrorView","WrapperContainer","styled","div","_templateObject","_taggedTemplateLiteral","SearchInput","React","PureComponent","constructor","super","arguments","this","searchInputRef","createRef","handleChange","autoComplete","onChange","getPlace","current","value","componentDidMount","input","map","Circle","places","searchBounds","center","getCenter","getBounds","Autocomplete","bounds","types","addListener","render","TextInput","name","ref","placeholder","padding","latLngAreEqual","latLng1","latLng2","lat1","lat","lng1","lng","lat2","lng2","MapContainer","_templateObject2","GoogleMap","mapRef","mapEl","attachClickHandler","onClick","clickHandler","remove","setMapElement","element","constructMap","componentDidUpdate","prevProps","location","panTo","equals","fitBounds","componentWillUnmount","LatLng","el","defaultZoom","mapTypeControl","controlSize","scrollWheel","Map","zoom","scrollwheel","streetViewControl","defaultProps","Marker","eventHandlers","position","onMove","zIndex","opacity","label","markerRef","color","GMarker","icon","path","fillOpacity","fillColor","background","strokeColor","border","strokeWeight","anchor","Point","labelOrigin","marker","draggable","Boolean","attachMoveHandler","setPosition","setLabel","setZIndex","setOpacity","setMap","move","click","fallbackLatLng","GeopointSelect","handlePlaceChanged","place","geometry","setValue","handleMarkerDragEnd","latLng","handleMapClick","defaultLocation","geoPoint","PreviewImage","img","_templateObject3","DialogInnerContainer","_templateObject4","getGeoConfig","setGeoConfig","newConfig","getStaticImageUrl","loc","params","key","markers","scale","qs","Object","keys","reduce","res","param","concat","encodeURIComponent","join","GeopointInput","_geopointInputId","uniqueId","setEditButton","editButton","handleToggleModal","prevState","modalOpen","handleCloseModal","schemaType","setIfMissing","_type","set","handleClear","unset","focus","readOnly","geoConfig","changed","focused","ChangeIndicator","isChanged","hasFocus","alt","marginTop","Grid","columns","gap","Button","mode","EditIcon","text","TrashIcon","Dialog","id","onClose","header","width","href","Arrow","from","to","arrowRef","lineSymbol","SymbolPath","FORWARD_OPEN_ARROW","line","Polyline","icons","offset","strokeOpacity","setPath","GeopointMove","_ref","diff","fromValue","toValue","annotation","userColor","useUserColor","author","fromRef","useRef","toRef","RootContainer","_templateObject5","GeopointArrayDiff","_ref2","GeopointDiff","_ref3","filter","hasCoordinates","length","LatLngBounds","forEach","point","extend","toJSON","items","_ref4","toIndex","pointDiff","action","isChangeDiff","GeopointFieldDiff","_ref5","_ref6","getAnnotationAtPath","DiffTooltip","annotations","description","getAction","googleMapsInput","definePlugin","form","components","isType","renderDefault","schema"],"mappings":"00CAOA,MAAMA,EAAe,kCAGd,MAAMC,UAAkBC,OAE/B,SAASC,EAAmBC,GAC1B,OAAO,IAAIC,SAAmC,CAACC,EAASC,KACtDC,sBAAkC,KACzBD,EAAA,IAAIN,EAAU,sDAAqD,EAG5EO,OAAOR,GAAgB,KACbM,EAAAE,OAAOC,OAAOC,KAAI,EAGtB,MAAAC,EAASC,SAASC,cAAc,UACtCF,EAAOG,QAAU,CACfC,EACAC,EACAC,EACAC,EACAC,IACGZ,EAAO,IAAIL,MAqBpB,SAAsBa,EAAuBI,GAC3C,GAAIA,EACF,OAAOA,EAAMC,QAGX,GAAiB,iBAAVL,EACF,OAAAA,EAGT,OAGF,SAAsBA,GACpB,GAAqB,iBAAVA,GAAgC,OAAVA,EACxB,OAAA,EAGL,KAAE,YAAaA,GACV,OAAA,EAGF,MAAyC,iBAAjCA,EAAqBK,OACtC,CAbSC,CAAaN,GAASA,EAAMK,QAAU,gCAC/C,CA/B0BE,CAAaP,EAAOI,KAE1CR,EAAOY,IAAqDnB,+CAAAA,OAAAA,EAAOoB,OAAoCxB,+BAAAA,OAAAA,EAAyBI,cAAAA,OAAAA,EAAOqB,QACvIb,SAASc,qBAAqB,QAAQ,GAAGC,YAAYhB,EAAM,IAC1DiB,SAAQ,YACFpB,OAAOR,UACPQ,OAAO,cAAA,GAElB,CAEA,IAAIqB,EAAkD,KClC/C,SAASC,EAAUC,GAL1B,IAAAC,EAME,OACGC,EAAAC,EAAA,CAAKC,KAAK,WAAWC,OAAQ,EAC5BC,SAAA,CAACC,EAAAC,EAAA,CAAIC,GAAG,SAASC,SAAU,EAAGC,WAAY,EAAGC,cAAe,EAC1DN,SAACC,EAAAM,EAAA,CA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A,EAGH,MAAA,IAAI1Q,MAAM,uCAClB,CA/CiB6F,CAAU2K,EAAM3M,GACzBmC,EAASyK,GAAaC,EAAU5K,GAAU2K,EAAWC,EAAS7M,QAAO,EAE3E,OACGzB,EAAAsQ,EAAA,CAAYC,YAAahC,EAAa,CAACA,GAAc,GAAIiC,YAAaC,GAAUrC,GAC/ErO,SAACC,EAAA,MAAA,CACCD,SAACC,EAAAgF,EAAA,CACCvD,MACAmE,SAAUpC,EACV4C,gBAAgB,EAChBC,YAAa,GACbzC,SACA0C,aAAa,EAEZvG,SAACqD,GAASpD,EAAAkO,GAAA,CAAazM,MAAU2B,MAAUgL,cAKtD,CAEA,SAAS1K,GACP2K,EACAC,EACA7M,GAEO,OAAA,IAAIA,EAAI8N,cAAeG,OAAOrB,GAAWqB,OAAOpB,EACzD,CAsBA,SAASmC,GAAUrC,GACX,MAAAC,UAACA,EAAWC,QAAAA,GAAWF,EAC7B,OAAIC,GAAaC,EACR,QACED,EACF,UACEC,EACF,QAGF,WACT,CC9Ea,MAAAoC,GAAkBC,GAAqC7S,IAClE+L,GAAa/L,GACN,CACLmG,KAAM,oBACN2M,KAAM,CACJC,WAAY,CACV1N,MAAM1D,GACA,GAYLqR,GAAO,WAZSrR,EAAM8L,YAAa,CAEhC,OAAQvL,EAAA8K,UADYrL,GACM,CAAA,EAAA,CAAasM,UAAWjO,IACpD,CACO,OAAA2B,EAAMsR,cAActR,EAC7B,QAUR,SAASqR,GAAO7M,EAAc+M,GACxB,OAAA,MAAAA,OAAA,EAAAA,EAAQ/M,QAASA,MAGT,MAAA+M,OAAA,EAAAA,EAAQ/M,OAGb6M,GAAO7M,EAAM,MAAA+M,OAAA,EAAAA,EAAQ5P,KAC9B"}
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e,t,n,o,r;function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Object.defineProperty(exports,"__esModule",{value:!0});var c=require("react/jsx-runtime"),d=require("react"),p=require("lodash"),h=require("@sanity/ui"),u=require("@sanity/icons"),f=require("sanity"),m=require("rxjs"),g=require("styled-components");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function j(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var v=x(d),C=j(d),y=x(g);const b="___sanity_googleMapsApiCallback",k="undefined"!=typeof window&&window.navigator.language||"en";let w;function M(e,t){return t||("string"==typeof e?new Error(e):new Error(function(e){if("object"!=typeof e||null===e)return!1;if(!("message"in e))return!1;return"string"==typeof e.message}(e)?e.message:"Failed to load Google Maps API"))}function P(e){var t;return c.jsxs(h.Card,{tone:"critical",radius:1,children:[c.jsx(h.Box,{as:"header",paddingX:4,paddingTop:4,paddingBottom:1,children:c.jsx(h.Text,{as:"h2",weight:"bold",children:"Google Maps failed to load"})}),c.jsx(h.Box,{paddingX:4,paddingTop:4,paddingBottom:1,children:e.isAuthError?c.jsx(O,{}):c.jsxs(c.Fragment,{children:[c.jsx(h.Text,{as:"h3",children:"Error details:"}),c.jsx("pre",{children:c.jsx(h.Code,{size:1,children:"error"in e&&(null==(t=e.error)?void 0:t.message)})})]})})]})}function O(){return c.jsxs(h.Text,{children:[c.jsx("p",{children:"The error appears to be related to authentication"}),c.jsx("p",{children:"Common causes include:"}),c.jsxs("ul",{children:[c.jsx("li",{children:"Incorrect API key"}),c.jsx("li",{children:"Referer not allowed"}),c.jsx("li",{children:"Missing authentication scope"})]}),c.jsx("p",{children:"Check the browser developer tools for more information."})]})}class I extends v.default.Component{constructor(e){super(e),this.state={loadState:"loading"};let t=!0;this.loadSubscription=function(e){const t=e.defaultLocale||k||"en-US";if(w)return w;w=new m.BehaviorSubject({loadState:"loading"}),window.gm_authFailure=()=>{delete window.gm_authFailure,w.next({loadState:"authError"})},window[b]=()=>{delete window[b],w.next({loadState:"loaded",api:window.google.maps})};const n=document.createElement("script");return n.onerror=(e,t,n,o,r)=>w.next({loadState:"loadError",error:M(e,r)}),n.src="https://maps.googleapis.com/maps/api/js?key=".concat(e.apiKey,"&libraries=places&callback=").concat(b,"&language=").concat(t),document.getElementsByTagName("head")[0].appendChild(n),w}(e.config).subscribe((e=>{t?this.state=e:this.setState(e)})),t=!1}componentWillUnmount(){this.loadSubscription&&this.loadSubscription.unsubscribe()}render(){switch(this.state.loadState){case"loadError":return c.jsx(P,{error:this.state.error,isAuthError:!1});case"authError":return c.jsx(P,{isAuthError:!0});case"loading":return c.jsx("div",{children:"Loading Google Maps API"});case"loaded":return this.props.children(this.state.api)||null;default:return null}}}const E=y.default.div(e||(e=l(["\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n"])));class S extends C.PureComponent{constructor(){super(...arguments),this.searchInputRef=C.createRef(),this.handleChange=()=>{this.autoComplete&&(this.props.onChange(this.autoComplete.getPlace()),this.searchInputRef.current&&(this.searchInputRef.current.value=""))}}componentDidMount(){const e=this.searchInputRef.current;if(!e)return;const{api:t,map:n}=this.props,{Circle:o,places:r,event:i}=t,a=new o({center:n.getCenter(),radius:100}).getBounds();this.autoComplete=new r.Autocomplete(e,{bounds:a,types:[]}),i.addListener(this.autoComplete,"place_changed",this.handleChange)}render(){return c.jsx(E,{children:c.jsx(h.TextInput,{name:"place",ref:this.searchInputRef,placeholder:"Search for place or address",padding:4})})}}function H(e,t){const n="function"==typeof e.lat?e.lat():e.lat,o="function"==typeof e.lng?e.lng():e.lng,r="function"==typeof t.lat?t.lat():t.lat,i="function"==typeof t.lng?t.lng():t.lng;return n===r&&o===i}const T=y.default.div(t||(t=l(["\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n"])));class R extends v.default.PureComponent{constructor(){super(...arguments),this.state={map:void 0},this.mapRef=v.default.createRef(),this.mapEl=null,this.attachClickHandler=()=>{const e=this.state.map;if(!e)return;const{api:t,onClick:n}=this.props,{event:o}=t;this.clickHandler&&this.clickHandler.remove(),n&&(this.clickHandler=o.addListener(e,"click",n))},this.setMapElement=e=>{if(e&&e!==this.mapEl){const t=this.constructMap(e);this.setState({map:t},this.attachClickHandler)}this.mapEl=e}}componentDidMount(){this.attachClickHandler()}componentDidUpdate(e){const t=this.state.map;if(!t)return;const{onClick:n,location:o,bounds:r}=this.props;e.onClick!==n&&this.attachClickHandler(),H(e.location,o)||t.panTo(this.getCenter()),!r||e.bounds&&r.equals(e.bounds)||t.fitBounds(r)}componentWillUnmount(){this.clickHandler&&this.clickHandler.remove()}getCenter(){const{location:e,api:t}=this.props;return new t.LatLng(e.lat,e.lng)}constructMap(e){const{defaultZoom:t,api:n,mapTypeControl:o,controlSize:r,bounds:i,scrollWheel:a}=this.props,s=new n.Map(e,{zoom:t,center:this.getCenter(),scrollwheel:a,streetViewControl:!1,mapTypeControl:o,controlSize:r});return i&&s.fitBounds(i),s}render(){const{children:e}=this.props,{map:t}=this.state;return c.jsxs(c.Fragment,{children:[c.jsx(T,{ref:this.setMapElement}),e&&t?e(t):null]})}}R.defaultProps={defaultZoom:8,scrollWheel:!0};class A extends C.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{position:e,api:t,map:n,onMove:o,zIndex:r,opacity:i,label:a,markerRef:s,color:l}=this.props,{Marker:c}=t;let d;l&&(d={path:"M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z",fillOpacity:1,fillColor:l.background,strokeColor:l.border,strokeWeight:2,anchor:new t.Point(10,35),labelOrigin:new t.Point(10,11)}),this.marker=new c({draggable:Boolean(o),position:e,map:n,zIndex:r,opacity:i,label:a,icon:d}),s&&(s.current=this.marker),this.attachMoveHandler(),this.attachClickHandler()}componentDidUpdate(e){if(!this.marker)return;const{position:t,onMove:n,label:o,zIndex:r,opacity:i,map:a}=this.props;e.onMove!==n&&this.attachMoveHandler(),H(e.position,t)||this.marker.setPosition(t),e.label!==o&&this.marker.setLabel(o||null),e.zIndex!==r&&this.marker.setZIndex(r||null),e.opacity!==i&&this.marker.setOpacity(i||null),e.map!==a&&this.marker.setMap(a)}componentWillUnmount(){this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&this.marker.setMap(null)}attachMoveHandler(){const{api:e,onMove:t}=this.props;this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&t&&(this.eventHandlers.move=e.event.addListener(this.marker,"dragend",t))}attachClickHandler(){const{api:e,onClick:t}=this.props;this.eventHandlers.click&&this.eventHandlers.click.remove(),this.marker&&t&&(this.eventHandlers.click=e.event.addListener(this.marker,"click",t))}render(){return null}}const L={lat:40.7058254,lng:-74.1180863};class z extends v.default.PureComponent{constructor(){super(...arguments),this.mapRef=v.default.createRef(),this.handlePlaceChanged=e=>{var t;(null==(t=e.geometry)?void 0:t.location)&&this.setValue(e.geometry.location)},this.handleMarkerDragEnd=e=>{e.latLng&&this.setValue(e.latLng)},this.handleMapClick=e=>{e.latLng&&this.setValue(e.latLng)}}getCenter(){const{value:e={},defaultLocation:t={}}=this.props;return a(a(a({},L),t),e)}setValue(e){this.props.onChange&&this.props.onChange(e)}render(){const{api:e,defaultZoom:t,value:n,onChange:o}=this.props;return c.jsx(R,{api:e,location:this.getCenter(),onClick:this.handleMapClick,defaultZoom:t,children:t=>c.jsxs(c.Fragment,{children:[c.jsx(S,{api:e,map:t,onChange:this.handlePlaceChanged}),n&&c.jsx(A,{api:e,map:t,position:n,onMove:o?this.handleMarkerDragEnd:void 0})]})})}}z.defaultProps={defaultZoom:8,defaultLocation:{lng:10.74609,lat:59.91273}};const B=y.default.img(n||(n=l(["\n width: 100%;\n height: auto;\n vertical-align: top;\n"]))),D=y.default.div(o||(o=l(["\n height: 40rem;\n width: 50rem;\n"])));let _;function V(){return _}function G(e){_=e}const F=(e,t)=>{const n="".concat(e.lat,",").concat(e.lng),o={key:t,center:n,markers:n,zoom:13,scale:2,size:"640x300"},r=Object.keys(o).reduce(((e,t)=>e.concat("".concat(t,"=").concat(encodeURIComponent(o[t])))),[]);return"https://maps.googleapis.com/maps/api/staticmap?".concat(r.join("&"))};class U extends v.default.PureComponent{constructor(e){super(e),this._geopointInputId=p.uniqueId("GeopointInput"),this.setEditButton=e=>{this.editButton=e},this.handleToggleModal=()=>{this.setState((e=>({modalOpen:!e.modalOpen})))},this.handleCloseModal=()=>{this.setState({modalOpen:!1})},this.handleChange=e=>{const{schemaType:t,onChange:n}=this.props;n([f.setIfMissing({_type:t.name}),f.set(e.lat(),["lat"]),f.set(e.lng(),["lng"])])},this.handleClear=()=>{const{onChange:e}=this.props;e(f.unset())},this.state={modalOpen:!1}}focus(){this.editButton&&this.editButton.focus()}render(){const{value:e,readOnly:t,geoConfig:n,path:o,changed:r,focused:i}=this.props,{modalOpen:a}=this.state;return n&&n.apiKey?c.jsxs(c.Fragment,{children:[e&&c.jsx(f.ChangeIndicator,{path:o,isChanged:r,hasFocus:!!i,children:c.jsx(B,{src:F(e,n.apiKey),alt:"Map location"})}),!t&&c.jsx(h.Box,{marginTop:4,children:c.jsxs(h.Grid,{columns:2,gap:2,children:[c.jsx(h.Button,{mode:"ghost",icon:e&&u.EditIcon,padding:3,ref:this.setEditButton,text:e?"Edit":"Set location",onClick:this.handleToggleModal}),e&&c.jsx(h.Button,{tone:"critical",icon:u.TrashIcon,padding:3,mode:"ghost",text:"Remove",onClick:this.handleClear})]})}),a&&c.jsx(h.Dialog,{id:"".concat(this._geopointInputId,"_dialog"),onClose:this.handleCloseModal,header:"Place the marker on the map",width:1,children:c.jsx(D,{children:c.jsx(I,{config:V(),children:o=>c.jsx(z,{api:o,value:e||void 0,onChange:t?void 0:this.handleChange,defaultLocation:n.defaultLocation,defaultZoom:n.defaultZoom})})})})]}):c.jsxs("div",{children:[c.jsxs("p",{children:["The ",c.jsx("a",{href:"https://sanity.io/docs/schema-types/geopoint-type",children:"Geopoint type"})," needs a Google Maps API key with access to:"]}),c.jsxs("ul",{children:[c.jsx("li",{children:"Google Maps JavaScript API"}),c.jsx("li",{children:"Google Places API Web Service"}),c.jsx("li",{children:"Google Static Maps API"})]}),c.jsx("p",{children:"Please enter the API key with access to these services in your googleMapsInput plugin config."})]})}}class W extends C.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{from:e,to:t,api:n,map:o,zIndex:r,onClick:i,color:a,arrowRef:s}=this.props,l={path:n.SymbolPath.FORWARD_OPEN_ARROW};this.line=new n.Polyline({map:o,zIndex:r,path:[e,t],icons:[{icon:l,offset:"50%"}],strokeOpacity:.55,strokeColor:a?a.text:"black"}),i&&(this.eventHandlers.click=n.event.addListener(this.line,"click",i)),s&&(s.current=this.line)}componentDidUpdate(e){if(!this.line)return;const{from:t,to:n,map:o}=this.props;H(e.from,t)&&H(e.to,n)||this.line.setPath([t,n]),e.map!==o&&this.line.setMap(o)}componentWillUnmount(){this.line&&this.line.setMap(null),this.eventHandlers.click&&this.eventHandlers.click.remove()}render(){return null}}function q(e){let{diff:t,api:n,map:o,label:r}=e;const{fromValue:i,toValue:a}=t,s=t.isChanged?t.annotation:void 0,l=f.useUserColor(s?s.author:null)||void 0,d=C.useRef(),p=C.useRef();return c.jsxs(c.Fragment,{children:[i&&c.jsx(A,{api:n,map:o,position:i,zIndex:0,opacity:.55,markerRef:d,color:l}),i&&a&&c.jsx(W,{api:n,map:o,from:i,to:a,zIndex:1,color:l}),a&&c.jsx(A,{api:n,map:o,position:a,zIndex:2,markerRef:p,label:r,color:l})]})}const Z=y.default.div(r||(r=l(["\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n"])));function N(e){let{api:t,diff:n}=e;const o=(n.fromValue||[]).filter(J),r=(n.toValue||[]).filter(J);if(0===o.length&&0===r.length)return null;const i=function(e,t,n){const o=new n.LatLngBounds;return[...e||[],...t||[]].forEach((e=>o.extend(e))),o}(o,r,t);return c.jsx(R,{api:t,location:i.getCenter().toJSON(),mapTypeControl:!1,controlSize:20,bounds:i,children:e=>c.jsx(c.Fragment,{children:n.items.map((n=>{let{toIndex:o,diff:r}=n;return function(e){return"unchanged"!==e.action&&"object"===e.type}(r)?c.jsx(q,{api:t,map:e,diff:r,label:"".concat(o)},o):null}))})})}function J(e){return"number"==typeof e.lat&&"number"==typeof e.lng}function K(e){let{api:t,diff:n}=e;const{fromValue:o,toValue:r}=n,i=f.getAnnotationAtPath(n,["lat"])||f.getAnnotationAtPath(n,["lng"])||f.getAnnotationAtPath(n,[]),a=function(e,t){const{fromValue:n,toValue:o}=e;if(n&&o)return X(n,o,t).getCenter().toJSON();if(n)return n;if(o)return o;throw new Error("Neither a from or a to value present")}(n,t),s=o&&r?X(o,r,t):void 0;return c.jsx(f.DiffTooltip,{annotations:i?[i]:[],description:Q(n),children:c.jsx("div",{children:c.jsx(R,{api:t,location:a,mapTypeControl:!1,controlSize:20,bounds:s,scrollWheel:!1,children:e=>c.jsx(q,{api:t,map:e,diff:n})})})})}function X(e,t,n){return(new n.LatLngBounds).extend(e).extend(t)}function Q(e){const{fromValue:t,toValue:n}=e;return t&&n?"Moved":t?"Removed":n?"Added":"Unchanged"}const Y=f.definePlugin((e=>(G(e),{name:"google-maps-input",form:{components:{input(t){if($("geopoint",t.schemaType)){const n=t;return c.jsx(U,a(a({},n),{},{geoConfig:e}))}return t.renderDefault(t)}}}})));function $(e,t){return(null==t?void 0:t.name)===e||!!(null==t?void 0:t.name)&&$(e,null==t?void 0:t.type)}exports.GeopointArrayDiff=e=>{let{diff:t,schemaType:n}=e;return c.jsx(Z,{children:c.jsx(I,{config:V(),children:e=>c.jsx(N,{api:e,diff:t,schemaType:n})})})},exports.GeopointFieldDiff=e=>{let{diff:t,schemaType:n}=e;return c.jsx(Z,{children:c.jsx(I,{config:V(),children:e=>c.jsx(K,{api:e,diff:t,schemaType:n})})})},exports.GeopointInput=U,exports.googleMapsInput=Y;
|
|
1
|
+
"use strict";var e,t,n,o,r;function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Object.defineProperty(exports,"__esModule",{value:!0});var c=require("react/jsx-runtime"),d=require("react"),p=require("lodash"),h=require("@sanity/ui"),u=require("@sanity/icons"),f=require("sanity"),m=require("styled-components");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function x(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var j=x(d),v=g(d),y=g(m);const C="___sanity_googleMapsApiCallback";class k extends Error{}function b(e){return new Promise(((t,n)=>{window.gm_authFailure=()=>{n(new k("Authentication error when loading Google Maps API."))},window[C]=()=>{t(window.google.maps)};const o=document.createElement("script");o.onerror=(e,t,o,r,i)=>n(new Error(function(e,t){if(t)return t.message;if("string"==typeof e)return e;return function(e){if("object"!=typeof e||null===e)return!1;if(!("message"in e))return!1;return"string"==typeof e.message}(e)?e.message:"Failed to load Google Maps API"}(e,i))),o.src="https://maps.googleapis.com/maps/api/js?key=".concat(e.apiKey,"&libraries=places&callback=").concat(C,"&language=").concat(e.locale),document.getElementsByTagName("head")[0].appendChild(o)})).finally((()=>{delete window[C],delete window.gm_authFailure}))}let w=null;function M(e){var t;return c.jsxs(h.Card,{tone:"critical",radius:1,children:[c.jsx(h.Box,{as:"header",paddingX:4,paddingTop:4,paddingBottom:1,children:c.jsx(h.Text,{as:"h2",weight:"bold",children:"Google Maps failed to load"})}),c.jsx(h.Box,{paddingX:4,paddingTop:4,paddingBottom:1,children:e.isAuthError?c.jsx(P,{}):c.jsxs(c.Fragment,{children:[c.jsx(h.Text,{as:"h3",children:"Error details:"}),c.jsx("pre",{children:c.jsx(h.Code,{size:1,children:"error"in e&&(null==(t=e.error)?void 0:t.message)})})]})})]})}function P(){return c.jsxs(h.Text,{children:[c.jsx("p",{children:"The error appears to be related to authentication"}),c.jsx("p",{children:"Common causes include:"}),c.jsxs("ul",{children:[c.jsx("li",{children:"Incorrect API key"}),c.jsx("li",{children:"Referer not allowed"}),c.jsx("li",{children:"Missing authentication scope"})]}),c.jsx("p",{children:"Check the browser developer tools for more information."})]})}const O="undefined"!=typeof window&&window.navigator.language||"en";function I(e){const t=e.defaultLocale||O||"en-US",[n,o]=d.useState({type:"loading"});return d.useEffect((()=>{(function(e){return w||(w=b(e),w.catch((()=>{w=null})),w)})({locale:t,apiKey:e.apiKey}).then((e=>o({type:"loaded",api:e})),(e=>o({type:"error",error:{type:e instanceof k?"authError":"loadError",message:e.message}})))}),[t,e.apiKey]),n}function E(e){const t=I(e.config);switch(t.type){case"error":return c.jsx(M,{error:t.error,isAuthError:"authError"===t.error.type});case"loading":return c.jsx("div",{children:"Loading Google Maps API"});case"loaded":return e.children(t.api);default:return null}}const H=y.default.div(e||(e=l(["\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n"])));class T extends j.PureComponent{constructor(){super(...arguments),this.searchInputRef=j.createRef(),this.handleChange=()=>{this.autoComplete&&(this.props.onChange(this.autoComplete.getPlace()),this.searchInputRef.current&&(this.searchInputRef.current.value=""))}}componentDidMount(){const e=this.searchInputRef.current;if(!e)return;const{api:t,map:n}=this.props,{Circle:o,places:r,event:i}=t,a=new o({center:n.getCenter(),radius:100}).getBounds();this.autoComplete=new r.Autocomplete(e,{bounds:a,types:[]}),i.addListener(this.autoComplete,"place_changed",this.handleChange)}render(){return c.jsx(H,{children:c.jsx(h.TextInput,{name:"place",ref:this.searchInputRef,placeholder:"Search for place or address",padding:4})})}}function A(e,t){const n="function"==typeof e.lat?e.lat():e.lat,o="function"==typeof e.lng?e.lng():e.lng,r="function"==typeof t.lat?t.lat():t.lat,i="function"==typeof t.lng?t.lng():t.lng;return n===r&&o===i}const R=y.default.div(t||(t=l(["\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n"])));class L extends v.default.PureComponent{constructor(){super(...arguments),this.state={map:void 0},this.mapRef=v.default.createRef(),this.mapEl=null,this.attachClickHandler=()=>{const e=this.state.map;if(!e)return;const{api:t,onClick:n}=this.props,{event:o}=t;this.clickHandler&&this.clickHandler.remove(),n&&(this.clickHandler=o.addListener(e,"click",n))},this.setMapElement=e=>{if(e&&e!==this.mapEl){const t=this.constructMap(e);this.setState({map:t},this.attachClickHandler)}this.mapEl=e}}componentDidMount(){this.attachClickHandler()}componentDidUpdate(e){const t=this.state.map;if(!t)return;const{onClick:n,location:o,bounds:r}=this.props;e.onClick!==n&&this.attachClickHandler(),A(e.location,o)||t.panTo(this.getCenter()),!r||e.bounds&&r.equals(e.bounds)||t.fitBounds(r)}componentWillUnmount(){this.clickHandler&&this.clickHandler.remove()}getCenter(){const{location:e,api:t}=this.props;return new t.LatLng(e.lat,e.lng)}constructMap(e){const{defaultZoom:t,api:n,mapTypeControl:o,controlSize:r,bounds:i,scrollWheel:a}=this.props,s=new n.Map(e,{zoom:t,center:this.getCenter(),scrollwheel:a,streetViewControl:!1,mapTypeControl:o,controlSize:r});return i&&s.fitBounds(i),s}render(){const{children:e}=this.props,{map:t}=this.state;return c.jsxs(c.Fragment,{children:[c.jsx(R,{ref:this.setMapElement}),e&&t?e(t):null]})}}L.defaultProps={defaultZoom:8,scrollWheel:!0};class z extends j.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{position:e,api:t,map:n,onMove:o,zIndex:r,opacity:i,label:a,markerRef:s,color:l}=this.props,{Marker:c}=t;let d;l&&(d={path:"M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z",fillOpacity:1,fillColor:l.background,strokeColor:l.border,strokeWeight:2,anchor:new t.Point(10,35),labelOrigin:new t.Point(10,11)}),this.marker=new c({draggable:Boolean(o),position:e,map:n,zIndex:r,opacity:i,label:a,icon:d}),s&&(s.current=this.marker),this.attachMoveHandler(),this.attachClickHandler()}componentDidUpdate(e){if(!this.marker)return;const{position:t,onMove:n,label:o,zIndex:r,opacity:i,map:a}=this.props;e.onMove!==n&&this.attachMoveHandler(),A(e.position,t)||this.marker.setPosition(t),e.label!==o&&this.marker.setLabel(o||null),e.zIndex!==r&&this.marker.setZIndex(r||null),e.opacity!==i&&this.marker.setOpacity(i||null),e.map!==a&&this.marker.setMap(a)}componentWillUnmount(){this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&this.marker.setMap(null)}attachMoveHandler(){const{api:e,onMove:t}=this.props;this.eventHandlers.move&&this.eventHandlers.move.remove(),this.marker&&t&&(this.eventHandlers.move=e.event.addListener(this.marker,"dragend",t))}attachClickHandler(){const{api:e,onClick:t}=this.props;this.eventHandlers.click&&this.eventHandlers.click.remove(),this.marker&&t&&(this.eventHandlers.click=e.event.addListener(this.marker,"click",t))}render(){return null}}const D={lat:40.7058254,lng:-74.1180863};class B extends v.default.PureComponent{constructor(){super(...arguments),this.mapRef=v.default.createRef(),this.handlePlaceChanged=e=>{var t;(null==(t=e.geometry)?void 0:t.location)&&this.setValue(e.geometry.location)},this.handleMarkerDragEnd=e=>{e.latLng&&this.setValue(e.latLng)},this.handleMapClick=e=>{e.latLng&&this.setValue(e.latLng)}}getCenter(){const{value:e={},defaultLocation:t={}}=this.props;return a(a(a({},D),t),e)}setValue(e){this.props.onChange&&this.props.onChange(e)}render(){const{api:e,defaultZoom:t,value:n,onChange:o}=this.props;return c.jsx(L,{api:e,location:this.getCenter(),onClick:this.handleMapClick,defaultZoom:t,children:t=>c.jsxs(c.Fragment,{children:[c.jsx(T,{api:e,map:t,onChange:this.handlePlaceChanged}),n&&c.jsx(z,{api:e,map:t,position:n,onMove:o?this.handleMarkerDragEnd:void 0})]})})}}B.defaultProps={defaultZoom:8,defaultLocation:{lng:10.74609,lat:59.91273}};const S=y.default.img(n||(n=l(["\n width: 100%;\n height: auto;\n vertical-align: top;\n"]))),_=y.default.div(o||(o=l(["\n height: 40rem;\n width: 50rem;\n"])));let V;function G(){return V}function F(e){V=e}const U=(e,t)=>{const n="".concat(e.lat,",").concat(e.lng),o={key:t,center:n,markers:n,zoom:13,scale:2,size:"640x300"},r=Object.keys(o).reduce(((e,t)=>e.concat("".concat(t,"=").concat(encodeURIComponent(o[t])))),[]);return"https://maps.googleapis.com/maps/api/staticmap?".concat(r.join("&"))};class W extends v.default.PureComponent{constructor(e){super(e),this._geopointInputId=p.uniqueId("GeopointInput"),this.setEditButton=e=>{this.editButton=e},this.handleToggleModal=()=>{this.setState((e=>({modalOpen:!e.modalOpen})))},this.handleCloseModal=()=>{this.setState({modalOpen:!1})},this.handleChange=e=>{const{schemaType:t,onChange:n}=this.props;n([f.setIfMissing({_type:t.name}),f.set(e.lat(),["lat"]),f.set(e.lng(),["lng"])])},this.handleClear=()=>{const{onChange:e}=this.props;e(f.unset())},this.state={modalOpen:!1}}focus(){this.editButton&&this.editButton.focus()}render(){const{value:e,readOnly:t,geoConfig:n,path:o,changed:r,focused:i}=this.props,{modalOpen:a}=this.state;return n&&n.apiKey?c.jsxs(c.Fragment,{children:[e&&c.jsx(f.ChangeIndicator,{path:o,isChanged:r,hasFocus:!!i,children:c.jsx(S,{src:U(e,n.apiKey),alt:"Map location"})}),!t&&c.jsx(h.Box,{marginTop:4,children:c.jsxs(h.Grid,{columns:2,gap:2,children:[c.jsx(h.Button,{mode:"ghost",icon:e&&u.EditIcon,padding:3,ref:this.setEditButton,text:e?"Edit":"Set location",onClick:this.handleToggleModal}),e&&c.jsx(h.Button,{tone:"critical",icon:u.TrashIcon,padding:3,mode:"ghost",text:"Remove",onClick:this.handleClear})]})}),a&&c.jsx(h.Dialog,{id:"".concat(this._geopointInputId,"_dialog"),onClose:this.handleCloseModal,header:"Place the marker on the map",width:1,children:c.jsx(_,{children:c.jsx(E,{config:G(),children:o=>c.jsx(B,{api:o,value:e||void 0,onChange:t?void 0:this.handleChange,defaultLocation:n.defaultLocation,defaultZoom:n.defaultZoom})})})})]}):c.jsxs("div",{children:[c.jsxs("p",{children:["The ",c.jsx("a",{href:"https://sanity.io/docs/schema-types/geopoint-type",children:"Geopoint type"})," needs a Google Maps API key with access to:"]}),c.jsxs("ul",{children:[c.jsx("li",{children:"Google Maps JavaScript API"}),c.jsx("li",{children:"Google Places API Web Service"}),c.jsx("li",{children:"Google Static Maps API"})]}),c.jsx("p",{children:"Please enter the API key with access to these services in your googleMapsInput plugin config."})]})}}class q extends j.PureComponent{constructor(){super(...arguments),this.eventHandlers={}}componentDidMount(){const{from:e,to:t,api:n,map:o,zIndex:r,onClick:i,color:a,arrowRef:s}=this.props,l={path:n.SymbolPath.FORWARD_OPEN_ARROW};this.line=new n.Polyline({map:o,zIndex:r,path:[e,t],icons:[{icon:l,offset:"50%"}],strokeOpacity:.55,strokeColor:a?a.text:"black"}),i&&(this.eventHandlers.click=n.event.addListener(this.line,"click",i)),s&&(s.current=this.line)}componentDidUpdate(e){if(!this.line)return;const{from:t,to:n,map:o}=this.props;A(e.from,t)&&A(e.to,n)||this.line.setPath([t,n]),e.map!==o&&this.line.setMap(o)}componentWillUnmount(){this.line&&this.line.setMap(null),this.eventHandlers.click&&this.eventHandlers.click.remove()}render(){return null}}function Z(e){let{diff:t,api:n,map:o,label:r}=e;const{fromValue:i,toValue:a}=t,s=t.isChanged?t.annotation:void 0,l=f.useUserColor(s?s.author:null)||void 0,d=j.useRef(),p=j.useRef();return c.jsxs(c.Fragment,{children:[i&&c.jsx(z,{api:n,map:o,position:i,zIndex:0,opacity:.55,markerRef:d,color:l}),i&&a&&c.jsx(q,{api:n,map:o,from:i,to:a,zIndex:1,color:l}),a&&c.jsx(z,{api:n,map:o,position:a,zIndex:2,markerRef:p,label:r,color:l})]})}const K=y.default.div(r||(r=l(["\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n"])));function N(e){let{api:t,diff:n}=e;const o=(n.fromValue||[]).filter(J),r=(n.toValue||[]).filter(J);if(0===o.length&&0===r.length)return null;const i=function(e,t,n){const o=new n.LatLngBounds;return[...e||[],...t||[]].forEach((e=>o.extend(e))),o}(o,r,t);return c.jsx(L,{api:t,location:i.getCenter().toJSON(),mapTypeControl:!1,controlSize:20,bounds:i,children:e=>c.jsx(c.Fragment,{children:n.items.map((n=>{let{toIndex:o,diff:r}=n;return function(e){return"unchanged"!==e.action&&"object"===e.type}(r)?c.jsx(Z,{api:t,map:e,diff:r,label:"".concat(o)},o):null}))})})}function J(e){return"number"==typeof e.lat&&"number"==typeof e.lng}function X(e){let{api:t,diff:n}=e;const{fromValue:o,toValue:r}=n,i=f.getAnnotationAtPath(n,["lat"])||f.getAnnotationAtPath(n,["lng"])||f.getAnnotationAtPath(n,[]),a=function(e,t){const{fromValue:n,toValue:o}=e;if(n&&o)return Q(n,o,t).getCenter().toJSON();if(n)return n;if(o)return o;throw new Error("Neither a from or a to value present")}(n,t),s=o&&r?Q(o,r,t):void 0;return c.jsx(f.DiffTooltip,{annotations:i?[i]:[],description:Y(n),children:c.jsx("div",{children:c.jsx(L,{api:t,location:a,mapTypeControl:!1,controlSize:20,bounds:s,scrollWheel:!1,children:e=>c.jsx(Z,{api:t,map:e,diff:n})})})})}function Q(e,t,n){return(new n.LatLngBounds).extend(e).extend(t)}function Y(e){const{fromValue:t,toValue:n}=e;return t&&n?"Moved":t?"Removed":n?"Added":"Unchanged"}const $=f.definePlugin((e=>(F(e),{name:"google-maps-input",form:{components:{input(t){if(ee("geopoint",t.schemaType)){const n=t;return c.jsx(W,a(a({},n),{},{geoConfig:e}))}return t.renderDefault(t)}}}})));function ee(e,t){return(null==t?void 0:t.name)===e||!!(null==t?void 0:t.name)&&ee(e,null==t?void 0:t.type)}exports.GeopointArrayDiff=e=>{let{diff:t,schemaType:n}=e;return c.jsx(K,{children:c.jsx(E,{config:G(),children:e=>c.jsx(N,{api:e,diff:t,schemaType:n})})})},exports.GeopointFieldDiff=e=>{let{diff:t,schemaType:n}=e;return c.jsx(K,{children:c.jsx(E,{config:G(),children:e=>c.jsx(X,{api:e,diff:t,schemaType:n})})})},exports.GeopointInput=W,exports.googleMapsInput=$;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/loader/loadGoogleMapsApi.ts","../src/loader/LoadError.tsx","../src/loader/GoogleMapsLoadProxy.tsx","../src/map/SearchInput.styles.tsx","../src/map/SearchInput.tsx","../src/map/util.ts","../src/map/Map.styles.tsx","../src/map/Map.tsx","../src/map/Marker.tsx","../src/input/GeopointSelect.tsx","../src/input/GeopointInput.styles.tsx","../src/global-workaround.ts","../src/input/GeopointInput.tsx","../src/map/Arrow.tsx","../src/diff/GeopointMove.tsx","../src/diff/GeopointFieldDiff.styles.tsx","../src/diff/GeopointArrayDiff.tsx","../src/diff/GeopointFieldDiff.tsx","../src/plugin.tsx"],"sourcesContent":["import {Observable, BehaviorSubject} from 'rxjs'\nimport {GoogleMapsInputConfig} from '../index'\n\ndeclare global {\n interface Window {\n gm_authFailure: any\n ___sanity_googleMapsApiCallback: any\n }\n}\n\nconst callbackName = '___sanity_googleMapsApiCallback'\nconst authFailureCallbackName = 'gm_authFailure'\nconst locale = (typeof window !== 'undefined' && window.navigator.language) || 'en'\n\nexport interface LoadingState {\n loadState: 'loading'\n}\n\nexport interface LoadedState {\n loadState: 'loaded'\n api: typeof window.google.maps\n}\n\nexport interface LoadErrorState {\n loadState: 'loadError'\n error: Error\n}\n\nexport interface AuthErrorState {\n loadState: 'authError'\n}\n\nexport type GoogleLoadState = LoadingState | LoadedState | LoadErrorState | AuthErrorState\n\nlet subject: BehaviorSubject<GoogleLoadState>\n\nexport function loadGoogleMapsApi(config: GoogleMapsInputConfig): Observable<GoogleLoadState> {\n const selectedLocale = config.defaultLocale || locale || 'en-US'\n\n if (subject) {\n return subject\n }\n\n subject = new BehaviorSubject<GoogleLoadState>({loadState: 'loading'})\n\n window[authFailureCallbackName] = () => {\n delete window[authFailureCallbackName]\n subject.next({loadState: 'authError'})\n }\n\n window[callbackName] = () => {\n delete window[callbackName]\n subject.next({loadState: 'loaded', api: window.google.maps})\n }\n\n const script = document.createElement('script')\n script.onerror = (\n event: Event | string,\n source?: string,\n lineno?: number,\n colno?: number,\n error?: Error\n ) =>\n subject.next({\n loadState: 'loadError',\n error: coeerceError(event, error),\n } as LoadErrorState)\n\n script.src = `https://maps.googleapis.com/maps/api/js?key=${config.apiKey}&libraries=places&callback=${callbackName}&language=${selectedLocale}`\n document.getElementsByTagName('head')[0].appendChild(script)\n\n return subject\n}\n\nfunction coeerceError(event: Event | string, error?: Error): Error {\n if (error) {\n return error\n }\n\n if (typeof event === 'string') {\n return new Error(event)\n }\n\n return new Error(isErrorEvent(event) ? event.message : 'Failed to load Google Maps API')\n}\n\nfunction isErrorEvent(event: unknown): event is ErrorEvent {\n if (typeof event !== 'object' || event === null) {\n return false\n }\n\n if (!('message' in event)) {\n return false\n }\n\n return typeof (event as ErrorEvent).message === 'string'\n}\n","import * as React from 'react'\nimport {Card, Box, Text, Code} from '@sanity/ui'\n\ntype Props = {error: Error; isAuthError: false} | {isAuthError: true}\n\nexport function LoadError(props: Props) {\n return (\n <Card tone=\"critical\" radius={1}>\n <Box as=\"header\" paddingX={4} paddingTop={4} paddingBottom={1}>\n <Text as=\"h2\" weight=\"bold\">\n Google Maps failed to load\n </Text>\n </Box>\n\n <Box paddingX={4} paddingTop={4} paddingBottom={1}>\n {props.isAuthError ? (\n <AuthError />\n ) : (\n <>\n <Text as=\"h3\">Error details:</Text>\n <pre>\n <Code size={1}>{'error' in props && props.error?.message}</Code>\n </pre>\n </>\n )}\n </Box>\n </Card>\n )\n}\n\nfunction AuthError() {\n return (\n <Text>\n <p>The error appears to be related to authentication</p>\n <p>Common causes include:</p>\n <ul>\n <li>Incorrect API key</li>\n <li>Referer not allowed</li>\n <li>Missing authentication scope</li>\n </ul>\n <p>Check the browser developer tools for more information.</p>\n </Text>\n )\n}\n","import React from 'react'\nimport {Subscription} from 'rxjs'\nimport {loadGoogleMapsApi, GoogleLoadState} from './loadGoogleMapsApi'\nimport {LoadError} from './LoadError'\nimport {GoogleMapsInputConfig} from '../index'\n\ninterface LoadProps {\n children: (api: typeof window.google.maps) => React.ReactElement\n config: GoogleMapsInputConfig\n}\n\nexport class GoogleMapsLoadProxy extends React.Component<LoadProps, GoogleLoadState> {\n loadSubscription: Subscription | undefined\n\n constructor(props: LoadProps) {\n super(props)\n\n this.state = {loadState: 'loading'}\n\n let sync = true\n this.loadSubscription = loadGoogleMapsApi(props.config).subscribe((loadState) => {\n if (sync) {\n this.state = loadState\n } else {\n this.setState(loadState)\n }\n })\n sync = false\n }\n\n componentWillUnmount() {\n if (this.loadSubscription) {\n this.loadSubscription.unsubscribe()\n }\n }\n\n render() {\n switch (this.state.loadState) {\n case 'loadError':\n return <LoadError error={this.state.error} isAuthError={false} />\n case 'authError':\n return <LoadError isAuthError />\n case 'loading':\n return <div>Loading Google Maps API</div>\n case 'loaded':\n return this.props.children(this.state.api) || null\n default:\n return null\n }\n }\n}\n","import styled from 'styled-components'\n\nexport const WrapperContainer = styled.div`\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n`\n","import * as React from 'react'\nimport {TextInput} from '@sanity/ui'\nimport {WrapperContainer} from './SearchInput.styles'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onChange: (result: google.maps.places.PlaceResult) => void\n}\n\nexport class SearchInput extends React.PureComponent<Props> {\n searchInputRef = React.createRef<HTMLInputElement>()\n autoComplete: google.maps.places.Autocomplete | undefined\n\n handleChange = () => {\n if (!this.autoComplete) {\n return\n }\n\n this.props.onChange(this.autoComplete.getPlace())\n\n if (this.searchInputRef.current) {\n this.searchInputRef.current.value = ''\n }\n }\n\n componentDidMount() {\n const input = this.searchInputRef.current\n if (!input) {\n return\n }\n\n const {api, map} = this.props\n const {Circle, places, event} = api\n const searchBounds = new Circle({center: map.getCenter(), radius: 100}).getBounds()!\n this.autoComplete = new places.Autocomplete(input, {\n bounds: searchBounds,\n types: [], // return all kinds of places\n })\n\n event.addListener(this.autoComplete, 'place_changed', this.handleChange)\n }\n\n render() {\n return (\n <WrapperContainer>\n <TextInput\n name=\"place\"\n ref={this.searchInputRef}\n placeholder=\"Search for place or address\"\n padding={4}\n />\n </WrapperContainer>\n )\n }\n}\n","import {LatLng} from '../types'\n\nexport function latLngAreEqual(\n latLng1: LatLng | google.maps.LatLng,\n latLng2: LatLng | google.maps.LatLng\n): boolean {\n const lat1 = typeof latLng1.lat === 'function' ? latLng1.lat() : latLng1.lat\n const lng1 = typeof latLng1.lng === 'function' ? latLng1.lng() : latLng1.lng\n\n const lat2 = typeof latLng2.lat === 'function' ? latLng2.lat() : latLng2.lat\n const lng2 = typeof latLng2.lng === 'function' ? latLng2.lng() : latLng2.lng\n\n return lat1 === lat2 && lng1 === lng2\n}\n","import styled from 'styled-components'\n\nexport const MapContainer = styled.div`\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n`\n","import React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\nimport {MapContainer} from './Map.styles'\n\ninterface MapProps {\n api: typeof window.google.maps\n location: LatLng\n bounds?: google.maps.LatLngBounds\n defaultZoom?: number\n mapTypeControl?: boolean\n scrollWheel?: boolean\n controlSize?: number\n onClick?: (event: google.maps.MapMouseEvent) => void\n children?: (map: google.maps.Map) => React.ReactElement\n}\n\ninterface MapState {\n map: google.maps.Map | undefined\n}\n\nexport class GoogleMap extends React.PureComponent<MapProps, MapState> {\n static defaultProps = {\n defaultZoom: 8,\n scrollWheel: true,\n }\n\n state: MapState = {map: undefined}\n clickHandler: google.maps.MapsEventListener | undefined\n mapRef = React.createRef<HTMLDivElement>()\n mapEl: HTMLDivElement | null = null\n\n componentDidMount() {\n this.attachClickHandler()\n }\n\n attachClickHandler = () => {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {api, onClick} = this.props\n const {event} = api\n\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n\n if (onClick) {\n this.clickHandler = event.addListener(map, 'click', onClick)\n }\n }\n\n componentDidUpdate(prevProps: MapProps) {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {onClick, location, bounds} = this.props\n\n if (prevProps.onClick !== onClick) {\n this.attachClickHandler()\n }\n\n if (!latLngAreEqual(prevProps.location, location)) {\n map.panTo(this.getCenter())\n }\n\n if (bounds && (!prevProps.bounds || !bounds.equals(prevProps.bounds))) {\n map.fitBounds(bounds)\n }\n }\n\n componentWillUnmount() {\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n }\n\n getCenter(): google.maps.LatLng {\n const {location, api} = this.props\n return new api.LatLng(location.lat, location.lng)\n }\n\n constructMap(el: HTMLDivElement) {\n const {defaultZoom, api, mapTypeControl, controlSize, bounds, scrollWheel} = this.props\n\n const map = new api.Map(el, {\n zoom: defaultZoom,\n center: this.getCenter(),\n scrollwheel: scrollWheel,\n streetViewControl: false,\n mapTypeControl,\n controlSize,\n })\n\n if (bounds) {\n map.fitBounds(bounds)\n }\n\n return map\n }\n\n setMapElement = (element: HTMLDivElement | null) => {\n if (element && element !== this.mapEl) {\n const map = this.constructMap(element)\n this.setState({map}, this.attachClickHandler)\n }\n\n this.mapEl = element\n }\n\n render() {\n const {children} = this.props\n const {map} = this.state\n return (\n <>\n <MapContainer ref={this.setMapElement} />\n {children && map ? children(map) : null}\n </>\n )\n }\n}\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\nconst markerPath =\n 'M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onMove?: (event: google.maps.MapMouseEvent) => void\n onClick?: (event: google.maps.MapMouseEvent) => void\n position: LatLng | google.maps.LatLng\n zIndex?: number\n opacity?: number\n label?: string\n markerRef?: React.MutableRefObject<google.maps.Marker | undefined>\n color?: {background: string; border: string; text: string}\n}\n\nexport class Marker extends React.PureComponent<Props> {\n marker: google.maps.Marker | undefined\n\n eventHandlers: {\n move?: google.maps.MapsEventListener\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {position, api, map, onMove, zIndex, opacity, label, markerRef, color} = this.props\n const {Marker: GMarker} = api\n\n let icon: google.maps.Symbol | undefined\n if (color) {\n icon = {\n path: markerPath,\n fillOpacity: 1,\n fillColor: color.background,\n strokeColor: color.border,\n strokeWeight: 2,\n anchor: new api.Point(10, 35),\n labelOrigin: new api.Point(10, 11),\n }\n }\n\n this.marker = new GMarker({\n draggable: Boolean(onMove),\n position,\n map,\n zIndex,\n opacity,\n label,\n icon,\n })\n\n if (markerRef) {\n markerRef.current = this.marker\n }\n\n this.attachMoveHandler()\n this.attachClickHandler()\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.marker) {\n return\n }\n\n const {position, onMove, label, zIndex, opacity, map} = this.props\n\n if (prevProps.onMove !== onMove) {\n this.attachMoveHandler()\n }\n\n if (!latLngAreEqual(prevProps.position, position)) {\n this.marker.setPosition(position)\n }\n\n if (prevProps.label !== label) {\n this.marker.setLabel(label || null)\n }\n\n if (prevProps.zIndex !== zIndex) {\n this.marker.setZIndex(zIndex || null)\n }\n\n if (prevProps.opacity !== opacity) {\n this.marker.setOpacity(opacity || null)\n }\n\n if (prevProps.map !== map) {\n this.marker.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n\n if (this.marker) {\n this.marker.setMap(null)\n }\n }\n\n attachMoveHandler() {\n const {api, onMove} = this.props\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n if (this.marker && onMove) {\n this.eventHandlers.move = api.event.addListener(this.marker, 'dragend', onMove)\n }\n }\n\n attachClickHandler() {\n const {api, onClick} = this.props\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n if (this.marker && onClick) {\n this.eventHandlers.click = api.event.addListener(this.marker, 'click', onClick)\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import React from 'react'\nimport {SearchInput} from '../map/SearchInput'\nimport {GoogleMap} from '../map/Map'\nimport {Marker} from '../map/Marker'\nimport {LatLng, Geopoint} from '../types'\n\nconst fallbackLatLng: LatLng = {lat: 40.7058254, lng: -74.1180863}\n\ninterface SelectProps {\n api: typeof window.google.maps\n value?: Geopoint\n onChange?: (latLng: google.maps.LatLng) => void\n defaultLocation?: LatLng\n defaultZoom?: number\n}\n\nexport class GeopointSelect extends React.PureComponent<SelectProps> {\n static defaultProps = {\n defaultZoom: 8,\n defaultLocation: {lng: 10.74609, lat: 59.91273},\n }\n\n mapRef = React.createRef<HTMLDivElement>()\n\n getCenter() {\n const {value = {}, defaultLocation = {}} = this.props\n const point: LatLng = {...fallbackLatLng, ...defaultLocation, ...value}\n return point\n }\n\n handlePlaceChanged = (place: google.maps.places.PlaceResult) => {\n if (!place.geometry?.location) {\n return\n }\n\n this.setValue(place.geometry.location)\n }\n\n handleMarkerDragEnd = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n handleMapClick = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n setValue(geoPoint: google.maps.LatLng) {\n if (this.props.onChange) {\n this.props.onChange(geoPoint)\n }\n }\n\n render() {\n const {api, defaultZoom, value, onChange} = this.props\n return (\n <GoogleMap\n api={api}\n location={this.getCenter()}\n onClick={this.handleMapClick}\n defaultZoom={defaultZoom}\n >\n {(map) => (\n <>\n <SearchInput api={api} map={map} onChange={this.handlePlaceChanged} />\n {value && (\n <Marker\n api={api}\n map={map}\n position={value}\n onMove={onChange ? this.handleMarkerDragEnd : undefined}\n />\n )}\n </>\n )}\n </GoogleMap>\n )\n }\n}\n","import styled from 'styled-components'\n\nexport const PreviewImage = styled.img`\n width: 100%;\n height: auto;\n vertical-align: top;\n`\n\nexport const DialogInnerContainer = styled.div`\n height: 40rem;\n width: 50rem;\n`\n","import {GoogleMapsInputConfig} from './index'\n\nlet config: GoogleMapsInputConfig\n\nexport function getGeoConfig(): GoogleMapsInputConfig {\n return config as GoogleMapsInputConfig\n}\n\nexport function setGeoConfig(newConfig: GoogleMapsInputConfig): void {\n config = newConfig\n}\n","import React from 'react'\nimport {uniqueId} from 'lodash'\nimport {Box, Button, Dialog, Grid} from '@sanity/ui'\nimport {EditIcon, TrashIcon} from '@sanity/icons'\nimport {ObjectInputProps, set, setIfMissing, unset, ChangeIndicator} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {Geopoint, GeopointSchemaType, LatLng} from '../types'\nimport {GeopointSelect} from './GeopointSelect'\nimport {DialogInnerContainer, PreviewImage} from './GeopointInput.styles'\nimport {GoogleMapsInputConfig} from '../index'\nimport {getGeoConfig} from '../global-workaround'\n\nconst getStaticImageUrl = (value: LatLng, apiKey: string) => {\n const loc = `${value.lat},${value.lng}`\n const params = {\n key: apiKey,\n center: loc,\n markers: loc,\n zoom: 13,\n scale: 2,\n size: '640x300',\n } as const\n const qs = Object.keys(params).reduce((res, param) => {\n return res.concat(`${param}=${encodeURIComponent(params[param as keyof typeof params])}`)\n }, [] as string[])\n\n return `https://maps.googleapis.com/maps/api/staticmap?${qs.join('&')}`\n}\n\nexport type GeopointInputProps = ObjectInputProps<Geopoint, GeopointSchemaType> & {\n geoConfig: GoogleMapsInputConfig\n}\n\ntype Focusable = any\n\ninterface InputState {\n modalOpen: boolean\n}\n\nclass GeopointInput extends React.PureComponent<GeopointInputProps, InputState> {\n _geopointInputId = uniqueId('GeopointInput')\n\n editButton: Focusable | undefined\n\n constructor(props: GeopointInputProps) {\n super(props)\n\n this.state = {\n modalOpen: false,\n }\n }\n\n setEditButton = (el: Focusable) => {\n this.editButton = el\n }\n\n focus() {\n if (this.editButton) {\n this.editButton.focus()\n }\n }\n\n handleToggleModal = () => {\n this.setState((prevState) => ({modalOpen: !prevState.modalOpen}))\n }\n\n handleCloseModal = () => {\n this.setState({modalOpen: false})\n }\n\n handleChange = (latLng: google.maps.LatLng) => {\n const {schemaType, onChange} = this.props\n onChange([\n setIfMissing({\n _type: schemaType.name,\n }),\n set(latLng.lat(), ['lat']),\n set(latLng.lng(), ['lng']),\n ])\n }\n\n handleClear = () => {\n const {onChange} = this.props\n onChange(unset())\n }\n\n render() {\n const {value, readOnly, geoConfig: config, path, changed, focused} = this.props\n\n const {modalOpen} = this.state\n\n if (!config || !config.apiKey) {\n return (\n <div>\n <p>\n The <a href=\"https://sanity.io/docs/schema-types/geopoint-type\">Geopoint type</a> needs\n a Google Maps API key with access to:\n </p>\n <ul>\n <li>Google Maps JavaScript API</li>\n <li>Google Places API Web Service</li>\n <li>Google Static Maps API</li>\n </ul>\n <p>\n Please enter the API key with access to these services in your googleMapsInput plugin\n config.\n </p>\n </div>\n )\n }\n\n return (\n <>\n {value && (\n <ChangeIndicator path={path} isChanged={changed} hasFocus={!!focused}>\n <PreviewImage src={getStaticImageUrl(value, config.apiKey)} alt=\"Map location\" />\n </ChangeIndicator>\n )}\n\n {!readOnly && (\n <Box marginTop={4}>\n <Grid columns={2} gap={2}>\n <Button\n mode=\"ghost\"\n icon={value && EditIcon}\n padding={3}\n ref={this.setEditButton}\n text={value ? 'Edit' : 'Set location'}\n onClick={this.handleToggleModal}\n />\n\n {value && (\n <Button\n tone=\"critical\"\n icon={TrashIcon}\n padding={3}\n mode=\"ghost\"\n text={'Remove'}\n onClick={this.handleClear}\n />\n )}\n </Grid>\n </Box>\n )}\n\n {modalOpen && (\n <Dialog\n id={`${this._geopointInputId}_dialog`}\n onClose={this.handleCloseModal}\n header=\"Place the marker on the map\"\n width={1}\n >\n <DialogInnerContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => (\n <GeopointSelect\n api={api}\n value={value || undefined}\n onChange={readOnly ? undefined : this.handleChange}\n defaultLocation={config.defaultLocation}\n defaultZoom={config.defaultZoom}\n />\n )}\n </GoogleMapsLoadProxy>\n </DialogInnerContainer>\n </Dialog>\n )}\n </>\n )\n }\n}\n\nexport default GeopointInput\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n from: LatLng\n to: LatLng\n color?: {background: string; border: string; text: string}\n zIndex?: number\n arrowRef?: React.MutableRefObject<google.maps.Polyline | undefined>\n onClick?: (event: google.maps.MapMouseEvent) => void\n}\n\nexport class Arrow extends React.PureComponent<Props> {\n line: google.maps.Polyline | undefined\n\n eventHandlers: {\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {from, to, api, map, zIndex, onClick, color, arrowRef} = this.props\n const lineSymbol = {\n path: api.SymbolPath.FORWARD_OPEN_ARROW,\n }\n\n this.line = new api.Polyline({\n map,\n zIndex,\n path: [from, to],\n icons: [{icon: lineSymbol, offset: '50%'}],\n strokeOpacity: 0.55,\n strokeColor: color ? color.text : 'black',\n })\n\n if (onClick) {\n this.eventHandlers.click = api.event.addListener(this.line, 'click', onClick)\n }\n\n if (arrowRef) {\n arrowRef.current = this.line\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.line) {\n return\n }\n\n const {from, to, map} = this.props\n if (!latLngAreEqual(prevProps.from, from) || !latLngAreEqual(prevProps.to, to)) {\n this.line.setPath([from, to])\n }\n\n if (prevProps.map !== map) {\n this.line.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.line) {\n this.line.setMap(null)\n }\n\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import * as React from 'react'\nimport {useUserColor, ObjectDiff} from 'sanity'\nimport {Marker} from '../map/Marker'\nimport {Arrow} from '../map/Arrow'\nimport {Geopoint} from '../types'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n diff: ObjectDiff<Geopoint>\n label?: string\n}\n\nexport function GeopointMove({diff, api, map, label}: Props) {\n const {fromValue: from, toValue: to} = diff\n const annotation = diff.isChanged ? diff.annotation : undefined\n const userColor = useUserColor(annotation ? annotation.author : null) || undefined\n const fromRef = React.useRef<google.maps.Marker>()\n const toRef = React.useRef<google.maps.Marker>()\n\n return (\n <>\n {from && (\n <Marker\n api={api}\n map={map}\n position={from}\n zIndex={0}\n opacity={0.55}\n markerRef={fromRef}\n color={userColor}\n />\n )}\n {from && to && <Arrow api={api} map={map} from={from} to={to} zIndex={1} color={userColor} />}\n {to && (\n <Marker\n api={api}\n map={map}\n position={to}\n zIndex={2}\n markerRef={toRef}\n label={label}\n color={userColor}\n />\n )}\n </>\n )\n}\n","import styled from 'styled-components'\n\nexport const RootContainer = styled.div`\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n`\n","import * as React from 'react'\nimport {ArrayDiff, ObjectDiff, Diff, DiffProps as GenericDiffProps, DiffComponent} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ArrayDiff<Geopoint>>\n\nexport const GeopointArrayDiff: DiffComponent<ArrayDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof google.maps}) {\n const fromValue = (diff.fromValue || []).filter(hasCoordinates)\n const toValue = (diff.toValue || []).filter(hasCoordinates)\n if (fromValue.length === 0 && toValue.length === 0) {\n return null\n }\n\n const bounds = getBounds(fromValue, toValue, api)\n return (\n <GoogleMap\n api={api}\n location={bounds.getCenter().toJSON()}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n >\n {(map) => (\n <>\n {diff.items.map(({toIndex, diff: pointDiff}) => {\n if (!isChangeDiff(pointDiff)) {\n return null\n }\n\n return (\n <GeopointMove\n key={toIndex}\n api={api}\n map={map}\n diff={pointDiff}\n label={`${toIndex}`}\n />\n )\n })}\n </>\n )}\n </GoogleMap>\n )\n}\n\nfunction isChangeDiff(diff: Diff): diff is ObjectDiff<Geopoint> {\n return diff.action !== 'unchanged' && diff.type === 'object'\n}\n\nfunction hasCoordinates(point: Partial<Geopoint>): point is Geopoint {\n return typeof point.lat === 'number' && typeof point.lng === 'number'\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral[] | null | undefined,\n toValue: google.maps.LatLngLiteral[] | null | undefined,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n const bounds = new api.LatLngBounds()\n const points = [...(fromValue || []), ...(toValue || [])]\n points.forEach((point) => bounds.extend(point))\n return bounds\n}\n","import * as React from 'react'\nimport {\n DiffComponent,\n ObjectDiff,\n DiffProps as GenericDiffProps,\n DiffTooltip,\n getAnnotationAtPath,\n} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ObjectDiff<Geopoint>>\n\nexport const GeopointFieldDiff: DiffComponent<ObjectDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof window.google.maps}) {\n const {fromValue, toValue} = diff\n const annotation =\n getAnnotationAtPath(diff, ['lat']) ||\n getAnnotationAtPath(diff, ['lng']) ||\n getAnnotationAtPath(diff, [])\n\n const center = getCenter(diff, api)\n const bounds = fromValue && toValue ? getBounds(fromValue, toValue, api) : undefined\n\n return (\n <DiffTooltip annotations={annotation ? [annotation] : []} description={getAction(diff)}>\n <div>\n <GoogleMap\n api={api}\n location={center}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n scrollWheel={false}\n >\n {(map) => <GeopointMove api={api} map={map} diff={diff} />}\n </GoogleMap>\n </div>\n </DiffTooltip>\n )\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral,\n toValue: google.maps.LatLngLiteral,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n return new api.LatLngBounds().extend(fromValue).extend(toValue)\n}\n\nfunction getCenter(\n diff: DiffProps['diff'],\n api: typeof window.google.maps\n): google.maps.LatLngLiteral {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return getBounds(fromValue, toValue, api).getCenter().toJSON()\n }\n\n if (fromValue) {\n return fromValue\n }\n\n if (toValue) {\n return toValue\n }\n\n throw new Error('Neither a from or a to value present')\n}\n\nfunction getAction(diff: ObjectDiff<Geopoint>) {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return 'Moved'\n } else if (fromValue) {\n return 'Removed'\n } else if (toValue) {\n return 'Added'\n }\n\n return 'Unchanged'\n}\n","import React from 'react'\nimport {definePlugin, SchemaType} from 'sanity'\nimport GeopointInput, {GeopointInputProps} from './input/GeopointInput'\nimport {setGeoConfig} from './global-workaround'\nimport {GeopointSchemaType} from './types'\n\nexport interface GoogleMapsInputConfig {\n apiKey: string\n defaultZoom?: number\n defaultLocale?: string\n defaultLocation?: {\n lat: number\n lng: number\n }\n}\n\nexport const googleMapsInput = definePlugin<GoogleMapsInputConfig>((config) => {\n setGeoConfig(config)\n return {\n name: 'google-maps-input',\n form: {\n components: {\n input(props) {\n if (isGeopoint(props.schemaType)) {\n const castedProps = props as unknown as Omit<GeopointInputProps, 'geoConfig'>\n return <GeopointInput {...castedProps} geoConfig={config} />\n }\n return props.renderDefault(props)\n },\n },\n },\n }\n})\n\nfunction isGeopoint(schemaType: SchemaType): schemaType is GeopointSchemaType {\n return isType('geopoint', schemaType)\n}\n\nfunction isType(name: string, schema?: SchemaType): boolean {\n if (schema?.name === name) {\n return true\n // eslint-disable-next-line no-negated-condition\n } else if (!schema?.name) {\n return false\n }\n return isType(name, schema?.type)\n}\n"],"names":["callbackName","locale","window","navigator","language","subject","coeerceError","event","error","Error","message","isErrorEvent","LoadError","props","_a","jsxs","Card","tone","radius","children","jsx","Box","as","paddingX","paddingTop","paddingBottom","Text","weight","isAuthError","AuthError","Fragment","Code","size","GoogleMapsLoadProxy","React","Component","constructor","super","this","state","loadState","sync","loadSubscription","config","selectedLocale","defaultLocale","BehaviorSubject","next","api","google","maps","script","document","createElement","onerror","source","lineno","colno","src","concat","apiKey","getElementsByTagName","appendChild","loadGoogleMapsApi","subscribe","setState","componentWillUnmount","unsubscribe","render","WrapperContainer","styled","div","_templateObject","_taggedTemplateLiteral","SearchInput","PureComponent","arguments","searchInputRef","createRef","handleChange","autoComplete","onChange","getPlace","current","value","componentDidMount","input","map","Circle","places","searchBounds","center","getCenter","getBounds","Autocomplete","bounds","types","addListener","TextInput","name","ref","placeholder","padding","latLngAreEqual","latLng1","latLng2","lat1","lat","lng1","lng","lat2","lng2","MapContainer","_templateObject2","GoogleMap","mapRef","mapEl","attachClickHandler","onClick","clickHandler","remove","setMapElement","element","constructMap","componentDidUpdate","prevProps","location","panTo","equals","fitBounds","LatLng","el","defaultZoom","mapTypeControl","controlSize","scrollWheel","Map","zoom","scrollwheel","streetViewControl","defaultProps","Marker","eventHandlers","position","onMove","zIndex","opacity","label","markerRef","color","GMarker","icon","path","fillOpacity","fillColor","background","strokeColor","border","strokeWeight","anchor","Point","labelOrigin","marker","draggable","Boolean","attachMoveHandler","setPosition","setLabel","setZIndex","setOpacity","setMap","move","click","fallbackLatLng","GeopointSelect","handlePlaceChanged","place","geometry","setValue","handleMarkerDragEnd","latLng","handleMapClick","defaultLocation","geoPoint","PreviewImage","img","_templateObject3","DialogInnerContainer","_templateObject4","getGeoConfig","setGeoConfig","newConfig","getStaticImageUrl","loc","params","key","markers","scale","qs","Object","keys","reduce","res","param","encodeURIComponent","join","GeopointInput","_geopointInputId","uniqueId","setEditButton","editButton","handleToggleModal","prevState","modalOpen","handleCloseModal","schemaType","setIfMissing","_type","set","handleClear","unset","focus","readOnly","geoConfig","changed","focused","ChangeIndicator","isChanged","hasFocus","alt","marginTop","Grid","columns","gap","Button","mode","EditIcon","text","TrashIcon","Dialog","id","onClose","header","width","href","Arrow","from","to","arrowRef","lineSymbol","SymbolPath","FORWARD_OPEN_ARROW","line","Polyline","icons","offset","strokeOpacity","setPath","GeopointMove","_ref","diff","fromValue","toValue","annotation","userColor","useUserColor","author","fromRef","useRef","toRef","RootContainer","_templateObject5","GeopointDiff","_ref3","filter","hasCoordinates","length","LatLngBounds","forEach","point","extend","toJSON","items","_ref4","toIndex","pointDiff","action","type","isChangeDiff","_ref6","getAnnotationAtPath","DiffTooltip","annotations","description","getAction","googleMapsInput","definePlugin","form","components","isType","castedProps","renderDefault","schema","_ref2","_ref5"],"mappings":"67CAUA,MAAMA,EAAe,kCAEfC,EAA4B,oBAAXC,QAA0BA,OAAOC,UAAUC,UAAa,KAsB/E,IAAIC,EAwCJ,SAASC,EAAaC,EAAuBC,GAC3C,OAAIA,IAIiB,iBAAVD,EACF,IAAIE,MAAMF,GAGZ,IAAIE,MAGb,SAAsBF,GACpB,GAAqB,iBAAVA,GAAgC,OAAVA,EACxB,OAAA,EAGL,KAAE,YAAaA,GACV,OAAA,EAGF,MAAyC,iBAAjCA,EAAqBG,OACtC,CAbmBC,CAAaJ,GAASA,EAAMG,QAAU,kCACzD,CC/EO,SAASE,EAAUC,GAL1B,IAAAC,EAME,OACGC,EAAAA,KAAAC,EAAAA,KAAA,CAAKC,KAAK,WAAWC,OAAQ,EAC5BC,SAAA,CAACC,EAAAA,IAAAC,EAAAA,IAAA,CAAIC,GAAG,SAASC,SAAU,EAAGC,WAAY,EAAGC,cAAe,EAC1DN,SAACC,EAAAA,IAAAM,OAAA,CAAKJ,GAAG,KAAKK,OAAO,OAAOR,SAAA,iCAK7BC,EAAAA,IAAAC,EAAAA,IAAA,CAAIE,SAAU,EAAGC,WAAY,EAAGC,cAAe,EAC7CN,SAAMN,EAAAe,YACJR,EAAAA,IAAAS,EAAA,IAEDd,EAAAA,KAAAe,WAAA,CACEX,SAAA,CAACC,EAAAA,IAAAM,EAAAA,KAAA,CAAKJ,GAAG,KAAKH,SAAA,mBACbC,EAAAA,IAAA,MAAA,CACCD,SAACC,EAAAA,IAAAW,OAAA,CAAKC,KAAM,EAAIb,SAAW,UAAAN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AA,EAAAA,EAAQ3M,OAGbwM,EAAOxM,EAAM,MAAA2M,OAAA,EAAAA,EAAQf,KAC9B,2BFnCqEgB,IAAwB,IAAvB3C,KAACA,EAAA7C,WAAMA,GAAgBwF,EAC3F,OACG3R,EAAAA,IAAA0P,EAAA,CACC3P,SAACC,EAAAA,IAAAa,EAAA,CAAoBU,OAAQkJ,IAC1B1K,SAAC6B,GAAS5B,EAAAA,IAAA4P,EAAA,CAAahO,MAAUoN,OAAY7C,kBAElD,4BCAkEyF,IAAwB,IAAvB5C,KAACA,EAAA7C,WAAMA,GAAgByF,EAC5F,OACG5R,EAAAA,IAAA0P,EAAA,CACC3P,SAACC,EAAAA,IAAAa,EAAA,CAAoBU,OAAQkJ,IAC1B1K,SAAC6B,GAAS5B,EAAAA,IAAA4P,EAAA,CAAahO,MAAUoN,OAAY7C,kBAElD"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/loader/loadGoogleMapsApi.ts","../src/loader/LoadError.tsx","../src/loader/GoogleMapsLoadProxy.tsx","../src/map/SearchInput.styles.tsx","../src/map/SearchInput.tsx","../src/map/util.ts","../src/map/Map.styles.tsx","../src/map/Map.tsx","../src/map/Marker.tsx","../src/input/GeopointSelect.tsx","../src/input/GeopointInput.styles.tsx","../src/global-workaround.ts","../src/input/GeopointInput.tsx","../src/map/Arrow.tsx","../src/diff/GeopointMove.tsx","../src/diff/GeopointFieldDiff.styles.tsx","../src/diff/GeopointArrayDiff.tsx","../src/diff/GeopointFieldDiff.tsx","../src/plugin.tsx"],"sourcesContent":["declare global {\n interface Window {\n gm_authFailure: any\n ___sanity_googleMapsApiCallback: any\n }\n}\n\nconst callbackName = '___sanity_googleMapsApiCallback'\nconst authFailureCallbackName = 'gm_authFailure'\n\nexport class AuthError extends Error {}\n\nfunction _loadGoogleMapsApi(config: {locale: string; apiKey: string}) {\n return new Promise<typeof window.google.maps>((resolve, reject) => {\n window[authFailureCallbackName] = () => {\n reject(new AuthError('Authentication error when loading Google Maps API.'))\n }\n\n window[callbackName] = () => {\n resolve(window.google.maps)\n }\n\n const script = document.createElement('script')\n script.onerror = (\n event: Event | string,\n source?: string,\n lineno?: number,\n colno?: number,\n error?: Error\n ) => reject(new Error(coeerceError(event, error)))\n\n script.src = `https://maps.googleapis.com/maps/api/js?key=${config.apiKey}&libraries=places&callback=${callbackName}&language=${config.locale}`\n document.getElementsByTagName('head')[0].appendChild(script)\n }).finally(() => {\n delete window[callbackName]\n delete window[authFailureCallbackName]\n })\n}\n\nlet memo: Promise<typeof window.google.maps> | null = null\nexport function loadGoogleMapsApi(config: {locale: string; apiKey: string}) {\n if (memo) {\n return memo\n }\n memo = _loadGoogleMapsApi(config)\n memo.catch(() => {\n memo = null\n })\n return memo\n}\nfunction coeerceError(event: Event | string, error?: Error): string {\n if (error) {\n return error.message\n }\n\n if (typeof event === 'string') {\n return event\n }\n\n return isErrorEvent(event) ? event.message : 'Failed to load Google Maps API'\n}\n\nfunction isErrorEvent(event: unknown): event is ErrorEvent {\n if (typeof event !== 'object' || event === null) {\n return false\n }\n\n if (!('message' in event)) {\n return false\n }\n\n return typeof (event as ErrorEvent).message === 'string'\n}\n","import * as React from 'react'\nimport {Card, Box, Text, Code} from '@sanity/ui'\n\ntype Props = {error: {message?: string}; isAuthError: false} | {isAuthError: true}\n\nexport function LoadError(props: Props) {\n return (\n <Card tone=\"critical\" radius={1}>\n <Box as=\"header\" paddingX={4} paddingTop={4} paddingBottom={1}>\n <Text as=\"h2\" weight=\"bold\">\n Google Maps failed to load\n </Text>\n </Box>\n\n <Box paddingX={4} paddingTop={4} paddingBottom={1}>\n {props.isAuthError ? (\n <AuthError />\n ) : (\n <>\n <Text as=\"h3\">Error details:</Text>\n <pre>\n <Code size={1}>{'error' in props && props.error?.message}</Code>\n </pre>\n </>\n )}\n </Box>\n </Card>\n )\n}\n\nfunction AuthError() {\n return (\n <Text>\n <p>The error appears to be related to authentication</p>\n <p>Common causes include:</p>\n <ul>\n <li>Incorrect API key</li>\n <li>Referer not allowed</li>\n <li>Missing authentication scope</li>\n </ul>\n <p>Check the browser developer tools for more information.</p>\n </Text>\n )\n}\n","import React, {useEffect, useState} from 'react'\nimport {AuthError, loadGoogleMapsApi} from './loadGoogleMapsApi'\nimport {LoadError as LoadErrorView} from './LoadError'\nimport {GoogleMapsInputConfig} from '../index'\n\ninterface LoadProps {\n children: (api: typeof window.google.maps) => React.ReactElement\n config: GoogleMapsInputConfig\n}\n\nconst browserLocale = (typeof window !== 'undefined' && window.navigator.language) || 'en'\n\ntype LoadState =\n | {\n type: 'loading'\n }\n | {\n type: 'loaded'\n api: typeof window.google.maps\n }\n | {\n type: 'error'\n error: {type: 'loadError' | 'authError'; message: string}\n }\n\nfunction useLoadGoogleMapsApi(config: {defaultLocale?: string; apiKey: string}): LoadState {\n const locale = config.defaultLocale || browserLocale || 'en-US'\n\n const [state, setState] = useState<LoadState>({type: 'loading'})\n\n useEffect(() => {\n loadGoogleMapsApi({locale, apiKey: config.apiKey}).then(\n (api) => setState({type: 'loaded', api}),\n (err) =>\n setState({\n type: 'error',\n error: {type: err instanceof AuthError ? 'authError' : 'loadError', message: err.message},\n })\n )\n }, [locale, config.apiKey])\n return state\n}\n\nexport function GoogleMapsLoadProxy(props: LoadProps) {\n const loadState = useLoadGoogleMapsApi(props.config)\n switch (loadState.type) {\n case 'error':\n return (\n <LoadErrorView error={loadState.error} isAuthError={loadState.error.type === 'authError'} />\n )\n case 'loading':\n return <div>Loading Google Maps API</div>\n case 'loaded':\n return props.children(loadState.api)\n default:\n return null\n }\n}\n","import styled from 'styled-components'\n\nexport const WrapperContainer = styled.div`\n position: absolute;\n right: 10px;\n top: 10px;\n width: 220px;\n`\n","import * as React from 'react'\nimport {TextInput} from '@sanity/ui'\nimport {WrapperContainer} from './SearchInput.styles'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onChange: (result: google.maps.places.PlaceResult) => void\n}\n\nexport class SearchInput extends React.PureComponent<Props> {\n searchInputRef = React.createRef<HTMLInputElement>()\n autoComplete: google.maps.places.Autocomplete | undefined\n\n handleChange = () => {\n if (!this.autoComplete) {\n return\n }\n\n this.props.onChange(this.autoComplete.getPlace())\n\n if (this.searchInputRef.current) {\n this.searchInputRef.current.value = ''\n }\n }\n\n componentDidMount() {\n const input = this.searchInputRef.current\n if (!input) {\n return\n }\n\n const {api, map} = this.props\n const {Circle, places, event} = api\n const searchBounds = new Circle({center: map.getCenter(), radius: 100}).getBounds()!\n this.autoComplete = new places.Autocomplete(input, {\n bounds: searchBounds,\n types: [], // return all kinds of places\n })\n\n event.addListener(this.autoComplete, 'place_changed', this.handleChange)\n }\n\n render() {\n return (\n <WrapperContainer>\n <TextInput\n name=\"place\"\n ref={this.searchInputRef}\n placeholder=\"Search for place or address\"\n padding={4}\n />\n </WrapperContainer>\n )\n }\n}\n","import {LatLng} from '../types'\n\nexport function latLngAreEqual(\n latLng1: LatLng | google.maps.LatLng,\n latLng2: LatLng | google.maps.LatLng\n): boolean {\n const lat1 = typeof latLng1.lat === 'function' ? latLng1.lat() : latLng1.lat\n const lng1 = typeof latLng1.lng === 'function' ? latLng1.lng() : latLng1.lng\n\n const lat2 = typeof latLng2.lat === 'function' ? latLng2.lat() : latLng2.lat\n const lng2 = typeof latLng2.lng === 'function' ? latLng2.lng() : latLng2.lng\n\n return lat1 === lat2 && lng1 === lng2\n}\n","import styled from 'styled-components'\n\nexport const MapContainer = styled.div`\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n`\n","import React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\nimport {MapContainer} from './Map.styles'\n\ninterface MapProps {\n api: typeof window.google.maps\n location: LatLng\n bounds?: google.maps.LatLngBounds\n defaultZoom?: number\n mapTypeControl?: boolean\n scrollWheel?: boolean\n controlSize?: number\n onClick?: (event: google.maps.MapMouseEvent) => void\n children?: (map: google.maps.Map) => React.ReactElement\n}\n\ninterface MapState {\n map: google.maps.Map | undefined\n}\n\nexport class GoogleMap extends React.PureComponent<MapProps, MapState> {\n static defaultProps = {\n defaultZoom: 8,\n scrollWheel: true,\n }\n\n state: MapState = {map: undefined}\n clickHandler: google.maps.MapsEventListener | undefined\n mapRef = React.createRef<HTMLDivElement>()\n mapEl: HTMLDivElement | null = null\n\n componentDidMount() {\n this.attachClickHandler()\n }\n\n attachClickHandler = () => {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {api, onClick} = this.props\n const {event} = api\n\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n\n if (onClick) {\n this.clickHandler = event.addListener(map, 'click', onClick)\n }\n }\n\n componentDidUpdate(prevProps: MapProps) {\n const map = this.state.map\n if (!map) {\n return\n }\n\n const {onClick, location, bounds} = this.props\n\n if (prevProps.onClick !== onClick) {\n this.attachClickHandler()\n }\n\n if (!latLngAreEqual(prevProps.location, location)) {\n map.panTo(this.getCenter())\n }\n\n if (bounds && (!prevProps.bounds || !bounds.equals(prevProps.bounds))) {\n map.fitBounds(bounds)\n }\n }\n\n componentWillUnmount() {\n if (this.clickHandler) {\n this.clickHandler.remove()\n }\n }\n\n getCenter(): google.maps.LatLng {\n const {location, api} = this.props\n return new api.LatLng(location.lat, location.lng)\n }\n\n constructMap(el: HTMLDivElement) {\n const {defaultZoom, api, mapTypeControl, controlSize, bounds, scrollWheel} = this.props\n\n const map = new api.Map(el, {\n zoom: defaultZoom,\n center: this.getCenter(),\n scrollwheel: scrollWheel,\n streetViewControl: false,\n mapTypeControl,\n controlSize,\n })\n\n if (bounds) {\n map.fitBounds(bounds)\n }\n\n return map\n }\n\n setMapElement = (element: HTMLDivElement | null) => {\n if (element && element !== this.mapEl) {\n const map = this.constructMap(element)\n this.setState({map}, this.attachClickHandler)\n }\n\n this.mapEl = element\n }\n\n render() {\n const {children} = this.props\n const {map} = this.state\n return (\n <>\n <MapContainer ref={this.setMapElement} />\n {children && map ? children(map) : null}\n </>\n )\n }\n}\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\nconst markerPath =\n 'M 3.052 3.7 C 1.56 5.293 0.626 7.612 0.663 9.793 C 0.738 14.352 2.793 16.077 6.078 22.351 C 7.263 25.111 8.497 28.032 9.672 32.871 C 9.835 33.584 9.994 34.246 10.069 34.305 C 10.143 34.362 10.301 33.697 10.465 32.983 C 11.639 28.145 12.875 25.226 14.059 22.466 C 17.344 16.192 19.398 14.466 19.474 9.908 C 19.511 7.727 18.574 5.405 17.083 3.814 C 15.379 1.994 12.809 0.649 10.069 0.593 C 7.328 0.536 4.756 1.882 3.052 3.7 Z'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n onMove?: (event: google.maps.MapMouseEvent) => void\n onClick?: (event: google.maps.MapMouseEvent) => void\n position: LatLng | google.maps.LatLng\n zIndex?: number\n opacity?: number\n label?: string\n markerRef?: React.MutableRefObject<google.maps.Marker | undefined>\n color?: {background: string; border: string; text: string}\n}\n\nexport class Marker extends React.PureComponent<Props> {\n marker: google.maps.Marker | undefined\n\n eventHandlers: {\n move?: google.maps.MapsEventListener\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {position, api, map, onMove, zIndex, opacity, label, markerRef, color} = this.props\n const {Marker: GMarker} = api\n\n let icon: google.maps.Symbol | undefined\n if (color) {\n icon = {\n path: markerPath,\n fillOpacity: 1,\n fillColor: color.background,\n strokeColor: color.border,\n strokeWeight: 2,\n anchor: new api.Point(10, 35),\n labelOrigin: new api.Point(10, 11),\n }\n }\n\n this.marker = new GMarker({\n draggable: Boolean(onMove),\n position,\n map,\n zIndex,\n opacity,\n label,\n icon,\n })\n\n if (markerRef) {\n markerRef.current = this.marker\n }\n\n this.attachMoveHandler()\n this.attachClickHandler()\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.marker) {\n return\n }\n\n const {position, onMove, label, zIndex, opacity, map} = this.props\n\n if (prevProps.onMove !== onMove) {\n this.attachMoveHandler()\n }\n\n if (!latLngAreEqual(prevProps.position, position)) {\n this.marker.setPosition(position)\n }\n\n if (prevProps.label !== label) {\n this.marker.setLabel(label || null)\n }\n\n if (prevProps.zIndex !== zIndex) {\n this.marker.setZIndex(zIndex || null)\n }\n\n if (prevProps.opacity !== opacity) {\n this.marker.setOpacity(opacity || null)\n }\n\n if (prevProps.map !== map) {\n this.marker.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n\n if (this.marker) {\n this.marker.setMap(null)\n }\n }\n\n attachMoveHandler() {\n const {api, onMove} = this.props\n if (this.eventHandlers.move) {\n this.eventHandlers.move.remove()\n }\n if (this.marker && onMove) {\n this.eventHandlers.move = api.event.addListener(this.marker, 'dragend', onMove)\n }\n }\n\n attachClickHandler() {\n const {api, onClick} = this.props\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n if (this.marker && onClick) {\n this.eventHandlers.click = api.event.addListener(this.marker, 'click', onClick)\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import React from 'react'\nimport {SearchInput} from '../map/SearchInput'\nimport {GoogleMap} from '../map/Map'\nimport {Marker} from '../map/Marker'\nimport {LatLng, Geopoint} from '../types'\n\nconst fallbackLatLng: LatLng = {lat: 40.7058254, lng: -74.1180863}\n\ninterface SelectProps {\n api: typeof window.google.maps\n value?: Geopoint\n onChange?: (latLng: google.maps.LatLng) => void\n defaultLocation?: LatLng\n defaultZoom?: number\n}\n\nexport class GeopointSelect extends React.PureComponent<SelectProps> {\n static defaultProps = {\n defaultZoom: 8,\n defaultLocation: {lng: 10.74609, lat: 59.91273},\n }\n\n mapRef = React.createRef<HTMLDivElement>()\n\n getCenter() {\n const {value = {}, defaultLocation = {}} = this.props\n const point: LatLng = {...fallbackLatLng, ...defaultLocation, ...value}\n return point\n }\n\n handlePlaceChanged = (place: google.maps.places.PlaceResult) => {\n if (!place.geometry?.location) {\n return\n }\n\n this.setValue(place.geometry.location)\n }\n\n handleMarkerDragEnd = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n handleMapClick = (event: google.maps.MapMouseEvent) => {\n if (event.latLng) this.setValue(event.latLng)\n }\n\n setValue(geoPoint: google.maps.LatLng) {\n if (this.props.onChange) {\n this.props.onChange(geoPoint)\n }\n }\n\n render() {\n const {api, defaultZoom, value, onChange} = this.props\n return (\n <GoogleMap\n api={api}\n location={this.getCenter()}\n onClick={this.handleMapClick}\n defaultZoom={defaultZoom}\n >\n {(map) => (\n <>\n <SearchInput api={api} map={map} onChange={this.handlePlaceChanged} />\n {value && (\n <Marker\n api={api}\n map={map}\n position={value}\n onMove={onChange ? this.handleMarkerDragEnd : undefined}\n />\n )}\n </>\n )}\n </GoogleMap>\n )\n }\n}\n","import styled from 'styled-components'\n\nexport const PreviewImage = styled.img`\n width: 100%;\n height: auto;\n vertical-align: top;\n`\n\nexport const DialogInnerContainer = styled.div`\n height: 40rem;\n width: 50rem;\n`\n","import {GoogleMapsInputConfig} from './index'\n\nlet config: GoogleMapsInputConfig\n\nexport function getGeoConfig(): GoogleMapsInputConfig {\n return config as GoogleMapsInputConfig\n}\n\nexport function setGeoConfig(newConfig: GoogleMapsInputConfig): void {\n config = newConfig\n}\n","import React from 'react'\nimport {uniqueId} from 'lodash'\nimport {Box, Button, Dialog, Grid} from '@sanity/ui'\nimport {EditIcon, TrashIcon} from '@sanity/icons'\nimport {ObjectInputProps, set, setIfMissing, unset, ChangeIndicator} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {Geopoint, GeopointSchemaType, LatLng} from '../types'\nimport {GeopointSelect} from './GeopointSelect'\nimport {DialogInnerContainer, PreviewImage} from './GeopointInput.styles'\nimport {GoogleMapsInputConfig} from '../index'\nimport {getGeoConfig} from '../global-workaround'\n\nconst getStaticImageUrl = (value: LatLng, apiKey: string) => {\n const loc = `${value.lat},${value.lng}`\n const params = {\n key: apiKey,\n center: loc,\n markers: loc,\n zoom: 13,\n scale: 2,\n size: '640x300',\n } as const\n const qs = Object.keys(params).reduce((res, param) => {\n return res.concat(`${param}=${encodeURIComponent(params[param as keyof typeof params])}`)\n }, [] as string[])\n\n return `https://maps.googleapis.com/maps/api/staticmap?${qs.join('&')}`\n}\n\nexport type GeopointInputProps = ObjectInputProps<Geopoint, GeopointSchemaType> & {\n geoConfig: GoogleMapsInputConfig\n}\n\ntype Focusable = any\n\ninterface InputState {\n modalOpen: boolean\n}\n\nclass GeopointInput extends React.PureComponent<GeopointInputProps, InputState> {\n _geopointInputId = uniqueId('GeopointInput')\n\n editButton: Focusable | undefined\n\n constructor(props: GeopointInputProps) {\n super(props)\n\n this.state = {\n modalOpen: false,\n }\n }\n\n setEditButton = (el: Focusable) => {\n this.editButton = el\n }\n\n focus() {\n if (this.editButton) {\n this.editButton.focus()\n }\n }\n\n handleToggleModal = () => {\n this.setState((prevState) => ({modalOpen: !prevState.modalOpen}))\n }\n\n handleCloseModal = () => {\n this.setState({modalOpen: false})\n }\n\n handleChange = (latLng: google.maps.LatLng) => {\n const {schemaType, onChange} = this.props\n onChange([\n setIfMissing({\n _type: schemaType.name,\n }),\n set(latLng.lat(), ['lat']),\n set(latLng.lng(), ['lng']),\n ])\n }\n\n handleClear = () => {\n const {onChange} = this.props\n onChange(unset())\n }\n\n render() {\n const {value, readOnly, geoConfig: config, path, changed, focused} = this.props\n\n const {modalOpen} = this.state\n\n if (!config || !config.apiKey) {\n return (\n <div>\n <p>\n The <a href=\"https://sanity.io/docs/schema-types/geopoint-type\">Geopoint type</a> needs\n a Google Maps API key with access to:\n </p>\n <ul>\n <li>Google Maps JavaScript API</li>\n <li>Google Places API Web Service</li>\n <li>Google Static Maps API</li>\n </ul>\n <p>\n Please enter the API key with access to these services in your googleMapsInput plugin\n config.\n </p>\n </div>\n )\n }\n\n return (\n <>\n {value && (\n <ChangeIndicator path={path} isChanged={changed} hasFocus={!!focused}>\n <PreviewImage src={getStaticImageUrl(value, config.apiKey)} alt=\"Map location\" />\n </ChangeIndicator>\n )}\n\n {!readOnly && (\n <Box marginTop={4}>\n <Grid columns={2} gap={2}>\n <Button\n mode=\"ghost\"\n icon={value && EditIcon}\n padding={3}\n ref={this.setEditButton}\n text={value ? 'Edit' : 'Set location'}\n onClick={this.handleToggleModal}\n />\n\n {value && (\n <Button\n tone=\"critical\"\n icon={TrashIcon}\n padding={3}\n mode=\"ghost\"\n text={'Remove'}\n onClick={this.handleClear}\n />\n )}\n </Grid>\n </Box>\n )}\n\n {modalOpen && (\n <Dialog\n id={`${this._geopointInputId}_dialog`}\n onClose={this.handleCloseModal}\n header=\"Place the marker on the map\"\n width={1}\n >\n <DialogInnerContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => (\n <GeopointSelect\n api={api}\n value={value || undefined}\n onChange={readOnly ? undefined : this.handleChange}\n defaultLocation={config.defaultLocation}\n defaultZoom={config.defaultZoom}\n />\n )}\n </GoogleMapsLoadProxy>\n </DialogInnerContainer>\n </Dialog>\n )}\n </>\n )\n }\n}\n\nexport default GeopointInput\n","import * as React from 'react'\nimport {LatLng} from '../types'\nimport {latLngAreEqual} from './util'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n from: LatLng\n to: LatLng\n color?: {background: string; border: string; text: string}\n zIndex?: number\n arrowRef?: React.MutableRefObject<google.maps.Polyline | undefined>\n onClick?: (event: google.maps.MapMouseEvent) => void\n}\n\nexport class Arrow extends React.PureComponent<Props> {\n line: google.maps.Polyline | undefined\n\n eventHandlers: {\n click?: google.maps.MapsEventListener\n } = {}\n\n componentDidMount() {\n const {from, to, api, map, zIndex, onClick, color, arrowRef} = this.props\n const lineSymbol = {\n path: api.SymbolPath.FORWARD_OPEN_ARROW,\n }\n\n this.line = new api.Polyline({\n map,\n zIndex,\n path: [from, to],\n icons: [{icon: lineSymbol, offset: '50%'}],\n strokeOpacity: 0.55,\n strokeColor: color ? color.text : 'black',\n })\n\n if (onClick) {\n this.eventHandlers.click = api.event.addListener(this.line, 'click', onClick)\n }\n\n if (arrowRef) {\n arrowRef.current = this.line\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (!this.line) {\n return\n }\n\n const {from, to, map} = this.props\n if (!latLngAreEqual(prevProps.from, from) || !latLngAreEqual(prevProps.to, to)) {\n this.line.setPath([from, to])\n }\n\n if (prevProps.map !== map) {\n this.line.setMap(map)\n }\n }\n\n componentWillUnmount() {\n if (this.line) {\n this.line.setMap(null)\n }\n\n if (this.eventHandlers.click) {\n this.eventHandlers.click.remove()\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n render(): any {\n return null\n }\n}\n","import * as React from 'react'\nimport {useUserColor, ObjectDiff} from 'sanity'\nimport {Marker} from '../map/Marker'\nimport {Arrow} from '../map/Arrow'\nimport {Geopoint} from '../types'\n\ninterface Props {\n api: typeof window.google.maps\n map: google.maps.Map\n diff: ObjectDiff<Geopoint>\n label?: string\n}\n\nexport function GeopointMove({diff, api, map, label}: Props) {\n const {fromValue: from, toValue: to} = diff\n const annotation = diff.isChanged ? diff.annotation : undefined\n const userColor = useUserColor(annotation ? annotation.author : null) || undefined\n const fromRef = React.useRef<google.maps.Marker>()\n const toRef = React.useRef<google.maps.Marker>()\n\n return (\n <>\n {from && (\n <Marker\n api={api}\n map={map}\n position={from}\n zIndex={0}\n opacity={0.55}\n markerRef={fromRef}\n color={userColor}\n />\n )}\n {from && to && <Arrow api={api} map={map} from={from} to={to} zIndex={1} color={userColor} />}\n {to && (\n <Marker\n api={api}\n map={map}\n position={to}\n zIndex={2}\n markerRef={toRef}\n label={label}\n color={userColor}\n />\n )}\n </>\n )\n}\n","import styled from 'styled-components'\n\nexport const RootContainer = styled.div`\n position: relative;\n min-height: 200px;\n\n &:empty {\n background-color: var(--card-skeleton-color-from);\n display: table;\n width: 100%;\n }\n\n &:empty:after {\n content: 'Missing/invalid data';\n display: table-cell;\n vertical-align: middle;\n text-align: center;\n position: relative;\n }\n`\n","import * as React from 'react'\nimport {ArrayDiff, ObjectDiff, Diff, DiffProps as GenericDiffProps, DiffComponent} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ArrayDiff<Geopoint>>\n\nexport const GeopointArrayDiff: DiffComponent<ArrayDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof google.maps}) {\n const fromValue = (diff.fromValue || []).filter(hasCoordinates)\n const toValue = (diff.toValue || []).filter(hasCoordinates)\n if (fromValue.length === 0 && toValue.length === 0) {\n return null\n }\n\n const bounds = getBounds(fromValue, toValue, api)\n return (\n <GoogleMap\n api={api}\n location={bounds.getCenter().toJSON()}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n >\n {(map) => (\n <>\n {diff.items.map(({toIndex, diff: pointDiff}) => {\n if (!isChangeDiff(pointDiff)) {\n return null\n }\n\n return (\n <GeopointMove\n key={toIndex}\n api={api}\n map={map}\n diff={pointDiff}\n label={`${toIndex}`}\n />\n )\n })}\n </>\n )}\n </GoogleMap>\n )\n}\n\nfunction isChangeDiff(diff: Diff): diff is ObjectDiff<Geopoint> {\n return diff.action !== 'unchanged' && diff.type === 'object'\n}\n\nfunction hasCoordinates(point: Partial<Geopoint>): point is Geopoint {\n return typeof point.lat === 'number' && typeof point.lng === 'number'\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral[] | null | undefined,\n toValue: google.maps.LatLngLiteral[] | null | undefined,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n const bounds = new api.LatLngBounds()\n const points = [...(fromValue || []), ...(toValue || [])]\n points.forEach((point) => bounds.extend(point))\n return bounds\n}\n","import * as React from 'react'\nimport {\n DiffComponent,\n ObjectDiff,\n DiffProps as GenericDiffProps,\n DiffTooltip,\n getAnnotationAtPath,\n} from 'sanity'\nimport {GoogleMapsLoadProxy} from '../loader/GoogleMapsLoadProxy'\nimport {GoogleMap} from '../map/Map'\nimport {Geopoint} from '../types'\nimport {GeopointMove} from './GeopointMove'\nimport {RootContainer} from './GeopointFieldDiff.styles'\nimport {getGeoConfig} from '../global-workaround'\n\nexport type DiffProps = GenericDiffProps<ObjectDiff<Geopoint>>\n\nexport const GeopointFieldDiff: DiffComponent<ObjectDiff<Geopoint>> = ({diff, schemaType}) => {\n return (\n <RootContainer>\n <GoogleMapsLoadProxy config={getGeoConfig()}>\n {(api) => <GeopointDiff api={api} diff={diff} schemaType={schemaType} />}\n </GoogleMapsLoadProxy>\n </RootContainer>\n )\n}\n\nfunction GeopointDiff({api, diff}: DiffProps & {api: typeof window.google.maps}) {\n const {fromValue, toValue} = diff\n const annotation =\n getAnnotationAtPath(diff, ['lat']) ||\n getAnnotationAtPath(diff, ['lng']) ||\n getAnnotationAtPath(diff, [])\n\n const center = getCenter(diff, api)\n const bounds = fromValue && toValue ? getBounds(fromValue, toValue, api) : undefined\n\n return (\n <DiffTooltip annotations={annotation ? [annotation] : []} description={getAction(diff)}>\n <div>\n <GoogleMap\n api={api}\n location={center}\n mapTypeControl={false}\n controlSize={20}\n bounds={bounds}\n scrollWheel={false}\n >\n {(map) => <GeopointMove api={api} map={map} diff={diff} />}\n </GoogleMap>\n </div>\n </DiffTooltip>\n )\n}\n\nfunction getBounds(\n fromValue: google.maps.LatLngLiteral,\n toValue: google.maps.LatLngLiteral,\n api: typeof window.google.maps\n): google.maps.LatLngBounds {\n return new api.LatLngBounds().extend(fromValue).extend(toValue)\n}\n\nfunction getCenter(\n diff: DiffProps['diff'],\n api: typeof window.google.maps\n): google.maps.LatLngLiteral {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return getBounds(fromValue, toValue, api).getCenter().toJSON()\n }\n\n if (fromValue) {\n return fromValue\n }\n\n if (toValue) {\n return toValue\n }\n\n throw new Error('Neither a from or a to value present')\n}\n\nfunction getAction(diff: ObjectDiff<Geopoint>) {\n const {fromValue, toValue} = diff\n if (fromValue && toValue) {\n return 'Moved'\n } else if (fromValue) {\n return 'Removed'\n } else if (toValue) {\n return 'Added'\n }\n\n return 'Unchanged'\n}\n","import React from 'react'\nimport {definePlugin, SchemaType} from 'sanity'\nimport GeopointInput, {GeopointInputProps} from './input/GeopointInput'\nimport {setGeoConfig} from './global-workaround'\nimport {GeopointSchemaType} from './types'\n\nexport interface GoogleMapsInputConfig {\n apiKey: string\n defaultZoom?: number\n defaultLocale?: string\n defaultLocation?: {\n lat: number\n lng: number\n }\n}\n\nexport const googleMapsInput = definePlugin<GoogleMapsInputConfig>((config) => {\n setGeoConfig(config)\n return {\n name: 'google-maps-input',\n form: {\n components: {\n input(props) {\n if (isGeopoint(props.schemaType)) {\n const castedProps = props as unknown as Omit<GeopointInputProps, 'geoConfig'>\n return <GeopointInput {...castedProps} geoConfig={config} />\n }\n return props.renderDefault(props)\n },\n },\n },\n }\n})\n\nfunction isGeopoint(schemaType: SchemaType): schemaType is GeopointSchemaType {\n return isType('geopoint', schemaType)\n}\n\nfunction isType(name: string, schema?: SchemaType): boolean {\n if (schema?.name === name) {\n return true\n // eslint-disable-next-line no-negated-condition\n } else if (!schema?.name) {\n return false\n }\n return isType(name, schema?.type)\n}\n"],"names":["callbackName","AuthError","Error","_loadGoogleMapsApi","config","Promise","resolve","reject","window","google","maps","script","document","createElement","onerror","event","source","lineno","colno","error","message","isErrorEvent","coeerceError","src","apiKey","locale","getElementsByTagName","appendChild","finally","memo","LoadError","props","_a","jsxs","Card","tone","radius","children","jsx","Box","as","paddingX","paddingTop","paddingBottom","Text","weight","isAuthError","Fragment","Code","size","browserLocale","navigator","language","useLoadGoogleMapsApi","defaultLocale","state","setState","useState","type","useEffect","catch","loadGoogleMapsApi","then","api","err","GoogleMapsLoadProxy","loadState","LoadErrorView","WrapperContainer","styled","div","_templateObject","_taggedTemplateLiteral","SearchInput","React","PureComponent","constructor","super","arguments","this","searchInputRef","createRef","handleChange","autoComplete","onChange","getPlace","current","value","componentDidMount","input","map","Circle","places","searchBounds","center","getCenter","getBounds","Autocomplete","bounds","types","addListener","render","TextInput","name","ref","placeholder","padding","latLngAreEqual","latLng1","latLng2","lat1","lat","lng1","lng","lat2","lng2","MapContainer","_templateObject2","GoogleMap","mapRef","mapEl","attachClickHandler","onClick","clickHandler","remove","setMapElement","element","constructMap","componentDidUpdate","prevProps","location","panTo","equals","fitBounds","componentWillUnmount","LatLng","el","defaultZoom","mapTypeControl","controlSize","scrollWheel","Map","zoom","scrollwheel","streetViewControl","defaultProps","Marker","eventHandlers","position","onMove","zIndex","opacity","label","markerRef","color","GMarker","icon","path","fillOpacity","fillColor","background","strokeColor","border","strokeWeight","anchor","Point","labelOrigin","marker","draggable","Boolean","attachMoveHandler","setPosition","setLabel","setZIndex","setOpacity","setMap","move","click","fallbackLatLng","GeopointSelect","handlePlaceChanged","place","geometry","setValue","handleMarkerDragEnd","latLng","handleMapClick","defaultLocation","geoPoint","PreviewImage","img","_templateObject3","DialogInnerContainer","_templateObject4","getGeoConfig","setGeoConfig","newConfig","getStaticImageUrl","loc","params","key","markers","scale","qs","Object","keys","reduce","res","param","concat","encodeURIComponent","join","GeopointInput","_geopointInputId","uniqueId","setEditButton","editButton","handleToggleModal","prevState","modalOpen","handleCloseModal","schemaType","setIfMissing","_type","set","handleClear","unset","focus","readOnly","geoConfig","changed","focused","ChangeIndicator","isChanged","hasFocus","alt","marginTop","Grid","columns","gap","Button","mode","EditIcon","text","TrashIcon","Dialog","id","onClose","header","width","href","Arrow","from","to","arrowRef","lineSymbol","SymbolPath","FORWARD_OPEN_ARROW","line","Polyline","icons","offset","strokeOpacity","setPath","GeopointMove","_ref","diff","fromValue","toValue","annotation","userColor","useUserColor","author","fromRef","useRef","toRef","RootContainer","_templateObject5","GeopointDiff","_ref3","filter","hasCoordinates","length","LatLngBounds","forEach","point","extend","toJSON","items","_ref4","toIndex","pointDiff","action","isChangeDiff","_ref6","getAnnotationAtPath","DiffTooltip","annotations","description","getAction","googleMapsInput","definePlugin","form","components","isType","castedProps","renderDefault","schema","_ref2","_ref5"],"mappings":"26CAOA,MAAMA,EAAe,kCAGd,MAAMC,UAAkBC,OAE/B,SAASC,EAAmBC,GAC1B,OAAO,IAAIC,SAAmC,CAACC,EAASC,KACtDC,sBAAkC,KACzBD,EAAA,IAAIN,EAAU,sDAAqD,EAG5EO,OAAOR,GAAgB,KACbM,EAAAE,OAAOC,OAAOC,KAAI,EAGtB,MAAAC,EAASC,SAASC,cAAc,UACtCF,EAAOG,QAAU,CACfC,EACAC,EACAC,EACAC,EACAC,IACGZ,EAAO,IAAIL,MAqBpB,SAAsBa,EAAuBI,GAC3C,GAAIA,EACF,OAAOA,EAAMC,QAGX,GAAiB,iBAAVL,EACF,OAAAA,EAGT,OAGF,SAAsBA,GACpB,GAAqB,iBAAVA,GAAgC,OAAVA,EACxB,OAAA,EAGL,KAAE,YAAaA,GACV,OAAA,EAGF,MAAyC,iBAAjCA,EAAqBK,OACtC,CAbSC,CAAaN,GAASA,EAAMK,QAAU,gCAC/C,CA/B0BE,CAAaP,EAAOI,KAE1CR,EAAOY,IAAqDnB,+CAAAA,OAAAA,EAAOoB,OAAoCxB,+BAAAA,OAAAA,EAAyBI,cAAAA,OAAAA,EAAOqB,QACvIb,SAASc,qBAAqB,QAAQ,GAAGC,YAAYhB,EAAM,IAC1DiB,SAAQ,YACFpB,OAAOR,UACPQ,OAAO,cAAA,GAElB,CAEA,IAAIqB,EAAkD,KClC/C,SAASC,EAAUC,GAL1B,IAAAC,EAME,OACGC,EAAAA,KAAAC,EAAAA,KAAA,CAAKC,KAAK,WAAWC,OAAQ,EAC5BC,SAAA,CAACC,EAAAA,IAAAC,EAAAA,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AAA,EAAAA,EAAQ5M,OAGbyM,GAAOzM,EAAM,MAAA4M,OAAA,EAAAA,EAAQzP,KAC9B,2BFnCqE0P,IAAwB,IAAvB1C,KAACA,EAAA7C,WAAMA,GAAgBuF,EAC3F,OACG9Q,EAAAA,IAAA8O,EAAA,CACC/O,SAACC,EAAAA,IAAA2B,EAAA,CAAoB7D,OAAQ8L,IAC1B7J,SAAC0B,GAASzB,EAAAA,IAAAgP,EAAA,CAAavN,MAAU2M,OAAY7C,kBAElD,4BCAkEwF,IAAwB,IAAvB3C,KAACA,EAAA7C,WAAMA,GAAgBwF,EAC5F,OACG/Q,EAAAA,IAAA8O,EAAA,CACC/O,SAACC,EAAAA,IAAA2B,EAAA,CAAoB7D,OAAQ8L,IAC1B7J,SAAC0B,GAASzB,EAAAA,IAAAgP,EAAA,CAAavN,MAAU2M,OAAY7C,kBAElD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/google-maps-input",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Sanity plugin providing input handlers for geo-related input types using Google Maps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -56,8 +56,7 @@
|
|
|
56
56
|
"@sanity/icons": "^2.0.0",
|
|
57
57
|
"@sanity/incompatible-plugin": "^1.0.4",
|
|
58
58
|
"@sanity/ui": "^1.0.0",
|
|
59
|
-
"lodash": "^4.17.21"
|
|
60
|
-
"rxjs": "^6.6.7"
|
|
59
|
+
"lodash": "^4.17.21"
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
63
62
|
"@commitlint/cli": "^17.2.0",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {LoadError} from './LoadError'
|
|
1
|
+
import React, {useEffect, useState} from 'react'
|
|
2
|
+
import {AuthError, loadGoogleMapsApi} from './loadGoogleMapsApi'
|
|
3
|
+
import {LoadError as LoadErrorView} from './LoadError'
|
|
5
4
|
import {GoogleMapsInputConfig} from '../index'
|
|
6
5
|
|
|
7
6
|
interface LoadProps {
|
|
@@ -9,43 +8,51 @@ interface LoadProps {
|
|
|
9
8
|
config: GoogleMapsInputConfig
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
loadSubscription: Subscription | undefined
|
|
11
|
+
const browserLocale = (typeof window !== 'undefined' && window.navigator.language) || 'en'
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
type LoadState =
|
|
14
|
+
| {
|
|
15
|
+
type: 'loading'
|
|
16
|
+
}
|
|
17
|
+
| {
|
|
18
|
+
type: 'loaded'
|
|
19
|
+
api: typeof window.google.maps
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
type: 'error'
|
|
23
|
+
error: {type: 'loadError' | 'authError'; message: string}
|
|
24
|
+
}
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
function useLoadGoogleMapsApi(config: {defaultLocale?: string; apiKey: string}): LoadState {
|
|
27
|
+
const locale = config.defaultLocale || browserLocale || 'en-US'
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
this.loadSubscription = loadGoogleMapsApi(props.config).subscribe((loadState) => {
|
|
22
|
-
if (sync) {
|
|
23
|
-
this.state = loadState
|
|
24
|
-
} else {
|
|
25
|
-
this.setState(loadState)
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
sync = false
|
|
29
|
-
}
|
|
29
|
+
const [state, setState] = useState<LoadState>({type: 'loading'})
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
loadGoogleMapsApi({locale, apiKey: config.apiKey}).then(
|
|
33
|
+
(api) => setState({type: 'loaded', api}),
|
|
34
|
+
(err) =>
|
|
35
|
+
setState({
|
|
36
|
+
type: 'error',
|
|
37
|
+
error: {type: err instanceof AuthError ? 'authError' : 'loadError', message: err.message},
|
|
38
|
+
})
|
|
39
|
+
)
|
|
40
|
+
}, [locale, config.apiKey])
|
|
41
|
+
return state
|
|
42
|
+
}
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
export function GoogleMapsLoadProxy(props: LoadProps) {
|
|
45
|
+
const loadState = useLoadGoogleMapsApi(props.config)
|
|
46
|
+
switch (loadState.type) {
|
|
47
|
+
case 'error':
|
|
48
|
+
return (
|
|
49
|
+
<LoadErrorView error={loadState.error} isAuthError={loadState.error.type === 'authError'} />
|
|
50
|
+
)
|
|
51
|
+
case 'loading':
|
|
52
|
+
return <div>Loading Google Maps API</div>
|
|
53
|
+
case 'loaded':
|
|
54
|
+
return props.children(loadState.api)
|
|
55
|
+
default:
|
|
56
|
+
return null
|
|
50
57
|
}
|
|
51
58
|
}
|
package/src/loader/LoadError.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import {Card, Box, Text, Code} from '@sanity/ui'
|
|
3
3
|
|
|
4
|
-
type Props = {error:
|
|
4
|
+
type Props = {error: {message?: string}; isAuthError: false} | {isAuthError: true}
|
|
5
5
|
|
|
6
6
|
export function LoadError(props: Props) {
|
|
7
7
|
return (
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {Observable, BehaviorSubject} from 'rxjs'
|
|
2
|
-
import {GoogleMapsInputConfig} from '../index'
|
|
3
|
-
|
|
4
1
|
declare global {
|
|
5
2
|
interface Window {
|
|
6
3
|
gm_authFailure: any
|
|
@@ -10,78 +7,57 @@ declare global {
|
|
|
10
7
|
|
|
11
8
|
const callbackName = '___sanity_googleMapsApiCallback'
|
|
12
9
|
const authFailureCallbackName = 'gm_authFailure'
|
|
13
|
-
const locale = (typeof window !== 'undefined' && window.navigator.language) || 'en'
|
|
14
|
-
|
|
15
|
-
export interface LoadingState {
|
|
16
|
-
loadState: 'loading'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface LoadedState {
|
|
20
|
-
loadState: 'loaded'
|
|
21
|
-
api: typeof window.google.maps
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface LoadErrorState {
|
|
25
|
-
loadState: 'loadError'
|
|
26
|
-
error: Error
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface AuthErrorState {
|
|
30
|
-
loadState: 'authError'
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type GoogleLoadState = LoadingState | LoadedState | LoadErrorState | AuthErrorState
|
|
34
|
-
|
|
35
|
-
let subject: BehaviorSubject<GoogleLoadState>
|
|
36
|
-
|
|
37
|
-
export function loadGoogleMapsApi(config: GoogleMapsInputConfig): Observable<GoogleLoadState> {
|
|
38
|
-
const selectedLocale = config.defaultLocale || locale || 'en-US'
|
|
39
10
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
11
|
+
export class AuthError extends Error {}
|
|
12
|
+
|
|
13
|
+
function _loadGoogleMapsApi(config: {locale: string; apiKey: string}) {
|
|
14
|
+
return new Promise<typeof window.google.maps>((resolve, reject) => {
|
|
15
|
+
window[authFailureCallbackName] = () => {
|
|
16
|
+
reject(new AuthError('Authentication error when loading Google Maps API.'))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
window[callbackName] = () => {
|
|
20
|
+
resolve(window.google.maps)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const script = document.createElement('script')
|
|
24
|
+
script.onerror = (
|
|
25
|
+
event: Event | string,
|
|
26
|
+
source?: string,
|
|
27
|
+
lineno?: number,
|
|
28
|
+
colno?: number,
|
|
29
|
+
error?: Error
|
|
30
|
+
) => reject(new Error(coeerceError(event, error)))
|
|
31
|
+
|
|
32
|
+
script.src = `https://maps.googleapis.com/maps/api/js?key=${config.apiKey}&libraries=places&callback=${callbackName}&language=${config.locale}`
|
|
33
|
+
document.getElementsByTagName('head')[0].appendChild(script)
|
|
34
|
+
}).finally(() => {
|
|
35
|
+
delete window[callbackName]
|
|
47
36
|
delete window[authFailureCallbackName]
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
})
|
|
38
|
+
}
|
|
50
39
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
let memo: Promise<typeof window.google.maps> | null = null
|
|
41
|
+
export function loadGoogleMapsApi(config: {locale: string; apiKey: string}) {
|
|
42
|
+
if (memo) {
|
|
43
|
+
return memo
|
|
54
44
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
lineno?: number,
|
|
61
|
-
colno?: number,
|
|
62
|
-
error?: Error
|
|
63
|
-
) =>
|
|
64
|
-
subject.next({
|
|
65
|
-
loadState: 'loadError',
|
|
66
|
-
error: coeerceError(event, error),
|
|
67
|
-
} as LoadErrorState)
|
|
68
|
-
|
|
69
|
-
script.src = `https://maps.googleapis.com/maps/api/js?key=${config.apiKey}&libraries=places&callback=${callbackName}&language=${selectedLocale}`
|
|
70
|
-
document.getElementsByTagName('head')[0].appendChild(script)
|
|
71
|
-
|
|
72
|
-
return subject
|
|
45
|
+
memo = _loadGoogleMapsApi(config)
|
|
46
|
+
memo.catch(() => {
|
|
47
|
+
memo = null
|
|
48
|
+
})
|
|
49
|
+
return memo
|
|
73
50
|
}
|
|
74
|
-
|
|
75
|
-
function coeerceError(event: Event | string, error?: Error): Error {
|
|
51
|
+
function coeerceError(event: Event | string, error?: Error): string {
|
|
76
52
|
if (error) {
|
|
77
|
-
return error
|
|
53
|
+
return error.message
|
|
78
54
|
}
|
|
79
55
|
|
|
80
56
|
if (typeof event === 'string') {
|
|
81
|
-
return
|
|
57
|
+
return event
|
|
82
58
|
}
|
|
83
59
|
|
|
84
|
-
return
|
|
60
|
+
return isErrorEvent(event) ? event.message : 'Failed to load Google Maps API'
|
|
85
61
|
}
|
|
86
62
|
|
|
87
63
|
function isErrorEvent(event: unknown): event is ErrorEvent {
|