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 line
8.4 KiB
1 line
8.4 KiB
2 years ago
|
{"ast":null,"code":"import { LeafletProvider, addClassName, useLeafletContext } from '@react-leaflet/core';\nimport React, { forwardRef, useState, useEffect, useImperativeHandle, useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nconst DEFAULT_PANES = ['mapPane', 'markerPane', 'overlayPane', 'popupPane', 'shadowPane', 'tilePane', 'tooltipPane'];\n\nfunction omitPane(obj, pane) {\n const {\n [pane]: _p,\n ...others\n } = obj;\n return others;\n}\n\nfunction createPane(name, props, context) {\n if (DEFAULT_PANES.indexOf(name) !== -1) {\n throw new Error(`You must use a unique name for a pane that is not a default Leaflet pane: ${name}`);\n }\n\n if (context.map.getPane(name) != null) {\n throw new Error(`A pane with this name already exists: ${name}`);\n }\n\n const parentPaneName = props.pane ?? context.pane;\n const parentPane = parentPaneName ? context.map.getPane(parentPaneName) : undefined;\n const element = context.map.createPane(name, parentPane);\n\n if (props.className != null) {\n addClassName(element, props.className);\n }\n\n if (props.style != null) {\n Object.keys(props.style).forEach(key => {\n // @ts-ignore\n element.style[key] = props.style[key];\n });\n }\n\n return element;\n}\n\nfunction PaneComponent(props, forwardedRef) {\n const [paneName] = useState(props.name);\n const [paneElement, setPaneElement] = useState(null);\n useImperativeHandle(forwardedRef, () => paneElement, [paneElement]);\n const context = useLeafletContext();\n const newContext = useMemo(() => ({ ...context,\n pane: paneName\n }), [context]);\n useEffect(() => {\n setPaneElement(createPane(paneName, props, context));\n return function removeCreatedPane() {\n const pane = context.map.getPane(paneName);\n pane?.remove?.(); // @ts-ignore map internals\n\n if (context.map._panes != null) {\n // @ts-ignore map internals\n context.map._panes = omitPane(context.map._panes, paneName); // @ts-ignore map internals\n\n context.map._paneRenderers = omitPane( // @ts-ignore map internals\n context.map._paneRenderers, paneName);\n }\n }; // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return props.children != null && paneElement != null ? /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(LeafletProvider, {\n value: newContext\n }, props.children), paneElement) : null;\n}\n\nexport const Pane = /*#__PURE__*/forwardRef(PaneComponent);","map":{"version":3,"names":["LeafletProvider","addClassName","useLeafletContext","React","forwardRef","useState","useEffect","useImperativeHandle","useMemo","createPortal","DEFAULT_PANES","omitPane","obj","pane","_p","others","createPane","name","props","context","indexOf","Error","map","getPane","parentPaneName","parentPane","undefined","element","className","style","Object","keys","forEach","key","PaneComponent","forwardedRef","paneName","paneElement","setPaneElement","newContext","removeCreatedPane","remove","_panes","_paneRenderers","children","createElement","value","Pane"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/react-leaflet/lib/Pane.js"],"sourcesContent":["import { LeafletProvider, addClassName, useLeafletContext } from '@react-leaflet/core';\nimport React, { forwardRef, useState, useEffect, useImperativeHandle, useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nconst DEFAULT_PANES = [\n 'mapPane',\n 'markerPane',\n 'overlayPane',\n 'popupPane',\n 'shadowPane',\n 'tilePane',\n 'tooltipPane', \n];\nfunction omitPane(obj, pane) {\n const { [pane]: _p , ...others } = obj;\n return others;\n}\nfunction createPane(name, props, context) {\n if (DEFAULT_PANES.indexOf(name) !== -1) {\n throw new Error(`You must use a unique name for a pane that is not a default Leaflet pane: ${name}`);\n }\n if (context.map.getPane(name) != null) {\n throw new Error(`A pane with this name already exists: ${name}`);\n }\n const parentPaneName = props
|