@amsterdam/react-maps
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
import { LeafletEventHandlerFnMap, Map } from 'leaflet'; | ||
import { AllLeafletInstances } from '../types'; | ||
/** | ||
@@ -13,4 +14,4 @@ * @example | ||
*/ | ||
declare const useEvents: <T extends Map | import("leaflet").Popup | import("leaflet").Tooltip | import("leaflet").TileLayer | import("leaflet").ImageOverlay | import("leaflet").LayerGroup<any> | import("leaflet").Marker<any> | import("leaflet").Circle<any> | import("leaflet").CircleMarker<any> | import("leaflet").Rectangle<any> | import("leaflet").GeoJSON<any>>(instance: T, events?: LeafletEventHandlerFnMap | undefined) => void; | ||
declare const useEvents: <T extends Map | AllLeafletInstances>(instance: T, events?: LeafletEventHandlerFnMap) => void; | ||
export default useEvents; | ||
//# sourceMappingURL=useEvents.d.ts.map |
@@ -6,4 +6,4 @@ import { LeafletEventHandlerFnMap } from 'leaflet'; | ||
*/ | ||
declare const useMapEvents: (events?: LeafletEventHandlerFnMap | undefined) => void; | ||
declare const useMapEvents: (events?: LeafletEventHandlerFnMap) => void; | ||
export default useMapEvents; | ||
//# sourceMappingURL=useMapEvents.d.ts.map |
"use strict"; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -34,5 +36,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment | ||
var instance = leaflet_1.default[leafletComponentName].apply(leaflet_1.default, __spreadArrays(args, [options])); | ||
var instance = leaflet_1.default[leafletComponentName].apply(leaflet_1.default, __spreadArray(__spreadArray([], args, true), [options], false)); | ||
// useCallback to only set the instance once | ||
var setInstanceCallback = react_1.useCallback(function (i) { | ||
var setInstanceCallback = (0, react_1.useCallback)(function (i) { | ||
if (setInstance) { | ||
@@ -42,6 +44,6 @@ setInstance(i); | ||
}, []); | ||
useAddToMapInstance_1.default(instance, | ||
(0, useAddToMapInstance_1.default)(instance, | ||
// useCallback to only set the instance once | ||
setInstanceCallback, customAdd); | ||
useEvents_1.default(instance, events); | ||
(0, useEvents_1.default)(instance, events); | ||
return null; | ||
@@ -48,0 +50,0 @@ }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -17,3 +21,3 @@ if (k2 === undefined) k2 = k; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -32,10 +36,10 @@ return result; | ||
var App = function () { | ||
var _a = react_1.useState(), markerInstance = _a[0], setMarkerInstance = _a[1]; | ||
var _b = react_1.useState(), circleInstance = _b[0], setCircleInstance = _b[1]; | ||
var _c = react_1.useState({ | ||
var _a = (0, react_1.useState)(), markerInstance = _a[0], setMarkerInstance = _a[1]; | ||
var _b = (0, react_1.useState)(), circleInstance = _b[0], setCircleInstance = _b[1]; | ||
var _c = (0, react_1.useState)({ | ||
lat: 52.3731081, | ||
lng: 4.8932945, | ||
}), markerPosition = _c[0], setMarkerPosition = _c[1]; | ||
var _d = react_1.useState(300), circleRadius = _d[0], setCircleRadius = _d[1]; | ||
var _e = react_1.useState(), map = _e[0], setMap = _e[1]; | ||
var _d = (0, react_1.useState)(300), circleRadius = _d[0], setCircleRadius = _d[1]; | ||
var _e = (0, react_1.useState)(), map = _e[0], setMap = _e[1]; | ||
var lat = markerPosition.lat, lng = markerPosition.lng; | ||
@@ -48,3 +52,3 @@ function moveMarker() { | ||
} | ||
react_1.useEffect(function () { | ||
(0, react_1.useEffect)(function () { | ||
if (markerInstance) { | ||
@@ -54,3 +58,3 @@ markerInstance.setLatLng(markerPosition); | ||
}, [markerPosition]); | ||
react_1.useEffect(function () { | ||
(0, react_1.useEffect)(function () { | ||
if (circleInstance) { | ||
@@ -61,3 +65,3 @@ circleInstance.setRadius(circleRadius); | ||
return (react_1.default.createElement(react_1.default.Fragment, null, | ||
react_1.default.createElement("div", null, "Current markerPosition: lat: " + lat + ", lng: " + lng), | ||
react_1.default.createElement("div", null, "Current markerPosition: lat: ".concat(lat, ", lng: ").concat(lng)), | ||
react_1.default.createElement("button", { type: "button", onClick: moveMarker }, "Move marker"), | ||
@@ -64,0 +68,0 @@ react_1.default.createElement("button", { type: "button", onClick: function () { |
@@ -9,3 +9,3 @@ "use strict"; | ||
var App_1 = __importDefault(require("./App")); | ||
react_dom_1.render(react_1.default.createElement(App_1.default, null), document.getElementById('root')); | ||
(0, react_dom_1.render)(react_1.default.createElement(App_1.default, null), document.getElementById('root')); | ||
//# sourceMappingURL=example.js.map |
@@ -6,23 +6,23 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GeoJSON = exports.CircleMarker = exports.Circle = exports.Rectangle = exports.Popup = exports.ToolTip = exports.ImageOverlay = exports.LayerGroup = exports.TileLayer = exports.Marker = exports.createLeafletComponent = void 0; | ||
exports.GeoJSON = exports.CircleMarker = exports.Circle = exports.Rectangle = exports.Popup = exports.ToolTip = exports.ImageOverlay = exports.LayerGroup = exports.TileLayer = exports.Marker = exports.createLeafletComponent = exports.useEvents = exports.useMapEvents = exports.useMapInstance = exports.Map = void 0; | ||
var createLeafletComponent_1 = __importDefault(require("./createLeafletComponent")); | ||
exports.createLeafletComponent = createLeafletComponent_1.default; | ||
var Map_1 = require("./Map"); | ||
Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return Map_1.default; } }); | ||
Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return __importDefault(Map_1).default; } }); | ||
var useMapInstance_1 = require("./utils/useMapInstance"); | ||
Object.defineProperty(exports, "useMapInstance", { enumerable: true, get: function () { return useMapInstance_1.default; } }); | ||
Object.defineProperty(exports, "useMapInstance", { enumerable: true, get: function () { return __importDefault(useMapInstance_1).default; } }); | ||
var useMapEvents_1 = require("./utils/useMapEvents"); | ||
Object.defineProperty(exports, "useMapEvents", { enumerable: true, get: function () { return useMapEvents_1.default; } }); | ||
Object.defineProperty(exports, "useMapEvents", { enumerable: true, get: function () { return __importDefault(useMapEvents_1).default; } }); | ||
var useEvents_1 = require("./utils/useEvents"); | ||
Object.defineProperty(exports, "useEvents", { enumerable: true, get: function () { return useEvents_1.default; } }); | ||
exports.Marker = createLeafletComponent_1.default('marker'); | ||
exports.TileLayer = createLeafletComponent_1.default('tileLayer'); | ||
exports.LayerGroup = createLeafletComponent_1.default('layerGroup'); | ||
exports.ImageOverlay = createLeafletComponent_1.default('imageOverlay'); | ||
exports.ToolTip = createLeafletComponent_1.default('tooltip'); | ||
exports.Popup = createLeafletComponent_1.default('popup'); | ||
exports.Rectangle = createLeafletComponent_1.default('rectangle'); | ||
exports.Circle = createLeafletComponent_1.default('circleMarker'); | ||
exports.CircleMarker = createLeafletComponent_1.default('circle'); | ||
exports.GeoJSON = createLeafletComponent_1.default('geoJSON'); | ||
Object.defineProperty(exports, "useEvents", { enumerable: true, get: function () { return __importDefault(useEvents_1).default; } }); | ||
exports.Marker = (0, createLeafletComponent_1.default)('marker'); | ||
exports.TileLayer = (0, createLeafletComponent_1.default)('tileLayer'); | ||
exports.LayerGroup = (0, createLeafletComponent_1.default)('layerGroup'); | ||
exports.ImageOverlay = (0, createLeafletComponent_1.default)('imageOverlay'); | ||
exports.ToolTip = (0, createLeafletComponent_1.default)('tooltip'); | ||
exports.Popup = (0, createLeafletComponent_1.default)('popup'); | ||
exports.Rectangle = (0, createLeafletComponent_1.default)('rectangle'); | ||
exports.Circle = (0, createLeafletComponent_1.default)('circleMarker'); | ||
exports.CircleMarker = (0, createLeafletComponent_1.default)('circle'); | ||
exports.GeoJSON = (0, createLeafletComponent_1.default)('geoJSON'); | ||
//# sourceMappingURL=index.js.map |
@@ -15,3 +15,7 @@ "use strict"; | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -29,3 +33,3 @@ if (k2 === undefined) k2 = k; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -56,4 +60,4 @@ return result; | ||
var children = _a.children, events = _a.events; | ||
var mapInstance = useMapInstance_1.default(); | ||
useEvents_1.default(mapInstance, events); | ||
var mapInstance = (0, useMapInstance_1.default)(); | ||
(0, useEvents_1.default)(mapInstance, events); | ||
return react_1.default.createElement(react_1.default.Fragment, null, children); | ||
@@ -63,5 +67,5 @@ }; | ||
var children = _a.children, events = _a.events, options = _a.options, setInstance = _a.setInstance, otherProps = __rest(_a, ["children", "events", "options", "setInstance"]); | ||
var _b = react_1.useState(null), mapInstance = _b[0], setMapInstance = _b[1]; | ||
var mapRef = react_1.useRef(null); | ||
react_1.useEffect(function () { | ||
var _b = (0, react_1.useState)(null), mapInstance = _b[0], setMapInstance = _b[1]; | ||
var mapRef = (0, react_1.useRef)(null); | ||
(0, react_1.useEffect)(function () { | ||
if (mapRef.current === null) { | ||
@@ -68,0 +72,0 @@ return; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = require("react"); | ||
var MapContext = react_1.createContext({ | ||
var MapContext = (0, react_1.createContext)({ | ||
mapInstance: null, | ||
@@ -6,0 +6,0 @@ }); |
@@ -9,6 +9,6 @@ "use strict"; | ||
exports.default = (function (instance, setInstance, customAdd) { | ||
var mapInstance = useMapInstance_1.default(); | ||
var _a = react_1.useState(), componentInstance = _a[0], setComponentInstance = _a[1]; | ||
var mapInstance = (0, useMapInstance_1.default)(); | ||
var _a = (0, react_1.useState)(), componentInstance = _a[0], setComponentInstance = _a[1]; | ||
// Cleanup | ||
react_1.useEffect(function () { return function () { | ||
(0, react_1.useEffect)(function () { return function () { | ||
if (componentInstance && mapInstance.hasLayer(componentInstance)) { | ||
@@ -19,3 +19,3 @@ componentInstance.removeFrom(mapInstance); | ||
// Add to map instance | ||
react_1.useEffect(function () { | ||
(0, react_1.useEffect)(function () { | ||
if (!componentInstance) { | ||
@@ -28,3 +28,3 @@ setComponentInstance(customAdd | ||
// Call setInstance when componentInstance is set | ||
react_1.useEffect(function () { | ||
(0, react_1.useEffect)(function () { | ||
if (setInstance && componentInstance) { | ||
@@ -31,0 +31,0 @@ setInstance(componentInstance); |
import { LeafletEventHandlerFnMap, Map } from 'leaflet'; | ||
import { AllLeafletInstances } from '../types'; | ||
/** | ||
@@ -13,4 +14,4 @@ * @example | ||
*/ | ||
declare const useEvents: <T extends Map | import("leaflet").Popup | import("leaflet").Tooltip | import("leaflet").TileLayer | import("leaflet").ImageOverlay | import("leaflet").LayerGroup<any> | import("leaflet").Marker<any> | import("leaflet").Circle<any> | import("leaflet").CircleMarker<any> | import("leaflet").Rectangle<any> | import("leaflet").GeoJSON<any>>(instance: T, events?: LeafletEventHandlerFnMap | undefined) => void; | ||
declare const useEvents: <T extends Map | AllLeafletInstances>(instance: T, events?: LeafletEventHandlerFnMap) => void; | ||
export default useEvents; | ||
//# sourceMappingURL=useEvents.d.ts.map |
@@ -21,3 +21,3 @@ "use strict"; | ||
var useEvents = function (instance, events) { | ||
var mapInstance = useMapInstance_1.default(); | ||
var mapInstance = (0, useMapInstance_1.default)(); | ||
if (instance instanceof leaflet_1.Map) { | ||
@@ -27,4 +27,4 @@ mapInstance = instance; | ||
// The eventsArray should only be set once | ||
var eventsArray = react_1.useMemo(function () { return Object.entries(events || {}); }, []); | ||
react_1.useEffect(function () { | ||
var eventsArray = (0, react_1.useMemo)(function () { return Object.entries(events || {}); }, []); | ||
(0, react_1.useEffect)(function () { | ||
eventsArray.forEach(function (_a) { | ||
@@ -38,3 +38,3 @@ var eventName = _a[0], method = _a[1]; | ||
// eslint-disable-next-line no-console | ||
console.warn("Unable to use event, perhaps the '" + eventName + "' event doesn't exist"); | ||
console.warn("Unable to use event, perhaps the '".concat(eventName, "' event doesn't exist")); | ||
} | ||
@@ -41,0 +41,0 @@ } |
@@ -6,4 +6,4 @@ import { LeafletEventHandlerFnMap } from 'leaflet'; | ||
*/ | ||
declare const useMapEvents: (events?: LeafletEventHandlerFnMap | undefined) => void; | ||
declare const useMapEvents: (events?: LeafletEventHandlerFnMap) => void; | ||
export default useMapEvents; | ||
//# sourceMappingURL=useMapEvents.d.ts.map |
@@ -13,6 +13,6 @@ "use strict"; | ||
var useMapEvents = function (events) { | ||
var mapInstance = useMapInstance_1.default(); | ||
useEvents_1.default(mapInstance, events); | ||
var mapInstance = (0, useMapInstance_1.default)(); | ||
(0, useEvents_1.default)(mapInstance, events); | ||
}; | ||
exports.default = useMapEvents; | ||
//# sourceMappingURL=useMapEvents.js.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
var useMapInstance = function () { | ||
var mapInstance = react_1.useContext(MapContext_1.default).mapInstance; | ||
var mapInstance = (0, react_1.useContext)(MapContext_1.default).mapInstance; | ||
if (!mapInstance) { | ||
@@ -12,0 +12,0 @@ throw new Error('Unable to retrieve map instance, no provider could be found for the MapContext.'); |
{ | ||
"name": "@amsterdam/react-maps", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "ReactJS wrapped around Leaflet", | ||
@@ -50,5 +50,4 @@ "license": "MPL-2.0", | ||
"@typescript-eslint/parser": "^5.8.0", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"css-loader": "^6.2.0", | ||
"eslint": "8.16.0", | ||
"eslint": "8.17.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
@@ -69,3 +68,3 @@ "eslint-plugin-import": "^2.25.3", | ||
"lerna": "^5.0.0", | ||
"lint-staged": "^12.1.2", | ||
"lint-staged": "^13.0.1", | ||
"prettier": "^2.2.1", | ||
@@ -77,3 +76,4 @@ "react": "^17.0.0", | ||
"ts-jest": "^27.0.5", | ||
"typescript": "^3.9.10", | ||
"ts-loader": "^9.3.0", | ||
"typescript": "^4.7.3", | ||
"webpack": "^5.11.0", | ||
@@ -80,0 +80,0 @@ "webpack-cli": "^4.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
78514
886
0