Add yet-another-react-lightbox package and update .gitignore to exclude node_modules

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-12 18:50:30 +00:00
parent bd2a5570a9
commit c92f4a5edd
9304 changed files with 29 additions and 2008667 deletions

View File

@@ -1,22 +0,0 @@
Copyright (c) 2015 Rubbby
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,313 +0,0 @@
# @react-jvectormap
![Logo](logo.png)
[![npm version](https://badge.fury.io/js/@react-jvectormap%2Fcore.svg)](https://badge.fury.io/js/@react-jvectormap%2Fcore)
## About
A simple wrapper for [jvectormap](http://jvectormap.com/)
## Quick Start
`npm install --save @react-jvectormap/core jquery`
or
`yarn add @react-jvectormap/core jquery`
To see examples, and play with the library, visit the project Storybook:
https://61685594b935d4003a3a6f2c-fcgvwodumn.chromatic.com/
# Basic Usage
## VectorMap
`VectorMap` is a basic map component. Available props:
```
export interface IVectorMapProps extends IMapComponent {
/**
* Optional ref for accessing map methods
*/
mapRef?: MutableRefObject<MapObject | null>;
/**
* Container class Name
*/
className?: string;
/**
* Container inline CSS-in-JS style
*/
style?: CSSProperties;
/**
* Map content definition
*/
map: IVectorMap;
/**
* Background color of the map in CSS format.
*/
backgroundColor?: string;
/**
* Indicates the minimum zoom ratio which could be reached zooming the map. Default value is 1.
*/
zoomMin?: number;
/**
* Indicates the maximum zoom ratio which could be reached zooming the map. Default value is 8.
*/
zoomMax?: number;
/**
* Indicates the multiplier used to zoom map with +/- buttons. Default value is 1.6.
*/
zoomStep?: number;
/**
* When set to true map could be zoomed using mouse scroll. Default value is true.
*/
zoomOnScroll?: boolean;
/**
* Indicates whether or not to animate changing of map zoom with zoom buttons.
*/
zoomAnimate?: boolean;
/**
* This parameter sets the initial position and scale of the map viewport.
*/
focusOn?: IFocus;
/**
* When set to true, the map pans when being dragged. Default value is true.
*/
panOnDrag?: boolean;
/**
* When set to true regions of the map could be selected. Default value is false.
*/
regionsSelectable?: boolean;
/**
* Allow only one region to be selected at the moment. Default value is false.
*/
regionsSelectableOne?: boolean;
/**
* Set of markers to add to the map during initialization. In case of array is provided, codes of markers will be set as string representations of array indexes. Each marker is represented by latLng (array of two numeric values), name (string which will be show on marker's tip) and any marker styles.
*/
markers?: Marker[];
/**
* When set to true markers on the map could be selected. Default value is false.
*/
markersSelectable?: boolean;
/**
* Allow only one marker to be selected at the moment. Default value is false.
*/
markersSelectableOne?: boolean;
/**
* Set the styles for the map's regions. Each region or marker has four states: initial (default state), hover (when the mouse cursor is over the region or marker), selected (when region or marker is selected), selectedHover (when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states.
*/
regionStyle?:
| ISVGElementStyleAttributes
| ((code: string) => ISVGElementStyleAttributes);
/**
* Set the styles for the regions' labels. Each region or marker has four states: initial (default state), hover (when the mouse cursor is over the region or marker), selected (when region or marker is selected), selectedHover (when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states.
*/
regionLabelStyle?: ISVGElementStyleAttributes;
/**
* Set initially selected markers.
*/
selectedMarkers?: string[] | { [region: string]: boolean } | string;
/**
* Set the styles for the map's markers. Any parameter suitable for regionStyle could be used as well as numeric parameter r to set the marker's radius.
*/
markerStyle?: ISVGElementStyleAttributes | IImageElementStyleAttributes;
/**
* Will be called on region click event.
*/
onRegionClick?: (event: JQuery.Event, code: string) => void;
/**
* Will be called when region is (de)selected. isSelected parameter of the callback indicates whether region is selected or not. selectedRegions contains codes of all currently selected regions.
*/
onRegionSelected?: (
event: JQuery.Event,
code: string,
isSelected: boolean,
selectedRegions: string[],
) => void;
/**
* Will be called right before the region tip is going to be shown.
*/
onRegionTipShow?: OnRegionTipShow;
/**
* Will be called on region mouse over event.
*/
onRegionOver?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on region mouse out event.
*/
onRegionOut?: (event: JQuery.Event, code: string) => void;
/**
* Will be called right before the marker tip is going to be shown.
*/
onMarkerTipShow?: (event: JQuery.Event, el: Element, code: string) => void;
/**
* Will be called on marker mouse over event.
*/
onMarkerOver?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on marker mouse out event.
*/
onMarkerOut?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on marker click event.
*/
onMarkerClick?: (event: JQuery.Event, code: string) => void;
/**
* Will be called when marker is (de)selected. isSelected parameter of the callback indicates whether marker is selected or not. selectedMarkers contains codes of all currently selected markers.
*/
onMarkerSelected?: (
event: JQuery.Event,
code: string,
isSelected: boolean,
selectedMarkers: string[],
) => void;
/**
* Triggered when the map's viewport is changed (map was panned or zoomed).
*/
onViewportChange?: (event: JQuery.Event, scale: number) => void;
/**
* Set initially selected regions.
* examples: ["US-CA"] | { "US-CA": true } | "US-CA"
*/
selectedRegions?: SelectedEntities;
/**
* Object with two keys: markers and regions. Each of which is an array of series configs to be applied to the respective map elements.
*/
series?: ISeries;
/**
* Object with two keys: markers and regions. Each of which is an array of labels configs to be applied to the respective map elements.
*/
labels?: ILabels;
}
```
## MultiMap
A `MultiMap` is a map with a drill-down option. For instance, a map of the United States, by which clicking on a state opens it's map.
Available props:
```
/**
* Maximum number of levels user can go through
*/
maxLevel?: number;
/**
* Config of the main map.
*/
main: IMainMap;
/**
* Function to generate map name by region code. Default value is:
*/
mapNameByCode?: (code: string) => string;
/**
* Function to generate map url by region code. Default value is:
*/
mapUrlByCode?: (code: string) => string;
/**
* Function to manually retrieve map data
* @param code
*/
getDrillDownMap?: (code: string) => Promise<IVectorMap> | IVectorMap;
```
# Loading Maps
In order to use a pre-built map, run:
`npm install --save @react-jvectormap/spain`
or
`yarn add @react-jvectormap/spain`
### Usage
`import { esMill } from '@react-jvectormap/spain`;
Or, for bundling optimizations purposes (Recommended!):
`import esMill from "@react-jvectormap/spain/dist/esMill.json";`
```
<VectorMap map={esMill} ... />
```
### Available Prebuilt Maps
| Continent/Country/City | Miller | Mercator | Lambert | Albers | Misc | Package Name |
| ---------------------- | ------------------ | ------------------ | ------- | ------ | ---------- | ---------------------------------------- |
| Africa | africaMill | africaMerc | - | - | - | @react-jvectormap/africa |
| Algeria | dzMill | - | - | - | - | @react-jvectormap/algeria |
| Argentina | arMill | arMerc | - | - | - | @react-jvectormap/argentina |
| Asia | asiaMill | asiaMerc | - | - | - | @react-jvectormap/asia |
| Australia | auMill | auMerc | - | - | - | @react-jvectormap/australia |
| Austria | atMill | atMerc | - | - | - | @react-jvectormap/austria |
| Belgium | beMill | beMerc | - | - | - | @react-jvectormap/belgium |
| Brazil | brMill | - | - | - | - | @react-jvectormap/brazil |
| Canada | caMill | caMerc | caLcc | - | - | @react-jvectormap/canada |
| Chicago | usIlChicagoMill | usIlChicagoMerc | - | - | - | @react-jvectormap/chicago |
| China | cnMill | cnMerc | - | - | - | @react-jvectormap/china |
| Colombia | coMill | coMerc | - | - | - | @react-jvectormap/colombia |
| Continents | continentsMill | continentsMerc | - | - | - | @react-jvectormap/continents |
| Denmark | dkMill | dkMerc | - | - | - | @react-jvectormap/denmark |
| Europe | europeMill | europeMerc | - | - | - | @react-jvectormap/europe |
| France | frMill | frMerc | - | - | - | @react-jvectormap/france |
| FranceRegions | frRegionsMill | frRegionsMerc | - | - | - | @react-jvectormap/franceregions |
| FranceRegions2016 | frRegions_2016Mill | frRegions_2016Merc | - | - | - | @react-jvectormap/franceregions2016 |
| Germany | deMill | deMerc | - | - | - | @react-jvectormap/germany |
| India | inMill | inMerc | - | - | - | @react-jvectormap/india |
| Iran | iranMill | - | - | - | - | @react-jvectormap/iran |
| Italy | itMill | itMerc | - | - | - | @react-jvectormap/italy |
| ItalyRegions | itRegionsMill | itRegionsMerc | - | - | - | @react-jvectormap/italyregions |
| Netherlands | nlMill | nlMerc | - | - | - | @react-jvectormap/netherlands |
| NewYork | usNyNewYorkMill | usNyNewYorkMerc | - | - | - | @react-jvectormap/newyork |
| NewZiland | nzMill | nzMerc | - | - | - | @react-jvectormap/newziland |
| NorthAmerica | northAmericaMill | northAmericaMerc | - | - | - | @react-jvectormap/northamerica |
| Norway | noMill | noMerc | - | - | - | @react-jvectormap/norway |
| Oceania | oceaniaMill | oceaniaMerc | - | - | - | @react-jvectormap/oceania |
| Poland | plMill | plMerc | - | - | - | @react-jvectormap/poland |
| Portugal | ptMill | ptMerc | - | - | - | @react-jvectormap/portugal |
| PuertoRico | - | - | - | - | puertoRico | @react-jvectormap/puertorico |
| Russia | ruMill | ruMerc | - | - | - | @react-jvectormap/russia |
| RussiaFederalDistricts | ruFdMill | ruFdMerc | - | - | - | @react-jvectormap/russiafederaldistricts |
| SouthAfrica | zaMill | zaMerc | - | - | - | @react-jvectormap/southafrica |
| SouthAmerica | southAmericaMill | southAmericaMerc | - | - | - | @react-jvectormap/southamerica |
| SouthKorea | krMill | krMerc | - | - | - | @react-jvectormap/southkorea |
| Spain | esMill | esMerc | - | - | - | @react-jvectormap/spain |
| Sweden | seMill | seMerc | - | - | - | @react-jvectormap/sweden |
| Switzerland | chMill | chMerc | - | - | - | @react-jvectormap/switzerland |
| Thailand | thMill | thMerc | - | - | - | @react-jvectormap/thailand |
| UkRegions | ukRegionsMill | ukRegionsMerc | - | - | - | @react-jvectormap/ukregions |
| UnitedKingdomCountries | ukCountriesMill | ukCountriesMerc | - | - | - | @react-jvectormap/unitedkingdomcountries |
| UnitedStates | usAea | usMill | useMerc | usLcc | - | @react-jvectormap/unitedstates |
| Venezuela | veMill | veMerc | - | - | - | @react-jvectormap/venezuela |
| World | worldMill | worldMerc | - | - | - | @react-jvectormap/world |
## Custom Maps
A `@react-jvectormap` map is represented by the following JSON schema:
```
{
"name": string,
"content": {
"paths": {
[REGION_CODE]: {
path: string (SVG Path)
"name": string;
}
}
},
"projection(optional)": { "type": string, "centralMeridian": number },
"height": number,
"width": number
}
```
# Prop Builders
TBD

View File

@@ -1,3 +0,0 @@
module.exports = {
extends: "../../babel.config.js",
};

View File

@@ -1,8 +0,0 @@
import { CSSProperties, FC, Ref } from "react";
interface IMapContainerProps {
style?: CSSProperties;
className?: string;
containerRef: Ref<HTMLDivElement>;
}
export declare const MapContainer: FC<IMapContainerProps>;
export {};

View File

@@ -1 +0,0 @@
export { MapContainer } from "./MapContainer";

View File

@@ -1,3 +0,0 @@
import { FC } from "react";
import { IMultiMapProps } from "../../types";
export declare const MultiMap: FC<IMultiMapProps>;

View File

@@ -1 +0,0 @@
export { MultiMap } from "./MultiMap";

View File

@@ -1,3 +0,0 @@
import { FC } from "react";
import { IVectorMapProps } from "../../types";
export declare const VectorMap: FC<IVectorMapProps>;

View File

@@ -1 +0,0 @@
export { VectorMap } from "./VectorMap";

View File

@@ -1,2 +0,0 @@
export * from "./VectorMap";
export * from "./MultiMap";

View File

@@ -1,2 +0,0 @@
export * from "./components";
export * from "./utils";

File diff suppressed because one or more lines are too long

View File

@@ -1,374 +0,0 @@
/// <reference types="jquery" />
import { CSSProperties, MutableRefObject } from "react";
export declare type Nullable<T> = null | T;
interface ISetFocusParams {
regions?: string[];
region?: string;
scale?: number;
lat?: number;
lng?: number;
x?: number;
y?: number;
animate?: boolean;
}
export interface IMapObject {
/**
* Add one marker to the map.
* @param key
* @param marker
* @param seriesData
*/
addMarker: (key: string, marker: Marker, seriesData: IAttributeSeries[]) => void;
/**
* Add set of marker to the map.
* @param key
*/
addMarkers: (markers: Marker[], seriesData: IAttributeSeries[]) => void;
/**
* Remove the selected state from all the currently selected markers.
*/
clearSelectedMarkers: () => void;
/**
* Remove the selected state from all the currently selected regions.
*/
clearSelectedRegions: () => void;
/**
* Get the name of a region
*/
getRegionName: (code: string) => void;
/**
* Return the codes of currently selected markers.
*/
getSelectedMarkers: () => Marker[];
/**
* Return the codes of currently selected regions.
*/
getSelectedRegions: () => IRegion[];
/**
* Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
*/
latLngToPoint: (lat: number, lng: number) => number[];
/**
* Converts cartesian coordinates into coordinates expressed as latitude and longitude.
*/
pointToLatLng: (x: number, y: number) => number[];
/**
* Gracefully remove the map and and all its accessories, unbind event handlers.
*/
remove: () => void;
/**
* Remove all markers from the map.
*/
removeAllMarkers: () => void;
/**
* Remove some markers from the map.
*/
removeMarkers: () => void;
/**
* Reset all the series and show the map with the initial zoom.
*/
reset: () => void;
/**
* Set background color of the map.
*/
setBackgroundColor: (backgroundColor: string) => void;
/**
* Set the map's viewport to the specific point and set zoom of the map to the specific level. Point and zoom level could be defined in two ways: using the code of some region to focus on or a central point and zoom level as numbers.
*/
setFocus: (params: ISetFocusParams) => void;
/**
* Set or remove selected state for the markers.
* @param keys
*/
setSelectedMarkers: (keys: string | string[] | {
[key: string]: boolean;
}) => void;
/**
* Set or remove selected state for the regions.
* @param keys
*/
setSelectedRegions: (keys: string | string[] | {
[key: string]: boolean;
}) => void;
/**
* Synchronize the size of the map with the size of the container. Suitable in situations where the size of the container is changed programmatically or container is shown after it became visible.
*/
updateSize: () => void;
}
export declare type MapObject = IMapObject;
interface IMapComponent {
/**
* Optional ref for accessing map methods
*/
mapRef?: MutableRefObject<MapObject | null>;
/**
* Container class Name
*/
className?: string;
/**
* Container inline CSS-in-JS style
*/
style?: CSSProperties;
}
export interface IVectorMapProps extends IMapComponent {
/**
* Map content definition
*/
map: IVectorMap;
/**
* Background color of the map in CSS format.
*/
backgroundColor?: string;
/**
* Indicates the minimum zoom ratio which could be reached zooming the map. Default value is 1.
*/
zoomMin?: number;
/**
* Indicates the maximum zoom ratio which could be reached zooming the map. Default value is 8.
*/
zoomMax?: number;
/**
* Indicates the multiplier used to zoom map with +/- buttons. Default value is 1.6.
*/
zoomStep?: number;
/**
* When set to true map could be zoomed using mouse scroll. Default value is true.
*/
zoomOnScroll?: boolean;
/**
* Indicates whether or not to animate changing of map zoom with zoom buttons.
*/
zoomAnimate?: boolean;
/**
* This parameter sets the initial position and scale of the map viewport.
*/
focusOn?: IFocus;
/**
* When set to true, the map pans when being dragged. Default value is true.
*/
panOnDrag?: boolean;
/**
* When set to true regions of the map could be selected. Default value is false.
*/
regionsSelectable?: boolean;
/**
* Allow only one region to be selected at the moment. Default value is false.
*/
regionsSelectableOne?: boolean;
/**
* Set of markers to add to the map during initialization. In case of array is provided, codes of markers will be set as string representations of array indexes. Each marker is represented by latLng (array of two numeric values), name (string which will be show on marker's tip) and any marker styles.
*/
markers?: Marker[];
/**
* When set to true markers on the map could be selected. Default value is false.
*/
markersSelectable?: boolean;
/**
* Allow only one marker to be selected at the moment. Default value is false.
*/
markersSelectableOne?: boolean;
/**
* Set the styles for the map's regions. Each region or marker has four states: initial (default state), hover (when the mouse cursor is over the region or marker), selected (when region or marker is selected), selectedHover (when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states.
*/
regionStyle?: ISVGElementStyleAttributes | ((code: string) => ISVGElementStyleAttributes);
/**
* Set the styles for the regions' labels. Each region or marker has four states: initial (default state), hover (when the mouse cursor is over the region or marker), selected (when region or marker is selected), selectedHover (when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states.
*/
regionLabelStyle?: ISVGElementStyleAttributes;
/**
* Set initially selected markers.
*/
selectedMarkers?: string[] | {
[region: string]: boolean;
} | string;
/**
* Set the styles for the map's markers. Any parameter suitable for regionStyle could be used as well as numeric parameter r to set the marker's radius.
*/
markerStyle?: ISVGElementStyleAttributes | IImageElementStyleAttributes;
/**
* Will be called on region click event.
*/
onRegionClick?: (event: JQuery.Event, code: string) => void;
/**
* Will be called when region is (de)selected. isSelected parameter of the callback indicates whether region is selected or not. selectedRegions contains codes of all currently selected regions.
*/
onRegionSelected?: (event: JQuery.Event, code: string, isSelected: boolean, selectedRegions: string[]) => void;
/**
* Will be called right before the region tip is going to be shown.
*/
onRegionTipShow?: OnRegionTipShow;
/**
* Will be called on region mouse over event.
*/
onRegionOver?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on region mouse out event.
*/
onRegionOut?: (event: JQuery.Event, code: string) => void;
/**
* Will be called right before the marker tip is going to be shown.
*/
onMarkerTipShow?: (event: JQuery.Event, el: Element, code: string) => void;
/**
* Will be called on marker mouse over event.
*/
onMarkerOver?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on marker mouse out event.
*/
onMarkerOut?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on marker click event.
*/
onMarkerClick?: (event: JQuery.Event, code: string) => void;
/**
* Will be called when marker is (de)selected. isSelected parameter of the callback indicates whether marker is selected or not. selectedMarkers contains codes of all currently selected markers.
*/
onMarkerSelected?: (event: JQuery.Event, code: string, isSelected: boolean, selectedMarkers: string[]) => void;
/**
* Triggered when the map's viewport is changed (map was panned or zoomed).
*/
onViewportChange?: (event: JQuery.Event, scale: number) => void;
/**
* Set initially selected regions.
* examples: ["US-CA"] | { "US-CA": true } | "US-CA"
*/
selectedRegions?: SelectedEntities;
/**
* Object with two keys: markers and regions. Each of which is an array of series configs to be applied to the respective map elements.
*/
series?: ISeries;
/**
* Object with two keys: markers and regions. Each of which is an array of labels configs to be applied to the respective map elements.
*/
labels?: ILabels;
}
export interface IMainMap {
map: IVectorMap;
}
export interface IMultiMapProps extends IMapComponent {
/**
* Maximum number of levels user can go through
*/
maxLevel?: number;
/**
* Config of the main map.
*/
main: IMainMap;
/**
* Function to generate map name by region code. Default value is:
*/
mapNameByCode?: (code: string) => string;
/**
* Function to generate map url by region code. Default value is:
*/
mapUrlByCode?: (code: string) => string;
/**
* Function to manually retrieve map data
* @param code
*/
getDrillDownMap?: (code: string) => Promise<IVectorMap> | IVectorMap;
}
interface IBBox {
x: number;
y: number;
}
interface IInset {
width: number;
height: number;
top: number;
left: number;
bbox: IBBox[];
}
interface IProjection {
type: string;
centralMeridian: number;
}
export interface IVectorMap {
name: string;
content: {
insets: IInset[];
paths: PathsDefinition;
height: number;
width: number;
projection: IProjection;
};
}
interface IFocus {
scale: number;
x: number;
y: number;
region?: string;
lat?: number;
lng?: number;
animate?: boolean;
}
export interface ISVGElementStyleAttributes {
initial?: CSSProperties;
hover?: CSSProperties;
selected?: CSSProperties;
selectedHover?: CSSProperties;
}
interface IImageElementStyleAttributes {
url: string;
offset?: number[];
}
declare type PathsDefinition = {
[key: string]: {
path: string;
name: string;
};
};
export interface ISeries {
regions?: IAttributeSeries[];
markers?: IAttributeSeries[];
}
declare type Scale = {
[key: string]: string;
} | number[] | string[];
declare type Values = {
[key: string]: string | number;
};
export declare type NormalizeFunctionType = "linear" | "polynomial";
export interface IAttributeSeries {
attribute: string;
values?: number[] | {
[key: string]: number;
};
scale?: Scale;
normalizeFunction?: NormalizeFunctionType | ((value?: number) => string);
}
export interface IRegion {
scale: Scale;
values: Values;
attribute: string;
normalizeFunction?: NormalizeFunctionType | ((value?: number) => string);
}
interface IMarkerBase {
name: string;
style?: CSSProperties;
}
interface IMarkerWithCoords extends IMarkerBase {
coords: number[];
}
interface IMarkerWithLatLng extends IMarkerBase {
latLng: number[];
}
export declare type RenderLabel = (code: string) => void | string;
export declare type GetOffsets = (code: string) => {
[key: string | number]: number[];
};
export interface ILabelsProps {
render: RenderLabel;
offsets: GetOffsets;
}
export interface ILabels {
regions?: ILabelsProps;
markers?: ILabelsProps;
}
export declare type Marker = IMarkerWithCoords | IMarkerWithLatLng;
export declare type OnRegionTipShow = (event: JQuery.Event, el: Element, code: string) => void;
export declare type SelectedEntities = string[] | {
[region: string]: boolean;
} | string;
export {};

View File

@@ -1,35 +0,0 @@
import { IAttributeSeries, NormalizeFunctionType } from "../../types";
import { IBuilder } from "./types";
export declare class AttributeSeriesBuilder implements IBuilder<IAttributeSeries> {
private attribute;
private scale?;
private values?;
private normalizeFunction?;
constructor(attribute: string);
/**
*
* @param value
*/
setAttribute(value: string): this;
/**
*
* @param value
*/
setScale(value: number[]): this;
/**
*
* @param value
*/
setValues(value: number[]): this;
/**
*
* @param value
*/
setNormalizeFunction(value: NormalizeFunctionType): this;
build(): {
scale: number[] | undefined;
values: number[] | undefined;
attribute: string;
normalizeFunction: NormalizeFunctionType | undefined;
};
}

View File

@@ -1,19 +0,0 @@
import { ILabels, ILabelsProps } from "../../types";
import { IBuilder } from "./types";
export declare class LabelsBuilder implements IBuilder<ILabels> {
private markers?;
private regions?;
/**
*
* @param values
*/
addMarkersLabelProps(...values: ILabelsProps[]): this;
/**
*
* @param values
*/
addRegionsLabelProps(...values: ILabelsProps[]): this;
build(): {
[k: string]: unknown;
};
}

View File

@@ -1,24 +0,0 @@
import { GetOffsets, ILabelsProps, RenderLabel } from "../../types";
import { IBuilder } from "./types";
export declare class LabelsPropsBuilder implements IBuilder<ILabelsProps> {
private render;
private offsets;
constructor(render: RenderLabel, offsets: GetOffsets);
/**
*
* @param render
*/
setRender(render: RenderLabel): this;
/**
*
* @param offsets
*/
setOffsets(offsets: GetOffsets): this;
/**
*
*/
build(): {
render: RenderLabel;
offsets: GetOffsets;
};
}

View File

@@ -1,42 +0,0 @@
import { CSSProperties } from "react";
import { Marker } from "../../types";
import { IBuilder } from "./types";
export declare class MarkerBuilder implements IBuilder<Marker> {
private name;
private coords?;
private latLng?;
private style?;
constructor(value: string);
/**
*
* @param value
*/
setName(value: string): this;
/**
*
* @param value
*/
setCoords(value: number[]): this;
/**
*
* @param value
*/
setLatLng(value: number[]): this;
/**
*
* @param value
*/
setStyle(value: CSSProperties): this;
/**
*
*/
build(): {
coords: number[];
name: string;
style: CSSProperties | undefined;
} | {
latLng: number[];
name: string;
style: CSSProperties | undefined;
};
}

View File

@@ -1,39 +0,0 @@
import { IMainMap, IMultiMapProps, IVectorMap } from "../../types";
import { IBuilder } from "./types";
export declare class MultiMapBuilder implements IBuilder<IMultiMapProps> {
private readonly main;
private maxLevel?;
private mapNameByCode?;
private mapUrlByCode?;
private getDrillDownMap?;
constructor(mainMap: IVectorMap, maxLevel?: number);
/**
*
* @param value
*/
setMainMap(value: IVectorMap): this;
/**
*
* @param value
*/
setMaxLevel(value: number): this;
/**
*
* @param value
*/
setMapNameByCode(value: (code: string) => string): this;
/**
*
* @param value
*/
setUrlByCode(value: (code: string) => string): this;
/**
*
* @param value
*/
setGetDrillDownMap(value: (code: string) => Promise<IVectorMap> | IVectorMap): this;
build(): {
main: IMainMap;
maxLevel: number | undefined;
};
}

View File

@@ -1,19 +0,0 @@
import { IAttributeSeries, ISeries } from "../../types";
import { IBuilder } from "./types";
export declare class SeriesBuilder implements IBuilder<ISeries> {
private markers?;
private regions?;
/**
*
* @param values
*/
addMarkersSeries(...values: IAttributeSeries[]): this;
/**
*
* @param values
*/
addRegionsSeries(...values: IAttributeSeries[]): this;
build(): {
[k: string]: unknown;
};
}

View File

@@ -1,32 +0,0 @@
import { CSSProperties } from "react";
import { ISVGElementStyleAttributes } from "../../types";
import { IBuilder } from "./types";
export declare class StyleBuilder implements IBuilder<ISVGElementStyleAttributes> {
private initial?;
private selected?;
private hover?;
private selectedHover?;
/**
*
* @param value
*/
setInitial(value: CSSProperties): this;
/**
*
* @param value
*/
setSelected(value: CSSProperties): this;
/**
*
* @param value
*/
setHover(value: CSSProperties): this;
/**
*
* @param value
*/
setSelectedHover(value: CSSProperties): this;
build(): {
[k: string]: unknown;
};
}

View File

@@ -1,108 +0,0 @@
import { ILabels, ISeries, ISVGElementStyleAttributes, IVectorMap, IVectorMapProps, Marker, OnRegionTipShow, SelectedEntities } from "../../types";
import { IBuilder } from "./types";
export declare class VectorMapBuilder implements IBuilder<IVectorMapProps> {
private map;
private backgroundColor?;
private zoomMin?;
private zoomMax?;
private markers?;
private markerStyle?;
private regionStyle?;
private regionsSelectable?;
private markersSelectable?;
private onRegionTipShow?;
private series?;
private labels?;
private selectedRegions?;
constructor(map: IVectorMap);
/**
*
* @param value
*/
setMap(value: IVectorMap): this;
/**
*
* @param value
*/
setBackgroundColor(value: string): this;
/**
*
* @param value
*/
setZoomMin(value: number): this;
/**
*
* @param value
*/
setZoomMax(value: number): this;
/**
*
* @param marker
*/
addMarker(marker: Marker): this;
/**
*
* @param value
*/
setMarkerStyle(value: ISVGElementStyleAttributes): this;
/**
*
* @param value
*/
setRegionStyle(value: ISVGElementStyleAttributes | ((code: string) => ISVGElementStyleAttributes)): this;
/**
*
* @param value
* @private
*/
setMarkersSelectable(value: boolean): this;
/**
*
* @param value
*/
setMarkers(value: Marker[]): this;
/**
*
* @private
* @param value
*/
setRegionsSelectable(value: boolean): this;
/**
*
* @private
* @param value
*/
setOnRegionTipShow(value: OnRegionTipShow): this;
/**
*
* @param value
*/
setSeries(value: ISeries): this;
/**
*
* @param values
*/
setLabels(values: ILabels): this;
/**
*
* @param value
*/
setSelectedRegions(value: SelectedEntities): this;
/**
*
*/
build(): {
map: IVectorMap;
series: ISeries | undefined;
backgroundColor: string | undefined;
zoomMax: number | undefined;
zoomMin: number | undefined;
markerStyle: ISVGElementStyleAttributes | undefined;
regionStyle: ISVGElementStyleAttributes | ((code: string) => ISVGElementStyleAttributes) | undefined;
markersSelectable: boolean | undefined;
regionsSelectable: boolean | undefined;
markers: Marker[] | undefined;
labels: ILabels | undefined;
selectedRegions: SelectedEntities | undefined;
};
}

View File

@@ -1,27 +0,0 @@
export declare const MapMock1: {
name: string;
content: {
insets: {
width: number;
top: number;
height: number;
bbox: {
y: number;
x: number;
}[];
left: number;
}[];
paths: {
V1: {
path: string;
name: string;
};
};
height: number;
projection: {
type: string;
centralMeridian: number;
};
width: number;
};
};

View File

@@ -1,8 +0,0 @@
export { VectorMapBuilder } from "./VectorMapBuilder";
export { MarkerBuilder } from "./MarkerBuilder";
export { StyleBuilder } from "./StyleBuilder";
export { AttributeSeriesBuilder } from "./AttributeSeriesBuilder";
export { SeriesBuilder } from "./SeriesBuilder";
export { LabelsBuilder } from "./LabelsBuilder";
export { LabelsPropsBuilder } from "./LabelsPropsBuilder";
export { MultiMapBuilder } from "./MultiMapBuilder";

View File

@@ -1,3 +0,0 @@
export interface IBuilder<T> {
build: () => T;
}

View File

@@ -1,9 +0,0 @@
/**
* remove undefined values from object
* @param object
*/
export declare const stripUndefinedValues: (object: {
[key: string]: unknown;
}) => {
[k: string]: unknown;
};

View File

@@ -1 +0,0 @@
export * from "./builders";

View File

@@ -1,44 +0,0 @@
{
"name": "@react-jvectormap/core",
"version": "1.0.4",
"description": "> TODO: description",
"author": "Mor Kadosh <kadoshms@gmail.com>",
"homepage": "https://github.com/kadoshms/react-jvectormap#readme",
"license": "ISC",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"jquery": "^3.6",
"react": "^16.8 || ^17 || ^18",
"react-dom": "^16.8 || ^17 || ^18"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kadoshms/react-jvectormap.git"
},
"scripts": {
"test": "jest",
"build": "rimraf dist && yarn run build:types && yarn run build:bundle",
"build:bundle": "webpack --mode development",
"build:types": "tsc --emitDeclarationOnly"
},
"bugs": {
"url": "https://github.com/kadoshms/react-jvectormap/issues"
},
"devDependencies": {
"@types/jquery": "^3.5.6",
"@types/react": "^17.0.24",
"jquery": "^3.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"webpack-bundle-analyzer": "^4.5.0"
},
"dependencies": {
"@react-jvectormap/lib": "^1.0.3",
"classnames": "^2.3.1"
},
"gitHead": "53a4ea6b33d647fef99940b044f140109fec0727"
}

View File

@@ -1,21 +0,0 @@
import React, { CSSProperties, FC, Ref } from "react";
import classNames from "classnames";
import styles from "./styles.module.scss";
interface IMapContainerProps {
style?: CSSProperties;
className?: string;
containerRef: Ref<HTMLDivElement>;
}
export const MapContainer: FC<IMapContainerProps> = ({
containerRef,
className,
style,
}) => (
<div
style={style}
className={classNames(styles.root, className)}
ref={containerRef as Ref<HTMLDivElement>}
/>
);

View File

@@ -1 +0,0 @@
export { MapContainer } from "./MapContainer";

View File

@@ -1,136 +0,0 @@
:global(.jvectormap-tip) {
position: absolute;
display: none;
border: solid 1px #cdcdcd;
border-radius: 3px;
background: #292929;
color: white;
font-family: sans-serif, Verdana;
font-size: smaller;
padding: 3px;
}
.root {
height: 100%;
width: 100%;
:global(svg) {
touch-action: none;
}
:global(.jvectormap-container) {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
touch-action: none;
}
:global(.jvectormap-zoomin) {
position: absolute;
left: 10px;
border-radius: 3px;
background: #292929;
padding: 3px;
color: white;
cursor: pointer;
line-height: 10px;
text-align: center;
box-sizing: content-box;
width: 10px;
height: 10px;
top: 10px;
}
:global(.jvectormap-zoomout) {
position: absolute;
left: 10px;
border-radius: 3px;
background: #292929;
padding: 3px;
color: white;
cursor: pointer;
line-height: 10px;
text-align: center;
box-sizing: content-box;
width: 10px;
height: 10px;
top: 30px;
}
:global(.jvectormap-goback) {
position: absolute;
left: 10px;
border-radius: 3px;
background: #292929;
color: white;
cursor: pointer;
line-height: 10px;
text-align: center;
box-sizing: content-box;
bottom: 10px;
z-index: 1000;
padding: 6px;
}
:global(.jvectormap-spinner) {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: center no-repeat
url(data:image/gif;base64,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);
}
:global(.jvectormap-legend-title) {
font-weight: bold;
font-size: 14px;
text-align: center;
}
:global(.jvectormap-legend-cnt) {
position: absolute;
}
:global(.jvectormap-legend-cnt-h) {
bottom: 0;
right: 0;
:global(.jvectormap-legend) {
float: left;
margin: 0 10px 10px 0;
padding: 3px 3px 1px 3px;
:global(.jvectormap-legend-tick) {
float: left;
}
}
:global(.jvectormap-legend-tick) {
width: 40px;
}
:global(.jvectormap-legend-tick-sample) {
height: 15px;
}
:global(.jvectormap-legend-tick-text) {
text-align: center;
}
}
:global(.jvectormap-legend-cnt-v) {
top: 0;
right: 0;
:global(.jvectormap-legend) {
margin: 10px 10px 0 0;
padding: 3px;
}
:global(.jvectormap-legend-tick-sample) {
height: 20px;
width: 20px;
display: inline-block;
vertical-align: middle;
}
:global(.jvectormap-legend-tick-text) {
display: inline-block;
vertical-align: middle;
line-height: 20px;
padding-left: 3px;
}
}
:global(.jvectormap-legend) {
background: black;
color: white;
border-radius: 3px;
}
:global(.jvectormap-legend-tick-text) {
font-size: 12px;
}
}

View File

@@ -1 +0,0 @@
export const root: string;

View File

@@ -1,39 +0,0 @@
import React, { FC, Ref, useLayoutEffect, useRef } from "react";
import $ from "jquery";
import { IMultiMapProps } from "../../types";
import { MapContainer } from "../MapContainer";
export const MultiMap: FC<IMultiMapProps> = ({
mapRef,
style,
className,
...props
}) => {
const containerRef = useRef<JQuery | null>(null);
useLayoutEffect(() => {
const mapContainer = containerRef.current;
const { main, ...rest } = props;
const {
map: { name, content },
...restMain
} = main;
$.fn.vectorMap("addMap", name, content);
if (mapContainer) {
$(mapContainer).multiMap({
main: {
...restMain,
map: name,
},
...rest,
});
}
}, [mapRef, props]);
return (
<MapContainer
style={style}
className={className}
containerRef={containerRef as Ref<HTMLDivElement>}
/>
);
};

View File

@@ -1 +0,0 @@
export { MultiMap } from "./MultiMap";

View File

@@ -1,62 +0,0 @@
import React, { FC, Ref, useEffect, useLayoutEffect, useRef } from "react";
import $ from "jquery";
import { IVectorMapProps, MapObject } from "../../types";
import { MapContainer } from "../MapContainer";
export const VectorMap: FC<IVectorMapProps> = ({
map,
mapRef,
style,
className,
series,
...props
}) => {
const containerRef = useRef<JQuery | null>(null);
useLayoutEffect(() => {
const mapContainer = containerRef.current;
if (!map) {
console.error("[react-jvectormap]: no map was loaded!");
}
const { name, content } = map;
$.fn.vectorMap("addMap", name, content);
if (mapContainer) {
$(mapContainer).vectorMap({
map: name,
series,
...props,
});
if (map && mapRef?.current === null) {
mapRef.current = $(mapContainer).vectorMap(
"get",
"mapObject",
) as unknown as MapObject;
}
}
}, [map, mapRef, props, series]);
useEffect(() => {
const mapContainer = containerRef.current;
if (series && mapContainer) {
const map = $(mapContainer).vectorMap("get", "mapObject");
const { markers = [], regions = [] } = series;
regions.forEach(({ values }, index) => {
if (values && map.series?.regions) {
map.series?.regions[index]?.clearAndSet(values);
}
});
markers.forEach(({ values }, index) => {
if (values && map.series?.markers) {
map.series?.markers[index]?.clearAndSet(values);
}
});
}
}, [series]);
return (
<MapContainer
className={className}
style={style}
containerRef={containerRef as Ref<HTMLDivElement>}
/>
);
};

View File

@@ -1 +0,0 @@
export { VectorMap } from "./VectorMap";

View File

@@ -1,2 +0,0 @@
export * from "./VectorMap";
export * from "./MultiMap";

View File

@@ -1,6 +0,0 @@
import { loadJVectorMap } from "@react-jvectormap/lib";
import $ from "jquery";
export * from "./components";
export * from "./utils";
loadJVectorMap($);

View File

@@ -1,410 +0,0 @@
import { CSSProperties, MutableRefObject, Ref } from "react";
export type Nullable<T> = null | T;
interface ISetFocusParams {
regions?: string[];
region?: string;
scale?: number;
lat?: number;
lng?: number;
x?: number;
y?: number;
animate?: boolean;
}
export interface IMapObject {
/**
* Add one marker to the map.
* @param key
* @param marker
* @param seriesData
*/
addMarker: (
key: string,
marker: Marker,
seriesData: IAttributeSeries[],
) => void;
/**
* Add set of marker to the map.
* @param key
*/
addMarkers: (markers: Marker[], seriesData: IAttributeSeries[]) => void;
/**
* Remove the selected state from all the currently selected markers.
*/
clearSelectedMarkers: () => void;
/**
* Remove the selected state from all the currently selected regions.
*/
clearSelectedRegions: () => void;
/**
* Get the name of a region
*/
getRegionName: (code: string) => void;
/**
* Return the codes of currently selected markers.
*/
getSelectedMarkers: () => Marker[];
/**
* Return the codes of currently selected regions.
*/
getSelectedRegions: () => IRegion[];
/**
* Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
*/
latLngToPoint: (lat: number, lng: number) => number[];
/**
* Converts cartesian coordinates into coordinates expressed as latitude and longitude.
*/
pointToLatLng: (x: number, y: number) => number[];
/**
* Gracefully remove the map and and all its accessories, unbind event handlers.
*/
remove: () => void;
/**
* Remove all markers from the map.
*/
removeAllMarkers: () => void;
/**
* Remove some markers from the map.
*/
removeMarkers: () => void;
/**
* Reset all the series and show the map with the initial zoom.
*/
reset: () => void;
/**
* Set background color of the map.
*/
setBackgroundColor: (backgroundColor: string) => void;
/**
* Set the map's viewport to the specific point and set zoom of the map to the specific level. Point and zoom level could be defined in two ways: using the code of some region to focus on or a central point and zoom level as numbers.
*/
setFocus: (params: ISetFocusParams) => void;
/**
* Set or remove selected state for the markers.
* @param keys
*/
setSelectedMarkers: (
keys: string | string[] | { [key: string]: boolean },
) => void;
/**
* Set or remove selected state for the regions.
* @param keys
*/
setSelectedRegions: (
keys: string | string[] | { [key: string]: boolean },
) => void;
/**
* Synchronize the size of the map with the size of the container. Suitable in situations where the size of the container is changed programmatically or container is shown after it became visible.
*/
updateSize: () => void;
}
export type MapObject = IMapObject;
interface IMapComponent {
/**
* Optional ref for accessing map methods
*/
mapRef?: MutableRefObject<MapObject | null>;
/**
* Container class Name
*/
className?: string;
/**
* Container inline CSS-in-JS style
*/
style?: CSSProperties;
}
export interface IVectorMapProps extends IMapComponent {
/**
* Map content definition
*/
map: IVectorMap;
/**
* Background color of the map in CSS format.
*/
backgroundColor?: string;
/**
* Indicates the minimum zoom ratio which could be reached zooming the map. Default value is 1.
*/
zoomMin?: number;
/**
* Indicates the maximum zoom ratio which could be reached zooming the map. Default value is 8.
*/
zoomMax?: number;
/**
* Indicates the multiplier used to zoom map with +/- buttons. Default value is 1.6.
*/
zoomStep?: number;
/**
* When set to true map could be zoomed using mouse scroll. Default value is true.
*/
zoomOnScroll?: boolean;
/**
* Indicates whether or not to animate changing of map zoom with zoom buttons.
*/
zoomAnimate?: boolean;
/**
* This parameter sets the initial position and scale of the map viewport.
*/
focusOn?: IFocus;
/**
* When set to true, the map pans when being dragged. Default value is true.
*/
panOnDrag?: boolean;
/**
* When set to true regions of the map could be selected. Default value is false.
*/
regionsSelectable?: boolean;
/**
* Allow only one region to be selected at the moment. Default value is false.
*/
regionsSelectableOne?: boolean;
/**
* Set of markers to add to the map during initialization. In case of array is provided, codes of markers will be set as string representations of array indexes. Each marker is represented by latLng (array of two numeric values), name (string which will be show on marker's tip) and any marker styles.
*/
markers?: Marker[];
/**
* When set to true markers on the map could be selected. Default value is false.
*/
markersSelectable?: boolean;
/**
* Allow only one marker to be selected at the moment. Default value is false.
*/
markersSelectableOne?: boolean;
/**
* Set the styles for the map's regions. Each region or marker has four states: initial (default state), hover (when the mouse cursor is over the region or marker), selected (when region or marker is selected), selectedHover (when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states.
*/
regionStyle?:
| ISVGElementStyleAttributes
| ((code: string) => ISVGElementStyleAttributes);
/**
* Set the styles for the regions' labels. Each region or marker has four states: initial (default state), hover (when the mouse cursor is over the region or marker), selected (when region or marker is selected), selectedHover (when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states.
*/
regionLabelStyle?: ISVGElementStyleAttributes;
/**
* Set initially selected markers.
*/
selectedMarkers?: string[] | { [region: string]: boolean } | string;
/**
* Set the styles for the map's markers. Any parameter suitable for regionStyle could be used as well as numeric parameter r to set the marker's radius.
*/
markerStyle?: ISVGElementStyleAttributes | IImageElementStyleAttributes;
/**
* Will be called on region click event.
*/
onRegionClick?: (event: JQuery.Event, code: string) => void;
/**
* Will be called when region is (de)selected. isSelected parameter of the callback indicates whether region is selected or not. selectedRegions contains codes of all currently selected regions.
*/
onRegionSelected?: (
event: JQuery.Event,
code: string,
isSelected: boolean,
selectedRegions: string[],
) => void;
/**
* Will be called right before the region tip is going to be shown.
*/
onRegionTipShow?: OnRegionTipShow;
/**
* Will be called on region mouse over event.
*/
onRegionOver?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on region mouse out event.
*/
onRegionOut?: (event: JQuery.Event, code: string) => void;
/**
* Will be called right before the marker tip is going to be shown.
*/
onMarkerTipShow?: (event: JQuery.Event, el: Element, code: string) => void;
/**
* Will be called on marker mouse over event.
*/
onMarkerOver?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on marker mouse out event.
*/
onMarkerOut?: (event: JQuery.Event, code: string) => void;
/**
* Will be called on marker click event.
*/
onMarkerClick?: (event: JQuery.Event, code: string) => void;
/**
* Will be called when marker is (de)selected. isSelected parameter of the callback indicates whether marker is selected or not. selectedMarkers contains codes of all currently selected markers.
*/
onMarkerSelected?: (
event: JQuery.Event,
code: string,
isSelected: boolean,
selectedMarkers: string[],
) => void;
/**
* Triggered when the map's viewport is changed (map was panned or zoomed).
*/
onViewportChange?: (event: JQuery.Event, scale: number) => void;
/**
* Set initially selected regions.
* examples: ["US-CA"] | { "US-CA": true } | "US-CA"
*/
selectedRegions?: SelectedEntities;
/**
* Object with two keys: markers and regions. Each of which is an array of series configs to be applied to the respective map elements.
*/
series?: ISeries;
/**
* Object with two keys: markers and regions. Each of which is an array of labels configs to be applied to the respective map elements.
*/
labels?: ILabels;
}
export interface IMainMap {
map: IVectorMap;
}
export interface IMultiMapProps extends IMapComponent {
/**
* Maximum number of levels user can go through
*/
maxLevel?: number;
/**
* Config of the main map.
*/
main: IMainMap;
/**
* Function to generate map name by region code. Default value is:
*/
mapNameByCode?: (code: string) => string;
/**
* Function to generate map url by region code. Default value is:
*/
mapUrlByCode?: (code: string) => string;
/**
* Function to manually retrieve map data
* @param code
*/
getDrillDownMap?: (code: string) => Promise<IVectorMap> | IVectorMap;
}
interface IBBox {
x: number;
y: number;
}
interface IInset {
width: number;
height: number;
top: number;
left: number;
bbox: IBBox[];
}
interface IProjection {
type: string;
centralMeridian: number;
}
export interface IVectorMap {
name: string;
content: {
insets: IInset[];
paths: PathsDefinition;
height: number;
width: number;
projection: IProjection;
};
}
interface IFocus {
scale: number;
x: number;
y: number;
region?: string;
lat?: number;
lng?: number;
animate?: boolean;
}
export interface ISVGElementStyleAttributes {
initial?: CSSProperties;
hover?: CSSProperties;
selected?: CSSProperties;
selectedHover?: CSSProperties;
}
interface IImageElementStyleAttributes {
url: string;
offset?: number[];
}
type PathsDefinition = { [key: string]: { path: string; name: string } };
export interface ISeries {
regions?: IAttributeSeries[];
markers?: IAttributeSeries[];
}
type Scale = { [key: string]: string } | number[] | string[];
type Values = { [key: string]: string | number };
export type NormalizeFunctionType = "linear" | "polynomial";
export interface IAttributeSeries {
attribute: string;
values?: number[] | { [key: string]: number };
scale?: Scale;
normalizeFunction?: NormalizeFunctionType | ((value?: number) => string);
}
export interface IRegion {
scale: Scale;
values: Values;
attribute: string;
normalizeFunction?: NormalizeFunctionType | ((value?: number) => string);
}
interface IMarkerBase {
name: string;
style?: CSSProperties;
}
interface IMarkerWithCoords extends IMarkerBase {
coords: number[];
}
interface IMarkerWithLatLng extends IMarkerBase {
latLng: number[];
}
export type RenderLabel = (code: string) => void | string;
export type GetOffsets = (code: string) => { [key: string | number]: number[] };
export interface ILabelsProps {
render: RenderLabel;
offsets: GetOffsets;
}
export interface ILabels {
regions?: ILabelsProps;
markers?: ILabelsProps;
}
export type Marker = IMarkerWithCoords | IMarkerWithLatLng;
export type OnRegionTipShow = (
event: JQuery.Event,
el: Element,
code: string,
) => void;
export type SelectedEntities =
| string[]
| { [region: string]: boolean }
| string;

View File

@@ -1,58 +0,0 @@
import { IAttributeSeries, NormalizeFunctionType } from "../../types";
import { IBuilder } from "./types";
export class AttributeSeriesBuilder implements IBuilder<IAttributeSeries> {
private attribute: string;
private scale?: number[];
private values?: number[];
private normalizeFunction?: NormalizeFunctionType;
constructor(attribute: string) {
this.attribute = attribute;
}
/**
*
* @param value
*/
public setAttribute(value: string) {
this.attribute = value;
return this;
}
/**
*
* @param value
*/
public setScale(value: number[]) {
this.scale = value;
return this;
}
/**
*
* @param value
*/
public setValues(value: number[]) {
this.values = value;
return this;
}
/**
*
* @param value
*/
public setNormalizeFunction(value: NormalizeFunctionType) {
this.normalizeFunction = value;
return this;
}
public build() {
return {
scale: this.scale,
values: this.values,
attribute: this.attribute,
normalizeFunction: this.normalizeFunction,
};
}
}

View File

@@ -1,39 +0,0 @@
import { ILabels, ILabelsProps } from "../../types";
import { stripUndefinedValues } from "./utils";
import { IBuilder } from "./types";
export class LabelsBuilder implements IBuilder<ILabels> {
private markers?: ILabelsProps[];
private regions?: ILabelsProps[];
/**
*
* @param values
*/
public addMarkersLabelProps(...values: ILabelsProps[]) {
if (!this.markers) {
this.markers = [];
}
this.markers.push(...values);
return this;
}
/**
*
* @param values
*/
public addRegionsLabelProps(...values: ILabelsProps[]) {
if (!this.regions) {
this.regions = [];
}
this.regions.push(...values);
return this;
}
public build() {
return stripUndefinedValues({
markers: this.markers,
regions: this.regions,
});
}
}

View File

@@ -1,40 +0,0 @@
import { GetOffsets, ILabelsProps, RenderLabel } from "../../types";
import { IBuilder } from "./types";
export class LabelsPropsBuilder implements IBuilder<ILabelsProps> {
private render: RenderLabel;
private offsets: GetOffsets;
public constructor(render: RenderLabel, offsets: GetOffsets) {
this.render = render;
this.offsets = offsets;
}
/**
*
* @param render
*/
public setRender(render: RenderLabel) {
this.render = render;
return this;
}
/**
*
* @param offsets
*/
public setOffsets(offsets: GetOffsets) {
this.offsets = offsets;
return this;
}
/**
*
*/
public build() {
return {
render: this.render,
offsets: this.offsets,
};
}
}

View File

@@ -1,78 +0,0 @@
import { CSSProperties } from "react";
import { Marker } from "../../types";
import { IBuilder } from "./types";
export class MarkerBuilder implements IBuilder<Marker> {
private name: string;
private coords?: number[];
private latLng?: number[];
private style?: CSSProperties;
constructor(value: string) {
this.name = value;
}
/**
*
* @param value
*/
public setName(value: string) {
this.name = value;
return this;
}
/**
*
* @param value
*/
public setCoords(value: number[]) {
this.latLng = undefined;
this.coords = value;
return this;
}
/**
*
* @param value
*/
public setLatLng(value: number[]) {
this.coords = undefined;
this.latLng = value;
return this;
}
/**
*
* @param value
*/
public setStyle(value: CSSProperties) {
this.style = value;
return this;
}
/**
*
*/
public build() {
const commonProps = {
name: this.name,
style: this.style,
};
if (this.coords) {
return {
...commonProps,
coords: this.coords,
};
} else if (this.latLng) {
return {
...commonProps,
latLng: this.latLng,
};
}
return {
...commonProps,
latLng: [0, 0],
};
}
}

View File

@@ -1,78 +0,0 @@
import { IMainMap, IMultiMapProps, IVectorMap } from "../../types";
import { IBuilder } from "./types";
import { stripUndefinedValues } from "./utils";
export class MultiMapBuilder implements IBuilder<IMultiMapProps> {
private readonly main: IMainMap;
private maxLevel?: number;
private mapNameByCode?: (code: string) => string;
private mapUrlByCode?: (code: string) => string;
private getDrillDownMap?: (code: string) => Promise<IVectorMap> | IVectorMap;
public constructor(mainMap: IVectorMap, maxLevel = 1) {
this.main = { map: mainMap };
this.maxLevel = maxLevel;
}
/**
*
* @param value
*/
public setMainMap(value: IVectorMap) {
this.main.map = value;
return this;
}
/**
*
* @param value
*/
public setMaxLevel(value: number) {
this.maxLevel = value;
return this;
}
/**
*
* @param value
*/
public setMapNameByCode(value: (code: string) => string) {
this.mapNameByCode = value;
return this;
}
/**
*
* @param value
*/
public setUrlByCode(value: (code: string) => string) {
this.mapUrlByCode = value;
return this;
}
/**
*
* @param value
*/
public setGetDrillDownMap(
value: (code: string) => Promise<IVectorMap> | IVectorMap,
) {
this.getDrillDownMap = value;
return this;
}
build() {
const baseProps = {
main: this.main,
maxLevel: this.maxLevel,
};
return {
...baseProps,
...stripUndefinedValues({
mapNameByCode: this.mapNameByCode,
mapUrlByCode: this.mapUrlByCode,
getDrillDownMap: this.getDrillDownMap,
}),
};
}
}

View File

@@ -1,39 +0,0 @@
import { IAttributeSeries, ISeries } from "../../types";
import { stripUndefinedValues } from "./utils";
import { IBuilder } from "./types";
export class SeriesBuilder implements IBuilder<ISeries> {
private markers?: IAttributeSeries[];
private regions?: IAttributeSeries[];
/**
*
* @param values
*/
public addMarkersSeries(...values: IAttributeSeries[]) {
if (!this.markers) {
this.markers = [];
}
this.markers.push(...values);
return this;
}
/**
*
* @param values
*/
public addRegionsSeries(...values: IAttributeSeries[]) {
if (!this.regions) {
this.regions = [];
}
this.regions.push(...values);
return this;
}
public build() {
return stripUndefinedValues({
markers: this.markers,
regions: this.regions,
});
}
}

View File

@@ -1,56 +0,0 @@
import { CSSProperties } from "react";
import { ISVGElementStyleAttributes } from "../../types";
import { stripUndefinedValues } from "./utils";
import { IBuilder } from "./types";
export class StyleBuilder implements IBuilder<ISVGElementStyleAttributes> {
private initial?: CSSProperties;
private selected?: CSSProperties;
private hover?: CSSProperties;
private selectedHover?: CSSProperties;
/**
*
* @param value
*/
public setInitial(value: CSSProperties) {
this.initial = value;
return this;
}
/**
*
* @param value
*/
public setSelected(value: CSSProperties) {
this.selected = value;
return this;
}
/**
*
* @param value
*/
public setHover(value: CSSProperties) {
this.hover = value;
return this;
}
/**
*
* @param value
*/
public setSelectedHover(value: CSSProperties) {
this.selectedHover = value;
return this;
}
public build() {
return stripUndefinedValues({
selected: this.selected,
selectedHover: this.selectedHover,
hover: this.hover,
initial: this.initial,
});
}
}

View File

@@ -1,189 +0,0 @@
import {
ILabels,
ISeries,
ISVGElementStyleAttributes,
IVectorMap,
IVectorMapProps,
Marker,
OnRegionTipShow,
SelectedEntities,
} from "../../types";
import { IBuilder } from "./types";
export class VectorMapBuilder implements IBuilder<IVectorMapProps> {
private map: IVectorMap;
private backgroundColor?: string;
private zoomMin?: number;
private zoomMax?: number;
private markers?: Marker[];
private markerStyle?: ISVGElementStyleAttributes;
private regionStyle?:
| ISVGElementStyleAttributes
| ((code: string) => ISVGElementStyleAttributes);
private regionsSelectable?: boolean;
private markersSelectable?: boolean;
private onRegionTipShow?: OnRegionTipShow;
private series?: ISeries;
private labels?: ILabels;
private selectedRegions?: SelectedEntities = [];
public constructor(map: IVectorMap) {
this.map = map;
}
/**
*
* @param value
*/
public setMap(value: IVectorMap) {
this.map = value;
return this;
}
/**
*
* @param value
*/
public setBackgroundColor(value: string) {
this.backgroundColor = value;
return this;
}
/**
*
* @param value
*/
public setZoomMin(value: number) {
this.zoomMin = value;
return this;
}
/**
*
* @param value
*/
public setZoomMax(value: number) {
this.zoomMax = value;
return this;
}
/**
*
* @param marker
*/
public addMarker(marker: Marker) {
if (!this.markers) {
this.markers = [];
}
this.markers.push(marker);
return this;
}
/**
*
* @param value
*/
public setMarkerStyle(value: ISVGElementStyleAttributes) {
this.markerStyle = value;
return this;
}
/**
*
* @param value
*/
public setRegionStyle(
value:
| ISVGElementStyleAttributes
| ((code: string) => ISVGElementStyleAttributes),
) {
this.regionStyle = value;
return this;
}
/**
*
* @param value
* @private
*/
public setMarkersSelectable(value: boolean) {
this.markersSelectable = value;
return this;
}
/**
*
* @param value
*/
public setMarkers(value: Marker[]) {
this.markers = value;
return this;
}
/**
*
* @private
* @param value
*/
public setRegionsSelectable(value: boolean) {
this.regionsSelectable = value;
return this;
}
/**
*
* @private
* @param value
*/
public setOnRegionTipShow(value: OnRegionTipShow) {
this.onRegionTipShow = value;
return this;
}
/**
*
* @param value
*/
public setSeries(value: ISeries) {
this.series = value;
return this;
}
/**
*
* @param values
*/
public setLabels(values: ILabels) {
this.labels = values;
return this;
}
/**
*
* @param value
*/
public setSelectedRegions(value: SelectedEntities) {
this.selectedRegions = value;
return this;
}
/**
*
*/
public build() {
return {
map: this.map,
series: this.series,
backgroundColor: this.backgroundColor,
zoomMax: this.zoomMax,
zoomMin: this.zoomMin,
markerStyle: this.markerStyle,
regionStyle: this.regionStyle,
markersSelectable: this.markersSelectable,
regionsSelectable: this.regionsSelectable,
markers: this.markers,
labels: this.labels,
selectedRegions: this.selectedRegions,
};
}
}

View File

@@ -1,27 +0,0 @@
import { AttributeSeriesBuilder } from "../AttributeSeriesBuilder";
describe("AttributeSeriesBuilder", () => {
it("should build an attribute series", () => {
const series = new AttributeSeriesBuilder("r")
.setValues([10, 10, 10])
.setScale([10, 10])
.setNormalizeFunction("polynomial")
.build();
expect(series).toEqual({
attribute: "r",
scale: [10, 10],
values: [10, 10, 10],
normalizeFunction: "polynomial",
});
});
it("should build an attribute series and change it's values", () => {
const series = new AttributeSeriesBuilder("r");
series.setAttribute("x").setScale([10, 10]).setValues([0]);
expect(series).toEqual({
attribute: "x",
scale: [10, 10],
values: [0],
});
});
});

View File

@@ -1,41 +0,0 @@
import { MarkerBuilder } from "../MarkerBuilder";
describe("MarkerBuilder", () => {
it("should build a simple MarkerBuilder with latLng", () => {
const marker = new MarkerBuilder("test-marker").setLatLng([10, 10]).build();
expect(marker).toEqual({
name: "test-marker",
latLng: [10, 10],
});
});
it("should build a simple MarkerBuilder with coords", () => {
const marker = new MarkerBuilder("test-marker").setCoords([10, 10]).build();
expect(marker).toEqual({
name: "test-marker",
coords: [10, 10],
});
});
it("should build a simple MarkerBuilder with both props defined", () => {
const marker = new MarkerBuilder("test-marker")
.setLatLng([10, 10])
.setCoords([11, 11])
.build();
expect(marker).toEqual({
name: "test-marker",
coords: [11, 11],
});
});
it("should build a simple MarkerBuilder with both props defined, oposite case", () => {
const marker = new MarkerBuilder("test-marker")
.setCoords([10, 10])
.setLatLng([11, 11])
.build();
expect(marker).toEqual({
name: "test-marker",
latLng: [11, 11],
});
});
});

View File

@@ -1,35 +0,0 @@
import { MapMock1 } from "./mocks/MapMock1";
import { MultiMapBuilder } from "../MultiMapBuilder";
jest.mock("../MarkerBuilder", () => ({
MarkerBuilder: jest.fn().mockImplementation(() => ({
build: () => ({
name: "test",
coords: [10, 10],
}),
})),
}));
describe("MultiMapBuilder", () => {
it("should build a simple MultiMap", () => {
const multiMap = new MultiMapBuilder(MapMock1).setMaxLevel(2);
expect(multiMap).toEqual({
main: {
map: MapMock1,
},
maxLevel: 2,
});
});
it("should build a simple MultiMap with a URL getter", () => {
const func = (code: string) => code;
const multiMap = new MultiMapBuilder(MapMock1, 2).setUrlByCode(func);
expect(multiMap).toEqual({
main: {
map: MapMock1,
},
mapUrlByCode: func,
maxLevel: 2,
});
});
});

View File

@@ -1,37 +0,0 @@
import { SeriesBuilder } from "../SeriesBuilder";
import { AttributeSeriesBuilder } from "../AttributeSeriesBuilder";
jest.mock("../MarkerBuilder", () => ({
AttributeSeriesBuilder: jest.fn().mockImplementation(() => ({
build: () => ({
scale: [10, 20],
values: [1, 2, 3],
attribute: "r",
}),
})),
}));
describe("AttributeSeriesBuilder", () => {
it("should add two marker series", () => {
const ms1 = new AttributeSeriesBuilder("r").build();
const ms2 = new AttributeSeriesBuilder("r").build();
const series = new SeriesBuilder().addMarkersSeries(ms1, ms2).build();
expect(series).toEqual({
markers: [
{ attribute: "r", scale: [10, 20], values: [1, 2, 3] },
{ attribute: "r", scale: [10, 20], values: [1, 2, 3] },
],
});
});
it("should add two region series", () => {
const rs1 = new AttributeSeriesBuilder("r").build();
const rs2 = new AttributeSeriesBuilder("r").build();
const series = new SeriesBuilder().addRegionsSeries(rs1, rs2).build();
expect(series).toEqual({
regions: [
{ attribute: "r", scale: [10, 20], values: [1, 2, 3] },
{ attribute: "r", scale: [10, 20], values: [1, 2, 3] },
],
});
});
});

View File

@@ -1,23 +0,0 @@
import { StyleBuilder } from "../StyleBuilder";
describe("StyleBuilder", () => {
it("should build a simple style builder", () => {
const style = new StyleBuilder()
.setHover({ fill: "red" })
.setInitial({ fill: "blue" })
.setSelectedHover({ stroke: "black" })
.build();
expect(style).toEqual({
initial: {
fill: "blue",
},
hover: {
fill: "red",
},
selectedHover: {
stroke: "black",
},
});
});
});

View File

@@ -1,31 +0,0 @@
import { VectorMapBuilder } from "../VectorMapBuilder";
import { MarkerBuilder } from "../MarkerBuilder";
import { MapMock1 } from "./mocks/MapMock1";
jest.mock("../MarkerBuilder", () => ({
MarkerBuilder: jest.fn().mockImplementation(() => ({
build: () => ({
name: "test",
coords: [10, 10],
}),
})),
}));
describe("VectorMapBuilder", () => {
it("should build a simple VectorMap with markers", () => {
const marker1 = new MarkerBuilder("test1").build();
const marker2 = new MarkerBuilder("test2").build();
const marker3 = new MarkerBuilder("test3").build();
const vectorMap = new VectorMapBuilder(MapMock1)
.addMarker(marker1)
.addMarker(marker2)
.addMarker(marker3)
.build();
expect(vectorMap).toEqual({
map: MapMock1,
series: {
markers: [marker1, marker2, marker3],
},
});
});
});

View File

@@ -1,26 +0,0 @@
export const MapMock1 = {
name: "map-mock-1",
content: {
insets: [
{
width: 200,
top: 370,
height: 100,
bbox: [
{ y: -100, x: -100 },
{ y: -100, x: -100 },
],
left: 10,
},
],
paths: {
V1: {
path: "M759.82,228.61l0.64,-1.34l-0.16,-0.64l0.65,-0.59l-0.36,-0.68l0.65,-0.53l-0.04,-1.04l0.41,-0.18l0.06,-0.65l0.56,-0.07l0.37,-0.53l0.66,-1.7l0.94,-0.11l0.2,-0.72l0.35,-0.03l0.21,-1.09l-0.46,-0.69l0.88,-0.42l0.11,-0.54l2.48,-0.24l-0.28,1.91l-5.78,7.44l-0.16,0.9l-0.99,0.98l-0.74,3.32l-0.49,-1.56l0.38,-0.59l-0.11,-0.6ZM641.4,241.28l7.18,-1.96l1.03,-1.75l3.06,-0.93l0.34,-1.44l2.1,-1.18l0.43,-1.57l5.11,-2.52l5.14,-3.99l0.13,0.53l0.67,0.45l0.07,1.16l1.55,1.56l1.29,0.3l1.66,1.22l1.27,0.15l0.78,-0.2l0.89,-0.86l1.14,-0.27l0.71,-1.01l2.15,1.62l1.46,-0.65l2.17,-0.43l0.66,0.17l1.13,-0.6l0.48,-0.66l-0.25,-0.86l0.24,-0.22l1.58,0.77l3.37,-1.55l0.6,0.64l0.6,0.05l2.55,-1.47l0.35,-0.72l-0.33,-0.48l1.05,-0.67l0.23,-0.54l-0.18,-0.51l-0.77,-0.46l1.18,-2.26l3.23,-3.39l0.91,-1.64l0.35,-1.51l1.93,-1.77l-0.01,-0.8l0.91,-0.91l0.69,-1.32l0.6,-2.51l1.05,0.36l0.73,1.6l3.32,1.02l0.59,-0.12l1.45,-1.85l0.65,-1.86l0.84,-0.71l0.3,-1.33l1.12,-1.68l1.45,0.93l0.62,-0.02l1.85,-2.41l1.12,-0.06l0.72,-0.87l0.88,-0.4l0.77,-1.37l1.75,-1.7l0.23,-2.16l0.85,-1.31l0.13,-1.64l7.33,5.42l0.62,-0.15l1.41,-3.06l2.36,0.44l0.44,0.58l0.9,0.38l-0.85,1.2l0.37,0.92l1.28,1.0l2.27,0.46l0.67,1.15l1.31,0.4l1.59,1.71l-0.16,2.14l-1.67,0.43l-0.29,0.48l-0.93,0.35l-1.52,3.89l-0.32,0.03l-0.17,0.48l0.71,0.91l-0.35,0.74l1.83,0.4l2.46,-0.69l0.6,-0.48l0.09,0.51l-0.59,0.47l1.49,1.26l0.13,0.96l1.35,0.74l1.75,0.22l0.67,0.51l0.87,-0.36l0.72,0.21l0.12,0.51l1.06,0.64l0.18,0.98l0.8,0.1l1.1,0.9l2.34,1.06l0.13,0.73l-0.64,-0.47l-0.62,0.25l0.37,1.6l-0.43,0.76l0.32,0.4l-0.53,0.55l0.0,0.46l-0.43,-0.15l-0.93,-1.04l-0.83,0.27l-1.64,-2.26l-0.47,-0.07l-0.22,-0.51l-0.55,0.14l-1.0,-1.33l-0.96,-0.54l-0.23,-0.57l-0.72,-0.5l-0.34,-1.17l-0.55,-0.67l-1.16,-0.37l-0.82,-0.86l-1.05,-0.19l-0.48,0.35l0.28,0.79l0.95,0.21l0.42,0.66l1.17,0.32l0.4,0.42l0.0,1.27l2.1,1.82l1.22,1.86l1.58,0.87l0.93,1.97l0.83,0.4l1.28,-0.08l0.77,0.55l-0.47,0.42l0.19,0.52l1.64,0.69l0.13,0.6l0.35,0.18l-0.14,1.44l-0.27,-0.68l-0.82,-0.25l-0.78,-1.01l-0.62,0.14l-0.51,1.15l0.39,0.74l-0.23,0.43l0.94,0.56l-1.31,0.28l-4.35,-4.95l-0.55,-0.03l-0.38,0.67l0.11,0.53l1.69,1.67l1.37,2.1l2.17,1.48l1.2,-0.26l0.21,0.88l0.97,0.38l-0.45,0.39l0.15,0.64l0.82,0.05l-0.25,0.82l-1.52,0.58l-0.36,-0.78l-2.47,-1.62l-0.02,-1.25l-0.42,-0.63l-0.75,-0.27l-1.18,0.28l-1.38,-0.66l-0.06,-0.94l-0.66,-0.22l-0.69,1.28l-0.97,-1.32l-1.01,0.32l-0.49,-0.43l-0.97,0.16l-1.95,-0.5l-0.55,0.77l0.23,0.48l3.62,0.92l0.64,-0.44l0.34,0.8l1.1,0.61l1.78,0.14l0.56,0.73l0.71,0.26l0.54,-0.28l0.14,1.99l1.14,0.39l1.42,1.26l0.22,0.54l-0.71,0.72l0.43,0.53l1.79,-0.69l0.75,0.15l0.72,0.73l0.67,-0.14l-0.4,-1.79l2.59,0.79l0.92,0.06l0.79,-0.37l0.95,3.06l-0.47,0.51l-0.14,2.49l-0.87,-0.68l-0.25,0.68l-62.64,0.19l-17.72,-0.53l-10.57,-0.86l-0.83,0.37l-25.18,-0.12Z",
name: "V1",
},
},
height: 100,
projection: { type: "mill", centralMeridian: 0 },
width: 100,
},
};

View File

@@ -1,8 +0,0 @@
export { VectorMapBuilder } from "./VectorMapBuilder";
export { MarkerBuilder } from "./MarkerBuilder";
export { StyleBuilder } from "./StyleBuilder";
export { AttributeSeriesBuilder } from "./AttributeSeriesBuilder";
export { SeriesBuilder } from "./SeriesBuilder";
export { LabelsBuilder } from "./LabelsBuilder";
export { LabelsPropsBuilder } from "./LabelsPropsBuilder";
export { MultiMapBuilder } from "./MultiMapBuilder";

View File

@@ -1,3 +0,0 @@
export interface IBuilder<T> {
build: () => T;
}

View File

@@ -1,8 +0,0 @@
/**
* remove undefined values from object
* @param object
*/
export const stripUndefinedValues = (object: { [key: string]: unknown }) =>
Object.fromEntries(
Object.entries(object).filter((entry) => entry[1] !== undefined),
);

View File

@@ -1 +0,0 @@
export * from "./builders";

View File

@@ -1,10 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"declaration": true,
"declarationDir": "dist",
"emitDeclarationOnly": false
}
}

View File

@@ -1,28 +0,0 @@
import jQuery from "@types/jquery";
import { IRegion, Marker } from "../src/types";
type DataSeries = {
clearAndSet: (values: { [key: string]: number } | number[]) => void;
};
declare global {
interface Window {
jQuery: typeof jQuery;
$: typeof jQuery;
}
interface JQuery {
vectorMap(...args: unknown[]): JQuery;
multiMap(...args: unknown[]): JQuery;
series?: {
regions?: DataSeries[];
markers?: DataSeries[];
};
}
}
declare module "jvectormap-next";
declare module "*.scss" {
const styles: { [className: string]: string };
export default styles;
}

View File

@@ -1,31 +0,0 @@
const path = require("path");
module.exports = {
entry: path.resolve(__dirname, "./src/index.ts"),
output: {
path: path.resolve(__dirname, "dist"),
filename: "index.js",
libraryTarget: "umd",
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "babel-loader",
},
{
test: /\.s[ac]ss$/i,
use: ["style-loader", "css-loader", "sass-loader"],
},
],
},
externals: {
react: "react",
"react-dom": "reactDOM",
jquery: "jquery",
},
plugins: []
};