@sanity/google-maps-input 0.147.10-next.23 → 1.0.0-v2-studio.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/LICENSE +1 -1
  2. package/config.dist.json +1 -0
  3. package/dts/diff/GeopointArrayDiff.d.ts +4 -0
  4. package/dts/diff/GeopointFieldDiff.d.ts +4 -0
  5. package/dts/diff/GeopointFieldDiff.styles.d.ts +1 -0
  6. package/dts/diff/GeopointMove.d.ts +12 -0
  7. package/dts/diff/resolver.d.ts +3 -0
  8. package/dts/input/GeopointInput.d.ts +64 -0
  9. package/dts/input/GeopointInput.styles.d.ts +2 -0
  10. package/dts/input/GeopointSelect.d.ts +52 -0
  11. package/dts/loader/GoogleMapsLoadProxy.d.ts +13 -0
  12. package/dts/loader/LoadError.d.ts +9 -0
  13. package/dts/loader/loadGoogleMapsApi.d.ts +17 -0
  14. package/dts/map/Arrow.d.ts +30 -0
  15. package/dts/map/Map.d.ts +38 -0
  16. package/dts/map/Map.styles.d.ts +1 -0
  17. package/dts/map/Marker.d.ts +38 -0
  18. package/dts/map/SearchInput.d.ts +17 -0
  19. package/dts/map/SearchInput.styles.d.ts +1 -0
  20. package/dts/map/util.d.ts +3 -0
  21. package/dts/types.d.ts +13 -0
  22. package/lib/@types/css.d.js +2 -0
  23. package/lib/@types/css.d.js.map +1 -0
  24. package/lib/diff/GeopointArrayDiff.js +66 -0
  25. package/lib/diff/GeopointArrayDiff.js.map +1 -0
  26. package/lib/diff/GeopointFieldDiff.js +78 -0
  27. package/lib/diff/GeopointFieldDiff.js.map +1 -0
  28. package/lib/diff/GeopointFieldDiff.styles.js +13 -0
  29. package/lib/diff/GeopointFieldDiff.styles.js.map +1 -0
  30. package/lib/diff/GeopointMove.js +49 -0
  31. package/lib/diff/GeopointMove.js.map +1 -0
  32. package/lib/diff/resolver.js +21 -0
  33. package/lib/diff/resolver.js.map +1 -0
  34. package/lib/input/GeopointInput.js +163 -0
  35. package/lib/input/GeopointInput.js.map +1 -0
  36. package/lib/input/GeopointInput.styles.js +15 -0
  37. package/lib/input/GeopointInput.styles.js.map +1 -0
  38. package/lib/input/GeopointSelect.js +81 -0
  39. package/lib/input/GeopointSelect.js.map +1 -0
  40. package/lib/loader/GoogleMapsLoadProxy.js +55 -0
  41. package/lib/loader/GoogleMapsLoadProxy.js.map +1 -0
  42. package/lib/loader/LoadError.js +37 -0
  43. package/lib/loader/LoadError.js.map +1 -0
  44. package/lib/loader/loadGoogleMapsApi.js +65 -0
  45. package/lib/loader/loadGoogleMapsApi.js.map +1 -0
  46. package/lib/map/Arrow.js +79 -0
  47. package/lib/map/Arrow.js.map +1 -0
  48. package/lib/map/Map.js +114 -0
  49. package/lib/map/Map.js.map +1 -0
  50. package/lib/map/Map.styles.js +13 -0
  51. package/lib/map/Map.styles.js.map +1 -0
  52. package/lib/map/Marker.js +125 -0
  53. package/lib/map/Marker.js.map +1 -0
  54. package/lib/map/SearchInput.js +60 -0
  55. package/lib/map/SearchInput.js.map +1 -0
  56. package/lib/map/SearchInput.styles.js +13 -0
  57. package/lib/map/SearchInput.styles.js.map +1 -0
  58. package/lib/map/util.js +14 -0
  59. package/lib/map/util.js.map +1 -0
  60. package/lib/types.js +2 -0
  61. package/lib/types.js.map +1 -0
  62. package/package.json +63 -22
  63. package/sanity.json +5 -1
  64. package/src/@types/css.d.ts +4 -0
  65. package/src/diff/GeopointArrayDiff.tsx +83 -0
  66. package/src/diff/GeopointFieldDiff.styles.tsx +20 -0
  67. package/src/diff/GeopointFieldDiff.tsx +94 -0
  68. package/src/diff/GeopointMove.tsx +49 -0
  69. package/src/diff/resolver.ts +21 -0
  70. package/src/input/GeopointInput.styles.tsx +12 -0
  71. package/src/input/GeopointInput.tsx +231 -0
  72. package/src/input/GeopointSelect.tsx +78 -0
  73. package/src/loader/GoogleMapsLoadProxy.tsx +49 -0
  74. package/src/loader/LoadError.tsx +44 -0
  75. package/src/loader/loadGoogleMapsApi.ts +93 -0
  76. package/src/map/Arrow.tsx +76 -0
  77. package/src/map/Map.styles.tsx +10 -0
  78. package/src/map/Map.tsx +125 -0
  79. package/src/map/Marker.tsx +132 -0
  80. package/src/map/SearchInput.styles.tsx +8 -0
  81. package/src/map/SearchInput.tsx +55 -0
  82. package/src/map/util.ts +14 -0
  83. package/src/types.ts +16 -0
  84. package/lib/GeopointInput.js +0 -170
  85. package/lib/GeopointSelect.js +0 -174
  86. package/lib/GoogleMapsLoadProxy.js +0 -65
  87. package/lib/loadGoogleMapsApi.js +0 -36
  88. package/styles/GeopointInput.css +0 -28
  89. package/styles/GeopointSelect.css +0 -27
@@ -0,0 +1,76 @@
1
+ import * as React from 'react'
2
+ import {LatLng} from '../types'
3
+ import {latLngAreEqual} from './util'
4
+
5
+ interface Props {
6
+ api: typeof window.google.maps
7
+ map: google.maps.Map
8
+ from: LatLng
9
+ to: LatLng
10
+ color?: {background: string; border: string; text: string}
11
+ zIndex?: number
12
+ arrowRef?: React.MutableRefObject<google.maps.Polyline | undefined>
13
+ onClick?: (event: google.maps.MapMouseEvent) => void
14
+ }
15
+
16
+ export class Arrow extends React.PureComponent<Props> {
17
+ line: google.maps.Polyline | undefined
18
+
19
+ eventHandlers: {
20
+ click?: google.maps.MapsEventListener
21
+ } = {}
22
+
23
+ componentDidMount() {
24
+ const {from, to, api, map, zIndex, onClick, color, arrowRef} = this.props
25
+ const lineSymbol = {
26
+ path: api.SymbolPath.FORWARD_OPEN_ARROW,
27
+ }
28
+
29
+ this.line = new api.Polyline({
30
+ map,
31
+ zIndex,
32
+ path: [from, to],
33
+ icons: [{icon: lineSymbol, offset: '50%'}],
34
+ strokeOpacity: 0.55,
35
+ strokeColor: color ? color.text : 'black',
36
+ })
37
+
38
+ if (onClick) {
39
+ this.eventHandlers.click = api.event.addListener(this.line, 'click', onClick)
40
+ }
41
+
42
+ if (arrowRef) {
43
+ arrowRef.current = this.line
44
+ }
45
+ }
46
+
47
+ componentDidUpdate(prevProps: Props) {
48
+ if (!this.line) {
49
+ return
50
+ }
51
+
52
+ const {from, to, map} = this.props
53
+ if (!latLngAreEqual(prevProps.from, from) || !latLngAreEqual(prevProps.to, to)) {
54
+ this.line.setPath([from, to])
55
+ }
56
+
57
+ if (prevProps.map !== map) {
58
+ this.line.setMap(map)
59
+ }
60
+ }
61
+
62
+ componentWillUnmount() {
63
+ if (this.line) {
64
+ this.line.setMap(null)
65
+ }
66
+
67
+ if (this.eventHandlers.click) {
68
+ this.eventHandlers.click.remove()
69
+ }
70
+ }
71
+
72
+ // eslint-disable-next-line class-methods-use-this
73
+ render() {
74
+ return null
75
+ }
76
+ }
@@ -0,0 +1,10 @@
1
+ import styled from 'styled-components'
2
+
3
+ export const MapContainer = styled.div`
4
+ position: absolute;
5
+ top: 0;
6
+ left: 0;
7
+ height: 100%;
8
+ width: 100%;
9
+ box-sizing: border-box;
10
+ `
@@ -0,0 +1,125 @@
1
+ import React from 'react'
2
+ import {LatLng} from '../types'
3
+ import {latLngAreEqual} from './util'
4
+ import {MapContainer} from './Map.styles'
5
+
6
+ interface MapProps {
7
+ api: typeof window.google.maps
8
+ location: LatLng
9
+ bounds?: google.maps.LatLngBounds
10
+ defaultZoom?: number
11
+ mapTypeControl?: boolean
12
+ scrollWheel?: boolean
13
+ controlSize?: number
14
+ onClick?: (event: google.maps.MapMouseEvent) => void
15
+ children?: (map: google.maps.Map) => React.ReactElement
16
+ }
17
+
18
+ interface MapState {
19
+ map: google.maps.Map | undefined
20
+ }
21
+
22
+ export class GoogleMap extends React.PureComponent<MapProps, MapState> {
23
+ static defaultProps = {
24
+ defaultZoom: 8,
25
+ scrollWheel: true,
26
+ }
27
+
28
+ state: MapState = {map: undefined}
29
+ clickHandler: google.maps.MapsEventListener | undefined
30
+ mapRef = React.createRef<HTMLDivElement>()
31
+ mapEl: HTMLDivElement | null = null
32
+
33
+ componentDidMount() {
34
+ this.attachClickHandler()
35
+ }
36
+
37
+ attachClickHandler = () => {
38
+ const map = this.state.map
39
+ if (!map) {
40
+ return
41
+ }
42
+
43
+ const {api, onClick} = this.props
44
+ const {event} = api
45
+
46
+ if (this.clickHandler) {
47
+ this.clickHandler.remove()
48
+ }
49
+
50
+ if (onClick) {
51
+ this.clickHandler = event.addListener(map, 'click', onClick)
52
+ }
53
+ }
54
+
55
+ componentDidUpdate(prevProps: MapProps) {
56
+ const map = this.state.map
57
+ if (!map) {
58
+ return
59
+ }
60
+
61
+ const {onClick, location, bounds} = this.props
62
+
63
+ if (prevProps.onClick !== onClick) {
64
+ this.attachClickHandler()
65
+ }
66
+
67
+ if (!latLngAreEqual(prevProps.location, location)) {
68
+ map.panTo(this.getCenter())
69
+ }
70
+
71
+ if (bounds && (!prevProps.bounds || !bounds.equals(prevProps.bounds))) {
72
+ map.fitBounds(bounds)
73
+ }
74
+ }
75
+
76
+ componentWillUnmount() {
77
+ if (this.clickHandler) {
78
+ this.clickHandler.remove()
79
+ }
80
+ }
81
+
82
+ getCenter(): google.maps.LatLng {
83
+ const {location, api} = this.props
84
+ return new api.LatLng(location.lat, location.lng)
85
+ }
86
+
87
+ constructMap(el: HTMLDivElement) {
88
+ const {defaultZoom, api, mapTypeControl, controlSize, bounds, scrollWheel} = this.props
89
+
90
+ const map = new api.Map(el, {
91
+ zoom: defaultZoom,
92
+ center: this.getCenter(),
93
+ scrollwheel: scrollWheel,
94
+ streetViewControl: false,
95
+ mapTypeControl,
96
+ controlSize,
97
+ })
98
+
99
+ if (bounds) {
100
+ map.fitBounds(bounds)
101
+ }
102
+
103
+ return map
104
+ }
105
+
106
+ setMapElement = (element: HTMLDivElement | null) => {
107
+ if (element && element !== this.mapEl) {
108
+ const map = this.constructMap(element)
109
+ this.setState({map}, this.attachClickHandler)
110
+ }
111
+
112
+ this.mapEl = element
113
+ }
114
+
115
+ render() {
116
+ const {children} = this.props
117
+ const {map} = this.state
118
+ return (
119
+ <>
120
+ <MapContainer ref={this.setMapElement} />
121
+ {children && map ? children(map) : null}
122
+ </>
123
+ )
124
+ }
125
+ }
@@ -0,0 +1,132 @@
1
+ import * as React from 'react'
2
+ import {LatLng} from '../types'
3
+ import {latLngAreEqual} from './util'
4
+
5
+ const markerPath =
6
+ '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'
7
+
8
+ interface Props {
9
+ api: typeof window.google.maps
10
+ map: google.maps.Map
11
+ onMove?: (event: google.maps.MapMouseEvent) => void
12
+ onClick?: (event: google.maps.MapMouseEvent) => void
13
+ onMouseOver?: (event: google.maps.MapMouseEvent) => void
14
+ onMouseOut?: (event: google.maps.MapMouseEvent) => void
15
+ position: LatLng | google.maps.LatLng
16
+ zIndex?: number
17
+ opacity?: number
18
+ label?: string
19
+ markerRef?: React.MutableRefObject<google.maps.Marker | undefined>
20
+ color?: {background: string; border: string; text: string}
21
+ }
22
+
23
+ export class Marker extends React.PureComponent<Props> {
24
+ marker: google.maps.Marker | undefined
25
+
26
+ eventHandlers: {
27
+ move?: google.maps.MapsEventListener
28
+ click?: google.maps.MapsEventListener
29
+ } = {}
30
+
31
+ componentDidMount() {
32
+ const {position, api, map, onMove, zIndex, opacity, label, markerRef, color} = this.props
33
+ const {Marker: GMarker} = api
34
+
35
+ let icon: google.maps.ReadonlySymbol | undefined
36
+ if (color) {
37
+ icon = {
38
+ path: markerPath,
39
+ fillOpacity: 1,
40
+ fillColor: color.background,
41
+ strokeColor: color.border,
42
+ strokeWeight: 2,
43
+ anchor: new api.Point(10, 35),
44
+ labelOrigin: new api.Point(10, 11),
45
+ }
46
+ }
47
+
48
+ this.marker = new GMarker({
49
+ draggable: Boolean(onMove),
50
+ position,
51
+ map,
52
+ zIndex,
53
+ opacity,
54
+ label,
55
+ icon,
56
+ })
57
+
58
+ if (markerRef) {
59
+ markerRef.current = this.marker
60
+ }
61
+
62
+ this.attachMoveHandler()
63
+ this.attachClickHandler()
64
+ }
65
+
66
+ componentDidUpdate(prevProps: Props) {
67
+ if (!this.marker) {
68
+ return
69
+ }
70
+
71
+ const {position, onMove, label, zIndex, opacity, map} = this.props
72
+
73
+ if (prevProps.onMove !== onMove) {
74
+ this.attachMoveHandler()
75
+ }
76
+
77
+ if (!latLngAreEqual(prevProps.position, position)) {
78
+ this.marker.setPosition(position)
79
+ }
80
+
81
+ if (prevProps.label !== label) {
82
+ this.marker.setLabel(label || null)
83
+ }
84
+
85
+ if (prevProps.zIndex !== zIndex) {
86
+ this.marker.setZIndex(zIndex || null)
87
+ }
88
+
89
+ if (prevProps.opacity !== opacity) {
90
+ this.marker.setOpacity(opacity || null)
91
+ }
92
+
93
+ if (prevProps.map !== map) {
94
+ this.marker.setMap(map)
95
+ }
96
+ }
97
+
98
+ componentWillUnmount() {
99
+ if (this.eventHandlers.move) {
100
+ this.eventHandlers.move.remove()
101
+ }
102
+
103
+ if (this.marker) {
104
+ this.marker.setMap(null)
105
+ }
106
+ }
107
+
108
+ attachMoveHandler() {
109
+ const {api, onMove} = this.props
110
+ if (this.eventHandlers.move) {
111
+ this.eventHandlers.move.remove()
112
+ }
113
+ if (this.marker && onMove) {
114
+ this.eventHandlers.move = api.event.addListener(this.marker, 'dragend', onMove)
115
+ }
116
+ }
117
+
118
+ attachClickHandler() {
119
+ const {api, onClick} = this.props
120
+ if (this.eventHandlers.click) {
121
+ this.eventHandlers.click.remove()
122
+ }
123
+ if (this.marker && onClick) {
124
+ this.eventHandlers.click = api.event.addListener(this.marker, 'click', onClick)
125
+ }
126
+ }
127
+
128
+ // eslint-disable-next-line class-methods-use-this
129
+ render() {
130
+ return null
131
+ }
132
+ }
@@ -0,0 +1,8 @@
1
+ import styled from 'styled-components'
2
+
3
+ export const WrapperContainer = styled.div`
4
+ position: absolute;
5
+ right: 10px;
6
+ top: 10px;
7
+ width: 220px;
8
+ `
@@ -0,0 +1,55 @@
1
+ import * as React from 'react'
2
+ import {TextInput} from '@sanity/ui'
3
+ import {WrapperContainer} from './SearchInput.styles'
4
+ interface Props {
5
+ api: typeof window.google.maps
6
+ map: google.maps.Map
7
+ onChange: (result: google.maps.places.PlaceResult) => void
8
+ }
9
+
10
+ export class SearchInput extends React.PureComponent<Props> {
11
+ searchInputRef = React.createRef<HTMLInputElement>()
12
+ autoComplete: google.maps.places.Autocomplete | undefined
13
+
14
+ handleChange = () => {
15
+ if (!this.autoComplete) {
16
+ return
17
+ }
18
+
19
+ this.props.onChange(this.autoComplete.getPlace())
20
+
21
+ if (this.searchInputRef.current) {
22
+ this.searchInputRef.current.value = ''
23
+ }
24
+ }
25
+
26
+ componentDidMount() {
27
+ const input = this.searchInputRef.current
28
+ if (!input) {
29
+ return
30
+ }
31
+
32
+ const {api, map} = this.props
33
+ const {Circle, places, event} = api
34
+ const searchBounds = new Circle({center: map.getCenter(), radius: 100}).getBounds()
35
+ this.autoComplete = new places.Autocomplete(input, {
36
+ bounds: searchBounds,
37
+ types: [], // return all kinds of places
38
+ })
39
+
40
+ event.addListener(this.autoComplete, 'place_changed', this.handleChange)
41
+ }
42
+
43
+ render() {
44
+ return (
45
+ <WrapperContainer>
46
+ <TextInput
47
+ name="place"
48
+ ref={this.searchInputRef}
49
+ placeholder="Search for place or address"
50
+ padding={4}
51
+ />
52
+ </WrapperContainer>
53
+ )
54
+ }
55
+ }
@@ -0,0 +1,14 @@
1
+ import {LatLng} from '../types'
2
+
3
+ export function latLngAreEqual(
4
+ latLng1: LatLng | google.maps.LatLng,
5
+ latLng2: LatLng | google.maps.LatLng
6
+ ) {
7
+ const lat1 = typeof latLng1.lat === 'function' ? latLng1.lat() : latLng1.lat
8
+ const lng1 = typeof latLng1.lng === 'function' ? latLng1.lng() : latLng1.lng
9
+
10
+ const lat2 = typeof latLng2.lat === 'function' ? latLng2.lat() : latLng2.lat
11
+ const lng2 = typeof latLng2.lng === 'function' ? latLng2.lng() : latLng2.lng
12
+
13
+ return lat1 === lat2 && lng1 === lng2
14
+ }
package/src/types.ts ADDED
@@ -0,0 +1,16 @@
1
+ import {ObjectSchemaType} from '@sanity/field/diff'
2
+
3
+ export interface LatLng {
4
+ lat: number
5
+ lng: number
6
+ }
7
+
8
+ export interface Geopoint {
9
+ _type: 'geopoint'
10
+ _key?: string
11
+ lat: number
12
+ lng: number
13
+ alt?: number
14
+ }
15
+
16
+ export type GeopointSchemaType = ObjectSchemaType<Geopoint>
@@ -1,170 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _googleMapsInput = _interopRequireDefault(require("config:@sanity/google-maps-input"));
13
-
14
- var _default2 = _interopRequireDefault(require("part:@sanity/components/buttons/default"));
15
-
16
- var _default3 = _interopRequireDefault(require("part:@sanity/components/dialogs/default"));
17
-
18
- var _default4 = _interopRequireDefault(require("part:@sanity/components/fieldsets/default"));
19
-
20
- var _patchEvent = require("part:@sanity/form-builder/patch-event");
21
-
22
- var _GeopointInput = _interopRequireDefault(require("../styles/GeopointInput.css"));
23
-
24
- var _GeopointSelect = _interopRequireDefault(require("./GeopointSelect"));
25
-
26
- var _GoogleMapsLoadProxy = _interopRequireDefault(require("./GoogleMapsLoadProxy"));
27
-
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
-
32
- var getLocale = context => {
33
- var intl = context.intl || {};
34
- return intl.locale || typeof window !== 'undefined' && window.navigator.language || 'en';
35
- };
36
-
37
- var getStaticImageUrl = value => {
38
- var loc = "".concat(value.lat, ",").concat(value.lng);
39
- var params = {
40
- key: _googleMapsInput.default.apiKey,
41
- center: loc,
42
- markers: loc,
43
- zoom: 13,
44
- scale: 2,
45
- size: '640x300'
46
- };
47
- var qs = Object.keys(params).reduce((res, param) => {
48
- return res.concat("".concat(param, "=").concat(encodeURIComponent(params[param])));
49
- }, []);
50
- return "https://maps.googleapis.com/maps/api/staticmap?".concat(qs.join('&'));
51
- };
52
-
53
- class GeopointInput extends _react.default.Component {
54
- constructor() {
55
- super();
56
-
57
- _defineProperty(this, "handleChange", latLng => {
58
- var _this$props = this.props,
59
- type = _this$props.type,
60
- onChange = _this$props.onChange;
61
- onChange(_patchEvent.PatchEvent.from([(0, _patchEvent.setIfMissing)({
62
- _type: type.name
63
- }), (0, _patchEvent.set)(latLng.lat(), ['lat']), (0, _patchEvent.set)(latLng.lng(), ['lng'])]));
64
- });
65
-
66
- _defineProperty(this, "handleClear", () => {
67
- var onChange = this.props.onChange;
68
- onChange(_patchEvent.PatchEvent.from((0, _patchEvent.unset)()));
69
- });
70
-
71
- this.handleToggleModal = this.handleToggleModal.bind(this);
72
- this.handleCloseModal = this.handleCloseModal.bind(this);
73
- this.state = {
74
- modalOpen: false
75
- };
76
- }
77
-
78
- handleToggleModal() {
79
- this.setState(prevState => ({
80
- modalOpen: !prevState.modalOpen
81
- }));
82
- }
83
-
84
- handleCloseModal() {
85
- this.setState({
86
- modalOpen: false
87
- });
88
- }
89
-
90
- render() {
91
- var _this$props2 = this.props,
92
- value = _this$props2.value,
93
- type = _this$props2.type,
94
- markers = _this$props2.markers;
95
-
96
- if (!_googleMapsInput.default || !_googleMapsInput.default.apiKey) {
97
- return _react.default.createElement("div", null, _react.default.createElement("p", null, "The ", _react.default.createElement("a", {
98
- href: "https://sanity.io/docs/schema-types/geopoint-type"
99
- }, "Geopoint type"), " needs a Google Maps API key with access to:"), _react.default.createElement("ul", null, _react.default.createElement("li", null, "Google Maps JavaScript API"), _react.default.createElement("li", null, "Google Places API Web Service"), _react.default.createElement("li", null, "Google Static Maps API")), _react.default.createElement("p", null, "Please enter the API key with access to these services in", _react.default.createElement("code", {
100
- style: {
101
- whitespace: 'nowrap'
102
- }
103
- }, "`<project-root>/config/@sanity/google-maps-input.json`")));
104
- }
105
-
106
- return _react.default.createElement(_default4.default, {
107
- legend: type.title,
108
- description: type.description,
109
- className: _GeopointInput.default.root,
110
- markers: markers
111
- }, value && _react.default.createElement("div", null, _react.default.createElement("img", {
112
- className: _GeopointInput.default.previewImage,
113
- src: getStaticImageUrl(value),
114
- alt: "Map location"
115
- })), _react.default.createElement("div", {
116
- className: _GeopointInput.default.functions
117
- }, _react.default.createElement(_default2.default, {
118
- onClick: this.handleToggleModal
119
- }, value ? 'Edit' : 'Set location'), value && _react.default.createElement(_default2.default, {
120
- type: "button",
121
- onClick: this.handleClear
122
- }, "Remove")), this.state.modalOpen && _react.default.createElement(_default3.default, {
123
- title: "Place on map",
124
- onClose: this.handleCloseModal,
125
- onCloseClick: this.handleCloseModal,
126
- onOpen: this.handleOpenModal,
127
- message: "Select location by dragging the marker or search for a place",
128
- isOpen: this.state.modalOpen
129
- }, _react.default.createElement("div", {
130
- className: _GeopointInput.default.dialogInner
131
- }, _react.default.createElement(_GoogleMapsLoadProxy.default, {
132
- value: value,
133
- apiKey: _googleMapsInput.default.apiKey,
134
- onChange: this.handleChange,
135
- defaultLocation: _googleMapsInput.default.defaultLocation,
136
- defaultZoom: _googleMapsInput.default.defaultZoom,
137
- locale: getLocale(this.context),
138
- component: _GeopointSelect.default
139
- }))));
140
- }
141
-
142
- }
143
-
144
- _defineProperty(GeopointInput, "propTypes", {
145
- onChange: _propTypes.default.func.isRequired,
146
- markers: _propTypes.default.arrayOf(_propTypes.default.shape({
147
- type: _propTypes.default.string
148
- })),
149
- value: _propTypes.default.shape({
150
- lat: _propTypes.default.number,
151
- lng: _propTypes.default.number
152
- }),
153
- type: _propTypes.default.shape({
154
- title: _propTypes.default.string.isRequired,
155
- description: _propTypes.default.string
156
- })
157
- });
158
-
159
- _defineProperty(GeopointInput, "defaultProps", {
160
- markers: []
161
- });
162
-
163
- _defineProperty(GeopointInput, "contextTypes", {
164
- intl: _propTypes.default.shape({
165
- locale: _propTypes.default.string
166
- })
167
- });
168
-
169
- var _default = GeopointInput;
170
- exports.default = _default;