-
Notifications
You must be signed in to change notification settings - Fork 925
Expand file tree
/
Copy pathStandaloneSearchBox.js
More file actions
216 lines (178 loc) · 5.58 KB
/
StandaloneSearchBox.js
File metadata and controls
216 lines (178 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
"use strict"
Object.defineProperty(exports, "__esModule", {
value: true,
})
exports.StandaloneSearchBox = undefined
var _defineProperty2 = require("babel-runtime/helpers/defineProperty")
var _defineProperty3 = _interopRequireDefault(_defineProperty2)
var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of")
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf)
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck")
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2)
var _createClass2 = require("babel-runtime/helpers/createClass")
var _createClass3 = _interopRequireDefault(_createClass2)
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn")
var _possibleConstructorReturn3 = _interopRequireDefault(
_possibleConstructorReturn2
)
var _inherits2 = require("babel-runtime/helpers/inherits")
var _inherits3 = _interopRequireDefault(_inherits2)
var _invariant = require("invariant")
var _invariant2 = _interopRequireDefault(_invariant)
var _react = require("react")
var _react2 = _interopRequireDefault(_react)
var _reactDom = require("react-dom")
var _reactDom2 = _interopRequireDefault(_reactDom)
var _propTypes = require("prop-types")
var _propTypes2 = _interopRequireDefault(_propTypes)
var _MapChildHelper = require("../../utils/MapChildHelper")
var _constants = require("../../constants")
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj }
}
/**
* A wrapper around `google.maps.places.SearchBox` without the map
*
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#SearchBox
*/
/*
* -----------------------------------------------------------------------------
* This file is auto-generated from the corresponding file at `src/macros/`.
* Please **DO NOT** edit this file directly when creating PRs.
* -----------------------------------------------------------------------------
*/
/* global google */
var SearchBox = (function(_React$PureComponent) {
;(0, _inherits3.default)(SearchBox, _React$PureComponent)
function SearchBox() {
var _ref
var _temp, _this, _ret
;(0, _classCallCheck3.default)(this, SearchBox)
for (
var _len = arguments.length, args = Array(_len), _key = 0;
_key < _len;
_key++
) {
args[_key] = arguments[_key]
}
return (
(_ret = ((_temp = ((_this = (0, _possibleConstructorReturn3.default)(
this,
(_ref =
SearchBox.__proto__ ||
(0, _getPrototypeOf2.default)(SearchBox)).call.apply(
_ref,
[this].concat(args)
)
)),
_this)),
(_this.state = (0, _defineProperty3.default)(
{},
_constants.SEARCH_BOX,
null
)),
_temp)),
(0, _possibleConstructorReturn3.default)(_this, _ret)
)
}
;(0, _createClass3.default)(SearchBox, [
{
key: "componentDidMount",
value: function componentDidMount() {
;(0, _invariant2.default)(
google.maps.places,
'Did you include "libraries=places" in the URL?'
)
var element = _reactDom2.default.findDOMNode(this)
/*
* @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#SearchBox
*/
var searchBox = new google.maps.places.SearchBox(
element.querySelector("input") || element
)
;(0, _MapChildHelper.construct)(
SearchBox.propTypes,
updaterMap,
this.props,
searchBox
)
;(0, _MapChildHelper.componentDidMount)(this, searchBox, eventMap)
this.setState(
(0, _defineProperty3.default)({}, _constants.SEARCH_BOX, searchBox)
)
},
},
{
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
;(0, _MapChildHelper.componentDidUpdate)(
this,
this.state[_constants.SEARCH_BOX],
eventMap,
updaterMap,
prevProps
)
},
},
{
key: "componentWillUnmount",
value: function componentWillUnmount() {
;(0, _MapChildHelper.componentWillUnmount)(this)
},
},
{
key: "render",
value: function render() {
return _react2.default.Children.only(this.props.children)
},
/**
* Returns the bounds to which query predictions are biased.
* @type LatLngBounds
* @public
*/
},
{
key: "getBounds",
value: function getBounds() {
return this.state[_constants.SEARCH_BOX].getBounds()
},
/**
* Returns the query selected by the user, or `null` if no places have been found yet, to be used with `places_changed` event.
* @type Array<PlaceResult>nullplaces_changed
* @public
*/
},
{
key: "getPlaces",
value: function getPlaces() {
return this.state[_constants.SEARCH_BOX].getPlaces()
},
},
])
return SearchBox
})(_react2.default.PureComponent)
SearchBox.displayName = "StandaloneSearchBox"
SearchBox.propTypes = {
/**
* @type LatLngBounds|LatLngBoundsLiteral
*/
defaultBounds: _propTypes2.default.any,
/**
* @type LatLngBounds|LatLngBoundsLiteral
*/
bounds: _propTypes2.default.any,
/**
* function
*/
onPlacesChanged: _propTypes2.default.func,
}
var StandaloneSearchBox = (exports.StandaloneSearchBox = SearchBox)
exports.default = StandaloneSearchBox
var eventMap = {
onPlacesChanged: "places_changed",
}
var updaterMap = {
bounds: function bounds(instance, _bounds) {
instance.setBounds(_bounds)
},
}