This commit is contained in:
2025-09-11 07:45:47 -07:00
parent 955946e79d
commit a9425720e9
2759 changed files with 0 additions and 294955 deletions

View File

@@ -1,33 +0,0 @@
@react-leaflet/core Copyright 2020 Paul Le Cam and contributors (“Licensor”)
Hippocratic License Version Number: 2.1.
Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensors copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability.
Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensors rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensors copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions:
- Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor.
- Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensees License (and all rights licensed hereunder) shall end immediately.
- Compliance with Human Rights Principles and Human Rights Laws.
1. Human Rights Principles.
(a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles.
(b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise.
Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply.
2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensors reasonable attorneys fees, arising out of or relating to Licensees use of the Software in violation of Human Rights Laws or Human Rights Principles.
- Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee.
- Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
- Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws.

View File

@@ -1,3 +0,0 @@
# React Leaflet core
[Documentation](https://react-leaflet.js.org/docs/core-introduction)

View File

@@ -1,2 +0,0 @@
import type { Map } from 'leaflet';
export declare function useAttribution(map: Map, attribution: string | null | undefined): void;

View File

@@ -1,18 +0,0 @@
import { useEffect, useRef } from 'react';
export function useAttribution(map, attribution) {
const attributionRef = useRef(attribution);
useEffect(function updateAttribution() {
if (attribution !== attributionRef.current && map.attributionControl != null) {
if (attributionRef.current != null) {
map.attributionControl.removeAttribution(attributionRef.current);
}
if (attribution != null) {
map.attributionControl.addAttribution(attribution);
}
}
attributionRef.current = attribution;
}, [
map,
attribution
]);
}

View File

@@ -1,12 +0,0 @@
import type { Circle as LeafletCircle, CircleMarker as LeafletCircleMarker, CircleMarkerOptions, CircleOptions, LatLngExpression } from 'leaflet';
import type { ReactNode } from 'react';
import type { PathProps } from './path.js';
export interface CircleMarkerProps extends CircleMarkerOptions, PathProps {
center: LatLngExpression;
children?: ReactNode;
}
export interface CircleProps extends CircleOptions, PathProps {
center: LatLngExpression;
children?: ReactNode;
}
export declare function updateCircle<P extends CircleMarkerProps | CircleProps>(layer: LeafletCircle<P> | LeafletCircleMarker<P>, props: P, prevProps: P): void;

View File

@@ -1,8 +0,0 @@
export function updateCircle(layer, props, prevProps) {
if (props.center !== prevProps.center) {
layer.setLatLng(props.center);
}
if (props.radius != null && props.radius !== prevProps.radius) {
layer.setRadius(props.radius);
}
}

View File

@@ -1,11 +0,0 @@
import React, { type MutableRefObject, type ReactNode } from 'react';
import type { DivOverlay, DivOverlayHook } from './div-overlay.js';
import type { LeafletElement } from './element.js';
declare type ElementHook<E, P> = (props: P) => MutableRefObject<LeafletElement<E>>;
export declare type PropsWithChildren = {
children?: ReactNode;
};
export declare function createContainerComponent<E, P extends PropsWithChildren>(useElement: ElementHook<E, P>): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<E>>;
export declare function createDivOverlayComponent<E extends DivOverlay, P extends PropsWithChildren>(useElement: ReturnType<DivOverlayHook<E, P>>): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<E>>;
export declare function createLeafComponent<E, P>(useElement: ElementHook<E, P>): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<E>>;
export {};

View File

@@ -1,41 +0,0 @@
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import { createPortal } from 'react-dom';
import { LeafletProvider } from './context.js';
export function createContainerComponent(useElement) {
function ContainerComponent(props, forwardedRef) {
const { instance , context } = useElement(props).current;
useImperativeHandle(forwardedRef, ()=>instance);
return props.children == null ? null : /*#__PURE__*/ React.createElement(LeafletProvider, {
value: context
}, props.children);
}
return /*#__PURE__*/ forwardRef(ContainerComponent);
}
export function createDivOverlayComponent(useElement) {
function OverlayComponent(props, forwardedRef) {
const [isOpen, setOpen] = useState(false);
const { instance } = useElement(props, setOpen).current;
useImperativeHandle(forwardedRef, ()=>instance);
useEffect(function updateOverlay() {
if (isOpen) {
instance.update();
}
}, [
instance,
isOpen,
props.children
]);
// @ts-ignore _contentNode missing in type definition
const contentNode = instance._contentNode;
return contentNode ? /*#__PURE__*/ createPortal(props.children, contentNode) : null;
}
return /*#__PURE__*/ forwardRef(OverlayComponent);
}
export function createLeafComponent(useElement) {
function LeafComponent(props, forwardedRef) {
const { instance } = useElement(props).current;
useImperativeHandle(forwardedRef, ()=>instance);
return null;
}
return /*#__PURE__*/ forwardRef(LeafComponent);
}

View File

@@ -1,34 +0,0 @@
/// <reference types="react" />
import type { Control, Layer, LayerGroup, Map } from 'leaflet';
export declare const CONTEXT_VERSION = 1;
export declare type ControlledLayer = {
addLayer(layer: Layer): void;
removeLayer(layer: Layer): void;
};
export declare type LeafletContextInterface = Readonly<{
__version: number;
map: Map;
layerContainer?: ControlledLayer | LayerGroup;
layersControl?: Control.Layers;
overlayContainer?: Layer;
pane?: string;
}>;
export declare function createLeafletContext(map: Map): LeafletContextInterface;
export declare function extendContext(source: LeafletContextInterface, extra: Partial<LeafletContextInterface>): LeafletContextInterface;
export declare const LeafletContext: import("react").Context<Readonly<{
__version: number;
map: Map;
layerContainer?: LayerGroup<any> | ControlledLayer | undefined;
layersControl?: Control.Layers | undefined;
overlayContainer?: Layer | undefined;
pane?: string | undefined;
}> | null>;
export declare const LeafletProvider: import("react").Provider<Readonly<{
__version: number;
map: Map;
layerContainer?: LayerGroup<any> | ControlledLayer | undefined;
layersControl?: Control.Layers | undefined;
overlayContainer?: Layer | undefined;
pane?: string | undefined;
}> | null>;
export declare function useLeafletContext(): LeafletContextInterface;

View File

@@ -1,23 +0,0 @@
import { createContext, useContext } from 'react';
export const CONTEXT_VERSION = 1;
export function createLeafletContext(map) {
return Object.freeze({
__version: CONTEXT_VERSION,
map
});
}
export function extendContext(source, extra) {
return Object.freeze({
...source,
...extra
});
}
export const LeafletContext = createContext(null);
export const LeafletProvider = LeafletContext.Provider;
export function useLeafletContext() {
const context = useContext(LeafletContext);
if (context == null) {
throw new Error('No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>');
}
return context;
}

View File

@@ -1,3 +0,0 @@
import { Control, type ControlOptions } from 'leaflet';
import type { ElementHook } from './element.js';
export declare function createControlHook<E extends Control, P extends ControlOptions>(useElement: ElementHook<E, P>): (props: P) => ReturnType<ElementHook<E, P>>;

View File

@@ -1,30 +0,0 @@
import { useEffect, useRef } from 'react';
import { useLeafletContext } from './context.js';
export function createControlHook(useElement) {
return function useLeafletControl(props) {
const context = useLeafletContext();
const elementRef = useElement(props, context);
const { instance } = elementRef.current;
const positionRef = useRef(props.position);
const { position } = props;
useEffect(function addControl() {
instance.addTo(context.map);
return function removeControl() {
instance.remove();
};
}, [
context.map,
instance
]);
useEffect(function updateControl() {
if (position != null && position !== positionRef.current) {
instance.setPosition(position);
positionRef.current = position;
}
}, [
instance,
position
]);
return elementRef;
};
}

View File

@@ -1,9 +0,0 @@
import type { Popup, Tooltip } from 'leaflet';
import { type LeafletContextInterface } from './context.js';
import type { LeafletElement, ElementHook } from './element.js';
import type { LayerProps } from './layer.js';
export declare type DivOverlay = Popup | Tooltip;
export declare type SetOpenFunc = (open: boolean) => void;
export declare type DivOverlayLifecycleHook<E, P> = (element: LeafletElement<E>, context: LeafletContextInterface, props: P, setOpen: SetOpenFunc) => void;
export declare type DivOverlayHook<E extends DivOverlay, P> = (useElement: ElementHook<E, P>, useLifecycle: DivOverlayLifecycleHook<E, P>) => (props: P, setOpen: SetOpenFunc) => ReturnType<ElementHook<E, P>>;
export declare function createDivOverlayHook<E extends DivOverlay, P extends LayerProps>(useElement: ElementHook<E, P>, useLifecycle: DivOverlayLifecycleHook<E, P>): (props: P, setOpen: SetOpenFunc) => ReturnType<ElementHook<E, P>>;

View File

@@ -1,14 +0,0 @@
import { useAttribution } from './attribution.js';
import { useLeafletContext } from './context.js';
import { useEventHandlers } from './events.js';
import { withPane } from './pane.js';
export function createDivOverlayHook(useElement, useLifecycle) {
return function useDivOverlay(props, setOpen) {
const context = useLeafletContext();
const elementRef = useElement(withPane(props, context), context);
useAttribution(context.map, props.attribution);
useEventHandlers(elementRef.current, props.eventHandlers);
useLifecycle(elementRef.current, context, props, setOpen);
return elementRef;
};
}

View File

@@ -1,3 +0,0 @@
export declare function addClassName(element: HTMLElement, className: string): void;
export declare function removeClassName(element: HTMLElement, className: string): void;
export declare function updateClassName(element?: HTMLElement, prevClassName?: string, nextClassName?: string): void;

View File

@@ -1,24 +0,0 @@
import { DomUtil } from 'leaflet';
function splitClassName(className) {
return className.split(' ').filter(Boolean);
}
export function addClassName(element, className) {
splitClassName(className).forEach((cls)=>{
DomUtil.addClass(element, cls);
});
}
export function removeClassName(element, className) {
splitClassName(className).forEach((cls)=>{
DomUtil.removeClass(element, cls);
});
}
export function updateClassName(element, prevClassName, nextClassName) {
if (element != null && nextClassName !== prevClassName) {
if (prevClassName != null && prevClassName.length > 0) {
removeClassName(element, prevClassName);
}
if (nextClassName != null && nextClassName.length > 0) {
addClassName(element, nextClassName);
}
}
}

View File

@@ -1,10 +0,0 @@
import { type MutableRefObject } from 'react';
import type { LeafletContextInterface } from './context.js';
export declare type LeafletElement<T, C = any> = Readonly<{
instance: T;
context: LeafletContextInterface;
container?: C | null;
}>;
export declare function createElementObject<T, C = any>(instance: T, context: LeafletContextInterface, container?: C | null): LeafletElement<T, C>;
export declare type ElementHook<E, P> = (props: P, context: LeafletContextInterface) => MutableRefObject<LeafletElement<E>>;
export declare function createElementHook<E, P, C = any>(createElement: (props: P, context: LeafletContextInterface) => LeafletElement<E>, updateElement?: (instance: E, props: P, prevProps: P) => void): (props: P, context: LeafletContextInterface) => ReturnType<ElementHook<E, P>>;

View File

@@ -1,34 +0,0 @@
import { useEffect, useRef } from 'react';
export function createElementObject(instance, context, container) {
return Object.freeze({
instance,
context,
container
});
}
export function createElementHook(createElement, updateElement) {
if (updateElement == null) {
return function useImmutableLeafletElement(props, context) {
const elementRef = useRef();
if (!elementRef.current) elementRef.current = createElement(props, context);
return elementRef;
};
}
return function useMutableLeafletElement(props, context) {
const elementRef = useRef();
if (!elementRef.current) elementRef.current = createElement(props, context);
const propsRef = useRef(props);
const { instance } = elementRef.current;
useEffect(function updateElementProps() {
if (propsRef.current !== props) {
updateElement(instance, props, propsRef.current);
propsRef.current = props;
}
}, [
instance,
props,
context
]);
return elementRef;
};
}

View File

@@ -1,6 +0,0 @@
import type { Evented, LeafletEventHandlerFnMap } from 'leaflet';
import type { LeafletElement } from './element.js';
export declare type EventedProps = {
eventHandlers?: LeafletEventHandlerFnMap;
};
export declare function useEventHandlers(element: LeafletElement<Evented>, eventHandlers: LeafletEventHandlerFnMap | null | undefined): void;

View File

@@ -1,19 +0,0 @@
import { useEffect, useRef } from 'react';
export function useEventHandlers(element, eventHandlers) {
const eventHandlersRef = useRef();
useEffect(function addEventHandlers() {
if (eventHandlers != null) {
element.instance.on(eventHandlers);
}
eventHandlersRef.current = eventHandlers;
return function removeEventHandlers() {
if (eventHandlersRef.current != null) {
element.instance.off(eventHandlersRef.current);
}
eventHandlersRef.current = null;
};
}, [
element,
eventHandlers
]);
}

View File

@@ -1,18 +0,0 @@
/// <reference types="react" />
import type { Control, ControlOptions, FeatureGroup, Layer, Path } from 'leaflet';
import { type PropsWithChildren } from './component.js';
import type { LeafletContextInterface } from './context.js';
import { type LeafletElement } from './element.js';
import { type LayerProps } from './layer.js';
import { type DivOverlay, type DivOverlayLifecycleHook } from './div-overlay.js';
import { type PathProps } from './path.js';
interface LayerWithChildrenProps extends LayerProps, PropsWithChildren {
}
interface PathWithChildrenProps extends PathProps, PropsWithChildren {
}
export declare function createControlComponent<E extends Control, P extends ControlOptions>(createInstance: (props: P) => E): import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<P> & import("react").RefAttributes<E>>;
export declare function createLayerComponent<E extends Layer, P extends LayerWithChildrenProps>(createElement: (props: P, context: LeafletContextInterface) => LeafletElement<E>, updateElement?: (instance: E, props: P, prevProps: P) => void): import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<P> & import("react").RefAttributes<E>>;
export declare function createOverlayComponent<E extends DivOverlay, P extends LayerWithChildrenProps>(createElement: (props: P, context: LeafletContextInterface) => LeafletElement<E>, useLifecycle: DivOverlayLifecycleHook<E, P>): import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<P> & import("react").RefAttributes<E>>;
export declare function createPathComponent<E extends FeatureGroup | Path, P extends PathWithChildrenProps>(createElement: (props: P, context: LeafletContextInterface) => LeafletElement<E>, updateElement?: (instance: E, props: P, prevProps: P) => void): import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<P> & import("react").RefAttributes<E>>;
export declare function createTileLayerComponent<E extends Layer, P extends LayerProps>(createElement: (props: P, context: LeafletContextInterface) => LeafletElement<E>, updateElement?: (instance: E, props: P, prevProps: P) => void): import("react").ForwardRefExoticComponent<import("react").PropsWithoutRef<P> & import("react").RefAttributes<E>>;
export {};

View File

@@ -1,34 +0,0 @@
import { createContainerComponent, createDivOverlayComponent, createLeafComponent } from './component.js';
import { createControlHook } from './control.js';
import { createElementHook, createElementObject } from './element.js';
import { createLayerHook } from './layer.js';
import { createDivOverlayHook } from './div-overlay.js';
import { createPathHook } from './path.js';
export function createControlComponent(createInstance) {
function createElement(props, context) {
return createElementObject(createInstance(props), context);
}
const useElement = createElementHook(createElement);
const useControl = createControlHook(useElement);
return createLeafComponent(useControl);
}
export function createLayerComponent(createElement, updateElement) {
const useElement = createElementHook(createElement, updateElement);
const useLayer = createLayerHook(useElement);
return createContainerComponent(useLayer);
}
export function createOverlayComponent(createElement, useLifecycle) {
const useElement = createElementHook(createElement);
const useOverlay = createDivOverlayHook(useElement, useLifecycle);
return createDivOverlayComponent(useOverlay);
}
export function createPathComponent(createElement, updateElement) {
const useElement = createElementHook(createElement, updateElement);
const usePath = createPathHook(useElement);
return createContainerComponent(usePath);
}
export function createTileLayerComponent(createElement, updateElement) {
const useElement = createElementHook(createElement, updateElement);
const useLayer = createLayerHook(useElement);
return createLeafComponent(useLayer);
}

View File

@@ -1,2 +0,0 @@
import type { GridLayer, GridLayerOptions } from 'leaflet';
export declare function updateGridLayer<E extends GridLayer, P extends GridLayerOptions>(layer: E, props: P, prevProps: P): void;

View File

@@ -1,9 +0,0 @@
export function updateGridLayer(layer, props, prevProps) {
const { opacity , zIndex } = props;
if (opacity != null && opacity !== prevProps.opacity) {
layer.setOpacity(opacity);
}
if (zIndex != null && zIndex !== prevProps.zIndex) {
layer.setZIndex(zIndex);
}
}

View File

@@ -1,15 +0,0 @@
export { useAttribution } from './attribution.js';
export { type CircleMarkerProps, type CircleProps, updateCircle, } from './circle.js';
export { createContainerComponent, createDivOverlayComponent, createLeafComponent, } from './component.js';
export { CONTEXT_VERSION, type LeafletContextInterface, LeafletContext, LeafletProvider, createLeafletContext, extendContext, useLeafletContext, } from './context.js';
export { createControlHook } from './control.js';
export { type DivOverlayHook, type DivOverlayLifecycleHook, type SetOpenFunc, createDivOverlayHook, } from './div-overlay.js';
export { addClassName, removeClassName, updateClassName } from './dom.js';
export { type ElementHook, type LeafletElement, createElementHook, createElementObject, } from './element.js';
export { type EventedProps, useEventHandlers } from './events.js';
export { createControlComponent, createLayerComponent, createOverlayComponent, createPathComponent, createTileLayerComponent, } from './generic.js';
export { updateGridLayer } from './grid-layer.js';
export { type InteractiveLayerProps, type LayerProps, createLayerHook, useLayerLifecycle, } from './layer.js';
export { type MediaOverlayProps, updateMediaOverlay } from './media-overlay.js';
export { withPane } from './pane.js';
export { type PathProps, createPathHook, usePathOptions } from './path.js';

View File

@@ -1,15 +0,0 @@
export { useAttribution } from './attribution.js';
export { updateCircle } from './circle.js';
export { createContainerComponent, createDivOverlayComponent, createLeafComponent } from './component.js';
export { CONTEXT_VERSION, LeafletContext, LeafletProvider, createLeafletContext, extendContext, useLeafletContext } from './context.js';
export { createControlHook } from './control.js';
export { createDivOverlayHook } from './div-overlay.js';
export { addClassName, removeClassName, updateClassName } from './dom.js';
export { createElementHook, createElementObject } from './element.js';
export { useEventHandlers } from './events.js';
export { createControlComponent, createLayerComponent, createOverlayComponent, createPathComponent, createTileLayerComponent } from './generic.js';
export { updateGridLayer } from './grid-layer.js';
export { createLayerHook, useLayerLifecycle } from './layer.js';
export { updateMediaOverlay } from './media-overlay.js';
export { withPane } from './pane.js';
export { createPathHook, usePathOptions } from './path.js';

View File

@@ -1,10 +0,0 @@
import type { InteractiveLayerOptions, Layer, LayerOptions } from 'leaflet';
import { type LeafletContextInterface } from './context.js';
import type { LeafletElement, ElementHook } from './element.js';
import { type EventedProps } from './events.js';
export interface LayerProps extends EventedProps, LayerOptions {
}
export interface InteractiveLayerProps extends LayerProps, InteractiveLayerOptions {
}
export declare function useLayerLifecycle(element: LeafletElement<Layer>, context: LeafletContextInterface): void;
export declare function createLayerHook<E extends Layer, P extends LayerProps>(useElement: ElementHook<E, P>): (props: P) => ReturnType<ElementHook<E, P>>;

View File

@@ -1,28 +0,0 @@
import { useEffect } from 'react';
import { useAttribution } from './attribution.js';
import { useLeafletContext } from './context.js';
import { useEventHandlers } from './events.js';
import { withPane } from './pane.js';
export function useLayerLifecycle(element, context) {
useEffect(function addLayer() {
const container = context.layerContainer ?? context.map;
container.addLayer(element.instance);
return function removeLayer() {
context.layerContainer?.removeLayer(element.instance);
context.map.removeLayer(element.instance);
};
}, [
context,
element
]);
}
export function createLayerHook(useElement) {
return function useLayer(props) {
const context = useLeafletContext();
const elementRef = useElement(withPane(props, context), context);
useAttribution(context.map, props.attribution);
useEventHandlers(elementRef.current, props.eventHandlers);
useLayerLifecycle(elementRef.current, context);
return elementRef;
};
}

View File

@@ -1,6 +0,0 @@
import { type LatLngBoundsExpression, type ImageOverlay as LeafletImageOverlay, type ImageOverlayOptions, type SVGOverlay as LeafletSVGOverlay, type VideoOverlay as LeafletVideoOverlay } from 'leaflet';
import type { InteractiveLayerProps } from './layer.js';
export interface MediaOverlayProps extends ImageOverlayOptions, InteractiveLayerProps {
bounds: LatLngBoundsExpression;
}
export declare function updateMediaOverlay<E extends LeafletImageOverlay | LeafletSVGOverlay | LeafletVideoOverlay, P extends MediaOverlayProps>(overlay: E, props: P, prevProps: P): void;

View File

@@ -1,13 +0,0 @@
import { LatLngBounds } from 'leaflet';
export function updateMediaOverlay(overlay, props, prevProps) {
if (props.bounds instanceof LatLngBounds && props.bounds !== prevProps.bounds) {
overlay.setBounds(props.bounds);
}
if (props.opacity != null && props.opacity !== prevProps.opacity) {
overlay.setOpacity(props.opacity);
}
if (props.zIndex != null && props.zIndex !== prevProps.zIndex) {
// @ts-ignore missing in definition but inherited from ImageOverlay
overlay.setZIndex(props.zIndex);
}
}

View File

@@ -1,3 +0,0 @@
import type { LayerOptions } from 'leaflet';
import type { LeafletContextInterface } from './context.js';
export declare function withPane<P extends LayerOptions>(props: P, context: LeafletContextInterface): P;

View File

@@ -1,7 +0,0 @@
export function withPane(props, context) {
const pane = props.pane ?? context.pane;
return pane ? {
...props,
pane
} : props;
}

View File

@@ -1,8 +0,0 @@
import type { FeatureGroup, Path, PathOptions } from 'leaflet';
import type { LeafletElement, ElementHook } from './element.js';
import { type InteractiveLayerProps } from './layer.js';
export interface PathProps extends InteractiveLayerProps {
pathOptions?: PathOptions;
}
export declare function usePathOptions(element: LeafletElement<FeatureGroup | Path>, props: PathProps): void;
export declare function createPathHook<E extends FeatureGroup | Path, P extends PathProps>(useElement: ElementHook<E, P>): (props: P) => ReturnType<ElementHook<E, P>>;

View File

@@ -1,28 +0,0 @@
import { useEffect, useRef } from 'react';
import { useLeafletContext } from './context.js';
import { useEventHandlers } from './events.js';
import { useLayerLifecycle } from './layer.js';
import { withPane } from './pane.js';
export function usePathOptions(element, props) {
const optionsRef = useRef();
useEffect(function updatePathOptions() {
if (props.pathOptions !== optionsRef.current) {
const options = props.pathOptions ?? {};
element.instance.setStyle(options);
optionsRef.current = options;
}
}, [
element,
props
]);
}
export function createPathHook(useElement) {
return function usePath(props) {
const context = useLeafletContext();
const elementRef = useElement(withPane(props, context), context);
useEventHandlers(elementRef.current, props.eventHandlers);
useLayerLifecycle(elementRef.current, context);
usePathOptions(elementRef.current, props);
return elementRef;
};
}

View File

@@ -1,66 +0,0 @@
{
"name": "@react-leaflet/core",
"version": "2.1.0",
"description": "React Leaflet core",
"repository": {
"type": "git",
"url": "https://github.com/PaulLeCam/react-leaflet.git"
},
"keywords": [
"react-component",
"react",
"leaflet",
"map"
],
"author": "Paul Le Cam <paul@ulem.net>",
"license": "Hippocratic-2.1",
"bugs": {
"url": "https://github.com/PaulLeCam/react-leaflet/issues"
},
"homepage": "https://react-leaflet.js.org/docs/core-introduction",
"type": "module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": "./lib/index.js"
},
"files": [
"lib/*"
],
"sideEffects": false,
"peerDependencies": {
"leaflet": "^1.9.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts",
".tsx"
],
"resolver": "ts-jest-resolver",
"testEnvironment": "jsdom",
"transform": {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
"root": "../.."
}
]
}
},
"scripts": {
"build:clean": "del lib",
"build:js": "swc src -d ./lib --config-file ../../.swcrc",
"build:types": "tsc --emitDeclarationOnly",
"build": "pnpm run build:clean && pnpm run build:types && pnpm run build:js",
"test:types": "tsc --noEmit",
"test:unit": "cross-env NODE_ENV=test jest",
"test": "pnpm run test:types && pnpm run test:unit",
"start": "pnpm run test && pnpm run build"
}
}