@woosmap/ui 2.50.0 → 2.54.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "2.50.0",
3
+ "version": "2.54.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -71,7 +71,7 @@ export default class DistanceDemo extends Component {
71
71
  this.requestUrl = 'https://api.woosmap.com/distance/route/json';
72
72
  this.polylines = [];
73
73
  this.directionsRenderer = null;
74
- this.mapDivRef = React.createRef();
74
+ this.demoRef = React.createRef();
75
75
  }
76
76
 
77
77
  componentDidMount() {
@@ -209,16 +209,14 @@ export default class DistanceDemo extends Component {
209
209
  clearTimeout(this.timeoutMap);
210
210
  }
211
211
 
212
- if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
213
- this.map = createWoosmapMap(this.mapDivRef.current);
212
+ if (window.woosmap && window.woosmap.map && this.demoRef.current) {
213
+ this.map = createWoosmapMap(this.demoRef.current.getMap());
214
214
  this.requestDistance();
215
215
  } else {
216
216
  this.timeoutMap = setTimeout(this.displayMap, 300);
217
217
  }
218
218
  };
219
219
 
220
- renderMap = () => <div className="map" ref={this.mapDivRef} />;
221
-
222
220
  localitiesOnChangeCallBack = (type) => (item) => {
223
221
  const newState = {};
224
222
  newState[`${type}Location`] = item ? item.location : {};
@@ -361,7 +359,8 @@ export default class DistanceDemo extends Component {
361
359
  referer="http://localhost/"
362
360
  response={error || routes}
363
361
  result={this.renderRoutesSummary()}
364
- map={this.renderMap()}
362
+ withMap
363
+ ref={this.demoRef}
365
364
  />
366
365
  </>
367
366
  );
@@ -26,7 +26,7 @@ export default class GeolocationDemo extends Component {
26
26
  this.marker = null;
27
27
  this.viewport = null;
28
28
  this.requestUrl = 'https://api.woosmap.com/geolocation/stores';
29
- this.mapDivRef = React.createRef();
29
+ this.demoRef = React.createRef();
30
30
  this.overlay = null;
31
31
  this.storeMarkers = [];
32
32
  }
@@ -178,16 +178,14 @@ export default class GeolocationDemo extends Component {
178
178
  clearTimeout(this.timeoutMap);
179
179
  }
180
180
 
181
- if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
182
- this.map = createWoosmapMap(this.mapDivRef.current);
181
+ if (window.woosmap && window.woosmap.map && this.demoRef.current) {
182
+ this.map = createWoosmapMap(this.demoRef.current.getMap());
183
183
  this.requestGeolocation();
184
184
  } else {
185
185
  this.timeoutMap = setTimeout(this.displayMap, 300);
186
186
  }
187
187
  };
188
188
 
189
- renderMap = () => <div className="map" ref={this.mapDivRef} />;
190
-
191
189
  render() {
192
190
  const { geolocation, error } = this.state;
193
191
  const { noheader } = this.props;
@@ -225,8 +223,9 @@ export default class GeolocationDemo extends Component {
225
223
  noheader={noheader}
226
224
  response={error || geolocation}
227
225
  result={this.renderGeolocationInfo()}
228
- map={this.renderMap()}
226
+ withMap
229
227
  footerFilters={this.renderFooterFilters()}
228
+ ref={this.demoRef}
230
229
  />
231
230
  </>
232
231
  );
@@ -31,7 +31,7 @@ export default class LocalitiesAddressDemo extends Component {
31
31
  this.requestDetailsUrl = 'https://api.woosmap.com/localities/details';
32
32
  this.inputRef = React.createRef();
33
33
  this.addressAutocompleteRef = React.createRef();
34
- this.mapDivRef = React.createRef();
34
+ this.demoRef = React.createRef();
35
35
  }
36
36
 
37
37
  componentDidMount() {
@@ -326,16 +326,14 @@ export default class LocalitiesAddressDemo extends Component {
326
326
  clearTimeout(this.timeoutMap);
327
327
  }
328
328
 
329
- if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
330
- this.map = createWoosmapMap(this.mapDivRef.current);
329
+ if (window.woosmap && window.woosmap.map && this.demoRef.current) {
330
+ this.map = createWoosmapMap(this.demoRef.current.getMap());
331
331
  this.requestAddress();
332
332
  } else {
333
333
  this.timeoutMap = setTimeout(this.displayMap, 300);
334
334
  }
335
335
  };
336
336
 
337
- renderMap = () => <div className="map" ref={this.mapDivRef} />;
338
-
339
337
  render() {
340
338
  const { response, error, showDetails } = this.state;
341
339
  const { noheader, headerLabels, subHeader } = this.props;
@@ -359,7 +357,8 @@ export default class LocalitiesAddressDemo extends Component {
359
357
  referer="http://localhost/"
360
358
  response={error || response}
361
359
  result={this.renderAddress()}
362
- map={this.renderMap()}
360
+ withMap
361
+ ref={this.demoRef}
363
362
  />
364
363
  </>
365
364
  );
@@ -64,7 +64,7 @@ export default class LocalitiesDemo extends Component {
64
64
  this.marker = null;
65
65
  this.viewport = null;
66
66
  this.requestUrl = 'https://api.woosmap.com/localities/autocomplete/';
67
- this.mapDivRef = React.createRef();
67
+ this.demoRef = React.createRef();
68
68
  this.overlay = null;
69
69
  }
70
70
 
@@ -194,16 +194,14 @@ export default class LocalitiesDemo extends Component {
194
194
  clearTimeout(this.timeoutMap);
195
195
  }
196
196
 
197
- if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
198
- this.map = createWoosmapMap(this.mapDivRef.current);
197
+ if (window.woosmap && window.woosmap.map && this.demoRef.current) {
198
+ this.map = createWoosmapMap(this.demoRef.current.getMap());
199
199
  this.requestLocalities();
200
200
  } else {
201
201
  this.timeoutMap = setTimeout(this.displayMap, 300);
202
202
  }
203
203
  };
204
204
 
205
- renderMap = () => <div className="map" ref={this.mapDivRef} />;
206
-
207
205
  renderHeaderFilters = () => {
208
206
  const { input } = this.state;
209
207
  const { usecaseFilter } = this.props;
@@ -287,7 +285,8 @@ export default class LocalitiesDemo extends Component {
287
285
  referer="http://localhost/"
288
286
  response={error || localities}
289
287
  result={this.renderAutocompleteList()}
290
- map={this.renderMap()}
288
+ withMap
289
+ ref={this.demoRef}
291
290
  />
292
291
  </>
293
292
  );
@@ -23,7 +23,7 @@ export default class MapDemo extends Component {
23
23
  this.marker = null;
24
24
  this.mounted = true;
25
25
  this.viewport = null;
26
- this.mapDivRef = React.createRef();
26
+ this.demoRef = React.createRef();
27
27
  }
28
28
 
29
29
  componentDidMount() {
@@ -179,7 +179,7 @@ storesOverlay.setMap(map);
179
179
  if (this.timeoutMap) {
180
180
  clearTimeout(this.timeoutMap);
181
181
  }
182
- if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
182
+ if (window.woosmap && window.woosmap.map && this.demoRef.current) {
183
183
  window.woosmap.map.config.setApiKey('woos-48c80350-88aa-333e-835a-07f4b658a9a4');
184
184
  if (!this.storeOverlay) {
185
185
  this.storesOverlay = new window.woosmap.map.StoresOverlay({
@@ -211,7 +211,7 @@ storesOverlay.setMap(map);
211
211
  if (colorStyle) {
212
212
  styles.push(colorStyle);
213
213
  }
214
- this.map = new window.woosmap.map.Map(this.mapDivRef.current, {
214
+ this.map = new window.woosmap.map.Map(this.demoRef.current.getMap(), {
215
215
  styles,
216
216
  center: {
217
217
  lat: 51.51,
@@ -228,8 +228,6 @@ storesOverlay.setMap(map);
228
228
  }
229
229
  };
230
230
 
231
- renderMap = () => <div className="map" ref={this.mapDivRef} />;
232
-
233
231
  applyStyle = (style) => {
234
232
  if (style === 'grey') {
235
233
  return { featureType: 'all', stylers: [{ saturation: -100, lightness: -30 }] };
@@ -255,6 +253,7 @@ storesOverlay.setMap(map);
255
253
  <>
256
254
  <Script url={`https://sdk.woosmap.com/map/map.js?key=${Constants.woosmapKey}`} />
257
255
  <Demo
256
+ ref={this.demoRef}
258
257
  header={headerLabels}
259
258
  id="map-demo"
260
259
  className="demo--map"
@@ -263,7 +262,7 @@ storesOverlay.setMap(map);
263
262
  renderCode={this.renderCode}
264
263
  noheader={noheader}
265
264
  referer="http://localhost/"
266
- map={this.renderMap()}
265
+ withMap
267
266
  response={null}
268
267
  />
269
268
  </>
@@ -36,7 +36,7 @@ export default class SearchDemo extends Component {
36
36
  this.map = null;
37
37
  this.markers = [];
38
38
  this.requestUrl = 'https://api.woosmap.com/stores/search/';
39
- this.mapDivRef = React.createRef();
39
+ this.demoRef = React.createRef();
40
40
  }
41
41
 
42
42
  componentDidMount() {
@@ -189,16 +189,14 @@ export default class SearchDemo extends Component {
189
189
  displayMap = () => {
190
190
  if (this.timeoutMap) clearTimeout(this.timeoutMap);
191
191
 
192
- if (window.woosmap && window.woosmap.map && this.mapDivRef.current) {
193
- this.map = createWoosmapMap(this.mapDivRef.current);
192
+ if (window.woosmap && window.woosmap.map && this.demoRef.current) {
193
+ this.map = createWoosmapMap(this.demoRef.current.getMap());
194
194
  this.requestSearch();
195
195
  } else {
196
196
  this.timeoutMap = setTimeout(this.displayMap, 300);
197
197
  }
198
198
  };
199
199
 
200
- renderMap = () => <div className="map" ref={this.mapDivRef} />;
201
-
202
200
  renderHeaderFilters = () => {
203
201
  const { selectedLocality } = this.state;
204
202
  const originInputs = {
@@ -326,7 +324,8 @@ export default class SearchDemo extends Component {
326
324
  response={error || data}
327
325
  noheader={noheader}
328
326
  result={this.renderStoreList()}
329
- map={this.renderMap()}
327
+ withMap
328
+ ref={this.demoRef}
330
329
  />
331
330
  </>
332
331
  );
@@ -18,6 +18,7 @@ export default class SkeletonDemo extends Component {
18
18
  };
19
19
  this.copyActionIdRequest = uniqueid();
20
20
  this.copyActionIdResponse = uniqueid();
21
+ this.mapDivRef = React.createRef();
21
22
  }
22
23
 
23
24
  componentWillUnmount() {
@@ -57,6 +58,13 @@ export default class SkeletonDemo extends Component {
57
58
  this.copy(JSON.stringify(response, null, 2));
58
59
  };
59
60
 
61
+ getMap = () => {
62
+ if (this.mapDivRef) {
63
+ return this.mapDivRef.current;
64
+ }
65
+ return null;
66
+ };
67
+
60
68
  renderJsCode = () => {
61
69
  const { params, request } = this.props;
62
70
  /* eslint-disable */
@@ -157,7 +165,7 @@ export default class SkeletonDemo extends Component {
157
165
  header,
158
166
  id,
159
167
  result,
160
- map,
168
+ withMap,
161
169
  request,
162
170
  response,
163
171
  className,
@@ -214,13 +222,13 @@ export default class SkeletonDemo extends Component {
214
222
  <div className="demo__results__content">{result}</div>
215
223
  </div>
216
224
  ) : null}
217
- {map ? (
225
+ {withMap ? (
218
226
  <div
219
227
  className={cl('demo__map', {
220
228
  'demo__map--small': result,
221
229
  })}
222
230
  >
223
- {map}
231
+ <div className="map" ref={this.mapDivRef} />
224
232
  </div>
225
233
  ) : null}
226
234
  <div className="demo__api">
@@ -281,7 +289,7 @@ SkeletonDemo.defaultProps = {
281
289
  leftContent: null,
282
290
  className: '',
283
291
  result: null,
284
- map: null,
292
+ withMap: false,
285
293
  request: null,
286
294
  response: {},
287
295
  params: {},
@@ -305,7 +313,7 @@ SkeletonDemo.propTypes = {
305
313
  headerFilters: PropTypes.array,
306
314
  footerFilters: PropTypes.array,
307
315
  result: PropTypes.node,
308
- map: PropTypes.node,
316
+ withMap: PropTypes.bool,
309
317
  leftContent: PropTypes.node,
310
318
  request: PropTypes.string,
311
319
  referer: PropTypes.string,
@@ -10,13 +10,17 @@ function mapChildrenWithProps(children, childrenRefs, closeCb) {
10
10
  if (children) {
11
11
  return React.Children.map(children, (child, index) => {
12
12
  if (React.isValidElement(child)) {
13
+ // only add ref to non functional components
13
14
  return React.cloneElement(child, {
14
15
  ...child.props,
15
16
  closeCb,
16
- ref: (elem) => {
17
- // eslint-disable-next-line no-param-reassign
18
- childrenRefs[index] = elem;
19
- },
17
+ ref:
18
+ !child.type.prototype || (child.type.prototype && child.type.prototype.render)
19
+ ? (elem) => {
20
+ // eslint-disable-next-line no-param-reassign
21
+ childrenRefs[index] = elem;
22
+ }
23
+ : undefined,
20
24
  });
21
25
  }
22
26
  return child;
@@ -349,7 +353,7 @@ class Dropdown extends Component {
349
353
 
350
354
  return (
351
355
  <div
352
- ref={this.clickOutsideRef}
356
+ ref={openOnMouseEnter ? null : this.clickOutsideRef}
353
357
  className={cl('dropdown', { open }, `dropdown--${size}`, className)}
354
358
  {...rest}
355
359
  onMouseEnter={this.onMouseEnter}
@@ -69,7 +69,7 @@
69
69
  mbib(3)
70
70
  &__section
71
71
  .select
72
- max-width 0
72
+ max-width min-content
73
73
  &__title
74
74
  font-weight 400
75
75
  color $secondary-medium60