@blaze-cms/plugin-google-maps-fe 0.146.0-rc-eagle.0 → 0.146.0-rc-eagle-3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/lib-es/GoogleMaps/GoogleMaps.js +122 -0
  2. package/lib-es/GoogleMaps/GoogleMaps.js.map +1 -0
  3. package/lib-es/GoogleMaps/GoogleMapsFactory.js +41 -0
  4. package/lib-es/GoogleMaps/GoogleMapsFactory.js.map +1 -0
  5. package/lib-es/GoogleMaps/GoogleMapsHtml.js +16 -0
  6. package/lib-es/GoogleMaps/GoogleMapsHtml.js.map +1 -0
  7. package/lib-es/GoogleMaps/GoogleMapsRender.js +72 -0
  8. package/lib-es/GoogleMaps/GoogleMapsRender.js.map +1 -0
  9. package/lib-es/GoogleMaps/helpers/add-zoom-listener.js +9 -0
  10. package/lib-es/GoogleMaps/helpers/add-zoom-listener.js.map +1 -0
  11. package/lib-es/GoogleMaps/helpers/build-map-shapes.js +68 -0
  12. package/lib-es/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
  13. package/lib-es/GoogleMaps/helpers/build-map-type-ids.js +9 -0
  14. package/lib-es/GoogleMaps/helpers/build-map-type-ids.js.map +1 -0
  15. package/lib-es/GoogleMaps/helpers/build-query.js +31 -0
  16. package/lib-es/GoogleMaps/helpers/build-query.js.map +1 -0
  17. package/lib-es/GoogleMaps/helpers/build-shapes-configs.js +124 -0
  18. package/lib-es/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
  19. package/lib-es/GoogleMaps/helpers/get-center-coordinates.js +29 -0
  20. package/lib-es/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
  21. package/lib-es/GoogleMaps/helpers/get-image-ids.js +13 -0
  22. package/lib-es/GoogleMaps/helpers/get-image-ids.js.map +1 -0
  23. package/lib-es/GoogleMaps/helpers/get-path.js +13 -0
  24. package/lib-es/GoogleMaps/helpers/get-path.js.map +1 -0
  25. package/lib-es/GoogleMaps/helpers/index.js +9 -0
  26. package/lib-es/GoogleMaps/helpers/index.js.map +1 -0
  27. package/lib-es/GoogleMaps/helpers/set-map-options.js +69 -0
  28. package/lib-es/GoogleMaps/helpers/set-map-options.js.map +1 -0
  29. package/lib-es/GoogleMaps/helpers/set-shapes.js +309 -0
  30. package/lib-es/GoogleMaps/helpers/set-shapes.js.map +1 -0
  31. package/lib-es/GoogleMaps/hooks/index.js +4 -0
  32. package/lib-es/GoogleMaps/hooks/index.js.map +1 -0
  33. package/lib-es/GoogleMaps/hooks/use-get-entity-schemas.js +20 -0
  34. package/lib-es/GoogleMaps/hooks/use-get-entity-schemas.js.map +1 -0
  35. package/lib-es/GoogleMaps/hooks/use-get-images.js +27 -0
  36. package/lib-es/GoogleMaps/hooks/use-get-images.js.map +1 -0
  37. package/lib-es/GoogleMaps/index.js +3 -0
  38. package/lib-es/GoogleMaps/index.js.map +1 -0
  39. package/lib-es/GoogleMaps/queries.js +47 -0
  40. package/lib-es/GoogleMaps/queries.js.map +1 -0
  41. package/lib-es/constants.js +90 -0
  42. package/lib-es/constants.js.map +1 -0
  43. package/lib-es/index.js +17 -0
  44. package/lib-es/index.js.map +1 -0
  45. package/package.json +12 -8
  46. package/CHANGELOG.md +0 -1790
  47. package/babel.config.js +0 -3
  48. package/jest.config.js +0 -3
@@ -0,0 +1,122 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ const _excluded = ["type", "name", "modifier", "elementTitle", "imageData", "onMount", "onMountProps", "parent", "mapShapes", "centerCoordinates"];
3
+ import React, { useEffect, useState } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { useApolloClient } from '@apollo/client';
6
+ import { useRouter } from 'next/router';
7
+ import { withTitle } from '@blaze-cms/react-page-builder';
8
+ import { useInView } from '@blaze-react/utils/lib/customHooks';
9
+ import { functions, isEqual, omit } from 'lodash';
10
+ import { setMapOptions, addZoomListener } from './helpers';
11
+ import { GOOGLE_MAPS_SCRIPT, LOAD, SCRIPT, IN_VIEW_CONFIG } from '../constants';
12
+ import GoogleMapsHtml from './GoogleMapsHtml';
13
+ const shouldNotUpdate = (props, nextProps) => {
14
+ const [funcs, nextFuncs] = [functions(props), functions(nextProps)];
15
+ const noPropChange = isEqual(omit(props, funcs), omit(nextProps, nextFuncs));
16
+ const noFuncChange = funcs.length === nextFuncs.length && funcs.every(fn => props[fn].toString() === nextProps[fn].toString());
17
+ return noPropChange && noFuncChange;
18
+ };
19
+ const GoogleMaps = _ref => {
20
+ let {
21
+ type,
22
+ name,
23
+ modifier,
24
+ elementTitle,
25
+ imageData,
26
+ onMount,
27
+ onMountProps,
28
+ parent,
29
+ mapShapes,
30
+ centerCoordinates
31
+ } = _ref,
32
+ otherProps = _objectWithoutProperties(_ref, _excluded);
33
+ const router = useRouter();
34
+ const [isIntersecting, mapRef] = useInView(IN_VIEW_CONFIG);
35
+ const client = useApolloClient();
36
+ const [map, setMap] = useState();
37
+ useEffect(() => {
38
+ const options = setMapOptions(otherProps);
39
+ const onLoad = () => {
40
+ const initialMap = new window.google.maps.Map(mapRef.current, options);
41
+ if (centerCoordinates.length === 1) {
42
+ const [{
43
+ latitude: lat,
44
+ longitude: lng
45
+ }] = centerCoordinates;
46
+ initialMap.setCenter({
47
+ lat,
48
+ lng
49
+ });
50
+ } else {
51
+ const bounds = new window.google.maps.LatLngBounds();
52
+ centerCoordinates.forEach(({
53
+ latitude,
54
+ longitude
55
+ }) => {
56
+ bounds.extend(new window.google.maps.LatLng(latitude, longitude));
57
+ });
58
+ initialMap.fitBounds(bounds);
59
+ }
60
+ setMap(initialMap);
61
+ };
62
+ if (!window.google) {
63
+ const script = document.createElement(SCRIPT);
64
+ script.src = `${GOOGLE_MAPS_SCRIPT}${process.env.GOOGLE_MAPS_API_KEY}`;
65
+ document.head.append(script);
66
+ script.addEventListener(LOAD, onLoad);
67
+ return () => script.removeEventListener(LOAD, onLoad);
68
+ }
69
+ onLoad();
70
+ if (map) {
71
+ map.setOptions(options);
72
+ const {
73
+ enableGeolocation
74
+ } = otherProps;
75
+ const shouldActivateGeolocation = enableGeolocation && navigator.geolocation;
76
+ if (shouldActivateGeolocation) {
77
+ navigator.geolocation.getCurrentPosition(position => {
78
+ const center = {
79
+ lat: position.coords.latitude,
80
+ lng: position.coords.longitude
81
+ };
82
+ map.setCenter(center);
83
+ }, () => {});
84
+ }
85
+ }
86
+ return () => {};
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ }, []);
89
+ useEffect(() => {
90
+ if (isIntersecting) addZoomListener(map, router, mapShapes, imageData, client);
91
+ }, [isIntersecting, map, mapShapes, imageData, router, client]);
92
+ if (map && typeof onMount === `function`) onMount(map, onMountProps);
93
+ return /*#__PURE__*/React.createElement(GoogleMapsHtml, {
94
+ mapRef: mapRef
95
+ });
96
+ };
97
+ GoogleMaps.propTypes = {
98
+ mapShapes: PropTypes.array,
99
+ imageData: PropTypes.array,
100
+ type: PropTypes.string,
101
+ name: PropTypes.string,
102
+ modifier: PropTypes.string,
103
+ elementTitle: PropTypes.string,
104
+ onMount: PropTypes.func,
105
+ onMountProps: PropTypes.object,
106
+ parent: PropTypes.object,
107
+ centerCoordinates: PropTypes.array
108
+ };
109
+ GoogleMaps.defaultProps = {
110
+ mapShapes: [],
111
+ imageData: [],
112
+ centerCoordinates: [],
113
+ type: '',
114
+ name: '',
115
+ modifier: '',
116
+ elementTitle: '',
117
+ onMount: null,
118
+ onMountProps: null,
119
+ parent: {}
120
+ };
121
+ export default React.memo(withTitle(GoogleMaps), shouldNotUpdate);
122
+ //# sourceMappingURL=GoogleMaps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMaps.js","names":["React","useEffect","useState","PropTypes","useApolloClient","useRouter","withTitle","useInView","functions","isEqual","omit","setMapOptions","addZoomListener","GOOGLE_MAPS_SCRIPT","LOAD","SCRIPT","IN_VIEW_CONFIG","GoogleMapsHtml","shouldNotUpdate","props","nextProps","funcs","nextFuncs","noPropChange","noFuncChange","length","every","fn","toString","GoogleMaps","_ref","type","name","modifier","elementTitle","imageData","onMount","onMountProps","parent","mapShapes","centerCoordinates","otherProps","_objectWithoutProperties","_excluded","router","isIntersecting","mapRef","client","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"],"sources":["../../src/GoogleMaps/GoogleMaps.js"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useApolloClient } from '@apollo/client';\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';\nimport GoogleMapsHtml from './GoogleMapsHtml';\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 client = useApolloClient();\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 useEffect(() => {\n if (isIntersecting) addZoomListener(map, router, mapShapes, imageData, client);\n }, [isIntersecting, map, mapShapes, imageData, router, client]);\n\n if (map && typeof onMount === `function`) onMount(map, onMountProps);\n\n return <GoogleMapsHtml mapRef={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"],"mappings":";;AAAA,OAAOA,KAAK,IAAI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;EAEpE,oBAAOrC,KAAA,CAAAuE,aAAA,CAACtD,cAAc;IAAC6B,MAAM,EAAEA;EAAO,CAAE,CAAC;AAC3C,CAAC;AAEDjB,UAAU,CAAC4D,SAAS,GAAG;EACrBlD,SAAS,EAAEpC,SAAS,CAACuF,KAAK;EAC1BvD,SAAS,EAAEhC,SAAS,CAACuF,KAAK;EAC1B3D,IAAI,EAAE5B,SAAS,CAACwF,MAAM;EACtB3D,IAAI,EAAE7B,SAAS,CAACwF,MAAM;EACtB1D,QAAQ,EAAE9B,SAAS,CAACwF,MAAM;EAC1BzD,YAAY,EAAE/B,SAAS,CAACwF,MAAM;EAC9BvD,OAAO,EAAEjC,SAAS,CAACyF,IAAI;EACvBvD,YAAY,EAAElC,SAAS,CAAC0F,MAAM;EAC9BvD,MAAM,EAAEnC,SAAS,CAAC0F,MAAM;EACxBrD,iBAAiB,EAAErC,SAAS,CAACuF;AAC/B,CAAC;AAED7D,UAAU,CAACiE,YAAY,GAAG;EACxBvD,SAAS,EAAE,EAAE;EACbJ,SAAS,EAAE,EAAE;EACbK,iBAAiB,EAAE,EAAE;EACrBT,IAAI,EAAE,EAAE;EACRC,IAAI,EAAE,EAAE;EACRC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,EAAE;EAChBE,OAAO,EAAE,IAAI;EACbC,YAAY,EAAE,IAAI;EAClBC,MAAM,EAAE,CAAC;AACX,CAAC;AAED,eAAetC,KAAK,CAAC+F,IAAI,CAACzF,SAAS,CAACuB,UAAU,CAAC,EAAEX,eAAe,CAAC","ignoreList":[]}
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["entityGroups", "parent"];
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { useGetEntitySchemasAsObj } from '@blaze-cms/react-page-builder';
7
+ import { buildShapesConfig } from './helpers';
8
+ import GoogleMapsRender from './GoogleMapsRender';
9
+ import GoogleMapsHtml from './GoogleMapsHtml';
10
+ const GoogleMapsFactory = _ref => {
11
+ let {
12
+ entityGroups,
13
+ parent
14
+ } = _ref,
15
+ otherProps = _objectWithoutProperties(_ref, _excluded);
16
+ const {
17
+ data,
18
+ loading,
19
+ error
20
+ } = useGetEntitySchemasAsObj(entityGroups.map(({
21
+ entity
22
+ }) => entity));
23
+ if (loading) return /*#__PURE__*/React.createElement(GoogleMapsHtml, null);
24
+ if (error) return error.message;
25
+ const shapeConfigs = buildShapesConfig(data, entityGroups, parent);
26
+ return /*#__PURE__*/React.createElement(GoogleMapsRender, _extends({
27
+ shapeConfigs: shapeConfigs,
28
+ entityGroups: entityGroups,
29
+ parent: parent
30
+ }, otherProps));
31
+ };
32
+ GoogleMapsFactory.propTypes = {
33
+ parent: PropTypes.object,
34
+ entityGroups: PropTypes.array
35
+ };
36
+ GoogleMapsFactory.defaultProps = {
37
+ parent: {},
38
+ entityGroups: []
39
+ };
40
+ export default GoogleMapsFactory;
41
+ //# sourceMappingURL=GoogleMapsFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMapsFactory.js","names":["React","PropTypes","useGetEntitySchemasAsObj","buildShapesConfig","GoogleMapsRender","GoogleMapsHtml","GoogleMapsFactory","_ref","entityGroups","parent","otherProps","_objectWithoutProperties","_excluded","data","loading","error","map","entity","createElement","message","shapeConfigs","_extends","propTypes","object","array","defaultProps"],"sources":["../../src/GoogleMaps/GoogleMapsFactory.js"],"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';\nimport GoogleMapsHtml from './GoogleMapsHtml';\n\nconst GoogleMapsFactory = ({ entityGroups, parent, ...otherProps }) => {\n const { data, loading, error } = useGetEntitySchemasAsObj(\n entityGroups.map(({ entity }) => entity)\n );\n\n if (loading) return <GoogleMapsHtml />;\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"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,iBAAiB,QAAQ,WAAW;AAC7C,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,cAAc,MAAM,kBAAkB;AAE7C,MAAMC,iBAAiB,GAAGC,IAAA,IAA6C;EAAA,IAA5C;MAAEC,YAAY;MAAEC;IAAsB,CAAC,GAAAF,IAAA;IAAZG,UAAU,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAC9D,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGb,wBAAwB,CACvDM,YAAY,CAACQ,GAAG,CAAC,CAAC;IAAEC;EAAO,CAAC,KAAKA,MAAM,CACzC,CAAC;EAED,IAAIH,OAAO,EAAE,oBAAOd,KAAA,CAAAkB,aAAA,CAACb,cAAc,MAAE,CAAC;EACtC,IAAIU,KAAK,EAAE,OAAOA,KAAK,CAACI,OAAO;EAE/B,MAAMC,YAAY,GAAGjB,iBAAiB,CAACU,IAAI,EAAEL,YAAY,EAAEC,MAAM,CAAC;EAElE,oBACET,KAAA,CAAAkB,aAAA,CAACd,gBAAgB,EAAAiB,QAAA;IACfD,YAAY,EAAEA,YAAa;IAC3BZ,YAAY,EAAEA,YAAa;IAC3BC,MAAM,EAAEA;EAAO,GACXC,UAAU,CACf,CAAC;AAEN,CAAC;AAEDJ,iBAAiB,CAACgB,SAAS,GAAG;EAC5Bb,MAAM,EAAER,SAAS,CAACsB,MAAM;EACxBf,YAAY,EAAEP,SAAS,CAACuB;AAC1B,CAAC;AAEDlB,iBAAiB,CAACmB,YAAY,GAAG;EAC/BhB,MAAM,EAAE,CAAC,CAAC;EACVD,YAAY,EAAE;AAChB,CAAC;AAED,eAAeF,iBAAiB","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ const GoogleMapsFactory = ({
4
+ mapRef
5
+ }) => /*#__PURE__*/React.createElement("div", {
6
+ className: `google-maps ${!mapRef ? 'loading' : ''}`,
7
+ ref: mapRef
8
+ });
9
+ GoogleMapsFactory.propTypes = {
10
+ mapRef: PropTypes.object
11
+ };
12
+ GoogleMapsFactory.defaultProps = {
13
+ mapRef: null
14
+ };
15
+ export default GoogleMapsFactory;
16
+ //# sourceMappingURL=GoogleMapsHtml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMapsHtml.js","names":["React","PropTypes","GoogleMapsFactory","mapRef","createElement","className","ref","propTypes","object","defaultProps"],"sources":["../../src/GoogleMaps/GoogleMapsHtml.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst GoogleMapsFactory = ({ mapRef }) => (\n <div className={`google-maps ${!mapRef ? 'loading' : ''}`} ref={mapRef} />\n);\n\nGoogleMapsFactory.propTypes = {\n mapRef: PropTypes.object\n};\n\nGoogleMapsFactory.defaultProps = {\n mapRef: null\n};\n\nexport default GoogleMapsFactory;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC;AAAO,CAAC,kBACnCH,KAAA,CAAAI,aAAA;EAAKC,SAAS,EAAE,eAAe,CAACF,MAAM,GAAG,SAAS,GAAG,EAAE,EAAG;EAACG,GAAG,EAAEH;AAAO,CAAE,CAC1E;AAEDD,iBAAiB,CAACK,SAAS,GAAG;EAC5BJ,MAAM,EAAEF,SAAS,CAACO;AACpB,CAAC;AAEDN,iBAAiB,CAACO,YAAY,GAAG;EAC/BN,MAAM,EAAE;AACV,CAAC;AAED,eAAeD,iBAAiB","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["shapeConfigs", "entityGroups", "id"];
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import isNumber from 'lodash.isnumber';
7
+ import { useQuery } from '@apollo/client';
8
+ import { getAction } from '@blaze-cms/react-page-builder';
9
+ import { useGetImages } from './hooks';
10
+ import { buildQuery, getImageIds, getCenterCoordinates, buildMapShapes } from './helpers';
11
+ import GoogleMaps from './GoogleMaps';
12
+ import GoogleMapsHtml from './GoogleMapsHtml';
13
+ const defaultQuery = getAction('getPublishedPages', 'id');
14
+ const GoogleMapsRender = _ref => {
15
+ let {
16
+ shapeConfigs,
17
+ entityGroups,
18
+ id
19
+ } = _ref,
20
+ otherProps = _objectWithoutProperties(_ref, _excluded);
21
+ const {
22
+ defaultZoom
23
+ } = otherProps;
24
+ const {
25
+ query
26
+ } = buildQuery(shapeConfigs);
27
+ const {
28
+ data,
29
+ loading,
30
+ error
31
+ } = useQuery(query || defaultQuery, {
32
+ skip: !query
33
+ });
34
+ const mapShapes = buildMapShapes(shapeConfigs, data);
35
+ const imageIds = getImageIds(mapShapes);
36
+ const {
37
+ data: {
38
+ getFiles: imageData
39
+ } = {},
40
+ loading: imagesLoading,
41
+ error: imagesError
42
+ } = useGetImages(imageIds);
43
+ if (loading || imagesLoading) return /*#__PURE__*/React.createElement(GoogleMapsHtml, null);
44
+ if (error || imagesError) return null;
45
+ const centerCoordinates = getCenterCoordinates(mapShapes, otherProps);
46
+ const shouldDisplayMap = isNumber(defaultZoom) && !!centerCoordinates.length;
47
+ if (!shouldDisplayMap) return null;
48
+ return /*#__PURE__*/React.createElement(GoogleMaps, _extends({
49
+ key: otherProps.slug,
50
+ centerCoordinates: centerCoordinates,
51
+ mapShapes: mapShapes,
52
+ imageData: imageData
53
+ }, otherProps));
54
+ };
55
+ GoogleMapsRender.propTypes = {
56
+ entityGroups: PropTypes.array,
57
+ id: PropTypes.string,
58
+ shapeConfigs: PropTypes.array,
59
+ centerLatitude: PropTypes.number,
60
+ centerLongitude: PropTypes.number,
61
+ defaultZoom: PropTypes.number
62
+ };
63
+ GoogleMapsRender.defaultProps = {
64
+ entityGroups: [],
65
+ shapeConfigs: [],
66
+ id: '',
67
+ centerLatitude: null,
68
+ centerLongitude: null,
69
+ defaultZoom: null
70
+ };
71
+ export default GoogleMapsRender;
72
+ //# sourceMappingURL=GoogleMapsRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMapsRender.js","names":["React","PropTypes","isNumber","useQuery","getAction","useGetImages","buildQuery","getImageIds","getCenterCoordinates","buildMapShapes","GoogleMaps","GoogleMapsHtml","defaultQuery","GoogleMapsRender","_ref","shapeConfigs","entityGroups","id","otherProps","_objectWithoutProperties","_excluded","defaultZoom","query","data","loading","error","skip","mapShapes","imageIds","getFiles","imageData","imagesLoading","imagesError","createElement","centerCoordinates","shouldDisplayMap","length","_extends","key","slug","propTypes","array","string","centerLatitude","number","centerLongitude","defaultProps"],"sources":["../../src/GoogleMaps/GoogleMapsRender.js"],"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';\nimport GoogleMapsHtml from './GoogleMapsHtml';\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\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 <GoogleMapsHtml />;\n if (error || imagesError) return null;\n\n const centerCoordinates = getCenterCoordinates(mapShapes, otherProps);\n const shouldDisplayMap = isNumber(defaultZoom) && !!centerCoordinates.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"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,QAAQ,MAAM,iBAAiB;AACtC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,YAAY,QAAQ,SAAS;AACtC,SAASC,UAAU,EAAEC,WAAW,EAAEC,oBAAoB,EAAEC,cAAc,QAAQ,WAAW;AACzF,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,cAAc,MAAM,kBAAkB;AAE7C,MAAMC,YAAY,GAAGR,SAAS,CAAC,mBAAmB,EAAE,IAAI,CAAC;AAEzD,MAAMS,gBAAgB,GAAGC,IAAA,IAAuD;EAAA,IAAtD;MAAEC,YAAY;MAAEC,YAAY;MAAEC;IAAkB,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C2B,SAAS,GAAG;EAC3BxB,YAAY,EAAEf,SAAS,CAACwC,KAAK;EAC7BxB,EAAE,EAAEhB,SAAS,CAACyC,MAAM;EACpB3B,YAAY,EAAEd,SAAS,CAACwC,KAAK;EAC7BE,cAAc,EAAE1C,SAAS,CAAC2C,MAAM;EAChCC,eAAe,EAAE5C,SAAS,CAAC2C,MAAM;EACjCvB,WAAW,EAAEpB,SAAS,CAAC2C;AACzB,CAAC;AAED/B,gBAAgB,CAACiC,YAAY,GAAG;EAC9B9B,YAAY,EAAE,EAAE;EAChBD,YAAY,EAAE,EAAE;EAChBE,EAAE,EAAE,EAAE;EACN0B,cAAc,EAAE,IAAI;EACpBE,eAAe,EAAE,IAAI;EACrBxB,WAAW,EAAE;AACf,CAAC;AAED,eAAeR,gBAAgB","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import { ZOOM_CHANGED } from '../../constants';
2
+ import setShapes from './set-shapes';
3
+ const addZoomListener = (map, router, shapes, imageData, client) => {
4
+ if (!map) return;
5
+ setShapes(map, router, shapes, imageData, client);
6
+ map.addListener(ZOOM_CHANGED, () => setShapes(map, router, shapes, imageData, client));
7
+ };
8
+ export default addZoomListener;
9
+ //# sourceMappingURL=add-zoom-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-zoom-listener.js","names":["ZOOM_CHANGED","setShapes","addZoomListener","map","router","shapes","imageData","client","addListener"],"sources":["../../../src/GoogleMaps/helpers/add-zoom-listener.js"],"sourcesContent":["import { ZOOM_CHANGED } from '../../constants';\nimport setShapes from './set-shapes';\n\nconst addZoomListener = (map, router, shapes, imageData, client) => {\n if (!map) return;\n setShapes(map, router, shapes, imageData, client);\n map.addListener(ZOOM_CHANGED, () => setShapes(map, router, shapes, imageData, client));\n};\n\nexport default addZoomListener;\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,OAAOC,SAAS,MAAM,cAAc;AAEpC,MAAMC,eAAe,GAAGA,CAACC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,MAAM,KAAK;EAClE,IAAI,CAACJ,GAAG,EAAE;EACVF,SAAS,CAACE,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,MAAM,CAAC;EACjDJ,GAAG,CAACK,WAAW,CAACR,YAAY,EAAE,MAAMC,SAAS,CAACE,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,MAAM,CAAC,CAAC;AACxF,CAAC;AAED,eAAeL,eAAe","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ const getLatLonValues = (keys, data) => {
5
+ if (keys.length === 1) return data[keys];
6
+ const key = keys.shift();
7
+ return getLatLonValues(keys, data[key]);
8
+ };
9
+ const getLatLong = (latProp, lonProp, shape, data) => {
10
+ const {
11
+ latitude,
12
+ longitude
13
+ } = shape;
14
+ if (!latProp || !lonProp) return {
15
+ latitude,
16
+ longitude
17
+ };
18
+ const latKeys = latProp.split('.');
19
+ const lonKeys = lonProp.split('.');
20
+ const lat = getLatLonValues(latKeys, data);
21
+ const lon = getLatLonValues(lonKeys, data);
22
+ return {
23
+ latitude: lat,
24
+ longitude: lon
25
+ };
26
+ };
27
+ const buildMapShapes = (shapesOptions, shapesData) => {
28
+ if (!shapesData) return [];
29
+ const mapShapes = [];
30
+ shapesOptions.forEach(shape => {
31
+ const {
32
+ shapeKey,
33
+ entityOptions,
34
+ shapeOptions
35
+ } = shape;
36
+ const {
37
+ dataSummaries,
38
+ enableInfoPane
39
+ } = entityOptions;
40
+ const shapeData = Array.isArray(shapesData[shapeKey]) ? shapesData[shapeKey] : shapesData[shapeKey].results;
41
+ if (!shapeData) return;
42
+ const {
43
+ latProp,
44
+ lonProp
45
+ } = entityOptions;
46
+ shapeData.forEach(data => {
47
+ const {
48
+ url
49
+ } = data;
50
+ const {
51
+ latitude,
52
+ longitude
53
+ } = getLatLong(latProp, lonProp, shapeOptions, data);
54
+ const formatedShape = _objectSpread(_objectSpread({}, shapeOptions), {}, {
55
+ latitude,
56
+ longitude,
57
+ dataSummaries,
58
+ enableInfoPane,
59
+ url,
60
+ shapeData: data
61
+ });
62
+ mapShapes.push(formatedShape);
63
+ });
64
+ });
65
+ return mapShapes;
66
+ };
67
+ export default buildMapShapes;
68
+ //# sourceMappingURL=build-map-shapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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","shapeData","Array","isArray","results","url","formatedShape","_objectSpread","push"],"sources":["../../../src/GoogleMaps/helpers/build-map-shapes.js"],"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\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 ...shapeOptions,\n latitude,\n longitude,\n dataSummaries,\n enableInfoPane,\n url,\n shapeData: data\n };\n\n mapShapes.push(formatedShape);\n });\n });\n\n return mapShapes;\n};\n\nexport default buildMapShapes;\n"],"mappings":";;;AAAA,MAAMA,eAAe,GAAGA,CAACC,IAAI,EAAEC,IAAI,KAAK;EACtC,IAAID,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOD,IAAI,CAACD,IAAI,CAAC;EACxC,MAAMG,GAAG,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC;EACxB,OAAOL,eAAe,CAACC,IAAI,EAAEC,IAAI,CAACE,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,MAAME,UAAU,GAAGA,CAACC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEP,IAAI,KAAK;EACpD,MAAM;IAAEQ,QAAQ;IAAEC;EAAU,CAAC,GAAGF,KAAK;EAErC,IAAI,CAACF,OAAO,IAAI,CAACC,OAAO,EAAE,OAAO;IAAEE,QAAQ;IAAEC;EAAU,CAAC;EACxD,MAAMC,OAAO,GAAGL,OAAO,CAACM,KAAK,CAAC,GAAG,CAAC;EAClC,MAAMC,OAAO,GAAGN,OAAO,CAACK,KAAK,CAAC,GAAG,CAAC;EAClC,MAAME,GAAG,GAAGf,eAAe,CAACY,OAAO,EAAEV,IAAI,CAAC;EAC1C,MAAMc,GAAG,GAAGhB,eA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SATELLITE, TERRAIN } from '../../constants';
2
+ const buildMapTypeIds = (enableSatelliteView, enableTerrainScreen) => {
3
+ const mapTypeIds = [ROADMAP];
4
+ if (enableSatelliteView) mapTypeIds.push(SATELLITE);
5
+ if (enableTerrainScreen) mapTypeIds.push(TERRAIN);
6
+ return mapTypeIds;
7
+ };
8
+ export default buildMapTypeIds;
9
+ //# sourceMappingURL=build-map-type-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-map-type-ids.js","names":["ROADMAP","SATELLITE","TERRAIN","buildMapTypeIds","enableSatelliteView","enableTerrainScreen","mapTypeIds","push"],"sources":["../../../src/GoogleMaps/helpers/build-map-type-ids.js"],"sourcesContent":["import { ROADMAP, SATELLITE, TERRAIN } from '../../constants';\n\nconst buildMapTypeIds = (enableSatelliteView, enableTerrainScreen) => {\n const mapTypeIds = [ROADMAP];\n if (enableSatelliteView) mapTypeIds.push(SATELLITE);\n if (enableTerrainScreen) mapTypeIds.push(TERRAIN);\n return mapTypeIds;\n};\n\nexport default buildMapTypeIds;\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,SAAS,EAAEC,OAAO,QAAQ,iBAAiB;AAE7D,MAAMC,eAAe,GAAGA,CAACC,mBAAmB,EAAEC,mBAAmB,KAAK;EACpE,MAAMC,UAAU,GAAG,CAACN,OAAO,CAAC;EAC5B,IAAII,mBAAmB,EAAEE,UAAU,CAACC,IAAI,CAACN,SAAS,CAAC;EACnD,IAAII,mBAAmB,EAAEC,UAAU,CAACC,IAAI,CAACL,OAAO,CAAC;EACjD,OAAOI,UAAU;AACnB,CAAC;AAED,eAAeH,eAAe","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ import upperFirst from 'lodash.upperfirst';
2
+ import camelcase from 'lodash.camelcase';
3
+ import { generateQuery, generateIdsQuery, generateFiltersQuery } from '../queries';
4
+ const buildQuery = entityConfigs => {
5
+ const entityIds = [];
6
+ const rawQueryStringified = '';
7
+ const queryString = entityConfigs.map(entityConfig => {
8
+ const {
9
+ action,
10
+ ids,
11
+ entity,
12
+ propsQuery,
13
+ shapeKey,
14
+ filtersObject
15
+ } = entityConfig;
16
+ if (!action) return '';
17
+ const formatedEntity = upperFirst(camelcase(entity));
18
+ const filterQueryKey = action.indexOf('Published') !== -1 ? `Published${formatedEntity}` : formatedEntity;
19
+ entityIds.push(...ids);
20
+ const props = propsQuery.trim() || 'id';
21
+ const singleItemQuery = filtersObject ? generateFiltersQuery(shapeKey, props, JSON.stringify(filtersObject), filterQueryKey) : generateIdsQuery(shapeKey, props, action, ids);
22
+ return singleItemQuery;
23
+ }).join(' ');
24
+ return {
25
+ query: queryString ? generateQuery(queryString) : '',
26
+ ids: entityIds,
27
+ rawQueryStringified
28
+ };
29
+ };
30
+ export default buildQuery;
31
+ //# sourceMappingURL=build-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-query.js","names":["upperFirst","camelcase","generateQuery","generateIdsQuery","generateFiltersQuery","buildQuery","entityConfigs","entityIds","rawQueryStringified","queryString","map","entityConfig","action","ids","entity","propsQuery","shapeKey","filtersObject","formatedEntity","filterQueryKey","indexOf","push","props","trim","singleItemQuery","JSON","stringify","join","query"],"sources":["../../../src/GoogleMaps/helpers/build-query.js"],"sourcesContent":["import upperFirst from 'lodash.upperfirst';\nimport camelcase from 'lodash.camelcase';\nimport { 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 = upperFirst(camelcase(entity));\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"],"mappings":"AAAA,OAAOA,UAAU,MAAM,mBAAmB;AAC1C,OAAOC,SAAS,MAAM,kBAAkB;AACxC,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,oBAAoB,QAAQ,YAAY;AAElF,MAAMC,UAAU,GAAGC,aAAa,IAAI;EAClC,MAAMC,SAAS,GAAG,EAAE;EACpB,MAAMC,mBAAmB,GAAG,EAAE;EAC9B,MAAMC,WAAW,GAAGH,aAAa,CAC9BI,GAAG,CAACC,YAAY,IAAI;IACnB,MAAM;MAAEC,MAAM;MAAEC,GAAG;MAAEC,MAAM;MAAEC,UAAU;MAAEC,QAAQ;MAAEC;IAAc,CAAC,GAAGN,YAAY;IACjF,IAAI,CAACC,MAAM,EAAE,OAAO,EAAE;IACtB,MAAMM,cAAc,GAAGlB,UAAU,CAACC,SAAS,CAACa,MAAM,CAAC,CAAC;IACpD,MAAMK,cAAc,GAClBP,MAAM,CAACQ,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAAG,YAAYF,cAAc,EAAE,GAAGA,cAAc;IAEpFX,SAAS,CAACc,IAAI,CAAC,GAAGR,GAAG,CAAC;IACtB,MAAMS,KAAK,GAAGP,UAAU,CAACQ,IAAI,CAAC,CAAC,IAAI,IAAI;IACvC,MAAMC,eAAe,GAAGP,aAAa,GACjCb,oBAAoB,CAACY,QAAQ,EAAEM,KAAK,EAAEG,IAAI,CAACC,SAAS,CAACT,aAAa,CAAC,EAAEE,cAAc,CAAC,GACpFhB,gBAAgB,CAACa,QAAQ,EAAEM,KAAK,EAAEV,MAAM,EAAEC,GAAG,CAAC;IAElD,OAAOW,eAAe;EACxB,CAAC,CAAC,CACDG,IAAI,CAAC,GAAG,CAAC;EAEZ,OAAO;IACLC,KAAK,EAAEnB,WAAW,GAAGP,aAAa,CAACO,WAAW,CAAC,GAAG,EAAE;IACpDI,GAAG,EAAEN,SAAS;IACdC;EACF,CAAC;AACH,CAAC;AAED,eAAeH,UAAU","ignoreList":[]}
@@ -0,0 +1,124 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import flatten from 'lodash.flatten';
5
+ import { IMAGE_ID, URL, ID } from '../../constants';
6
+ const getPropValues = properties => properties.reduce((acc, property) => {
7
+ if (property.includes('.')) {
8
+ const [relationName, relationProp] = property.split('.');
9
+ return `${acc} ${relationName} { ${relationProp} }`;
10
+ }
11
+ return `${acc} ${property}`;
12
+ }, '').trim();
13
+ const getUpdatedPropsQuery = (propsQuery, entityData) => {
14
+ const {
15
+ properties = {},
16
+ dynamicProperties = {}
17
+ } = entityData;
18
+ const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);
19
+ const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;
20
+ let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;
21
+ updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;
22
+ return updatedPropsQuery;
23
+ };
24
+ const buildFilterQueryString = filter => {
25
+ const [filterKey, filterValue] = filter.split('/');
26
+ const filterKeyword = `${filterKey}.keyword`;
27
+ return {
28
+ bool: {
29
+ should: [{
30
+ match: {
31
+ [filterKeyword]: filterValue
32
+ }
33
+ }]
34
+ }
35
+ };
36
+ };
37
+ const buildFilters = filters => {
38
+ if (!filters || !filters.length) return null;
39
+ const filterQueryProps = filters.map(buildFilterQueryString);
40
+ return {
41
+ bool: {
42
+ should: filterQueryProps
43
+ }
44
+ };
45
+ };
46
+ const buiildShapeProps = (shape, shapeKey, dataSummaries, parentId, entityData, entityGroup) => {
47
+ const {
48
+ displayItems = [],
49
+ filterBy
50
+ } = shape;
51
+ const {
52
+ latProp,
53
+ lonProp,
54
+ entity
55
+ } = entityGroup;
56
+ const {
57
+ actions,
58
+ relations
59
+ } = entityData;
60
+ const action = actions ? actions.getAllPublished || actions.getAll : '';
61
+ const dataSummaryProps = dataSummaries.reduce((acc, {
62
+ propsToDisplay
63
+ }) => {
64
+ const propsToDisplayValues = flatten(propsToDisplay.map(({
65
+ propertiesToDisplay
66
+ }) => propertiesToDisplay));
67
+ const propsToDisplayString = getPropValues(propsToDisplayValues);
68
+ return `${acc} ${propsToDisplayString}`;
69
+ }, '').trim();
70
+ const ids = [];
71
+ displayItems.length ? ids.push(displayItems[0]) : ids.push(parentId);
72
+ const filtersObject = buildFilters(filterBy);
73
+ let propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';
74
+ propsQuery = getUpdatedPropsQuery(propsQuery, entityData);
75
+ if (latProp && lonProp) {
76
+ propsQuery = `${propsQuery} ${formatProp(latProp, relations)} ${formatProp(lonProp, relations)}`;
77
+ }
78
+ if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;
79
+ return {
80
+ shapeKey,
81
+ entity,
82
+ propsQuery,
83
+ ids,
84
+ action,
85
+ filtersObject
86
+ };
87
+ };
88
+ const formatProp = (prop, relations = []) => {
89
+ if (!prop.includes('.')) return prop;
90
+ const [mainProp, nestedProp] = prop.split('.');
91
+ const idProp = relations.find(({
92
+ localField
93
+ }) => localField === mainProp) ? 'id ' : '';
94
+ return `${mainProp}{${idProp}${nestedProp}}`;
95
+ };
96
+ const buildShapesConfig = (schemas, entityGroups, parent) => {
97
+ if (!schemas || !entityGroups) return [];
98
+ const {
99
+ itemId,
100
+ itemEntity
101
+ } = parent;
102
+ const shapeGroups = [];
103
+ entityGroups.forEach((entityGroup, i) => {
104
+ const {
105
+ entity,
106
+ shapes,
107
+ dataSummaries = []
108
+ } = entityGroup;
109
+ const parentId = entity === itemEntity && itemId;
110
+ if (!entity) return null;
111
+ const entityData = schemas[entity] || {};
112
+ shapes.filter(Boolean).forEach((shape, shapeIndex) => {
113
+ const shapeKey = `shape${i}${shapeIndex}`;
114
+ const shapeValues = buiildShapeProps(shape, shapeKey, dataSummaries, parentId, entityData, entityGroup);
115
+ shapeGroups.push(_objectSpread(_objectSpread({}, shapeValues), {}, {
116
+ shapeOptions: shape,
117
+ entityOptions: entityGroup
118
+ }));
119
+ });
120
+ });
121
+ return shapeGroups;
122
+ };
123
+ export default buildShapesConfig;
124
+ //# sourceMappingURL=build-shapes-configs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-shapes-configs.js","names":["flatten","IMAGE_ID","URL","ID","getPropValues","properties","reduce","acc","property","includes","relationName","relationProp","split","trim","getUpdatedPropsQuery","propsQuery","entityData","dynamicProperties","url","Object","keys","filter","prop","hasImage","length","updatedPropsQuery","buildFilterQueryString","filterKey","filterValue","filterKeyword","bool","should","match","buildFilters","filters","filterQueryProps","map","buiildShapeProps","shape","shapeKey","dataSummaries","parentId","entityGroup","displayItems","filterBy","latProp","lonProp","entity","actions","relations","action","getAllPublished","getAll","dataSummaryProps","propsToDisplay","propsToDisplayValues","propertiesToDisplay","propsToDisplayString","ids","push","filtersObject","formatProp","mainProp","nestedProp","idProp","find","localField","buildShapesConfig","schemas","entityGroups","parent","itemId","itemEntity","shapeGroups","forEach","i","shapes","Boolean","shapeIndex","shapeValues","_objectSpread","shapeOptions","entityOptions"],"sources":["../../../src/GoogleMaps/helpers/build-shapes-configs.js"],"sourcesContent":["import flatten from 'lodash.flatten';\nimport { IMAGE_ID, URL, ID } from '../../constants';\n\nconst getPropValues = properties =>\n properties\n .reduce((acc, property) => {\n if (property.includes('.')) {\n const [relationName, relationProp] = property.split('.');\n return `${acc} ${relationName} { ${relationProp} }`;\n }\n return `${acc} ${property}`;\n }, '')\n .trim();\n\nconst getUpdatedPropsQuery = (propsQuery, entityData) => {\n const { properties = {}, dynamicProperties = {} } = entityData;\n\n const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);\n const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;\n\n let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;\n updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;\n\n return updatedPropsQuery;\n};\n\nconst buildFilterQueryString = filter => {\n const [filterKey, filterValue] = filter.split('/');\n const filterKeyword = `${filterKey}.keyword`;\n return { bool: { should: [{ match: { [filterKeyword]: filterValue } }] } };\n};\n\nconst buildFilters = filters => {\n if (!filters || !filters.length) return null;\n const filterQueryProps = filters.map(buildFilterQueryString);\n return { bool: { should: filterQueryProps } };\n};\n\nconst buiildShapeProps = (shape, shapeKey, dataSummaries, parentId, entityData, entityGroup) => {\n const { displayItems = [], filterBy } = shape;\n const { latProp, lonProp, entity } = entityGroup;\n const { actions, relations } = entityData;\n const action = actions ? actions.getAllPublished || actions.getAll : '';\n\n const dataSummaryProps = dataSummaries\n .reduce((acc, { propsToDisplay }) => {\n const propsToDisplayValues = flatten(\n propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay)\n );\n const propsToDisplayString = getPropValues(propsToDisplayValues);\n\n return `${acc} ${propsToDisplayString}`;\n }, '')\n .trim();\n const ids = [];\n displayItems.length ? ids.push(displayItems[0]) : ids.push(parentId);\n\n const filtersObject = buildFilters(filterBy);\n let propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';\n propsQuery = getUpdatedPropsQuery(propsQuery, entityData);\n if (latProp && lonProp) {\n propsQuery = `${propsQuery} ${formatProp(latProp, relations)} ${formatProp(\n lonProp,\n relations\n )}`;\n }\n if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;\n\n return {\n shapeKey,\n entity,\n propsQuery,\n ids,\n action,\n filtersObject\n };\n};\n\nconst formatProp = (prop, relations = []) => {\n if (!prop.includes('.')) return prop;\n\n const [mainProp, nestedProp] = prop.split('.');\n const idProp = relations.find(({ localField }) => localField === mainProp) ? 'id ' : '';\n return `${mainProp}{${idProp}${nestedProp}}`;\n};\n\nconst buildShapesConfig = (schemas, entityGroups, parent) => {\n if (!schemas || !entityGroups) return [];\n const { itemId, itemEntity } = parent;\n const shapeGroups = [];\n entityGroups.forEach((entityGroup, i) => {\n const { entity, shapes, dataSummaries = [] } = entityGroup;\n const parentId = entity === itemEntity && itemId;\n if (!entity) return null;\n const entityData = schemas[entity] || {};\n\n shapes.filter(Boolean).forEach((shape, shapeIndex) => {\n const shapeKey = `shape${i}${shapeIndex}`;\n const shapeValues = buiildShapeProps(\n shape,\n shapeKey,\n dataSummaries,\n parentId,\n entityData,\n entityGroup\n );\n shapeGroups.push({ ...shapeValues, shapeOptions: shape, entityOptions: entityGroup });\n });\n });\n\n return shapeGroups;\n};\n\nexport default buildShapesConfig;\n"],"mappings":";;;AAAA,OAAOA,OAAO,MAAM,gBAAgB;AACpC,SAASC,QAAQ,EAAEC,GAAG,EAAEC,EAAE,QAAQ,iBAAiB;AAEnD,MAAMC,aAAa,GAAGC,UAAU,IAC9BA,UAAU,CACPC,MAAM,CAAC,CAACC,GAAG,EAAEC,QAAQ,KAAK;EACzB,IAAIA,QAAQ,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC1B,MAAM,CAACC,YAAY,EAAEC,YAAY,CAAC,GAAGH,QAAQ,CAACI,KAAK,CAAC,GAAG,CAAC;IACxD,OAAO,GAAGL,GAAG,IAAIG,YAAY,MAAMC,YAAY,IAAI;EACrD;EACA,OAAO,GAAG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MAAE6B,MAAM;MAAEpC,aAAa,GAAG;IAAG,CAAC,GAAGE,WAAW;IAC1D,MAAMD,QAAQ,GAAGM,MAAM,KAAKyB,UAAU,IAAID,MAAM;IAChD,IAAI,CAACxB,MAAM,EAAE,OAAO,IAAI;IACxB,MAAM/B,UAAU,GAAGoD,OAAO,CAACrB,MAAM,CAAC,IAAI,CAAC,CAAC;IAExC6B,MAAM,CAACvD,MAAM,CAACwD,OAAO,CAAC,CAACH,OAAO,CAAC,CAACpC,KAAK,EAAEwC,UAAU,KAAK;MACpD,MAAMvC,QAAQ,GAAG,QAAQoC,CAAC,GAAGG,UAAU,EAAE;MACzC,MAAMC,WAAW,GAAG1C,gBAAgB,CAClCC,KAAK,EACLC,QAAQ,EACRC,aAAa,EACbC,QAAQ,EACRzB,UAAU,EACV0B,WACF,CAAC;MACD+B,WAAW,CAACd,IAAI,CAAAqB,aAAA,CAAAA,aAAA,KAAMD,WAAW;QAAEE,YAAY,EAAE3C,KAAK;QAAE4C,aAAa,EAAExC;MAAW,EAAE,CAAC;IACvF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO+B,WAAW;AACpB,CAAC;AAED,eAAeN,iBAAiB","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ import isNumber from 'lodash.isnumber';
2
+ const getCenterCoordinates = (mapShapes, otherProps) => {
3
+ const centerCoordinates = [];
4
+ const {
5
+ centerLatitude,
6
+ centerLongitude
7
+ } = otherProps;
8
+ const useDefaultCenter = centerLatitude !== 0 && centerLongitude !== 0 && isNumber(centerLatitude) && isNumber(centerLongitude);
9
+ if (useDefaultCenter) return [{
10
+ latitude: centerLatitude,
11
+ longitude: centerLongitude
12
+ }];
13
+ const useAsCenterShapes = mapShapes.filter(({
14
+ useAsCenter
15
+ }) => useAsCenter);
16
+ const shapesForCenter = useAsCenterShapes.length ? useAsCenterShapes : mapShapes;
17
+ shapesForCenter.forEach(({
18
+ latitude,
19
+ longitude
20
+ }) => {
21
+ if (isNumber(latitude) && isNumber(longitude)) centerCoordinates.push({
22
+ latitude,
23
+ longitude
24
+ });
25
+ });
26
+ return centerCoordinates;
27
+ };
28
+ export default getCenterCoordinates;
29
+ //# sourceMappingURL=get-center-coordinates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-center-coordinates.js","names":["isNumber","getCenterCoordinates","mapShapes","otherProps","centerCoordinates","centerLatitude","centerLongitude","useDefaultCenter","latitude","longitude","useAsCenterShapes","filter","useAsCenter","shapesForCenter","length","forEach","push"],"sources":["../../../src/GoogleMaps/helpers/get-center-coordinates.js"],"sourcesContent":["import isNumber from 'lodash.isnumber';\n\nconst getCenterCoordinates = (mapShapes, otherProps) => {\n const centerCoordinates = [];\n\n const { centerLatitude, centerLongitude } = otherProps;\n const useDefaultCenter =\n centerLatitude !== 0 &&\n centerLongitude !== 0 &&\n isNumber(centerLatitude) &&\n isNumber(centerLongitude);\n\n if (useDefaultCenter) return [{ latitude: centerLatitude, longitude: centerLongitude }];\n\n const useAsCenterShapes = mapShapes.filter(({ useAsCenter }) => useAsCenter);\n const shapesForCenter = useAsCenterShapes.length ? useAsCenterShapes : mapShapes;\n shapesForCenter.forEach(({ latitude, longitude }) => {\n if (isNumber(latitude) && isNumber(longitude)) centerCoordinates.push({ latitude, longitude });\n });\n\n return centerCoordinates;\n};\n\nexport default getCenterCoordinates;\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,iBAAiB;AAEtC,MAAMC,oBAAoB,GAAGA,CAACC,SAAS,EAAEC,UAAU,KAAK;EACtD,MAAMC,iBAAiB,GAAG,EAAE;EAE5B,MAAM;IAAEC,cAAc;IAAEC;EAAgB,CAAC,GAAGH,UAAU;EACtD,MAAMI,gBAAgB,GACpBF,cAAc,KAAK,CAAC,IACpBC,eAAe,KAAK,CAAC,IACrBN,QAAQ,CAACK,cAAc,CAAC,IACxBL,QAAQ,CAACM,eAAe,CAAC;EAE3B,IAAIC,gBAAgB,EAAE,OAAO,CAAC;IAAEC,QAAQ,EAAEH,cAAc;IAAEI,SAAS,EAAEH;EAAgB,CAAC,CAAC;EAEvF,MAAMI,iBAAiB,GAAGR,SAAS,CAACS,MAAM,CAAC,CAAC;IAAEC;EAAY,CAAC,KAAKA,WAAW,CAAC;EAC5E,MAAMC,eAAe,GAAGH,iBAAiB,CAACI,MAAM,GAAGJ,iBAAiB,GAAGR,SAAS;EAChFW,eAAe,CAACE,OAAO,CAAC,CAAC;IAAEP,QAAQ;IAAEC;EAAU,CAAC,KAAK;IACnD,IAAIT,QAAQ,CAACQ,QAAQ,CAAC,IAAIR,QAAQ,CAACS,SAAS,CAAC,EAAEL,iBAAiB,CAACY,IAAI,CAAC;MAAER,QAAQ;MAAEC;IAAU,CAAC,CAAC;EAChG,CAAC,CAAC;EAEF,OAAOL,iBAAiB;AAC1B,CAAC;AAED,eAAeH,oBAAoB","ignoreList":[]}