You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
9.8 KiB

{"ast":null,"code":"import { LeafletProvider, createContainerComponent, createControlHook, createElementHook, createElementObject, extendContext, useLeafletContext } from '@react-leaflet/core';\nimport { Control } from 'leaflet';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nexport const useLayersControlElement = createElementHook(function createLayersControl(_ref, ctx) {\n let {\n children: _c,\n ...options\n } = _ref;\n const control = new Control.Layers(undefined, undefined, options);\n return createElementObject(control, extendContext(ctx, {\n layersControl: control\n }));\n}, function updateLayersControl(control, props, prevProps) {\n if (props.collapsed !== prevProps.collapsed) {\n if (props.collapsed === true) {\n control.collapse();\n } else {\n control.expand();\n }\n }\n});\nexport const useLayersControl = createControlHook(useLayersControlElement); // @ts-ignore\n\nexport const LayersControl = createContainerComponent(useLayersControl);\nexport function createControlledLayer(addLayerToControl) {\n return function ControlledLayer(props) {\n const parentContext = useLeafletContext();\n const propsRef = useRef(props);\n const [layer, setLayer] = useState(null);\n const {\n layersControl,\n map\n } = parentContext;\n const addLayer = useCallback(layerToAdd => {\n if (layersControl != null) {\n if (propsRef.current.checked) {\n map.addLayer(layerToAdd);\n }\n\n addLayerToControl(layersControl, layerToAdd, propsRef.current.name);\n setLayer(layerToAdd);\n }\n }, [layersControl, map]);\n const removeLayer = useCallback(layerToRemove => {\n layersControl?.removeLayer(layerToRemove);\n setLayer(null);\n }, [layersControl]);\n const context = useMemo(() => {\n return extendContext(parentContext, {\n layerContainer: {\n addLayer,\n removeLayer\n }\n });\n }, [parentContext, addLayer, removeLayer]);\n useEffect(() => {\n if (layer !== null && propsRef.current !== props) {\n if (props.checked === true && (propsRef.current.checked == null || propsRef.current.checked === false)) {\n map.addLayer(layer);\n } else if (propsRef.current.checked === true && (props.checked == null || props.checked === false)) {\n map.removeLayer(layer);\n }\n\n propsRef.current = props;\n }\n });\n return props.children ? /*#__PURE__*/React.createElement(LeafletProvider, {\n value: context\n }, props.children) : null;\n };\n}\nLayersControl.BaseLayer = createControlledLayer(function addBaseLayer(layersControl, layer, name) {\n layersControl.addBaseLayer(layer, name);\n});\nLayersControl.Overlay = createControlledLayer(function addOverlay(layersControl, layer, name) {\n layersControl.addOverlay(layer, name);\n});","map":{"version":3,"names":["LeafletProvider","createContainerComponent","createControlHook","createElementHook","createElementObject","extendContext","useLeafletContext","Control","React","useCallback","useEffect","useMemo","useRef","useState","useLayersControlElement","createLayersControl","ctx","children","_c","options","control","Layers","undefined","layersControl","updateLayersControl","props","prevProps","collapsed","collapse","expand","useLayersControl","LayersControl","createControlledLayer","addLayerToControl","ControlledLayer","parentContext","propsRef","layer","setLayer","map","addLayer","layerToAdd","current","checked","name","removeLayer","layerToRemove","context","layerContainer","createElement","value","BaseLayer","addBaseLayer","Overlay","addOverlay"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/react-leaflet/lib/LayersControl.js"],"sourcesContent":["import { LeafletProvider, createContainerComponent, createControlHook, createElementHook, createElementObject, extendContext, useLeafletContext } from '@react-leaflet/core';\nimport { Control } from 'leaflet';\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nexport const useLayersControlElement = createElementHook(function createLayersControl({ children: _c , ...options }, ctx) {\n const control = new Control.Layers(undefined, undefined, options);\n return createElementObject(control, extendContext(ctx, {\n layersControl: control\n }));\n}, function updateLayersControl(control, props, prevProps) {\n if (props.collapsed !== prevProps.collapsed) {\n if (props.collapsed === true) {\n control.collapse();\n } else {\n control.expand();\n }\n }\n});\nexport const useLayersControl = createControlHook(useLayersControlElement);\n// @ts-ignore\nexport const LayersControl = createContainerComponent(useLayersControl);\nexport function createControlledLayer(addLayerToControl) {\n return function ControlledLayer(props) {\n const parentContext = useLeafletContext();\n const propsRef = useRef(props);\n const [layer, setLayer] = useState(null);\n const { layersControl , map } = parentContext;\n const addLayer = useCallback((layerToAdd)=>{\n if (layersControl != null) {\n if (propsRef.current.checked) {\n map.addLayer(layerToAdd);\n }\n addLayerToControl(layersControl, layerToAdd, propsRef.current.name);\n setLayer(layerToAdd);\n }\n }, [\n layersControl,\n map\n ]);\n const removeLayer = useCallback((layerToRemove)=>{\n layersControl?.removeLayer(layerToRemove);\n setLayer(null);\n }, [\n layersControl\n ]);\n const context = useMemo(()=>{\n return extendContext(parentContext, {\n layerContainer: {\n addLayer,\n removeLayer\n }\n });\n }, [\n parentContext,\n addLayer,\n removeLayer\n ]);\n useEffect(()=>{\n if (layer !== null && propsRef.current !== props) {\n if (props.checked === true && (propsRef.current.checked == null || propsRef.current.checked === false)) {\n map.addLayer(layer);\n } else if (propsRef.current.checked === true && (props.checked == null || props.checked === false)) {\n map.removeLayer(layer);\n }\n propsRef.current = props;\n }\n });\n return props.children ? /*#__PURE__*/ React.createElement(LeafletProvider, {\n value: context\n }, props.children) : null;\n };\n}\nLayersControl.BaseLayer = createControlledLayer(function addBaseLayer(layersControl, layer, name) {\n layersControl.addBaseLayer(layer, name);\n});\nLayersControl.Overlay = createControlledLayer(function addOverlay(layersControl, layer, name) {\n layersControl.addOverlay(layer, name);\n});\n"],"mappings":"AAAA,SAASA,eAAT,EAA0BC,wBAA1B,EAAoDC,iBAApD,EAAuEC,iBAAvE,EAA0FC,mBAA1F,EAA+GC,aAA/G,EAA8HC,iBAA9H,QAAuJ,qBAAvJ;AACA,SAASC,OAAT,QAAwB,SAAxB;AACA,OAAOC,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,OAAxC,EAAiDC,MAAjD,EAAyDC,QAAzD,QAAyE,OAAzE;AACA,OAAO,MAAMC,uBAAuB,GAAGX,iBAAiB,CAAC,SAASY,mBAAT,OAA4DC,GAA5D,EAAiE;EAAA,IAApC;IAAEC,QAAQ,EAAEC,EAAZ;IAAiB,GAAGC;EAApB,CAAoC;EACtH,MAAMC,OAAO,GAAG,IAAIb,OAAO,CAACc,MAAZ,CAAmBC,SAAnB,EAA8BA,SAA9B,EAAyCH,OAAzC,CAAhB;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