react-leaflet-custom-control
Advanced tools
Comparing version
@@ -0,7 +1,7 @@ | ||
import L from 'leaflet'; | ||
import React from 'react'; | ||
import L from 'leaflet'; | ||
interface Props { | ||
position: L.ControlPosition; | ||
children?: React.ReactNode; | ||
style?: React.CSSProperties; | ||
container?: React.HTMLAttributes<HTMLDivElement>; | ||
prepend?: boolean; | ||
@@ -8,0 +8,0 @@ } |
@@ -0,3 +1,14 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import L from 'leaflet'; | ||
import React from 'react'; | ||
import L from 'leaflet'; | ||
import ReactDOM from 'react-dom'; | ||
@@ -11,3 +22,4 @@ var POSITION_CLASSES = { | ||
var Control = function (props) { | ||
var _a = React.useState(document.createElement('div')), portalRoot = _a[0], setPortalRoot = _a[1]; | ||
var _a, _b; | ||
var _c = React.useState(document.createElement('div')), portalRoot = _c[0], setPortalRoot = _c[1]; | ||
var positionClass = ((props.position && POSITION_CLASSES[props.position]) || POSITION_CLASSES.topright); | ||
@@ -25,3 +37,5 @@ var portalContainer = document.createElement('div'); | ||
} | ||
var controlContainer = (React.createElement("div", { className: 'leaflet-control leaflet-bar', style: props.style }, props.children)); | ||
var className = (((_b = (_a = props.container) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.concat(' ')) || '') + 'leaflet-control'; | ||
var container = __assign(__assign({}, props.container), { className: className }); | ||
var controlContainer = (React.createElement("div", __assign({}, container), props.children)); | ||
L.DomEvent.disableClickPropagation(portalRoot); | ||
@@ -28,0 +42,0 @@ return ReactDOM.createPortal(controlContainer, portalContainer); |
{ | ||
"name": "react-leaflet-custom-control", | ||
"version": "1.2.6", | ||
"version": "1.3.0", | ||
"description": "Creates a control wrapper around a React element", | ||
@@ -5,0 +5,0 @@ "main": "lib/Control.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12517
7.84%120
15.38%