@blaze-cms/plugin-google-maps-fe 0.123.0-alpha.24 → 0.123.0-alpha.28
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/CHANGELOG.md +27 -0
- package/lib/GoogleMaps/GoogleMaps.js +68 -40
- package/lib/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsFactory.js +8 -4
- package/lib/GoogleMaps/GoogleMapsFactory.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsRender.js +24 -41
- package/lib/GoogleMaps/GoogleMapsRender.js.map +1 -1
- package/lib/GoogleMaps/helpers/add-zoom-listener.js +3 -50
- package/lib/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-map-shapes.js +97 -0
- package/lib/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
- package/lib/GoogleMaps/helpers/build-query.js +24 -14
- package/lib/GoogleMaps/helpers/build-query.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-shapes-configs.js +196 -0
- package/lib/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
- package/lib/GoogleMaps/helpers/get-center-coordinates.js +49 -0
- package/lib/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
- package/lib/GoogleMaps/helpers/get-image-ids.js +16 -14
- package/lib/GoogleMaps/helpers/get-image-ids.js.map +1 -1
- package/lib/GoogleMaps/helpers/index.js +21 -5
- package/lib/GoogleMaps/helpers/index.js.map +1 -1
- package/lib/GoogleMaps/helpers/set-shapes.js +87 -153
- package/lib/GoogleMaps/helpers/set-shapes.js.map +1 -1
- package/lib/GoogleMaps/hooks/use-get-images.js +3 -2
- package/lib/GoogleMaps/hooks/use-get-images.js.map +1 -1
- package/lib/GoogleMaps/queries.js +22 -4
- package/lib/GoogleMaps/queries.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMaps.js +51 -25
- package/lib-es/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMapsFactory.js +10 -6
- package/lib-es/GoogleMaps/GoogleMapsFactory.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMapsRender.js +24 -32
- package/lib-es/GoogleMaps/GoogleMapsRender.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js +3 -23
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/build-map-shapes.js +86 -0
- package/lib-es/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/build-query.js +17 -8
- package/lib-es/GoogleMaps/helpers/build-query.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/build-shapes-configs.js +134 -0
- package/lib-es/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/get-center-coordinates.js +31 -0
- package/lib-es/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/get-image-ids.js +9 -14
- package/lib-es/GoogleMaps/helpers/get-image-ids.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/index.js +4 -2
- package/lib-es/GoogleMaps/helpers/index.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/set-shapes.js +76 -123
- package/lib-es/GoogleMaps/helpers/set-shapes.js.map +1 -1
- package/lib-es/GoogleMaps/hooks/use-get-images.js +4 -3
- package/lib-es/GoogleMaps/hooks/use-get-images.js.map +1 -1
- package/lib-es/GoogleMaps/queries.js +23 -2
- package/lib-es/GoogleMaps/queries.js.map +1 -1
- package/package.json +4 -4
- package/src/GoogleMaps/GoogleMaps.js +40 -27
- package/src/GoogleMaps/GoogleMapsFactory.js +11 -4
- package/src/GoogleMaps/GoogleMapsRender.js +23 -21
- package/src/GoogleMaps/helpers/add-zoom-listener.js +3 -22
- package/src/GoogleMaps/helpers/build-map-shapes.js +70 -0
- package/src/GoogleMaps/helpers/build-query.js +25 -10
- package/src/GoogleMaps/helpers/build-shapes-configs.js +110 -0
- package/src/GoogleMaps/helpers/get-center-coordinates.js +24 -0
- package/src/GoogleMaps/helpers/get-image-ids.js +6 -15
- package/src/GoogleMaps/helpers/index.js +12 -2
- package/src/GoogleMaps/helpers/set-shapes.js +59 -99
- package/src/GoogleMaps/hooks/use-get-images.js +4 -3
- package/src/GoogleMaps/queries.js +30 -3
- package/lib/GoogleMaps/helpers/set-entity-configs.js +0 -144
- package/lib/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
- package/lib-es/GoogleMaps/helpers/set-entity-configs.js +0 -94
- package/lib-es/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
- package/src/GoogleMaps/helpers/set-entity-configs.js +0 -84
|
@@ -1,35 +1,67 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
const _excluded = ["
|
|
2
|
+
const _excluded = ["type", "name", "modifier", "elementTitle", "imageData", "onMount", "onMountProps", "parent", "mapShapes", "centerCoordinates"];
|
|
3
3
|
import React, { useEffect, useState } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import {
|
|
5
|
+
import { useRouter } from 'next/router';
|
|
6
6
|
import { withTitle } from '@blaze-cms/react-page-builder';
|
|
7
7
|
import { useInView } from '@blaze-react/utils/lib/customHooks';
|
|
8
8
|
import { functions, isEqual, omit } from 'lodash';
|
|
9
9
|
import { setMapOptions, addZoomListener } from './helpers';
|
|
10
10
|
import { GOOGLE_MAPS_SCRIPT, LOAD, SCRIPT, IN_VIEW_CONFIG } from '../constants';
|
|
11
11
|
|
|
12
|
+
const shouldNotUpdate = (props, nextProps) => {
|
|
13
|
+
const [funcs, nextFuncs] = [functions(props), functions(nextProps)];
|
|
14
|
+
const noPropChange = isEqual(omit(props, funcs), omit(nextProps, nextFuncs));
|
|
15
|
+
const noFuncChange = funcs.length === nextFuncs.length && funcs.every(fn => props[fn].toString() === nextProps[fn].toString());
|
|
16
|
+
return noPropChange && noFuncChange;
|
|
17
|
+
};
|
|
18
|
+
|
|
12
19
|
const GoogleMaps = _ref => {
|
|
13
20
|
let {
|
|
14
|
-
router,
|
|
15
|
-
data,
|
|
16
21
|
type,
|
|
17
22
|
name,
|
|
18
23
|
modifier,
|
|
19
24
|
elementTitle,
|
|
20
|
-
entityGroups,
|
|
21
25
|
imageData,
|
|
22
26
|
onMount,
|
|
23
|
-
onMountProps
|
|
27
|
+
onMountProps,
|
|
28
|
+
parent,
|
|
29
|
+
mapShapes,
|
|
30
|
+
centerCoordinates
|
|
24
31
|
} = _ref,
|
|
25
32
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
26
33
|
|
|
34
|
+
const router = useRouter();
|
|
27
35
|
const [isIntersecting, mapRef] = useInView(IN_VIEW_CONFIG);
|
|
28
36
|
const [map, setMap] = useState();
|
|
29
37
|
useEffect(() => {
|
|
30
38
|
const options = setMapOptions(otherProps);
|
|
31
39
|
|
|
32
|
-
const onLoad = () =>
|
|
40
|
+
const onLoad = () => {
|
|
41
|
+
const initialMap = new window.google.maps.Map(mapRef.current, options);
|
|
42
|
+
|
|
43
|
+
if (centerCoordinates.length === 1) {
|
|
44
|
+
const [{
|
|
45
|
+
latitude: lat,
|
|
46
|
+
longitude: lng
|
|
47
|
+
}] = centerCoordinates;
|
|
48
|
+
initialMap.setCenter({
|
|
49
|
+
lat,
|
|
50
|
+
lng
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
const bounds = new window.google.maps.LatLngBounds();
|
|
54
|
+
centerCoordinates.forEach(({
|
|
55
|
+
latitude,
|
|
56
|
+
longitude
|
|
57
|
+
}) => {
|
|
58
|
+
bounds.extend(new window.google.maps.LatLng(latitude, longitude));
|
|
59
|
+
});
|
|
60
|
+
initialMap.fitBounds(bounds);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setMap(initialMap);
|
|
64
|
+
};
|
|
33
65
|
|
|
34
66
|
if (!window.google) {
|
|
35
67
|
const script = document.createElement(SCRIPT);
|
|
@@ -62,42 +94,36 @@ const GoogleMaps = _ref => {
|
|
|
62
94
|
return () => {}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
95
|
}, []);
|
|
64
96
|
if (map && typeof onMount === `function`) onMount(map, onMountProps);
|
|
65
|
-
if (isIntersecting) addZoomListener(map, router,
|
|
97
|
+
if (isIntersecting) addZoomListener(map, router, mapShapes, imageData);
|
|
66
98
|
return /*#__PURE__*/React.createElement("div", {
|
|
67
99
|
className: "google-maps",
|
|
68
100
|
ref: mapRef
|
|
69
101
|
});
|
|
70
102
|
};
|
|
71
103
|
|
|
72
|
-
const shouldNotUpdate = (props, nextProps) => {
|
|
73
|
-
const [funcs, nextFuncs] = [functions(props), functions(nextProps)];
|
|
74
|
-
const noPropChange = isEqual(omit(props, funcs), omit(nextProps, nextFuncs));
|
|
75
|
-
const noFuncChange = funcs.length === nextFuncs.length && funcs.every(fn => props[fn].toString() === nextProps[fn].toString());
|
|
76
|
-
return noPropChange && noFuncChange;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
104
|
GoogleMaps.propTypes = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
imageData: PropTypes.object,
|
|
105
|
+
mapShapes: PropTypes.array,
|
|
106
|
+
imageData: PropTypes.array,
|
|
83
107
|
type: PropTypes.string,
|
|
84
108
|
name: PropTypes.string,
|
|
85
109
|
modifier: PropTypes.string,
|
|
86
110
|
elementTitle: PropTypes.string,
|
|
87
|
-
entityGroups: PropTypes.array,
|
|
88
111
|
onMount: PropTypes.func,
|
|
89
|
-
onMountProps: PropTypes.object
|
|
112
|
+
onMountProps: PropTypes.object,
|
|
113
|
+
parent: PropTypes.object,
|
|
114
|
+
centerCoordinates: PropTypes.array
|
|
90
115
|
};
|
|
91
116
|
GoogleMaps.defaultProps = {
|
|
92
|
-
|
|
93
|
-
imageData:
|
|
117
|
+
mapShapes: [],
|
|
118
|
+
imageData: [],
|
|
119
|
+
centerCoordinates: [],
|
|
94
120
|
type: '',
|
|
95
121
|
name: '',
|
|
96
122
|
modifier: '',
|
|
97
123
|
elementTitle: '',
|
|
98
|
-
entityGroups: [],
|
|
99
124
|
onMount: null,
|
|
100
|
-
onMountProps: null
|
|
125
|
+
onMountProps: null,
|
|
126
|
+
parent: {}
|
|
101
127
|
};
|
|
102
|
-
export default React.memo(
|
|
128
|
+
export default React.memo(withTitle(GoogleMaps), shouldNotUpdate);
|
|
103
129
|
//# sourceMappingURL=GoogleMaps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GoogleMaps/GoogleMaps.js"],"names":["React","useEffect","useState","PropTypes","
|
|
1
|
+
{"version":3,"sources":["../../src/GoogleMaps/GoogleMaps.js"],"names":["React","useEffect","useState","PropTypes","useRouter","withTitle","useInView","functions","isEqual","omit","setMapOptions","addZoomListener","GOOGLE_MAPS_SCRIPT","LOAD","SCRIPT","IN_VIEW_CONFIG","shouldNotUpdate","props","nextProps","funcs","nextFuncs","noPropChange","noFuncChange","length","every","fn","toString","GoogleMaps","type","name","modifier","elementTitle","imageData","onMount","onMountProps","parent","mapShapes","centerCoordinates","otherProps","router","isIntersecting","mapRef","map","setMap","options","onLoad","initialMap","window","google","maps","Map","current","latitude","lat","longitude","lng","setCenter","bounds","LatLngBounds","forEach","extend","LatLng","fitBounds","script","document","createElement","src","process","env","GOOGLE_MAPS_API_KEY","head","append","addEventListener","removeEventListener","setOptions","enableGeolocation","shouldActivateGeolocation","navigator","geolocation","getCurrentPosition","position","center","coords","propTypes","array","string","func","object","defaultProps","memo"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,SAAT,QAA0B,+BAA1B;AACA,SAASC,SAAT,QAA0B,oCAA1B;AACA,SAASC,SAAT,EAAoBC,OAApB,EAA6BC,IAA7B,QAAyC,QAAzC;AAC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MAJK;AAKrBvD,EAAAA,QAAQ,EAAE3B,SAAS,CAACkF,MALC;AAMrBtD,EAAAA,YAAY,EAAE5B,SAAS,CAACkF,MANH;AAOrBpD,EAAAA,OAAO,EAAE9B,SAAS,CAACmF,IAPE;AAQrBpD,EAAAA,YAAY,EAAE/B,SAAS,CAACoF,MARH;AASrBpD,EAAAA,MAAM,EAAEhC,SAAS,CAACoF,MATG;AAUrBlD,EAAAA,iBAAiB,EAAElC,SAAS,CAACiF;AAVR,CAAvB;AAaAzD,UAAU,CAAC6D,YAAX,GAA0B;AACxBpD,EAAAA,SAAS,EAAE,EADa;AAExBJ,EAAAA,SAAS,EAAE,EAFa;AAGxBK,EAAAA,iBAAiB,EAAE,EAHK;AAIxBT,EAAAA,IAAI,EAAE,EAJkB;AAKxBC,EAAAA,IAAI,EAAE,EALkB;AAMxBC,EAAAA,QAAQ,EAAE,EANc;AAOxBC,EAAAA,YAAY,EAAE,EAPU;AAQxBE,EAAAA,OAAO,EAAE,IARe;AASxBC,EAAAA,YAAY,EAAE,IATU;AAUxBC,EAAAA,MAAM,EAAE;AAVgB,CAA1B;AAaA,eAAenC,KAAK,CAACyF,IAAN,CAAWpF,SAAS,CAACsB,UAAD,CAApB,EAAkCX,eAAlC,CAAf","sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { withTitle } from '@blaze-cms/react-page-builder';\nimport { useInView } from '@blaze-react/utils/lib/customHooks';\nimport { functions, isEqual, omit } from 'lodash';\nimport { setMapOptions, addZoomListener } from './helpers';\nimport { GOOGLE_MAPS_SCRIPT, LOAD, SCRIPT, IN_VIEW_CONFIG } from '../constants';\n\nconst shouldNotUpdate = (props, nextProps) => {\n const [funcs, nextFuncs] = [functions(props), functions(nextProps)];\n const noPropChange = isEqual(omit(props, funcs), omit(nextProps, nextFuncs));\n const noFuncChange =\n funcs.length === nextFuncs.length &&\n funcs.every(fn => props[fn].toString() === nextProps[fn].toString());\n return noPropChange && noFuncChange;\n};\n\nconst GoogleMaps = ({\n type,\n name,\n modifier,\n elementTitle,\n imageData,\n onMount,\n onMountProps,\n parent,\n mapShapes,\n centerCoordinates,\n ...otherProps\n}) => {\n const router = useRouter();\n const [isIntersecting, mapRef] = useInView(IN_VIEW_CONFIG);\n const [map, setMap] = useState();\n\n useEffect(() => {\n const options = setMapOptions(otherProps);\n const onLoad = () => {\n const initialMap = new window.google.maps.Map(mapRef.current, options);\n if (centerCoordinates.length === 1) {\n const [{ latitude: lat, longitude: lng }] = centerCoordinates;\n initialMap.setCenter({ lat, lng });\n } else {\n const bounds = new window.google.maps.LatLngBounds();\n centerCoordinates.forEach(({ latitude, longitude }) => {\n bounds.extend(new window.google.maps.LatLng(latitude, longitude));\n });\n initialMap.fitBounds(bounds);\n }\n setMap(initialMap);\n };\n\n if (!window.google) {\n const script = document.createElement(SCRIPT);\n script.src = `${GOOGLE_MAPS_SCRIPT}${process.env.GOOGLE_MAPS_API_KEY}`;\n document.head.append(script);\n script.addEventListener(LOAD, onLoad);\n return () => script.removeEventListener(LOAD, onLoad);\n }\n\n onLoad();\n\n if (map) {\n map.setOptions(options);\n const { enableGeolocation } = otherProps;\n const shouldActivateGeolocation = enableGeolocation && navigator.geolocation;\n if (shouldActivateGeolocation) {\n navigator.geolocation.getCurrentPosition(\n position => {\n const center = {\n lat: position.coords.latitude,\n lng: position.coords.longitude\n };\n\n map.setCenter(center);\n },\n () => {}\n );\n }\n }\n\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n if (map && typeof onMount === `function`) onMount(map, onMountProps);\n if (isIntersecting) addZoomListener(map, router, mapShapes, imageData);\n\n return <div className=\"google-maps\" ref={mapRef} />;\n};\n\nGoogleMaps.propTypes = {\n mapShapes: PropTypes.array,\n imageData: PropTypes.array,\n type: PropTypes.string,\n name: PropTypes.string,\n modifier: PropTypes.string,\n elementTitle: PropTypes.string,\n onMount: PropTypes.func,\n onMountProps: PropTypes.object,\n parent: PropTypes.object,\n centerCoordinates: PropTypes.array\n};\n\nGoogleMaps.defaultProps = {\n mapShapes: [],\n imageData: [],\n centerCoordinates: [],\n type: '',\n name: '',\n modifier: '',\n elementTitle: '',\n onMount: null,\n onMountProps: null,\n parent: {}\n};\n\nexport default React.memo(withTitle(GoogleMaps), shouldNotUpdate);\n"],"file":"GoogleMaps.js"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["entityGroups"];
|
|
3
|
+
const _excluded = ["entityGroups", "parent"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useGetEntitySchemasAsObj } from '@blaze-cms/react-page-builder';
|
|
7
|
-
import {
|
|
7
|
+
import { buildShapesConfig } from './helpers';
|
|
8
8
|
import GoogleMapsRender from './GoogleMapsRender';
|
|
9
9
|
|
|
10
10
|
const GoogleMapsFactory = _ref => {
|
|
11
11
|
let {
|
|
12
|
-
entityGroups
|
|
12
|
+
entityGroups,
|
|
13
|
+
parent
|
|
13
14
|
} = _ref,
|
|
14
15
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
15
16
|
|
|
@@ -22,17 +23,20 @@ const GoogleMapsFactory = _ref => {
|
|
|
22
23
|
}) => entity));
|
|
23
24
|
if (loading) return '';
|
|
24
25
|
if (error) return error.message;
|
|
25
|
-
const
|
|
26
|
+
const shapeConfigs = buildShapesConfig(data, entityGroups, parent);
|
|
26
27
|
return /*#__PURE__*/React.createElement(GoogleMapsRender, _extends({
|
|
27
|
-
|
|
28
|
-
entityGroups: entityGroups
|
|
28
|
+
shapeConfigs: shapeConfigs,
|
|
29
|
+
entityGroups: entityGroups,
|
|
30
|
+
parent: parent
|
|
29
31
|
}, otherProps));
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
GoogleMapsFactory.propTypes = {
|
|
35
|
+
parent: PropTypes.object,
|
|
33
36
|
entityGroups: PropTypes.array
|
|
34
37
|
};
|
|
35
38
|
GoogleMapsFactory.defaultProps = {
|
|
39
|
+
parent: {},
|
|
36
40
|
entityGroups: []
|
|
37
41
|
};
|
|
38
42
|
export default GoogleMapsFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GoogleMaps/GoogleMapsFactory.js"],"names":["React","PropTypes","useGetEntitySchemasAsObj","
|
|
1
|
+
{"version":3,"sources":["../../src/GoogleMaps/GoogleMapsFactory.js"],"names":["React","PropTypes","useGetEntitySchemasAsObj","buildShapesConfig","GoogleMapsRender","GoogleMapsFactory","entityGroups","parent","otherProps","data","loading","error","map","entity","message","shapeConfigs","propTypes","object","array","defaultProps"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,wBAAT,QAAyC,+BAAzC;AACA,SAASC,iBAAT,QAAkC,WAAlC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAEA,MAAMC,iBAAiB,GAAG,QAA6C;AAAA,MAA5C;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA4C;AAAA,MAAjBC,UAAiB;;AACrE,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,OAAR;AAAiBC,IAAAA;AAAjB,MAA2BT,wBAAwB,CACvDI,YAAY,CAACM,GAAb,CAAiB,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAgBA,MAAjC,CADuD,CAAzD;AAIA,MAAIH,OAAJ,EAAa,OAAO,EAAP;AACb,MAAIC,KAAJ,EAAW,OAAOA,KAAK,CAACG,OAAb;AAEX,QAAMC,YAAY,GAAGZ,iBAAiB,CAACM,IAAD,EAAOH,YAAP,EAAqBC,MAArB,CAAtC;AAEA,sBACE,oBAAC,gBAAD;AACE,IAAA,YAAY,EAAEQ,YADhB;AAEE,IAAA,YAAY,EAAET,YAFhB;AAGE,IAAA,MAAM,EAAEC;AAHV,KAIMC,UAJN,EADF;AAQD,CAlBD;;AAoBAH,iBAAiB,CAACW,SAAlB,GAA8B;AAC5BT,EAAAA,MAAM,EAAEN,SAAS,CAACgB,MADU;AAE5BX,EAAAA,YAAY,EAAEL,SAAS,CAACiB;AAFI,CAA9B;AAKAb,iBAAiB,CAACc,YAAlB,GAAiC;AAC/BZ,EAAAA,MAAM,EAAE,EADuB;AAE/BD,EAAAA,YAAY,EAAE;AAFiB,CAAjC;AAKA,eAAeD,iBAAf","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useGetEntitySchemasAsObj } from '@blaze-cms/react-page-builder';\nimport { buildShapesConfig } from './helpers';\nimport GoogleMapsRender from './GoogleMapsRender';\n\nconst GoogleMapsFactory = ({ entityGroups, parent, ...otherProps }) => {\n const { data, loading, error } = useGetEntitySchemasAsObj(\n entityGroups.map(({ entity }) => entity)\n );\n\n if (loading) return '';\n if (error) return error.message;\n\n const shapeConfigs = buildShapesConfig(data, entityGroups, parent);\n\n return (\n <GoogleMapsRender\n shapeConfigs={shapeConfigs}\n entityGroups={entityGroups}\n parent={parent}\n {...otherProps}\n />\n );\n};\n\nGoogleMapsFactory.propTypes = {\n parent: PropTypes.object,\n entityGroups: PropTypes.array\n};\n\nGoogleMapsFactory.defaultProps = {\n parent: {},\n entityGroups: []\n};\n\nexport default GoogleMapsFactory;\n"],"file":"GoogleMapsFactory.js"}
|
|
@@ -1,78 +1,70 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["
|
|
3
|
+
const _excluded = ["shapeConfigs", "entityGroups", "id"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import isNumber from 'lodash.isnumber';
|
|
7
7
|
import { useQuery } from '@apollo/client';
|
|
8
8
|
import { getAction } from '@blaze-cms/react-page-builder';
|
|
9
9
|
import { useGetImages } from './hooks';
|
|
10
|
-
import { buildQuery, getImageIds } from './helpers';
|
|
10
|
+
import { buildQuery, getImageIds, getCenterCoordinates, buildMapShapes } from './helpers';
|
|
11
11
|
import GoogleMaps from './GoogleMaps';
|
|
12
12
|
const defaultQuery = getAction('getPublishedPages', 'id');
|
|
13
13
|
|
|
14
14
|
const GoogleMapsRender = _ref => {
|
|
15
15
|
let {
|
|
16
|
-
|
|
16
|
+
shapeConfigs,
|
|
17
17
|
entityGroups,
|
|
18
|
-
id
|
|
19
|
-
parent
|
|
18
|
+
id
|
|
20
19
|
} = _ref,
|
|
21
20
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
22
21
|
|
|
23
22
|
const {
|
|
24
|
-
centerLatitude,
|
|
25
|
-
centerLongitude,
|
|
26
23
|
defaultZoom
|
|
27
24
|
} = otherProps;
|
|
28
25
|
const {
|
|
29
|
-
query
|
|
30
|
-
|
|
31
|
-
} = buildQuery(entityConfigs);
|
|
32
|
-
const shouldDisplayMap = [centerLatitude, centerLongitude, defaultZoom].every(value => isNumber(value));
|
|
26
|
+
query
|
|
27
|
+
} = buildQuery(shapeConfigs);
|
|
33
28
|
const {
|
|
34
|
-
data
|
|
29
|
+
data,
|
|
35
30
|
loading,
|
|
36
31
|
error
|
|
37
32
|
} = useQuery(query || defaultQuery, {
|
|
38
|
-
|
|
39
|
-
where: {
|
|
40
|
-
id: {
|
|
41
|
-
_in: ids
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
skip: !(ids.length && query)
|
|
33
|
+
skip: !query
|
|
46
34
|
});
|
|
47
|
-
const
|
|
35
|
+
const mapShapes = buildMapShapes(shapeConfigs, data);
|
|
36
|
+
const imageIds = getImageIds(mapShapes);
|
|
48
37
|
const {
|
|
49
|
-
data:
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
data: {
|
|
39
|
+
getFiles: imageData
|
|
40
|
+
} = {},
|
|
41
|
+
loading: imagesLoading,
|
|
42
|
+
error: imagesError
|
|
52
43
|
} = useGetImages(imageIds);
|
|
53
|
-
if (loading ||
|
|
54
|
-
if (error ||
|
|
44
|
+
if (loading || imagesLoading) return '';
|
|
45
|
+
if (error || imagesError) return null;
|
|
46
|
+
const centerCoordinates = getCenterCoordinates(mapShapes, otherProps);
|
|
47
|
+
const shouldDisplayMap = isNumber(defaultZoom) && !!centerCoordinates.length && !!mapShapes.length;
|
|
55
48
|
if (!shouldDisplayMap) return null;
|
|
56
49
|
return /*#__PURE__*/React.createElement(GoogleMaps, _extends({
|
|
57
50
|
key: otherProps.slug,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
centerCoordinates: centerCoordinates,
|
|
52
|
+
mapShapes: mapShapes,
|
|
53
|
+
imageData: imageData
|
|
61
54
|
}, otherProps));
|
|
62
55
|
};
|
|
63
56
|
|
|
64
57
|
GoogleMapsRender.propTypes = {
|
|
65
|
-
parent: PropTypes.object.isRequired,
|
|
66
58
|
entityGroups: PropTypes.array,
|
|
67
59
|
id: PropTypes.string,
|
|
68
|
-
|
|
60
|
+
shapeConfigs: PropTypes.array,
|
|
69
61
|
centerLatitude: PropTypes.number,
|
|
70
62
|
centerLongitude: PropTypes.number,
|
|
71
63
|
defaultZoom: PropTypes.number
|
|
72
64
|
};
|
|
73
65
|
GoogleMapsRender.defaultProps = {
|
|
74
66
|
entityGroups: [],
|
|
75
|
-
|
|
67
|
+
shapeConfigs: [],
|
|
76
68
|
id: '',
|
|
77
69
|
centerLatitude: null,
|
|
78
70
|
centerLongitude: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GoogleMaps/GoogleMapsRender.js"],"names":["React","PropTypes","isNumber","useQuery","getAction","useGetImages","buildQuery","getImageIds","GoogleMaps","defaultQuery","GoogleMapsRender","
|
|
1
|
+
{"version":3,"sources":["../../src/GoogleMaps/GoogleMapsRender.js"],"names":["React","PropTypes","isNumber","useQuery","getAction","useGetImages","buildQuery","getImageIds","getCenterCoordinates","buildMapShapes","GoogleMaps","defaultQuery","GoogleMapsRender","shapeConfigs","entityGroups","id","otherProps","defaultZoom","query","data","loading","error","skip","mapShapes","imageIds","getFiles","imageData","imagesLoading","imagesError","centerCoordinates","shouldDisplayMap","length","slug","propTypes","array","string","centerLatitude","number","centerLongitude","defaultProps"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,QAAT,QAAyB,gBAAzB;AACA,SAASC,SAAT,QAA0B,+BAA1B;AACA,SAASC,YAAT,QAA6B,SAA7B;AACA,SAASC,UAAT,EAAqBC,WAArB,EAAkCC,oBAAlC,EAAwDC,cAAxD,QAA8E,WAA9E;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAMC,YAAY,GAAGP,SAAS,CAAC,mBAAD,EAAsB,IAAtB,CAA9B;;AAEA,MAAMQ,gBAAgB,GAAG,QAAuD;AAAA,MAAtD;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,YAAhB;AAA8BC,IAAAA;AAA9B,GAAsD;AAAA,MAAjBC,UAAiB;;AAC9E,QAAM;AAAEC,IAAAA;AAAF,MAAkBD,UAAxB;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAYZ,UAAU,CAACO,YAAD,CAA5B;AACA,QAAM;AAAEM,IAAAA,IAAF;AAAQC,IAAAA,OAAR;AAAiBC,IAAAA;AAAjB,MAA2BlB,QAAQ,CAACe,KAAK,IAAIP,YAAV,EAAwB;AAC/DW,IAAAA,IAAI,EAAE,CAACJ;AADwD,GAAxB,CAAzC;AAGA,QAAMK,SAAS,GAAGd,cAAc,CAACI,YAAD,EAAeM,IAAf,CAAhC;AACA,QAAMK,QAAQ,GAAGjB,WAAW,CAACgB,SAAD,CAA5B;AACA,QAAM;AACJJ,IAAAA,IAAI,EAAE;AAAEM,MAA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eAAe,EAAE,IALa;AAM9BrB,EAAAA,WAAW,EAAE;AANiB,CAAhC;AASA,eAAeL,gBAAf","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isNumber from 'lodash.isnumber';\nimport { useQuery } from '@apollo/client';\nimport { getAction } from '@blaze-cms/react-page-builder';\nimport { useGetImages } from './hooks';\nimport { buildQuery, getImageIds, getCenterCoordinates, buildMapShapes } from './helpers';\nimport GoogleMaps from './GoogleMaps';\n\nconst defaultQuery = getAction('getPublishedPages', 'id');\n\nconst GoogleMapsRender = ({ shapeConfigs, entityGroups, id, ...otherProps }) => {\n const { defaultZoom } = otherProps;\n const { query } = buildQuery(shapeConfigs);\n const { data, loading, error } = useQuery(query || defaultQuery, {\n skip: !query\n });\n const mapShapes = buildMapShapes(shapeConfigs, data);\n const imageIds = getImageIds(mapShapes);\n const {\n data: { getFiles: imageData } = {},\n loading: imagesLoading,\n error: imagesError\n } = useGetImages(imageIds);\n if (loading || imagesLoading) return '';\n if (error || imagesError) return null;\n\n const centerCoordinates = getCenterCoordinates(mapShapes, otherProps);\n const shouldDisplayMap =\n isNumber(defaultZoom) && !!centerCoordinates.length && !!mapShapes.length;\n\n if (!shouldDisplayMap) return null;\n\n return (\n <GoogleMaps\n key={otherProps.slug}\n centerCoordinates={centerCoordinates}\n mapShapes={mapShapes}\n imageData={imageData}\n {...otherProps}\n />\n );\n};\n\nGoogleMapsRender.propTypes = {\n entityGroups: PropTypes.array,\n id: PropTypes.string,\n shapeConfigs: PropTypes.array,\n centerLatitude: PropTypes.number,\n centerLongitude: PropTypes.number,\n defaultZoom: PropTypes.number\n};\n\nGoogleMapsRender.defaultProps = {\n entityGroups: [],\n shapeConfigs: [],\n id: '',\n centerLatitude: null,\n centerLongitude: null,\n defaultZoom: null\n};\n\nexport default GoogleMapsRender;\n"],"file":"GoogleMapsRender.js"}
|
|
@@ -1,30 +1,10 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
1
|
import { ZOOM_CHANGED } from '../../constants';
|
|
8
2
|
import setShapes from './set-shapes';
|
|
9
3
|
|
|
10
|
-
const addZoomListener = (map, router,
|
|
4
|
+
const addZoomListener = (map, router, shapes, imageData) => {
|
|
11
5
|
if (!map) return;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
entity,
|
|
15
|
-
shapes: entityShapes,
|
|
16
|
-
enableInfoPane = false,
|
|
17
|
-
dataSummaries = []
|
|
18
|
-
} = entityGroup;
|
|
19
|
-
acc.push(...entityShapes.map(entityShape => _objectSpread(_objectSpread({}, entityShape), {}, {
|
|
20
|
-
entity,
|
|
21
|
-
enableInfoPane,
|
|
22
|
-
dataSummaries
|
|
23
|
-
})));
|
|
24
|
-
return acc;
|
|
25
|
-
}, []);
|
|
26
|
-
setShapes(map, router, shapes, data, imageData);
|
|
27
|
-
map.addListener(ZOOM_CHANGED, () => setShapes(map, router, shapes, data, imageData));
|
|
6
|
+
setShapes(map, router, shapes, imageData);
|
|
7
|
+
map.addListener(ZOOM_CHANGED, () => setShapes(map, router, shapes, imageData));
|
|
28
8
|
};
|
|
29
9
|
|
|
30
10
|
export default addZoomListener;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/GoogleMaps/helpers/add-zoom-listener.js"],"names":["ZOOM_CHANGED","setShapes","addZoomListener","map","router","
|
|
1
|
+
{"version":3,"sources":["../../../src/GoogleMaps/helpers/add-zoom-listener.js"],"names":["ZOOM_CHANGED","setShapes","addZoomListener","map","router","shapes","imageData","addListener"],"mappings":"AAAA,SAASA,YAAT,QAA6B,iBAA7B;AACA,OAAOC,SAAP,MAAsB,cAAtB;;AAEA,MAAMC,eAAe,GAAG,CAACC,GAAD,EAAMC,MAAN,EAAcC,MAAd,EAAsBC,SAAtB,KAAoC;AAC1D,MAAI,CAACH,GAAL,EAAU;AACVF,EAAAA,SAAS,CAACE,GAAD,EAAMC,MAAN,EAAcC,MAAd,EAAsBC,SAAtB,CAAT;AACAH,EAAAA,GAAG,CAACI,WAAJ,CAAgBP,YAAhB,EAA8B,MAAMC,SAAS,CAACE,GAAD,EAAMC,MAAN,EAAcC,MAAd,EAAsBC,SAAtB,CAA7C;AACD,CAJD;;AAMA,eAAeJ,eAAf","sourcesContent":["import { ZOOM_CHANGED } from '../../constants';\nimport setShapes from './set-shapes';\n\nconst addZoomListener = (map, router, shapes, imageData) => {\n if (!map) return;\n setShapes(map, router, shapes, imageData);\n map.addListener(ZOOM_CHANGED, () => setShapes(map, router, shapes, imageData));\n};\n\nexport default addZoomListener;\n"],"file":"add-zoom-listener.js"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const getLatLonValues = (keys, data) => {
|
|
2
|
+
if (keys.length === 1) return data[keys];
|
|
3
|
+
const key = keys.shift();
|
|
4
|
+
return getLatLonValues(keys, data[key]);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const getLatLong = (latProp, lonProp, shape, data) => {
|
|
8
|
+
const {
|
|
9
|
+
latitude,
|
|
10
|
+
longitude
|
|
11
|
+
} = shape;
|
|
12
|
+
if (!latProp || !lonProp) return {
|
|
13
|
+
latitude,
|
|
14
|
+
longitude
|
|
15
|
+
};
|
|
16
|
+
const latKeys = latProp.split('.');
|
|
17
|
+
const lonKeys = lonProp.split('.');
|
|
18
|
+
const lat = getLatLonValues(latKeys, data);
|
|
19
|
+
const lon = getLatLonValues(lonKeys, data);
|
|
20
|
+
return {
|
|
21
|
+
latitude: lat,
|
|
22
|
+
longitude: lon
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const buildMapShapes = (shapesOptions, shapesData) => {
|
|
27
|
+
if (!shapesData) return [];
|
|
28
|
+
const mapShapes = [];
|
|
29
|
+
shapesOptions.forEach(shape => {
|
|
30
|
+
const {
|
|
31
|
+
shapeKey,
|
|
32
|
+
entityOptions,
|
|
33
|
+
shapeOptions
|
|
34
|
+
} = shape;
|
|
35
|
+
const {
|
|
36
|
+
dataSummaries,
|
|
37
|
+
enableInfoPane
|
|
38
|
+
} = entityOptions;
|
|
39
|
+
const {
|
|
40
|
+
imageId,
|
|
41
|
+
label,
|
|
42
|
+
markerHeight,
|
|
43
|
+
markerWidth,
|
|
44
|
+
maxZoom,
|
|
45
|
+
minZoom,
|
|
46
|
+
type,
|
|
47
|
+
useAsCenter
|
|
48
|
+
} = shapeOptions;
|
|
49
|
+
const shapeData = Array.isArray(shapesData[shapeKey]) ? shapesData[shapeKey] : shapesData[shapeKey].results;
|
|
50
|
+
if (!shapeData) return;
|
|
51
|
+
const {
|
|
52
|
+
latProp,
|
|
53
|
+
lonProp
|
|
54
|
+
} = entityOptions;
|
|
55
|
+
shapeData.forEach(data => {
|
|
56
|
+
const {
|
|
57
|
+
url
|
|
58
|
+
} = data;
|
|
59
|
+
const {
|
|
60
|
+
latitude,
|
|
61
|
+
longitude
|
|
62
|
+
} = getLatLong(latProp, lonProp, shapeOptions, data);
|
|
63
|
+
const formatedShape = {
|
|
64
|
+
latitude,
|
|
65
|
+
longitude,
|
|
66
|
+
dataSummaries,
|
|
67
|
+
enableInfoPane,
|
|
68
|
+
imageId,
|
|
69
|
+
label,
|
|
70
|
+
markerHeight,
|
|
71
|
+
markerWidth,
|
|
72
|
+
maxZoom,
|
|
73
|
+
minZoom,
|
|
74
|
+
type,
|
|
75
|
+
url,
|
|
76
|
+
useAsCenter,
|
|
77
|
+
shapeData: data
|
|
78
|
+
};
|
|
79
|
+
mapShapes.push(formatedShape);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return mapShapes;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default buildMapShapes;
|
|
86
|
+
//# sourceMappingURL=build-map-shapes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/GoogleMaps/helpers/build-map-shapes.js"],"names":["getLatLonValues","keys","data","length","key","shift","getLatLong","latProp","lonProp","shape","latitude","longitude","latKeys","split","lonKeys","lat","lon","buildMapShapes","shapesOptions","shapesData","mapShapes","forEach","shapeKey","entityOptions","shapeOptions","dataSummaries","enableInfoPane","imageId","label","markerHeight","markerWidth","maxZoom","minZoom","type","useAsCenter","shapeData","Array","isArray","results","url","formatedShape","push"],"mappings":"AAAA,MAAMA,eAAe,GAAG,CAACC,IAAD,EAAOC,IAAP,KAAgB;AACtC,MAAID,IAAI,CAACE,MAAL,KAAgB,CAApB,EAAuB,OAAOD,IAAI,CAACD,IAAD,CAAX;AACvB,QAAMG,GAAG,GAAGH,IAAI,CAACI,KAAL,EAAZ;AACA,SAAOL,eAAe,CAACC,IAAD,EAAOC,IAAI,CAACE,GAAD,CAAX,CAAtB;AACD,CAJD;;AAMA,MAAME,UAAU,GAAG,CAACC,OAAD,EAAUC,OAAV,EAAmBC,KAAnB,EAA0BP,IAA1B,KAAmC;AACpD,QAAM;AAAEQ,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA0BF,KAAhC;AAEA,MAAI,CAACF,OAAD,IAAY,CAACC,OAAjB,EAA0B,OAAO;AAAEE,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAP;AAC1B,QAAMC,OAAO,GAAGL,OAAO,CAACM,KAAR,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AA,QAAF;AAAYC,QAAAA;AAAZ,UAA0BL,UAAU,CAACC,OAAD,EAAUC,OAAV,EAAmBgB,YAAnB,EAAiCtB,IAAjC,CAA1C;AAEA,YAAMsC,aAAa,GAAG;AACpB9B,QAAAA,QADoB;AAEpBC,QAAAA,SAFoB;AAGpBc,QAAAA,aAHoB;AAIpBC,QAAAA,cAJoB;AAKpBC,QAAAA,OALoB;AAMpBC,QAAAA,KANoB;AAOpBC,QAAAA,YAPoB;AAQpBC,QAAAA,WARoB;AASpBC,QAAAA,OAToB;AAUpBC,QAAAA,OAVoB;AAWpBC,QAAAA,IAXoB;AAYpBM,QAAAA,GAZoB;AAapBL,QAAAA,WAboB;AAcpBC,QAAAA,SAAS,EAAEjC;AAdS,OAAtB;AAiBAkB,MAAAA,SAAS,CAACqB,IAAV,CAAeD,aAAf;AACD,KAtBD;AAuBD,GA3CD;AA6CA,SAAOpB,SAAP;AACD,CAjDD;;AAmDA,eAAeH,cAAf","sourcesContent":["const getLatLonValues = (keys, data) => {\n if (keys.length === 1) return data[keys];\n const key = keys.shift();\n return getLatLonValues(keys, data[key]);\n};\n\nconst getLatLong = (latProp, lonProp, shape, data) => {\n const { latitude, longitude } = shape;\n\n if (!latProp || !lonProp) return { latitude, longitude };\n const latKeys = latProp.split('.');\n const lonKeys = lonProp.split('.');\n const lat = getLatLonValues(latKeys, data);\n const lon = getLatLonValues(lonKeys, data);\n\n return { latitude: lat, longitude: lon };\n};\n\nconst buildMapShapes = (shapesOptions, shapesData) => {\n if (!shapesData) return [];\n const mapShapes = [];\n shapesOptions.forEach(shape => {\n const { shapeKey, entityOptions, shapeOptions } = shape;\n const { dataSummaries, enableInfoPane } = entityOptions;\n const {\n imageId,\n label,\n markerHeight,\n markerWidth,\n maxZoom,\n minZoom,\n type,\n useAsCenter\n } = shapeOptions;\n\n const shapeData = Array.isArray(shapesData[shapeKey])\n ? shapesData[shapeKey]\n : shapesData[shapeKey].results;\n if (!shapeData) return;\n const { latProp, lonProp } = entityOptions;\n\n shapeData.forEach(data => {\n const { url } = data;\n const { latitude, longitude } = getLatLong(latProp, lonProp, shapeOptions, data);\n\n const formatedShape = {\n latitude,\n longitude,\n dataSummaries,\n enableInfoPane,\n imageId,\n label,\n markerHeight,\n markerWidth,\n maxZoom,\n minZoom,\n type,\n url,\n useAsCenter,\n shapeData: data\n };\n\n mapShapes.push(formatedShape);\n });\n });\n\n return mapShapes;\n};\n\nexport default buildMapShapes;\n"],"file":"build-map-shapes.js"}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
import { generateQuery,
|
|
1
|
+
import { generateQuery, generateIdsQuery, generateFiltersQuery } from '../queries';
|
|
2
2
|
|
|
3
3
|
const buildQuery = entityConfigs => {
|
|
4
4
|
const entityIds = [];
|
|
5
|
-
const
|
|
5
|
+
const rawQueryStringified = '';
|
|
6
|
+
const queryString = entityConfigs.map(entityConfig => {
|
|
6
7
|
const {
|
|
7
8
|
action,
|
|
8
9
|
ids,
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
entity,
|
|
11
|
+
propsQuery,
|
|
12
|
+
shapeKey,
|
|
13
|
+
filtersObject
|
|
14
|
+
} = entityConfig;
|
|
15
|
+
if (!action) return '';
|
|
16
|
+
const formatedEntity = `${entity[0].toUpperCase()}${entity.slice(1)}`;
|
|
17
|
+
const filterQueryKey = action.indexOf('Published') !== -1 ? `Published${formatedEntity}` : formatedEntity;
|
|
11
18
|
entityIds.push(...ids);
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
const props = propsQuery.trim() || 'id';
|
|
20
|
+
const singleItemQuery = filtersObject ? generateFiltersQuery(shapeKey, props, JSON.stringify(filtersObject), filterQueryKey) : generateIdsQuery(shapeKey, props, action, ids);
|
|
21
|
+
return singleItemQuery;
|
|
22
|
+
}).join(' ');
|
|
15
23
|
return {
|
|
16
24
|
query: queryString ? generateQuery(queryString) : '',
|
|
17
|
-
ids: entityIds
|
|
25
|
+
ids: entityIds,
|
|
26
|
+
rawQueryStringified
|
|
18
27
|
};
|
|
19
28
|
};
|
|
20
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/GoogleMaps/helpers/build-query.js"],"names":["generateQuery","
|
|
1
|
+
{"version":3,"sources":["../../../src/GoogleMaps/helpers/build-query.js"],"names":["generateQuery","generateIdsQuery","generateFiltersQuery","buildQuery","entityConfigs","entityIds","rawQueryStringified","queryString","map","entityConfig","action","ids","entity","propsQuery","shapeKey","filtersObject","formatedEntity","toUpperCase","slice","filterQueryKey","indexOf","push","props","trim","singleItemQuery","JSON","stringify","join","query"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,gBAAxB,EAA0CC,oBAA1C,QAAsE,YAAtE;;AAEA,MAAMC,UAAU,GAAGC,aAAa,IAAI;AAClC,QAAMC,SAAS,GAAG,EAAlB;AACA,QAAMC,mBAAmB,GAAG,EAA5B;AACA,QAAMC,WAAW,GAAGH,aAAa,CAC9BI,GADiB,CACbC,YAAY,IAAI;AACnB,UAAM;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,GAAV;AAAeC,MAAAA,MAAf;AAAuBC,MAAAA,UAAvB;AAAmCC,MAAAA,QAAnC;AAA6CC,MAAAA;AAA7C,QAA+DN,YAArE;AACA,QAAI,CAACC,MAAL,EAAa,OAAO,EAAP;AACb,UAAMM,cAAc,GAAI,GAAEJ,MAAM,CAAC,CAAD,CAAN,CAAUK,WAAV,EAAwB,GAAEL,MAAM,CAACM,KAAP,CAAa,CAAb,CAAgB,EAApE;AACA,UAAMC,cAAc,GAClBT,MAAM,CAACU,OAAP,CAAe,WAAf,MAAgC,CAAC,CAAjC,GAAsC,YAAWJ,cAAe,EAAhE,GAAoEA,cADtE;AAGAX,IAAAA,SAAS,CAACgB,IAAV,CAAe,GAAGV,GAAlB;AACA,UAAMW,KAAK,GAAGT,UAAU,CAACU,IAAX,MAAqB,IAAnC;AACA,UAAMC,eAAe,GAAGT,aAAa,GACjCb,oBAAoB,CAACY,QAAD,EAAWQ,KAAX,EAAkBG,IAAI,CAACC,SAAL,CAAeX,aAAf,CAAlB,EAAiDI,cAAjD,CADa,GAEjClB,gBAAgB,CAACa,QAAD,EAAWQ,KAAX,EAAkBZ,MAAlB,EAA0BC,GAA1B,CAFpB;AAIA,WAAOa,eAAP;AACD,GAfiB,EAgBjBG,IAhBiB,CAgBZ,GAhBY,CAApB;AAkBA,SAAO;AACLC,IAAAA,KAAK,EAAErB,WAAW,GAAGP,aAAa,CAACO,WAAD,CAAhB,GAAgC,EAD7C;AAELI,IAAAA,GAAG,EAAEN,SAFA;AAGLC,IAAAA;AAHK,GAAP;AAKD,CA1BD;;AA4BA,eAAeH,UAAf","sourcesContent":["import { generateQuery, generateIdsQuery, generateFiltersQuery } from '../queries';\n\nconst buildQuery = entityConfigs => {\n const entityIds = [];\n const rawQueryStringified = '';\n const queryString = entityConfigs\n .map(entityConfig => {\n const { action, ids, entity, propsQuery, shapeKey, filtersObject } = entityConfig;\n if (!action) return '';\n const formatedEntity = `${entity[0].toUpperCase()}${entity.slice(1)}`;\n const filterQueryKey =\n action.indexOf('Published') !== -1 ? `Published${formatedEntity}` : formatedEntity;\n\n entityIds.push(...ids);\n const props = propsQuery.trim() || 'id';\n const singleItemQuery = filtersObject\n ? generateFiltersQuery(shapeKey, props, JSON.stringify(filtersObject), filterQueryKey)\n : generateIdsQuery(shapeKey, props, action, ids);\n\n return singleItemQuery;\n })\n .join(' ');\n\n return {\n query: queryString ? generateQuery(queryString) : '',\n ids: entityIds,\n rawQueryStringified\n };\n};\n\nexport default buildQuery;\n"],"file":"build-query.js"}
|