@contentful/field-editor-location 1.2.2 → 1.3.0
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/dist/cjs/GoogleMapView.js +156 -0
- package/dist/cjs/LocationEditor.js +204 -0
- package/dist/cjs/LocationSearchInput.js +153 -0
- package/dist/cjs/LocationSelector.js +184 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/types.js +15 -0
- package/dist/esm/GoogleMapView.js +102 -0
- package/dist/esm/LocationEditor.js +142 -0
- package/dist/esm/LocationSearchInput.js +99 -0
- package/dist/esm/LocationSelector.js +130 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/types.js +5 -0
- package/dist/{GoogleMapView.d.ts → types/GoogleMapView.d.ts} +25 -25
- package/dist/{LocationEditor.d.ts → types/LocationEditor.d.ts} +45 -45
- package/dist/{LocationSearchInput.d.ts → types/LocationSearchInput.d.ts} +11 -11
- package/dist/{LocationSelector.d.ts → types/LocationSelector.d.ts} +13 -13
- package/dist/{index.d.ts → types/index.d.ts} +2 -2
- package/dist/{types.d.ts → types/types.d.ts} +22 -22
- package/package.json +23 -9
- package/CHANGELOG.md +0 -210
- package/dist/field-editor-location.cjs.development.js +0 -545
- package/dist/field-editor-location.cjs.development.js.map +0 -1
- package/dist/field-editor-location.cjs.production.min.js +0 -2
- package/dist/field-editor-location.cjs.production.min.js.map +0 -1
- package/dist/field-editor-location.esm.js +0 -538
- package/dist/field-editor-location.esm.js.map +0 -1
- package/dist/index.js +0 -8
|
@@ -1,545 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var React__default = _interopDefault(React);
|
|
9
|
-
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
10
|
-
var deepEqual = _interopDefault(require('deep-equal'));
|
|
11
|
-
var isNumber = _interopDefault(require('lodash/isNumber'));
|
|
12
|
-
var throttle = _interopDefault(require('lodash/throttle'));
|
|
13
|
-
var emotion = require('emotion');
|
|
14
|
-
var GoogleMapReact = _interopDefault(require('google-map-react'));
|
|
15
|
-
var f36Components = require('@contentful/f36-components');
|
|
16
|
-
var tokens = _interopDefault(require('@contentful/f36-tokens'));
|
|
17
|
-
|
|
18
|
-
function _inheritsLoose(subClass, superClass) {
|
|
19
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
20
|
-
subClass.prototype.constructor = subClass;
|
|
21
|
-
|
|
22
|
-
_setPrototypeOf(subClass, superClass);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function _setPrototypeOf(o, p) {
|
|
26
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
27
|
-
o.__proto__ = p;
|
|
28
|
-
return o;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return _setPrototypeOf(o, p);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var styles = {
|
|
35
|
-
root: /*#__PURE__*/emotion.css({
|
|
36
|
-
height: '300px',
|
|
37
|
-
width: '100%'
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
var BerlinLocation = {
|
|
41
|
-
lat: 52.5018,
|
|
42
|
-
lng: 13.41115439
|
|
43
|
-
};
|
|
44
|
-
var GoogleMapView = /*#__PURE__*/function (_React$Component) {
|
|
45
|
-
_inheritsLoose(GoogleMapView, _React$Component);
|
|
46
|
-
|
|
47
|
-
function GoogleMapView(props) {
|
|
48
|
-
var _this;
|
|
49
|
-
|
|
50
|
-
_this = _React$Component.call(this, props) || this;
|
|
51
|
-
|
|
52
|
-
_this.onGoogleApiLoaded = function (event) {
|
|
53
|
-
var maps = event.maps,
|
|
54
|
-
map = event.map;
|
|
55
|
-
var marker = new maps.Marker({
|
|
56
|
-
map: map,
|
|
57
|
-
position: map.getCenter(),
|
|
58
|
-
cursor: _this.props.disabled ? 'not-allowed' : 'auto',
|
|
59
|
-
draggable: !_this.props.disabled,
|
|
60
|
-
visible: Boolean(_this.props.location)
|
|
61
|
-
});
|
|
62
|
-
maps.event.addListener(map, 'click', function (event) {
|
|
63
|
-
if (_this.props.disabled || !_this.state.marker || !_this.state.maps) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
_this.state.marker.setPosition(event.latLng);
|
|
68
|
-
|
|
69
|
-
_this.state.marker.setVisible(true);
|
|
70
|
-
|
|
71
|
-
_this.props.onChangeLocation({
|
|
72
|
-
lat: event.latLng.lat(),
|
|
73
|
-
lng: event.latLng.lng()
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
maps.event.addListener(marker, 'dragend', function (event) {
|
|
77
|
-
_this.props.onChangeLocation({
|
|
78
|
-
lat: event.latLng.lat(),
|
|
79
|
-
lng: event.latLng.lng()
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
_this.setState({
|
|
84
|
-
marker: marker,
|
|
85
|
-
maps: maps
|
|
86
|
-
}, function () {
|
|
87
|
-
_this.props.onGoogleApiLoaded({
|
|
88
|
-
maps: maps
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
_this.state = {
|
|
94
|
-
marker: undefined,
|
|
95
|
-
maps: undefined
|
|
96
|
-
};
|
|
97
|
-
return _this;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var _proto = GoogleMapView.prototype;
|
|
101
|
-
|
|
102
|
-
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
103
|
-
if (this.state.marker && this.state.maps) {
|
|
104
|
-
if (this.props.location) {
|
|
105
|
-
var latLng = new this.state.maps.LatLng(this.props.location.lat, this.props.location.lng);
|
|
106
|
-
this.state.marker.setPosition(latLng);
|
|
107
|
-
this.state.marker.setVisible(true);
|
|
108
|
-
} else {
|
|
109
|
-
this.state.marker.setVisible(false);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
this.state.marker.setDraggable(!this.props.disabled);
|
|
113
|
-
this.state.marker.setCursor(this.props.disabled ? 'not-allowed' : 'auto');
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
_proto.render = function render() {
|
|
118
|
-
return React__default.createElement("div", {
|
|
119
|
-
className: styles.root
|
|
120
|
-
}, React__default.createElement(GoogleMapReact, {
|
|
121
|
-
draggable: !this.props.disabled,
|
|
122
|
-
bootstrapURLKeys: this.props.googleMapsKey ? {
|
|
123
|
-
key: this.props.googleMapsKey
|
|
124
|
-
} : undefined,
|
|
125
|
-
defaultCenter: BerlinLocation,
|
|
126
|
-
center: this.props.location,
|
|
127
|
-
options: {
|
|
128
|
-
scrollwheel: false,
|
|
129
|
-
mapTypeId: 'roadmap'
|
|
130
|
-
},
|
|
131
|
-
defaultZoom: 6,
|
|
132
|
-
yesIWantToUseGoogleMapApiInternals: true,
|
|
133
|
-
onGoogleApiLoaded: this.onGoogleApiLoaded
|
|
134
|
-
}));
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
return GoogleMapView;
|
|
138
|
-
}(React__default.Component);
|
|
139
|
-
|
|
140
|
-
var styles$1 = {
|
|
141
|
-
root: /*#__PURE__*/emotion.css({
|
|
142
|
-
width: '100%'
|
|
143
|
-
}),
|
|
144
|
-
input: /*#__PURE__*/emotion.css({
|
|
145
|
-
position: 'relative',
|
|
146
|
-
width: '100%'
|
|
147
|
-
}),
|
|
148
|
-
spinner: /*#__PURE__*/emotion.css({
|
|
149
|
-
position: 'absolute',
|
|
150
|
-
right: 10,
|
|
151
|
-
top: 10,
|
|
152
|
-
zIndex: 99
|
|
153
|
-
}),
|
|
154
|
-
validationMessage: /*#__PURE__*/emotion.css({
|
|
155
|
-
marginTop: tokens.spacingS
|
|
156
|
-
}),
|
|
157
|
-
suggestion: /*#__PURE__*/emotion.css({
|
|
158
|
-
position: 'absolute',
|
|
159
|
-
transform: 'translateY(100%)',
|
|
160
|
-
bottom: 0,
|
|
161
|
-
left: 0,
|
|
162
|
-
zIndex: 1
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
function LocationSearchInput(props) {
|
|
166
|
-
var _React$useState = React__default.useState(false),
|
|
167
|
-
isSearching = _React$useState[0],
|
|
168
|
-
setIsSearching = _React$useState[1];
|
|
169
|
-
|
|
170
|
-
var _React$useState2 = React__default.useState(''),
|
|
171
|
-
address = _React$useState2[0],
|
|
172
|
-
setAddress = _React$useState2[1];
|
|
173
|
-
|
|
174
|
-
var _React$useState3 = React__default.useState(false),
|
|
175
|
-
hasError = _React$useState3[0],
|
|
176
|
-
setHasError = _React$useState3[1];
|
|
177
|
-
|
|
178
|
-
var _React$useState4 = React__default.useState(null),
|
|
179
|
-
suggestion = _React$useState4[0],
|
|
180
|
-
setSuggestion = _React$useState4[1];
|
|
181
|
-
|
|
182
|
-
React__default.useEffect(function () {
|
|
183
|
-
setIsSearching(true);
|
|
184
|
-
props.onGetAddressFromLocation(props.value, address).then(function (address) {
|
|
185
|
-
setAddress(address);
|
|
186
|
-
setIsSearching(false);
|
|
187
|
-
}); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
|
|
188
|
-
}, [props.value, props.disabled]);
|
|
189
|
-
return React__default.createElement("div", {
|
|
190
|
-
className: styles$1.root
|
|
191
|
-
}, React__default.createElement("div", {
|
|
192
|
-
className: styles$1.input
|
|
193
|
-
}, React__default.createElement(f36Components.TextInput, {
|
|
194
|
-
testId: "location-editor-search",
|
|
195
|
-
isInvalid: hasError,
|
|
196
|
-
placeholder: "Start typing to find location",
|
|
197
|
-
value: address,
|
|
198
|
-
onChange: function onChange(e) {
|
|
199
|
-
setAddress(e.target.value);
|
|
200
|
-
setHasError(false);
|
|
201
|
-
setSuggestion(null);
|
|
202
|
-
|
|
203
|
-
if (e.target.value === '') {
|
|
204
|
-
props.onChangeLocation(undefined);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
setIsSearching(true);
|
|
209
|
-
props.onSearchAddress(e.target.value).then(function (value) {
|
|
210
|
-
setIsSearching(false);
|
|
211
|
-
|
|
212
|
-
if (value === null) {
|
|
213
|
-
setHasError(false);
|
|
214
|
-
} else if (value.length === 0) {
|
|
215
|
-
setHasError(true);
|
|
216
|
-
} else {
|
|
217
|
-
setHasError(false);
|
|
218
|
-
setSuggestion({
|
|
219
|
-
address: value[0].formatted_address,
|
|
220
|
-
location: {
|
|
221
|
-
lat: Number(value[0].geometry.location.lat().toString().slice(0, 8)),
|
|
222
|
-
lng: Number(value[0].geometry.location.lng().toString().slice(0, 8))
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
isDisabled: props.disabled
|
|
229
|
-
}), isSearching && React__default.createElement(f36Components.Spinner, {
|
|
230
|
-
className: styles$1.spinner
|
|
231
|
-
}), suggestion && React__default.createElement(f36Components.Card, {
|
|
232
|
-
padding: "none",
|
|
233
|
-
className: styles$1.suggestion
|
|
234
|
-
}, React__default.createElement(f36Components.Button, {
|
|
235
|
-
variant: "transparent",
|
|
236
|
-
testId: "location-editor-suggestion",
|
|
237
|
-
onClick: function onClick() {
|
|
238
|
-
setAddress(suggestion.address);
|
|
239
|
-
props.onChangeLocation(suggestion.location);
|
|
240
|
-
setSuggestion(null);
|
|
241
|
-
}
|
|
242
|
-
}, suggestion.address)), hasError && React__default.createElement(f36Components.ValidationMessage, {
|
|
243
|
-
testId: "location-editor-not-found",
|
|
244
|
-
className: styles$1.validationMessage
|
|
245
|
-
}, "No results found for ", React__default.createElement("strong", null, address), ". Please make sure that address is spelled correctly.")));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
var ViewType;
|
|
249
|
-
|
|
250
|
-
(function (ViewType) {
|
|
251
|
-
ViewType["Address"] = "Address";
|
|
252
|
-
ViewType["Coordinates"] = "Coordinates";
|
|
253
|
-
})(ViewType || (ViewType = {}));
|
|
254
|
-
|
|
255
|
-
var styles$2 = {
|
|
256
|
-
root: /*#__PURE__*/emotion.css({
|
|
257
|
-
display: 'flex',
|
|
258
|
-
flexDirection: 'row',
|
|
259
|
-
marginTop: tokens.spacingS,
|
|
260
|
-
alignItems: 'flex-end'
|
|
261
|
-
}),
|
|
262
|
-
main: /*#__PURE__*/emotion.css({
|
|
263
|
-
flexGrow: 1
|
|
264
|
-
}),
|
|
265
|
-
secondary: /*#__PURE__*/emotion.css({
|
|
266
|
-
minWidth: '70px',
|
|
267
|
-
textAlign: 'right'
|
|
268
|
-
}),
|
|
269
|
-
inputsRow: /*#__PURE__*/emotion.css({
|
|
270
|
-
display: 'flex',
|
|
271
|
-
marginTop: tokens.spacingS,
|
|
272
|
-
fontSize: tokens.fontSizeM,
|
|
273
|
-
color: tokens.gray900,
|
|
274
|
-
fontFamily: tokens.fontStackPrimary,
|
|
275
|
-
alignItems: 'center'
|
|
276
|
-
}),
|
|
277
|
-
splitter: /*#__PURE__*/emotion.css({
|
|
278
|
-
width: tokens.spacingL
|
|
279
|
-
}),
|
|
280
|
-
clearBtn: /*#__PURE__*/emotion.css({
|
|
281
|
-
marginBottom: tokens.spacingS
|
|
282
|
-
})
|
|
283
|
-
};
|
|
284
|
-
function LocationSelector(props) {
|
|
285
|
-
return React__default.createElement("div", {
|
|
286
|
-
className: styles$2.root
|
|
287
|
-
}, React__default.createElement("div", {
|
|
288
|
-
className: styles$2.main
|
|
289
|
-
}, React__default.createElement(f36Components.Flex, {
|
|
290
|
-
flexDirection: "row"
|
|
291
|
-
}, React__default.createElement(f36Components.Radio, {
|
|
292
|
-
className: emotion.css({
|
|
293
|
-
flexBasis: '100%'
|
|
294
|
-
}),
|
|
295
|
-
id: ViewType.Address,
|
|
296
|
-
testId: "location-editor-address-radio",
|
|
297
|
-
isDisabled: props.disabled,
|
|
298
|
-
value: ViewType.Address,
|
|
299
|
-
isChecked: props.view === ViewType.Address,
|
|
300
|
-
onChange: function onChange() {
|
|
301
|
-
props.onChangeView(ViewType.Address);
|
|
302
|
-
}
|
|
303
|
-
}, "Address"), React__default.createElement(f36Components.Radio, {
|
|
304
|
-
className: emotion.css({
|
|
305
|
-
flexBasis: '100%'
|
|
306
|
-
}),
|
|
307
|
-
id: ViewType.Coordinates,
|
|
308
|
-
testId: "location-editor-coordinates-radio",
|
|
309
|
-
isDisabled: props.disabled,
|
|
310
|
-
value: ViewType.Coordinates,
|
|
311
|
-
isChecked: props.view === ViewType.Coordinates,
|
|
312
|
-
onChange: function onChange() {
|
|
313
|
-
props.onChangeView(ViewType.Coordinates);
|
|
314
|
-
}
|
|
315
|
-
}, "Coordinates")), props.view === ViewType.Address && React__default.createElement("div", {
|
|
316
|
-
className: styles$2.inputsRow
|
|
317
|
-
}, React__default.createElement(LocationSearchInput, {
|
|
318
|
-
onSearchAddress: props.onSearchAddress,
|
|
319
|
-
onGetAddressFromLocation: props.onGetAddressFromLocation,
|
|
320
|
-
disabled: props.disabled,
|
|
321
|
-
value: props.value,
|
|
322
|
-
onChangeLocation: props.onChangeLocation
|
|
323
|
-
})), props.view === ViewType.Coordinates && React__default.createElement("div", {
|
|
324
|
-
className: styles$2.inputsRow
|
|
325
|
-
}, React__default.createElement("label", {
|
|
326
|
-
htmlFor: "latitude"
|
|
327
|
-
}, "Latitude"), React__default.createElement("div", {
|
|
328
|
-
className: styles$2.splitter
|
|
329
|
-
}), React__default.createElement(f36Components.TextInput, {
|
|
330
|
-
id: "latitude",
|
|
331
|
-
testId: "location-editor-latitude",
|
|
332
|
-
placeholder: "Between -90 and 90",
|
|
333
|
-
isDisabled: props.disabled,
|
|
334
|
-
value: props.value ? String(props.value.lat) : '',
|
|
335
|
-
onChange: function onChange(e) {
|
|
336
|
-
props.onChangeLocation({
|
|
337
|
-
lng: props.value && props.value.lng !== undefined ? props.value.lng : 0,
|
|
338
|
-
lat: Number(e.target.value) || 0
|
|
339
|
-
});
|
|
340
|
-
},
|
|
341
|
-
type: "number",
|
|
342
|
-
max: "90",
|
|
343
|
-
min: "-90",
|
|
344
|
-
step: "0.1"
|
|
345
|
-
}), React__default.createElement("div", {
|
|
346
|
-
className: styles$2.splitter
|
|
347
|
-
}), React__default.createElement("label", {
|
|
348
|
-
htmlFor: "longitude"
|
|
349
|
-
}, "Longitude"), React__default.createElement("div", {
|
|
350
|
-
className: styles$2.splitter
|
|
351
|
-
}), React__default.createElement(f36Components.TextInput, {
|
|
352
|
-
id: "longitude",
|
|
353
|
-
testId: "location-editor-longitude",
|
|
354
|
-
placeholder: "Between -180 and 180",
|
|
355
|
-
isDisabled: props.disabled,
|
|
356
|
-
value: props.value ? String(props.value.lng) : '',
|
|
357
|
-
onChange: function onChange(e) {
|
|
358
|
-
props.onChangeLocation({
|
|
359
|
-
lat: props.value && props.value.lat !== undefined ? props.value.lat : 0,
|
|
360
|
-
lng: Number(e.target.value) || 0
|
|
361
|
-
});
|
|
362
|
-
},
|
|
363
|
-
type: "number",
|
|
364
|
-
max: "180",
|
|
365
|
-
min: "-180",
|
|
366
|
-
step: "0.1"
|
|
367
|
-
}))), React__default.createElement("div", {
|
|
368
|
-
className: styles$2.secondary
|
|
369
|
-
}, React__default.createElement(f36Components.TextLink, {
|
|
370
|
-
as: "button",
|
|
371
|
-
isDisabled: props.disabled,
|
|
372
|
-
testId: "location-editor-clear",
|
|
373
|
-
className: styles$2.clearBtn,
|
|
374
|
-
onClick: function onClick() {
|
|
375
|
-
props.onChangeLocation(undefined);
|
|
376
|
-
}
|
|
377
|
-
}, "Clear")));
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
function toLocationValue(coords) {
|
|
381
|
-
if (coords && isNumber(coords.lat) && isNumber(coords.lng)) {
|
|
382
|
-
return {
|
|
383
|
-
lat: coords.lat,
|
|
384
|
-
lon: coords.lng
|
|
385
|
-
};
|
|
386
|
-
} else {
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
var LocationEditor = /*#__PURE__*/function (_React$Component) {
|
|
392
|
-
_inheritsLoose(LocationEditor, _React$Component);
|
|
393
|
-
|
|
394
|
-
function LocationEditor(props) {
|
|
395
|
-
var _this;
|
|
396
|
-
|
|
397
|
-
_this = _React$Component.call(this, props) || this;
|
|
398
|
-
_this.onSearchAddress = throttle(function (value) {
|
|
399
|
-
if (!_this.state.mapsObject) {
|
|
400
|
-
return Promise.resolve(null);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
var mapsObject = _this.state.mapsObject;
|
|
404
|
-
|
|
405
|
-
if (!value) {
|
|
406
|
-
return Promise.resolve(null);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return new Promise(function (resolve) {
|
|
410
|
-
var geocoder = new mapsObject.Geocoder();
|
|
411
|
-
geocoder.geocode({
|
|
412
|
-
address: value
|
|
413
|
-
}, resolve, function () {
|
|
414
|
-
resolve(null);
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
}, 300);
|
|
418
|
-
|
|
419
|
-
_this.onGetAddressFromLocation = function (location, value) {
|
|
420
|
-
if (!_this.state.mapsObject || !location) {
|
|
421
|
-
return Promise.resolve('');
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
var mapsObject = _this.state.mapsObject;
|
|
425
|
-
return new Promise(function (resolve) {
|
|
426
|
-
var geocoder = new mapsObject.Geocoder();
|
|
427
|
-
geocoder.geocode({
|
|
428
|
-
location: location
|
|
429
|
-
}, function (result) {
|
|
430
|
-
if (result && result.length > 0) {
|
|
431
|
-
var addresses = result.map(function (item) {
|
|
432
|
-
return item.formatted_address;
|
|
433
|
-
});
|
|
434
|
-
resolve(addresses.find(function (item) {
|
|
435
|
-
return item === value;
|
|
436
|
-
}) || addresses[0]);
|
|
437
|
-
} else {
|
|
438
|
-
resolve('');
|
|
439
|
-
}
|
|
440
|
-
}, function () {
|
|
441
|
-
resolve('');
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
_this.state = {
|
|
447
|
-
localValue: props.value ? {
|
|
448
|
-
lng: props.value.lon,
|
|
449
|
-
lat: props.value.lat
|
|
450
|
-
} : undefined,
|
|
451
|
-
mapsObject: null
|
|
452
|
-
};
|
|
453
|
-
return _this;
|
|
454
|
-
} // @ts-expect-error
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
var _proto = LocationEditor.prototype;
|
|
458
|
-
|
|
459
|
-
_proto.render = function render() {
|
|
460
|
-
var _this2 = this;
|
|
461
|
-
|
|
462
|
-
var _this$state = this.state,
|
|
463
|
-
mapsObject = _this$state.mapsObject,
|
|
464
|
-
localValue = _this$state.localValue;
|
|
465
|
-
return React.createElement("div", {
|
|
466
|
-
"data-test-id": "location-editor"
|
|
467
|
-
}, React.createElement(GoogleMapView, {
|
|
468
|
-
disabled: this.props.disabled || mapsObject === null,
|
|
469
|
-
googleMapsKey: this.props.googleMapsKey,
|
|
470
|
-
location: localValue,
|
|
471
|
-
onGoogleApiLoaded: function onGoogleApiLoaded(_ref) {
|
|
472
|
-
var maps = _ref.maps;
|
|
473
|
-
|
|
474
|
-
_this2.setState({
|
|
475
|
-
mapsObject: maps
|
|
476
|
-
});
|
|
477
|
-
},
|
|
478
|
-
onChangeLocation: function onChangeLocation(coords) {
|
|
479
|
-
_this2.setState({
|
|
480
|
-
localValue: coords
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
_this2.props.setValue(toLocationValue(coords));
|
|
484
|
-
}
|
|
485
|
-
}), React.createElement(LocationSelector, {
|
|
486
|
-
disabled: this.props.disabled || mapsObject === null,
|
|
487
|
-
value: localValue,
|
|
488
|
-
view: this.props.selectedView,
|
|
489
|
-
onChangeView: function onChangeView(view) {
|
|
490
|
-
_this2.props.setSelectedView(view);
|
|
491
|
-
},
|
|
492
|
-
onChangeLocation: function onChangeLocation(coords) {
|
|
493
|
-
_this2.setState({
|
|
494
|
-
localValue: coords
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
_this2.props.setValue(toLocationValue(coords));
|
|
498
|
-
},
|
|
499
|
-
onSearchAddress: this.onSearchAddress,
|
|
500
|
-
onGetAddressFromLocation: this.onGetAddressFromLocation
|
|
501
|
-
}));
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
return LocationEditor;
|
|
505
|
-
}(React.Component);
|
|
506
|
-
function LocationEditorConnected(props) {
|
|
507
|
-
var field = props.field;
|
|
508
|
-
var googleMapsKey = props.parameters ? props.parameters.instance.googleMapsKey : undefined;
|
|
509
|
-
|
|
510
|
-
var _React$useState = React.useState(ViewType.Address),
|
|
511
|
-
selectedView = _React$useState[0],
|
|
512
|
-
setSelectedView = _React$useState[1];
|
|
513
|
-
|
|
514
|
-
return React.createElement(fieldEditorShared.FieldConnector, {
|
|
515
|
-
isEqualValues: function isEqualValues(value1, value2) {
|
|
516
|
-
return deepEqual(value1, value2);
|
|
517
|
-
},
|
|
518
|
-
field: field,
|
|
519
|
-
isInitiallyDisabled: props.isInitiallyDisabled
|
|
520
|
-
}, function (_ref2) {
|
|
521
|
-
var value = _ref2.value,
|
|
522
|
-
disabled = _ref2.disabled,
|
|
523
|
-
setValue = _ref2.setValue,
|
|
524
|
-
externalReset = _ref2.externalReset;
|
|
525
|
-
return React.createElement(LocationEditor // on external change reset component completely and init with initial value again
|
|
526
|
-
, {
|
|
527
|
-
// on external change reset component completely and init with initial value again
|
|
528
|
-
key: "location-editor-" + externalReset,
|
|
529
|
-
value: value,
|
|
530
|
-
disabled: disabled,
|
|
531
|
-
setValue: setValue,
|
|
532
|
-
googleMapsKey: googleMapsKey,
|
|
533
|
-
selectedView: selectedView,
|
|
534
|
-
setSelectedView: setSelectedView
|
|
535
|
-
});
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
LocationEditorConnected.defaultProps = {
|
|
539
|
-
isInitiallyDisabled: true
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
var LocationEditor$1 = LocationEditorConnected;
|
|
543
|
-
|
|
544
|
-
exports.LocationEditor = LocationEditor$1;
|
|
545
|
-
//# sourceMappingURL=field-editor-location.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-location.cjs.development.js","sources":["../src/GoogleMapView.tsx","../src/LocationSearchInput.tsx","../src/types.ts","../src/LocationSelector.tsx","../src/LocationEditor.tsx","../src/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport React from 'react';\n\nimport { css } from 'emotion';\nimport GoogleMapReact from 'google-map-react';\n\nimport { Coords } from './types';\n\nconst styles = {\n root: css({\n height: '300px',\n width: '100%',\n }),\n};\n\nconst BerlinLocation = {\n lat: 52.5018,\n lng: 13.41115439,\n};\n\ntype GoogleMapViewProps = {\n disabled: boolean;\n location: Coords | undefined;\n onGoogleApiLoaded: ({ maps }: { maps: any }) => void;\n onChangeLocation: (location: Coords) => void;\n googleMapsKey?: string;\n};\n\ntype GoogleMapsViewState = {\n marker: any;\n maps: any;\n};\n\nexport class GoogleMapView extends React.Component<GoogleMapViewProps, GoogleMapsViewState> {\n constructor(props: GoogleMapViewProps) {\n super(props);\n this.state = {\n marker: undefined,\n maps: undefined,\n };\n }\n\n componentDidUpdate() {\n if (this.state.marker && this.state.maps) {\n if (this.props.location) {\n const latLng = new this.state.maps.LatLng(this.props.location.lat, this.props.location.lng);\n this.state.marker.setPosition(latLng);\n this.state.marker.setVisible(true);\n } else {\n this.state.marker.setVisible(false);\n }\n this.state.marker.setDraggable(!this.props.disabled);\n this.state.marker.setCursor(this.props.disabled ? 'not-allowed' : 'auto');\n }\n }\n\n onGoogleApiLoaded = (event: { maps: any; map: any }) => {\n const { maps, map } = event;\n const marker = new maps.Marker({\n map,\n position: map.getCenter(),\n cursor: this.props.disabled ? 'not-allowed' : 'auto',\n draggable: !this.props.disabled,\n visible: Boolean(this.props.location),\n });\n\n maps.event.addListener(map, 'click', (event: any) => {\n if (this.props.disabled || !this.state.marker || !this.state.maps) {\n return;\n }\n this.state.marker.setPosition(event.latLng);\n this.state.marker.setVisible(true);\n this.props.onChangeLocation({\n lat: event.latLng.lat(),\n lng: event.latLng.lng(),\n });\n });\n\n maps.event.addListener(marker, 'dragend', (event: any) => {\n this.props.onChangeLocation({\n lat: event.latLng.lat(),\n lng: event.latLng.lng(),\n });\n });\n this.setState({ marker, maps }, () => {\n this.props.onGoogleApiLoaded({ maps });\n });\n };\n\n render() {\n return (\n <div className={styles.root}>\n <GoogleMapReact\n draggable={!this.props.disabled}\n bootstrapURLKeys={\n this.props.googleMapsKey ? { key: this.props.googleMapsKey } : undefined\n }\n defaultCenter={BerlinLocation}\n center={this.props.location}\n options={{\n scrollwheel: false,\n mapTypeId: 'roadmap',\n }}\n defaultZoom={6}\n yesIWantToUseGoogleMapApiInternals\n onGoogleApiLoaded={this.onGoogleApiLoaded}\n />\n </div>\n );\n }\n}\n","import React from 'react';\n\nimport { Button, Card, Spinner, ValidationMessage, TextInput } from '@contentful/f36-components';\nimport tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nimport { Coords, GeocodeApiResponse } from './types';\n\nconst styles = {\n root: css({\n width: '100%',\n }),\n input: css({\n position: 'relative',\n width: '100%',\n }),\n spinner: css({\n position: 'absolute',\n right: 10,\n top: 10,\n zIndex: 99,\n }),\n validationMessage: css({\n marginTop: tokens.spacingS,\n }),\n suggestion: css({\n position: 'absolute',\n transform: 'translateY(100%)',\n bottom: 0,\n left: 0,\n zIndex: 1,\n }),\n};\n\ntype LocationSearchInputProps = {\n disabled: boolean;\n value?: Coords;\n onSearchAddress: (term: string) => Promise<GeocodeApiResponse>;\n onGetAddressFromLocation: (coors: Coords | undefined, value: string) => Promise<string>;\n onChangeLocation: (location?: Coords) => void;\n};\n\nexport function LocationSearchInput(props: LocationSearchInputProps) {\n const [isSearching, setIsSearching] = React.useState<boolean>(false);\n const [address, setAddress] = React.useState<string>('');\n const [hasError, setHasError] = React.useState<boolean>(false);\n const [suggestion, setSuggestion] = React.useState<null | {\n address: string;\n location: { lat: number; lng: number };\n }>(null);\n\n React.useEffect(() => {\n setIsSearching(true);\n props.onGetAddressFromLocation(props.value, address).then((address) => {\n setAddress(address);\n setIsSearching(false);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies\n }, [props.value, props.disabled]);\n\n return (\n <div className={styles.root}>\n <div className={styles.input}>\n <TextInput\n testId=\"location-editor-search\"\n isInvalid={hasError}\n placeholder=\"Start typing to find location\"\n value={address}\n onChange={(e) => {\n setAddress(e.target.value);\n setHasError(false);\n setSuggestion(null);\n\n if (e.target.value === '') {\n props.onChangeLocation(undefined);\n return;\n }\n\n setIsSearching(true);\n props.onSearchAddress(e.target.value).then((value) => {\n setIsSearching(false);\n if (value === null) {\n setHasError(false);\n } else if (value.length === 0) {\n setHasError(true);\n } else {\n setHasError(false);\n setSuggestion({\n address: value[0].formatted_address,\n location: {\n lat: Number(value[0].geometry.location.lat().toString().slice(0, 8)),\n lng: Number(value[0].geometry.location.lng().toString().slice(0, 8)),\n },\n });\n }\n });\n }}\n isDisabled={props.disabled}\n />\n {isSearching && <Spinner className={styles.spinner} />}\n {suggestion && (\n <Card padding=\"none\" className={styles.suggestion}>\n <Button\n variant=\"transparent\"\n testId=\"location-editor-suggestion\"\n onClick={() => {\n setAddress(suggestion.address);\n props.onChangeLocation(suggestion.location);\n setSuggestion(null);\n }}\n >\n {suggestion.address}\n </Button>\n </Card>\n )}\n {hasError && (\n <ValidationMessage\n testId=\"location-editor-not-found\"\n className={styles.validationMessage}\n >\n No results found for <strong>{address}</strong>. Please make sure that address is\n spelled correctly.\n </ValidationMessage>\n )}\n </div>\n </div>\n );\n}\n","export interface Coords {\n lat: number;\n lng: number;\n}\n\nexport type LocationValue = { lat: number; lon: number };\nexport type NullableLocationValue = LocationValue | null | undefined;\n\nexport enum ViewType {\n Address = 'Address',\n Coordinates = 'Coordinates',\n}\n\nexport type GeocodeApiResponse = null | Array<{\n formatted_address: string;\n geometry: {\n location: {\n lat: () => number;\n lng: () => number;\n };\n };\n}>;\n","import React from 'react';\n\nimport { TextLink, TextInput, Radio, Flex } from '@contentful/f36-components';\nimport tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\n\nimport { LocationSearchInput } from './LocationSearchInput';\nimport { Coords, ViewType, GeocodeApiResponse } from './types';\n\ninterface LocationSelectorProps {\n disabled: boolean;\n value: Coords | undefined;\n view: ViewType;\n onChangeView: (view: ViewType) => void;\n onChangeLocation: (value?: Coords) => void;\n onSearchAddress: (value: string) => Promise<GeocodeApiResponse>;\n onGetAddressFromLocation: (location: Coords | undefined, address: string) => Promise<string>;\n}\n\nconst styles = {\n root: css({\n display: 'flex',\n flexDirection: 'row',\n marginTop: tokens.spacingS,\n alignItems: 'flex-end',\n }),\n main: css({\n flexGrow: 1,\n }),\n secondary: css({\n minWidth: '70px',\n textAlign: 'right',\n }),\n inputsRow: css({\n display: 'flex',\n marginTop: tokens.spacingS,\n fontSize: tokens.fontSizeM,\n color: tokens.gray900,\n fontFamily: tokens.fontStackPrimary,\n alignItems: 'center',\n }),\n splitter: css({\n width: tokens.spacingL,\n }),\n clearBtn: css({\n marginBottom: tokens.spacingS,\n }),\n};\n\nexport function LocationSelector(props: LocationSelectorProps) {\n return (\n <div className={styles.root}>\n <div className={styles.main}>\n <Flex flexDirection=\"row\">\n <Radio\n className={css({ flexBasis: '100%' })}\n id={ViewType.Address}\n testId=\"location-editor-address-radio\"\n isDisabled={props.disabled}\n value={ViewType.Address}\n isChecked={props.view === ViewType.Address}\n onChange={() => {\n props.onChangeView(ViewType.Address);\n }}\n >\n Address\n </Radio>\n <Radio\n className={css({ flexBasis: '100%' })}\n id={ViewType.Coordinates}\n testId=\"location-editor-coordinates-radio\"\n isDisabled={props.disabled}\n value={ViewType.Coordinates}\n isChecked={props.view === ViewType.Coordinates}\n onChange={() => {\n props.onChangeView(ViewType.Coordinates);\n }}\n >\n Coordinates\n </Radio>\n </Flex>\n {props.view === ViewType.Address && (\n <div className={styles.inputsRow}>\n <LocationSearchInput\n onSearchAddress={props.onSearchAddress}\n onGetAddressFromLocation={props.onGetAddressFromLocation}\n disabled={props.disabled}\n value={props.value}\n onChangeLocation={props.onChangeLocation}\n />\n </div>\n )}\n {props.view === ViewType.Coordinates && (\n <div className={styles.inputsRow}>\n <label htmlFor=\"latitude\">Latitude</label>\n <div className={styles.splitter} />\n <TextInput\n id=\"latitude\"\n testId=\"location-editor-latitude\"\n placeholder=\"Between -90 and 90\"\n isDisabled={props.disabled}\n value={props.value ? String(props.value.lat) : ''}\n onChange={(e) => {\n props.onChangeLocation({\n lng: props.value && props.value.lng !== undefined ? props.value.lng : 0,\n lat: Number(e.target.value) || 0,\n });\n }}\n type=\"number\"\n max=\"90\"\n min=\"-90\"\n step=\"0.1\"\n />\n <div className={styles.splitter} />\n <label htmlFor=\"longitude\">Longitude</label>\n <div className={styles.splitter} />\n <TextInput\n id=\"longitude\"\n testId=\"location-editor-longitude\"\n placeholder=\"Between -180 and 180\"\n isDisabled={props.disabled}\n value={props.value ? String(props.value.lng) : ''}\n onChange={(e) => {\n props.onChangeLocation({\n lat: props.value && props.value.lat !== undefined ? props.value.lat : 0,\n lng: Number(e.target.value) || 0,\n });\n }}\n type=\"number\"\n max=\"180\"\n min=\"-180\"\n step=\"0.1\"\n />\n </div>\n )}\n </div>\n <div className={styles.secondary}>\n <TextLink\n as=\"button\"\n isDisabled={props.disabled}\n testId=\"location-editor-clear\"\n className={styles.clearBtn}\n onClick={() => {\n props.onChangeLocation(undefined);\n }}\n >\n Clear\n </TextLink>\n </div>\n </div>\n );\n}\n","import * as React from 'react';\n\nimport { FieldAPI, FieldConnector, ParametersAPI } from '@contentful/field-editor-shared';\nimport deepEqual from 'deep-equal';\nimport isNumber from 'lodash/isNumber';\nimport throttle from 'lodash/throttle';\n\nimport { GoogleMapView } from './GoogleMapView';\nimport { LocationSelector } from './LocationSelector';\nimport {\n LocationValue,\n ViewType,\n NullableLocationValue,\n Coords,\n GeocodeApiResponse,\n} from './types';\n\nexport interface LocationEditorConnectedProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.parameters\n */\n parameters?: ParametersAPI & {\n instance: {\n googleMapsKey?: string;\n };\n };\n}\n\ntype LocationEditorProps = {\n disabled: boolean;\n value: NullableLocationValue;\n setValue: (value: NullableLocationValue) => void;\n googleMapsKey?: string;\n selectedView: ViewType;\n setSelectedView: (view: ViewType) => void;\n};\n\nfunction toLocationValue(coords?: Coords): NullableLocationValue {\n if (coords && isNumber(coords.lat) && isNumber(coords.lng)) {\n return { lat: coords.lat, lon: coords.lng };\n } else {\n return null;\n }\n}\n\nexport class LocationEditor extends React.Component<\n LocationEditorProps,\n {\n localValue?: Coords;\n mapsObject: any; // eslint-disable-line -- TODO: describe this disable @typescript-eslint/no-explicit-any\n }\n> {\n constructor(props: LocationEditorProps) {\n super(props);\n\n this.state = {\n localValue: props.value\n ? {\n lng: props.value.lon,\n lat: props.value.lat,\n }\n : undefined,\n mapsObject: null,\n };\n }\n\n // @ts-expect-error\n onSearchAddress: (value: string) => Promise<GeocodeApiResponse> = throttle((value) => {\n if (!this.state.mapsObject) {\n return Promise.resolve(null);\n }\n const { mapsObject } = this.state;\n if (!value) {\n return Promise.resolve(null);\n }\n return new Promise((resolve) => {\n const geocoder = new mapsObject.Geocoder();\n geocoder.geocode({ address: value }, resolve, () => {\n resolve(null);\n });\n });\n }, 300);\n\n onGetAddressFromLocation = (location: Coords | undefined, value: string): Promise<string> => {\n if (!this.state.mapsObject || !location) {\n return Promise.resolve('');\n }\n const { mapsObject } = this.state;\n return new Promise((resolve) => {\n const geocoder = new mapsObject.Geocoder();\n geocoder.geocode(\n { location },\n (result: GeocodeApiResponse) => {\n if (result && result.length > 0) {\n const addresses = result.map((item) => item.formatted_address);\n resolve(addresses.find((item) => item === value) || addresses[0]);\n } else {\n resolve('');\n }\n },\n () => {\n resolve('');\n }\n );\n });\n };\n\n render() {\n const { mapsObject, localValue } = this.state;\n\n return (\n <div data-test-id=\"location-editor\">\n <GoogleMapView\n disabled={this.props.disabled || mapsObject === null}\n googleMapsKey={this.props.googleMapsKey}\n location={localValue}\n onGoogleApiLoaded={({ maps }) => {\n this.setState({ mapsObject: maps });\n }}\n onChangeLocation={(coords) => {\n this.setState({ localValue: coords });\n this.props.setValue(toLocationValue(coords));\n }}\n />\n <LocationSelector\n disabled={this.props.disabled || mapsObject === null}\n value={localValue}\n view={this.props.selectedView}\n onChangeView={(view) => {\n this.props.setSelectedView(view);\n }}\n onChangeLocation={(coords) => {\n this.setState({ localValue: coords });\n this.props.setValue(toLocationValue(coords));\n }}\n onSearchAddress={this.onSearchAddress}\n onGetAddressFromLocation={this.onGetAddressFromLocation}\n />\n </div>\n );\n }\n}\n\nexport function LocationEditorConnected(props: LocationEditorConnectedProps) {\n const { field } = props;\n const googleMapsKey = props.parameters ? props.parameters.instance.googleMapsKey : undefined;\n const [selectedView, setSelectedView] = React.useState<ViewType>(ViewType.Address);\n\n return (\n <FieldConnector<LocationValue>\n isEqualValues={(value1, value2) => {\n return deepEqual(value1, value2);\n }}\n field={field}\n isInitiallyDisabled={props.isInitiallyDisabled}\n >\n {({ value, disabled, setValue, externalReset }) => {\n return (\n <LocationEditor\n // on external change reset component completely and init with initial value again\n key={`location-editor-${externalReset}`}\n value={value}\n disabled={disabled}\n setValue={setValue}\n googleMapsKey={googleMapsKey}\n selectedView={selectedView}\n setSelectedView={setSelectedView}\n />\n );\n }}\n </FieldConnector>\n );\n}\n\nLocationEditorConnected.defaultProps = {\n isInitiallyDisabled: true,\n};\n","import { LocationEditorConnected } from './LocationEditor';\n\nexport const LocationEditor = LocationEditorConnected;\n"],"names":["styles","root","css","height","width","BerlinLocation","lat","lng","GoogleMapView","props","onGoogleApiLoaded","event","maps","map","marker","Marker","position","getCenter","cursor","disabled","draggable","visible","Boolean","location","addListener","state","setPosition","latLng","setVisible","onChangeLocation","setState","undefined","componentDidUpdate","LatLng","setDraggable","setCursor","render","React","className","GoogleMapReact","bootstrapURLKeys","googleMapsKey","key","defaultCenter","center","options","scrollwheel","mapTypeId","defaultZoom","yesIWantToUseGoogleMapApiInternals","Component","input","spinner","right","top","zIndex","validationMessage","marginTop","tokens","spacingS","suggestion","transform","bottom","left","LocationSearchInput","useState","isSearching","setIsSearching","address","setAddress","hasError","setHasError","setSuggestion","useEffect","onGetAddressFromLocation","value","then","TextInput","testId","isInvalid","placeholder","onChange","e","target","onSearchAddress","length","formatted_address","Number","geometry","toString","slice","isDisabled","Spinner","Card","padding","Button","variant","onClick","ValidationMessage","ViewType","display","flexDirection","alignItems","main","flexGrow","secondary","minWidth","textAlign","inputsRow","fontSize","fontSizeM","color","gray900","fontFamily","fontStackPrimary","splitter","spacingL","clearBtn","marginBottom","LocationSelector","Flex","Radio","flexBasis","id","Address","isChecked","view","onChangeView","Coordinates","htmlFor","String","type","max","min","step","TextLink","as","toLocationValue","coords","isNumber","lon","LocationEditor","throttle","mapsObject","Promise","resolve","geocoder","Geocoder","geocode","result","addresses","item","find","localValue","setValue","selectedView","setSelectedView","LocationEditorConnected","field","parameters","instance","FieldConnector","isEqualValues","value1","value2","deepEqual","isInitiallyDisabled","externalReset","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,MAAM,GAAG;AACbC,EAAAA,IAAI,eAAEC,WAAG,CAAC;AACRC,IAAAA,MAAM,EAAE,OADA;AAERC,IAAAA,KAAK,EAAE;AAFC,GAAD;AADI,CAAf;AAOA,IAAMC,cAAc,GAAG;AACrBC,EAAAA,GAAG,EAAE,OADgB;AAErBC,EAAAA,GAAG,EAAE;AAFgB,CAAvB;IAkBaC,aAAb;AAAA;;AACE,yBAAYC,KAAZ;;;AACE,wCAAMA,KAAN;;UAqBFC,oBAAoB,UAACC,KAAD;AAClB,UAAQC,IAAR,GAAsBD,KAAtB,CAAQC,IAAR;AAAA,UAAcC,GAAd,G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AG,uBAAqB6H;AACxB5F,MAAAA,KAAK,EAAEA;AACPxD,MAAAA,QAAQ,EAAEA;AACVuI,MAAAA,QAAQ,EAAEA;AACVjH,MAAAA,aAAa,EAAEA;AACfkH,MAAAA,YAAY,EAAEA;AACdC,MAAAA,eAAe,EAAEA;KARnB,CADF;AAYD,GApBH,CADF;AAwBD;AAEDC,uBAAuB,CAACW,YAAxB,GAAuC;AACrCF,EAAAA,mBAAmB,EAAE;AADgB,CAAvC;;ICtLazB,gBAAc,GAAGgB,uBAAvB;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),a=e(t),o=require("@contentful/field-editor-shared"),n=e(require("deep-equal")),s=e(require("lodash/isNumber")),i=e(require("lodash/throttle")),r=require("emotion"),l=e(require("google-map-react")),d=require("@contentful/f36-components"),c=e(require("@contentful/f36-tokens"));function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var p,m={root:r.css({height:"300px",width:"100%"})},g={lat:52.5018,lng:13.41115439},f=function(e){function t(t){var a;return(a=e.call(this,t)||this).onGoogleApiLoaded=function(e){var t=e.maps,o=e.map,n=new t.Marker({map:o,position:o.getCenter(),cursor:a.props.disabled?"not-allowed":"auto",draggable:!a.props.disabled,visible:Boolean(a.props.location)});t.event.addListener(o,"click",(function(e){!a.props.disabled&&a.state.marker&&a.state.maps&&(a.state.marker.setPosition(e.latLng),a.state.marker.setVisible(!0),a.props.onChangeLocation({lat:e.latLng.lat(),lng:e.latLng.lng()}))})),t.event.addListener(n,"dragend",(function(e){a.props.onChangeLocation({lat:e.latLng.lat(),lng:e.latLng.lng()})})),a.setState({marker:n,maps:t},(function(){a.props.onGoogleApiLoaded({maps:t})}))},a.state={marker:void 0,maps:void 0},a}u(t,e);var o=t.prototype;return o.componentDidUpdate=function(){if(this.state.marker&&this.state.maps){if(this.props.location){var e=new this.state.maps.LatLng(this.props.location.lat,this.props.location.lng);this.state.marker.setPosition(e),this.state.marker.setVisible(!0)}else this.state.marker.setVisible(!1);this.state.marker.setDraggable(!this.props.disabled),this.state.marker.setCursor(this.props.disabled?"not-allowed":"auto")}},o.render=function(){return a.createElement("div",{className:m.root},a.createElement(l,{draggable:!this.props.disabled,bootstrapURLKeys:this.props.googleMapsKey?{key:this.props.googleMapsKey}:void 0,defaultCenter:g,center:this.props.location,options:{scrollwheel:!1,mapTypeId:"roadmap"},defaultZoom:6,yesIWantToUseGoogleMapApiInternals:!0,onGoogleApiLoaded:this.onGoogleApiLoaded}))},t}(a.Component),v={root:r.css({width:"100%"}),input:r.css({position:"relative",width:"100%"}),spinner:r.css({position:"absolute",right:10,top:10,zIndex:99}),validationMessage:r.css({marginTop:c.spacingS}),suggestion:r.css({position:"absolute",transform:"translateY(100%)",bottom:0,left:0,zIndex:1})};function h(e){var t=a.useState(!1),o=t[0],n=t[1],s=a.useState(""),i=s[0],r=s[1],l=a.useState(!1),c=l[0],u=l[1],p=a.useState(null),m=p[0],g=p[1];return a.useEffect((function(){n(!0),e.onGetAddressFromLocation(e.value,i).then((function(e){r(e),n(!1)}))}),[e.value,e.disabled]),a.createElement("div",{className:v.root},a.createElement("div",{className:v.input},a.createElement(d.TextInput,{testId:"location-editor-search",isInvalid:c,placeholder:"Start typing to find location",value:i,onChange:function(t){r(t.target.value),u(!1),g(null),""!==t.target.value?(n(!0),e.onSearchAddress(t.target.value).then((function(e){n(!1),null===e?u(!1):0===e.length?u(!0):(u(!1),g({address:e[0].formatted_address,location:{lat:Number(e[0].geometry.location.lat().toString().slice(0,8)),lng:Number(e[0].geometry.location.lng().toString().slice(0,8))}}))}))):e.onChangeLocation(void 0)},isDisabled:e.disabled}),o&&a.createElement(d.Spinner,{className:v.spinner}),m&&a.createElement(d.Card,{padding:"none",className:v.suggestion},a.createElement(d.Button,{variant:"transparent",testId:"location-editor-suggestion",onClick:function(){r(m.address),e.onChangeLocation(m.location),g(null)}},m.address)),c&&a.createElement(d.ValidationMessage,{testId:"location-editor-not-found",className:v.validationMessage},"No results found for ",a.createElement("strong",null,i),". Please make sure that address is spelled correctly.")))}!function(e){e.Address="Address",e.Coordinates="Coordinates"}(p||(p={}));var b={root:r.css({display:"flex",flexDirection:"row",marginTop:c.spacingS,alignItems:"flex-end"}),main:r.css({flexGrow:1}),secondary:r.css({minWidth:"70px",textAlign:"right"}),inputsRow:r.css({display:"flex",marginTop:c.spacingS,fontSize:c.fontSizeM,color:c.gray900,fontFamily:c.fontStackPrimary,alignItems:"center"}),splitter:r.css({width:c.spacingL}),clearBtn:r.css({marginBottom:c.spacingS})};function C(e){return a.createElement("div",{className:b.root},a.createElement("div",{className:b.main},a.createElement(d.Flex,{flexDirection:"row"},a.createElement(d.Radio,{className:r.css({flexBasis:"100%"}),id:p.Address,testId:"location-editor-address-radio",isDisabled:e.disabled,value:p.Address,isChecked:e.view===p.Address,onChange:function(){e.onChangeView(p.Address)}},"Address"),a.createElement(d.Radio,{className:r.css({flexBasis:"100%"}),id:p.Coordinates,testId:"location-editor-coordinates-radio",isDisabled:e.disabled,value:p.Coordinates,isChecked:e.view===p.Coordinates,onChange:function(){e.onChangeView(p.Coordinates)}},"Coordinates")),e.view===p.Address&&a.createElement("div",{className:b.inputsRow},a.createElement(h,{onSearchAddress:e.onSearchAddress,onGetAddressFromLocation:e.onGetAddressFromLocation,disabled:e.disabled,value:e.value,onChangeLocation:e.onChangeLocation})),e.view===p.Coordinates&&a.createElement("div",{className:b.inputsRow},a.createElement("label",{htmlFor:"latitude"},"Latitude"),a.createElement("div",{className:b.splitter}),a.createElement(d.TextInput,{id:"latitude",testId:"location-editor-latitude",placeholder:"Between -90 and 90",isDisabled:e.disabled,value:e.value?String(e.value.lat):"",onChange:function(t){e.onChangeLocation({lng:e.value&&void 0!==e.value.lng?e.value.lng:0,lat:Number(t.target.value)||0})},type:"number",max:"90",min:"-90",step:"0.1"}),a.createElement("div",{className:b.splitter}),a.createElement("label",{htmlFor:"longitude"},"Longitude"),a.createElement("div",{className:b.splitter}),a.createElement(d.TextInput,{id:"longitude",testId:"location-editor-longitude",placeholder:"Between -180 and 180",isDisabled:e.disabled,value:e.value?String(e.value.lng):"",onChange:function(t){e.onChangeLocation({lat:e.value&&void 0!==e.value.lat?e.value.lat:0,lng:Number(t.target.value)||0})},type:"number",max:"180",min:"-180",step:"0.1"}))),a.createElement("div",{className:b.secondary},a.createElement(d.TextLink,{as:"button",isDisabled:e.disabled,testId:"location-editor-clear",className:b.clearBtn,onClick:function(){e.onChangeLocation(void 0)}},"Clear")))}function L(e){return e&&s(e.lat)&&s(e.lng)?{lat:e.lat,lon:e.lng}:null}var y=function(e){function a(t){var a;return(a=e.call(this,t)||this).onSearchAddress=i((function(e){if(!a.state.mapsObject)return Promise.resolve(null);var t=a.state.mapsObject;return e?new Promise((function(a){(new t.Geocoder).geocode({address:e},a,(function(){a(null)}))})):Promise.resolve(null)}),300),a.onGetAddressFromLocation=function(e,t){if(!a.state.mapsObject||!e)return Promise.resolve("");var o=a.state.mapsObject;return new Promise((function(a){(new o.Geocoder).geocode({location:e},(function(e){if(e&&e.length>0){var o=e.map((function(e){return e.formatted_address}));a(o.find((function(e){return e===t}))||o[0])}else a("")}),(function(){a("")}))}))},a.state={localValue:t.value?{lng:t.value.lon,lat:t.value.lat}:void 0,mapsObject:null},a}return u(a,e),a.prototype.render=function(){var e=this,a=this.state,o=a.mapsObject,n=a.localValue;return t.createElement("div",{"data-test-id":"location-editor"},t.createElement(f,{disabled:this.props.disabled||null===o,googleMapsKey:this.props.googleMapsKey,location:n,onGoogleApiLoaded:function(t){e.setState({mapsObject:t.maps})},onChangeLocation:function(t){e.setState({localValue:t}),e.props.setValue(L(t))}}),t.createElement(C,{disabled:this.props.disabled||null===o,value:n,view:this.props.selectedView,onChangeView:function(t){e.props.setSelectedView(t)},onChangeLocation:function(t){e.setState({localValue:t}),e.props.setValue(L(t))},onSearchAddress:this.onSearchAddress,onGetAddressFromLocation:this.onGetAddressFromLocation}))},a}(t.Component);function E(e){var a=e.field,s=e.parameters?e.parameters.instance.googleMapsKey:void 0,i=t.useState(p.Address),r=i[0],l=i[1];return t.createElement(o.FieldConnector,{isEqualValues:function(e,t){return n(e,t)},field:a,isInitiallyDisabled:e.isInitiallyDisabled},(function(e){return t.createElement(y,{key:"location-editor-"+e.externalReset,value:e.value,disabled:e.disabled,setValue:e.setValue,googleMapsKey:s,selectedView:r,setSelectedView:l})}))}E.defaultProps={isInitiallyDisabled:!0},exports.LocationEditor=E;
|
|
2
|
-
//# sourceMappingURL=field-editor-location.cjs.production.min.js.map
|