google-maps-react-markers 1.4.2 → 2.0.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/LICENCE.md +1 -1
- package/README.md +15 -1
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +171 -0
- package/dist/index.d.ts +171 -2
- package/dist/index.js +7 -574
- package/dist/index.js.map +1 -1
- package/package.json +90 -46
- package/dist/google-map.d.ts +0 -3
- package/dist/google-map.d.ts.map +0 -1
- package/dist/hooks/useGoogleMaps.d.ts +0 -9
- package/dist/hooks/useGoogleMaps.d.ts.map +0 -1
- package/dist/hooks/useMemoCompare.d.ts +0 -10
- package/dist/hooks/useMemoCompare.d.ts.map +0 -1
- package/dist/hooks/useScript.d.ts +0 -10
- package/dist/hooks/useScript.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.modern.js +0 -573
- package/dist/index.modern.js.map +0 -1
- package/dist/map/map.d.ts +0 -32
- package/dist/map/map.d.ts.map +0 -1
- package/dist/map/markers.d.ts +0 -14
- package/dist/map/markers.d.ts.map +0 -1
- package/dist/map/overlay-view.d.ts +0 -29
- package/dist/map/overlay-view.d.ts.map +0 -1
- package/dist/map/overlay.d.ts +0 -24
- package/dist/map/overlay.d.ts.map +0 -1
- package/dist/utils/utils.d.ts +0 -2
- package/dist/utils/utils.d.ts.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/hooks/useScript.js","../src/hooks/useGoogleMaps.js","../src/utils/utils.js","../src/hooks/useMemoCompare.js","../src/map/overlay.js","../src/map/overlay-view.js","../src/map/markers.js","../src/map/map.js","../src/google-map.js"],"sourcesContent":["/* eslint-disable no-unused-expressions */\nimport { useEffect, useState } from 'react'\n\n/**\n * @description Hook to load external script.\n * @param {Object} script - Script to load.\n * @param {string} script.src - Script source.\n * @param {Object} [script.attributes] - Attributes to add to the script tag.\n * @param {Object} [script.callbacks] - Callbacks executed on completion.\n * @param {Function} [script.callbacks.onLoadCallback] - Callback executed on completion in case of success.\n * @param {Function} [script.callbacks.onErrorCallback] - Callbacks executed on completion in case of error.\n * @param {string} [script.elementIdToAppend] - HTML element id to append the script to. Default is HTML HEAD.\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n *\n * @example\n * const status = useScript({\n * \t\tsrc: \"https://script-to-load.js\",\n * \t\tattributes: { id: \"scriptId\", class: \"script-class\" },\n * \t\tcallbacks: {\n * \t\t\tonLoadCallback: onLoadFunc,\n * \t\t\tonErrorCallback: onErrorFunc,\n * \t\t},\n * \t\telementIdToAppend: \"script-container\"\n * })\n */\n\nexport const useScript = (\n\tscript = {\n\t\tsrc: '',\n\t\tattributes: {},\n\t\tcallbacks: { onLoadCallback: null, onErrorCallback: null },\n\t\telementIdToAppend: null,\n\t},\n\tforcedStatus = undefined,\n) => {\n\t// Keep track of script status (\"idle\", \"loading\", \"ready\", \"error\")\n\tconst [status, setStatus] = useState(script.src ? 'loading' : 'idle')\n\n\tuseEffect(\n\t\t() => {\n\t\t\tif (forcedStatus) {\n\t\t\t\tsetStatus(forcedStatus)\n\t\t\t\treturn () => {\n\t\t\t\t\t// do nothing\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Allow falsy src value if waiting on other data needed for\n\t\t\t// constructing the script URL passed to this hook.\n\t\t\tif (!script.src) {\n\t\t\t\tsetStatus('idle')\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Fetch existing script element by src\n\t\t\t// It may have been added by another instance of this hook\n\t\t\tlet scriptToAdd = document.querySelector(`script[src=\"${script.src}\"]`)\n\t\t\tif (!scriptToAdd) {\n\t\t\t\t// Create script\n\t\t\t\tscriptToAdd = document.createElement('script')\n\t\t\t\tscriptToAdd.src = script.src\n\t\t\t\tscriptToAdd.async = true\n\t\t\t\tscriptToAdd.setAttribute('data-status', 'loading')\n\t\t\t\t// Add other script attributes, if they exist\n\t\t\t\tscript.attributes && Object.entries(script.attributes).length > 0\n\t\t\t\t\t? Object.entries(script.attributes).map(([key, value]) => scriptToAdd.setAttribute(key, value))\n\t\t\t\t\t: null\n\t\t\t\t// Add script to document body\n\t\t\t\tif (script.elementIdToAppend && document.getElementById(script.elementIdToAppend)) {\n\t\t\t\t\tdocument.getElementById(script.elementIdToAppend).appendChild(scriptToAdd)\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.appendChild(scriptToAdd)\n\t\t\t\t}\n\t\t\t\t// Store status in attribute on script\n\t\t\t\t// This can be read by other instances of this hook\n\t\t\t\tconst setAttributeFromEvent = (event) => {\n\t\t\t\t\tscriptToAdd.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error')\n\t\t\t\t}\n\t\t\t\tscriptToAdd.addEventListener('load', setAttributeFromEvent)\n\t\t\t\tscriptToAdd.addEventListener('error', setAttributeFromEvent)\n\t\t\t} else {\n\t\t\t\t// Grab existing script status from attribute and set to state.\n\t\t\t\tconst currentScriptStatus = scriptToAdd.getAttribute('data-status')\n\t\t\t\tswitch (currentScriptStatus) {\n\t\t\t\t\tcase 'load':\n\t\t\t\t\tcase 'ready':\n\t\t\t\t\t\tscript.callbacks?.onLoadCallback ? script.callbacks.onLoadCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\tscript.callbacks?.onErrorCallback ? script.callbacks.onErrorCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// loading: do nothing\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tsetStatus(currentScriptStatus)\n\t\t\t}\n\t\t\t// Script event handler to update status in state\n\t\t\t// Note: Even if the script already exists we still need to add\n\t\t\t// event handlers to update the state for this hook instance.\n\t\t\tconst setStateFromEvent = (event) => {\n\t\t\t\tevent.type === 'load'\n\t\t\t\t\t? script.callbacks?.onLoadCallback\n\t\t\t\t\t\t? script.callbacks.onLoadCallback()\n\t\t\t\t\t\t: null\n\t\t\t\t\t: script.callbacks?.onErrorCallback\n\t\t\t\t\t? script.callbacks.onErrorCallback()\n\t\t\t\t\t: null\n\t\t\t\tsetStatus(event.type === 'load' ? 'ready' : 'error')\n\t\t\t}\n\t\t\t// Add event listeners\n\t\t\tscriptToAdd.addEventListener('load', setStateFromEvent)\n\t\t\tscriptToAdd.addEventListener('error', setStateFromEvent)\n\t\t\t// Remove event listeners on cleanup\n\t\t\treturn () => {\n\t\t\t\tif (scriptToAdd) {\n\t\t\t\t\tscriptToAdd.removeEventListener('load', setStateFromEvent)\n\t\t\t\t\tscriptToAdd.removeEventListener('error', setStateFromEvent)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Re-run useEffect if script changes\n\t\t[script, forcedStatus, status],\n\t)\n\n\treturn status\n}\n","import { useScript } from './useScript'\n\n/**\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n */\nexport const useGoogleMaps = ({\n\tapiKey,\n\tlibraries = [],\n\tloadScriptExternally = false,\n\tstatus = 'idle',\n\texternalApiParams,\n\tcallback,\n}) => {\n\t// eslint-disable-next-line no-undef\n\tif (typeof window !== 'undefined') window.googleMapsCallback = callback\n\tconst apiParams = new URLSearchParams(externalApiParams)?.toString()\n\tconst script = apiKey\n\t\t? {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=googleMapsCallback&libraries=${libraries?.join(\n\t\t\t\t\t',',\n\t\t\t\t)}${apiParams ? '&' + apiParams : ''}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\t\t: {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${libraries?.join(',')}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\n\treturn useScript(script, loadScriptExternally ? status : undefined)\n}\n","export const isArraysEqualEps = (arrayA, arrayB, eps) => {\n\tif (arrayA && arrayB) {\n\t\tfor (let i = 0; i !== arrayA.length; ++i) {\n\t\t\tif (Math.abs(arrayA[i] - arrayB[i]) > eps) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n","import { useEffect, useRef } from 'react'\n\n/**\n * A hook that compares the previous and current values of a reference.\n * @param {any} value - the current value of the reference\n * @param {function} compare - a function that compares the previous and current values\n * @returns {any} the previous value of the reference\n * @ref https://usehooks.com/useMemoCompare/\n */\nconst useMemoCompare = (next, compare) => {\n\t// Ref for storing previous value\n\tconst previousRef = useRef()\n\tconst previous = previousRef.current\n\t// Pass previous and next value to compare function\n\t// to determine whether to consider them equal.\n\tconst isEqual = compare(previous, next)\n\t// If not equal update previousRef to next value.\n\t// We only update if not equal so that this hook continues to return\n\t// the same old value if compare keeps returning true.\n\tuseEffect(() => {\n\t\tif (!isEqual) {\n\t\t\tpreviousRef.current = next\n\t\t}\n\t})\n\t// Finally, if equal then return the previous value\n\treturn isEqual ? previous : next\n}\n\nexport default useMemoCompare\n","import { bool, element, func, number, object, shape, string } from 'prop-types'\n\n// return lat, lng from LatLngLiteral\nconst getLatLng = (LatLng) => {\n\ttry {\n\t\tconst latLng = { lat: LatLng.lat(), lng: LatLng.lng() }\n\t\treturn latLng\n\t} catch (e) {\n\t\treturn LatLng\n\t}\n}\n\n/**\n * @param {HTMLElement} container - The HTML container element for the overlay.\n * @param {google.maps.MapPanes} pane - The HTML container element for the overlay.\n * @param {google.maps.LatLng | google.maps.LatLngLiteral} position - The geographical location of the overlay.\n * @param {google.maps} maps - The Google Maps API.\n * @param {object} drag - The drag configuration of the overlay.\n * @param {boolean} drag.draggable - If true, the marker can be dragged. Default value is false.\n * @param {function} drag.onDragStart - This event is fired when the user starts dragging the marker.\n * @param {function} drag.onDrag - This event is repeatedly fired while the user drags the marker.\n * @param {function} drag.onDragEnd - This event is fired when the user stops dragging the marker.\n * @returns {void}\n */\nconst createOverlay = ({ container, pane, position, maps, drag }) => {\n\tclass Overlay extends maps.OverlayView {\n\t\tconstructor(container, pane, position) {\n\t\t\tsuper()\n\t\t\tthis.container = container\n\t\t\tthis.pane = pane\n\t\t\tthis.position = position\n\t\t}\n\n\t\t/**\n\t\t * onAdd is called when the map's panes are ready and the overlay has been\n\t\t * added to the map.\n\t\t */\n\t\tonAdd = () => {\n\t\t\tlet that = this\n\t\t\t// manage draggable\n\t\t\tif (drag?.draggable) {\n\t\t\t\tmaps.event.addDomListener(this.get('map').getDiv(), 'mouseleave', () => {\n\t\t\t\t\tmaps.event.trigger(container, 'mouseup')\n\t\t\t\t})\n\t\t\t\tmaps.event.addDomListener(this.container, 'mousedown', (e) => {\n\t\t\t\t\tthis.container.style.cursor = 'grabbing'\n\t\t\t\t\tthat.map.set('draggable', false)\n\t\t\t\t\tthat.set('origin', e)\n\n\t\t\t\t\tdrag.onDragStart(e, { latLng: getLatLng(this.position) })\n\n\t\t\t\t\tthat.moveHandler = maps.event.addDomListener(this.get('map').getDiv(), 'mousemove', (e) => {\n\t\t\t\t\t\tlet origin = that.get('origin'),\n\t\t\t\t\t\t\tleft = origin.clientX - e.clientX,\n\t\t\t\t\t\t\ttop = origin.clientY - e.clientY,\n\t\t\t\t\t\t\tpos = that.getProjection().fromLatLngToDivPixel(that.position),\n\t\t\t\t\t\t\tlatLng = that.getProjection().fromDivPixelToLatLng(new maps.Point(pos.x - left, pos.y - top))\n\t\t\t\t\t\tthat.set('position', latLng)\n\t\t\t\t\t\tthat.set('origin', e)\n\t\t\t\t\t\tthat.draw()\n\t\t\t\t\t\tdrag.onDrag(e, { latLng: getLatLng(latLng) })\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tmaps.event.addDomListener(container, 'mouseup', (e) => {\n\t\t\t\t\tthat.map.set('draggable', true)\n\t\t\t\t\tthis.container.style.cursor = 'default'\n\t\t\t\t\tmaps.event.removeListener(that.moveHandler)\n\t\t\t\t\tdrag.onDragEnd(e, { latLng: getLatLng(that.position) })\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Add the element to the pane.\n\t\t\tconst pane = this.getPanes()[this.pane]\n\t\t\tpane?.classList.add('google-map-markers-overlay')\n\t\t\tpane?.appendChild(this.container)\n\t\t}\n\n\t\tdraw = () => {\n\t\t\tconst projection = this.getProjection()\n\t\t\t// Computes the pixel coordinates of the given geographical location in the DOM element that holds the draggable map.\n\t\t\tconst point = projection.fromLatLngToDivPixel(this.position)\n\t\t\tif (point === null) return\n\t\t\tthis.container.style.transform = `translate(${point.x}px, ${point.y}px)`\n\t\t\tthis.container.style.width = '0px'\n\t\t\tthis.container.style.height = '0px'\n\t\t}\n\n\t\t/**\n\t\t * The onRemove() method will be called automatically from the API if\n\t\t * we ever set the overlay's map property to 'null'.\n\t\t */\n\t\tonRemove = () => {\n\t\t\tif (this.container.parentNode !== null) {\n\t\t\t\t// remove DOM listeners\n\t\t\t\tmaps.event.clearInstanceListeners(this.container)\n\t\t\t\tthis.container.parentNode.removeChild(this.container)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn new Overlay(container, pane, position)\n}\n\ncreateOverlay.propTypes = {\n\t/**\n\t * The HTML container element for the overlay.\n\t */\n\tcontainer: element.isRequired,\n\t/**\n\t * The HTML container element for the overlay.\n\t * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n\t * @default 'floatPane'\n\t * @type {google.maps.MapPanes}\n\t * @required\n\t */\n\tpane: string.isRequired,\n\t/**\n\t * The geographical location of the overlay.\n\t * @type {google.maps.LatLng | google.maps.LatLngLiteral}\n\t * @required\n\t * @ref [LatLng](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLng)\n\t */\n\tposition: shape({\n\t\tlat: number.isRequired,\n\t\tlng: number.isRequired,\n\t}).isRequired,\n\t/**\n\t * The Google Maps API.\n\t */\n\tmaps: object.isRequired,\n\t/**\n\t * The draggable options of the overlay.\n\t * @type {object}\n\t * @default { draggable: false, onDragStart: noop, onDrag: noop, onDragEnd: noop }\n\t */\n\tdrag: shape({\n\t\tdraggable: bool,\n\t\tonDragStart: func,\n\t\tonDrag: func,\n\t\tonDragEnd: func,\n\t}),\n}\n\nexport default createOverlay\n","import { bool, func, node, number, object, shape, string } from 'prop-types'\nimport { useEffect, useMemo } from 'react'\nimport { createPortal } from 'react-dom'\nimport useMemoCompare from '../hooks/useMemoCompare'\nimport createOverlay from './overlay'\n\n/**\n * @param {google.maps.MapPanes} pane - The pane on which to display the overlay. This is the Pane name, not the Pane itself. Defaults to floatPane.\n * @param {google.maps.LatLng | google.maps.LatLngLiteral} position - The geographical location of the overlay.\n * @param {google.maps.Map} map - The map on which to display the overlay.\n * @param {google.maps} maps - The Google Maps API.\n * @param {number} zIndex - The z-index of the overlay.\n * @param {ReactNode} children - The children of the OverlayView - the Marker component.\n * @param {object} drag - The drag configuration of the overlay.\n * @param {boolean} drag.draggable - If true, the marker can be dragged. Default value is false.\n * @param {function} drag.onDragStart - This event is fired when the user starts dragging the marker.\n * @param {function} drag.onDrag - This event is repeatedly fired while the user drags the marker.\n * @param {function} drag.onDragEnd - This event is fired when the user stops dragging the marker.\n * @returns {void}\n * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n */\nconst OverlayView = ({ pane = 'floatPane', position, map, maps, zIndex = 0, children, drag }) => {\n\tconst container = useMemo(() => {\n\t\t// eslint-disable-next-line no-undef\n\t\tconst div = document.createElement('div')\n\t\tdiv.style.position = 'absolute'\n\t\treturn div\n\t}, [])\n\n\tconst overlay = useMemo(() => {\n\t\treturn createOverlay({ container, pane, position, maps, drag })\n\t}, [container, drag, maps, pane, position])\n\n\t// Because React does not do deep comparisons, a custom hook is used.\n\t// This fixes the issue where the overlay is not updated when the position changes.\n\tconst childrenProps = useMemoCompare(children?.props, (prev, next) => {\n\t\treturn prev && prev.lat === next.lat && prev.lng === next.lng\n\t})\n\n\tuseEffect(() => {\n\t\tif (!overlay.map) {\n\t\t\toverlay?.setMap(map)\n\t\t\treturn () => {\n\t\t\t\toverlay?.setMap(null)\n\t\t\t}\n\t\t}\n\t\t// overlay depends on map, so we don't need to add it to the dependency array\n\t\t// otherwise, it will re-render the overlay every time the map changes\n\t\t//? added childrenProps to the dependency array to re-render the overlay when the children props change.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [map, childrenProps])\n\n\t// to move the container to the foreground and background\n\tuseEffect(() => {\n\t\tcontainer.style.zIndex = `${zIndex}`\n\t}, [zIndex, container])\n\n\treturn createPortal(children, container)\n}\n\nOverlayView.propTypes = {\n\t/**\n\t * The HTML container element for the overlay.\n\t * @ref [MapPanes](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes)\n\t * @default 'floatPane'\n\t * @type {google.maps.MapPanes}\n\t */\n\tpane: string,\n\t/**\n\t * The geographical location of the overlay.\n\t * @type {google.maps.LatLng | google.maps.LatLngLiteral}\n\t * @required\n\t * @ref [LatLng](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLng)\n\t */\n\tposition: shape({\n\t\tlat: number.isRequired,\n\t\tlng: number.isRequired,\n\t}).isRequired,\n\t/**\n\t * The map on which to display the overlay.\n\t * @type {google.maps.Map}\n\t * @required\n\t * @ref [Map](https://developers.google.com/maps/documentation/javascript/reference/map#Map)\n\t */\n\tmap: object.isRequired,\n\t/**\n\t * The Google Maps API.\n\t * @type {object}\n\t * @required\n\t * @ref [Google Maps API](https://developers.google.com/maps/documentation/javascript/reference)\n\t */\n\tmaps: object.isRequired,\n\t/**\n\t * The z-index of the overlay.\n\t * @type {number}\n\t * @default 0\n\t */\n\tzIndex: number,\n\t/**\n\t * The children of the OverlayView.\n\t * @type {ReactNode}\n\t * @required\n\t * @ref [ReactNode](https://reactjs.org/docs/react-api.html#reactnode)\n\t */\n\tchildren: node.isRequired,\n\t/**\n\t * The drag configuration of the overlay.\n\t * @type {object}\n\t * @default { draggable: false, onDragStart: noop, onDrag: noop, onDragEnd: noop }\n\t */\n\tdrag: shape({\n\t\tdraggable: bool,\n\t\tonDragStart: func,\n\t\tonDrag: func,\n\t\tonDragEnd: func,\n\t}),\n}\n\nexport default OverlayView\n","import { node, object } from 'prop-types'\nimport React, { Children, cloneElement, isValidElement, useMemo } from 'react'\nimport OverlayView from './overlay-view'\n\nconst noop = () => {}\n\nconst MapMarkers = ({ children, map, maps }) => {\n\tconst markers = useMemo(() => {\n\t\tif (!map || !maps) return []\n\n\t\treturn Children.map(children, (child) => {\n\t\t\tif (isValidElement(child)) {\n\t\t\t\tconst latLng = { lat: child.props.lat, lng: child.props.lng }\n\t\t\t\tconst { zIndex, draggable = false, onDragStart = noop, onDrag = noop, onDragEnd = noop } = child.props || {}\n\n\t\t\t\t// clone child without draggable props\n\t\t\t\tchild = cloneElement(child, {\n\t\t\t\t\t...child.props,\n\t\t\t\t\tdraggable: undefined,\n\t\t\t\t\tonDragStart: undefined,\n\t\t\t\t\tonDrag: undefined,\n\t\t\t\t\tonDragEnd: undefined,\n\t\t\t\t})\n\n\t\t\t\treturn (\n\t\t\t\t\t<OverlayView\n\t\t\t\t\t\tposition={latLng}\n\t\t\t\t\t\tmap={map}\n\t\t\t\t\t\tmaps={maps}\n\t\t\t\t\t\tzIndex={zIndex}\n\t\t\t\t\t\tdrag={{\n\t\t\t\t\t\t\tdraggable,\n\t\t\t\t\t\t\tonDragStart,\n\t\t\t\t\t\t\tonDrag,\n\t\t\t\t\t\t\tonDragEnd,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{child}\n\t\t\t\t\t</OverlayView>\n\t\t\t\t)\n\t\t\t}\n\t\t})\n\t}, [children, map, maps])\n\n\treturn <div>{markers}</div>\n}\n\nMapMarkers.propTypes = {\n\t/**\n\t * The Markers on the Map.\n\t * @type {ReactNode}\n\t * @required\n\t */\n\tchildren: node.isRequired,\n\t/**\n\t * The Google Maps instance.\n\t * @type {object}\n\t * @required\n\t */\n\tmap: object,\n\t/**\n\t * The Google Maps API.\n\t * @type {object}\n\t * @required\n\t */\n\tmaps: object.isRequired,\n}\n\nexport default MapMarkers\n","import { arrayOf, func, node, number, object, oneOfType, shape, string } from 'prop-types'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { isArraysEqualEps } from '../utils/utils'\nimport MapMarkers from './markers'\n\nconst EPS = 0.00001\n\nconst MapComponent = ({\n\tchildren = null,\n\tstyle = {\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tmargin: 0,\n\t\tpadding: 0,\n\t\tposition: 'absolute',\n\t},\n\tdefaultCenter,\n\tdefaultZoom,\n\tonGoogleApiLoaded = () => {},\n\tonChange = () => {},\n\toptions = {},\n\tevents = [],\n}) => {\n\tconst mapRef = useRef(null)\n\tconst prevBoundsRef = useRef(null)\n\tconst [map, setMap] = useState(null)\n\tconst [maps, setMaps] = useState(null)\n\tconst [googleApiCalled, setGoogleApiCalled] = useState(false)\n\n\tconst onIdle = useCallback(() => {\n\t\ttry {\n\t\t\tconst zoom = map.getZoom()\n\t\t\tconst bounds = map.getBounds()\n\t\t\tconst centerLatLng = map.getCenter()\n\n\t\t\tconst ne = bounds.getNorthEast()\n\t\t\tconst sw = bounds.getSouthWest()\n\t\t\tconst boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]\n\n\t\t\tif (!isArraysEqualEps(boundsArray, prevBoundsRef.current, EPS)) {\n\t\t\t\tif (onChange) {\n\t\t\t\t\tonChange({\n\t\t\t\t\t\tzoom,\n\t\t\t\t\t\tcenter: [centerLatLng.lng(), centerLatLng.lat()],\n\t\t\t\t\t\tbounds,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tprevBoundsRef.current = boundsArray\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t}\n\t}, [map, onChange])\n\n\tuseEffect(() => {\n\t\tif (mapRef.current && !map) {\n\t\t\tsetMap(\n\t\t\t\tnew window.google.maps.Map(mapRef.current, {\n\t\t\t\t\tcenter: defaultCenter,\n\t\t\t\t\tzoom: defaultZoom,\n\t\t\t\t\t...options,\n\t\t\t\t}),\n\t\t\t)\n\t\t\tsetMaps(window.google.maps)\n\t\t}\n\t}, [defaultCenter, defaultZoom, map, mapRef, options])\n\n\tuseEffect(() => {\n\t\tif (map) {\n\t\t\tif (!googleApiCalled) {\n\t\t\t\tonGoogleApiLoaded({ map, maps, ref: mapRef.current })\n\t\t\t\tsetGoogleApiCalled(true)\n\t\t\t}\n\n\t\t\twindow.google.maps.event.clearListeners(map, 'idle')\n\t\t\t// Idle event is fired when the map becomes idle after panning or zooming.\n\t\t\twindow.google.maps.event.addListener(map, 'idle', onIdle)\n\t\t}\n\t}, [googleApiCalled, map, maps, onChange, onGoogleApiLoaded, onIdle])\n\n\tuseEffect(() => {\n\t\t// clear listeners on unmount\n\t\treturn () => {\n\t\t\tif (map) {\n\t\t\t\twindow.google.maps.event.clearListeners(map, 'idle')\n\t\t\t}\n\t\t}\n\t}, [map])\n\n\treturn (\n\t\t<React.Fragment>\n\t\t\t<div\n\t\t\t\tref={mapRef}\n\t\t\t\tstyle={style}\n\t\t\t\tclassName=\"google-map\"\n\t\t\t\t// spread the events as props\n\t\t\t\t{...events?.reduce((acc, { name, handler } = {}) => {\n\t\t\t\t\tacc[name] = handler\n\t\t\t\t\treturn acc\n\t\t\t\t}, {})}\n\t\t\t/>\n\t\t\t{children && map && maps && (\n\t\t\t\t<MapMarkers map={map} maps={maps}>\n\t\t\t\t\t{children}\n\t\t\t\t</MapMarkers>\n\t\t\t)}\n\t\t</React.Fragment>\n\t)\n}\n\nMapComponent.propTypes = {\n\t/**\n\t * The Markers on the Map.\n\t */\n\tchildren: oneOfType([arrayOf(node), node]),\n\tstyle: object,\n\tdefaultCenter: object.isRequired,\n\tdefaultZoom: number.isRequired,\n\tonGoogleApiLoaded: func,\n\tonChange: func,\n\toptions: object,\n\t/**\n\t * The events to pass to the Google Maps instance (`div`).\n\t * @type {Array}\n\t * @example\n\t * [\n\t * {\n\t * name: 'onClick',\n\t * handler: (event) => { ... }\n\t * }\n\t * ]\n\t */\n\tevents: arrayOf(\n\t\tshape({\n\t\t\tname: string.isRequired,\n\t\t\thandler: func.isRequired,\n\t\t}),\n\t),\n}\n\nexport default MapComponent\n","import { arrayOf, bool, func, node, number, object, oneOf, oneOfType, string } from 'prop-types'\nimport React, { forwardRef } from 'react'\nimport { useGoogleMaps } from './hooks/useGoogleMaps'\nimport MapComponent from './map/map'\n\nconst GoogleMap = forwardRef(function GoogleMap(\n\t{\n\t\tapiKey = '',\n\t\tlibraries = ['places', 'geometry'],\n\t\tchildren = null,\n\t\tloadingContent = 'Google Maps is loading',\n\t\tidleContent = 'Google Maps is on idle',\n\t\terrorContent = 'Google Maps is on error',\n\t\tmapMinHeight = 'unset',\n\t\tcontainerProps = {},\n\t\tloadScriptExternally = false,\n\t\tstatus = 'idle',\n\t\tscriptCallback = () => {},\n\t\texternalApiParams = {},\n\t\t...props\n\t},\n\tref,\n) {\n\tconst renderers = {\n\t\tready: <MapComponent {...props}>{children}</MapComponent>,\n\t\tloading: loadingContent,\n\t\tidle: idleContent,\n\t\terror: errorContent,\n\t}\n\n\tconst _status = useGoogleMaps({\n\t\tapiKey,\n\t\tlibraries,\n\t\tloadScriptExternally,\n\t\tstatus,\n\t\texternalApiParams,\n\t\tcallback: scriptCallback,\n\t})\n\n\treturn (\n\t\t<div\n\t\t\tstyle={{ height: '100%', width: '100%', overflow: 'hidden', position: 'relative', minHeight: mapMinHeight }}\n\t\t\tref={ref}\n\t\t\t{...containerProps}\n\t\t>\n\t\t\t{renderers[_status] || null}\n\t\t</div>\n\t)\n})\n\nGoogleMap.propTypes = {\n\t...MapComponent.propTypes,\n\t/**\n\t * The Markers on the Map.\n\t */\n\tchildren: oneOfType([node, arrayOf(node)]),\n\t/**\n\t * Content to be displayed while the map is loading.\n\t */\n\tloadingContent: node,\n\t/**\n\t * Content to be displayed while the map is idle.\n\t */\n\tidleContent: node,\n\t/**\n\t * Content to be displayed when there is an error loading the map.\n\t */\n\terrorContent: node,\n\t/**\n\t * The minimum height of the map.\n\t */\n\tmapMinHeight: oneOfType([number, string]),\n\t/**\n\t * Props to be passed to the container div.\n\t */\n\tcontainerProps: object,\n\t/**\n\t * Whether to load the Google Maps script externally.\n\t * If true, the status prop will be used to control the loading of the script.\n\t * If false, the script will be loaded automatically.\n\t * @default false\n\t */\n\tloadScriptExternally: bool,\n\t/**\n\t * The forced status of the Google Maps script.\n\t * @default 'idle'\n\t */\n\tstatus: oneOf(['idle', 'loading', 'ready', 'error']),\n\t/**\n\t * The callback function to pass to the Google Maps script.\n\t * @default () => {}\n\t */\n\tscriptCallback: func,\n\t/**\n\t * Prop to be passed on to google map api while loading the script such as region & language\n\t * e.g. {region: 'JP', language: 'ja'} can be used to localize map in japanese\n\t */\n\texternalApiParams: object,\n}\n\nexport default GoogleMap\n"],"names":["useScript","script","forcedStatus","src","attributes","callbacks","onLoadCallback","onErrorCallback","elementIdToAppend","undefined","_useState","useState","status","setStatus","useEffect","_script$callbacks","_script$callbacks2","scriptToAdd","document","querySelector","createElement","async","setAttribute","Object","entries","length","map","_ref","key","value","getElementById","appendChild","body","setAttributeFromEvent","event","type","addEventListener","currentScriptStatus","getAttribute","setStateFromEvent","_script$callbacks3","_script$callbacks4","removeEventListener","useGoogleMaps","_URLSearchParams","apiKey","_ref$libraries","libraries","_ref$loadScriptExtern","loadScriptExternally","_ref$status","externalApiParams","callback","window","googleMapsCallback","apiParams","URLSearchParams","toString","join","id","isArraysEqualEps","arrayA","arrayB","eps","i","Math","abs","useMemoCompare","next","compare","previousRef","useRef","previous","current","isEqual","getLatLng","LatLng","latLng","lat","lng","e","createOverlay","container","pane","position","maps","drag","Overlay","_maps$OverlayView","_inheritsLoose","_this","call","onAdd","that","_assertThisInitialized","draggable","addDomListener","get","getDiv","trigger","style","cursor","set","onDragStart","moveHandler","origin","left","clientX","top","clientY","pos","getProjection","fromLatLngToDivPixel","fromDivPixelToLatLng","Point","x","y","draw","onDrag","removeListener","onDragEnd","getPanes","classList","add","projection","point","transform","width","height","onRemove","parentNode","clearInstanceListeners","removeChild","OverlayView","propTypes","element","isRequired","string","shape","number","object","bool","func","_ref$pane","_ref$zIndex","zIndex","children","useMemo","div","overlay","childrenProps","props","prev","setMap","createPortal","node","noop","MapMarkers","markers","Children","child","isValidElement","_ref2","_ref2$draggable","_ref2$onDragStart","_ref2$onDrag","_ref2$onDragEnd","cloneElement","_extends","React","EPS","MapComponent","_ref$children","_ref$style","margin","padding","defaultCenter","defaultZoom","_ref$onGoogleApiLoade","onGoogleApiLoaded","_ref$onChange","onChange","_ref$options","options","_ref$events","events","mapRef","prevBoundsRef","_useState2","setMaps","_useState3","googleApiCalled","setGoogleApiCalled","onIdle","useCallback","zoom","getZoom","bounds","getBounds","centerLatLng","getCenter","ne","getNorthEast","sw","getSouthWest","boundsArray","center","console","error","google","Map","ref","clearListeners","addListener","Fragment","className","reduce","acc","_temp","name","handler","oneOfType","arrayOf","GoogleMap","forwardRef","_ref$apiKey","_ref$loadingContent","loadingContent","_ref$idleContent","idleContent","_ref$errorContent","errorContent","_ref$mapMinHeight","mapMinHeight","_ref$containerProps","containerProps","_ref$scriptCallback","scriptCallback","_ref$externalApiParam","_objectWithoutPropertiesLoose","_excluded","renderers","ready","loading","idle","_status","overflow","minHeight","oneOf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BO,IAAMA,SAAS,GAAG,SAAZA,SAASA,CACrBC,MAAM,EAMNC,YAAY,EACR;EAAA,IAPJD,MAAM;IAANA,MAAM,GAAG;MACRE,GAAG,EAAE,EAAE;MACPC,UAAU,EAAE,EAAE;MACdC,SAAS,EAAE;QAAEC,cAAc,EAAE,IAAI;QAAEC,eAAe,EAAE;OAAM;MAC1DC,iBAAiB,EAAE;KACnB;;EAAA,IACDN,YAAY;IAAZA,YAAY,GAAGO,SAAS;;EAGxB,IAAAC,SAAA,GAA4BC,cAAQ,CAACV,MAAM,CAACE,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC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AC,CAAC;EAIzCkG,cAAc,EAAE/F,gBAAM;EAOtB3F,oBAAoB,EAAE4F,cAAI;EAK1BjI,MAAM,EAAE4O,eAAK,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;EAKpDX,cAAc,EAAE/F,cAAI;EAKpB3F,iBAAiB,EAAEyF;AAAM,EACzB;;;;"}
|
|
1
|
+
{"version":3,"sources":["../src/google-map.tsx","../src/map/hooks/useScript.ts","../src/map/hooks/useGoogleMaps.ts","../src/map/map.tsx","../src/utils/utils.ts","../src/map/markers.tsx","../src/map/overlay-view.tsx","../src/map/hooks/useMemoCompare.ts","../src/map/overlay.tsx","../src/index.ts"],"names":["forwardRef","useEffect","useState","cachedScriptStatuses","getScriptNode","src","node","status","useScript","script","forcedStatus","options","setStatus","_a","_b","_c","cachedScriptStatus","scriptToAdd","scriptNode","currentScriptStatus","key","value","setAttributeFromEvent","event","scriptStatus","setStateFromEvent","newStatus","useScript_default","useGoogleMaps","apiKey","libraries","loadScriptExternally","externalApiParams","callback","apiParams","useCallback","useRef","isArraysEqualEps","arrayA","arrayB","eps","i","Children","cloneElement","isValidElement","useMemo","createPortal","useMemoCompare","next","compare","previousRef","previous","isEqual","useMemoCompare_default","getLatLng","LatLng","createOverlay","container","pane","position","maps","drag","Overlay","that","e","evt","origin","left","top","pos","latLng","currentPane","point","overlay_default","OverlayView","map","zIndex","children","div","overlay","childrenProps","prev","overlay_view_default","jsx","noop","MapMarkers","markers","child","draggable","onDragStart","onDrag","onDragEnd","markers_default","Fragment","jsxs","MapComponent","style","defaultCenter","defaultZoom","onGoogleApiLoaded","onChange","events","mapRef","prevBoundsRef","setMap","setMaps","googleApiCalled","setGoogleApiCalled","onIdle","zoom","bounds","centerLatLng","ne","sw","boundsArray","acc","name","handler","map_default","GoogleMap","loadingContent","idleContent","errorContent","mapMinHeight","containerProps","statusProp","scriptCallback","props","ref","renderers","google_map_default","src_default"],"mappings":"AAAA,OAAS,cA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Aa,EACzG,GAAGC,EAEH,SAAAK,EAAU1H,CAAM,GAAK,KACvB,CAEF,CACD,EAEO2H,EAAQX,GSlDf,IAAOY,GAAQD","sourcesContent":["import { forwardRef } from 'react'\nimport { useGoogleMaps } from './map/hooks/useGoogleMaps'\nimport MapComponent from './map/map'\nimport { GoogleMapProps } from './utils/types'\n\nconst GoogleMap = forwardRef<HTMLDivElement, GoogleMapProps>(\n\t(\n\t\t{\n\t\t\tapiKey = '',\n\t\t\tlibraries = ['places', 'geometry'],\n\t\t\tchildren = null,\n\t\t\tloadingContent = 'Google Maps is loading',\n\t\t\tidleContent = 'Google Maps is on idle',\n\t\t\terrorContent = 'Google Maps is on error',\n\t\t\tmapMinHeight = 'unset',\n\t\t\tcontainerProps = {},\n\t\t\tloadScriptExternally = false,\n\t\t\tstatus: statusProp = 'idle',\n\t\t\tscriptCallback = () => {},\n\t\t\texternalApiParams = {},\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst renderers = {\n\t\t\tready: <MapComponent {...props}>{children}</MapComponent>,\n\t\t\tloading: loadingContent,\n\t\t\tidle: idleContent,\n\t\t\terror: errorContent,\n\t\t}\n\n\t\tconst status = useGoogleMaps({\n\t\t\tapiKey,\n\t\t\tlibraries,\n\t\t\tloadScriptExternally,\n\t\t\tstatus: statusProp,\n\t\t\texternalApiParams,\n\t\t\tcallback: scriptCallback,\n\t\t})\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tstyle={{ height: '100%', width: '100%', overflow: 'hidden', position: 'relative', minHeight: mapMinHeight }}\n\t\t\t\t{...containerProps}\n\t\t\t>\n\t\t\t\t{renderers[status] || null}\n\t\t\t</div>\n\t\t)\n\t},\n)\n\nexport default GoogleMap\n","/* eslint-disable no-unused-expressions */\nimport { useEffect, useState } from 'react'\nimport { ScriptProps, UseScriptOptions, UseScriptStatus } from '../../utils/types'\n\n// Cached script statuses\nconst cachedScriptStatuses: Record<string, UseScriptStatus | undefined> = {}\n\nfunction getScriptNode(src: string) {\n\tconst node: HTMLScriptElement | null = document.querySelector(`script[src=\"${src}\"]`)\n\tconst status = node?.getAttribute('data-status') as UseScriptStatus | undefined\n\n\treturn {\n\t\tnode,\n\t\tstatus,\n\t}\n}\n\n/**\n * @description Hook to load external script.\n * @param {Object} script - Script to load.\n * @param {string} script.src - Script source.\n * @param {Object} [script.attributes] - Attributes to add to the script tag.\n * @param {Object} [script.callbacks] - Callbacks executed on completion.\n * @param {Function} [script.callbacks.onLoadCallback] - Callback executed on completion in case of success.\n * @param {Function} [script.callbacks.onErrorCallback] - Callbacks executed on completion in case of error.\n * @param {string} [script.elementIdToAppend] - HTML element id to append the script to. Default is HTML HEAD.\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n *\n * @example\n * const status = useScript({\n * \t\tsrc: \"https://script-to-load.js\",\n * \t\tattributes: { id: \"scriptId\", class: \"script-class\" },\n * \t\tcallbacks: {\n * \t\t\tonLoadCallback: onLoadFunc,\n * \t\t\tonErrorCallback: onErrorFunc,\n * \t\t},\n * \t\telementIdToAppend: \"script-container\"\n * }, undefined, { removeOnUnmount: true, shouldPreventLoad: false })\n */\n\nfunction useScript(\n\t// eslint-disable-next-line default-param-last\n\tscript: ScriptProps = {\n\t\tsrc: '',\n\t\tattributes: {},\n\t\tcallbacks: { onLoadCallback: () => {}, onErrorCallback: () => {} },\n\t\telementIdToAppend: '',\n\t},\n\tforcedStatus?: UseScriptStatus,\n\toptions: UseScriptOptions = { removeOnUnmount: false, shouldPreventLoad: false },\n): 'idle' | 'loading' | 'ready' | 'error' {\n\tconst [status, setStatus] = useState<UseScriptStatus>(() => {\n\t\tif (!script.src || options?.shouldPreventLoad) {\n\t\t\treturn 'idle'\n\t\t}\n\n\t\tif (typeof window === 'undefined') {\n\t\t\t// SSR Handling - always return 'loading'\n\t\t\treturn 'loading'\n\t\t}\n\n\t\treturn cachedScriptStatuses[script.src] ?? 'loading'\n\t})\n\n\tuseEffect(\n\t\t() => {\n\t\t\tif (forcedStatus) {\n\t\t\t\tsetStatus(forcedStatus)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (!script?.src || options?.shouldPreventLoad) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst cachedScriptStatus = cachedScriptStatuses[script.src]\n\t\t\tif (cachedScriptStatus === 'ready' || cachedScriptStatus === 'error') {\n\t\t\t\t// If the script is already cached, set its status immediately\n\t\t\t\tsetStatus(cachedScriptStatus)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Fetch existing script element by src\n\t\t\t// It may have been added by another instance of this hook\n\t\t\tconst scriptToAdd = getScriptNode(script.src)\n\t\t\tlet scriptNode = scriptToAdd.node\n\n\t\t\tif (!scriptNode) {\n\t\t\t\t// Create script element and add it to document body\n\t\t\t\tscriptNode = document.createElement('script')\n\t\t\t\tscriptNode.src = script.src\n\t\t\t\tscriptNode.async = true\n\t\t\t\tscriptNode.setAttribute('data-status', 'loading')\n\t\t\t\t// Add other script attributes, if they exist\n\t\t\t\tscript.attributes && Object.entries(script.attributes).length > 0\n\t\t\t\t\t? Object.entries(script.attributes).map(([key, value]) => scriptNode?.setAttribute(key, value))\n\t\t\t\t\t: null\n\t\t\t\tif (script.elementIdToAppend && document.getElementById(script.elementIdToAppend)) {\n\t\t\t\t\tdocument.getElementById(script.elementIdToAppend)?.appendChild(scriptNode)\n\t\t\t\t} else {\n\t\t\t\t\tdocument.body.appendChild(scriptNode)\n\t\t\t\t}\n\n\t\t\t\t// Store status in attribute on script\n\t\t\t\t// This can be read by other instances of this hook\n\t\t\t\tconst setAttributeFromEvent = (event: Event) => {\n\t\t\t\t\tconst scriptStatus: UseScriptStatus = event.type === 'load' ? 'ready' : 'error'\n\n\t\t\t\t\tscriptNode?.setAttribute('data-status', scriptStatus)\n\t\t\t\t}\n\n\t\t\t\tscriptNode.addEventListener('load', setAttributeFromEvent)\n\t\t\t\tscriptNode.addEventListener('error', setAttributeFromEvent)\n\t\t\t} else {\n\t\t\t\t// Grab existing script status from attribute and set to state.\n\t\t\t\tconst currentScriptStatus = scriptToAdd.status ?? cachedScriptStatus ?? 'loading'\n\n\t\t\t\tswitch (currentScriptStatus) {\n\t\t\t\t\tcase 'loading':\n\t\t\t\t\tcase 'ready':\n\t\t\t\t\t\tscript.callbacks?.onLoadCallback ? script.callbacks.onLoadCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\tscript.callbacks?.onErrorCallback ? script.callbacks.onErrorCallback() : null\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// loading: do nothing\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tsetStatus(currentScriptStatus)\n\t\t\t}\n\n\t\t\t// Script event handler to update status in state\n\t\t\t// Note: Even if the script already exists we still need to add\n\t\t\t// event handlers to update the state for this hook instance.\n\t\t\tconst setStateFromEvent = (event: Event) => {\n\t\t\t\tconst newStatus = event.type === 'load' ? 'ready' : 'error'\n\t\t\t\tevent.type === 'load'\n\t\t\t\t\t? script.callbacks?.onLoadCallback\n\t\t\t\t\t\t? script.callbacks.onLoadCallback()\n\t\t\t\t\t\t: null\n\t\t\t\t\t: script.callbacks?.onErrorCallback\n\t\t\t\t\t? script.callbacks.onErrorCallback()\n\t\t\t\t\t: null\n\n\t\t\t\tsetStatus(newStatus)\n\t\t\t\tcachedScriptStatuses[script.src] = newStatus\n\t\t\t}\n\t\t\t// Add event listeners\n\t\t\tscriptNode.addEventListener('load', setStateFromEvent)\n\t\t\tscriptNode.addEventListener('error', setStateFromEvent)\n\t\t\t// Remove event listeners on cleanup\n\t\t\t// eslint-disable-next-line consistent-return\n\t\t\treturn () => {\n\t\t\t\tif (scriptNode) {\n\t\t\t\t\tscriptNode.removeEventListener('load', setStateFromEvent)\n\t\t\t\t\tscriptNode.removeEventListener('error', setStateFromEvent)\n\t\t\t\t}\n\n\t\t\t\tif (scriptNode && options?.removeOnUnmount) {\n\t\t\t\t\tscriptNode.remove()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Re-run useEffect if script changes\n\t\t[script, forcedStatus, status],\n\t)\n\n\treturn status\n}\n\nexport default useScript\n","import { IUseGoogleMaps, UseScriptStatus } from '../../utils/types'\nimport useScript from './useScript'\n\n/**\n * @returns {\"idle\" | \"loading\" | \"ready\" | \"error\"} status\n */\nexport const useGoogleMaps = ({\n\tapiKey,\n\tlibraries = [],\n\tloadScriptExternally = false,\n\tstatus = 'idle',\n\texternalApiParams,\n\tcallback,\n}: IUseGoogleMaps): UseScriptStatus => {\n\tif (typeof window !== 'undefined') window.googleMapsCallback = callback\n\tconst apiParams = new URLSearchParams(externalApiParams)?.toString()\n\tconst script = apiKey\n\t\t? {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=googleMapsCallback&libraries=${libraries?.join(\n\t\t\t\t\t',',\n\t\t\t\t)}${apiParams ? `&${apiParams}` : ''}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\t\t: {\n\t\t\t\tsrc: `https://maps.googleapis.com/maps/api/js?callback=googleMapsCallback&libraries=${libraries?.join(',')}`,\n\t\t\t\tattributes: { id: 'googleMapsApi' },\n\t\t }\n\n\treturn useScript(script, loadScriptExternally ? status : undefined)\n}\n","import { useCallback, useEffect, useRef, useState } from 'react'\nimport { EventProps, Map, MapProps, MapsLibrary } from '../utils/types'\nimport { isArraysEqualEps } from '../utils/utils'\nimport MapMarkers from './markers'\n\nfunction MapComponent({\n\tchildren = null,\n\tstyle = {\n\t\twidth: '100%',\n\t\theight: '100%',\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tmargin: 0,\n\t\tpadding: 0,\n\t\tposition: 'absolute',\n\t},\n\tdefaultCenter,\n\tdefaultZoom,\n\tonGoogleApiLoaded,\n\tonChange,\n\toptions = {},\n\tevents = [],\n}: MapProps) {\n\tconst mapRef = useRef<HTMLDivElement>(null)\n\tconst prevBoundsRef = useRef<number[] | undefined>()\n\tconst [map, setMap] = useState<Map>()\n\tconst [maps, setMaps] = useState<MapsLibrary>()\n\tconst [googleApiCalled, setGoogleApiCalled] = useState<boolean>(false)\n\n\tconst onIdle = useCallback(() => {\n\t\ttry {\n\t\t\tif (!map) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst zoom = map.getZoom() ?? defaultZoom\n\t\t\tconst bounds = map.getBounds()\n\t\t\tconst centerLatLng = [map.getCenter()?.lng(), map.getCenter()?.lat()]\n\n\t\t\tconst ne = bounds?.getNorthEast()\n\t\t\tconst sw = bounds?.getSouthWest()\n\n\t\t\tif (!ne || !sw || !bounds) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// east, north, south, west\n\t\t\tconst boundsArray = [sw.lng(), sw.lat(), ne.lng(), ne.lat()]\n\n\t\t\tif (!isArraysEqualEps(boundsArray, prevBoundsRef.current)) {\n\t\t\t\tif (onChange) {\n\t\t\t\t\tonChange({\n\t\t\t\t\t\tzoom,\n\t\t\t\t\t\tcenter: centerLatLng,\n\t\t\t\t\t\tbounds,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tprevBoundsRef.current = boundsArray\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(e)\n\t\t}\n\t}, [map, onChange])\n\n\tuseEffect(() => {\n\t\tif (mapRef.current && !map) {\n\t\t\tsetMap(\n\t\t\t\tnew google.maps.Map(mapRef.current as HTMLElement, {\n\t\t\t\t\tcenter: defaultCenter,\n\t\t\t\t\tzoom: defaultZoom,\n\t\t\t\t\t...(options as google.maps.MapOptions),\n\t\t\t\t}),\n\t\t\t)\n\t\t\tsetMaps(google.maps)\n\t\t}\n\t}, [defaultCenter, defaultZoom, map, mapRef, options])\n\n\tuseEffect(() => {\n\t\tif (map) {\n\t\t\tif (!googleApiCalled) {\n\t\t\t\tif (onGoogleApiLoaded && maps) onGoogleApiLoaded({ map, maps, ref: mapRef.current })\n\t\t\t\tsetGoogleApiCalled(true)\n\t\t\t}\n\n\t\t\tgoogle.maps.event.clearListeners(map, 'idle')\n\t\t\t// Idle event is fired when the map becomes idle after panning or zooming.\n\t\t\tgoogle.maps.event.addListener(map, 'idle', onIdle)\n\t\t}\n\t}, [googleApiCalled, map, maps, onChange, onGoogleApiLoaded, onIdle])\n\n\tuseEffect(\n\t\t() =>\n\t\t\t// clear listeners on unmount\n\t\t\t() => {\n\t\t\t\tif (map) {\n\t\t\t\t\tgoogle.maps.event.clearListeners(map, 'idle')\n\t\t\t\t}\n\t\t\t},\n\t\t[map],\n\t)\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={mapRef}\n\t\t\t\tstyle={style}\n\t\t\t\tclassName=\"google-map\"\n\t\t\t\t// spread the events as props\n\t\t\t\t{...events?.reduce(\n\t\t\t\t\t(acc, { name, handler }: EventProps) => {\n\t\t\t\t\t\tacc[name] = handler\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t},\n\t\t\t\t\t{} as { [key: string]: any },\n\t\t\t\t)}\n\t\t\t/>\n\t\t\t{children && map && maps && (\n\t\t\t\t<MapMarkers map={map} maps={maps}>\n\t\t\t\t\t{children}\n\t\t\t\t</MapMarkers>\n\t\t\t)}\n\t\t</>\n\t)\n}\n\nexport default MapComponent\n","export const isArraysEqualEps = (arrayA: number[], arrayB?: number[], eps = 0.000001): boolean => {\n\tif (arrayA && arrayB) {\n\t\tfor (let i = 0; i !== arrayA.length; ++i) {\n\t\t\tif (Math.abs(arrayA[i] - arrayB[i]) > eps) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n","import { Children, cloneElement, isValidElement, useMemo } from 'react'\nimport { MapMarkersProps } from '../utils/types'\nimport OverlayView from './overlay-view'\n\nconst noop = () => {}\n\nconst MapMarkers = ({ children, map, maps }: MapMarkersProps) => {\n\tconst markers = useMemo(() => {\n\t\tif (!map || !maps) return []\n\n\t\treturn Children.map(children, (child) => {\n\t\t\tif (isValidElement(child)) {\n\t\t\t\tconst latLng = { lat: child.props.lat, lng: child.props.lng } as google.maps.LatLngLiteral\n\t\t\t\tconst { zIndex, draggable = false, onDragStart = noop, onDrag = noop, onDragEnd = noop } = child.props || {}\n\n\t\t\t\t// clone child without draggable props\n\t\t\t\t// eslint-disable-next-line no-param-reassign\n\t\t\t\tchild = cloneElement(child, {\n\t\t\t\t\t...child.props,\n\t\t\t\t\tdraggable: undefined,\n\t\t\t\t\tonDragStart: undefined,\n\t\t\t\t\tonDrag: undefined,\n\t\t\t\t\tonDragEnd: undefined,\n\t\t\t\t})\n\n\t\t\t\treturn (\n\t\t\t\t\t<OverlayView\n\t\t\t\t\t\tposition={new maps.LatLng(latLng.lat, latLng.lng)}\n\t\t\t\t\t\tmap={map}\n\t\t\t\t\t\tmaps={maps}\n\t\t\t\t\t\tzIndex={zIndex}\n\t\t\t\t\t\tdrag={{\n\t\t\t\t\t\t\tdraggable,\n\t\t\t\t\t\t\tonDragStart,\n\t\t\t\t\t\t\tonDrag,\n\t\t\t\t\t\t\tonDragEnd,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{child}\n\t\t\t\t\t</OverlayView>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn null\n\t\t})\n\t}, [children, map, maps])\n\n\treturn <div>{markers}</div>\n}\n\nexport default MapMarkers\n","import { useEffect, useMemo } from 'react'\nimport { createPortal } from 'react-dom'\nimport { OverlayViewProps } from '../utils/types'\nimport useMemoCompare from './hooks/useMemoCompare'\nimport createOverlay from './overlay'\n\nconst OverlayView = ({ pane = 'floatPane', position, map, maps, zIndex = 0, children, drag }: OverlayViewProps) => {\n\tconst container = useMemo<HTMLDivElement>(() => {\n\t\t// eslint-disable-next-line no-undef\n\t\tconst div = document.createElement('div') as HTMLDivElement\n\t\tdiv.style.position = 'absolute'\n\t\treturn div as HTMLDivElement\n\t}, [])\n\n\tconst overlay = useMemo(\n\t\t() => createOverlay({ container, pane, position, maps, drag }),\n\t\t[container, drag, maps, pane, position],\n\t)\n\n\t// Because React does not do deep comparisons, a custom hook is used.\n\t// This fixes the issue where the overlay is not updated when the position changes.\n\tconst childrenProps = useMemoCompare(\n\t\tchildren?.props as any,\n\t\t(prev: { lat: any; lng: any }, next: { lat: any; lng: any }) =>\n\t\t\tprev && prev.lat === next.lat && prev.lng === next.lng,\n\t)\n\n\tuseEffect(() => {\n\t\tif (!overlay.map && map) {\n\t\t\toverlay?.setMap(map)\n\t\t\treturn () => {\n\t\t\t\toverlay?.setMap(null)\n\t\t\t}\n\t\t}\n\t\treturn () => {}\n\t\t// overlay depends on map, so we don't need to add it to the dependency array\n\t\t// otherwise, it will re-render the overlay every time the map changes\n\t\t// ? added childrenProps to the dependency array to re-render the overlay when the children props change.\n\t}, [map, childrenProps])\n\n\t// to move the container to the foreground and background\n\tuseEffect(() => {\n\t\tcontainer.style.zIndex = `${zIndex}`\n\t}, [zIndex, container])\n\n\treturn createPortal(children, container)\n}\n\nexport default OverlayView\n","import { useEffect, useRef } from 'react'\n\n/**\n * A hook that compares the previous and current values of a reference.\n * @param {any} next - the current value of the reference\n * @param {function} compare - a function that compares the previous and current values\n * @returns {any} the previous value of the reference\n * @ref https://usehooks.com/useMemoCompare/\n */\nconst useMemoCompare = (next: any, compare: Function): any => {\n\t// Ref for storing previous value\n\tconst previousRef = useRef()\n\tconst previous = previousRef.current\n\t// Pass previous and next value to compare function\n\t// to determine whether to consider them equal.\n\tconst isEqual = compare(previous, next)\n\t// If not equal update previousRef to next value.\n\t// We only update if not equal so that this hook continues to return\n\t// the same old value if compare keeps returning true.\n\tuseEffect(() => {\n\t\tif (!isEqual) {\n\t\t\tpreviousRef.current = next\n\t\t}\n\t})\n\t// Finally, if equal then return the previous value\n\treturn isEqual ? previous : next\n}\n\nexport default useMemoCompare\n","import { Pane, createOverlayProps } from '../utils/types'\n\n// return lat, lng from LatLngLiteral\nconst getLatLng = (LatLng: google.maps.LatLng | null) => {\n\ttry {\n\t\tconst latLng = { lat: LatLng?.lat(), lng: LatLng?.lng() } as google.maps.LatLngLiteral\n\t\treturn latLng\n\t} catch (e) {\n\t\treturn LatLng\n\t}\n}\n\nconst createOverlay = ({ container, pane, position, maps, drag }: createOverlayProps) => {\n\tclass Overlay extends google.maps.OverlayView {\n\t\t/**\n\t\t * onAdd is called when the map's panes are ready and the overlay has been\n\t\t * added to the map.\n\t\t */\n\t\tonAdd = () => {\n\t\t\tconst that = this\n\t\t\t// manage draggable\n\t\t\tif (drag?.draggable) {\n\t\t\t\tthis.get('map')\n\t\t\t\t\t.getDiv()\n\t\t\t\t\t.addEventListener('mouseleave', () => {\n\t\t\t\t\t\tgoogle.maps.event.trigger(this.container, 'mouseup')\n\t\t\t\t\t})\n\t\t\t\tthis.container.addEventListener('mousedown', (e: MouseEvent) => {\n\t\t\t\t\tthis.container.style.cursor = 'grabbing'\n\t\t\t\t\tthat.map?.set('draggable', false)\n\t\t\t\t\tthat.set('origin', e)\n\n\t\t\t\t\tdrag.onDragStart(e, { latLng: getLatLng(this.position) })\n\n\t\t\t\t\t// eslint-disable-next-line no-shadow\n\t\t\t\t\tthat.moveHandler = this.get('map')\n\t\t\t\t\t\t.getDiv()\n\t\t\t\t\t\t.addEventListener('mousemove', (evt: MouseEvent) => {\n\t\t\t\t\t\t\tconst origin = that.get('origin')\n\t\t\t\t\t\t\tconst left = origin.clientX - evt.clientX\n\t\t\t\t\t\t\tconst top = origin.clientY - evt.clientY\n\t\t\t\t\t\t\tconst pos = that.getProjection().fromLatLngToDivPixel(that.position)\n\t\t\t\t\t\t\tif (pos === null) return\n\t\t\t\t\t\t\tconst latLng = that.getProjection().fromDivPixelToLatLng(new maps.Point(pos.x - left, pos.y - top))\n\t\t\t\t\t\t\tthat.set('position', latLng)\n\t\t\t\t\t\t\tthat.set('origin', evt)\n\t\t\t\t\t\t\tthat.draw()\n\t\t\t\t\t\t\tdrag.onDrag(evt, { latLng: getLatLng(latLng) })\n\t\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tthis.container.addEventListener('mouseup', (e) => {\n\t\t\t\t\tthat.map?.set('draggable', true)\n\t\t\t\t\tthis.container.style.cursor = 'default'\n\t\t\t\t\tif (that.moveHandler) {\n\t\t\t\t\t\tgoogle.maps.event.removeListener(that.moveHandler)\n\t\t\t\t\t\tthat.moveHandler = null\n\t\t\t\t\t}\n\t\t\t\t\tdrag.onDragEnd(e, { latLng: getLatLng(that.position) })\n\t\t\t\t})\n\t\t\t}\n\t\t\t// Add the element to the pane.\n\t\t\tconst currentPane = this.getPanes()?.[this.pane] as HTMLElement\n\t\t\tcurrentPane?.classList.add('google-map-markers-overlay')\n\t\t\tcurrentPane?.appendChild(this.container)\n\t\t}\n\n\t\tdraw = () => {\n\t\t\tconst projection = this.getProjection() as google.maps.MapCanvasProjection\n\t\t\t// Computes the pixel coordinates of the given geographical location in the DOM element that holds the draggable map.\n\t\t\tconst point = projection.fromLatLngToDivPixel(this.position) as google.maps.Point\n\t\t\tif (point === null) return\n\t\t\tthis.container.style.transform = `translate(${point.x}px, ${point.y}px)`\n\t\t\tthis.container.style.width = '0px'\n\t\t\tthis.container.style.height = '0px'\n\t\t}\n\n\t\t/**\n\t\t * The onRemove() method will be called automatically from the API if\n\t\t * we ever set the overlay's map property to 'null'.\n\t\t */\n\t\tonRemove = () => {\n\t\t\tif (this.container.parentNode !== null) {\n\t\t\t\t// remove DOM listeners\n\t\t\t\tgoogle.maps.event.clearInstanceListeners(this.container)\n\t\t\t\tthis.container.parentNode.removeChild(this.container)\n\t\t\t}\n\t\t}\n\n\t\tpublic container: HTMLDivElement\n\n\t\tpublic pane: Pane\n\n\t\tpublic position: google.maps.LatLng\n\n\t\tpublic map = this.getMap()\n\n\t\tpublic moveHandler: google.maps.MapsEventListener | null\n\n\t\t// eslint-disable-next-line no-shadow\n\t\tconstructor(container: HTMLDivElement, pane: Pane, position: google.maps.LatLng) {\n\t\t\tsuper()\n\n\t\t\t// Initialize all properties.\n\t\t\tthis.container = container\n\t\t\tthis.pane = pane\n\t\t\tthis.position = position\n\n\t\t\tthis.moveHandler = null\n\t\t}\n\t}\n\n\treturn new Overlay(container, pane, position)\n}\n\nexport default createOverlay\n","import GoogleMap from './google-map'\n\nexport default GoogleMap\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "google-maps-react-markers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Google Maps library with markers as react components",
|
|
5
5
|
"author": "Giorgia Bosello",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
"url": "https://github.com/giorgiabosello/google-maps-react-markers.git"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://giorgiabosello.github.io/google-maps-react-markers/",
|
|
12
|
-
"main": "dist/index.js",
|
|
13
|
-
"module": "dist/index.modern.js",
|
|
14
|
-
"source": "src/index.js",
|
|
15
12
|
"keywords": [
|
|
16
13
|
"react",
|
|
17
14
|
"google-maps",
|
|
@@ -23,58 +20,105 @@
|
|
|
23
20
|
"google-maps-react-markers",
|
|
24
21
|
"react-component"
|
|
25
22
|
],
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"module": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"type": "module",
|
|
29
27
|
"scripts": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"lint
|
|
28
|
+
"dev": "concurrently \"yarn build --watch\"",
|
|
29
|
+
"build": "tsup --onSuccess \"yarn link:self\"",
|
|
30
|
+
"type-check": "tsc",
|
|
31
|
+
"lint": "eslint --ignore-path .gitignore \"{src,docs/src}/**/*.+(ts|js|tsx)\"",
|
|
32
|
+
"lint:fix": "yarn lint --fix && prettier --write .",
|
|
33
|
+
"prepare": "husky install",
|
|
34
|
+
"commit": "cz",
|
|
35
|
+
"release": "yarn build && yarn release-it",
|
|
36
|
+
"link:self": "yarn yalc publish && yarn link",
|
|
34
37
|
"predeploy": "cd docs && yarn install && yarn build",
|
|
35
38
|
"deploy": "gh-pages -d docs/build",
|
|
36
|
-
"publish": "yarn build && npm publish"
|
|
39
|
+
"final:publish": "yarn build && npm publish"
|
|
37
40
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"lint-staged": {
|
|
45
|
+
"./{src,tests}/**/*.{ts,js,jsx,tsx}": [
|
|
46
|
+
"eslint --ignore-path .gitignore --fix"
|
|
47
|
+
],
|
|
48
|
+
"*": "prettier --write"
|
|
49
|
+
},
|
|
50
|
+
"config": {
|
|
51
|
+
"commitizen": {
|
|
52
|
+
"path": "./node_modules/@ryansonshine/cz-conventional-changelog"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"release-it": {
|
|
56
|
+
"git": {
|
|
57
|
+
"commitMessage": "chore(release): v${version}"
|
|
58
|
+
},
|
|
59
|
+
"github": {
|
|
60
|
+
"release": true
|
|
61
|
+
},
|
|
62
|
+
"npm": {
|
|
63
|
+
"publish": false
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=16"
|
|
41
68
|
},
|
|
42
69
|
"devDependencies": {
|
|
43
|
-
"@babel/core": "
|
|
44
|
-
"@babel/
|
|
45
|
-
"@babel/
|
|
46
|
-
"@babel/preset-
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"eslint-plugin
|
|
56
|
-
"eslint
|
|
70
|
+
"@babel/core": "7.22.15",
|
|
71
|
+
"@babel/preset-env": "7.22.15",
|
|
72
|
+
"@babel/preset-react": "7.22.15",
|
|
73
|
+
"@babel/preset-typescript": "7.22.15",
|
|
74
|
+
"@commitlint/cli": "17.7.1",
|
|
75
|
+
"@commitlint/config-conventional": "17.7.0",
|
|
76
|
+
"@ryansonshine/commitizen": "4.2.8",
|
|
77
|
+
"@ryansonshine/cz-conventional-changelog": "3.3.4",
|
|
78
|
+
"@types/google.maps": "^3.54.0",
|
|
79
|
+
"@types/node": "20.5.9",
|
|
80
|
+
"@types/react": "18.2.21",
|
|
81
|
+
"@types/react-dom": "18.2.7",
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "6.6.0",
|
|
83
|
+
"@typescript-eslint/parser": "6.6.0",
|
|
84
|
+
"babel-loader": "9.1.3",
|
|
85
|
+
"concurrently": "8.2.1",
|
|
86
|
+
"eslint": "8.48.0",
|
|
87
|
+
"eslint-config-airbnb": "19.0.4",
|
|
88
|
+
"eslint-config-prettier": "9.0.0",
|
|
89
|
+
"eslint-plugin-import": "2.28.1",
|
|
90
|
+
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
91
|
+
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
57
92
|
"eslint-plugin-prettier": "5.0.0",
|
|
58
|
-
"eslint-plugin-
|
|
59
|
-
"eslint-plugin-react": "
|
|
60
|
-
"eslint-plugin-
|
|
61
|
-
"eslint-plugin-
|
|
62
|
-
"eslint-plugin-
|
|
63
|
-
"gh-pages": "^
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"prettier": "^3.0.
|
|
93
|
+
"eslint-plugin-react": "7.33.2",
|
|
94
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
95
|
+
"eslint-plugin-sort-class-members": "^1.18.0",
|
|
96
|
+
"eslint-plugin-typescript-sort-keys": "3.0.0",
|
|
97
|
+
"eslint-plugin-unused-imports": "3.0.0",
|
|
98
|
+
"gh-pages": "^6.0.0",
|
|
99
|
+
"husky": "8.0.3",
|
|
100
|
+
"lint-staged": "14.0.1",
|
|
101
|
+
"prettier": "^3.0.3",
|
|
102
|
+
"prop-types": "15.8.1",
|
|
67
103
|
"react": "^18.2.0",
|
|
68
104
|
"react-dom": "^18.2.0",
|
|
69
105
|
"react-scripts": "^5.0.1",
|
|
70
|
-
"
|
|
106
|
+
"release-it": "16.1.5",
|
|
107
|
+
"storybook": "7.4.0",
|
|
108
|
+
"tsup": "7.2.0",
|
|
109
|
+
"typescript": "5.2.2",
|
|
110
|
+
"yalc": "1.0.0-pre.53"
|
|
71
111
|
},
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
"
|
|
112
|
+
"peerDependencies": {
|
|
113
|
+
"react": ">=18",
|
|
114
|
+
"react-dom": ">=18"
|
|
115
|
+
},
|
|
116
|
+
"resolutions": {
|
|
117
|
+
"glob-parent": ">=5.1.2",
|
|
118
|
+
"parse-url": ">=8.1.0",
|
|
119
|
+
"semver": ">=7.5.2",
|
|
120
|
+
"trim": ">=0.0.3",
|
|
121
|
+
"trim-newlines": ">=3.0.1",
|
|
122
|
+
"yaml": ">=2.2.2"
|
|
79
123
|
}
|
|
80
124
|
}
|
package/dist/google-map.d.ts
DELETED
package/dist/google-map.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-map.d.ts","sourceRoot":"","sources":["../src/google-map.js"],"names":[],"mappings":";AAKA,6BA2CE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function useGoogleMaps({ apiKey, libraries, loadScriptExternally, status, externalApiParams, callback, }: {
|
|
2
|
-
apiKey: any;
|
|
3
|
-
libraries?: any[];
|
|
4
|
-
loadScriptExternally?: boolean;
|
|
5
|
-
status?: string;
|
|
6
|
-
externalApiParams: any;
|
|
7
|
-
callback: any;
|
|
8
|
-
}): "idle" | "loading" | "ready" | "error";
|
|
9
|
-
//# sourceMappingURL=useGoogleMaps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGoogleMaps.d.ts","sourceRoot":"","sources":["../../src/hooks/useGoogleMaps.js"],"names":[],"mappings":"AAKO;;;;;;;IAFM,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CA0BlD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default useMemoCompare;
|
|
2
|
-
/**
|
|
3
|
-
* A hook that compares the previous and current values of a reference.
|
|
4
|
-
* @param {any} value - the current value of the reference
|
|
5
|
-
* @param {function} compare - a function that compares the previous and current values
|
|
6
|
-
* @returns {any} the previous value of the reference
|
|
7
|
-
* @ref https://usehooks.com/useMemoCompare/
|
|
8
|
-
*/
|
|
9
|
-
declare function useMemoCompare(next: any, compare: Function): any;
|
|
10
|
-
//# sourceMappingURL=useMemoCompare.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMemoCompare.d.ts","sourceRoot":"","sources":["../../src/hooks/useMemoCompare.js"],"names":[],"mappings":";AAEA;;;;;;GAMG;AACH,+DAHa,GAAG,CAoBf"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function useScript(script?: {
|
|
2
|
-
src: string;
|
|
3
|
-
attributes?: any;
|
|
4
|
-
callbacks?: {
|
|
5
|
-
onLoadCallback?: Function;
|
|
6
|
-
onErrorCallback?: Function;
|
|
7
|
-
};
|
|
8
|
-
elementIdToAppend?: string;
|
|
9
|
-
}, forcedStatus?: any): "idle" | "loading" | "ready" | "error";
|
|
10
|
-
//# sourceMappingURL=useScript.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useScript.d.ts","sourceRoot":"","sources":["../../src/hooks/useScript.js"],"names":[],"mappings":"AA0BO;IApBmB,GAAG,EAAlB,MAAM;IACU,UAAU;IACV,SAAS;QACG,cAAc;QACd,eAAe;;IAC3B,iBAAiB,GAAjC,MAAM;wBACJ,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAiHlD"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|