@sanity/google-maps-input 3.0.0-v3-studio.6 → 3.0.0-v3-studio.8
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/README.md +1 -1
- package/lib/index.esm.js +2 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/src/index.d.ts +73 -0
- package/package.json +68 -63
- package/sanity.json +8 -0
- package/src/index.ts +10 -0
- package/src/{index.tsx → plugin.tsx} +2 -9
- package/v2-incompatible.js +10 -0
- package/lib/cjs/index.js +0 -899
- package/lib/cjs/index.js.map +0 -1
- package/lib/esm/index.js +0 -889
- package/lib/esm/index.js.map +0 -1
- package/lib/types/index.d.ts +0 -41
- package/lib/types/index.d.ts.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Add it as a plugin in sanity.config.ts (or .js), with a valid [Google Maps API k
|
|
|
40
40
|
```js
|
|
41
41
|
import { googleMapsInput } from "@sanity/google-maps-input";
|
|
42
42
|
|
|
43
|
-
export default
|
|
43
|
+
export default defineConfig({
|
|
44
44
|
// ...
|
|
45
45
|
plugins: [
|
|
46
46
|
googleMapsInput({
|
package/lib/index.esm.js
ADDED
|
@@ -0,0 +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};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +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,Y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OAAOpB,EACzD,CAsBA,SAASoC,GAAUtC,GACX,MAAAC,UAACA,EAAWC,QAAAA,GAAWF,EAC7B,OAAIC,GAAaC,EACR,QACED,EACF,UACEC,EACF,QAGF,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"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +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;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +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,IAAS,OAAAC,EAAMD,EAAAL,YAAO,EAAAM,EAAAJ,oBAO/D,CAEA,SAASmB,IACP,OACGd,EAAAA,KAAAW,EAAAA,KAAA,CACCP,SAAA,CAACC,EAAAA,IAAA,IAAA,CA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3R,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"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
|
|
3
|
+
import {ArrayDiff} from 'sanity'
|
|
4
|
+
import {DiffComponent} from 'sanity'
|
|
5
|
+
import {DiffComponentOptions} from 'sanity'
|
|
6
|
+
import {DiffProps} from 'sanity'
|
|
7
|
+
import {ObjectDiff} from 'sanity'
|
|
8
|
+
import {ObjectInputProps} from 'sanity'
|
|
9
|
+
import {ObjectSchemaType} from 'sanity'
|
|
10
|
+
import {Plugin as Plugin_2} from 'sanity'
|
|
11
|
+
import {default as React_2} from 'react'
|
|
12
|
+
|
|
13
|
+
declare type Focusable = any
|
|
14
|
+
|
|
15
|
+
export declare interface Geopoint {
|
|
16
|
+
_type: 'geopoint'
|
|
17
|
+
_key?: string
|
|
18
|
+
lat: number
|
|
19
|
+
lng: number
|
|
20
|
+
alt?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare const GeopointArrayDiff: DiffComponent<ArrayDiff<Geopoint>>
|
|
24
|
+
|
|
25
|
+
export declare type GeopointArrayDiffProps = DiffProps<ArrayDiff<Geopoint>>
|
|
26
|
+
|
|
27
|
+
export declare const GeopointFieldDiff: DiffComponent<ObjectDiff<Geopoint>>
|
|
28
|
+
|
|
29
|
+
export declare type GeopointFieldDiffProps = DiffProps<ObjectDiff<Geopoint>>
|
|
30
|
+
|
|
31
|
+
export declare class GeopointInput extends React_2.PureComponent<GeopointInputProps, InputState> {
|
|
32
|
+
_geopointInputId: string
|
|
33
|
+
editButton: Focusable | undefined
|
|
34
|
+
constructor(props: GeopointInputProps)
|
|
35
|
+
setEditButton: (el: Focusable) => void
|
|
36
|
+
focus(): void
|
|
37
|
+
handleToggleModal: () => void
|
|
38
|
+
handleCloseModal: () => void
|
|
39
|
+
handleChange: (latLng: google.maps.LatLng) => void
|
|
40
|
+
handleClear: () => void
|
|
41
|
+
render(): JSX.Element
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare type GeopointInputProps = ObjectInputProps<Geopoint, GeopointSchemaType> & {
|
|
45
|
+
geoConfig: GoogleMapsInputConfig
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export declare interface GeopointSchemaType extends ObjectSchemaType {
|
|
49
|
+
diffComponent?: DiffComponent<ObjectDiff<Geopoint>> | DiffComponentOptions<ObjectDiff<Geopoint>>
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare const googleMapsInput: Plugin_2<GoogleMapsInputConfig>
|
|
53
|
+
|
|
54
|
+
export declare interface GoogleMapsInputConfig {
|
|
55
|
+
apiKey: string
|
|
56
|
+
defaultZoom?: number
|
|
57
|
+
defaultLocale?: string
|
|
58
|
+
defaultLocation?: {
|
|
59
|
+
lat: number
|
|
60
|
+
lng: number
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare interface InputState {
|
|
65
|
+
modalOpen: boolean
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare interface LatLng {
|
|
69
|
+
lat: number
|
|
70
|
+
lng: number
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export {}
|
package/package.json
CHANGED
|
@@ -1,103 +1,108 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/google-maps-input",
|
|
3
|
-
"version": "3.0.0-v3-studio.
|
|
3
|
+
"version": "3.0.0-v3-studio.8",
|
|
4
4
|
"description": "Sanity plugin providing input handlers for geo-related input types using Google Maps",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sanity",
|
|
7
|
+
"cms",
|
|
8
|
+
"headless",
|
|
9
|
+
"realtime",
|
|
10
|
+
"content",
|
|
11
|
+
"google-maps-input",
|
|
12
|
+
"sanity-plugin"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/sanity-io/google-maps-input#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/sanity-io/google-maps-input/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git@github.com:sanity-io/google-maps-input.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Sanity.io <hello@sanity.io>",
|
|
6
24
|
"exports": {
|
|
7
25
|
".": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
26
|
+
"types": "./lib/src/index.d.ts",
|
|
27
|
+
"source": "./src/index.ts",
|
|
28
|
+
"import": "./lib/index.esm.js",
|
|
29
|
+
"require": "./lib/index.js",
|
|
30
|
+
"default": "./lib/index.esm.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
11
33
|
},
|
|
12
|
-
"main": "./lib/
|
|
13
|
-
"module": "./lib/
|
|
14
|
-
"
|
|
34
|
+
"main": "./lib/index.js",
|
|
35
|
+
"module": "./lib/index.esm.js",
|
|
36
|
+
"source": "./src/index.ts",
|
|
37
|
+
"types": "./lib/src/index.d.ts",
|
|
15
38
|
"files": [
|
|
16
39
|
"src",
|
|
17
|
-
"lib"
|
|
40
|
+
"lib",
|
|
41
|
+
"v2-incompatible.js",
|
|
42
|
+
"sanity.json"
|
|
18
43
|
],
|
|
19
|
-
"author": "Sanity.io <hello@sanity.io>",
|
|
20
|
-
"license": "MIT",
|
|
21
44
|
"scripts": {
|
|
45
|
+
"prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils",
|
|
46
|
+
"build": "pkg-utils build --strict",
|
|
22
47
|
"clean": "rimraf lib",
|
|
23
|
-
"
|
|
24
|
-
"prebuild": "npm run clean && plugin-kit verify-package --silent",
|
|
25
|
-
"build": "parcel build --no-cache",
|
|
26
|
-
"watch": "parcel watch",
|
|
48
|
+
"compile": "tsc --noEmit",
|
|
27
49
|
"link-watch": "plugin-kit link-watch",
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"prepare": "husky install",
|
|
28
52
|
"prepublishOnly": "npm run build",
|
|
29
|
-
"
|
|
30
|
-
"lint": "eslint ."
|
|
53
|
+
"watch": "pkg-utils watch"
|
|
31
54
|
},
|
|
32
|
-
"sanityPlugin": {
|
|
33
|
-
"upgradeHelp": {
|
|
34
|
-
"sanityJson": false
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"keywords": [
|
|
38
|
-
"sanity",
|
|
39
|
-
"cms",
|
|
40
|
-
"headless",
|
|
41
|
-
"realtime",
|
|
42
|
-
"content",
|
|
43
|
-
"google-maps-input",
|
|
44
|
-
"sanity-plugin"
|
|
45
|
-
],
|
|
46
55
|
"dependencies": {
|
|
47
56
|
"@sanity/incompatible-plugin": "^1.0.4",
|
|
48
57
|
"lodash": "^4.17.21",
|
|
49
58
|
"rxjs": "^6.6.7"
|
|
50
59
|
},
|
|
51
60
|
"devDependencies": {
|
|
52
|
-
"@commitlint/cli": "^17.
|
|
53
|
-
"@commitlint/config-conventional": "^17.
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@sanity/
|
|
57
|
-
"@sanity/semantic-release-preset": "^2.0.1",
|
|
61
|
+
"@commitlint/cli": "^17.2.0",
|
|
62
|
+
"@commitlint/config-conventional": "^17.2.0",
|
|
63
|
+
"@sanity/pkg-utils": "^1.17.2",
|
|
64
|
+
"@sanity/plugin-kit": "^2.1.5",
|
|
65
|
+
"@sanity/semantic-release-preset": "^2.0.2",
|
|
58
66
|
"@types/google.maps": "^3.49.2",
|
|
59
67
|
"@types/styled-components": "^5.1.25",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
61
|
-
"@typescript-eslint/parser": "^5.
|
|
62
|
-
"eslint": "^8.
|
|
63
|
-
"eslint-config-prettier": "^8.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
69
|
+
"@typescript-eslint/parser": "^5.42.0",
|
|
70
|
+
"eslint": "^8.26.0",
|
|
71
|
+
"eslint-config-prettier": "^8.5.0",
|
|
64
72
|
"eslint-config-sanity": "^6.0.0",
|
|
65
|
-
"eslint-plugin-prettier": "4.
|
|
66
|
-
"eslint-plugin-react": "^7.
|
|
67
|
-
"eslint-plugin-react-hooks": "^4.
|
|
73
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
74
|
+
"eslint-plugin-react": "^7.31.10",
|
|
75
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
68
76
|
"husky": "^8.0.1",
|
|
69
77
|
"lint-staged": "^13.0.3",
|
|
70
|
-
"
|
|
71
|
-
"prettier": "^2.
|
|
72
|
-
"react": "^18
|
|
73
|
-
"react-dom": "^18
|
|
78
|
+
"prettier": "^2.7.1",
|
|
79
|
+
"prettier-plugin-packagejson": "^2.3.0",
|
|
80
|
+
"react": "^18",
|
|
81
|
+
"react-dom": "^18",
|
|
74
82
|
"rimraf": "^3.0.2",
|
|
75
|
-
"sanity": "3.0.0-
|
|
83
|
+
"sanity": "3.0.0-rc.0",
|
|
76
84
|
"styled-components": "^5.2.0",
|
|
77
|
-
"typescript": "4.
|
|
85
|
+
"typescript": "^4.8.4"
|
|
78
86
|
},
|
|
79
87
|
"peerDependencies": {
|
|
80
88
|
"@sanity/icons": "^1.3",
|
|
81
|
-
"@sanity/ui": "
|
|
82
|
-
"react": "^18
|
|
83
|
-
"react-dom": "^18
|
|
84
|
-
"sanity": "dev-preview || 3.0.0-
|
|
89
|
+
"@sanity/ui": "1.0.0-beta.32",
|
|
90
|
+
"react": "^18",
|
|
91
|
+
"react-dom": "^18",
|
|
92
|
+
"sanity": "dev-preview || 3.0.0-rc.0",
|
|
85
93
|
"styled-components": "^5.2"
|
|
86
94
|
},
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"url": "git+https://github.com/sanity-io/google-maps-input.git"
|
|
90
|
-
},
|
|
91
|
-
"bugs": {
|
|
92
|
-
"url": "https://github.com/sanity-io/google-maps-input/issues"
|
|
95
|
+
"engines": {
|
|
96
|
+
"node": ">=14"
|
|
93
97
|
},
|
|
94
|
-
"homepage": "https://www.sanity.io/",
|
|
95
98
|
"alias": {
|
|
96
99
|
"google": {
|
|
97
100
|
"global": "google"
|
|
98
101
|
}
|
|
99
102
|
},
|
|
100
|
-
"
|
|
101
|
-
"
|
|
103
|
+
"sanityPlugin": {
|
|
104
|
+
"upgradeHelp": {
|
|
105
|
+
"sanityJson": false
|
|
106
|
+
}
|
|
102
107
|
}
|
|
103
108
|
}
|