Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Feat] Add type definition (#1116)

Shan He25c6d2e568d0
diff --git a/.gitignore b/.gitignore
index 68944749e..8725630bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,8 @@ build/
umd/
*/**/dist/
+typedoc/
+
*/**/yarn.lock
yarn-error.log
*/**/package-lock.json
diff --git a/docs/RFC/table-class.md b/docs/RFC/table-class.md
index 14e703ea2..b4d4cec26 100644
--- a/docs/RFC/table-class.md
+++ b/docs/RFC/table-class.md
@@ -4,67 +4,54 @@ Replace kepler.gl dataset with table class
```js
export type KeplerDataset = {
- id: string,
- label: string,
- color: number[], // rgb
-
- // fields and row
- fields: KeplerField[],
- allData: any[][],
-
- // for Filter
- allIndexes: number[],
- filteredIndex: number[],
- filteredIdxCPU: number[],
- filteredIndexForDomain: number[],
-
- gpuFilter: {
- filterRange: number[][],
- filterValueUpdateTriggers: any,
- filterValueAccessor: any
- },
- filterRecord: {
- dynamicDomain: any,
- fixedDomain: any,
- cpu: any,
- gpu: any
- },
- filterRecordCPU: {
- dynamicDomain: any,
- fixedDomain: any,
- cpu: any,
- gpu: any
- }
- changedFilters: any,
-
- // for suggest lat + lng column pairs, and can be extend to also support auto assign visuals
+ id: string;
+ label?: string;
+ color: RGBColor;
+
+ // fields and data
+ fields: KeplerField[];
+ allData: any[][];
+
+ allIndexes: number[];
+ filteredIndex: number[];
+ filteredIdxCPU: number[];
+ filteredIndexForDomain: number[];
fieldPairs: {
- defaultName: string,
- pair: any,
- suffix: string[]
- }[],
+ defaultName: string;
+ pair: any;
+ suffix: string[];
+ }[];
+ gpuFilter: {
+ filterRange: number[][];
+ filterValueUpdateTriggers: any;
+ filterValueAccessor: any;
+ };
+ filterRecord: FilterRecord;
+ filterRecordCPU: FilterRecord;
+ changedFilters: any;
+ // table-injected metadata
sortColumn?: {
// column name: sorted idx
- [key: string]: number[]
- },
- sortOrder?: string, // ASCENDING | DESCENDING | UNSORT
+ [key: string]: number[];
+ };
+ sortOrder?: string; // ASCENDING | DESCENDING | UNSORT
- pinnedColumns?: string[],
+ pinnedColumns?: string[];
// table-injected metadata
- metadata?: object
+ metadata?: object;
};
export type KeplerField = {
- analyzerType: string,
- id: string,
- name: string,
- format: string,
- tableFieldIndex: numberstring,
- type: string,
+ analyzerType: string;
+ id: string;
+ name: string;
+ format: string;
+ tableFieldIndex: numberstring;
+ type: string;
// meta data, storing domain and mappedValues
- filterProps?: any
+ filterProps?: any;
};
```
diff --git a/package.json b/package.json
index 5a066c3d3..1853d7620 100644
--- a/package.json
+++ b/package.json
@@ -47,9 +47,11 @@
"add-licence": "uber-licence",
"prepublish": "uber-licence && yarn build && yarn build:umd",
"docs": "babel-node ./scripts/documentation.js",
+ "typedoc": "typedoc --theme markdown --out typedoc --inputFiles ./src/reducers --inputFiles ./src/actions --excludeExternals --excludeNotExported --excludePrivate",
"example-version": "babel-node ./scripts/edit-version.js",
"prettier-all": "prettier --write '{src,examples,test}/**/*.js'",
- "lint": "eslint src test webpack examples/*.js examples/**/src website/*.js website/src --fix",
+ "lint": "yarn typescript && eslint src test webpack examples/*.js examples/**/src website/*.js website/src --fix",
+ "typescript": "tsc --noEmit",
"web": "(yarn && yarn install:web && yarn start:web)",
"deploy": "yarn install:web && (cd website && yarn build)",
"clean": "rm -rf node_modules examples/**/node_modules website/node_modules",
@@ -146,6 +148,7 @@
"s2-geometry": "^1.2.10",
"supercluster": "^6.0.1",
"type-analyzer": "0.2.5",
+ "typedoc": "^0.17.7",
"uber-licence": "^3.1.1",
"viewport-mercator-project": "^6.0.0",
"wellknown": "^0.5.0"
@@ -183,6 +186,7 @@
"@deck.gl/test-utils": "^8.0.11",
"@luma.gl/test-utils": "^8.0.5",
"@probe.gl/test-utils": "^3.0.1",
+ "@types/d3-array": "^2.0.0",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.0",
"babel-plugin-istanbul": "^5.1.1",
@@ -224,6 +228,8 @@
"tap-spec": "^4.1.1",
"tape": "4.8.0",
"tape-catch": "^1.0.6",
+ "typedoc-plugin-markdown": "^2.2.17",
+ "typescript": "3.8.3",
"url-loader": "^0.5.7",
"watchify": "^3.6.1",
"webpack": "^4.29.0",
diff --git a/src/actions/action-wrapper.js b/src/actions/action-wrapper.js
index e3f7f941e..4cc05d730 100644
--- a/src/actions/action-wrapper.js
+++ b/src/actions/action-wrapper.js
@@ -55,7 +55,7 @@ export const getActionForwardAddress = id => `${ADDRESS_PREFIX}${id.toUpperCase(
* @memberof forwardActions
* @param {string} id - The id to forward to
* @param {Object} action - the action object {type: string, payload: *}
- * @returns {{type: string, payload: {type: string: payload: *, meta: {_id_: string}, meta: {_forward_: string, _addr_: string}}}}
+ * @returns {{type: string, payload: {type: string, payload: *, meta: {_id_: string}, meta: {_forward_: string, _addr_: string}}}}
* @public
* @example
*
@@ -178,5 +178,6 @@ export const _updateProperty = (state, id, nextState) =>
* @public
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const forwardActions = null;
/* eslint-enable no-unused-vars */
diff --git a/src/actions/actions.d.ts b/src/actions/actions.d.ts
new file mode 100644
index 000000000..aa121e743
--- /dev/null
+++ b/src/actions/actions.d.ts
@@ -0,0 +1,96 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+import ActionTypes from 'constants/action-types';
+import {ParsedConfig} from '../schemas';
+import {RGBColor} from 'reducers/types';
+import {Bounds} from 'reducers/map-state-updaters';
+import {MapInfo} from 'reducers/vis-state-updaters';
+
+/**
+ * Input dataest parsed to addDataToMap
+ */
+export type ProtoDataset = {
+ info: {
+ id: string;
+ label: string;
+ format?: string;
+ color?: RGBColor;
+ };
+ data: {
+ fields: {
+ name: string;
+ type?: string;
+ format?: string;
+ }[];
+ rows: any[][];
+ };
+
+ // table-injected metadata
+ metadata?: any;
+};
+
+export type AddDataToMapOptions = {
+ centerMap?: boolean;
+ readOnly?: boolean;
+ keepExistingConfig?: boolean;
+};
+
+export type AddDataToMaoPayload = {
+ datasets: ProtoDataset[];
+ options?: AddDataToMapOptions;
+ config?: ParsedConfig;
+ info?: Partial<MapInfo>
+};
+
+export function addDataToMap(
+ data: AddDataToMaoPayload
+): {type: ActionTypes.ADD_DATA_TO_MAP; payload: AddDataToMaoPayload};
+
+export function resetMapConfig(): {type: ActionTypes.RESET_MAP_CONFIG};
+
+export type ReceiveMapConfigPayload = {
+ config: ParsedConfig;
+ options?: AddDataToMapOptions;
+ bounds?: Bounds;
+};
+
+export function receiveMapConfig(
+ config: ParsedConfig,
+ options: AddDataToMapOptions
+): {
+ type: ActionTypes.RECEIVE_MAP_CONFIG;
+ payload: ReceiveMapConfigPayload;
+};
+
+export type KeplerGlInitPayload = {
+ mapboxApiAccessToken?: string;
+ mapboxApiUrl?: string;
+ mapStylesReplaceDefault?: boolean;
+};
+
+export function keplerGlInit(options?: {
+ mapboxApiAccessToken?: string;
+ mapboxApiUrl?: string;
+ mapStylesReplaceDefault?: boolean;
+}): {
+ type: ActionTypes.INIT;
+ payload: KeplerGlInitPayload;
+};
diff --git a/src/actions/actions.js b/src/actions/actions.js
index 740f62758..03d6d51d6 100644
--- a/src/actions/actions.js
+++ b/src/actions/actions.js
@@ -149,14 +149,16 @@ export const receiveMapConfig = createAction(ActionTypes.RECEIVE_MAP_CONFIG, (co
/**
* Initialize kepler.gl reducer. It is used to pass in `mapboxApiAccessToken` to `mapStyle` reducer.
* @memberof main
- * @param {Object} payload
- * @param {string} payload.mapboxApiAccessToken - mapboxApiAccessToken to be saved to mapStyle reducer
- * @param {string} payload.mapboxApiUrl - mapboxApiUrl to be saved to mapStyle reducer.
- * @param {Boolean} payload.mapStylesReplaceDefault - mapStylesReplaceDefault to be saved to mapStyle reducer
+ * @param {object} payload
+ * @param payload.mapboxApiAccessToken - mapboxApiAccessToken to be saved to mapStyle reducer
+ * @param payload.mapboxApiUrl - mapboxApiUrl to be saved to mapStyle reducer.
+ * @param payload.mapStylesReplaceDefault - mapStylesReplaceDefault to be saved to mapStyle reducer
+ * @type {typeof import('./actions').keplerGlInit}
* @public
*/
export const keplerGlInit = createAction(
ActionTypes.INIT,
+ // @ts-ignore
({mapboxApiAccessToken, mapboxApiUrl, mapStylesReplaceDefault} = {}) => ({
mapboxApiAccessToken,
mapboxApiUrl,
@@ -173,5 +175,6 @@ export const keplerGlInit = createAction(
* @public
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const main = null;
/* eslint-enable no-unused-vars */
diff --git a/src/actions/identity-actions.d.ts b/src/actions/identity-actions.d.ts
new file mode 100644
index 000000000..1d16c0538
--- /dev/null
+++ b/src/actions/identity-actions.d.ts
@@ -0,0 +1,51 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+import ActionTypes from 'constants/action-types';
+
+export type RegisterEntryUpdaterAction = {
+ payload: {
+ id: string;
+ mint: boolean;
+ mapboxApiAccessToken: string;
+ mapboxApiUrl: string;
+ mapStylesReplaceDefault: boolean;
+ };
+};
+
+export function registerEntry(
+ entry: RegisterEntryUpdaterAction['payload']
+): {
+ type: ActionTypes.REGISTER_ENTRY;
+ payload: RegisterEntryUpdaterAction['payload'];
+};
+
+export function deleteEntry(id: string): {type: ActionTypes.DELETE_ENTRY; payload: string};
+
+export function renameEntry(
+ oldId: string,
+ newId: string
+): {
+ type: ActionTypes.RENAME_ENTRY;
+ payload: {
+ oldId: string;
+ newId: string;
+ };
+};
diff --git a/src/actions/identity-actions.js b/src/actions/identity-actions.js
index 9629f9a09..2c6ba67a1 100644
--- a/src/actions/identity-actions.js
+++ b/src/actions/identity-actions.js
@@ -85,5 +85,6 @@ export const renameEntry = createAction(ActionTypes.RENAME_ENTRY, (oldId, newId)
* @public
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const rootActions = null;
/* eslint-enable no-unused-vars */
diff --git a/src/actions/index.d.ts b/src/actions/index.d.ts
new file mode 100644
index 000000000..c29660429
--- /dev/null
+++ b/src/actions/index.d.ts
@@ -0,0 +1,22 @@
+// Actions
+export * from './actions';
+
+// kepler.gl actions accessible outside component
+export * from './vis-state-actions';
+export * from './ui-state-actions';
+export * from './map-state-actions';
+export * from './map-style-actions';
+export * from './identity-actions';
+
+// TODO - Add typescript defs for these functions
+// Dispatch
+// export {
+// _actionFor,
+// forwardTo,
+// getActionForwardAddress,
+// isForwardAction,
+// unwrap,
+// wrapTo
+// } from './action-wrapper';
+
+export {default as ActionTypes} from '../constants/action-types';
diff --git a/src/actions/map-state-actions.d.ts b/src/actions/map-state-actions.d.ts
new file mode 100644
index 000000000..ad6aeefc1
--- /dev/null
+++ b/src/actions/map-state-actions.d.ts
@@ -0,0 +1,46 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+import ActionTypes from 'constants/action-types';
+import {ValueOf, Merge} from '../reducers/types';
+import {Bounds, Viewport} from '../reducers/map-state-updaters';
+
+export type TogglePerspectiveUpdaterAction = {};
+export function togglePerspective(): Merge<
+ TogglePerspectiveUpdaterAction,
+ {type: ActionTypes.TOGGLE_PERSPECTIVE}
+>;
+
+export type FitBoundsUpdaterAction = {payload: Bounds};
+export function fitBounds(
+ payload: Bounds
+): Merge<FitBoundsUpdaterAction, {type: ActionTypes.FIT_BOUNDS}>;
+
+export type UpdateMapUpdaterAction = {payload: Viewport};
+export function updateMap(
+ payload: Viewport
+): Merge<UpdateMapUpdaterAction, {type: ActionTypes.UPDATE_MAP}>;
+
+export type ToggleSplitMapUpdaterAction = {
+ payload: number;
+};
+export function toggleSplitMap(
+ payload: number
+): Merge<ToggleSplitMapUpdaterAction, {type: ActionTypes.TOGGLE_SPLIT_MAP}>;
diff --git a/src/actions/map-state-actions.js b/src/actions/map-state-actions.js
index 2dc2103d2..7d2d77f56 100644
--- a/src/actions/map-state-actions.js
+++ b/src/actions/map-state-actions.js
@@ -85,5 +85,6 @@ export const toggleSplitMap = createAction(ActionTypes.TOGGLE_SPLIT_MAP, index =
* @public
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const mapStateActions = null;
/* eslint-enable no-unused-vars */
diff --git a/src/actions/map-style-actions.d.ts b/src/actions/map-style-actions.d.ts
new file mode 100644
index 000000000..0c9c18314
--- /dev/null
+++ b/src/actions/map-style-actions.d.ts
@@ -0,0 +1,116 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+import ActionTypes from 'constants/action-types';
+import {Merge, RGBColor} from '../reducers/types';
+import {
+ InputStyle,
+ MapStyles,
+ VisibleLayerGroups,
+ MapStyles
+} from '../reducers/map-style-updaters';
+import {MapState} from '../reducers/map-state-updaters';
+
+export function addCustomMapStyle(): {type: ActionTypes.ADD_CUSTOM_MAP_STYLE};
+
+/** INPUT_MAP_STYLE */
+export type InputMapStyleUpdaterAction = {
+ payload: {
+ inputStyle: Partial<InputStyle>;
+ mapState?: MapState
+ }
+};
+
+export function inputMapStyle(
+ inputStyle: InputMapStyleUpdaterAction['payload']['inputStyle'],
+ mapState?: InputMapStyleUpdaterAction['payload']['mapState']
+): Merge<InputMapStyleUpdaterAction, {type: ActionTypes.INPUT_MAP_STYLE}>;
+
+/** MAP_CONFIG_CHANGE */
+export type MapConfigChangeUpdaterAction = {
+ payload: {
+ visibleLayerGroups?: VisibleLayerGroups;
+ topLayerGroups?: VisibleLayerGroups;
+ };
+};
+
+export function mapConfigChange(
+ mapStyle: MapConfigChangeUpdaterAction['payload']
+): Merge<MapConfigChangeUpdaterAction, {type: ActionTypes.MAP_CONFIG_CHANGE}>;
+
+/** REQUEST_MAP_STYLES */
+export type RequestMapStylesUpdaterAction = {
+ payload: {
+ [key: string]: {
+ id: string;
+ label?: string;
+ url: string;
+ icon?: string;
+ layerGroups?: string;
+ };
+ };
+};
+export function requestMapStyles(
+ mapStyles: RequestMapStylesUpdaterAction['payload']
+): Merge<RequestMapStylesUpdaterAction, {type: ActionTypes.REQUEST_MAP_STYLES}>;
+
+/** LOAD_MAP_STYLES */
+export type LoadMapStylesUpdaterAction = {
+ payload: MapStyles;
+};
+export function loadMapStyles(
+ newStyles: LoadMapStylesUpdaterAction['payload']
+): Merge<LoadMapStylesUpdaterAction, {type: ActionTypes.LOAD_MAP_STYLES}>;
+
+/** LOAD_MAP_STYLE_ERR */
+export type LoadMapStyleErrUpdaterAction = {
+ payload: Error;
+};
+export function loadMapStyleErr(
+ error: LoadMapStyleErrUpdaterAction['payload']
+): Merge<LoadMapStyleErrUpdaterAction, {type: ActionTypes.LOAD_MAP_STYLE_ERR}>;
+
+/** MAP_STYLE_CHANGE */
+export type MapStyleChangeUpdaterAction = {
+ payload: string;
+};
+export function mapStyleChange(
+ styleType: MapStyleChangeUpdaterAction['payload']
+): Merge<MapStyleChangeUpdaterAction, {type: ActionTypes.MAP_STYLE_CHANGE}>;
+
+/** LOAD_CUSTOM_MAP_STYLE */
+export type LoadCustomMapStyleUpdaterAction = {
+ payload: {
+ icon?: string;
+ style?: object;
+ error?: Error;
+ };
+};
+export function loadCustomMapStyle(
+ customMapStyle: LoadCustomMapStyleUpdaterAction['payload']
+): Merge<LoadCustomMapStyleUpdaterAction, {type: ActionTypes.LOAD_CUSTOM_MAP_STYLE}>;
+
+/** SET_3D_BUILDING_COLOR */
+export type Set3dBuildingColorUpdaterAction = {
+ payload: RGBColor;
+};
+export function set3dBuildingColor(
+ color: Set3dBuildingColorUpdaterAction['payload']
+): Merge<Set3dBuildingColorUpdaterAction, {type: ActionTypes.SET_3D_BUILDING_COLOR}>;
diff --git a/src/actions/map-style-actions.js b/src/actions/map-style-actions.js
index 7e88669b0..68fe9a465 100644
--- a/src/actions/map-style-actions.js
+++ b/src/actions/map-style-actions.js
@@ -27,6 +27,7 @@ import ActionTypes from 'constants/action-types';
* It should not be called from outside kepler.gl without a valid `inputStyle` in the `mapStyle` reducer.
* param {void}
* @memberof mapStyleActions
+ * @type {typeof import('./map-style-actions').addCustomMapStyle}
* @public
*/
export const addCustomMapStyle = createAction(ActionTypes.ADD_CUSTOM_MAP_STYLE);
@@ -34,14 +35,15 @@ export const addCustomMapStyle = createAction(ActionTypes.ADD_CUSTOM_MAP_STYLE);
/**
* Input a custom map style object
* @memberof mapStyleActions
- * @param {Object} inputStyle
- * @param {string} inputStyle.url - style url e.g. `'mapbox://styles/heshan/xxxxxyyyyzzz'`
- * @param {string} inputStyle.id - style url e.g. `'custom_style_1'`
- * @param {Object} inputStyle.style - actual mapbox style json
- * @param {string} inputStyle.name - style name
- * @param {Object} inputStyle.layerGroups - layer groups that can be used to set map layer visibility
- * @param {Object} inputStyle.icon - icon image data url
- * @param {Object} mapState - mapState is optional
+ * @param inputStyle
+ * @param inputStyle.url - style url e.g. `'mapbox://styles/heshan/xxxxxyyyyzzz'`
+ * @param inputStyle.id - style id e.g. `'custom_style_1'`
+ * @param inputStyle.style - actual mapbox style json
+ * @param inputStyle.label - style name
+ * @param inputStyle.accessToken - mapbox access token
+ * @param inputStyle.icon - icon image data url
+ * @param [mapState] - mapState is optional
+ * @type {typeof import('./map-style-actions').inputMapStyle}
* @public
*/
export const inputMapStyle = createAction(ActionTypes.INPUT_MAP_STYLE, (inputStyle, mapState) => ({
@@ -52,7 +54,8 @@ export const inputMapStyle = createAction(ActionTypes.INPUT_MAP_STYLE, (inputSty
/**
* Update `visibleLayerGroups`to change layer group visibility
* @memberof mapStyleActions
- * @param {Object} mapStyle new config `{visibleLayerGroups: {label: false, road: true, background: true}}`
+ * @param mapStyle new config `{visibleLayerGroups: {label: false, road: true, background: true}}`
+ * @type {typeof import('./map-style-actions').mapConfigChange}
* @public
*/
export const mapConfigChange = createAction(ActionTypes.MAP_CONFIG_CHANGE, mapStyle => mapStyle);
@@ -60,7 +63,7 @@ export const mapConfigChange = createAction(ActionTypes.MAP_CONFIG_CHANGE, mapSt
/**
* Request map style style object based on style.url.
* @memberof mapStyleActions
- * @param {Array<Object>} mapStyles
+ * @type {typeof import('./map-style-actions').requestMapStyles}
* @public
*/
export const requestMapStyles = createAction(
@@ -70,7 +73,8 @@ export const requestMapStyles = createAction(
/**
* Callback when load map style success
* @memberof mapStyleActions
- * @param {Object} newStyles a `{[id]: style}` mapping
+ * @param newStyles a `{[id]: style}` mapping
+ * @type {typeof import('./map-style-actions').loadMapStyles}
* @public
*/
export const loadMapStyles = createAction(ActionTypes.LOAD_MAP_STYLES, newStyles => newStyles);
@@ -78,7 +82,8 @@ export const loadMapStyles = createAction(ActionTypes.LOAD_MAP_STYLES, newStyles
/**
* Callback when load map style error
* @memberof mapStyleActions
- * @param {*} error
+ * @param error
+ * @type {typeof import('./map-style-actions').loadMapStyleErr}
* @public
*/
export const loadMapStyleErr = createAction(ActionTypes.LOAD_MAP_STYLE_ERR, error => error);
@@ -86,7 +91,8 @@ export const loadMapStyleErr = createAction(ActionTypes.LOAD_MAP_STYLE_ERR, erro
/**
* Change to another map style. The selected style should already been loaded into `mapStyle.mapStyles`
* @memberof mapStyleActions
- * @param {string} styleType the style to change to
+ * @param styleType the style to change to
+ * @type {typeof import('./map-style-actions').mapStyleChange}
* @public
*/
export const mapStyleChange = createAction(ActionTypes.MAP_STYLE_CHANGE, styleType => styleType);
@@ -94,10 +100,11 @@ export const mapStyleChange = createAction(ActionTypes.MAP_STYLE_CHANGE, styleTy
/**
* Callback when a custom map style object is received
* @memberof mapStyleActions
- * @param {Object} customMapStyle
- * @param {string} customMapStyle.icon
- * @param {Object} customMapStyle.style
- * @param {*} customMapStyle.error
+ * @param customMapStyle
+ * @param customMapStyle.icon
+ * @param customMapStyle.style
+ * @param customMapStyle.error
+ * @type {typeof import('./map-style-actions').loadCustomMapStyle}
* @public
*/
export const loadCustomMapStyle = createAction(
@@ -109,7 +116,8 @@ export const loadCustomMapStyle = createAction(
/**
* Set 3d building layer group color
* @memberof mapStyleActions
- * @param {Array} color - [r, g, b]
+ * @param color - [r, g, b]
+ * @type {typeof import('./map-style-actions').set3dBuildingColor}
* @public
*/
export const set3dBuildingColor = createAction(ActionTypes.SET_3D_BUILDING_COLOR, color => color);
@@ -122,5 +130,6 @@ export const set3dBuildingColor = createAction(ActionTypes.SET_3D_BUILDING_COLOR
* @public
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const mapStyleActions = null;
/* eslint-enable no-unused-vars */
diff --git a/src/actions/provider-actions.d.ts b/src/actions/provider-actions.d.ts
new file mode 100644
index 000000000..1d22b8778
--- /dev/null
+++ b/src/actions/provider-actions.d.ts
@@ -0,0 +1,203 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+import {SavedMap} from 'schemas';
+import {MapListItem, Provider} from 'cloud-providers';
+
+type ProviderActionTypes = {
+ EXPORT_FILE_TO_CLOUD: string;
+ EXPORT_FILE_SUCCESS: string;
+ EXPORT_FILE_ERROR: string;
+ RESET_PROVIDER_STATUS: string;
+ SET_CLOUD_PROVIDER: string;
+ POST_SAVE_LOAD_SUCCESS: string;
+ LOAD_CLOUD_MAP: string;
+ LOAD_CLOUD_MAP_SUCCESS: string;
+ LOAD_CLOUD_MAP_ERROR: string;
+ GET_SAVED_MAPS: string;
+ GET_SAVED_MAPS_SUCCESS: string;
+ GET_SAVED_MAPS_ERROR: string;
+};
+
+/** EXPORT_FILE_TO_CLOUD */
+export type MapData = {
+ map: SavedMap;
+ thumbnail: Blob | null;
+};
+export type ExportFileOptions = {
+ isPublic?: boolean;
+ overwrite?: boolean;
+};
+export type OnErrorCallBack = (error: Error) => any;
+export type OnSuccessCallBack = (p: {
+ response: any;
+ provider: Provider;
+ options: ExportFileOptions;
+}) => any;
+
+export type ExportFileToCloudPayload = {
+ mapData: MapData;
+ provider: Provider;
+ options: ExportFileOptions;
+ onSuccess?: OnSuccessCallBack;
+ onError?: OnErrorCallBack;
+ closeModal?: boolean;
+};
+
+export function exportFileToCloud(
+ p: ExportFileToCloudPayload
+): {
+ type: ProviderActionTypes.EXPORT_FILE_TO_CLOUD;
+ payload: ExportFileToCloudPayload;
+};
+
+/** EXPORT_FILE_SUCCESS */
+export type ExportFileSuccessPayload = {
+ response: any;
+ provider: Provider;
+ options?: ExportFileOptions;
+ onSuccess?: OnSuccessCallBack;
+ closeModal?: boolean;
+};
+export function exportFileSuccess(
+ p: ExportFileSuccessPayload
+): {
+ type: ProviderActionTypes.EXPORT_FILE_SUCCESS;
+ payload: ExportFileSuccessPayload;
+};
+
+/** EXPORT_FILE_ERROR */
+export type ExportFileErrorPayload = {
+ error: any;
+ provider: Provider;
+ options?: Options;
+ onError?: OnErrorCallBack;
+};
+
+export function exportFileError(
+ p: ExportFileErrorPayload
+): {
+ type: ProviderActionTypes.EXPORT_FILE_ERROR;
+ payload: ExportFileErrorPayload;
+};
+
+/** RESET_PROVIDER_STATUS */
+export function resetProviderStatus(): {
+ type: ProviderActionTypes.RESET_PROVIDER_STATUS;
+};
+
+/** SET_CLOUD_PROVIDER */
+export type SetCloudProviderPayload = string;
+export function setCloudProvider(
+ p: SetCloudProviderPayload
+): {
+ type: ProviderActionTypes.SET_CLOUD_PROVIDER;
+ payload: SetCloudProviderPayload;
+};
+
+/** POST_SAVE_LOAD_SUCCESS */
+export type PostSaveLoadSuccessPayload = string;
+export function postSaveLoadSuccess(
+ p: PostSaveLoadSuccessPayload
+): {
+ type: ProviderActionTypes.POST_SAVE_LOAD_SUCCESS;
+ payload: PostSaveLoadSuccessPayload;
+};
+
+/** LOAD_CLOUD_MAP */
+type LoadCloudMapSuccessCallback = (p: {
+ response: any;
+ loadParams: any;
+ provider: Provider;
+}) => any;
+export type LoadCloudMapPayload = {
+ loadParams: any;
+ provider: string;
+ onSuccess?: any;
+ onError?: OnErrorCallBack;
+};
+export function loadCloudMap(
+ p: LoadCloudMapPayload
+): {
+ type: ProviderActionTypes.LOAD_CLOUD_MAP;
+ payload: LoadCloudMapPayload;
+};
+
+/** LOAD_CLOUD_MAP_SUCCESS */
+export type LoadCloudMapSuccessPayload = {
+ response: any;
+ loadParams: any;
+ provider: Provider;
+ onSuccess?: LoadCloudMapSuccessCallback;
+ onError?: OnErrorCallBack;
+};
+export function loadCloudMapSuccess(
+ p: LoadCloudMapSuccessPayload
+): {
+ type: ProviderActionTypes.LOAD_CLOUD_MAP_SUCCESS;
+ payload: LoadCloudMapSuccessPayload;
+};
+
+/** LOAD_CLOUD_MAP_ERROR */
+export type LoadCloudMapErrorPayload = {
+ error: any;
+ provider: Provider;
+ onError?: OnErrorCallBack;
+};
+export function loadCloudMapError(
+ p: LoadCloudMapErrorPayload
+): {
+ type: ProviderActionTypes.LOAD_CLOUD_MAP_ERROR;
+ payload: LoadCloudMapErrorPayload;
+};
+
+/** GET_SAVED_MAPS */
+export type GetSavedMapsPayload = string;
+export function getSavedMaps(
+ p: GetSavedMapsPayload
+): {
+ type: ProviderActionTypes.GET_SAVED_MAPS;
+ payload: GetSavedMapsPayload;
+};
+
+/** GET_SAVED_MAPS_SUCCESS */
+export type GetSavedMapsSuccessPayload = {
+ visualizations: MapListItem[];
+ provider: string;
+};
+export function getSavedMapsSuccess(
+ p: GetSavedMapsSuccessPayload
+): {
+ type: ProviderActionTypes.GET_SAVED_MAPS_SUCCESS;
+ payload: GetSavedMapsSuccessPayload;
+};
+
+/** GET_SAVED_MAPS_ERROR */
+export type GetSavedMapsErrorPayload = {
+ error: any;
+ provider: string;
+};
+export function getSavedMapsError(
+ p: GetSavedMapsErrorPayload
+): {
+ type: ProviderActionTypes.GET_SAVED_MAPS_ERROR;
+ payload: GetSavedMapsErrorPayload;
+};
+
+export const ActionTypes: ProviderActionTypes;
diff --git a/src/actions/provider-actions.js b/src/actions/provider-actions.js
index 442aabe4a..ddca70c9b 100644
--- a/src/actions/provider-actions.js
+++ b/src/actions/provider-actions.js
@@ -19,55 +19,76 @@
// THE SOFTWARE.
import {createAction} from 'redux-actions';
-import keyMirror from 'keymirror';
-import {addPrefix} from 'constants/action-types';
+import {ACTION_PREFIX} from 'constants/action-types';
-export const ActionTypes = addPrefix(
- keyMirror({
- EXPORT_FILE_TO_CLOUD: null,
- EXPORT_FILE_SUCCESS: null,
- EXPORT_FILE_ERROR: null,
- RESET_PROVIDER_STATUS: null,
- SET_CLOUD_PROVIDER: null,
- POST_SAVE_LOAD_SUCCESS: null,
- LOAD_CLOUD_MAP: null,
- LOAD_CLOUD_MAP_SUCCESS: null,
- LOAD_CLOUD_MAP_ERROR: null,
- GET_SAVED_MAPS: null,
- GET_SAVED_MAPS_SUCCESS: null,
- GET_SAVED_MAPS_ERROR: null
- })
-);
+/** @type {import('./provider-actions').ProviderActionTypes} */
+export const ActionTypes = {
+ EXPORT_FILE_TO_CLOUD: `${ACTION_PREFIX}EXPORT_FILE_TO_CLOUD`,
+ EXPORT_FILE_SUCCESS: `${ACTION_PREFIX}EXPORT_FILE_SUCCESS`,
+ EXPORT_FILE_ERROR: `${ACTION_PREFIX}EXPORT_FILE_ERROR`,
+ RESET_PROVIDER_STATUS: `${ACTION_PREFIX}RESET_PROVIDER_STATUS`,
+ SET_CLOUD_PROVIDER: `${ACTION_PREFIX}SET_CLOUD_PROVIDER`,
+ POST_SAVE_LOAD_SUCCESS: `${ACTION_PREFIX}POST_SAVE_LOAD_SUCCESS`,
+ LOAD_CLOUD_MAP: `${ACTION_PREFIX}LOAD_CLOUD_MAP`,
+ LOAD_CLOUD_MAP_SUCCESS: `${ACTION_PREFIX}LOAD_CLOUD_MAP_SUCCESS`,
+ LOAD_CLOUD_MAP_ERROR: `${ACTION_PREFIX}LOAD_CLOUD_MAP_ERROR`,
+ GET_SAVED_MAPS: `${ACTION_PREFIX}GET_SAVED_MAPS`,
+ GET_SAVED_MAPS_SUCCESS: `${ACTION_PREFIX}GET_SAVED_MAPS_SUCCESS`,
+ GET_SAVED_MAPS_ERROR: `${ACTION_PREFIX}GET_SAVED_MAPS_ERROR`
+};
+/**
+ * Call provider to upload file to cloud
+ * @param mapData
+ * @param provider
+ * @param options
+ * @param onSuccess
+ * @param onError
+ * @param closeModal
+ * @type {typeof import('./provider-actions').exportFileToCloud}
+ */
export const exportFileToCloud = createAction(ActionTypes.EXPORT_FILE_TO_CLOUD, payload => payload);
+/**
+ * @type {typeof import('./provider-actions').exportFileSuccess}
+ */
export const exportFileSuccess = createAction(ActionTypes.EXPORT_FILE_SUCCESS, payload => payload);
+/** @type {typeof import('./provider-actions').exportFileError} */
export const exportFileError = createAction(ActionTypes.EXPORT_FILE_ERROR, payload => payload);
+/** @type {typeof import('./provider-actions').postSaveLoadSuccess} */
export const postSaveLoadSuccess = createAction(
ActionTypes.POST_SAVE_LOAD_SUCCESS,
message => message
);
+/** @type {typeof import('./provider-actions').resetProviderStatus} */
export const resetProviderStatus = createAction(ActionTypes.RESET_PROVIDER_STATUS);
+/** @type {typeof import('./provider-actions').setCloudProvider} */
export const setCloudProvider = createAction(ActionTypes.SET_CLOUD_PROVIDER, provider => provider);
+/** @type {typeof import('./provider-actions').loadCloudMap} */
export const loadCloudMap = createAction(ActionTypes.LOAD_CLOUD_MAP, payload => payload);
+/** @type {typeof import('./provider-actions').loadCloudMapSuccess} */
export const loadCloudMapSuccess = createAction(
ActionTypes.LOAD_CLOUD_MAP_SUCCESS,
payload => payload
);
+/** @type {typeof import('./provider-actions').loadCloudMapError} */
export const loadCloudMapError = createAction(ActionTypes.LOAD_CLOUD_MAP_ERROR, payload => payload);
+/** @type {typeof import('./provider-actions').getSavedMaps} */
export const getSavedMaps = createAction(ActionTypes.GET_SAVED_MAPS, provider => provider);
+/** @type {typeof import('./provider-actions').getSavedMapsSuccess} */
export const getSavedMapsSuccess = createAction(
ActionTypes.GET_SAVED_MAPS_SUCCESS,
payload => payload
);
+/** @type {typeof import('./provider-actions').getSavedMapsError} */
export const getSavedMapsError = createAction(ActionTypes.GET_SAVED_MAPS_ERROR, payload => payload);
diff --git a/src/actions/ui-state-actions.d.ts b/src/actions/ui-state-actions.d.ts
new file mode 100644
index 000000000..c3ae8e02a
--- /dev/null
+++ b/src/actions/ui-state-actions.d.ts
@@ -0,0 +1,183 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+import ActionTypes from 'constants/action-types';
+import {Merge} from '../reducers/types';
+
+/** TOGGLE_SIDE_PANEL */
+export type ToggleSidePanelUpdaterAction = {
+ payload: string;
+};
+export function toggleSidePanel(
+ id: string
+): Merge<ToggleSidePanelUpdaterAction, {type: ActionTypes.TOGGLE_SIDE_PANEL}>;
+
+/** TOGGLE_MODAL */
+export type ToggleModalUpdaterAction = {
+ payload: string | null;
+};
+export function toggleModal(
+ id: string | null
+): Merge<ToggleModalUpdaterAction, {type: ActionTypes.TOGGLE_MODAL}>;
+
+/** SHOW_EXPORT_DROPDOWN */
+export type ShowExportDropdownUpdaterAction = {
+ payload: string;
+};
+export function showExportDropdown(
+ id: string
+): Merge<ShowExportDropdownUpdaterAction, {type: ActionTypes.SHOW_EXPORT_DROPDOWN}>;
+
+/** HIDE_EXPORT_DROPDOWN */
+export function hideExportDropdown(): {type: ActionTypes.HIDE_EXPORT_DROPDOWN};
+
+/** TOGGLE_MAP_CONTROL */
+export type ToggleMapControlUpdaterAction = {
+ payload: {
+ panelId: string;
+ index: number;
+ };
+};
+export function toggleMapControl(
+ panelId,
+ index
+): Merge<ToggleMapControlUpdaterAction, {type: ActionTypes.TOGGLE_MAP_CONTROL}>;
+
+/** OPEN_DELETE_MODAL */
+export type OpenDeleteModalUpdaterAction = {
+ payload: string;
+};
+export function openDeleteModal(
+ datasetId: string
+): Merge<OpenDeleteModalUpdaterAction, {type: ActionTypes.OPEN_DELETE_MODAL}>;
+
+/** ADD_NOTIFICATION */
+export type AddNotificationUpdaterAction = {
+ payload: object;
+};
+export function addNotification(
+ notification: object
+): Merge<
+ AddNotificationUpdaterAction,
+ {
+ type: ActionTypes.ADD_NOTIFICATION;
+ }
+>;
+
+/** REMOVE_NOTIFICATION */
+export type RemoveNotificationUpdaterAction = {
+ payload: string;
+};
+export function removeNotification(
+ id: string
+): Merge<RemoveNotificationUpdaterAction, {type: ActionTypes.REMOVE_NOTIFICATION}>;
+
+/** SET_EXPORT_IMAGE_SETTING */
+export type SetExportImageSettingUpdaterAction = {
+ payload: {ratio?: string; resolution?: string; legend?: string};
+};
+export function setExportImageSetting(newSetting: {
+ ratio?: string;
+ resolution?: string;
+ legend?: string;
+}): Merge<SetExportImageSettingUpdaterAction, {type: ActionTypes.SET_EXPORT_IMAGE_SETTING}>;
+
+/** START_EXPORTING_IMAGE */
+export function startExportingImage(): {type: ActionTypes.START_EXPORTING_IMAGE};
+
+/** SET_EXPORT_IMAGE_DATA_URI */
+export type SetExportImageDataUriUpdaterAction = {
+ payload: string;
+};
+export function setExportImageDataUri(): Merge<
+ SetExportImageDataUriUpdaterAction,
+ {type: ActionTypes.SET_EXPORT_IMAGE_DATA_URI}
+>;
+
+/** SET_EXPORT_IMAGE_ERROR */
+export type SetExportImageErrorUpdaterAction = {
+ payload: Error;
+};
+export function setExportImageError(
+ error: Error
+): Merge<SetExportImageErrorUpdaterAction, {type: ActionTypes.SET_EXPORT_IMAGE_ERROR}>;
+
+/** CLEANUP_EXPORT_IMAGE */
+export function cleanupExportImage(): {type: ActionTypes.CLEANUP_EXPORT_IMAGE};
+
+/** SET_EXPORT_SELECTED_DATASET */
+export type SetExportSelectedDatasetUpdaterAction = {
+ payload: string;
+};
+export function setExportSelectedDataset(
+ datasetId: string
+): Merge<SetExportSelectedDatasetUpdaterAction, {type: ActionTypes.SET_EXPORT_SELECTED_DATASET}>;
+
+/** SET_EXPORT_DATA_TYPE */
+export type SetExportDataTypeUpdaterAction = {
+ payload: string;
+};
+export function setExportDataType(
+ dataType: string
+): Merge<SetExportDataTypeUpdaterAction, {type: ActionTypes.SET_EXPORT_DATA_TYPE}>;
+
+/** SET_EXPORT_FILTERED */
+export type SetExportFilteredUpdaterAction = {
+ payload: boolean;
+};
+export function setExportFiltered(
+ exportFiltered: boolean
+): Merge<SetExportFilteredUpdaterAction, {type: ActionTypes.SET_EXPORT_FILTERED}>;
+
+/** SET_EXPORT_DATA */
+export function setExportData(): {type: ActionTypes.SET_EXPORT_DATA};
+
+/** SET_USER_MAPBOX_ACCESS_TOKEN */
+export type SetUserMapboxAccessTokenUpdaterAction = {
+ payload: string;
+};
+export function setUserMapboxAccessToken(): Merge<
+ SetUserMapboxAccessTokenUpdaterAction,
+ {type: ActionTypes.SET_USER_MAPBOX_ACCESS_TOKEN}
+>;
+
+/** SET_EXPORT_MAP_FORMAT */
+export type SetExportMapFormatUpdaterAction = {
+ payload: string;
+};
+export function setExportMapFormat(
+ mapFormat: string
+): Merge<SetExportMapFormatUpdaterAction, {type: ActionTypes.SET_EXPORT_MAP_FORMAT}>;
+
+/** SET_EXPORT_MAP_HTML_MODE */
+export type SetExportHTMLMapModeUpdaterAction = {
+ payload: string;
+};
+export function setExportHTMLMapMode(
+ mode: string
+): Merge<SetExportHTMLMapModeUpdaterAction, {type: ActionTypes.SET_EXPORT_MAP_HTML_MODE}>;
+
+/** SET_LOCALE */
+export type SetLocaleUpdaterAction = {
+ payload: {locale: string};
+};
+export function setLocale(
+ locale: string
+): Merge<SetLocaleUpdaterAction, {type: ActionTypes.SET_LOCALE}>;
diff --git a/src/actions/ui-state-actions.js b/src/actions/ui-state-actions.js
index 7dc9c3c95..5eef1fdb2 100644
--- a/src/actions/ui-state-actions.js
+++ b/src/actions/ui-state-actions.js
@@ -24,7 +24,8 @@ import ActionTypes from 'constants/action-types';
/**
* Toggle active side panel
* @memberof uiStateActions
- * @param {string} id id of side panel to be shown, one of `layer`, `filter`, `interaction`, `map`
+ * @param id id of side panel to be shown, one of `layer`, `filter`, `interaction`, `map`
+ * @type {typeof import('./ui-state-actions').toggleSidePanel}
* @public
*/
export const toggleSidePanel = createAction(ActionTypes.TOGGLE_SIDE_PANEL, id => id);
@@ -32,14 +33,14 @@ export const toggleSidePanel = createAction(ActionTypes.TOGGLE_SIDE_PANEL, id =>
/**
* Show and hide modal dialog
* @memberof uiStateActions
- * @param {string|null} id - id of modal to be shown, null to hide modals. One of:
- *
+ * @param id - id of modal to be shown, null to hide modals. One of:
* - [`DATA_TABLE_ID`](../constants/default-settings.md#data_table_id)
* - [`DELETE_DATA_ID`](../constants/default-settings.md#delete_data_id)
* - [`ADD_DATA_ID`](../constants/default-settings.md#add_data_id)
* - [`EXPORT_IMAGE_ID`](../constants/default-settings.md#export_image_id)
* - [`EXPORT_DATA_ID`](../constants/default-settings.md#export_data_id)
* - [`ADD_MAP_STYLE_ID`](../constants/default-settings.md#add_map_style_id)
+ * @type {typeof import('./ui-state-actions').toggleModal}
* @public
*/
export const toggleModal = createAction(ActionTypes.TOGGLE_MODAL, id => id);
@@ -47,7 +48,8 @@ export const toggleModal = createAction(ActionTypes.TOGGLE_MODAL, id => id);
/**
* Hide and show side panel header dropdown, activated by clicking the share link on top of the side panel
* @memberof uiStateActions
- * @param {string} id - id of the dropdown
+ * @param id - id of the dropdown
+ * @type {typeof import('./ui-state-actions').showExportDropdown}
* @public
*/
export const showExportDropdown = createAction(ActionTypes.SHOW_EXPORT_DROPDOWN, id => id);
@@ -55,6 +57,7 @@ export const showExportDropdown = createAction(ActionTypes.SHOW_EXPORT_DROPDOWN,
/**
* Hide side panel header dropdown, activated by clicking the share link on top of the side panel
* @memberof uiStateActions
+ * @type {typeof import('./ui-state-actions').hideExportDropdown}
* @public
*/
export const hideExportDropdown = createAction(ActionTypes.HIDE_EXPORT_DROPDOWN);
@@ -62,7 +65,8 @@ export const hideExportDropdown = createAction(ActionTypes.HIDE_EXPORT_DROPDOWN)
/**
* Toggle active map control panel
* @memberof uiStateActions
- * @param {string} panelId - map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
+ * @param panelId - map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
+ * @type {typeof import('./ui-state-actions').toggleMapControl}
* @public
*/
export const toggleMapControl = createAction(ActionTypes.TOGGLE_MAP_CONTROL, (panelId, index) => ({
@@ -73,7 +77,8 @@ export const toggleMapControl = createAction(ActionTypes.TOGGLE_MAP_CONTROL, (pa
/**
* Toggle active map control panel
* @memberof uiStateActions
- * @param {string} datasetId - `id` of the dataset to be deleted
+ * @param datasetId - `id` of the dataset to be deleted
+ * @type {typeof import('./ui-state-actions').openDeleteModal}
* @public
*/
export const openDeleteModal = createAction(ActionTypes.OPEN_DELETE_MODAL, datasetId => datasetId);
@@ -81,7 +86,8 @@ export const openDeleteModal = createAction(ActionTypes.OPEN_DELETE_MODAL, datas
/**
* Add a notification to be displayed
* @memberof uiStateActions
- * @param {Object} notification - The `notification` object to be added
+ * @param notification - The `notification` object to be added
+ * @type {typeof import('./ui-state-actions').addNotification}
* @public
*/
export const addNotification = createAction(
@@ -92,7 +98,8 @@ export const addNotification = createAction(
/**
* Remove a notification
* @memberof uiStateActions
- * @param {string} id - `id` of the notification to be removed
+ * @param id - `id` of the notification to be removed
+ * @type {typeof import('./ui-state-actions').removeNotification}
* @public
*/
export const removeNotification = createAction(ActionTypes.REMOVE_NOTIFICATION, id => id);
@@ -100,7 +107,8 @@ export const removeNotification = createAction(ActionTypes.REMOVE_NOTIFICATION,
/**
* Set `exportImage` settings: ratio, resolution, legend
* @memberof uiStateActions
- * @param {Object} newSetting - {ratio: '1x'}
+ * @param newSetting - {ratio: '1x'}
+ * @type {typeof import('./ui-state-actions').setExportImageSetting}
* @public
*/
export const setExportImageSetting = createAction(
@@ -111,6 +119,7 @@ export const setExportImageSetting = createAction(
/**
* Set `exportImage.exporting` to true
* @memberof uiStateActions
+ * @type {typeof import('./ui-state-actions').startExportingImage}
* @public
*/
export const startExportingImage = createAction(ActionTypes.START_EXPORTING_IMAGE);
@@ -118,7 +127,8 @@ export const startExportingImage = createAction(ActionTypes.START_EXPORTING_IMAG
/**
* Set `exportImage.setExportImageDataUri` to a dataUri
* @memberof uiStateActions
- * @param {string} dataUri - export image data uri
+ * @param dataUri - export image data uri
+ * @type {typeof import('./ui-state-actions').setExportImageDataUri}
* @public
*/
export const setExportImageDataUri = createAction(
@@ -126,11 +136,18 @@ export const setExportImageDataUri = createAction(
dataUri => dataUri
);
+/**
+ * Set Export image error
+ * @memberof uiStateActions
+ * @type {typeof import('./ui-state-actions').setExportImageError}
+ * @public
+ */
export const setExportImageError = createAction(ActionTypes.SET_EXPORT_IMAGE_ERROR, error => error);
/**
* Delete cached export image
* @memberof uiStateActions
+ * @type {typeof import('./ui-state-actions').cleanupExportImage}
* @public
*/
export const cleanupExportImage = createAction(ActionTypes.CLEANUP_EXPORT_IMAGE);
@@ -138,7 +155,8 @@ export const cleanupExportImage = createAction(ActionTypes.CLEANUP_EXPORT_IMAGE)
/**
* Set selected dataset for export
* @memberof uiStateActions
- * @param {string} datasetId - dataset id
+ * @param datasetId - dataset id
+ * @type {typeof import('./ui-state-actions').setExportSelectedDataset}
* @public
*/
export const setExportSelectedDataset = createAction(
@@ -149,7 +167,8 @@ export const setExportSelectedDataset = createAction(
/**
* Set data format for exporting data
* @memberof uiStateActions
- * @param {string} dataType - one of `'text/csv'`
+ * @param dataType - one of `'text/csv'`
+ * @type {typeof import('./ui-state-actions').setExportDataType}
* @public
*/
export const setExportDataType = createAction(
@@ -160,7 +179,8 @@ export const setExportDataType = createAction(
/**
* Whether to export filtered data, `true` or `false`
* @memberof uiStateActions
- * @param {boolean} payload - set `true` to ony export filtered data
+ * @param payload - set `true` to ony export filtered data
+ * @type {typeof import('./ui-state-actions').setExportFiltered}
* @public
*/
export const setExportFiltered = createAction(ActionTypes.SET_EXPORT_FILTERED, payload => payload);
@@ -168,6 +188,7 @@ export const setExportFiltered = createAction(ActionTypes.SET_EXPORT_FILTERED, p
/**
* Whether to including data in map config, toggle between `true` or `false`
* @memberof uiStateActions
+ * @type {typeof import('./ui-state-actions').setExportData}
* @public
*/
export const setExportData = createAction(ActionTypes.SET_EXPORT_DATA);
@@ -175,7 +196,8 @@ export const setExportData = createAction(ActionTypes.SET_EXPORT_DATA);
/**
* Whether we export a mapbox access token used to create a single map html file
* @memberof uiStateActions
- * @param {string} payload - mapbox access token
+ * @param payload - mapbox access token
+ * @type {typeof import('./ui-state-actions').setUserMapboxAccessToken}
* @public
*/
export const setUserMapboxAccessToken = createAction(
@@ -186,7 +208,8 @@ export const setUserMapboxAccessToken = createAction(
/**
* Set the export map format (html, json)
* @memberOf uiStateActions
- * @param {string} payload - map format
+ * @param payload - map format
+ * @type {typeof import('./ui-state-actions').setExportMapFormat}
* @public
*/
export const setExportMapFormat = createAction(
@@ -196,7 +219,9 @@ export const setExportMapFormat = createAction(
/**
* Set the HTML mode to use to export HTML mode
- * @type {actionCreator}
+ * @memberOf uiStateActions
+ * @param payload - map mode
+ * @type {typeof import('./ui-state-actions').setExportHTMLMapMode}
*/
export const setExportHTMLMapMode = createAction(
ActionTypes.SET_EXPORT_MAP_HTML_MODE,
@@ -206,7 +231,8 @@ export const setExportHTMLMapMode = createAction(
/**
* Set `locale` value
* @memberof uiStateActions
- * @param {Object} locale - locale of the UI
+ * @param locale - locale of the UI
+ * @type {typeof import('./ui-state-actions').setLocale}
* @public
*/
export const setLocale = createAction(ActionTypes.SET_LOCALE, locale => ({
@@ -225,5 +251,6 @@ export const setLocale = createAction(ActionTypes.SET_LOCALE, locale => ({
* @public
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const uiStateActions = null;
/* eslint-enable no-unused-vars */
diff --git a/src/actions/vis-state-actions.d.ts b/src/actions/vis-state-actions.d.ts
new file mode 100644
index 000000000..d827e8671
--- /dev/null
+++ b/src/actions/vis-state-actions.d.ts
@@ -0,0 +1,399 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+// vis-state-reducer
+import ActionTypes from 'constants/action-types';
+import {ProtoDataset, AddDataToMaoPayload} from '../actions/actions';
+import {ParsedConfig} from '../schemas';
+import {FileCacheItem} from '../processors/file-handler';
+import {Layer, LayerConfig, LayerVisConfig} from 'layers';
+import {Feature, InteractionConfig} from 'reducers/vis-state-updaters';
+import {ValueOf, Merge} from '../reducers/types';
+
+export type LayerConfigChangeUpdaterAction = {
+ oldLayer: Layer;
+ newConfig: Partial<LayerConfig>;
+};
+
+export function layerConfigChange(
+ oldLayer: Layer,
+ newConfig: Partial<LayerConfig>
+): Merge<LayerConfigChangeUpdaterAction, {type: ActionTypes.LAYER_CONFIG_CHANGE}>;
+
+export type LayerTextLabelChangeUpdaterAction = {
+ oldLayer: Layer;
+ idx: number | 'all';
+ prop: string;
+ value: any;
+};
+
+export function layerTextLabelChange(
+ oldLayer: Layer,
+ idx: number | 'all',
+ prop: string,
+ value: any
+): Merge<LayerTextLabelChangeUpdaterAction, {type: ActionTypes.LAYER_TEXT_LABEL_CHANGE}>;
+
+export type LayerTypeChangeUpdaterAction = {
+ oldLayer: Layer;
+ newType: string;
+};
+export function layerTypeChange(
+ oldLayer: Layer,
+ newType: string
+): Merge<LayerTypeChangeUpdaterAction, {type: ActionTypes.LAYER_TYPE_CHANGE}>;
+
+export type LayerVisualChannelConfigChangeUpdaterAction = {
+ oldLayer: Layer;
+ newConfig: Partial<LayerConfig>;
+ channel: string;
+};
+export function layerVisualChannelConfigChange(
+ oldLayer: Layer,
+ newConfig: Partial<LayerConfig>,
+ channel: string
+): Merge<
+ LayerVisualChannelConfigChangeUpdaterAction,
+ {type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE}
+>;
+
+export type LayerVisConfigChangeUpdaterAction = {
+ oldLayer: Layer;
+ newVisConfig: Partial<LayerVisConfig>;
+};
+export function layerVisConfigChange(
+ oldLayer: Layer,
+ newVisConfig: Partial<LayerVisConfig>
+): Merge<LayerVisConfigChangeUpdaterAction, {type: ActionTypes.LAYER_VIS_CONFIG_CHANGE}>;
+
+export type LayerColorUIChangeUpdaterAction = {
+ oldLayer: Layer;
+ prop: string;
+ newConfig: object;
+};
+export function layerColorUIChange(
+ oldLayer: Layer,
+ prop: string,
+ newConfig: object
+): Merge<LayerColorUIChangeUpdaterAction, {type: ActionTypes.LAYER_COLOR_UI_CHANGE}>;
+
+export type UpdateLayerBlendingUpdaterAction = {
+ mode: string;
+};
+export function updateLayerBlending(
+ mode: 'additive' | 'normal' | 'subtractive'
+): Merge<UpdateLayerBlendingUpdaterAction, {type: ActionTypes.UPDATE_LAYER_BLENDING}>;
+
+export type InteractionConfigChangeUpdaterAction = {
+ config: ValueOf<InteractionConfig>;
+};
+export function interactionConfigChange(
+ config: ValueOf<InteractionConfig>
+): Merge<InteractionConfigChangeUpdaterAction, {type: ActionTypes.INTERACTION_CONFIG_CHANGE}>;
+
+export type SetFilterUpdaterAction = {
+ idx: number;
+ prop: string;
+ value: any;
+ valueIndex?: number;
+};
+export function setFilter(
+ idx: number,
+ prop: string,
+ value: any,
+ valueIndex: number
+): Merge<SetFilterUpdaterAction, {type: ActionTypes.SET_FILTER}>;
+
+export type AddFilterUpdaterAction = {
+ dataId: string;
+};
+export function addFilter(
+ dataId: string
+): Merge<AddFilterUpdaterAction, {type: ActionTypes.ADD_FILTER}>;
+
+export type AddLayerUpdaterAction = {
+ props: object;
+};
+export function addLayer(
+ props: object
+): Merge<AddLayerUpdaterAction, {type: ActionTypes.ADD_LAYER}>;
+
+export type ReorderLayerUpdaterAction = {
+ order: number[];
+};
+export function reorderLayer(
+ order: number[]
+): Merge<ReorderLayerUpdaterAction, {type: ActionTypes.REORDER_LAYER}>;
+
+export type RemoveFilterUpdaterAction = {
+ idx: number;
+};
+export function removeFilter(
+ idx: number
+): Merge<RemoveFilterUpdaterAction, {type: ActionTypes.REMOVE_FILTER}>;
+
+export type RemoveLayerUpdaterAction = {
+ idx: number;
+};
+export function removeLayer(
+ idx: number
+): Merge<RemoveLayerUpdaterAction, {type: ActionTypes.REMOVE_LAYER}>;
+
+export type RemoveDatasetUpdaterAction = {
+ dataId: string;
+};
+export function removeDataset(
+ dataId: string
+): Merge<RemoveDatasetUpdaterAction, {type: ActionTypes.REMOVE_DATASET}>;
+
+export type ShowDatasetTableUpdaterAction = {
+ dataId: string;
+};
+export function showDatasetTable(
+ dataId: string
+): Merge<ShowDatasetTableUpdaterAction, {type: ActionTypes.SHOW_DATASET_TABLE}>;
+
+export type SortTableColumnUpdaterAction = {
+ dataId: string;
+ column: string;
+ mode: string;
+};
+export function sortTableColumn(
+ dataId: string,
+ column: string,
+ mode: string
+): Merge<SortTableColumnUpdaterAction, {type: ActionTypes.SORT_TABLE_COLUMN}>;
+
+export type PinTableColumnUpdaterAction = {
+ dataId: string;
+ column: string;
+};
+export function pinTableColumn(
+ dataId: string,
+ column: string
+): Merge<PinTableColumnUpdaterAction, {type: ActionTypes.PIN_TABLE_COLUMN}>;
+
+export type CopyTableColumnUpdaterAction = {
+ dataId: string;
+ column: string;
+};
+export function copyTableColumn(
+ dataId: string,
+ column: string
+): Merge<CopyTableColumnUpdaterAction, {type: ActionTypes.COPY_TABLE_COLUMN}>;
+
+export type AddDaataToMapOUpdaterptions = {
+ centrMap?: boolean;
+ readOnly?: boolean;
+ keepExistingConfig?: boolean;
+};
+
+export type UpdateVisDataUpdaterAction = {
+ datasets: AddDataToMaoPayload['datasets'];
+ options: AddDataToMaoPayload['options'];
+ config: AddDataToMaoPayload['config'];
+} & AddDataToMaoPayload;
+export function updateVisData(
+ datasets: AddDataToMaoPayload['datasets'],
+ options: AddDataToMaoPayload['options'],
+ config: AddDataToMaoPayload['config']
+): Merge<UpdateVisDataUpdaterAction, {type: ActionTypes.UPDATE_VIS_DATA}>;
+
+export type ToggleFilterAnimationUpdaterAction = {
+ idx;
+};
+export function toggleFilterAnimation(
+ idx: number
+): Merge<ToggleFilterAnimationUpdaterAction, {type: ActionTypes.TOGGLE_FILTER_ANIMATION}>;
+
+export type UpdateFilterAnimationSpeedUpdaterAction = {
+ idx: number;
+ speed: number;
+};
+export function updateFilterAnimationSpeed(
+ idx: number,
+ speed: number
+): Merge<
+ UpdateFilterAnimationSpeedUpdaterAction,
+ {type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED}
+>;
+
+export type UpdateAnimationTimeUpdaterAction = {
+ value: number;
+};
+export function updateAnimationTime(
+ value: number
+): Merge<UpdateAnimationTimeUpdaterAction, {type: ActionTypes.UPDATE_ANIMATION_TIME}>;
+
+export type UpdateLayerAnimationSpeedUpdaterAction = {
+ speed: number;
+};
+export function updateLayerAnimationSpeed(
+ speed: number
+): Merge<UpdateLayerAnimationSpeedUpdaterAction, {type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED}>;
+
+export type EnlargeFilterUpdaterAction = {
+ idx: number;
+};
+export function enlargeFilter(
+ idx: number
+): Merge<EnlargeFilterUpdaterAction, {type: ActionTypes.ENLARGE_FILTER}>;
+
+export type ToggleFilterFeatureUpdaterAction = {
+ idx: number;
+};
+export function toggleFilterFeature(
+ idx: number
+): Merge<ToggleFilterFeatureUpdaterAction, {type: ActionTypes.TOGGLE_FILTER_FEATURE}>;
+
+export type OnLayerHoverUpdaterAction = {
+ info: {picked?: boolean} | null;
+};
+export function onLayerHover(
+ info: {picked?: boolean} | null
+): Merge<OnLayerHoverUpdaterAction, {type: ActionTypes.LAYER_HOVER}>;
+
+export type OnLayerClickUpdaterAction = {
+ info: {picked?: boolean} | null;
+};
+export function onLayerClick(
+ info: {picked?: boolean} | null
+): Merge<OnLayerClickUpdaterAction, {type: ActionTypes.LAYER_CLICK}>;
+
+export type OnMapClickUpdaterAction = {};
+
+export function onMapClick(): Merge<OnMapClickUpdaterAction, {type: ActionTypes.MAP_CLICK}>;
+export type OnMouseMoveUpdaterAction = {
+ evt;
+};
+export function onMouseMove(evt): Merge<OnMouseMoveUpdaterAction, {type: ActionTypes.MOUSE_MOVE}>;
+
+export type ToggleLayerForMapUpdaterAction = {
+ mapIndex: number;
+ layerId: string;
+};
+export function toggleLayerForMap(
+ mapIndex: number,
+ layerId: string
+): Merge<ToggleLayerForMapUpdaterAction, {type: ActionTypes.TOGGLE_LAYER_FOR_MAP}>;
+
+export type SetFilterPlotUpdaterAction = {
+ idx: number;
+ newProp: object;
+ valueIndex?: number;
+};
+export function setFilterPlot(
+ idx: number,
+ newProp: object,
+ valueIndex?: number
+): Merge<SetFilterPlotUpdaterAction, {type: ActionTypes.SET_FILTER_PLOT}>;
+
+export type SetMapInfoUpdaterAction = {
+ info: any;
+};
+export function setMapInfo(
+ info: any
+): Merge<SetMapInfoUpdaterAction, {type: ActionTypes.SET_MAP_INFO}>;
+
+export type LoadFilesUpdaterAction = {
+ files: FileList;
+ onFinish?(result: any): any;
+};
+export function loadFiles(
+ files: FileList,
+ onFinish?: (result: any) => any
+): Merge<LoadFilesUpdaterAction, {type: ActionTypes.LOAD_FILES}>;
+
+export type SetFeaturesUpdaterAction = {
+ features: Feature[];
+};
+export function setFeatures(
+ features: Feature[]
+): Merge<SetFeaturesUpdaterAction, {type: ActionTypes.SET_FEATURES}>;
+
+export type SetPolygonFilterLayerUpdaterAction = {
+ layer: Layer;
+ feature: Feature;
+};
+export function setPolygonFilterLayer(
+ layer: Layer,
+ feature: Feature
+): Merge<SetPolygonFilterLayerUpdaterAction, {type: ActionTypes.SET_POLYGON_FILTER_LAYER}>;
+
+export type SetSelectedFeatureUpdaterAction = {
+ feature: Feature;
+};
+export function setSelectedFeature(
+ feature: Feature
+): Merge<SetSelectedFeatureUpdaterAction, {type: ActionTypes.SET_SELECTED_FEATURE}>;
+
+export type DeleteFeatureUpdaterAction = {
+ feature: Feature;
+};
+export function deleteFeature(
+ feature: Feature
+): Merge<DeleteFeatureUpdaterAction, {type: ActionTypes.DELETE_FEATURE}>;
+
+export type SetEditorModeUpdaterAction = {
+ mode: string;
+};
+export function setEditorMode(
+ mode: string
+): Merge<SetEditorModeUpdaterAction, {type: ActionTypes.SET_EDITOR_MODE}>;
+
+export type ApplyCPUFilterUpdaterAction = {
+ dataId: string | string[];
+};
+export function applyCPUFilter(
+ dataId: string | string[]
+): Merge<ApplyCPUFilterUpdaterAction, {type: ActionTypes.APPLY_CPU_FILTER}>;
+
+export type ToggleEditorVisibilityUpdaterAction = {};
+export function toggleEditorVisibility(): Merge<
+ ToggleEditorVisibilityUpdaterAction,
+ {type: ActionTypes.TOGGLE_EDITOR_VISIBILITY}
+>;
+
+export type LoadNextFileUpdaterAction = {
+ fileCache: FileCacheItem[];
+ filesToLoad: FileList[];
+ totalCount: number;
+ onFinish: function;
+};
+export function loadNextFile(payload: {
+ fileCache: FileCacheItem[];
+ filesToLoad: FileList[];
+ totalCount: number;
+ onFinish: function;
+}): Merge<LoadNextFileUpdaterAction, {type: ActionTypes.LOAD_NEXT_FILE}>;
+
+export type LoadFileSuccessUpdaterAction = {
+ result: FileCacheItem[];
+};
+export function loadFileSuccess(
+ result: FileCacheItem[]
+): Merge<LoadFileSuccessUpdaterAction, {type: ActionTypes.LOAD_FILES_SUCCESS}>;
+
+export type loadFilesErrUpdaterAction = {
+ error: any;
+};
+export function loadFilesErr(
+ error: any
+): Merge<loadFilesErrUpdaterAction, {type: ActionTypes.LOAD_FILES_ERR}>;
diff --git a/src/actions/vis-state-actions.js b/src/actions/vis-state-actions.js
index c0e82aa55..37f3c54bf 100644
--- a/src/actions/vis-state-actions.js
+++ b/src/actions/vis-state-actions.js
@@ -23,10 +23,10 @@ import ActionTypes from 'constants/action-types';
/**
* Update layer base config: dataId, label, column, isVisible
- * @memberof visStateActions
- * @param {Object} oldLayer - layer to be updated
- * @param {Object} newConfig - new config
- * @returns {{type: ActionTypes.LAYER_CONFIG_CHANGE, oldLayer: oldLayer, newConfig: newConfig}}
+ * @param oldLayer - layer to be updated
+ * @param newConfig - new config to be merged with old config
+ * @returns action
+ * @type {typeof import('./vis-state-actions').layerConfigChange}
* @public
*/
export function layerConfigChange(oldLayer, newConfig) {
@@ -39,12 +39,12 @@ export function layerConfigChange(oldLayer, newConfig) {
/**
* Update layer text label
- * @memberof visStateActions
- * @param {Object} oldLayer - layer to be updated
- * @param {Number} idx -`idx` of text label to be updated
- * @param {string} prop - `prop` of text label, e,g, `anchor`, `alignment`, `color`, `size`, `field`
- * @param {*} value - new value
- * @returns {{type: ActionTypes.LAYER_TEXT_LABEL_CHANGE, oldLayer: oldLayer, idx: idx, prop: prop, value:}}
+ * @param oldLayer - layer to be updated
+ * @param idx -`idx` of text label to be updated
+ * @param prop - `prop` of text label, e,g, `anchor`, `alignment`, `color`, `size`, `field`
+ * @param value - new value
+ * @returns action
+ * @type {typeof import('./vis-state-actions').layerTextLabelChange}
* @public
*/
export function layerTextLabelChange(oldLayer, idx, prop, value) {
@@ -59,10 +59,10 @@ export function layerTextLabelChange(oldLayer, idx, prop, value) {
/**
* Update layer type. Previews layer config will be copied if applicable.
- * @memberof visStateActions
- * @param {Object} oldLayer - layer to be updated
- * @param {string} newType - new type
- * @returns {{type: ActionTypes.LAYER_TYPE_CHANGE, oldLayer: oldLayer, newType: newType}}
+ * @param oldLayer - layer to be updated
+ * @param newType - new type
+ * @returns action
+ * @type {typeof import('./vis-state-actions').layerTypeChange}
* @public
*/
export function layerTypeChange(oldLayer, newType) {
@@ -76,10 +76,11 @@ export function layerTypeChange(oldLayer, newType) {
/**
* Update layer visual channel
* @memberof visStateActions
- * @param {Object} oldLayer - layer to be updated
- * @param {Object} newConfig - new visual channel config
- * @param {string} channel - channel to be updated
- * @returns {{type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE, oldLayer: oldLayer, newConfig: newConfig, channel: channel}}
+ * @param oldLayer - layer to be updated
+ * @param newConfig - new visual channel config
+ * @param channel - channel to be updated
+ * @returns action
+ * @type {typeof import('./vis-state-actions').layerVisualChannelConfigChange}
* @public
*/
export function layerVisualChannelConfigChange(oldLayer, newConfig, channel) {
@@ -94,9 +95,10 @@ export function layerVisualChannelConfigChange(oldLayer, newConfig, channel) {
/**
* Update layer `visConfig`
* @memberof visStateActions
- * @param {Object} oldLayer - layer to be updated
- * @param {Object} newVisConfig - new visConfig as a key value map: e.g. `{opacity: 0.8}`
- * @returns {{type: ActionTypes.LAYER_VIS_CONFIG_CHANGE, oldLayer: oldLayer, newVisConfig: newVisConfig}}
+ * @param oldLayer - layer to be updated
+ * @param newVisConfig - new visConfig as a key value map: e.g. `{opacity: 0.8}`
+ * @returns action
+ * @type {typeof import('./vis-state-actions').layerVisConfigChange}
* @public
*/
export function layerVisConfigChange(oldLayer, newVisConfig) {
@@ -110,9 +112,11 @@ export function layerVisConfigChange(oldLayer, newVisConfig) {
/**
* Set the color palette ui for layer color
* @memberOf visStateActions
- * @param {Object} oldLayer - layer to be updated
- * @param {String} prop - which color prop
- * @param {object} newConfig - to be merged
+ * @param oldLayer - layer to be updated
+ * @param prop - which color prop
+ * @param newConfig - to be merged
+ * @returns action
+ * @type {typeof import('./vis-state-actions').layerColorUIChange}
* @public
*/
export function layerColorUIChange(oldLayer, prop, newConfig) {
@@ -127,8 +131,9 @@ export function layerColorUIChange(oldLayer, prop, newConfig) {
/**
* Update layer blending mode
* @memberof visStateActions
- * @param {string} mode one of `additive`, `normal` and `subtractive`
- * @returns {{type: ActionTypes.UPDATE_LAYER_BLENDING, mode: mode}}
+ * @param mode one of `additive`, `normal` and `subtractive`
+ * @returns action
+ * @type {typeof import('./vis-state-actions').updateLayerBlending}
* @public
*/
export function updateLayerBlending(mode) {
@@ -141,8 +146,9 @@ export function updateLayerBlending(mode) {
/**
* Update `interactionConfig`
* @memberof visStateActions
- * @param {Object} config - new config as key value map: `{tooltip: {enabled: true}}`
- * @returns {{type: ActionTypes.INTERACTION_CONFIG_CHANGE, config: config}}
+ * @param config - new config as key value map: `{tooltip: {enabled: true}}`
+ * @returns action
+ * @type {typeof import('./vis-state-actions').interactionConfigChange}
* @public
*/
export function interactionConfigChange(config) {
@@ -155,11 +161,12 @@ export function interactionConfigChange(config) {
/**
* Update filter property
* @memberof visStateActions
- * @param {Number} idx -`idx` of filter to be updated
- * @param {string} prop - `prop` of filter, e,g, `dataId`, `name`, `value`
- * @param {*} value - new value
- * @param {Number} valueIndex - array properties like dataset require index in order to improve performance
- * @returns {{type: ActionTypes.SET_FILTER, idx: idx, prop: prop, value: value}}
+ * @param idx -`idx` of filter to be updated
+ * @param prop - `prop` of filter, e,g, `dataId`, `name`, `value`
+ * @param value - new value
+ * @param valueIndex - dataId index
+ * @returns action
+ * @type {typeof import('./vis-state-actions').setFilter}
* @public
*/
export function setFilter(idx, prop, value, valueIndex) {
@@ -175,8 +182,9 @@ export function setFilter(idx, prop, value, valueIndex) {
/**
* Add a new filter
* @memberof visStateActions
- * @param {string} dataId - dataset `id` this new filter is associated with
- * @returns {{type: ActionTypes.ADD_FILTER, dataId: dataId}}
+ * @param dataId - dataset `id` this new filter is associated with
+ * @returns action
+ * @type {typeof import('./vis-state-actions').addFilter}
* @public
*/
export function addFilter(dataId) {
@@ -189,8 +197,9 @@ export function addFilter(dataId) {
/**
* Add a new layer
* @memberof visStateActions
- * @param {Object} props - new layer props
- * @returns {{type: ActionTypes.ADD_LAYER, props: props}}
+ * @param props - new layer props
+ * @returns action
+ * @type {typeof import('./vis-state-actions').addLayer}
* @public
*/
export function addLayer(props) {
@@ -203,8 +212,9 @@ export function addLayer(props) {
/**
* Reorder layer, order is an array of layer indexes, index 0 will be the one at the bottom
* @memberof visStateActions
- * @param {Array<Number>} order an array of layer indexes
- * @returns {{type: ActionTypes.REORDER_LAYER, order: order}}
+ * @param order an array of layer indexes
+ * @returns action
+ * @type {typeof import('./vis-state-actions').reorderLayer}
* @public
* @example
*
@@ -222,8 +232,9 @@ export function reorderLayer(order) {
/**
* Remove a filter from `visState.filters`, once a filter is removed, data will be re-filtered and layer will be updated
* @memberof visStateActions
- * @param {Number} idx idx of filter to be removed
- * @returns {{type: ActionTypes.REMOVE_FILTER, idx: idx}}
+ * @param idx idx of filter to be removed
+ * @returns action
+ * @type {typeof import('./vis-state-actions').removeFilter}
* @public
*/
export function removeFilter(idx) {
@@ -236,8 +247,9 @@ export function removeFilter(idx) {
/**
* Remove a layer
* @memberof visStateActions
- * @param {Number} idx idx of layer to be removed
- * @returns {{type: ActionTypes.REMOVE_LAYER, idx: idx}}
+ * @param idx idx of layer to be removed
+ * @returns action
+ * @type {typeof import('./vis-state-actions').removeLayer}
* @public
*/
export function removeLayer(idx) {
@@ -250,22 +262,24 @@ export function removeLayer(idx) {
/**
* Remove a dataset and all layers, filters, tooltip configs that based on it
* @memberof visStateActions
- * @param {string} key dataset id
- * @returns {{type: ActionTypes.REMOVE_DATASET, key: key}}
+ * @param dataId dataset id
+ * @returns action
+ * @type {typeof import('./vis-state-actions').removeDataset}
* @public
*/
-export function removeDataset(key) {
+export function removeDataset(dataId) {
return {
type: ActionTypes.REMOVE_DATASET,
- key
+ dataId
};
}
/**
* Display dataset table in a modal
* @memberof visStateActions
- * @param {string} dataId dataset id to show in table
- * @returns {{type: ActionTypes.SHOW_DATASET_TABLE, dataId: dataId}}
+ * @param dataId dataset id to show in table
+ * @returns action
+ * @type {typeof import('./vis-state-actions').showDatasetTable}
* @public
*/
export function showDatasetTable(dataId) {
@@ -277,9 +291,13 @@ export function showDatasetTable(dataId) {
/**
* Sort dataset column, for table display
- * @param {string} dataId
- * @param {string} column
- * @param {string} mode
+ * @memberof visStateActions
+ * @param dataId
+ * @param column
+ * @param mode
+ * @returns action
+ * @type {typeof import('./vis-state-actions').sortTableColumn}
+ * @public
*/
export function sortTableColumn(dataId, column, mode) {
return {
@@ -292,8 +310,11 @@ export function sortTableColumn(dataId, column, mode) {
/**
* Pin dataset column, for table display
- * @param {string} dataId
- * @param {string} column
+ * @param dataId
+ * @param column
+ * @returns action
+ * @type {typeof import('./vis-state-actions').pinTableColumn}
+ * @public
*/
export function pinTableColumn(dataId, column) {
return {
@@ -305,8 +326,11 @@ export function pinTableColumn(dataId, column) {
/**
* Copy column, for table display
- * @param {string} dataId
- * @param {string} column
+ * @param dataId
+ * @param column
+ * @returns action
+ * @type {typeof import('./vis-state-actions').copyTableColumn}
+ * @public
*/
export function copyTableColumn(dataId, column) {
return {
@@ -316,26 +340,26 @@ export function copyTableColumn(dataId, column) {
};
}
+// * @param dataset.info -info of a dataset
+// * @param dataset.info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
+// * @param dataset.info.label - A display name of this dataset
+// * @param dataset.data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
+// * @param dataset.data.fields - ***required** Array of fields,
+// * @param dataset.data.fields.name - ***required** Name of the field,
+// * @param dataset.data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
/**
* Add new dataset to `visState`, with option to load a map config along with the datasets
* @memberof visStateActions
- * @param {Array<Object>|Object} datasets - ***required** datasets can be a dataset or an array of datasets
+ * @param datasets - ***required** datasets can be a dataset or an array of datasets
* Each dataset object needs to have `info` and `data` property.
- * @param {Object} datasets.info -info of a dataset
- * @param {string} datasets.info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- * @param {string} datasets.info.label - A display name of this dataset
- * @param {Object} datasets.data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
- * @param {Array<Object>} datasets.data.fields - ***required** Array of fields,
- * @param {string} datasets.data.fields.name - ***required** Name of the field,
- * @param {Array<Array>} datasets.data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
-
- * @param {Object} options
- * @param {boolean} options.centerMap `default: true` if `centerMap` is set to `true` kepler.gl will
+ * @param {object} options
+ * @param options.centerMap `default: true` if `centerMap` is set to `true` kepler.gl will
* place the map view within the data points boundaries
- * @param {boolean} options.readOnly `default: false` if `readOnly` is set to `true`
+ * @param options.readOnly `default: false` if `readOnly` is set to `true`
* the left setting panel will be hidden
- * @param {Object} config this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
- * @returns {{type: ActionTypes.UPDATE_VIS_DATA, datasets: datasets, options: options, config: config}}
+ * @param config this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
+ * @returns action
+ * @type {typeof import('./vis-state-actions').updateVisData}
* @public
*/
export function updateVisData(datasets, options, config) {
@@ -350,8 +374,9 @@ export function updateVisData(datasets, options, config) {
/**
* Start and end filter animation
* @memberof visStateActions
- * @param {Number} idx - idx of filter
- * @returns {{type: ActionTypes.TOGGLE_FILTER_ANIMATION, idx: idx}}
+ * @param {Number} idx of filter
+ * @type {typeof import('./vis-state-actions').toggleFilterAnimation}
+ * @returns action
* @public
*/
export function toggleFilterAnimation(idx) {
@@ -364,9 +389,10 @@ export function toggleFilterAnimation(idx) {
/**
* Change filter animation speed
* @memberof visStateActions
- * @param {Number} idx - `idx` of filter
- * @param {Number} speed - `speed` to change it to. `speed` is a multiplier
- * @returns {{type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED, idx: idx, speed: speed}}
+ * @param idx - `idx` of filter
+ * @param speed - `speed` to change it to. `speed` is a multiplier
+ * @type {typeof import('./vis-state-actions').updateFilterAnimationSpeed}
+ * @returns action
* @public
*/
export function updateFilterAnimationSpeed(idx, speed) {
@@ -380,8 +406,9 @@ export function updateFilterAnimationSpeed(idx, speed) {
/**
* Reset animation
* @memberof visStateActions
- * @param {Number} value - Current value of the slider
- * @returns {{type: ActionTypes.UPDATE_ANIMATION_TIME, value: value}}
+ * @param value - Current value of the slider
+ * @type {typeof import('./vis-state-actions').updateAnimationTime}
+ * @returns action
* @public
*/
export function updateAnimationTime(value) {
@@ -394,8 +421,9 @@ export function updateAnimationTime(value) {
/**
* update trip layer animation speed
* @memberof visStateActions
- * @param {Number} speed - `speed` to change it to. `speed` is a multiplier
- * @returns {{type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED, speed: speed}}
+ * @param speed - `speed` to change it to. `speed` is a multiplier
+ * @type {typeof import('./vis-state-actions').updateLayerAnimationSpeed}
+ * @returns action
* @public
*/
export function updateLayerAnimationSpeed(speed) {
@@ -408,8 +436,9 @@ export function updateLayerAnimationSpeed(speed) {
/**
* Show larger time filter at bottom for time playback (apply to time filter only)
* @memberof visStateActions
- * @param {Number} idx - index of filter to enlarge
- * @returns {{type: ActionTypes.ENLARGE_FILTER, idx: idx}}
+ * @param idx - index of filter to enlarge
+ * @type {typeof import('./vis-state-actions').enlargeFilter}
+ * @returns action
* @public
*/
export function enlargeFilter(idx) {
@@ -422,8 +451,9 @@ export function enlargeFilter(idx) {
/**
* Show/hide filter feature on map
* @memberof visStateActions
- * @param {Number} idx - index of filter feature to show/hide
- * @return {{type: ActionTypes.TOGGLE_FILTER_FEATURE, idx: idx}}
+ * @param idx - index of filter feature to show/hide
+ * @type {typeof import('./vis-state-actions').toggleFilterFeature}
+ * @return action
*/
export function toggleFilterFeature(idx) {
return {
@@ -435,8 +465,9 @@ export function toggleFilterFeature(idx) {
/**
* Trigger layer hover event with hovered object
* @memberof visStateActions
- * @param {Object} info - Object hovered, returned by deck.gl
- * @returns {{type: ActionTypes.LAYER_HOVER, info: info}}
+ * @param info - Object hovered, returned by deck.gl
+ * @type {typeof import('./vis-state-actions').onLayerHover}
+ * @returns action
* @public
*/
export function onLayerHover(info) {
@@ -449,8 +480,9 @@ export function onLayerHover(info) {
/**
* Trigger layer click event with clicked object
* @memberof visStateActions
- * @param {Object} info - Object clicked, returned by deck.gl
- * @returns {{type: ActionTypes.LAYER_CLICK, info: info}}
+ * @param info - Object clicked, returned by deck.gl
+ * @type {typeof import('./vis-state-actions').onLayerClick}
+ * @returns action
* @public
*/
export function onLayerClick(info) {
@@ -463,7 +495,8 @@ export function onLayerClick(info) {
/**
* Trigger map click event, unselect clicked object
* @memberof visStateActions
- * @returns {{type: ActionTypes.MAP_CLICK}}
+ * @type {typeof import('./vis-state-actions').onMapClick}
+ * @returns action
* @public
*/
export function onMapClick() {
@@ -478,8 +511,9 @@ export function onMapClick() {
* https://uber.github.io/react-map-gl/#/documentation/api-reference/pointer-event
*
* @memberof visStateActions
- * @param {Object} evt - PointerEvent
- * @returns {{type: ActionTypes.MAP_CLICK}}
+ * @param evt - PointerEvent
+ * @type {typeof import('./vis-state-actions').onMouseMove}
+ * @returns action
* @public
*/
export function onMouseMove(evt) {
@@ -492,9 +526,10 @@ export function onMouseMove(evt) {
/**
* Toggle visibility of a layer in a split map
* @memberof visStateActions
- * @param {Number} mapIndex - index of the split map
- * @param {string} layerId - id of the layer
- * @returns {{type: ActionTypes.TOGGLE_LAYER_FOR_MAP, mapIndex: *, layerId: *}}
+ * @param mapIndex - index of the split map
+ * @param layerId - id of the layer
+ * @type {typeof import('./vis-state-actions').toggleLayerForMap}
+ * @returns action
* @public
*/
export function toggleLayerForMap(mapIndex, layerId) {
@@ -508,25 +543,28 @@ export function toggleLayerForMap(mapIndex, layerId) {
/**
* Set the property of a filter plot
* @memberof visStateActions
- * @param {Number} idx
- * @param {Object} newProp key value mapping of new prop `{yAxis: 'histogram'}`
- * @returns {{type: ActionTypes.SET_FILTER_PLOT, idx: *, newProp: *}}
+ * @param idx
+ * @param newProp key value mapping of new prop `{yAxis: 'histogram'}`
+ * @param valueIndex dataId index
+ * @type {typeof import('./vis-state-actions').setFilterPlot}
+ * @returns action
* @public
*/
-export function setFilterPlot(idx, newProp) {
+export function setFilterPlot(idx, newProp, valueIndex) {
return {
type: ActionTypes.SET_FILTER_PLOT,
idx,
- newProp
+ newProp,
+ valueIndex
};
}
/**
* Set the property of a filter plot
* @memberof visStateActions
- * @param {Number} idx
- * @param {Object} newProp key value mapping of new prop `{yAxis: 'histogram'}`
- * @returns {{type: ActionTypes.SET_FILTER_PLOT, idx: *, newProp: *}}
+ * @param info
+ * @type {typeof import('./vis-state-actions').setMapInfo}
+ * @returns action
* @public
*/
export function setMapInfo(info) {
@@ -539,8 +577,9 @@ export function setMapInfo(info) {
/**
* Trigger file loading dispatch `addDataToMap` if succeed, or `loadFilesErr` if failed
* @memberof visStateActions
- * @param {Array<Object>} files array of fileblob
- * @returns {{type: ActionTypes.LOAD_FILES, files: *}}
+ * @param files array of fileblob
+ * @type {typeof import('./vis-state-actions').loadFiles}
+ * @returns action
* @public
*/
export function loadFiles(files) {
@@ -551,12 +590,12 @@ export function loadFiles(files) {
}
/**
- * called with next file to load
- * @param {object} payload
- * @param {Array<object>} payload.fileCache
- * @param {Array<object>} payload.filesToLoad
- * @param {number} payload.totalCount
- * @param {Function} payload.onFinish - action creator to execute when all files are loaded
+ * Called with next file to load
+ * @memberof visStateActions
+ * @param payload
+ * @type {typeof import('./vis-state-actions').loadNextFile}
+ * @returns action
+ * @public
*/
export function loadNextFile({fileCache, filesToLoad, totalCount, onFinish}) {
return {
@@ -570,7 +609,10 @@ export function loadNextFile({fileCache, filesToLoad, totalCount, onFinish}) {
/**
* called when all files are processed and loaded
- * @param {Array<object>} result
+ * @memberof visStateActions
+ * @param result
+ * @type {typeof import('./vis-state-actions').loadFileSuccess}
+ * @returns action
*/
export function loadFileSuccess(result) {
return {
@@ -582,8 +624,9 @@ export function loadFileSuccess(result) {
/**
* Trigger loading file error
* @memberof visStateActions
- * @param {*} error
- * @returns {{type: ActionTypes.LOAD_FILES_ERR, error: Object}}
+ * @param error
+ * @type {typeof import('./vis-state-actions').loadFilesErr}
+ * @returns action
* @public
*/
export function loadFilesErr(error) {
@@ -596,8 +639,9 @@ export function loadFilesErr(error) {
/**
* Store features to state
* @memberof visStateActions
- * @param {Array<Object>} features
- * @returns {{type: ActionTypes.SET_FEATURES, features: Object}}
+ * @param features
+ * @type {typeof import('./vis-state-actions').setFeatures}
+ * @returns action
*/
export function setFeatures(features) {
return {
@@ -610,9 +654,10 @@ export function setFeatures(features) {
* It will apply the provide feature as filter to the given layer.
* If the given feature is already applied as filter to the layer, it will remove the layer from the filter
* @memberof visStateActions
- * @param {Object} layer
- * @param {Object} feature
- * @return {{feature: *, type: ActionTypes.SET_POLYGON_FILTER_LAYER, layer: *}}
+ * @param layer
+ * @param feature
+ * @type {typeof import('./vis-state-actions').setPolygonFilterLayer}
+ * @returns action
*/
export function setPolygonFilterLayer(layer, feature) {
return {
@@ -625,8 +670,9 @@ export function setPolygonFilterLayer(layer, feature) {
/**
* Set the current feature to be edited/deleted
* @memberof visStateActions
- * @param {Object} feature
- * @return {{feature: feature, type: ActionTypes.SET_SELECTED_FEATURE}}
+ * @param feature
+ * @type {typeof import('./vis-state-actions').setSelectedFeature}
+ * @returns action
*/
export function setSelectedFeature(feature) {
return {
@@ -638,8 +684,9 @@ export function setSelectedFeature(feature) {
/**
* Delete the given feature
* @memberof visStateActions
- * @param {Object} feature
- * @return {{type: ActionTypes.DELETE_FEATURE, feature: feature}}
+ * @param feature
+ * @type {typeof import('./vis-state-actions').deleteFeature}
+ * @returns action
*/
export function deleteFeature(feature) {
return {
@@ -650,8 +697,9 @@ export function deleteFeature(feature) {
/** Set the map mode
* @memberof visStateActions
- * @param {string} mode one of EDITOR_MODES
- * @return {{type: ActionTypes. SET_EDITOR_MODE, mode: *}}
+ * @param mode one of EDITOR_MODES
+ * @type {typeof import('./vis-state-actions').setEditorMode}
+ * @returns action
* @public
* @example
* import {setMapMode} from 'kepler.gl/actions';
@@ -669,8 +717,9 @@ export function setEditorMode(mode) {
/**
* Trigger CPU filter of selected dataset
* @memberof visStateActions
- * @param {string | Arrary<string>} dataId - single dataId or an array of dataIds
- * @returns {{type: ActionTypes.APPLY_CPU_FILTER, dataId: string}}
+ * @param dataId - single dataId or an array of dataIds
+ * @type {typeof import('./vis-state-actions').applyCPUFilter}
+ * @returns action
* @public
*/
export function applyCPUFilter(dataId) {
@@ -684,7 +733,8 @@ export function applyCPUFilter(dataId) {
* Toggle editor layer visibility
* @memberof visStateActions
- * @return {{type: ActionTypes.TOGGLE_EDITOR_VISIBILITY}}
+ * @type {typeof import('./vis-state-actions').toggleEditorVisibility}
+ * @return action
*/
export function toggleEditorVisibility() {
return {
@@ -703,5 +753,6 @@ export function toggleEditorVisibility() {
* @public
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const visStateActions = null;
/* eslint-enable no-unused-vars */
diff --git a/src/cloud-providers/index.d.ts b/src/cloud-providers/index.d.ts
new file mode 100644
index 000000000..85937061c
--- /dev/null
+++ b/src/cloud-providers/index.d.ts
@@ -0,0 +1,45 @@
+import {ReactElementLike} from 'prop-types';
+import {MapData, ExportFileOptions} from 'actions/provider-actions';
+
+export type Millisecond = number;
+
+export type MapListItem = {
+ id: string;
+ title: string;
+ description: string;
+ loadParams: any;
+ imageUrl?: string;
+ lastModification?: Millisecond;
+ privateMap?: boolean;
+};
+
+export type Thumbnail = {
+ width: number;
+ height: number;
+};
+
+export type ProviderProps = {
+ name?: string;
+ displayName?: string;
+ icon?: ReactElementLike;
+ thumbnail?: Thumbnail;
+};
+
+export class Provider {
+ constructor(p: ProviderProps);
+ name: string;
+ displayName: string;
+ icon: ReactElementLike;
+ thumbnail: Thumbnail;
+ hasPrivateStorage(): boolean;
+ hasSharingUrl(): boolean;
+ getShareUrl(fullUrl?: boolean): string;
+ getMapUrl(fullUrl?: boolean): string;
+ getAccessToken(): boolean;
+ getUserName(): boolean;
+ login(Fn?: any): Promise<any>;
+ logout(Fn?: any): Promise<any>;
+ uploadMap(p: {mapData: MapData; options: ExportFileOptions}): Promise<any>;
+ listMaps(): Promise<MapListItem>;
+ downloadMap(param: any): Promose<{map: MapData; format: string}>;
+}
diff --git a/src/cloud-providers/provider.js b/src/cloud-providers/provider.js
index 0fc198088..ef62a31c6 100644
--- a/src/cloud-providers/provider.js
+++ b/src/cloud-providers/provider.js
@@ -30,7 +30,7 @@ const ICON = Upload;
* @param {object} props
* @param {string} props.name
* @param {string} props.displayName
- * @param {ReactElement} props.icon - React element
+ * @param {React.Component} props.icon - React element
* @param {object} props.thumbnail - thumbnail size object
* @param {number} props.thumbnail.width - thumbnail width in pixels
* @param {number} props.thumbnail.height - thumbnail height in pixels
@@ -138,9 +138,9 @@ export default class Provider {
* @param {Object} param.mapData - the map object
* @param {Object} param.mapData.map - {datasets. config, info: {title, description}}
* @param {Blob} param.mapData.thumbnail - A thumbnail of current map. thumbnail size can be defined by provider by this.thumbnail
- * @param {Object} param.options
- * @param {boolean} param.options.overwrite - whether user choose to overwrite already saved map under the same name
- * @param {boolean} param.options.isPublic - whether user wish to share the map with others. if isPublic is truthy, kepler will call this.getShareUrl() to display an URL they can share with others
+ * @param {object} [param.options]
+ * @param {boolean} [param.options.overwrite] - whether user choose to overwrite already saved map under the same name
+ * @param {boolean} [param.options.isPublic] - whether user wish to share the map with others. if isPublic is truthy, kepler will call this.getShareUrl() to display an URL they can share with others
* @public
*/
async uploadMap({mapData, options = {}}) {
@@ -149,7 +149,7 @@ export default class Provider {
/**
* This method is called to get a list of maps saved by the current logged in user.
- * @returns {Array<Viz>} an array of Viz objects
+ * @returns visualizations an array of Viz objects
* @public
* @example
* async listMaps() {
@@ -173,7 +173,7 @@ export default class Provider {
/**
* This method will be called when user select a map to load from the storage map viewer
* @param {*} loadParams - the loadParams property of each visualization object
- * @returns {MapResponse} - the map object containing dataset config info and format option
+ * @returns mapResponse - the map object containing dataset config info and format option
* @public
* @example
* async downloadMap(loadParams) {
diff --git a/src/components/map-container.js b/src/components/map-container.js
index f4d286172..99e5b0cbd 100644
--- a/src/components/map-container.js
+++ b/src/components/map-container.js
@@ -61,9 +61,15 @@ const TRANSITION_DURATION = 0;
const Attribution = () => (
<StyledAttrbution>
- <a href="https://kepler.gl/policy/" target="_blank" rel="noopener noreferrer">© kepler.gl | </a>
- <a href="https://www.mapbox.com/about/maps/" target="_blank" rel="noopener noreferrer">© Mapbox | </a>
- <a href="http://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">© OpenStreetMap | </a>
+ <a href="https://kepler.gl/policy/" target="_blank" rel="noopener noreferrer">
+ © kepler.gl |{' '}
+ </a>
+ <a href="https://www.mapbox.com/about/maps/" target="_blank" rel="noopener noreferrer">
+ © Mapbox |{' '}
+ </a>
+ <a href="http://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">
+ © OpenStreetMap |{' '}
+ </a>
<a href="https://www.mapbox.com/map-feedback/" target="_blank" rel="noopener noreferrer">
<strong>Improve this map</strong>
</a>
@@ -73,7 +79,6 @@ const Attribution = () => (
MapContainerFactory.deps = [MapPopoverFactory, MapControlFactory, EditorFactory];
export default function MapContainerFactory(MapPopover, MapControl, Editor) {
-
class MapContainer extends Component {
static propTypes = {
// required
@@ -522,7 +527,7 @@ export default function MapContainerFactory(MapPopover, MapControl, Editor) {
</div>
)}
{this._renderMapPopover(layersToRender)}
- <Attribution/>
+ <Attribution />
</StyledMapContainer>
);
}
diff --git a/src/components/side-panel/layer-panel/layer-configurator.js b/src/components/side-panel/layer-panel/layer-configurator.js
index 383a11722..99d06bc8b 100644
--- a/src/components/side-panel/layer-panel/layer-configurator.js
+++ b/src/components/side-panel/layer-panel/layer-configurator.js
@@ -112,7 +112,7 @@ export default function LayerConfiguratorFactory(SourceDataSelector) {
<StyledLayerVisualConfigurator>
{/* Fill Color */}
<LayerConfigGroup
- {...layer.visConfigSettings.filled || {label: 'layer.color'}}
+ {...(layer.visConfigSettings.filled || {label: 'layer.color'})}
{...visConfiguratorProps}
collapsible
>
diff --git a/src/components/side-panel/map-manager.js b/src/components/side-panel/map-manager.js
index 153c7d38c..56d54ecfe 100644
--- a/src/components/side-panel/map-manager.js
+++ b/src/components/side-panel/map-manager.js
@@ -49,11 +49,6 @@ function MapManagerFactory(MapStyleSelector, LayerGroupSelector) {
buildingColorSelector = props => props.mapStyle.threeDBuildingColor;
setColorSelector = props => props.set3dBuildingColor;
- _updateConfig = newProp => {
- const newConfig = {...this.props.mapStyle, ...newProp};
- this.props.onConfigChange(newConfig);
- };
-
_toggleSelecting = () => {
this.setState({isSelecting: !this.state.isSelecting});
};
@@ -96,7 +91,7 @@ function MapManagerFactory(MapStyleSelector, LayerGroupSelector) {
layers={mapStyle.visibleLayerGroups}
editableLayers={editableLayers}
topLayers={mapStyle.topLayerGroups}
- onChange={this._updateConfig}
+ onChange={this.props.onConfigChange}
/>
) : null}
<SidePanelSection>
diff --git a/src/constants/action-types.d.ts b/src/constants/action-types.d.ts
new file mode 100644
index 000000000..9f0ec7540
--- /dev/null
+++ b/src/constants/action-types.d.ts
@@ -0,0 +1,120 @@
+export type ActionType = {
+ // identity action
+ REGISTER_ENTRY: string;
+ DELETE_ENTRY: string;
+ RENAME_ENTRY: string;
+
+ // visState
+ ADD_DATA: string;
+ ADD_FILTER: string;
+ ADD_LAYER: string;
+ INTERACTION_CONFIG_CHANGE: string;
+ LAYER_CONFIG_CHANGE: string;
+ LAYER_VISUAL_CHANNEL_CHANGE: string;
+ LAYER_TYPE_CHANGE: string;
+ LAYER_VIS_CONFIG_CHANGE: string;
+ LAYER_TEXT_LABEL_CHANGE: string;
+ LAYER_HOVER: string;
+ LAYER_CLICK: string;
+ MAP_CLICK: string;
+ MOUSE_MOVE: string;
+ REMOVE_FILTER: string;
+ REMOVE_LAYER: string;
+ REMOVE_DATASET: string;
+ REORDER_LAYER: string;
+ SET_FILTER: string;
+ SHOW_DATASET_TABLE: string;
+ UPDATE_LAYER_BLENDING: string;
+ UPDATE_VIS_DATA: string;
+ TOGGLE_FILTER_ANIMATION: string;
+ UPDATE_FILTER_ANIMATION_SPEED: string;
+ PLAY_ANIMATION: string;
+ UPDATE_ANIMATION_TIME: string;
+ UPDATE_ANIMATION_SPEED: string;
+ UPDATE_LAYER_ANIMATION_SPEED: string;
+ TOGGLE_LAYER_CONFIG_ACTIVE: string;
+ ENLARGE_FILTER: string;
+ TOGGLE_FILTER_FEATURE: string;
+ SET_VISIBLE_LAYERS_FOR_MAP: string;
+ TOGGLE_LAYER_FOR_MAP: string;
+ SET_FILTER_PLOT: string;
+ LOAD_FILES: string;
+ LOAD_NEXT_FILE: string;
+ LOAD_FILES_ERR: string;
+ LOAD_FILES_SUCCESS: string;
+ LAYER_COLOR_UI_CHANGE: string;
+ TOGGLE_FEATURE_LAYER: string;
+ APPLY_CPU_FILTER: string;
+ SET_MAP_INFO: string;
+ SORT_TABLE_COLUMN: string;
+ PIN_TABLE_COLUMN: string;
+ COPY_TABLE_COLUMN: string;
+
+ // mapState
+ UPDATE_MAP: string;
+ FIT_BOUNDS: string;
+ TOGGLE_PERSPECTIVE: string;
+ TOGGLE_SPLIT_MAP: string;
+ TOGGLE_FULLSCREEN: string;
+
+ // mapStyle
+ MAP_CONFIG_CHANGE: string;
+ SET_DEFAULT_MAP_STYLE: string;
+ MAP_STYLE_CHANGE: string;
+ LOAD_MAP_STYLES: string;
+ LOAD_MAP_STYLE_ERR: string;
+ INPUT_MAP_STYLE: string;
+ LOAD_CUSTOM_MAP_STYLE: string;
+ ADD_CUSTOM_MAP_STYLE: string;
+ REQUEST_MAP_STYLES: string;
+ SET_3D_BUILDING_COLOR: string;
+
+ // uiState
+ TOGGLE_SIDE_PANEL: string;
+ TOGGLE_MODAL: string;
+ SHOW_EXPORT_DROPDOWN: string;
+ HIDE_EXPORT_DROPDOWN: string;
+ OPEN_DELETE_MODAL: string;
+ TOGGLE_MAP_CONTROL: string;
+ ADD_NOTIFICATION: string;
+ REMOVE_NOTIFICATION: string;
+ SET_LOCALE: string;
+
+ // uiState > export image
+ SET_EXPORT_IMAGE_SETTING: string;
+ START_EXPORTING_IMAGE: string;
+ SET_EXPORT_IMAGE_DATA_URI: string;
+ SET_EXPORT_IMAGE_ERROR: string;
+ CLEANUP_EXPORT_IMAGE: string;
+
+ // uiState > export data
+ SET_EXPORT_SELECTED_DATASET: string;
+ SET_EXPORT_DATA_TYPE: string;
+ SET_EXPORT_FILTERED: string;
+ SET_EXPORT_DATA: string;
+
+ // uiState > export map
+ SET_EXPORT_MAP_FORMAT: string;
+ SET_USER_MAPBOX_ACCESS_TOKEN: string;
+ SET_EXPORT_MAP_HTML_MODE: string;
+
+ // uiState > editor
+ SET_EDITOR_MODE: string;
+ SET_SELECTED_FEATURE: string;
+
+ // all
+ INIT: string;
+ ADD_DATA_TO_MAP: string;
+ RECEIVE_MAP_CONFIG: string;
+ RESET_MAP_CONFIG: string;
+
+ // geo-operations
+ SET_FEATURES: string;
+ SET_POLYGON_FILTER_LAYER: string;
+ DELETE_FEATURE: string;
+ TOGGLE_EDITOR_VISIBILITY: string;
+};
+
+export const ActionTypes: ActionType;
+export const ACTION_PREFIX: string;
+export default ActionTypes;
\ No newline at end of file
diff --git a/src/constants/action-types.js b/src/constants/action-types.js
index 5a21ee0a7..7cea768e7 100644
--- a/src/constants/action-types.js
+++ b/src/constants/action-types.js
@@ -18,8 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import keyMirror from 'keymirror';
-import {ACTION_PREFIX} from './default-settings';
+export const ACTION_PREFIX = '@@kepler.gl/';
/**
* Kepler.gl action types, can be listened by reducers to perform additional tasks whenever an action is called in kepler.gl
@@ -51,130 +50,120 @@ import {ACTION_PREFIX} from './default-settings';
*
* export default createStore(reducers, {}, applyMiddleware(taskMiddleware))
*/
-const ActionTypes = keyMirror({
+const ActionTypes = {
// identity action
- REGISTER_ENTRY: null,
- DELETE_ENTRY: null,
- RENAME_ENTRY: null,
+ REGISTER_ENTRY: `${ACTION_PREFIX}REGISTER_ENTRY`,
+ DELETE_ENTRY: `${ACTION_PREFIX}DELETE_ENTRY`,
+ RENAME_ENTRY: `${ACTION_PREFIX}RENAME_ENTRY`,
// visState
- ADD_DATA: null,
- ADD_FILTER: null,
- ADD_LAYER: null,
- INTERACTION_CONFIG_CHANGE: null,
- LAYER_CONFIG_CHANGE: null,
- LAYER_VISUAL_CHANNEL_CHANGE: null,
- LAYER_TYPE_CHANGE: null,
- LAYER_VIS_CONFIG_CHANGE: null,
- LAYER_TEXT_LABEL_CHANGE: null,
- LAYER_HOVER: null,
- LAYER_CLICK: null,
- MAP_CLICK: null,
- MOUSE_MOVE: null,
- REMOVE_FILTER: null,
- REMOVE_LAYER: null,
- REMOVE_DATASET: null,
- REORDER_LAYER: null,
- SET_FILTER: null,
- SHOW_DATASET_TABLE: null,
- UPDATE_LAYER_BLENDING: null,
- UPDATE_VIS_DATA: null,
- TOGGLE_FILTER_ANIMATION: null,
- UPDATE_FILTER_ANIMATION_SPEED: null,
- PLAY_ANIMATION: null,
- UPDATE_ANIMATION_TIME: null,
- UPDATE_ANIMATION_SPEED: null,
- UPDATE_LAYER_ANIMATION_SPEED: null,
- TOGGLE_LAYER_CONFIG_ACTIVE: null,
- ENLARGE_FILTER: null,
- TOGGLE_FILTER_FEATURE: null,
- SET_VISIBLE_LAYERS_FOR_MAP: null,
- TOGGLE_LAYER_FOR_MAP: null,
- SET_FILTER_PLOT: null,
- LOAD_FILES: null,
- LOAD_NEXT_FILE: null,
- LOAD_FILES_ERR: null,
- LOAD_FILES_SUCCESS: null,
- LAYER_COLOR_UI_CHANGE: null,
- TOGGLE_FEATURE_LAYER: null,
- APPLY_CPU_FILTER: null,
- SET_MAP_INFO: null,
- SORT_TABLE_COLUMN: null,
- PIN_TABLE_COLUMN: null,
- COPY_TABLE_COLUMN: null,
+ ADD_DATA: `${ACTION_PREFIX}ADD_DATA`,
+ ADD_FILTER: `${ACTION_PREFIX}ADD_FILTER`,
+ ADD_LAYER: `${ACTION_PREFIX}ADD_LAYER`,
+ INTERACTION_CONFIG_CHANGE: `${ACTION_PREFIX}INTERACTION_CONFIG_CHANGE`,
+ LAYER_CONFIG_CHANGE: `${ACTION_PREFIX}LAYER_CONFIG_CHANGE`,
+ LAYER_VISUAL_CHANNEL_CHANGE: `${ACTION_PREFIX}LAYER_VISUAL_CHANNEL_CHANGE`,
+ LAYER_TYPE_CHANGE: `${ACTION_PREFIX}LAYER_TYPE_CHANGE`,
+ LAYER_VIS_CONFIG_CHANGE: `${ACTION_PREFIX}LAYER_VIS_CONFIG_CHANGE`,
+ LAYER_TEXT_LABEL_CHANGE: `${ACTION_PREFIX}LAYER_TEXT_LABEL_CHANGE`,
+ LAYER_HOVER: `${ACTION_PREFIX}LAYER_HOVER`,
+ LAYER_CLICK: `${ACTION_PREFIX}LAYER_CLICK`,
+ MAP_CLICK: `${ACTION_PREFIX}MAP_CLICK`,
+ MOUSE_MOVE: `${ACTION_PREFIX}MOUSE_MOVE`,
+ REMOVE_FILTER: `${ACTION_PREFIX}REMOVE_FILTER`,
+ REMOVE_LAYER: `${ACTION_PREFIX}REMOVE_LAYER`,
+ REMOVE_DATASET: `${ACTION_PREFIX}REMOVE_DATASET`,
+ REORDER_LAYER: `${ACTION_PREFIX}REORDER_LAYER`,
+ SET_FILTER: `${ACTION_PREFIX}SET_FILTER`,
+ SHOW_DATASET_TABLE: `${ACTION_PREFIX}SHOW_DATASET_TABLE`,
+ UPDATE_LAYER_BLENDING: `${ACTION_PREFIX}UPDATE_LAYER_BLENDING`,
+ UPDATE_VIS_DATA: `${ACTION_PREFIX}UPDATE_VIS_DATA`,
+ TOGGLE_FILTER_ANIMATION: `${ACTION_PREFIX}TOGGLE_FILTER_ANIMATION`,
+ UPDATE_FILTER_ANIMATION_SPEED: `${ACTION_PREFIX}UPDATE_FILTER_ANIMATION_SPEED`,
+ PLAY_ANIMATION: `${ACTION_PREFIX}PLAY_ANIMATION`,
+ UPDATE_ANIMATION_TIME: `${ACTION_PREFIX}UPDATE_ANIMATION_TIME`,
+ UPDATE_ANIMATION_SPEED: `${ACTION_PREFIX}UPDATE_ANIMATION_SPEED`,
+ UPDATE_LAYER_ANIMATION_SPEED: `${ACTION_PREFIX}UPDATE_LAYER_ANIMATION_SPEED`,
+ TOGGLE_LAYER_CONFIG_ACTIVE: `${ACTION_PREFIX}TOGGLE_LAYER_CONFIG_ACTIVE`,
+ ENLARGE_FILTER: `${ACTION_PREFIX}ENLARGE_FILTER`,
+ TOGGLE_FILTER_FEATURE: `${ACTION_PREFIX}TOGGLE_FILTER_FEATURE`,
+ TOGGLE_LAYER_FOR_MAP: `${ACTION_PREFIX}TOGGLE_LAYER_FOR_MAP`,
+ SET_FILTER_PLOT: `${ACTION_PREFIX}SET_FILTER_PLOT`,
+ LOAD_FILES: `${ACTION_PREFIX}LOAD_FILES`,
+ LOAD_NEXT_FILE: `${ACTION_PREFIX}LOAD_NEXT_FILE`,
+ LOAD_FILES_ERR: `${ACTION_PREFIX}LOAD_FILES_ERR`,
+ LOAD_FILES_SUCCESS: `${ACTION_PREFIX}LOAD_FILES_SUCCESS`,
+ LAYER_COLOR_UI_CHANGE: `${ACTION_PREFIX}LAYER_COLOR_UI_CHANGE`,
+ TOGGLE_FEATURE_LAYER: `${ACTION_PREFIX}TOGGLE_FEATURE_LAYER`,
+ APPLY_CPU_FILTER: `${ACTION_PREFIX}APPLY_CPU_FILTER`,
+ SET_MAP_INFO: `${ACTION_PREFIX}SET_MAP_INFO`,
+ SORT_TABLE_COLUMN: `${ACTION_PREFIX}SORT_TABLE_COLUMN`,
+ PIN_TABLE_COLUMN: `${ACTION_PREFIX}PIN_TABLE_COLUMN`,
+ COPY_TABLE_COLUMN: `${ACTION_PREFIX}COPY_TABLE_COLUMN`,
// mapState
- UPDATE_MAP: null,
- FIT_BOUNDS: null,
- TOGGLE_PERSPECTIVE: null,
- TOGGLE_SPLIT_MAP: null,
- TOGGLE_FULLSCREEN: null,
+ UPDATE_MAP: `${ACTION_PREFIX}UPDATE_MAP`,
+ FIT_BOUNDS: `${ACTION_PREFIX}FIT_BOUNDS`,
+ TOGGLE_PERSPECTIVE: `${ACTION_PREFIX}TOGGLE_PERSPECTIVE`,
+ TOGGLE_SPLIT_MAP: `${ACTION_PREFIX}TOGGLE_SPLIT_MAP`,
+ TOGGLE_FULLSCREEN: `${ACTION_PREFIX}TOGGLE_FULLSCREEN`,
// mapStyle
- MAP_CONFIG_CHANGE: null,
- SET_DEFAULT_MAP_STYLE: null,
- MAP_STYLE_CHANGE: null,
- LOAD_MAP_STYLES: null,
- LOAD_MAP_STYLE_ERR: null,
- INPUT_MAP_STYLE: null,
- LOAD_CUSTOM_MAP_STYLE: null,
- ADD_CUSTOM_MAP_STYLE: null,
- REQUEST_MAP_STYLES: null,
- SET_3D_BUILDING_COLOR: null,
+ MAP_CONFIG_CHANGE: `${ACTION_PREFIX}MAP_CONFIG_CHANGE`,
+ SET_DEFAULT_MAP_STYLE: `${ACTION_PREFIX}SET_DEFAULT_MAP_STYLE`,
+ MAP_STYLE_CHANGE: `${ACTION_PREFIX}MAP_STYLE_CHANGE`,
+ LOAD_MAP_STYLES: `${ACTION_PREFIX}LOAD_MAP_STYLES`,
+ LOAD_MAP_STYLE_ERR: `${ACTION_PREFIX}LOAD_MAP_STYLE_ERR`,
+ INPUT_MAP_STYLE: `${ACTION_PREFIX}INPUT_MAP_STYLE`,
+ LOAD_CUSTOM_MAP_STYLE: `${ACTION_PREFIX}LOAD_CUSTOM_MAP_STYLE`,
+ ADD_CUSTOM_MAP_STYLE: `${ACTION_PREFIX}ADD_CUSTOM_MAP_STYLE`,
+ REQUEST_MAP_STYLES: `${ACTION_PREFIX}REQUEST_MAP_STYLES`,
+ SET_3D_BUILDING_COLOR: `${ACTION_PREFIX}SET_3D_BUILDING_COLOR`,
// uiState
- TOGGLE_SIDE_PANEL: null,
- TOGGLE_MODAL: null,
- SHOW_EXPORT_DROPDOWN: null,
- HIDE_EXPORT_DROPDOWN: null,
- OPEN_DELETE_MODAL: null,
- TOGGLE_MAP_CONTROL: null,
- ADD_NOTIFICATION: null,
- REMOVE_NOTIFICATION: null,
- SET_LOCALE: null,
+ TOGGLE_SIDE_PANEL: `${ACTION_PREFIX}TOGGLE_SIDE_PANEL`,
+ TOGGLE_MODAL: `${ACTION_PREFIX}TOGGLE_MODAL`,
+ SHOW_EXPORT_DROPDOWN: `${ACTION_PREFIX}SHOW_EXPORT_DROPDOWN`,
+ HIDE_EXPORT_DROPDOWN: `${ACTION_PREFIX}HIDE_EXPORT_DROPDOWN`,
+ OPEN_DELETE_MODAL: `${ACTION_PREFIX}OPEN_DELETE_MODAL`,
+ TOGGLE_MAP_CONTROL: `${ACTION_PREFIX}TOGGLE_MAP_CONTROL`,
+ ADD_NOTIFICATION: `${ACTION_PREFIX}ADD_NOTIFICATION`,
+ REMOVE_NOTIFICATION: `${ACTION_PREFIX}REMOVE_NOTIFICATION`,
+ SET_LOCALE: `${ACTION_PREFIX}SET_LOCALE`,
// uiState > export image
- SET_EXPORT_IMAGE_SETTING: null,
- START_EXPORTING_IMAGE: null,
- SET_EXPORT_IMAGE_DATA_URI: null,
- SET_EXPORT_IMAGE_ERROR: null,
- CLEANUP_EXPORT_IMAGE: null,
+ SET_EXPORT_IMAGE_SETTING: `${ACTION_PREFIX}SET_EXPORT_IMAGE_SETTING`,
+ START_EXPORTING_IMAGE: `${ACTION_PREFIX}START_EXPORTING_IMAGE`,
+ SET_EXPORT_IMAGE_DATA_URI: `${ACTION_PREFIX}SET_EXPORT_IMAGE_DATA_URI`,
+ SET_EXPORT_IMAGE_ERROR: `${ACTION_PREFIX}SET_EXPORT_IMAGE_ERROR`,
+ CLEANUP_EXPORT_IMAGE: `${ACTION_PREFIX}CLEANUP_EXPORT_IMAGE`,
// uiState > export data
- SET_EXPORT_SELECTED_DATASET: null,
- SET_EXPORT_DATA_TYPE: null,
- SET_EXPORT_FILTERED: null,
- SET_EXPORT_DATA: null,
+ SET_EXPORT_SELECTED_DATASET: `${ACTION_PREFIX}SET_EXPORT_SELECTED_DATASET`,
+ SET_EXPORT_DATA_TYPE: `${ACTION_PREFIX}SET_EXPORT_DATA_TYPE`,
+ SET_EXPORT_FILTERED: `${ACTION_PREFIX}SET_EXPORT_FILTERED`,
+ SET_EXPORT_DATA: `${ACTION_PREFIX}SET_EXPORT_DATA`,
// uiState > export map
- SET_EXPORT_MAP_FORMAT: null,
- SET_USER_MAPBOX_ACCESS_TOKEN: null,
- SET_EXPORT_MAP_HTML_MODE: null,
+ SET_EXPORT_MAP_FORMAT: `${ACTION_PREFIX}SET_EXPORT_MAP_FORMAT`,
+ SET_USER_MAPBOX_ACCESS_TOKEN: `${ACTION_PREFIX}SET_USER_MAPBOX_ACCESS_TOKEN`,
+ SET_EXPORT_MAP_HTML_MODE: `${ACTION_PREFIX}SET_EXPORT_MAP_HTML_MODE`,
// uiState > editor
- SET_EDITOR_MODE: null,
- SET_SELECTED_FEATURE: null,
+ SET_EDITOR_MODE: `${ACTION_PREFIX}SET_EDITOR_MODE`,
+ SET_SELECTED_FEATURE: `${ACTION_PREFIX}SET_SELECTED_FEATURE`,
// all
- INIT: null,
- ADD_DATA_TO_MAP: null,
- RECEIVE_MAP_CONFIG: null,
- RESET_MAP_CONFIG: null,
+ INIT: `${ACTION_PREFIX}INIT`,
+ ADD_DATA_TO_MAP: `${ACTION_PREFIX}ADD_DATA_TO_MAP`,
+ RECEIVE_MAP_CONFIG: `${ACTION_PREFIX}RECEIVE_MAP_CONFIG`,
+ RESET_MAP_CONFIG: `${ACTION_PREFIX}RESET_MAP_CONFIG`,
// geo-operations
- SET_FEATURES: null,
- SET_POLYGON_FILTER_LAYER: null,
- DELETE_FEATURE: null,
- TOGGLE_EDITOR_VISIBILITY: null
-});
+ SET_FEATURES: `${ACTION_PREFIX}SET_FEATURES`,
+ SET_POLYGON_FILTER_LAYER: `${ACTION_PREFIX}SET_POLYGON_FILTER_LAYER`,
+ DELETE_FEATURE: `${ACTION_PREFIX}DELETE_FEATURE`,
+ TOGGLE_EDITOR_VISIBILITY: `${ACTION_PREFIX}TOGGLE_EDITOR_VISIBILITY`
+};
-export const addPrefix = actions =>
- Object.keys(actions).reduce(
- (accu, key) => ({
- ...accu,
- [key]: `${ACTION_PREFIX}${actions[key]}`
- }),
- {}
- );
-
-export default addPrefix(ActionTypes);
+export default ActionTypes;
diff --git a/src/constants/color-ranges.js b/src/constants/color-ranges.js
index 6ebaa6ee2..bdf373346 100644
--- a/src/constants/color-ranges.js
+++ b/src/constants/color-ranges.js
@@ -55,4 +55,9 @@ for (const [keyName, colorScheme] of Object.entries(colorbrewer)) {
export const COLOR_RANGES = colorRanges;
-export const DefaultColorRange = colorRanges.find(({name}) => name === 'Global Warming');
+export const DefaultColorRange = colorRanges.find(({name}) => name === 'Global Warming') || {
+ name: 'Global Warming',
+ type: 'SEQ',
+ category: 'Uber',
+ colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300']
+};
diff --git a/src/constants/index.js b/src/constants/index.js
index 1c11180d2..6767c529d 100644
--- a/src/constants/index.js
+++ b/src/constants/index.js
@@ -26,7 +26,6 @@ export {
ALL_FIELD_TYPES,
DATA_TABLE_ID,
DATASET_FORMATS,
- DEFAULT_COLOR_RANGE,
DEFAULT_LAYER_GROUPS,
DEFAULT_MAP_STYLES,
DEFAULT_NOTIFICATION_TOPICS,
@@ -65,3 +64,4 @@ export {BUG_REPORT_LINK, USER_GUIDE_DOC} from './user-guides';
export {VizColorPalette, DataVizColors} from './custom-color-ranges';
export {COLOR_RANGES, DefaultColorRange} from './color-ranges';
+export {DEFAULT_COLOR_RANGE} from 'layers/layer-factory';
diff --git a/src/layers/index.d.ts b/src/layers/index.d.ts
new file mode 100644
index 000000000..054852c31
--- /dev/null
+++ b/src/layers/index.d.ts
@@ -0,0 +1,80 @@
+import {RGBColor, RGBAColor} from '../reducers/types';
+import {Dataset, Field, Datasets} from '../reducers/vis-state-updaters';
+import {LayerTextLabel, ColorRange, ColorUI} from './layer-factory';
+
+export type LayerVisConfig = {
+ opacity: number;
+ colorRange: ColorRange;
+};
+
+export type LayerColumns = {
+ [key: string]: {value: string | null; fieldIdx: number; optional?: boolean};
+};
+export type VisualChannelDomain = number[] | string[];
+export type VisualChannelField = Field | null;
+
+export type LayerConfig = {
+ dataId: string | null;
+ label: string;
+ color: RGBColor;
+
+ columns: LayerColumns;
+ isVisible: boolean;
+ isConfigActive: boolean;
+ highlightColor: RGBColor | RGBAColor;
+ hidden: boolean;
+
+ colorField: VisualChannelField;
+ colorDomain: VisualChannelDomain;
+ colorScale: string;
+
+ // color by size, domain is set by filters, field, scale type
+ sizeDomain: VisualChannelDomain;
+ sizeScale: string;
+ sizeField: VisualChannelField;
+
+ visConfig: LayerVisConfig;
+ textLabel: LayerTextLabel[];
+
+ colorUI: {
+ color: ColorUI;
+ colorRange: ColorUI;
+ };
+ animation: {
+ enabled: boolean;
+ };
+};
+
+export class Layer {
+ constructor(
+ prop?: {
+ id?: string;
+ } & Partial<LayerConfig>
+ );
+ id: string;
+ type: string;
+ config: LayerConfig;
+ visConfigSettings: any;
+ hasAllColumns(): boolean;
+ updateLayerConfig(p: Partial<LayerConfig>): Layer;
+ updateLayerVisualChannel(dataset: Dataset, channel: string): Layer;
+ shouldCalculateLayerData(props: string[]): boolean;
+ formatLayerData(datasets: Datasets, oldLayerData?: any);
+ updateLayerColorUI(prop: string, newConfig: Partial<ColorUI>): Layer;
+}
+
+export const LayerClasses: {
+ point: Layer;
+ arc: Layer;
+ line: Layer;
+ grid: Layer;
+ hexagon: Layer;
+ geojson: Layer;
+ cluster: Layer;
+ icon: Layer;
+ heatmap: Layer;
+ hexagonId: Layer;
+ '3D': Layer;
+ trip: Layer;
+ s2: Layer;
+};
diff --git a/src/layers/layer-factory.d.ts b/src/layers/layer-factory.d.ts
new file mode 100644
index 000000000..7064c5c5a
--- /dev/null
+++ b/src/layers/layer-factory.d.ts
@@ -0,0 +1,145 @@
+import {RGBColor, RGBAColor, HexColor, Field} from 'reducers';
+
+export type ColorRange = {
+ name: string;
+ type: string;
+ category: string;
+ colors: HexColor[];
+ reversed?: boolean;
+};
+
+export type LayerTextLabel = {
+ field: Field | null;
+ color: RGBColor;
+ size: number;
+ offset: [number, number];
+ anchor: string;
+ alignment: string;
+};
+
+export type ColorUI = {
+ // customPalette in edit
+ customPalette: ColorRange;
+ // show color sketcher modal
+ showSketcher: boolean;
+ // show color range selection panel
+ showDropdown: boolean;
+ // color range selector config
+ colorRangeConfig: {
+ type: string;
+ steps: number;
+ reversed: boolean;
+ custom: boolean;
+ };
+};
+
+export type VisConfig = {
+ label: string | ((config: LayerConfig) => string);
+ group: string;
+ property: string;
+ description?: string;
+ condition?: (config: LayerConfig) => boolean;
+};
+
+export type VisConfigNumber = VisConfig & {
+ type: 'number';
+ isRanged: false;
+ defaultValue: number;
+ range: [number, number];
+ step: number;
+};
+
+export type VisConfigBoolean = VisConfig & {
+ type: 'boolean';
+ defaultValue: boolean;
+};
+
+export type VisConfigSelection = VisConfig & {
+ type: 'select';
+ defaultValue: string;
+ options: string[];
+};
+
+export type VisConfigRange = VisConfig & {
+ type: 'number';
+ isRanged: boolean;
+ range: [number, number];
+ defaultValue: [number, number];
+ step: number;
+};
+
+export type VisConfigColorSelect = VisConfig & {
+ type: 'color-select';
+ defaultValue: null;
+};
+
+export type VisConfigColorRange = VisConfig & {
+ type: 'color-range-select';
+ defaultValue: ColorRange;
+};
+
+export type LayerVisConfig = {
+ thickness: VisConfigNumber;
+ strokeWidthRange: VisConfigRange;
+ trailLength: VisConfigNumber;
+ radius: VisConfigNumber;
+ fixedRadius: VisConfigBoolean;
+ radiusRange: VisConfigRange;
+ clusterRadius: VisConfigNumber;
+ clusterRadiusRange: VisConfigRange;
+ opacity: VisConfigNumber;
+ coverage: VisConfigNumber;
+ outline: VisConfigBoolean;
+ colorRange: VisConfigColorRange;
+ strokeColorRange: VisConfigColorRange;
+ targetColor: VisConfigColorSelect;
+ strokeColor: VisConfigColorSelect;
+ aggregation: VisConfigSelect;
+ sizeAggregation: VisConfigSelect;
+ percentile: VisConfigRange;
+ elevationPercentile: VisConfigRange;
+ resolution: VisConfigNumber;
+ sizeScale: VisConfigNumber;
+ angle: VisConfigNumber;
+ worldUnitSize: VisConfigNumber;
+ elevationScale: VisConfigNumber;
+ elevationRange: VisConfigRange;
+ heightRange: VisConfigRange;
+ coverageRange: VisConfigRange;
+ 'hi-precision': VisConfigBoolean;
+ enable3d: VisConfigBoolean;
+ stroked: VisConfigBoolean;
+ filled: VisConfigBoolean;
+ extruded: VisConfigBoolean;
+ wireframe: VisConfigBoolean;
+ weight: VisConfigNumber;
+ heatmapRadius: VisConfigNumber;
+};
+
+export type TextConfigSelect = {
+ type: 'select';
+ options: string[];
+ multiSelect: boolean;
+ searchable: boolean;
+};
+export type TextConfigNumber = {
+ type: 'number';
+ range: number[];
+ value0: number;
+ step: number;
+ isRanged: boolean;
+ label: string;
+ showInput: boolean;
+};
+export type LayerTextConfig = {
+ fontSize: TextConfigNumber;
+ textAnchor: TextConfigSelect;
+ textAlignment: TextConfigSelect;
+};
+
+export const DEFAULT_TEXT_LABEL: LayerTextLabel;
+export const DEFAULT_CUSTOM_PALETTE: ColorRange;
+export const DEFAULT_COLOR_UI: ColorUI;
+export const LAYER_VIS_CONFIGS: LayerVisConfig;
+export const LAYER_TEXT_CONFIGS: LayerTextConfig;
+export const DEFAULT_COLOR_RANGE: ColorRange;
diff --git a/src/layers/layer-factory.js b/src/layers/layer-factory.js
index 3821ce4a5..af33ae7fd 100644
--- a/src/layers/layer-factory.js
+++ b/src/layers/layer-factory.js
@@ -28,7 +28,7 @@ export const PROPERTY_GROUPS = keyMirror({
stroke: null,
radius: null,
height: null,
-
+ angle: null,
// for heatmap aggregation
cell: null,
precision: null
@@ -36,6 +36,7 @@ export const PROPERTY_GROUPS = keyMirror({
export const DEFAULT_LAYER_OPACITY = 0.8;
+/** @type {import('./layer-factory').LayerTextLabel} */
export const DEFAULT_TEXT_LABEL = {
field: null,
color: [255, 255, 255],
@@ -47,6 +48,7 @@ export const DEFAULT_TEXT_LABEL = {
export const DEFAULT_COLOR_RANGE = DefaultColorRange;
+/** @type {import('./layer-factory').ColorRange} */
export const DEFAULT_CUSTOM_PALETTE = {
name: 'color.customPalette',
type: 'custom',
@@ -54,6 +56,7 @@ export const DEFAULT_CUSTOM_PALETTE = {
colors: []
};
+/** @type {import('./layer-factory').ColorUI} */
export const DEFAULT_COLOR_UI = {
// customPalette in edit
customPalette: DEFAULT_CUSTOM_PALETTE,
@@ -70,6 +73,7 @@ export const DEFAULT_COLOR_UI = {
}
};
+/** @type {import('./layer-factory').LayerVisConfig} */
export const LAYER_VIS_CONFIGS = {
thickness: {
type: 'number',
@@ -276,14 +280,18 @@ export const LAYER_VIS_CONFIGS = {
isRanged: false,
range: [1, 1000],
step: 1,
+ group: PROPERTY_GROUPS.stroke,
property: 'sizeScale'
},
angle: {
type: 'number',
+ label: 'layerVisConfigs.angle',
defaultValue: 0,
isRanged: false,
range: [0, 360],
- step: 1
+ group: PROPERTY_GROUPS.angle,
+ step: 1,
+ property: 'angle'
},
worldUnitSize: {
type: 'number',
@@ -404,6 +412,7 @@ export const LAYER_VIS_CONFIGS = {
}
};
+/** @type {import('./layer-factory').LayerTextConfig} */
export const LAYER_TEXT_CONFIGS = {
fontSize: {
type: 'number',
diff --git a/src/localization/en.js b/src/localization/en.js
index 8fa41c9e8..bd0b367f1 100644
--- a/src/localization/en.js
+++ b/src/localization/en.js
@@ -122,6 +122,7 @@ export default {
}
},
layerVisConfigs: {
+ angle: 'Angle',
strokeWidth: 'Stroke Width (Pixels)',
strokeWidthRange: 'Stroke Width Range',
radius: 'Radius',
diff --git a/src/localization/locales.js b/src/localization/locales.js
index 9b00ff1ad..cbdd7720c 100644
--- a/src/localization/locales.js
+++ b/src/localization/locales.js
@@ -30,7 +30,6 @@ export const LOCALES = {
* Localization can be passed to `KeplerGl` via uiState `locale`.
* Available languages are `en` and `fi`. Default language is `en`
* @constant
- * @type {string}
* @public
* @example
* ```js
diff --git a/src/processors/data-processor.d.ts b/src/processors/data-processor.d.ts
new file mode 100644
index 000000000..dbc3d472f
--- /dev/null
+++ b/src/processors/data-processor.d.ts
@@ -0,0 +1,55 @@
+import {ProtoDataset} from '../actions';
+import {Field} from 'reducers/vis-state-updaters';
+import {SavedMap, ParsedDataset} from 'schemas';
+
+type RowData = {
+ [key: string]: any;
+}[];
+type ProcessorResult = {fields: Field[]; rows: any[][]} | null;
+export function processGeojson(rawData: object): ProcessorResult;
+export function processCsvData(rawData: string): ProcessorResult;
+export function processKeplerglJSON(rawData: SavedMap): ProcessorResult;
+export function processRowObject(rawData: object[]): ProcessorResult;
+export function processKeplerglDataset(
+ rawData: object | object[]
+): ParsedDataset | ParsedDataset[] | null;
+
+export function validateInputData(data: any): ProcessorResult;
+
+export function getSampleForTypeAnalyze(p: {
+ fields: string[];
+ allData: any[][];
+ sampleCount?: number;
+}): object[];
+
+export function getFieldsFromData(data: RowData, fieldOrder: string[]): Field[];
+
+export function parseCsvRowsByFieldType(
+ rows: any[][],
+ geoFieldIdx: number,
+ field: Field,
+ i: number
+): void;
+
+export function formatCsv(data: any[][], fields: Field[]): string;
+
+export function analyzerTypeToFieldType(aType: string): string;
+
+export const DATASET_HANDLERS: {
+ row: typeof processRowObject;
+ geojson: typeof processGeojson;
+ csv: typeof processCsvData;
+ keplergl: typeof processKeplerglDataset;
+};
+
+export const Processors: {
+ processGeojson: typeof processGeojson;
+ processCsvData: typeof processCsvData;
+ processRowObject: typeof processRowObject;
+ processKeplerglJSON: typeof processKeplerglJSON;
+ processKeplerglDataset: typeof processKeplerglDataset;
+ analyzerTypeToFieldType: typeof analyzerTypeToFieldType;
+ getFieldsFromData: typeof getFieldsFromData;
+ parseCsvRowsByFieldType: typeof parseCsvRowsByFieldType;
+ formatCsv: typeof formatCsv;
+};
diff --git a/src/processors/data-processor.js b/src/processors/data-processor.js
index d2dfc8e85..949c490b7 100644
--- a/src/processors/data-processor.js
+++ b/src/processors/data-processor.js
@@ -77,8 +77,9 @@ export const PARSE_FIELD_VALUE_FROM_STRING = {
/**
* Process csv data, output a data object with `{fields: [], rows: []}`.
* The data object can be wrapped in a `dataset` and pass to [`addDataToMap`](../actions/actions.md#adddatatomap)
- * @param {string} rawData raw csv string
- * @returns {Object} data object `{fields: [], rows: []}`
+ * @param rawData raw csv string
+ * @returns data object `{fields: [], rows: []}` can be passed to addDataToMaps
+ * @type {typeof import('./data-processor').processCsvData}
* @public
* @example
* import {processCsvData} from 'kepler.gl/processors';
@@ -126,7 +127,7 @@ export function processCsvData(rawData) {
/**
* Parse rows of csv by analyzed field types. So that `'1'` -> `1`, `'True'` -> `true`
* @param {Array<Array>} rows
- * @param {Array<Object} fields
+ * @param {Array<Object>} fields
*/
export function parseRowsByFields(rows, fields) {
// Edit rows in place
@@ -138,10 +139,7 @@ export function parseRowsByFields(rows, fields) {
/**
* Getting sample data for analyzing field type.
*
- * @param {Array<string>} fields an array of field names
- * @param {Array<Array>} allData
- * @param {Array} sampleCount
- * @returns {Array} formatted fields
+ * @type {typeof import('./data-processor').getSampleForTypeAnalyze}
*/
export function getSampleForTypeAnalyze({fields, allData, sampleCount = 50}) {
const total = Math.min(sampleCount, allData.length);
@@ -196,11 +194,11 @@ function cleanUpFalsyCsvValue(rows) {
/**
* Process uploaded csv file to parse value by field type
*
- * @param {Array<Array>} rows
- * @param {Number} geo field index
- * @param {Object} field
- * @param {Number} i
- * @returns {void}
+ * @param rows
+ * @param geoFieldIdx field index
+ * @param field
+ * @param i
+ * @type {typeof import('./data-processor').parseCsvRowsByFieldType}
*/
export function parseCsvRowsByFieldType(rows, geoFieldIdx, field, i) {
const parser = PARSE_FIELD_VALUE_FROM_STRING[field.type];
@@ -226,9 +224,10 @@ export function parseCsvRowsByFieldType(rows, geoFieldIdx, field, i) {
* Analyze field types from data in `string` format, e.g. uploaded csv.
* Assign `type`, `tableFieldIndex` and `format` (timestamp only) to each field
*
- * @param {Array<Object>} data array of row object
- * @param {Array} fieldOrder array of field names as string
- * @returns {Array<Object>} formatted fields
+ * @param data array of row object
+ * @param fieldOrder array of field names as string
+ * @returns formatted fields
+ * @type {typeof import('./data-processor').getFieldsFromData}
* @public
* @example
*
@@ -273,21 +272,20 @@ export function getFieldsFromData(data, fieldOrder) {
const {fieldByIndex} = renameDuplicateFields(fieldOrder);
- const result = fieldOrder.reduce((orderedArray, field, index) => {
+ const result = fieldOrder.map((field, index) => {
const name = fieldByIndex[index];
const fieldMeta = metadata.find(m => m.key === field);
const {type, format} = fieldMeta || {};
- orderedArray[index] = {
+ return {
name,
format,
tableFieldIndex: index + 1,
type: analyzerTypeToFieldType(type),
analyzerType: type
};
- return orderedArray;
- }, []);
+ });
return result;
}
@@ -326,8 +324,9 @@ export function renameDuplicateFields(fieldOrder) {
/**
* Convert type-analyzer output to kepler.gl field types
*
- * @param {string} aType
- * @returns {string} corresponding type in `ALL_FIELD_TYPES`
+ * @param aType
+ * @returns corresponding type in `ALL_FIELD_TYPES`
+ * @type {typeof import('./data-processor').analyzerTypeToFieldType}}
*/
/* eslint-disable complexity */
export function analyzerTypeToFieldType(aType) {
@@ -382,8 +381,9 @@ export function analyzerTypeToFieldType(aType) {
/**
* Process data where each row is an object, output can be passed to [`addDataToMap`](../actions/actions.md#adddatatomap)
- * @param {Array<Object>} rawData an array of row object, each object should have the same number of keys
- * @returns {Object} dataset containing `fields` and `rows`
+ * @param rawData an array of row object, each object should have the same number of keys
+ * @returns dataset containing `fields` and `rows`
+ * @type {typeof import('./data-processor').processRowObject}
* @public
* @example
* import {addDataToMap} from 'kepler.gl/actions';
@@ -425,8 +425,9 @@ export function processRowObject(rawData) {
* output a data object with `{fields: [], rows: []}`.
* The data object can be wrapped in a `dataset` and pass to [`addDataToMap`](../actions/actions.md#adddatatomap)
*
- * @param {Object} rawData raw geojson feature collection
- * @returns {Object} dataset containing `fields` and `rows`
+ * @param rawData raw geojson feature collection
+ * @returns dataset containing `fields` and `rows`
+ * @type {typeof import('./data-processor').processGeojson}
* @public
* @example
* import {addDataToMap} from 'kepler.gl/actions';
@@ -523,10 +524,7 @@ export function formatCsv(data, fields) {
/**
* Validate input data, adding missing field types, rename duplicate columns
- * @param {Object} data dataset.data
- * @param {Array<Object>} data.fields an array of fields
- * @param {Array<Object>} data.rows an array of data rows
- * @returns {{allData: Array, fields: Array}}
+ * @type {typeof import('./data-processor').validateInputData}
*/
export function validateInputData(data) {
if (!isPlainObject(data)) {
@@ -636,6 +634,9 @@ export function processKeplerglDataset(rawData) {
}
const results = KeplerGlSchema.parseSavedData(toArray(rawData));
+ if (!results) {
+ return null;
+ }
return Array.isArray(rawData) ? results : results[0];
}
diff --git a/src/processors/file-handler.d.ts b/src/processors/file-handler.d.ts
new file mode 100644
index 000000000..de8af0c29
--- /dev/null
+++ b/src/processors/file-handler.d.ts
@@ -0,0 +1,37 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+import {ProtoDataset, AddDataToMaoPayload} from 'actions/actions';
+
+export type FileCacheItem = {
+ data: any;
+ info: {
+ label: string;
+ format: string;
+ };
+};
+
+export function readFile(payload: {
+ file: File;
+ fileCache: FileCacheItem[];
+}): Promise<FileCacheItem[]>;
+export function getFileHandler(fileBlob: File): {handler: function; format: string};
+export function filesToDataPayload(fileCache: FileCacheItem[]): AddDataToMaoPayload[];
+export function getFileType(filename: string): 'csv' | 'json' | 'other';
\ No newline at end of file
diff --git a/src/processors/file-handler.js b/src/processors/file-handler.js
index da55ce924..c02dd237d 100644
--- a/src/processors/file-handler.js
+++ b/src/processors/file-handler.js
@@ -34,6 +34,7 @@ const FILE_HANDLERS = {
json: loadJSON
};
+/** @type {typeof import('./file-handler').readFile} */
export function readFile({file, fileCache = []}) {
return new Promise((resolve, reject) => {
const {handler, format} = getFileHandler(file);
@@ -63,12 +64,14 @@ export function readFile({file, fileCache = []}) {
});
}
+/** @type {typeof import('./file-handler').getFileHandler} */
export function getFileHandler(fileBlob) {
const type = getFileType(fileBlob.name);
return {handler: FILE_HANDLERS[type], format: type};
}
+/** @type {typeof import('./file-handler').getFileType} */
export function getFileType(filename) {
if (filename.endsWith('csv')) {
return 'csv';
diff --git a/src/reducers/combined-updaters.d.ts b/src/reducers/combined-updaters.d.ts
new file mode 100644
index 000000000..49031285e
--- /dev/null
+++ b/src/reducers/combined-updaters.d.ts
@@ -0,0 +1,26 @@
+import {VisState} from './vis-state-updaters';
+import {MapState} from './map-state-updaters';
+import {UiState} from './ui-state-updaters';
+import {MapStyle} from './map-style-updaters';
+import {ProviderState} from './provider-state-updaters';
+import {AddDataToMaoPayload} from 'actions/actions';
+import {FileCacheItem} from 'processors/file-handler';
+import {LoadFileSuccessUpdaterAction} from 'actions/vis-state-actions';
+
+export type KeplerGlState = {
+ visState: VisState;
+ mapState: MapState;
+ mapStyle: MapStyle;
+ uiState: UiState;
+ providerState: ProviderState;
+};
+
+export function addDataToMapUpdater(
+ state: KeplerGlState,
+ action: {payload: AddDataToMaoPayload}
+): KeplerGlState;
+
+export function loadFileSuccessUpdater(
+ state: KeplerGlState,
+ action: LoadFileSuccessUpdaterAction
+): KeplerGlState;
\ No newline at end of file
diff --git a/src/reducers/combined-updaters.js b/src/reducers/combined-updaters.js
index b722e799e..ba16522fb 100644
--- a/src/reducers/combined-updaters.js
+++ b/src/reducers/combined-updaters.js
@@ -74,7 +74,9 @@ import Console from 'global/console';
*
* export default composedReducer;
*/
+
/* eslint-disable no-unused-vars */
+// @ts-ignore
const combinedUpdaters = null;
/* eslint-enable no-unused-vars */
@@ -88,10 +90,12 @@ export const defaultAddDataToMapOptions = {
const identity = state => state;
-/* eslint-disable-next-line no-unused-vars */
+/* eslint-disable no-unused-vars */
+// @ts-ignore
function log(text) {
return value => Console.log(text, value);
}
+/* eslint-enable no-unused-vars */
function payload_(p) {
return {payload: p};
@@ -128,18 +132,23 @@ function pick_(prop) {
* @param {Object} state kepler.gl instance state, containing all subreducer state
* @param {Object} action
* @param {Object} action.payload `{datasets, options, config}`
- * @param {Array<Object>|Object} action.payload.datasets - ***required** datasets can be a dataset or an array of datasets
+ * @param action.payload.datasets - ***required** datasets can be a dataset or an array of datasets
* Each dataset object needs to have `info` and `data` property.
- * @param {Object} action.payload.datasets.info -info of a dataset
- * @param {string} action.payload.datasets.info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- * @param {string} action.payload.datasets.info.label - A display name of this dataset
- * @param {Object} action.payload.datasets.data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
- * @param {Array<Object>} action.payload.datasets.data.fields - ***required** Array of fields,
- * @param {string} action.payload.datasets.data.fields.name - ***required** Name of the field,
- * @param {Array<Array>} action.payload.datasets.data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
- * @param {Object} action.payload.options option object `{centerMap: true}`
- * @param {Object} action.payload.config map config
- * @returns {Object} nextState
+ * @param [action.payload.options] option object `{centerMap: true}`
+ * @param [action.payload.config] map config
+ * @param [action.payload.info] map info contains title and description
+ * @returns nextState
+ *
+ * @typedef {Object} Dataset
+ * @property info -info of a dataset
+ * @property info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
+ * @property info.label - A display name of this dataset
+ * @property data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
+ * @property data.fields - ***required** Array of fields,
+ * @property data.fields.name - ***required** Name of the field,
+ * @property data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
+ *
+ * @type {typeof import('./combined-updaters').addDataToMapUpdater}
* @public
*/
export const addDataToMapUpdater = (state, {payload}) => {
@@ -195,6 +204,9 @@ export const addDataToMapUpdater = (state, {payload}) => {
])(state);
};
+/**
+ * @type {typeof import('./combined-updaters').loadFileSuccessUpdater}
+ */
export const loadFileSuccessUpdater = (state, action) => {
// still more to load
const payloads = filesToDataPayload(action.result);
diff --git a/src/reducers/index.d.ts b/src/reducers/index.d.ts
new file mode 100644
index 000000000..732971afc
--- /dev/null
+++ b/src/reducers/index.d.ts
@@ -0,0 +1,118 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+// Root Reducer, used to register, and remove core reducers of each instance
+// export {default} from './root';
+// export {default as keplerGlReducer} from './root';
+
+// Core Reducer
+// export {
+// default as keplerGlReducerCore,
+// visStateLens,
+// mapStateLens,
+// uiStateLens,
+// mapStyleLens
+// } from './core';
+
+// Each individual reducer
+// export {default as visStateReducer} from './vis-state';
+// export {default as mapStateReducer} from './map-state';
+// export {default as mapStyleReducer} from './map-style';
+
+// reducer updaters
+export * as visStateUpdaters from './vis-state-updaters';
+export * as mapStateUpdaters from './map-state-updaters';
+export * as mapStyleUpdaters from './map-style-updaters';
+export * as uiStateUpdaters from './ui-state-updaters';
+
+// This will be deprecated
+export * as combineUpdaters from './combined-updaters';
+export * as combinedUpdaters from './combined-updaters';
+
+// reducer merges
+export * as visStateMergers from './vis-state-merger';
+
+// export tyes
+export {
+ AnimationConfig,
+ Brush,
+ Coordinate,
+ Dataset,
+ Datasets,
+ Editor,
+ Feature,
+ FeatureValue,
+ Field,
+ FieldDomain,
+ FieldPair,
+ Filter,
+ FilterBase,
+ FilterRecord,
+ Geocoder,
+ GpuFilter,
+ HistogramBin,
+ InteractionConfig,
+ LineChart,
+ MapInfo,
+ MultiSelectFieldDomain,
+ MultiSelectFilter,
+ PolygonFilter,
+ RangeFieldDomain,
+ RangeFilter,
+ SelectFieldDomain,
+ SelectFilter,
+ SplitMap,
+ TimeRangeFieldDomain,
+ TimeRangeFilter,
+ Tooltip,
+ VisState
+} from './vis-state-updaters';
+
+export {
+ BaseMapStyle,
+ InputStyle,
+ LayerGroup,
+ MapboxStyleUrl,
+ MapStyle,
+ MapStyles,
+ VisibleLayerGroups
+} from './map-style-updaters';
+
+export {
+ Bounds,
+ MapState,
+ Viewport
+} from './map-state-updaters';
+
+export {
+ ExportData,
+ ExportHtml,
+ ExportImage,
+ ExportJson,
+ ExportMap,
+ LoadFiles,
+ Locale,
+ MapControl,
+ MapControls,
+ Notifications,
+ UiState
+} from './ui-state-updaters';
+
+export * from './types';
\ No newline at end of file
diff --git a/src/reducers/map-state-updaters.d.ts b/src/reducers/map-state-updaters.d.ts
new file mode 100644
index 000000000..5075585d2
--- /dev/null
+++ b/src/reducers/map-state-updaters.d.ts
@@ -0,0 +1,64 @@
+import * as MapStateActions from 'actions/map-state-actions';
+import {ReceiveMapConfigPayload} from '../actions/actions';
+import ActionTypes from 'constants/action-types';
+
+export type MapState = {
+ pitch: number;
+ bearing: number;
+ latitude: number;
+ longitude: number;
+ zoom: number;
+ dragRotate: boolean;
+ width: number;
+ height: number;
+ isSplit: boolean;
+ initialState?: any;
+};
+
+export type Bounds = [number, number, number, number];
+/** Width of viewport */
+export type Viewport = {
+ /** Width of viewport */
+ width?: number;
+ /** Height of viewport */
+ height?: number;
+ /** Zoom of viewport */
+ zoom?: number;
+ /** Camera angle in degrees (0 is straight down) */
+ pitch?: number;
+ /** Map rotation in degrees (0 means north is up) */
+ bearing?: number;
+ /** Latitude center of viewport on map in mercator projection */
+ latitude?: number;
+ /** Longitude Center of viewport on map in mercator projection */
+ longitude?: number;
+ /** Whether to enable drag and rotate map into perspective viewport */
+ dragRotate?: boolean;
+};
+
+export const INITIAL_MAP_STATE: MapState;
+
+export function updateMapUpdater(
+ state: MapState,
+ action: MapStateActions.UpdateMapUpdaterAction
+): MapState;
+export function fitBoundsUpdater(
+ state: MapState,
+ action: MapStateActions.FitBoundsUpdaterAction
+): MapState;
+export function togglePerspectiveUpdater(
+ state: MapState,
+ action: MapStateActions.TogglePerspectiveUpdaterAction
+): MapState;
+export function resetMapConfigUpdater(state: MapState): MapState;
+export function receiveMapConfigUpdater(
+ state: MapState,
+ action: {
+ type?: ActionTypes.RECEIVE_MAP_CONFIG;
+ payload: ReceiveMapConfigPayload;
+ }
+): MapState;
+export function toggleSplitMapUpdater(
+ state: MapState,
+ action: MapStateActions.ToggleSplitMapUpdaterAction
+): MapState;
diff --git a/src/reducers/map-state-updaters.js b/src/reducers/map-state-updaters.js
index 517fbbb88..a88108f1b 100644
--- a/src/reducers/map-state-updaters.js
+++ b/src/reducers/map-state-updaters.js
@@ -20,6 +20,8 @@
import geoViewport from '@mapbox/geo-viewport';
+/** @typedef {import('./map-state-updaters').MapState} MapState */
+
/**
* Updaters for `mapState` reducer. Can be used in your root reducer to directly modify kepler.gl's state.
* Read more about [Using updaters](../advanced-usage/using-updaters.md)
@@ -56,6 +58,7 @@ import geoViewport from '@mapbox/geo-viewport';
* export default composedReducer;
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const mapStateUpdaters = null;
/* eslint-enable no-unused-vars */
@@ -63,15 +66,16 @@ const mapStateUpdaters = null;
* Default initial `mapState`
* @memberof mapStateUpdaters
* @constant
- * @property {number} pitch Default: `0`
- * @property {number} bearing Default: `0`
- * @property {number} latitude Default: `37.75043`
- * @property {number} longitude Default: `-122.34679`
- * @property {number} zoom Default: `9`
- * @property {boolean} dragRotate Default: `false`
- * @property {number} width Default: `800`
- * @property {number} height Default: `800`
- * @property {boolean} isSplit Default: `false`
+ * @property pitch Default: `0`
+ * @property bearing Default: `0`
+ * @property latitude Default: `37.75043`
+ * @property longitude Default: `-122.34679`
+ * @property zoom Default: `9`
+ * @property dragRotate Default: `false`
+ * @property width Default: `800`
+ * @property height Default: `800`
+ * @property isSplit Default: `false`
+ * @type {MapState}
* @public
*/
export const INITIAL_MAP_STATE = {
@@ -90,10 +94,7 @@ export const INITIAL_MAP_STATE = {
/**
* Update map viewport
* @memberof mapStateUpdaters
- * @param {Object} state
- * @param {Object} action
- * @param {Object} action.payload - viewport
- * @returns {Object} nextState
+ * @type {typeof import('./map-state-updaters').updateMapUpdater}
* @public
*/
export const updateMapUpdater = (state, action) => ({
@@ -104,10 +105,7 @@ export const updateMapUpdater = (state, action) => ({
/**
* Fit map viewport to bounds
* @memberof mapStateUpdaters
- * @param {Object} state
- * @param {Object} action
- * @param {number[]} action.payload - bounds as `[lngMin, latMin, lngMax, latMax]`
- * @returns {Object} nextState
+ * @type {typeof import('./map-state-updaters').fitBoundsUpdater}
* @public
*/
export const fitBoundsUpdater = (state, action) => {
@@ -125,8 +123,7 @@ export const fitBoundsUpdater = (state, action) => {
/**
* Toggle between 3d and 2d map.
* @memberof mapStateUpdaters
- * @param {Object} state
- * @returns {Object} nextState
+ * @type {typeof import('./map-state-updaters').togglePerspectiveUpdater}
* @public
*/
export const togglePerspectiveUpdater = state => ({
@@ -141,8 +138,7 @@ export const togglePerspectiveUpdater = state => ({
/**
* reset mapState to initial State
* @memberof mapStateUpdaters
- * @param {Object} state `mapState`
- * @returns {Object} nextState
+ * @type {typeof import('./map-state-updaters').resetMapConfigUpdater}
* @public
*/
export const resetMapConfigUpdater = state => ({
@@ -155,10 +151,7 @@ export const resetMapConfigUpdater = state => ({
/**
* Update `mapState` to propagate a new config
* @memberof mapStateUpdaters
- * @param {Object} state
- * @param {Object} action
- * @param {Object} action.payload - saved map config
- * @returns {Object} nextState
+ * @type {typeof import('./map-state-updaters').receiveMapConfigUpdater}
* @public
*/
export const receiveMapConfigUpdater = (
@@ -188,8 +181,7 @@ export const receiveMapConfigUpdater = (
/**
* Toggle between one or split maps
* @memberof mapStateUpdaters
- * @param {Object} state
- * @returns {Object} nextState
+ * @type {typeof import('./map-state-updaters').toggleSplitMapUpdater}
* @public
*/
export const toggleSplitMapUpdater = state => ({
diff --git a/src/reducers/map-style-updaters.d.ts b/src/reducers/map-style-updaters.d.ts
new file mode 100644
index 000000000..0bccada8f
--- /dev/null
+++ b/src/reducers/map-style-updaters.d.ts
@@ -0,0 +1,76 @@
+import {RGBColor} from './types';
+import ActionTypes from 'constants/action-types';
+import {ReceiveMapConfigPayload, KeplerGlInitPayload} from '../actions/actions';
+import * as MapStyleActions from '../actions/map-style-actions';
+
+export type LayerGroup = {
+ slug: string;
+ filter(layer: {id: string}): boolean;
+ defaultVisibility: boolean;
+};
+
+export type VisibleLayerGroups = {
+ [key: string]: boolean;
+};
+
+export type MapboxStyleUrl = string;
+
+export type BaseMapStyle = {
+ id: string;
+ label: string;
+ url: string;
+ icon: string;
+ style?: object;
+ layerGroups: LayerGroup[];
+};
+
+export type MapStyles = {
+ [key: string]: BaseMapStyle;
+};
+
+export type InputStyle = {
+ accessToken: string | null;
+ error: boolean;
+ isValid: boolean;
+ label: string | null;
+ style: object | null;
+ url: string | null;
+ icon: string | null;
+ custom: boolean;
+};
+
+export type MapStyle = {
+ styleType: string;
+ visibleLayerGroups: VisibleLayerGroups;
+ topLayerGroups: VisibleLayerGroups;
+ mapStyles: MapStyles;
+ // save mapbox access token
+ mapboxApiAccessToken: string | null;
+ mapboxApiUrl: string;
+ mapStylesReplaceDefault: boolean;
+ inputStyle: InputStyle;
+ threeDBuildingColor: RGBColor;
+ custom3DBuildingColor: boolean;
+};
+
+export const INITIAL_MAP_STYLE: MapStyle;
+
+export function addCustomMapStyleUpdater(state: MapStyle, action: MapStyleActions.AddCustomMapStyleUpdaterAction): MapStyle;
+export function inputMapStyleUpdater(state: MapStyle, action: MapStyleActions.InputMapStyleUpdaterAction): MapStyle;
+export function mapConfigChangeUpdater(state: MapStyle, action: MapStyleActions.MapConfigChangeUpdaterAction): MapStyle;
+export function requestMapStylesUpdater(state: MapStyle, action: MapStyleActions.RequestMapStylesUpdaterAction): MapStyle;
+export function loadMapStylesUpdater(state: MapStyle, action: MapStyleActions.LoadMapStylesUpdaterAction): MapStyle;
+export function loadMapStyleErrUpdater(state: MapStyle, action: MapStyleActions.LoadMapStyleErrUpdaterAction): MapStyle;
+export function mapStyleChangeUpdater(state: MapStyle, action: MapStyleActions.MapStyleChangeUpdaterAction): MapStyle;
+export function loadCustomMapStyleUpdater(state: MapStyle, action: MapStyleActions.LoadCustomMapStyleUpdaterAction): MapStyle;
+export function set3dBuildingColorUpdater(state: MapStyle, action: MapStyleActions.Set3dBuildingColorUpdaterAction): MapStyle;
+
+export function receiveMapConfigUpdater(state: MapStyle, action: {
+ type?: ActionTypes.RECEIVE_MAP_CONFIG;
+ payload: ReceiveMapConfigPayload;
+}): MapStyle;
+export function initMapStyleUpdater(state: MapStyle, action: {
+ type?: ActionTypes.INIT;
+ payload: KeplerGlInitPayload;
+}): MapStyle;
+export function resetMapConfigMapStyleUpdater(state: MapStyle): MapStyle;
\ No newline at end of file
diff --git a/src/reducers/map-style-updaters.js b/src/reducers/map-style-updaters.js
index 4d39a2d1a..e6de74538 100644
--- a/src/reducers/map-style-updaters.js
+++ b/src/reducers/map-style-updaters.js
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import Task, {withTask} from 'react-palm/tasks';
import cloneDeep from 'lodash.clonedeep';
@@ -44,6 +45,9 @@ import {hexToRgb} from 'utils/color-utils';
const DEFAULT_BLDG_COLOR = '#D1CEC7';
+/**
+ * @return {import('./map-style-updaters').MapStyle}
+ */
const getDefaultState = () => {
const visibleLayerGroups = {};
const styleType = 'dark';
@@ -113,15 +117,16 @@ const mapStyleUpdaters = null;
* Default initial `mapStyle`
* @memberof mapStyleUpdaters
* @constant
- * @property {string} styleType - Default: `'dark'`
- * @property {Object} visibleLayerGroups - Default: `{}`
- * @property {Object} topLayerGroups - Default: `{}`
- * @property {Object} mapStyles - mapping from style key to style object
- * @property {string} mapboxApiAccessToken - Default: `null`
- * @Property {string} mapboxApiUrl - Default null
- * @Property {Boolean} mapStylesReplaceDefault - Default: `false`
- * @property {Object} inputStyle - Default: `{}`
- * @property {Array} threeDBuildingColor - Default: `[r, g, b]`
+ * @property styleType - Default: `'dark'`
+ * @property visibleLayerGroups - Default: `{}`
+ * @property topLayerGroups - Default: `{}`
+ * @property mapStyles - mapping from style key to style object
+ * @property mapboxApiAccessToken - Default: `null`
+ * @Property mapboxApiUrl - Default null
+ * @Property mapStylesReplaceDefault - Default: `false`
+ * @property inputStyle - Default: `{}`
+ * @property threeDBuildingColor - Default: `[r, g, b]`
+ * @type {import('./map-style-updaters').MapStyle}
* @public
*/
export const INITIAL_MAP_STYLE = getDefaultState();
@@ -215,11 +220,7 @@ function getLayerGroupsFromStyle(style) {
* populate mapStyles.
*
* @memberof mapStyleUpdaters
- * @param {Object} state
- * @param {Object} action
- * @param {Object} action.payload
- * @param {string} action.payload.mapboxApiAccessToken
- * @returns {Object} nextState
+ * @type {typeof import('./map-style-updaters').initMapStyleUpdater}
* @public
*/
export const initMapStyleUpdater = (state, action) => ({
@@ -235,10 +236,7 @@ export const initMapStyleUpdater = (state, action) => ({
/**
* Update `visibleLayerGroups`to change layer group visibility
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @param {Object} action
- * @param {Object} action.payload new config `{visibleLayerGroups: {label: false, road: true, background: true}}`
- * @returns {Object} nextState
+ * @type {typeof import('./map-style-updaters').mapConfigChangeUpdater}
* @public
*/
export const mapConfigChangeUpdater = (state, action) => ({
@@ -253,10 +251,7 @@ export const mapConfigChangeUpdater = (state, action) => ({
/**
* Change to another map style. The selected style should already been loaded into `mapStyle.mapStyles`
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @param {Object} action
- * @param {string} action.payload
- * @returns {Object} nextState
+ * @type {typeof import('./map-style-updaters').mapStyleChangeUpdater}
* @public
*/
export const mapStyleChangeUpdater = (state, {payload: styleType}) => {
@@ -291,10 +286,7 @@ export const mapStyleChangeUpdater = (state, {payload: styleType}) => {
/**
* Callback when load map style success
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @param {Object} action
- * @param {Object} action.payload a `{[id]: style}` mapping
- * @return {Object} nextState
+ * @type {typeof import('./map-style-updaters').loadMapStylesUpdater}
* @public
*/
export const loadMapStylesUpdater = (state, action) => {
@@ -327,15 +319,17 @@ export const loadMapStylesUpdater = (state, action) => {
/**
* Callback when load map style error
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @param {Object} action
- * @param {*} action.payload error
- * @returns {Object} nextState
+ * @type {typeof import('./map-style-updaters').loadMapStyleErrUpdater}
* @public
*/
// do nothing for now, if didn't load, skip it
export const loadMapStyleErrUpdater = state => state;
+/**
+ * @memberof mapStyleUpdaters
+ * @type {typeof import('./map-style-updaters').requestMapStylesUpdater}
+ * @public
+ */
export const requestMapStylesUpdater = (state, {payload: mapStyles}) => {
const loadMapStyleTasks = getLoadMapStyleTasks(
mapStyles,
@@ -348,10 +342,11 @@ export const requestMapStylesUpdater = (state, {payload: mapStyles}) => {
/**
* Load map style object when pass in saved map config
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @param {Object} action
- * @param {Object} action.payload saved map config `{mapStyle, visState, mapState}`
- * @returns {Object} nextState or `react-pam` tasks to load map style object
+ * @param state `mapStyle`
+ * @param action
+ * @param action.payload saved map config `{mapStyle, visState, mapState}`
+ * @returns nextState or `react-pam` tasks to load map style object
+ * @type {typeof import('./map-style-updaters').receiveMapConfigUpdater}
*/
export const receiveMapConfigUpdater = (state, {payload: {config = {}}}) => {
const {mapStyle} = config || {};
@@ -418,8 +413,9 @@ function getLoadMapStyleTasks(mapStyles, mapboxApiAccessToken, mapboxApiUrl) {
/**
* Reset map style config to initial state
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @returns {Object} nextState
+ * @param state `mapStyle`
+ * @returns nextState
+ * @type {typeof import('./map-style-updaters').resetMapConfigMapStyleUpdater}
* @public
*/
export const resetMapConfigMapStyleUpdater = state => {
@@ -439,13 +435,7 @@ export const resetMapConfigMapStyleUpdater = state => {
/**
* Callback when a custom map style object is received
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @param {Object} action
- * @param {Object} action.payload
- * @param {string} action.payload.icon
- * @param {Object} action.payload.style
- * @param {*} action.payload.error
- * @returns {Object} nextState
+ * @type {typeof import('./map-style-updaters').loadCustomMapStyleUpdater}
* @public
*/
export const loadCustomMapStyleUpdater = (state, {payload: {icon, style, error}}) => ({
@@ -471,16 +461,7 @@ export const loadCustomMapStyleUpdater = (state, {payload: {icon, style, error}}
/**
* Input a custom map style object
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @param {Object} action action object
- * @param {Object} action.payload inputStyle
- * @param {string} action.payload.url style url e.g. `'mapbox://styles/heshan/xxxxxyyyyzzz'`
- * @param {string} action.payload.id style url e.g. `'custom_style_1'`
- * @param {Object} action.payload.style actual mapbox style json
- * @param {string} action.payload.name style name
- * @param {Object} action.payload.layerGroups layer groups that can be used to set map layer visibility
- * @param {Object} action.payload.icon icon image data url
- * @returns {Object} nextState
+ * @type {typeof import('./map-style-updaters').inputMapStyleUpdater}
* @public
*/
export const inputMapStyleUpdater = (state, {payload: {inputStyle, mapState}}) => {
@@ -514,8 +495,7 @@ export const inputMapStyleUpdater = (state, {payload: {inputStyle, mapState}}) =
* This action is called when user click confirm after putting in a valid style url in the custom map style dialog.
* It should not be called from outside kepler.gl without a valid `inputStyle` in the `mapStyle` reducer.
* @memberof mapStyleUpdaters
- * @param {Object} state `mapStyle`
- * @returns {Object} nextState
+ * @type {typeof import('./map-style-updaters').addCustomMapStyleUpdater}
*/
export const addCustomMapStyleUpdater = state => {
const styleId = state.inputStyle.id;
@@ -535,9 +515,7 @@ export const addCustomMapStyleUpdater = state => {
/**
* Updates 3d building color
* @memberof mapStyleUpdaters
- * @param state
- * @param color
- * @return {Object} nextState
+ * @type {typeof import('./map-style-updaters').set3dBuildingColorUpdater}
*/
export const set3dBuildingColorUpdater = (state, {payload: color}) => ({
...state,
diff --git a/src/reducers/provider-state-updaters.d.ts b/src/reducers/provider-state-updaters.d.ts
new file mode 100644
index 000000000..13c68929f
--- /dev/null
+++ b/src/reducers/provider-state-updaters.d.ts
@@ -0,0 +1,88 @@
+import * as ProviderActions from 'actions/provider-actions';
+import {MapListItem} from 'cloud-providers';
+
+type ActionPayload<P> = {
+ type?: string;
+ payload: P;
+};
+
+export type ProviderState = {
+ isProviderLoading: boolean;
+ isCloudMapLoading: boolean;
+ providerError: any;
+ currentProvider: string | null;
+ successInfo: any;
+ mapSaved: null | string;
+ initialState: any;
+ visualizations: MapListItem[]
+};
+
+export const INITIAL_PROVIDER_STATE: ProviderState;
+
+export function withTask<T>(s: T, any): T;
+
+export function exportFileToCloudUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.ExportFileToCloudPayload>
+): ProviderState;
+
+export function exportFileSuccessUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.ExportFileSuccessPayload>
+): ProviderState;
+
+export function postSaveLoadSuccessUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.PostSaveLoadSuccessPayload>
+): ProviderState;
+
+export function exportFileErrorUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.ExportFileErrorPayload>
+): ProviderState;
+
+export function loadCloudMapUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.LoadCloudMapPayload>
+): ProviderState;
+
+export function loadCloudMapSuccessUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.LoadCloudMapSuccessPayload>
+): ProviderState;
+
+export function loadCloudMapErrorUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.LoadCloudMapErrorPayload>
+): ProviderState;
+
+export function resetProviderStatusUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.ResetProviderStatusPayload>
+): ProviderState;
+
+export function setCloudProviderUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.SetCloudProviderPayload>
+): ProviderState;
+
+export function getSavedMapsUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.GetSavedMapsPayload>
+): ProviderState;
+
+export function getSavedMapsSuccessUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.GetSavedMapsSuccessPayload>
+): ProviderState;
+
+export function getSavedMapsErrorUpdater(
+ state: ProviderState,
+ action: ActionPayload<ProviderActions.GetSavedMapsErrorPayload>
+): ProviderState;
+
+export function createGlobalNotificationTasks(p: {
+ type?: string;
+ message: string;
+ delayClose?: boolean;
+}): any[];
diff --git a/src/reducers/provider-state-updaters.js b/src/reducers/provider-state-updaters.js
index 174bd18d9..436019f79 100644
--- a/src/reducers/provider-state-updaters.js
+++ b/src/reducers/provider-state-updaters.js
@@ -54,7 +54,8 @@ export const INITIAL_PROVIDER_STATE = {
providerError: null,
currentProvider: null,
successInfo: {},
- mapSaved: null
+ mapSaved: null,
+ visualizations: []
};
import {DATASET_HANDLERS} from 'processors/data-processor';
@@ -80,6 +81,9 @@ function _validateProvider(provider, method) {
return true;
}
+/**
+ * @type {typeof import('./provider-state-updaters').createGlobalNotificationTasks}
+ */
function createGlobalNotificationTasks({type, message, delayClose = true}) {
const id = generateHashId();
const successNote = {
@@ -96,8 +100,7 @@ function createGlobalNotificationTasks({type, message, delayClose = true}) {
* This method will export the current kepler config file to the chosen cloud proder
* add returns a share URL
*
- * @param {*} state
- * @param {*} action
+ * @type {typeof import('./provider-state-updaters').exportFileToCloudUpdater}
*/
export const exportFileToCloudUpdater = (state, action) => {
const {mapData, provider, options = {}, onSuccess, onError, closeModal} = action.payload;
@@ -129,11 +132,10 @@ export const exportFileToCloudUpdater = (state, action) => {
/**
*
- * @param {*} state
- * @param {*} action
+ * @type {typeof import('./provider-state-updaters').exportFileSuccessUpdater}
*/
export const exportFileSuccessUpdater = (state, action) => {
- const {response, provider, options, onSuccess, closeModal} = action.payload;
+ const {response, provider, options = {}, onSuccess, closeModal} = action.payload;
const newState = {
...state,
@@ -158,8 +160,7 @@ export const exportFileSuccessUpdater = (state, action) => {
/**
* Close modal on success and display notification
- * @param {*} state
- * @param {*} action
+ * @type {typeof import('./provider-state-updaters').postSaveLoadSuccessUpdater}
*/
export const postSaveLoadSuccessUpdater = (state, action) => {
const message = action.payload || `Saved / Load to ${state.currentProvider} Success`;
@@ -175,8 +176,7 @@ export const postSaveLoadSuccessUpdater = (state, action) => {
/**
*
- * @param {*} state
- * @param {*} action
+ * @type {typeof import('./provider-state-updaters').exportFileErrorUpdater}
*/
export const exportFileErrorUpdater = (state, action) => {
const {error, provider, onError} = action.payload;
@@ -266,16 +266,24 @@ function parseLoadMapResponse(response, loadParams, provider) {
return {info, data};
});
- const parsedConfig = map.config ? KeplerGlSchema.parseSavedConfig(map.config) : null;
+ const parsedConfig = map.config && KeplerGlSchema.parseSavedConfig(map.config);
const info = {
...map.info,
provider: provider.name,
loadParams
};
- return {datasets: parsedDatasets, config: parsedConfig, info};
+ return {
+ datasets: parsedDatasets,
+ info,
+ ...(parsedConfig ? {config: parsedConfig} : {})
+ };
}
+/**
+ *
+ * @type {typeof import('./provider-state-updaters').loadCloudMapSuccessUpdater}
+ */
export const loadCloudMapSuccessUpdater = (state, action) => {
const {response, loadParams, provider, onSuccess, onError} = action.payload;
@@ -306,6 +314,10 @@ export const loadCloudMapSuccessUpdater = (state, action) => {
return tasks.length ? withTask(newState, tasks) : newState;
};
+/**
+ *
+ * @type {typeof import('./provider-state-updaters').loadCloudMapErrorUpdater}
+ */
export const loadCloudMapErrorUpdater = (state, action) => {
const message = getError(action.payload.error) || `Error loading saved map`;
@@ -323,10 +335,10 @@ export const loadCloudMapErrorUpdater = (state, action) => {
createGlobalNotificationTasks({type: 'error', message, delayClose: false})
);
};
+
/**
*
- * @param {*} state
- * @param {*} action
+ * @type {typeof import('./provider-state-updaters').resetProviderStatusUpdater}
*/
export const resetProviderStatusUpdater = (state, action) => ({
...state,
@@ -338,8 +350,7 @@ export const resetProviderStatusUpdater = (state, action) => ({
/**
* Set current cloudProvider
- * @param {*} state
- * @param {*} action
+ * @type {typeof import('./provider-state-updaters').setCloudProviderUpdater}
*/
export const setCloudProviderUpdater = (state, action) => ({
...state,
@@ -349,6 +360,10 @@ export const setCloudProviderUpdater = (state, action) => ({
currentProvider: action.payload
});
+/**
+ *
+ * @type {typeof import('./provider-state-updaters').getSavedMapsUpdater}
+ */
export const getSavedMapsUpdater = (state, action) => {
const provider = action.payload;
if (!_validateProvider(provider, 'listMaps')) {
@@ -371,12 +386,20 @@ export const getSavedMapsUpdater = (state, action) => {
);
};
+/**
+ *
+ * @type {typeof import('./provider-state-updaters').getSavedMapsSuccessUpdater}
+ */
export const getSavedMapsSuccessUpdater = (state, action) => ({
...state,
isProviderLoading: false,
visualizations: action.payload.visualizations
});
+/**
+ *
+ * @type {typeof import('./provider-state-updaters').getSavedMapsErrorUpdater}
+ */
export const getSavedMapsErrorUpdater = (state, action) => {
const message =
getError(action.payload.error) || `Error getting saved maps from ${state.currentProvider}`;
diff --git a/src/reducers/types.d.ts b/src/reducers/types.d.ts
new file mode 100644
index 000000000..39e20d470
--- /dev/null
+++ b/src/reducers/types.d.ts
@@ -0,0 +1,10 @@
+export type RGBColor = [number, number, number];
+export type RGBAColor = [number, number, number, number];
+export type HexColor = string; // this is the best tpescript can do at the moment
+export type Millisecond = number;
+
+type ValueOf<T> = T[keyof T];
+
+type Merge<A, B> = {[K in keyof A]: K extends keyof B ? B[K] : A[K]} & B extends infer O
+ ? {[K in keyof O]: O[K]}
+ : never;
diff --git a/src/reducers/ui-state-updaters.d.ts b/src/reducers/ui-state-updaters.d.ts
new file mode 100644
index 000000000..c43cb2f19
--- /dev/null
+++ b/src/reducers/ui-state-updaters.d.ts
@@ -0,0 +1,184 @@
+import * as UiStateActions from 'actions/ui-state-actions';
+import {ToggleSplitMapUpdaterAction} from 'actions/map-state-actions';
+import {LoadFilesUpdaterAction, LoadFilesErrUpdaterAction} from ' actions/vis-state-actions';
+
+export type ExportImage = {
+ ratio: string;
+ resolution: string;
+ legend: boolean;
+ mapH: number;
+ mapW: number;
+ imageSize: {
+ zoomOffset: number;
+ scale: number;
+ imageW: number;
+ imageH: number;
+ };
+ // exporting state
+ imageDataUri: string;
+ exporting: boolean;
+ error: boolean;
+};
+
+export type ExportData = {
+ selectedDataset: string;
+ dataType: string;
+ filtered: boolean;
+};
+
+export type ExportHtml = {
+ exportMapboxAccessToken: null | string;
+ userMapboxToken: string;
+ mode: string;
+};
+export type ExportJson = {
+ hasData: boolean;
+};
+export type ExportMap = {
+ HTML: ExportHtml;
+ JSON: ExportJson;
+ format: 'HTML' | 'JSON';
+};
+
+export type MapControl = {
+ show: boolean;
+ active: boolean;
+ activeMapIndex: number;
+};
+export type MapControls = {
+ visibleLayers: MapControl;
+ mapLegend: MapControl;
+ toggle3d: MapControl;
+ splitMap: MapControl;
+ mapDraw: MapControl;
+ mapLocale: MapControl;
+};
+
+export type LoadFiles = {
+ fileLoading: boolean;
+};
+
+export type Notifications = {
+ message: string;
+ type: string;
+ topic: string;
+ id: string;
+};
+
+export type Locale = string;
+
+export type UiState = {
+ readOnly: boolean;
+ activeSidePanel: string;
+ currentModal: string | null;
+ datasetKeyToRemove: string | null;
+ visibleDropdown: string | null;
+ // export image modal ui
+ exportImage: ExportImage;
+ // export data modal ui
+ exportData: ExportData;
+ // html export
+ exportMap: ExportMap;
+ // map control panels
+ mapControls: MapControls;
+ // ui notifications
+ notifications: Notifications[];
+ // load files
+ loadFiles: LoadFiles;
+ // Locale of the UI
+ locale: Locale;
+};
+
+export const DEFAULT_MAP_CONTROLS: MapControls;
+export const DEFAULT_EXPORT_IMAGE: ExportImage;
+export const INITIAL_UI_STATE: UiState;
+
+export function toggleSidePanelUpdater(
+ state: UiState,
+ action: UiStateActions.ToggleSidePanelUpdaterAction
+): UiState;
+export function toggleModalUpdater(
+ state: UiState,
+ action: UiStateActions.ToggleModalUpdaterAction
+): UiState;
+export function showExportDropdownUpdater(
+ state: UiState,
+ action: UiStateActions.ShowExportDropdownUpdaterAction
+): UiState;
+export function hideExportDropdownUpdater(
+ state: UiState,
+ action: UiStateActions.HideExportDropdownUpdaterAction
+): UiState;
+export function toggleMapControlUpdater(
+ state: UiState,
+ action: UiStateActions.ToggleMapControlUpdaterAction
+): UiState;
+export function openDeleteModalUpdater(
+ state: UiState,
+ action: UiStateActions.OpenDeleteModalUpdaterAction
+): UiState;
+export function addNotificationUpdater(
+ state: UiState,
+ action: UiStateActions.AddNotificationUpdaterAction
+): UiState;
+export function removeNotificationUpdater(
+ state: UiState,
+ action: UiStateActions.RemoveNotificationUpdaterAction
+): UiState;
+export function setExportImageSettingUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportImageSettingUpdaterAction
+): UiState;
+export function startExportingImageUpdater(
+ state: UiState,
+ action: UiStateActions.StartExportingImageUpdaterAction
+): UiState;
+export function setExportImageDataUriUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportImageDataUriUpdaterAction
+): UiState;
+export function setExportImageErrorUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportImageErrorUpdaterAction
+): UiState;
+export function cleanupExportImageUpdater(
+ state: UiState,
+ action: UiStateActions.CleanupExportImageUpdaterAction
+): UiState;
+export function setExportSelectedDatasetUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportSelectedDatasetUpdaterAction
+): UiState;
+export function setExportDataTypeUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportDataTypeUpdaterAction
+): UiState;
+export function setExportFilteredUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportFilteredUpdaterAction
+): UiState;
+export function setExportDataUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportDataUpdaterAction
+): UiState;
+export function setUserMapboxAccessTokenUpdater(
+ state: UiState,
+ action: UiStateActions.SetUserMapboxAccessTokenUpdaterAction
+): UiState;
+export function setExportMapFormatUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportMapFormatUpdaterAction
+): UiState;
+export function setExportMapHTMLModeUpdater(
+ state: UiState,
+ action: UiStateActions.SetExportHTMLMapModeUpdaterAction
+): UiState;
+export function setLocaleUpdater(
+ state: UiState,
+ action: UiStateActions.SetLocaleUpdaterAction
+): UiState;
+
+export function loadFilesUpdater(state: UiState, action: LoadFilesUpdaterAction): UiState;
+export function loadFilesErrUpdater(state: UiState, action: LoadFilesErrUpdaterAction): UiState;
+export function loadFilesSuccessUpdater(state: UiState): UiState;
+export function toggleSplitMapUpdater(state: UiState, action: ToggleSplitMapUpdaterAction): UiState;
diff --git a/src/reducers/ui-state-updaters.js b/src/reducers/ui-state-updaters.js
index 8d7bfd532..94e406596 100644
--- a/src/reducers/ui-state-updaters.js
+++ b/src/reducers/ui-state-updaters.js
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import {
ADD_DATA_ID,
DEFAULT_NOTIFICATION_TOPICS,
@@ -75,19 +76,6 @@ export const DEFAULT_MODAL = ADD_DATA_ID;
const uiStateUpdaters = null;
/* eslint-enable no-unused-vars */
-/**
- * A list of map control visibility and whether is it active.
- * @memberof uiStateUpdaters
- * @constant
- * @type {Object}
- * @property {Object} visibleLayers Default: `{show: true, active: false}`
- * @property {Object} mapLegend Default: `{show: true, active: false}`
- * @property {Object} toggle3d Default: `{show: true}`
- * @property {Object} splitMap Default: `{show: true}`
- * @property {Object} mapDraw Default: `{show: true, active: false}`
- * @property {Object} mapLocale Default: `{show: false, active: false}`
- * @public
- */
const DEFAULT_MAP_CONTROLS_FEATURES = {
show: true,
active: false,
@@ -95,6 +83,19 @@ const DEFAULT_MAP_CONTROLS_FEATURES = {
activeMapIndex: 0
};
+/**
+ * A list of map control visibility and whether is it active.
+ * @memberof uiStateUpdaters
+ * @constant
+ * @property visibleLayers Default: `{show: true, active: false}`
+ * @property mapLegend Default: `{show: true, active: false}`
+ * @property toggle3d Default: `{show: true}`
+ * @property splitMap Default: `{show: true}`
+ * @property mapDraw Default: `{show: true, active: false}`
+ * @property mapLocale Default: `{show: false, active: false}`
+ * @type {import('./ui-state-updaters').MapControls}
+ * @public
+ */
export const DEFAULT_MAP_CONTROLS = [
'visibleLayers',
'mapLegend',
@@ -114,13 +115,16 @@ export const DEFAULT_MAP_CONTROLS = [
* Default image export config
* @memberof uiStateUpdaters
* @constant
- * @type {Object}
- * @property {string} ratio Default: `'SCREEN'`,
- * @property {string} resolution Default: `'ONE_X'`,
- * @property {boolean} legend Default: `false`,
- * @property {string} imageDataUri Default: `''`,
- * @property {boolean} exporting Default: `false`
- * @property {boolean} error Default: `false`
+ * @property ratio Default: `'SCREEN'`,
+ * @property resolution Default: `'ONE_X'`,
+ * @property legend Default: `false`,
+ * @property mapH Default: 0,
+ * @property mapW Default: 0,
+ * @property imageSize Default: {zoomOffset: 0, scale: 1, imageW: 0, imageH: 0},
+ * @property imageDataUri Default: `''`,
+ * @property exporting Default: `false`
+ * @property error Default: `false`
+ * @type {import('./ui-state-updaters').ExportImage}
* @public
*/
export const DEFAULT_EXPORT_IMAGE = {
@@ -150,12 +154,10 @@ export const DEFAULT_LOAD_FILES = {
* Default initial `exportData` settings
* @memberof uiStateUpdaters
* @constant
- * @type {Object}
- * @property {string} selectedDataset Default: `''`,
- * @property {string} dataType Default: `'csv'`,
- * @property {boolean} filtered Default: `true`,
- * @property {boolean} config deprecated
- * @property {boolean} data used in modal config export. Default: `false`
+ * @property selectedDataset Default: `''`,
+ * @property dataType Default: `'csv'`,
+ * @property filtered Default: `true`,
+ * @type {import('./ui-state-updaters').ExportData}
* @public
*/
export const DEFAULT_EXPORT_DATA = {
@@ -166,15 +168,15 @@ export const DEFAULT_EXPORT_DATA = {
/**
* @constant
- * @type {Array}
*/
export const DEFAULT_NOTIFICATIONS = [];
/**
* @constant
- * @type {Object}
- * @property {string} exportMapboxAccessToken - Default: null, this is used when we provide a default mapbox token for users to take advantage of
- * @property {string} userMapboxToken - Default: '', mapbox token provided by user through input field
+ * @property exportMapboxAccessToken - Default: null, this is used when we provide a default mapbox token for users to take advantage of
+ * @property userMapboxToken - Default: '', mapbox token provided by user through input field
+ * @property mode - Default: 'READ', read only or editable
+ * @type {import('./ui-state-updaters').ExportHtml}
* @public
*/
export const DEFAULT_EXPORT_HTML = {
@@ -183,10 +185,25 @@ export const DEFAULT_EXPORT_HTML = {
mode: EXPORT_HTML_MAP_MODES.READ
};
+/**
+ * @constant
+ * @property hasData - Default: 'true',
+ * @type {import('./ui-state-updaters').ExportJson}
+ * @public
+ */
export const DEFAULT_EXPORT_JSON = {
hasData: true
};
+/**
+ * Export Map Config
+ * @constant
+ * @property HTML - Default: 'DEFAULT_EXPORT_HTML',
+ * @property JSON - Default: 'DEFAULT_EXPORT_JSON',
+ * @property format - Default: 'HTML',
+ * @type {import('./ui-state-updaters').ExportMap}
+ * @public
+ */
export const DEFAULT_EXPORT_MAP = {
[EXPORT_MAP_FORMATS.HTML]: DEFAULT_EXPORT_HTML,
[EXPORT_MAP_FORMATS.JSON]: DEFAULT_EXPORT_JSON,
@@ -197,16 +214,19 @@ export const DEFAULT_EXPORT_MAP = {
* Default initial `uiState`
* @memberof uiStateUpdaters
* @constant
- * @type {Object}
- * @property {boolean} readOnly Default: `false`
- * @property {string} activeSidePanel Default: `'layer'`
- * @property {string|null} currentModal Default: `'addData'`
- * @property {string|null} datasetKeyToRemove Default: `null`
- * @property {string|null} visibleDropdown Default: `null`
- * @property {Object} exportImage Default: [`DEFAULT_EXPORT_IMAGE`](#default_export_image)
- * @property {Object} exportData Default: [`DEFAULT_EXPORT_DATA`](#default_export_data)
- * @property {Object} mapControls Default: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
- * @property {number} activeMapIndex defines which map the user clicked on. Default: 0
+ * @property readOnly Default: `false`
+ * @property activeSidePanel Default: `'layer'`
+ * @property currentModal Default: `'addData'`
+ * @property datasetKeyToRemove Default: `null`
+ * @property visibleDropdown Default: `null`
+ * @property exportImage Default: [`DEFAULT_EXPORT_IMAGE`](#default_export_image)
+ * @property exportData Default: [`DEFAULT_EXPORT_DATA`](#default_export_data)
+ * @property exportMap Default: [`DEFAULT_EXPORT_MAP`](#default_export_map)
+ * @property mapControls Default: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
+ * @property notifications Default: `[]`
+ * @property notifications Default: `[]`
+ * @property loadFiles
+ * @type {import('./ui-state-updaters').UiState}
* @public
*/
export const INITIAL_UI_STATE = {
@@ -235,10 +255,11 @@ export const INITIAL_UI_STATE = {
/**
* Toggle active side panel
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {string|null} action.payload id of side panel to be shown, one of `layer`, `filter`, `interaction`, `map`. close side panel if `null`
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload id of side panel to be shown, one of `layer`, `filter`, `interaction`, `map`. close side panel if `null`
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').toggleSidePanelUpdater}
* @public
*/
export const toggleSidePanelUpdater = (state, {payload: id}) => {
@@ -253,17 +274,17 @@ export const toggleSidePanelUpdater = (state, {payload: id}) => {
/**
* Show and hide modal dialog
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {string|null} action.payload id of modal to be shown, null to hide modals. One of:
- *
+ * @param state `uiState`
+ * @param action
+ * @paramaction.payload id of modal to be shown, null to hide modals. One of:
* - [`DATA_TABLE_ID`](../constants/default-settings.md#data_table_id)
* - [`DELETE_DATA_ID`](../constants/default-settings.md#delete_data_id)
* - [`ADD_DATA_ID`](../constants/default-settings.md#add_data_id)
* - [`EXPORT_IMAGE_ID`](../constants/default-settings.md#export_image_id)
* - [`EXPORT_DATA_ID`](../constants/default-settings.md#export_data_id)
* - [`ADD_MAP_STYLE_ID`](../constants/default-settings.md#add_map_style_id)
- * @returns {Object} nextState
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').toggleModalUpdater}
* @public
*/
export const toggleModalUpdater = (state, {payload: id}) => ({
@@ -274,10 +295,7 @@ export const toggleModalUpdater = (state, {payload: id}) => ({
/**
* Hide and show side panel header dropdown, activated by clicking the share link on top of the side panel
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {string} action.payload id of the dropdown
- * @returns {Object} nextState
+ * @type {typeof import('./ui-state-updaters').showExportDropdownUpdater}
* @public
*/
export const showExportDropdownUpdater = (state, {payload: id}) => ({
@@ -288,8 +306,7 @@ export const showExportDropdownUpdater = (state, {payload: id}) => ({
/**
* Hide side panel header dropdown, activated by clicking the share link on top of the side panel
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @returns {Object} nextState
+ * @type {typeof import('./ui-state-updaters').hideExportDropdownUpdater}
* @public
*/
export const hideExportDropdownUpdater = state => ({
@@ -300,10 +317,11 @@ export const hideExportDropdownUpdater = state => ({
/**
* Toggle active map control panel
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action action
- * @param {string} action.payload map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action action
+ * @param action.payload map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`](#default_map_controls)
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').toggleMapControlUpdater}
* @public
*/
export const toggleMapControlUpdater = (state, {payload: {panelId, index = 0}}) => ({
@@ -327,10 +345,11 @@ export const toggleMapControlUpdater = (state, {payload: {panelId, index = 0}})
/**
* Toggle active map control panel
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {string} action.payload dataset id
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload dataset id
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').openDeleteModalUpdater}
* @public
*/
export const openDeleteModalUpdater = (state, {payload: datasetKeyToRemove}) => ({
@@ -342,11 +361,12 @@ export const openDeleteModalUpdater = (state, {payload: datasetKeyToRemove}) =>
/**
* Set `exportImage.legend` to `true` or `false`
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setExportImageSettingUpdater}
* @public
*/
-export const setExportImageSetting = (state, {payload: newSetting}) => {
+export const setExportImageSettingUpdater = (state, {payload: newSetting}) => {
const updated = {...state.exportImage, ...newSetting};
const imageSize = calculateExportImageSize(updated) || state.exportImage.imageSize;
@@ -362,11 +382,12 @@ export const setExportImageSetting = (state, {payload: newSetting}) => {
/**
* Set `exportImage.exporting` to `true`
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').startExportingImageUpdater}
* @public
*/
-export const startExportingImage = state => ({
+export const startExportingImageUpdater = state => ({
...state,
exportImage: {
...state.exportImage,
@@ -378,13 +399,14 @@ export const startExportingImage = state => ({
/**
* Set `exportImage.setExportImageDataUri` to a image dataUri
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {string} action.payload export image data uri
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload export image data uri
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setExportImageDataUriUpdater}
* @public
*/
-export const setExportImageDataUri = (state, {payload: dataUri}) => ({
+export const setExportImageDataUriUpdater = (state, {payload: dataUri}) => ({
...state,
exportImage: {
...state.exportImage,
@@ -393,7 +415,12 @@ export const setExportImageDataUri = (state, {payload: dataUri}) => ({
}
});
-export const setExportImageError = (state, {payload: error}) => ({
+/**
+ * @memberof uiStateUpdaters
+ * @type {typeof import('./ui-state-updaters').setExportImageErrorUpdater}
+ * @public
+ */
+export const setExportImageErrorUpdater = (state, {payload: error}) => ({
...state,
exportImage: {
...state.exportImage,
@@ -405,11 +432,10 @@ export const setExportImageError = (state, {payload: error}) => ({
/**
* Delete cached export image
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @returns {Object} nextState
+ * @type {typeof import('./ui-state-updaters').cleanupExportImageUpdater}
* @public
*/
-export const cleanupExportImage = state => ({
+export const cleanupExportImageUpdater = state => ({
...state,
exportImage: {
...state.exportImage,
@@ -422,10 +448,11 @@ export const cleanupExportImage = state => ({
/**
* Set selected dataset for export
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {string} action.payload dataset id
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload dataset id
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setExportSelectedDatasetUpdater}
* @public
*/
export const setExportSelectedDatasetUpdater = (state, {payload: dataset}) => ({
@@ -439,10 +466,11 @@ export const setExportSelectedDatasetUpdater = (state, {payload: dataset}) => ({
/**
* Set data format for exporting data
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {string} action.payload one of `'text/csv'`
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload one of `'text/csv'`
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setExportDataTypeUpdater}
* @public
*/
export const setExportDataTypeUpdater = (state, {payload: dataType}) => ({
@@ -456,10 +484,11 @@ export const setExportDataTypeUpdater = (state, {payload: dataType}) => ({
/**
* Whether to export filtered data, `true` or `false`
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {boolean} action.payload
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setExportFilteredUpdater}
* @public
*/
export const setExportFilteredUpdater = (state, {payload: filtered}) => ({
@@ -473,8 +502,9 @@ export const setExportFilteredUpdater = (state, {payload: filtered}) => ({
/**
* Whether to including data in map config, toggle between `true` or `false`
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setExportDataUpdater}
* @public
*/
export const setExportDataUpdater = state => ({
@@ -490,10 +520,11 @@ export const setExportDataUpdater = state => ({
/**
* whether to export a mapbox access to HTML single page
- * @param {Object} state - `uiState`
- * @param {Object} action
- * @param {string} action.payload
- * @returns {Object} nextState
+ * @param state - `uiState`
+ * @param action
+ * @param action.payload
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setUserMapboxAccessTokenUpdater}
* @public
*/
export const setUserMapboxAccessTokenUpdater = (state, {payload: userMapboxToken}) => ({
@@ -509,9 +540,11 @@ export const setUserMapboxAccessTokenUpdater = (state, {payload: userMapboxToken
/**
* Sets the export map format
- * @param {Object} state - `uiState`
- * @param {string} format to use to export the map onto
- * @return {Object} nextState
+ * @param state - `uiState`
+ * @param action
+ * @param action.payload format to use to export the map into
+ * @return nextState
+ * @type {typeof import('./ui-state-updaters').setExportMapFormatUpdater}
*/
export const setExportMapFormatUpdater = (state, {payload: format}) => ({
...state,
@@ -523,11 +556,13 @@ export const setExportMapFormatUpdater = (state, {payload: format}) => ({
/**
* Set the export html map mode
- * @param {Object} state - `uiState`
- * @param {string} mode to be set (available modes: EXPORT_HTML_MAP_MODES)
- * @return {{[p: string]: *}}
+ * @param state - `uiState`
+ * @param action
+ * @param action.payload to be set (available modes: EXPORT_HTML_MAP_MODES)
+ * @return nextState
+ * @type {typeof import('./ui-state-updaters').setExportMapHTMLModeUpdater}
*/
-export const setExportMapHTMLMode = (state, {payload: mode}) => ({
+export const setExportMapHTMLModeUpdater = (state, {payload: mode}) => ({
...state,
exportMap: {
...state.exportMap,
@@ -541,10 +576,11 @@ export const setExportMapHTMLMode = (state, {payload: mode}) => ({
/**
* Add a notification to be displayed
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {Object} action.payload
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').addNotificationUpdater}
* @public
*/
export const addNotificationUpdater = (state, {payload}) => ({
@@ -555,10 +591,11 @@ export const addNotificationUpdater = (state, {payload}) => ({
/**
* Remove a notification
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {String} action.payload id of the notification to be removed
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload id of the notification to be removed
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').removeNotificationUpdater}
* @public
*/
export const removeNotificationUpdater = (state, {payload: id}) => ({
@@ -569,8 +606,9 @@ export const removeNotificationUpdater = (state, {payload: id}) => ({
/**
* Fired when file loading begin
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').loadFilesUpdater}
* @public
*/
export const loadFilesUpdater = state => ({
@@ -584,8 +622,9 @@ export const loadFilesUpdater = state => ({
/**
* Handles loading file success and set fileLoading property to false
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').loadFilesSuccessUpdater}
*/
export const loadFilesSuccessUpdater = state => ({
...state,
@@ -599,8 +638,10 @@ export const loadFilesSuccessUpdater = state => ({
* Handles load file error and set fileLoading property to false
* @memberof uiStateUpdaters
* @param state
- * @param error
- * @returns {Object} nextState
+ * @param action
+ * @param action.error
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').loadFilesErrUpdater}
* @public
*/
export const loadFilesErrUpdater = (state, {error}) =>
@@ -624,7 +665,8 @@ export const loadFilesErrUpdater = (state, {error}) =>
* Handles toggle map split and reset all map control index to 0
* @memberof uiStateUpdaters
* @param state
- * @returns {Object} nextState
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').toggleSplitMapUpdater}
* @public
*/
export const toggleSplitMapUpdater = state => ({
@@ -644,10 +686,12 @@ export const toggleSplitMapUpdater = state => ({
/**
* Set the locale of the UI
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {Object} action
- * @param {String} action.payload locale
- * @returns {Object} nextState
+ * @param state `uiState`
+ * @param action
+ * @param action.payload
+ * @param action.payload.locale locale
+ * @returns nextState
+ * @type {typeof import('./ui-state-updaters').setLocaleUpdater}
* @public
*/
export const setLocaleUpdater = (state, {payload: {locale}}) => ({
diff --git a/src/reducers/ui-state.js b/src/reducers/ui-state.js
index 5abdc3c5f..883ba8c4c 100644
--- a/src/reducers/ui-state.js
+++ b/src/reducers/ui-state.js
@@ -36,11 +36,11 @@ const actionHandler = {
[ActionTypes.ADD_NOTIFICATION]: uiStateUpdaters.addNotificationUpdater,
[ActionTypes.REMOVE_NOTIFICATION]: uiStateUpdaters.removeNotificationUpdater,
- [ActionTypes.SET_EXPORT_IMAGE_SETTING]: uiStateUpdaters.setExportImageSetting,
- [ActionTypes.START_EXPORTING_IMAGE]: uiStateUpdaters.startExportingImage,
- [ActionTypes.SET_EXPORT_IMAGE_DATA_URI]: uiStateUpdaters.setExportImageDataUri,
- [ActionTypes.SET_EXPORT_IMAGE_ERROR]: uiStateUpdaters.setExportImageError,
- [ActionTypes.CLEANUP_EXPORT_IMAGE]: uiStateUpdaters.cleanupExportImage,
+ [ActionTypes.SET_EXPORT_IMAGE_SETTING]: uiStateUpdaters.setExportImageSettingUpdater,
+ [ActionTypes.START_EXPORTING_IMAGE]: uiStateUpdaters.startExportingImageUpdater,
+ [ActionTypes.SET_EXPORT_IMAGE_DATA_URI]: uiStateUpdaters.setExportImageDataUriUpdater,
+ [ActionTypes.SET_EXPORT_IMAGE_ERROR]: uiStateUpdaters.setExportImageErrorUpdater,
+ [ActionTypes.CLEANUP_EXPORT_IMAGE]: uiStateUpdaters.cleanupExportImageUpdater,
[ActionTypes.SET_EXPORT_SELECTED_DATASET]: uiStateUpdaters.setExportSelectedDatasetUpdater,
[ActionTypes.SET_EXPORT_DATA_TYPE]: uiStateUpdaters.setExportDataTypeUpdater,
@@ -50,7 +50,7 @@ const actionHandler = {
[ActionTypes.SET_EXPORT_MAP_FORMAT]: uiStateUpdaters.setExportMapFormatUpdater,
- [ActionTypes.SET_EXPORT_MAP_HTML_MODE]: uiStateUpdaters.setExportMapHTMLMode,
+ [ActionTypes.SET_EXPORT_MAP_HTML_MODE]: uiStateUpdaters.setExportMapHTMLModeUpdater,
[ActionTypes.LOAD_FILES]: uiStateUpdaters.loadFilesUpdater,
[ActionTypes.LOAD_FILES_ERR]: uiStateUpdaters.loadFilesErrUpdater,
diff --git a/src/reducers/vis-state-merger.d.ts b/src/reducers/vis-state-merger.d.ts
new file mode 100644
index 000000000..e7d48e72e
--- /dev/null
+++ b/src/reducers/vis-state-merger.d.ts
@@ -0,0 +1,26 @@
+import {VisState} from './vis-state-updaters';
+import {ParsedConfig} from 'schemas';
+
+export function mergeAnimationConfig(
+ state: VisState,
+ animation: ParsedConfig['visState']['animationConfig']
+): VisState;
+export function mergeFilters(
+ state: VisState,
+ filters: ParsedConfig['visState']['filters']
+): VisState;
+export function mergeInteractions(
+ state: VisState,
+ interactionConfig: ParsedConfig['visState']['interactionConfig']
+): VisState;
+export function mergeLayerBlending(
+ state: VisState,
+ layerBlending: ParsedConfig['visState']['layerBlending']
+): VisState;
+export function mergeLayers(state: VisState, layers: ParsedConfig['visState']['layers']): VisState;
+export function mergeSplitMaps(
+ state: VisState,
+ splitMaps: ParsedConfig['visState']['splitMaps']
+): VisState;
+
+export function mergeInteractionTooltipConfig(state: VisState);
diff --git a/src/reducers/vis-state-merger.js b/src/reducers/vis-state-merger.js
index b765322ef..170e31439 100644
--- a/src/reducers/vis-state-merger.js
+++ b/src/reducers/vis-state-merger.js
@@ -24,21 +24,22 @@ import isEqual from 'lodash.isequal';
import flattenDeep from 'lodash.flattendeep';
import {toArray} from 'utils/utils';
-import {applyFiltersToDatasets, validateFilterWithData} from 'utils/filter-utils';
+import {
+ applyFiltersToDatasets,
+ mergeFilterDomainStep,
+ validateFilterWithData
+} from 'utils/filter-utils';
import {getInitialMapLayersForSplitMap} from 'utils/split-map-utils';
import {resetFilterGpuMode, assignGpuChannels} from 'utils/gpu-filter-utils';
import {LAYER_BLENDINGS} from 'constants/default-settings';
-import {mergeFilterDomainStep} from '../utils/filter-utils';
/**
* Merge loaded filters with current state, if no fields or data are loaded
* save it for later
*
- * @param {Object} state
- * @param {Array<Object>} filtersToMerge
- * @return {Object} updatedState
+ * @type {typeof import('./vis-state-merger').mergeFilters}
*/
export function mergeFilters(state, filtersToMerge) {
const merged = [];
@@ -135,9 +136,7 @@ export function mergeFilters(state, filtersToMerge) {
* Merge layers from de-serialized state, if no fields or data are loaded
* save it for later
*
- * @param {Object} state
- * @param {Array<Object>} layersToMerge
- * @return {Object} state
+ * @type {typeof import('./vis-state-merger').mergeLayers}
*/
export function mergeLayers(state, layersToMerge) {
const mergedLayer = [];
@@ -184,9 +183,7 @@ export function mergeLayers(state, layersToMerge) {
/**
* Merge interactions with saved config
*
- * @param {Object} state
- * @param {Object} interactionToBeMerged
- * @return {Object} mergedState
+ * @type {typeof import('./vis-state-merger').mergeInteractions}
*/
export function mergeInteractions(state, interactionToBeMerged) {
const merged = {};
@@ -253,6 +250,7 @@ export function mergeInteractions(state, interactionToBeMerged) {
* : don't merge anything
* 2. if current map is NOT split, but splitMaps contain maps
* : add to splitMaps, and add current layers to splitMaps
+ * @type {typeof import('./vis-state-merger').mergeInteractions}
*/
export function mergeSplitMaps(state, splitMaps = []) {
const merged = [...state.splitMaps];
@@ -284,9 +282,9 @@ export function mergeSplitMaps(state, splitMaps = []) {
* Merge interactionConfig.tooltip with saved config,
* validate fieldsToShow
*
- * @param {string} state
- * @param {Object} tooltipConfig
- * @return {Object} - {mergedTooltip: {}, unmergedTooltip: {}}
+ * @param {object} state
+ * @param {object} tooltipConfig
+ * @return {object} - {mergedTooltip: {}, unmergedTooltip: {}}
*/
export function mergeInteractionTooltipConfig(state, tooltipConfig = {}) {
const unmergedTooltip = {};
@@ -316,9 +314,7 @@ export function mergeInteractionTooltipConfig(state, tooltipConfig = {}) {
/**
* Merge layerBlending with saved
*
- * @param {object} state
- * @param {string} layerBlending
- * @return {object} merged state
+ * @type {typeof import('./vis-state-merger').mergeLayerBlending}
*/
export function mergeLayerBlending(state, layerBlending) {
if (layerBlending && LAYER_BLENDINGS[layerBlending]) {
@@ -333,8 +329,7 @@ export function mergeLayerBlending(state, layerBlending) {
/**
* Merge animation config
- * @param {Object} state
- * @param {Object} animation
+ * @type {typeof import('./vis-state-merger').mergeAnimationConfig}
*/
export function mergeAnimationConfig(state, animation) {
if (animation && animation.currentTime) {
@@ -449,9 +444,9 @@ export function validateSavedVisualChannels(fields, newLayer, savedLayer) {
/**
* Validate saved layer config with new data,
* update fieldIdx based on new fields
- *
- * @param {Array<Object>} fields
- * @param {string} dataId
+ * @param {object} dataset
+ * @param {Array<Object>} dataset.fields
+ * @param {string} dataset.id
* @param {Object} savedLayer
* @param {Object} layerClasses
* @return {null | Object} - validated layer or null
diff --git a/src/reducers/vis-state-updaters.d.ts b/src/reducers/vis-state-updaters.d.ts
new file mode 100644
index 000000000..f8a7af925
--- /dev/null
+++ b/src/reducers/vis-state-updaters.d.ts
@@ -0,0 +1,494 @@
+import {RGBColor, RGBAColor, Millisecond} from './types';
+import {AddDataToMapOptions, ReceiveMapConfigPayload} from '../actions/actions';
+import {ParsedConfig} from '../schemas';
+import * as VisStateActions from 'actions/vis-state-actions';
+import ActionTypes from 'constants/action-types';
+
+export type HistogramBin = {
+ x0: number | undefined;
+ x1: number | undefined;
+ count: number;
+};
+
+export type RangeFieldDomain = {
+ domain: [number, number];
+ step: number;
+ histogram: HistogramBin[];
+ enlargedHistogram: HistogramBin[];
+};
+
+export type SelectFieldDomain = {
+ domain: [true, false];
+};
+export type MultiSelectFieldDomain = {
+ domain: string[];
+};
+
+export type TimeRangeFieldDomain = {
+ domain: [number, number];
+ step: number;
+ histogram: HistogramBin[];
+ enlargedHistogram: HistogramBin[];
+ mappedValue: (Millisecond | null)[];
+};
+export type FieldDomain =
+ | RangeFieldDomain
+ | TimeRangeFieldDomain
+ | SelectFieldDomain
+ | MultiSelectFieldDomain;
+
+export type LineChart = {
+ series: {x: number; y: number}[];
+ yDomain: [number, number];
+ xDomain: [number, number];
+};
+
+export type FilterBase = {
+ dataId: string[];
+ id: string;
+
+ freeze: boolean;
+
+ // time range filter specific
+ fixedDomain: boolean;
+ enlarged: boolean;
+ isAnimating: boolean;
+ speed: number;
+
+ // field specific
+ name: string[]; // string
+ type: string | null;
+ fieldIdx: number[]; // [integer]
+ domain: any[] | null;
+ value: any;
+ mappedValue?: number[];
+
+ // plot
+ yAxis: Field | null;
+ plotType: string;
+ lineChart?: LineChart;
+ // gpu filter
+ gpu: boolean;
+ gpuChannel?: number[];
+ fieldType?: string;
+
+ // polygon
+ layerId?: string[];
+};
+
+export type RangeFilter = FilterBase &
+ RangeFieldDomain & {
+ type: 'range';
+ fieldType: 'real' | 'integer';
+ value: [number, number];
+ fixedDomain: true;
+ typeOptions: ['range'];
+ };
+
+export type SelectFilter = FilterBase &
+ SelectFieldDomain & {
+ type: 'select';
+ fieldType: 'boolean';
+ value: boolean;
+ };
+
+export type MultiSelectFilter = FilterBase &
+ MultiSelectFieldDomain & {
+ type: 'range';
+ fieldType: 'string' | 'date';
+ value: string[];
+ };
+export type TimeRangeFilter = FilterBase &
+ TimeRangeFieldDomain & {
+ type: 'timeRange';
+ fieldType: 'timestamp';
+ fixedDomain: true;
+ value: [number, number];
+ };
+
+export type PolygonFilter = FilterBase & {
+ layerId: string[];
+ type: 'polygon';
+ fixedDomain: true;
+ value: Feature;
+};
+
+export type Filter =
+ | FilterBase
+ | RangeFilter
+ | TimeRangeFilter
+ | SelectFilter
+ | MultiSelectFilter
+ | PolygonFilter;
+
+export type FilterRecord = {
+ dynamicDomain: Filter[];
+ fixedDomain: Filter[];
+ cpu: Filter[];
+ gpu: Filter[];
+};
+
+export type Field = {
+ analyzerType: string;
+ id?: string;
+ name: string;
+ format: string;
+ tableFieldIndex: number;
+ type: string;
+ filterProps?: any;
+};
+
+export type GpuFilter = {
+ filterRange: number[][];
+ filterValueUpdateTriggers: any;
+ filterValueAccessor: any;
+};
+
+export type FieldPair = {
+ defaultName: string;
+ pair: {
+ [key: string]: {
+ fieldIdx: number;
+ value: string;
+ }
+ };
+ suffix: string[];
+};
+
+export type Dataset = {
+ id: string;
+ label?: string;
+ color: RGBColor;
+
+ // fields and data
+ fields: Field[];
+ allData: any[][];
+
+ allIndexes: number[];
+ filteredIndex: number[];
+ filteredIdxCPU?: number[];
+ filteredIndexForDomain: number[];
+ fieldPairs: FieldPair[];
+ gpuFilter: GpuFilter;
+ filterRecord?: FilterRecord;
+ filterRecordCPU?: FilterRecord;
+ changedFilters?: any;
+
+ // table-injected metadata
+ sortColumn?: {
+ // column name: sorted idx
+ [key: string]: string; // ASCENDING | DESCENDING | UNSORT
+ };
+ sortOrder?: number[] | null;
+
+ pinnedColumns?: string[];
+ // table-injected metadata
+ metadata?: object;
+};
+
+export type Datasets = {
+ [key: string]: Dataset;
+};
+export type Feature = {
+ id: string;
+ properties: any;
+ geometry: {
+ type: string;
+ coordinates: any;
+ };
+};
+export type FeatureValue = {
+ id: string;
+ properties: {
+ filterId: string;
+ };
+ geometry: {
+ type: string;
+ coordinates: any;
+ };
+};
+export type Editor = {
+ mode: string;
+ features: Feature[];
+ selectedFeature: any;
+ visible: boolean;
+};
+export type SplitMap = {
+ layers: {[key: string]: boolean};
+};
+export type AnimationConfig = {
+ domain: number[] | null;
+ currentTime: number | null;
+ speed: number;
+};
+
+type BaseInteraction = {
+ id: string;
+ label: string;
+ enabled: boolean;
+ iconComponent: any;
+};
+export type Tooltip = BaseInteraction & {
+ config: {
+ fieldsToShow: {
+ [key: string]: string[];
+ };
+ };
+};
+export type Geocoder = BaseInteraction & {
+ position: number[] | null;
+};
+export type Brush = BaseInteraction & {
+ config: {
+ size: number;
+ };
+};
+export type Coordinate = BaseInteraction & {
+ position: number[] | null;
+};
+export type InteractionConfig = {
+ tooltip: Tooltip;
+ geocoder: Geocoder;
+ brush: Brush;
+ coordinate: Coordinate;
+};
+export type MapInfo = {
+ title: string;
+ description: string;
+};
+export type VisState = {
+ mapInfo: MapInfo;
+ layers: Layer[];
+ layerData: any[];
+ layerToBeMerged: any[];
+ layerOrder: number[];
+ filters: Filter[];
+ filterToBeMerged: any[];
+ datasets: Datasets;
+ editingDataset: string | undefined;
+ interactionConfig: InteractionConfig;
+ interactionToBeMerged: any;
+ layerBlending: string;
+ hoverInfo: any;
+ clicked: any;
+ mousePos: any;
+ layerClasses: {
+ [key: string]: any;
+ };
+ animationConfig: AnimationConfig;
+ editor: Editor;
+ splitMaps: SplitMap[];
+ splitMapsToBeMerged?: SplitMap[];
+ initialState?: Partial<VisState>;
+ fileLoading?: boolean;
+ fileLoadingErr?: any;
+};
+
+export function addDefaultLayers(
+ state: VisState,
+ datasets: Datasets
+): {state: VisState; newLayers: Layer[]};
+export function updateAllLayerDomainData(
+ state: VisState,
+ dataId: string | string[],
+ updatedFilter?: Filter
+): VisState;
+
+export function updateStateWithLayerAndData(
+ state: VisState,
+ data: {layerData?: any; layer: Layer; idx: number}
+): VisState;
+
+export function layerConfigChangeUpdater(
+ state: VisState,
+ action: VisStateActions.LayerConfigChangeUpdaterAction
+): VisState;
+export function layerTextLabelChangeUpdater(
+ state: VisState,
+ action: VisStateActions.LayerTextLabelChangeUpdaterAction
+): VisState;
+export function layerTypeChangeUpdater(
+ state: VisState,
+ action: VisStateActions.LayerTypeChangeUpdaterAction
+): VisState;
+export function layerVisualChannelChangeUpdater(
+ state: VisState,
+ action: VisStateActions.LayerVisualChannelConfigChangeUpdaterAction
+): VisState;
+export function layerVisConfigChangeUpdater(
+ state: VisState,
+ action: VisStateActions.LayerVisConfigChangeUpdaterAction
+): VisState;
+export function layerColorUIChangeUpdater(
+ state: VisState,
+ action: VisStateActions.LayerColorUIChangeUpdaterAction
+): VisState;
+export function updateLayerBlendingUpdater(
+ state: VisState,
+ action: VisStateActions.UpdateLayerBlendingUpdaterAction
+): VisState;
+export function interactionConfigChangeUpdater(
+ state: VisState,
+ action: VisStateActions.InteractionConfigChangeUpdaterAction
+): VisState;
+export function setFilterUpdater(
+ state: VisState,
+ action: VisStateActions.SetFilterUpdaterAction
+): VisState;
+export function addFilterUpdater(
+ state: VisState,
+ action: VisStateActions.AddFilterUpdaterAction
+): VisState;
+export function addLayerUpdater(
+ state: VisState,
+ action: VisStateActions.AddLayerUpdaterAction
+): VisState;
+export function reorderLayerUpdater(
+ state: VisState,
+ action: VisStateActions.ReorderLayerUpdaterAction
+): VisState;
+export function removeFilterUpdater(
+ state: VisState,
+ action: VisStateActions.RemoveFilterUpdaterAction
+): VisState;
+export function removeLayerUpdater(
+ state: VisState,
+ action: VisStateActions.RemoveLayerUpdaterAction
+): VisState;
+export function removeDatasetUpdater(
+ state: VisState,
+ action: VisStateActions.RemoveDatasetUpdaterAction
+): VisState;
+export function showDatasetTableUpdater(
+ state: VisState,
+ action: VisStateActions.ShowDatasetTableUpdaterAction
+): VisState;
+export function sortTableColumnUpdater(
+ state: VisState,
+ action: VisStateActions.SortTableColumnUpdaterAction
+): VisState;
+export function pinTableColumnUpdater(
+ state: VisState,
+ action: VisStateActions.PinTableColumnUpdaterAction
+): VisState;
+export function copyTableColumnUpdater(
+ state: VisState,
+ action: VisStateActions.CopyTableColumnUpdaterAction
+): VisState;
+export function updateVisDataUpdater(
+ state: VisState,
+ action: VisStateActions.UpdateVisDataUpdaterAction
+): VisState;
+export function toggleFilterAnimationUpdater(
+ state: VisState,
+ action: VisStateActions.ToggleFilterAnimationUpdaterAction
+): VisState;
+export function updateFilterAnimationSpeedUpdater(
+ state: VisState,
+ action: VisStateActions.UpdateFilterAnimationSpeedUpdaterAction
+): VisState;
+export function updateAnimationTimeUpdater(
+ state: VisState,
+ action: VisStateActions.UpdateAnimationTimeUpdaterAction
+): VisState;
+export function updateLayerAnimationSpeedUpdater(
+ state: VisState,
+ action: VisStateActions.UpdateLayerAnimationSpeedUpdaterAction
+): VisState;
+export function enlargeFilterUpdater(
+ state: VisState,
+ action: VisStateActions.EnlargeFilterUpdaterAction
+): VisState;
+export function toggleFilterFeatureUpdater(
+ state: VisState,
+ action: VisStateActions.ToggleFilterFeatureUpdaterAction
+): VisState;
+export function layerHoverUpdater(
+ state: VisState,
+ action: VisStateActions.OnLayerHoverUpdaterAction
+): VisState;
+export function layerClickUpdater(
+ state: VisState,
+ action: VisStateActions.OnLayerClickUpdaterAction
+): VisState;
+export function mapClickUpdater(
+ state: VisState,
+ action: VisStateActions.OnMapClickUpdaterAction
+): VisState;
+export function mouseMoveUpdater(
+ state: VisState,
+ action: VisStateActions.OnMouseMoveUpdaterAction
+): VisState;
+export function toggleSplitMapUpdater(
+ state: VisState,
+ action: MapStateActions.ToggleSplitMapUpdaterAction
+);
+export function toggleLayerForMapUpdater(
+ state: VisState,
+ action: VisStateActions.ToggleLayerForMapUpdaterAction
+): VisState;
+export function setFilterPlotUpdater(
+ state: VisState,
+ action: VisStateActions.SetFilterPlotUpdaterAction
+): VisState;
+export function setMapInfoUpdater(
+ state: VisState,
+ action: VisStateActions.SetMapInfoUpdaterAction
+): VisState;
+export function loadFilesUpdater(
+ state: VisState,
+ action: VisStateActions.LoadFilesUpdaterAction
+): VisState;
+export function loadNextFileUpdater(
+ state: VisState,
+ action: VisStateActions.LoadNextFileUpdaterAction
+): VisState;
+export function loadFileSuccessUpdater(
+ state: VisState,
+ action: VisStateActions.LoadFileSuccessUpdaterAction
+): VisState;
+export function loadFilesErrUpdater(
+ state: VisState,
+ action: VisStateActions.LoadFilesErrUpdaterAction
+): VisState;
+export function setFeaturesUpdater(
+ state: VisState,
+ action: VisStateActions.SetFeaturesUpdaterAction
+): VisState;
+export function setPolygonFilterLayerUpdater(
+ state: VisState,
+ action: VisStateActions.SetPolygonFilterLayerUpdaterAction
+): VisState;
+export function setSelectedFeatureUpdater(
+ state: VisState,
+ action: VisStateActions.SetSelectedFeatureUpdaterAction
+): VisState;
+export function deleteFeatureUpdater(
+ state: VisState,
+ action: VisStateActions.DeleteFeatureUpdaterAction
+): VisState;
+export function setEditorModeUpdater(
+ state: VisState,
+ action: VisStateActions.SetEditorModeUpdaterAction
+): VisState;
+export function applyCPUFilterUpdater(
+ state: VisState,
+ action: VisStateActions.ApplyCPUFilterUpdaterAction
+): VisState;
+export function toggleEditorVisibilityUpdater(
+ state: VisState,
+ action: VisStateActions.ToggleEditorVisibilityUpdaterAction
+): VisState;
+
+export function resetMapConfigUpdater(state: VisState): VisState;
+
+export function receiveMapConfigUpdater(
+ state: VisState,
+ action: {
+ type?: ActionTypes.RECEIVE_MAP_CONFIG;
+ payload: ReceiveMapConfigPayload;
+ }
+);
+export const INITIAL_VIS_STATE: VisState;
+export const DEFAULT_ANIMATION_CONFIG: AnimationConfig;
+export const DEFAULT_EDITOR: Editor;
diff --git a/src/reducers/vis-state-updaters.js b/src/reducers/vis-state-updaters.js
index 6ab32feef..ac6d2edee 100644
--- a/src/reducers/vis-state-updaters.js
+++ b/src/reducers/vis-state-updaters.js
@@ -72,6 +72,15 @@ import {Layer, LayerClasses} from 'layers';
import {DEFAULT_TEXT_LABEL} from 'layers/layer-factory';
import {EDITOR_MODES, SORT_ORDER} from 'constants/default-settings';
+// type imports
+/** @typedef {import('./vis-state-updaters').Field} Field */
+/** @typedef {import('./vis-state-updaters').Filter} Filter */
+/** @typedef {import('./vis-state-updaters').Dataset} Dataset */
+/** @typedef {import('./vis-state-updaters').VisState} VisState */
+/** @typedef {import('./vis-state-updaters').Datasets} Datasets */
+/** @typedef {import('./vis-state-updaters').AnimationConfig} AnimationConfig */
+/** @typedef {import('./vis-state-updaters').Editor} Editor */
+
// react-palm
// disable capture exception for react-palm call to withTask
disableStackCapturing();
@@ -113,15 +122,18 @@ disableStackCapturing();
* export default composedReducer;
*/
/* eslint-disable no-unused-vars */
+// @ts-ignore
const visStateUpdaters = null;
/* eslint-enable no-unused-vars */
-export const defaultAnimationConfig = {
+/** @type {AnimationConfig} */
+export const DEFAULT_ANIMATION_CONFIG = {
domain: null,
currentTime: null,
speed: 1
};
+/** @type {Editor} */
export const DEFAULT_EDITOR = {
mode: EDITOR_MODES.DRAW_POLYGON,
features: [],
@@ -133,25 +145,7 @@ export const DEFAULT_EDITOR = {
* Default initial `visState`
* @memberof visStateUpdaters
* @constant
- * @type {Object}
- * @property {Array} layers
- * @property {Array} layerData
- * @property {Array} layerToBeMerged
- * @property {Array} layerOrder
- * @property {Array} filters
- * @property {Array} filterToBeMerged
- * @property {Array} datasets
- * @property {string} editingDataset
- * @property {Object} interactionConfig
- * @property {Object} interactionToBeMerged
- * @property {string} layerBlending
- * @property {Object} hoverInfo
- * @property {Object} clicked
- * @property {Object} mousePos
- * @property {Array} splitMaps - a list of objects of layer availabilities and visibilities for each map
- * @property {Object} layerClasses
- * @property {Object} animationConfig
- * @property {Object} editor
+ * @type {VisState}
* @public
*/
export const INITIAL_VIS_STATE = {
@@ -198,11 +192,16 @@ export const INITIAL_VIS_STATE = {
// default animation
// time in unix timestamp (milliseconds) (the number of seconds since the Unix Epoch)
- animationConfig: defaultAnimationConfig,
+ animationConfig: DEFAULT_ANIMATION_CONFIG,
editor: DEFAULT_EDITOR
};
+/**
+ * Update state with updated layer and layerData
+ * @type {typeof import('./vis-state-updaters').updateStateWithLayerAndData}
+ *
+ */
function updateStateWithLayerAndData(state, {layerData, layer, idx}) {
return {
...state,
@@ -234,11 +233,8 @@ export function updateStateOnLayerVisibilityChange(state, layer) {
/**
* Update layer base config: dataId, label, column, isVisible
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.oldLayer layer to be updated
- * @param {Object} action.newConfig new config
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').layerConfigChangeUpdater}
+ * @returns nextState
*/
export function layerConfigChangeUpdater(state, action) {
const {oldLayer} = action;
@@ -310,6 +306,12 @@ function updateTextLabelPropAndValue(idx, prop, value, textLabel) {
return newTextLabel;
}
+/**
+ * Update layer base config: dataId, label, column, isVisible
+ * @memberof visStateUpdaters
+ * @type {typeof import('./vis-state-updaters').layerTextLabelChangeUpdater}
+ * @returns nextState
+ */
export function layerTextLabelChangeUpdater(state, action) {
const {oldLayer, idx, prop, value} = action;
const {textLabel} = oldLayer.config;
@@ -336,11 +338,7 @@ export function layerTextLabelChangeUpdater(state, action) {
/**
* Update layer type. Previews layer config will be copied if applicable.
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.oldLayer layer to be updated
- * @param {string} action.newType new type
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').layerTypeChangeUpdater}
* @public
*/
export function layerTypeChangeUpdater(state, action) {
@@ -400,16 +398,15 @@ export function layerTypeChangeUpdater(state, action) {
/**
* Update layer visual channel
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.oldLayer layer to be updated
- * @param {Object} action.newConfig new visual channel config
- * @param {string} action.channel channel to be updated
+ * @type {typeof import('./vis-state-updaters').layerVisualChannelChangeUpdater}
* @returns {Object} nextState
* @public
*/
export function layerVisualChannelChangeUpdater(state, action) {
const {oldLayer, newConfig, channel} = action;
+ if (!oldLayer.config.dataId) {
+ return state;
+ }
const dataset = state.datasets[oldLayer.config.dataId];
const idx = state.layers.findIndex(l => l.id === oldLayer.id);
@@ -426,11 +423,7 @@ export function layerVisualChannelChangeUpdater(state, action) {
/**
* Update layer `visConfig`
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.oldLayer layer to be updated
- * @param {Object} action.newVisConfig new visConfig as a key value map: e.g. `{opacity: 0.8}`
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').layerVisConfigChangeUpdater}
* @public
*/
export function layerVisConfigChangeUpdater(state, action) {
@@ -456,13 +449,7 @@ export function layerVisConfigChangeUpdater(state, action) {
/**
* Update filter property
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx `idx` of filter to be updated
- * @param {string} action.prop `prop` of filter, e,g, `dataId`, `name`, `value`
- * @param {*} action.value new value
- * @param {string} datasetId used when updating a prop (dataId, name) that can be linked to multiple datasets
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').setFilterUpdater}
* @public
*/
export function setFilterUpdater(state, action) {
@@ -517,6 +504,7 @@ export function setFilterUpdater(state, action) {
// We need to update only datasetId/s if we have added/removed layers
// - check for layerId changes (XOR works because of string values)
// if no differences between layerIds, don't do any filtering
+ // @ts-ignore
const layerIdDifference = xor(newFilter.layerId, oldFilter.layerId);
const layerDataIds = uniq(
@@ -591,23 +579,22 @@ export function setFilterUpdater(state, action) {
/**
* Set the property of a filter plot
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx
- * @param {Object} action.newProp key value mapping of new prop `{yAxis: 'histogram'}`
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').setFilterPlotUpdater}
* @public
*/
-export const setFilterPlotUpdater = (state, {idx, newProp}) => {
+export const setFilterPlotUpdater = (state, {idx, newProp, valueIndex = 0}) => {
let newFilter = {...state.filters[idx], ...newProp};
const prop = Object.keys(newProp)[0];
if (prop === 'yAxis') {
const plotType = getDefaultFilterPlotType(newFilter);
-
+ // TODO: plot is not supported in multi dataset filter for now
if (plotType) {
newFilter = {
...newFilter,
- ...getFilterPlot({...newFilter, plotType}, state.datasets[newFilter.dataId].allData),
+ ...getFilterPlot(
+ {...newFilter, plotType},
+ state.datasets[newFilter.dataId[valueIndex]].allData
+ ),
plotType
};
}
@@ -622,10 +609,7 @@ export const setFilterPlotUpdater = (state, {idx, newProp}) => {
/**
* Add a new filter
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {string} action.dataId dataset `id` this new filter is associated with
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').addFilterUpdater}
* @public
*/
export const addFilterUpdater = (state, action) =>
@@ -639,10 +623,7 @@ export const addFilterUpdater = (state, action) =>
/**
* Set layer color palette ui state
* @memberof visStateUpdaters
- * @param {Object} state
- * @param {Object} action
- * @param {Object} action.prop
- * @param {Object} action.newConfig
+ * @type {typeof import('./vis-state-updaters').layerColorUIChangeUpdater}
*/
export const layerColorUIChangeUpdater = (state, {oldLayer, prop, newConfig}) => {
const newLayer = oldLayer.updateLayerColorUI(prop, newConfig);
@@ -655,10 +636,7 @@ export const layerColorUIChangeUpdater = (state, {oldLayer, prop, newConfig}) =>
/**
* Start and end filter animation
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx idx of filter
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').toggleFilterAnimationUpdater}
* @public
*/
export const toggleFilterAnimationUpdater = (state, action) => ({
@@ -669,11 +647,7 @@ export const toggleFilterAnimationUpdater = (state, action) => ({
/**
* Change filter animation speed
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx `idx` of filter
- * @param {Number} action.speed `speed` to change it to. `speed` is a multiplier
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').updateFilterAnimationSpeedUpdater}
* @public
*/
export const updateFilterAnimationSpeedUpdater = (state, action) => ({
@@ -684,10 +658,7 @@ export const updateFilterAnimationSpeedUpdater = (state, action) => ({
/**
* Reset animation config current time to a specified value
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.value the value current time will be set to
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').updateAnimationTimeUpdater}
* @public
*
*/
@@ -702,10 +673,7 @@ export const updateAnimationTimeUpdater = (state, {value}) => ({
/**
* Update animation speed with the vertical speed slider
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.speed the updated speed of the animation
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').updateLayerAnimationSpeedUpdater}
* @public
*
*/
@@ -722,10 +690,7 @@ export const updateLayerAnimationSpeedUpdater = (state, {speed}) => {
/**
* Show larger time filter at bottom for time playback (apply to time filter only)
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx index of filter to enlarge
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').enlargeFilterUpdater}
* @public
*/
export const enlargeFilterUpdater = (state, action) => {
@@ -743,10 +708,7 @@ export const enlargeFilterUpdater = (state, action) => {
/**
* Toggles filter feature visibility
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx index of filter to enlarge
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').toggleFilterFeatureUpdater}
*/
export const toggleFilterFeatureUpdater = (state, action) => {
const filter = state.filters[action.idx];
@@ -760,17 +722,14 @@ export const toggleFilterFeatureUpdater = (state, action) => {
return {
...state,
- filters: Object.assign([].concat(state.filters), {[action.idx]: newFilter})
+ filters: Object.assign([...state.filters], {[action.idx]: newFilter})
};
};
/**
* Remove a filter
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx index of filter to b e removed
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').removeFilterUpdater}
* @public
*/
export const removeFilterUpdater = (state, action) => {
@@ -795,16 +754,13 @@ export const removeFilterUpdater = (state, action) => {
newState = set(['datasets'], filteredDatasets, newState);
newState = set(['editor'], newEditor, newState);
- return updateAllLayerDomainData(newState, dataId);
+ return updateAllLayerDomainData(newState, dataId, undefined);
};
/**
* Add a new layer
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.props - new layer props
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').addLayerUpdater}
* @public
*/
export const addLayerUpdater = (state, action) => {
@@ -828,10 +784,7 @@ export const addLayerUpdater = (state, action) => {
/**
* remove layer
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number} action.idx index of layer to b e removed
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').removeLayerUpdater}
* @public
*/
export const removeLayerUpdater = (state, {idx}) => {
@@ -856,10 +809,7 @@ export const removeLayerUpdater = (state, {idx}) => {
/**
* Reorder layer
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Array<Number>} action.order an array of layer indexes
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').reorderLayerUpdater}
* @public
*/
export const reorderLayerUpdater = (state, {order}) => ({
@@ -870,15 +820,12 @@ export const reorderLayerUpdater = (state, {order}) => ({
/**
* Remove a dataset and all layers, filters, tooltip configs that based on it
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {string} action.key dataset id
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').removeDatasetUpdater}
* @public
*/
export const removeDatasetUpdater = (state, action) => {
// extract dataset key
- const {key: datasetKey} = action;
+ const {dataId: datasetKey} = action;
const {datasets} = state;
// check if dataset is present
@@ -934,10 +881,7 @@ export const removeDatasetUpdater = (state, action) => {
/**
* update layer blending mode
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {string} action.mode one of `additive`, `normal` and `subtractive`
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').updateLayerBlendingUpdater}
* @public
*/
export const updateLayerBlendingUpdater = (state, action) => ({
@@ -948,10 +892,7 @@ export const updateLayerBlendingUpdater = (state, action) => ({
/**
* Display dataset table in a modal
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {string} action.dataId dataset id to show in table
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').showDatasetTableUpdater}
* @public
*/
export const showDatasetTableUpdater = (state, action) => {
@@ -964,8 +905,7 @@ export const showDatasetTableUpdater = (state, action) => {
/**
* reset visState to initial State
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').resetMapConfigUpdater}
* @public
*/
export const resetMapConfigUpdater = state => ({
@@ -977,12 +917,7 @@ export const resetMapConfigUpdater = state => ({
/**
* Propagate `visState` reducer with a new configuration. Current config will be override.
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.payload map config to be propagated
- * @param {Object} action.payload.config map config to be propagated
- * @param {Object} action.payload.option {keepExistingConfig: true | false}
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').receiveMapConfigUpdater}
* @public
*/
export const receiveMapConfigUpdater = (state, {payload: {config = {}, options = {}}}) => {
@@ -1016,10 +951,7 @@ export const receiveMapConfigUpdater = (state, {payload: {config = {}, options =
/**
* Trigger layer hover event with hovered object
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.info Object hovered, returned by deck.gl
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').layerHoverUpdater}
* @public
*/
export const layerHoverUpdater = (state, action) => ({
@@ -1032,10 +964,7 @@ export const layerHoverUpdater = (state, action) => ({
/**
* Update `interactionConfig`
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.config new config as key value map: `{tooltip: {enabled: true}}`
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').interactionConfigChangeUpdater}
* @public
*/
export function interactionConfigChangeUpdater(state, action) {
@@ -1069,7 +998,7 @@ export function interactionConfigChangeUpdater(state, action) {
};
if (config.id === 'geocoder' && !config.enabled) {
- return removeDatasetUpdater(newState, {key: 'geocoder_dataset'});
+ return removeDatasetUpdater(newState, {dataId: 'geocoder_dataset'});
}
return newState;
@@ -1078,10 +1007,7 @@ export function interactionConfigChangeUpdater(state, action) {
/**
* Trigger layer click event with clicked object
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.info Object clicked, returned by deck.gl
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').layerClickUpdater}
* @public
*/
export const layerClickUpdater = (state, action) => ({
@@ -1098,8 +1024,7 @@ export const layerClickUpdater = (state, action) => ({
/**
* Trigger map click event, unselect clicked object
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').mapClickUpdater}
* @public
*/
export const mapClickUpdater = state => {
@@ -1109,6 +1034,12 @@ export const mapClickUpdater = state => {
};
};
+/**
+ * Trigger map move event
+ * @memberof visStateUpdaters
+ * @type {typeof import('./vis-state-updaters').mouseMoveUpdater}
+ * @public
+ */
export const mouseMoveUpdater = (state, {evt}) => {
if (Object.values(state.interactionConfig).some(config => config.enabled)) {
return {
@@ -1126,10 +1057,7 @@ export const mouseMoveUpdater = (state, {evt}) => {
/**
* Toggle visibility of a layer for a split map
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Number|undefined} action.payload index of the split map
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').toggleSplitMapUpdater}
* @public
*/
export const toggleSplitMapUpdater = (state, action) =>
@@ -1145,11 +1073,7 @@ export const toggleSplitMapUpdater = (state, action) =>
/**
* Toggle visibility of a layer in a split map
* @memberof visStateUpdaters
- * @param {Object} state
- * @param {Object} action
- * @param {Number} action.mapIndex index of the split map
- * @param {string} action.layerId id of the layer
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').toggleLayerForMapUpdater}
* @public
*/
export const toggleLayerForMapUpdater = (state, {mapIndex, layerId}) => {
@@ -1175,20 +1099,7 @@ export const toggleLayerForMapUpdater = (state, {mapIndex, layerId}) => {
/**
* Add new dataset to `visState`, with option to load a map config along with the datasets
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Array<Object>|Object} action.datasets - ***required** datasets can be a dataset or an array of datasets
- * Each dataset object needs to have `info` and `data` property.
- * @param {Object} action.datasets.info -info of a dataset
- * @param {string} action.datasets.info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- * @param {string} action.datasets.info.label - A display name of this dataset
- * @param {Object} action.datasets.data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
- * @param {Array<Object>} action.datasets.data.fields - ***required** Array of fields,
- * @param {string} action.datasets.data.fields.name - ***required** Name of the field,
- * @param {Array<Array>} action.datasets.data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
- * @param {Object} action.options option object `{centerMap: true, keepExistingConfig: false}`
- * @param {Object} action.config map config
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').updateVisDataUpdater}
* @public
*/
/* eslint-disable max-statements */
@@ -1270,7 +1181,7 @@ export const updateVisDataUpdater = (state, action) => {
}
});
- let updatedState = updateAllLayerDomainData(mergedState, Object.keys(newDataEntries));
+ let updatedState = updateAllLayerDomainData(mergedState, Object.keys(newDataEntries), undefined);
// register layer animation domain,
// need to be called after layer data is calculated
@@ -1316,11 +1227,7 @@ function closeSpecificMapAtIndex(state, action) {
/**
* Trigger file loading dispatch `addDataToMap` if succeed, or `loadFilesErr` if failed
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Array<Object>} action.files array of fileblob
- * @param {Function} action.onFinish action creator to execute after load file succeed
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').loadFilesUpdater}
* @public
*/
export const loadFilesUpdater = (state, action) => {
@@ -1375,10 +1282,7 @@ export function makeLoadFileTask(totalCount, filesToLoad, fileCache, onFinish) {
/**
* Trigger loading file error
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {*} action.error
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').loadFilesErrUpdater}
* @public
*/
export const loadFilesErrUpdater = (state, {error}) => ({
@@ -1390,10 +1294,7 @@ export const loadFilesErrUpdater = (state, {error}) => ({
/**
* When select dataset for export, apply cpu filter to selected dataset
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action
- * @param {string} action.dataId dataset id
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').applyCPUFilterUpdater}
* @public
*/
export const applyCPUFilterUpdater = (state, {dataId}) => {
@@ -1406,10 +1307,7 @@ export const applyCPUFilterUpdater = (state, {dataId}) => {
/**
* User input to update the info of the map
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Object} action action
- * @param {Object} action.info {title: 'hello'}
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').setMapInfoUpdater}
* @public
*/
export const setMapInfoUpdater = (state, action) => ({
@@ -1421,13 +1319,11 @@ export const setMapInfoUpdater = (state, action) => ({
});
/**
* Helper function to update All layer domain and layer data of state
- * @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {Array<string>} datasets
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').addDefaultLayers}
*/
export function addDefaultLayers(state, datasets) {
const defaultLayers = Object.values(datasets).reduce(
+ // @ts-ignore
(accu, dataset) => [...accu, ...(findDefaultLayer(dataset, state.layerClasses) || [])],
[]
);
@@ -1464,10 +1360,7 @@ export function addDefaultTooltips(state, dataset) {
/**
* Helper function to update layer domains for an array of datasets
- * @param {Object} state
- * @param {Array|Array<string>} dataId dataset id or array of dataset ids
- * @param {Object} updatedFilter if is called by setFilter, the filter that has updated
- * @returns {Object} nextState
+ * @type {typeof import('./vis-state-updaters').updateAllLayerDomainData}
*/
export function updateAllLayerDomainData(state, dataId, updatedFilter) {
const dataIds = typeof dataId === 'string' ? [dataId] : dataId;
@@ -1514,7 +1407,7 @@ export function updateAnimationDomain(state) {
if (!animatableLayers.length) {
return {
...state,
- animationConfig: defaultAnimationConfig
+ animationConfig: DEFAULT_ANIMATION_CONFIG
};
}
@@ -1541,9 +1434,7 @@ export function updateAnimationDomain(state) {
/**
* Update the status of the editor
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {string} mode to set to editor to
- * @return {Object} nextState
+ * @type {typeof import('./vis-state-updaters').setEditorModeUpdater}
*/
export const setEditorModeUpdater = (state, {mode}) => ({
...state,
@@ -1558,9 +1449,7 @@ export const setEditorModeUpdater = (state, {mode}) => ({
/**
* Update editor features
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {[Object]} features to store
- * @return {Object} nextState
+ * @type {typeof import('./vis-state-updaters').setFeaturesUpdater}
*/
export function setFeaturesUpdater(state, {features = []}) {
const lastFeature = features.length && features[features.length - 1];
@@ -1588,7 +1477,7 @@ export function setFeaturesUpdater(state, {features = []}) {
// if feature is part of a filter
const filterId = feature && getFilterIdInFeature(feature);
- if (filterId) {
+ if (filterId && feature) {
const featureValue = featureToFilterValue(feature, filterId);
const filterIdx = state.filters.findIndex(fil => fil.id === filterId);
return setFilterUpdater(newState, {
@@ -1604,9 +1493,7 @@ export function setFeaturesUpdater(state, {features = []}) {
/**
* Set the current selected feature
* @memberof uiStateUpdaters
- * @param {Object} state `uiState`
- * @param {[Object]} features to store
- * @return {Object} nextState
+ * @type {typeof import('./vis-state-updaters').setSelectedFeatureUpdater}
*/
export const setSelectedFeatureUpdater = (state, {feature}) => ({
...state,
@@ -1619,9 +1506,7 @@ export const setSelectedFeatureUpdater = (state, {feature}) => ({
/**
* Delete existing feature from filters
* @memberof visStateUpdaters
- * @param {Object} state `visState`
- * @param {string} selectedFeatureId feature to delete
- * @return {Object} nextState
+ * @type {typeof import('./vis-state-updaters').deleteFeatureUpdater}
*/
export function deleteFeatureUpdater(state, {feature}) {
if (!feature) {
@@ -1658,11 +1543,7 @@ export function deleteFeatureUpdater(state, {feature}) {
/**
* Toggle feature as layer filter
* @memberof visStateUpdaters
- * @param state
- * @param {Object} payload
- * @param {string} payload.featureId
- * @param {Object} payload.layer
- * @return {Object} nextState
+ * @type {typeof import('./vis-state-updaters').setPolygonFilterLayerUpdater}
*/
export function setPolygonFilterLayerUpdater(state, payload) {
const {layer, feature} = payload;
@@ -1697,15 +1578,14 @@ export function setPolygonFilterLayerUpdater(state, payload) {
}
};
}
-
- const {layerId} = state.filters[filterIdx] || [];
- const isLayerIncluded = layerId.includes(layer.id);
const filter = state.filters[filterIdx];
+ const {layerId = []} = filter;
+ const isLayerIncluded = layerId.includes(layer.id);
newLayerId = isLayerIncluded
? // if layer is included, remove it
- filter.layerId.filter(l => l !== layer.id)
- : [...filter.layerId, layer.id];
+ layerId.filter(l => l !== layer.id)
+ : [...layerId, layer.id];
} else {
// if we haven't create the polygon filter, create it
const newFilter = generatePolygonFilter([], feature);
@@ -1730,6 +1610,11 @@ export function setPolygonFilterLayerUpdater(state, payload) {
});
}
+/**
+ * @memberof visStateUpdaters
+ * @type {typeof import('./vis-state-updaters').sortTableColumnUpdater}
+ * @public
+ */
export function sortTableColumnUpdater(state, {dataId, column, mode}) {
const dataset = state.datasets[dataId];
if (!dataset) {
@@ -1746,6 +1631,11 @@ export function sortTableColumnUpdater(state, {dataId, column, mode}) {
return set(['datasets', dataId], sorted, state);
}
+/**
+ * @memberof visStateUpdaters
+ * @type {typeof import('./vis-state-updaters').pinTableColumnUpdater}
+ * @public
+ */
export function pinTableColumnUpdater(state, {dataId, column}) {
const dataset = state.datasets[dataId];
if (!dataset) {
@@ -1767,6 +1657,12 @@ export function pinTableColumnUpdater(state, {dataId, column}) {
return set(['datasets', dataId, 'pinnedColumns'], pinnedColumns, state);
}
+/**
+ * Copy column content as strings
+ * @memberof visStateUpdaters
+ * @type {typeof import('./vis-state-updaters').copyTableColumnUpdater}
+ * @public
+ */
export function copyTableColumnUpdater(state, {dataId, column}) {
const dataset = state.datasets[dataId];
if (!dataset) {
@@ -1786,11 +1682,9 @@ export function copyTableColumnUpdater(state, {dataId, column}) {
/**
* Update editor
- * @param {Object} state `visState`
- * @param visible
- * @return {Object} nextState
+ * @type {typeof import('./vis-state-updaters').toggleEditorVisibilityUpdater}
*/
-export function toggleEditorVisibility(state, {visible}) {
+export function toggleEditorVisibilityUpdater(state) {
return {
...state,
editor: {
diff --git a/src/reducers/vis-state.js b/src/reducers/vis-state.js
index 8a15eab08..c6ff63c28 100644
--- a/src/reducers/vis-state.js
+++ b/src/reducers/vis-state.js
@@ -79,8 +79,6 @@ const actionHandler = {
[ActionTypes.SET_MAP_INFO]: visStateUpdaters.setMapInfoUpdater,
- [ActionTypes.SET_VISIBLE_LAYERS_FOR_MAP]: visStateUpdaters.setVisibleLayersForMapUpdater,
-
[ActionTypes.SHOW_DATASET_TABLE]: visStateUpdaters.showDatasetTableUpdater,
[ActionTypes.TOGGLE_FILTER_ANIMATION]: visStateUpdaters.toggleFilterAnimationUpdater,
@@ -109,7 +107,7 @@ const actionHandler = {
[ActionTypes.SET_EDITOR_MODE]: visStateUpdaters.setEditorModeUpdater,
- [ActionTypes.TOGGLE_EDITOR_VISIBILITY]: visStateUpdaters.toggleEditorVisibility,
+ [ActionTypes.TOGGLE_EDITOR_VISIBILITY]: visStateUpdaters.toggleEditorVisibilityUpdater,
[ActionTypes.TOGGLE_FILTER_FEATURE]: visStateUpdaters.toggleFilterFeatureUpdater,
diff --git a/src/schemas/dataset-schema.js b/src/schemas/dataset-schema.js
index 9027ed65d..559f0b80f 100644
--- a/src/schemas/dataset-schema.js
+++ b/src/schemas/dataset-schema.js
@@ -39,7 +39,6 @@ const fieldPropertiesV1 = {
};
class FieldSchema extends Schema {
- key = 'fields';
save(fields) {
return {
[this.key]: fields.map(f => this.savePropertiesOrApplySchema(f)[this.key])
@@ -56,6 +55,7 @@ const propertiesV0 = {
color: null,
allData: null,
fields: new FieldSchema({
+ key: 'fields',
version: VERSIONS.v0,
properties: fieldPropertiesV0
})
@@ -64,6 +64,7 @@ const propertiesV0 = {
const propertiesV1 = {
...propertiesV0,
fields: new FieldSchema({
+ key: 'fields',
version: VERSIONS.v1,
properties: fieldPropertiesV1
})
@@ -116,10 +117,12 @@ class DatasetSchema extends Schema {
const datasetSchema = {
[VERSIONS.v0]: new DatasetSchema({
+ key: 'dataset',
version: VERSIONS.v0,
properties: propertiesV0
}),
[VERSIONS.v1]: new DatasetSchema({
+ key: 'dataset',
version: VERSIONS.v1,
properties: propertiesV1
})
diff --git a/src/schemas/index.d.ts b/src/schemas/index.d.ts
new file mode 100644
index 000000000..50348beb1
--- /dev/null
+++ b/src/schemas/index.d.ts
@@ -0,0 +1,14 @@
+import {KeplerGLSchema} from './schema-manager';
+
+export {
+ // default,
+ KeplerGLSchema,
+ ParsedConfig,
+ ParsedDataset,
+ SavedConfigV1,
+ SavedDatasetV1,
+ SavedMap
+} from './schema-manager';
+
+export const KeplerGlSchema: KeplerGLSchema;
+export default KeplerGlSchema
\ No newline at end of file
diff --git a/src/schemas/schema-manager.d.ts b/src/schemas/schema-manager.d.ts
new file mode 100644
index 000000000..afba58e1a
--- /dev/null
+++ b/src/schemas/schema-manager.d.ts
@@ -0,0 +1,209 @@
+import {
+ InteractionConfig,
+ Filter,
+ Tooltip,
+ SplitMap,
+ AnimationConfig,
+ VisState,
+ RGBColor,
+ Merge
+} from 'reducers';
+import {LayerTextLabel} from 'layers/layer-factory';
+
+export type SavedFilter = {
+ dataId: Filter['dataId'];
+ id: Filter['id'];
+ name: Filter['name'];
+ type: Filter['type'];
+ value: Filter['value'];
+ enlarged: Filter['enlarged'];
+ plotType: Filter['plotType'];
+ yAxis: {
+ name: string;
+ type: string;
+ } | null;
+};
+
+export type ParsedFilter = Partial<SavedFilter>;
+
+export type SavedInteractionConfig = {
+ tooltip: Tooltip['config'] & {
+ enabled: boolean;
+ };
+ geocoder: Tooltip['geocoder'] & {
+ enabled: boolean;
+ };
+ brush: Tooltip['brush'] & {
+ enabled: boolean;
+ };
+ coordinate: Tooltip['coordinate'] & {
+ enabled: boolean;
+ };
+};
+
+export type SavedField = {
+ name: string;
+ type: string;
+} | null;
+export type SavedScale = string;
+export type SavedVisualChannels = {
+ [key: string]: SavedField | SavedScale;
+};
+
+export type SavedLayer = {
+ id: string;
+ type: string;
+ config: {
+ dataId: string;
+ label: string;
+ color: RGBColor;
+ columns: {
+ [key: string]: string;
+ };
+ isVisible: boolean;
+ visConfig: object;
+ hidden: boolean;
+ textLabel: Merge<LayerTextLabel, {field: {name: string; type: string} | null}>;
+ };
+ visualChannels: SavedVisualChannels;
+};
+
+export type ParsedLayer = {
+ id?: string;
+ type?: string;
+ config?: Partial<SavedLayer['config']> & SavedVisualChannels;
+};
+
+export type SavedAnimationConfig = {
+ currentTime: AnimationConfig['currentTime'];
+ speed: AnimationConfig['speed'];
+};
+
+export type SavedVisState = {
+ filters: SavedFilter[];
+ layers: SavedLayer[];
+ interactionConfig: SavedInteractionConfig;
+ layerBlending: string;
+ splitMaps: SplitMap[];
+ animationConfig: SavedAnimationConfig;
+};
+
+export type SavedMapState = {
+ bearing: number;
+ dragRotate: boolean;
+ latitude: number;
+ longitude: number;
+ pitch: number;
+ zoom: number;
+ isSplit: boolean;
+};
+
+export type SavedLayerGroups = {
+ [key: string]: boolean;
+};
+
+export type SavedCustomMapStyle = {
+ [key: string]: {
+ accessToken: string;
+ custom: boolean;
+ icon: string;
+ id: string;
+ label: string;
+ url: string;
+ };
+};
+
+export type SavedMapStyle = {
+ styleType: string;
+ topLayerGroups: SavedLayerGroups;
+ visibleLayerGroups: SavedLayerGroups;
+ threeDBuildingColor: RGBColor;
+ mapStyles: SavedCustomMapStyle;
+};
+
+export type SavedConfigV1 = {
+ version: 'v1';
+ config: {
+ visState: SavedVisState;
+ mapState: SavedMapState;
+ mapStyle: SavedMapStyle;
+ };
+};
+
+export type ParsedConfig = {
+ visState?: {
+ layers?: ParsedLayer[];
+ filters?: ParsedFilter[];
+ interactionConfig?: Partial<SavedInteractionConfig>;
+ layerBlending?: string;
+ splitMaps?: SplitMap[];
+ animationConfig?: Partial<SavedAnimationConfig>;
+ };
+ mapState?: Partial<SavedMapState>;
+ mapStyle?: Partial<SavedMapStyle>;
+};
+
+export type SavedField = {
+ name: string;
+ type: string;
+ format?: string;
+ analyzerType?: string;
+};
+
+export type ParsedField = {
+ name: string;
+ type: string;
+ format: string;
+ analyzerType: string;
+};
+
+export type SavedDatasetV1 = {
+ version: 'v1';
+ data: {
+ id: string;
+ label: string;
+ color: RGBColor;
+ allData: any[][];
+ fields: SavedField[];
+ };
+};
+
+export type ParsedDataset = {
+ data: {
+ fields: ParsedField[];
+ rows: anu[][];
+ };
+ info: {
+ id?: string;
+ label?: string;
+ color?: RGBColor;
+ };
+};
+
+export type SavedMap = {
+ datasets: SavedDatasetV1[];
+ config: SavedConfigV1;
+ info: {
+ app: string;
+ created_at: string;
+ title: string;
+ description: string;
+ };
+};
+
+export type LoadedMap = {datasets?: ParsedDataset[] | null; config?: ParsedConfig | null};
+export class KeplerGLSchema {
+ save(state: any): SavedMap;
+ load(arg1: SavedMap | SavedMap['datasets'] | any, arg1?: SavedMap['cnofig'] | any): LoadedMap;
+ getMapInfo(state: any): VisState['mapInfo'];
+ getDatasetToSave(state: any): SavedDatasetV1[];
+ getConfigToSave(state: any): SavedConfigV1;
+ parseSavedConfig(config: any): ParsedConfig | null;
+ parseSavedData(datasets: any): ParsedDataset[] | null;
+ validateVersion(version: any): string | null;
+ hasDataChanged(state: any): boolean;
+}
+
+const KeplerGLSchemaManager: KeplerGLSchema;
+
+export default KeplerGLSchemaManager;
diff --git a/src/schemas/schema-manager.js b/src/schemas/schema-manager.js
index a8ea0cec4..3a63e55ff 100644
--- a/src/schemas/schema-manager.js
+++ b/src/schemas/schema-manager.js
@@ -34,6 +34,7 @@ const REDUCER_SCHEMAS = {
mapStyle: mapStyleSchema
};
+/** @type {typeof import('./schema-manager').KeplerGLSchema} */
class KeplerGLSchema {
constructor() {
this._validVersions = VERSIONS;
@@ -68,8 +69,8 @@ class KeplerGLSchema {
* }
*
* Get config and data of current map to save
- * @param {Object} state
- * @returns {{datasets: Object[], config: Object, info: Object}} app state to save
+ * @param state
+ * @returns app state to save
*/
save(state) {
return {
@@ -88,8 +89,8 @@ class KeplerGLSchema {
}
/**
* Load saved map, argument can be (datasets, config) or ({datasets, config})
- * @param {Object|Array<Object>} savedDatasets
- * @param {Object} savedConfig
+ * @param savedDatasets
+ * @param savedConfig
*/
load(savedDatasets, savedConfig) {
// if pass dataset and config in as a single object
@@ -109,8 +110,8 @@ class KeplerGLSchema {
/**
* Get data to save
- * @param {Object} state - app state
- * @returns {{version: String, data: Object}} - dataset to save
+ * @param state - app state
+ * @returns - dataset to save
*/
getDatasetToSave(state) {
const dataChangedSinceLastSave = this.hasDataChanged(state);
@@ -154,8 +155,8 @@ class KeplerGLSchema {
/**
* Parse saved data
- * @param {Array} datasets
- * @returns {Object | null} - data to save
+ * @param datasets
+ * @returns - dataset to pass to addDataToMap
*/
parseSavedData(datasets) {
return datasets.reduce((accu, ds) => {
@@ -170,10 +171,6 @@ class KeplerGLSchema {
/**
* Parse saved App config
- * @param {String} opt.version - config version
- * @param {Object} opt.config - saved config
- * @param {Object} state - current App State
- * @returns {Object | null} - parsed config
*/
parseSavedConfig({version, config}, state = {}) {
const validVersion = this.validateVersion(version);
@@ -194,8 +191,8 @@ class KeplerGLSchema {
/**
* Validate version
- * @param {String} version
- * @returns {String | null} validVersion
+ * @param version
+ * @returns validVersion
*/
validateVersion(version) {
if (!version) {
@@ -213,8 +210,8 @@ class KeplerGLSchema {
/**
* Check if data has changed since last save
- * @param {Object} state
- * @returns {boolean} - whether data has changed or not
+ * @param state
+ * @returns - whether data has changed or not
*/
hasDataChanged(state) {
return this._datasetLastSaved !== state.visState.datasets;
diff --git a/src/schemas/schema-utils.js b/src/schemas/schema-utils.js
index 03c46e97b..ef4fbef9d 100644
--- a/src/schemas/schema-utils.js
+++ b/src/schemas/schema-utils.js
@@ -22,7 +22,6 @@
* Recursively save / load value for state based on property keys,
* if property[key] is another schema
* Use is to get value to save
- * @param {Object} opertation - 'save' or 'load'
* @param {Object} state - state to save
* @param {Object} properties - properties schema
* @returns {Object} - saved state
diff --git a/src/schemas/schema.d.ts b/src/schemas/schema.d.ts
new file mode 100644
index 000000000..9341c89a4
--- /dev/null
+++ b/src/schemas/schema.d.ts
@@ -0,0 +1,47 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+type Properties =
+ | {
+ [key: string]: null | Schema;
+ }
+ | string[]
+ | null;
+
+export class Schema {
+ constructor(prop?: {version?: string; key?: string; properties?: Properties}): any;
+ version: string;
+ key: string;
+ properties: Properties;
+ load(node: any, parents?: string[], accumulator?: any): {[key: string]: any};
+ save(node: any, parents?: string[], accumulator?: any): {[key: string]: any};
+ savePropertiesOrApplySchema(
+ node: any,
+ parents?: string[],
+ accumulator?: any
+ ): {[key: string]: any};
+ loadPropertiesOrApplySchema(
+ node: any,
+ parents?: string[],
+ accumulator?: any
+ ): {[key: string]: any};
+}
+
+export default Schema;
diff --git a/src/schemas/schema.js b/src/schemas/schema.js
index 91e182910..09d3d9544 100644
--- a/src/schemas/schema.js
+++ b/src/schemas/schema.js
@@ -22,8 +22,9 @@ import {console as Console} from 'global/window';
import {CURRENT_VERSION} from './versions';
+/** @type {typeof import('./schema').Schema} */
export default class Schema {
- constructor({version, key, properties} = {}) {
+ constructor({version = CURRENT_VERSION, key = '', properties = null} = {}) {
this.version = version;
this.properties = properties;
this.key = key;
diff --git a/src/schemas/vis-state-schema.js b/src/schemas/vis-state-schema.js
index c0554086c..3442d2767 100644
--- a/src/schemas/vis-state-schema.js
+++ b/src/schemas/vis-state-schema.js
@@ -464,7 +464,7 @@ export const layerPropsV1 = {
visConfig: new VisConfigSchemaV1({
version: VERSIONS.v1
}),
- hidden: false,
+ hidden: null,
textLabel: new TextLabelSchemaV1({
version: VERSIONS.v1,
key: 'textLabel'
@@ -522,33 +522,37 @@ class InteractionSchemaV0 extends Schema {
key = 'interactionConfig';
save(interactionConfig) {
- return {
- [this.key]: this.properties.reduce(
- (accu, key) => ({
- ...accu,
- ...(interactionConfig[key].enabled ? {[key]: interactionConfig[key].config} : {})
- }),
- {}
- )
- };
+ return Array.isArray(this.properties)
+ ? {
+ [this.key]: this.properties.reduce(
+ (accu, key) => ({
+ ...accu,
+ ...(interactionConfig[key].enabled ? {[key]: interactionConfig[key].config} : {})
+ }),
+ {}
+ )
+ }
+ : {};
}
load(interactionConfig) {
// convert v0 -> v1
// return enabled: false if disabled,
- return {
- [this.key]: this.properties.reduce(
- (accu, key) => ({
- ...accu,
- ...{
- [key]: {
- ...(interactionConfig[key] || {}),
- enabled: Boolean(interactionConfig[key])
- }
- }
- }),
- {}
- )
- };
+ return Array.isArray(this.properties)
+ ? {
+ [this.key]: this.properties.reduce(
+ (accu, key) => ({
+ ...accu,
+ ...{
+ [key]: {
+ ...(interactionConfig[key] || {}),
+ enabled: Boolean(interactionConfig[key])
+ }
+ }
+ }),
+ {}
+ )
+ }
+ : {};
}
}
@@ -559,18 +563,20 @@ class InteractionSchemaV1 extends Schema {
save(interactionConfig) {
// save config even if disabled,
- return {
- [this.key]: this.properties.reduce(
- (accu, key) => ({
- ...accu,
- [key]: {
- ...interactionConfig[key].config,
- enabled: interactionConfig[key].enabled
- }
- }),
- {}
- )
- };
+ return Array.isArray(this.properties)
+ ? {
+ [this.key]: this.properties.reduce(
+ (accu, key) => ({
+ ...accu,
+ [key]: {
+ ...interactionConfig[key].config,
+ enabled: interactionConfig[key].enabled
+ }
+ }),
+ {}
+ )
+ }
+ : {};
}
load(interactionConfig) {
return {[this.key]: interactionConfig};
diff --git a/src/templates/export-map-html.js b/src/templates/export-map-html.js
index a08cd199c..84416c9c3 100644
--- a/src/templates/export-map-html.js
+++ b/src/templates/export-map-html.js
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import {KEPLER_GL_VERSION, EXPORT_HTML_MAP_MODES} from 'constants/default-settings';
/**
diff --git a/src/utils/color-utils.js b/src/utils/color-utils.js
index 2c5625291..d9f3abf46 100644
--- a/src/utils/color-utils.js
+++ b/src/utils/color-utils.js
@@ -22,7 +22,7 @@
* get r g b from hex code
*
* @param {string} hex
- * @returns {array} array of r g bs
+ * @returns {import('reducers/types').RGBColor} array of r g bs
*/
export function hexToRgb(hex) {
const result = isHexColor(hex);
@@ -64,7 +64,7 @@ export function rgbToHex([r, g, b]) {
* e.g. Global Warming 6 -> Global Warming
*
* @param {Object} colorRange
- * @return {string}
+ * @return {string | null}
*/
export function getColorGroupByName(colorRange) {
if (!colorRange || typeof colorRange.name !== 'string') {
@@ -92,11 +92,11 @@ export function reverseColorRange(reversed, colorRange) {
/**
* given a list of rgb arrays it will generate a linear gradient css rule
* @param direction
- * @param colors
+ * @param {Array} colors
* @return {string}
*/
export function createLinearGradient(direction, colors) {
- const step = parseFloat(100.0 / colors.length).toFixed(2);
+ const step = parseFloat((100.0 / colors.length).toFixed(2));
const bands = colors.map((rgb, index) => {
return `rgba(${rgb.join(',')}, 1) ${step * index}%, rgba(${rgb.join(',')}, 1) ${step *
(index + 1)}%`;
diff --git a/src/utils/data-scale-utils.d.ts b/src/utils/data-scale-utils.d.ts
new file mode 100644
index 000000000..1ac3d5e63
--- /dev/null
+++ b/src/utils/data-scale-utils.d.ts
@@ -0,0 +1,11 @@
+function dataValueAccessor(any): any;
+function sort(a: any, b: any): any;
+
+export function getQuantileDomain(
+ data: any[],
+ valueAccessor?: typeof dataValueAccessor,
+ sortFunc?: typeof sort
+): number[];
+export function getOrdinalDomain(data: any[], valueAccessor?: typeof dataValueAccessor): string[];
+export function getLinearDomain(data: any[], valueAccessor?: typeof dataValueAccessor): [number, number];
+export function getLogDomain(data: any[], valueAccessor?: typeof dataValueAccessor): [number, number];
diff --git a/src/utils/data-scale-utils.js b/src/utils/data-scale-utils.js
index ae129ace0..cdc82de65 100644
--- a/src/utils/data-scale-utils.js
+++ b/src/utils/data-scale-utils.js
@@ -23,10 +23,7 @@ import {extent} from 'd3-array';
/**
* return quantile domain for an array of data
- * @param {array} data
- * @param {function | undefined} valueAccessor
- * @param {function | undefined} sortFunc
- * @returns {array} domain
+ * @type {typeof import('./data-scale-utils').getQuantileDomain}
*/
export function getQuantileDomain(data, valueAccessor, sortFunc) {
const values = typeof valueAccessor === 'function' ? data.map(valueAccessor) : data;
@@ -36,9 +33,7 @@ export function getQuantileDomain(data, valueAccessor, sortFunc) {
/**
* return ordinal domain for an array of data
- * @param {array} data
- * @param {function} valueAccessor
- * @returns {array} domain
+ * @type {typeof import('./data-scale-utils').getOrdinalDomain}
*/
export function getOrdinalDomain(data, valueAccessor) {
const values = typeof valueAccessor === 'function' ? data.map(valueAccessor) : data;
@@ -50,21 +45,17 @@ export function getOrdinalDomain(data, valueAccessor) {
/**
* return linear domain for an array of data
- * @param {Array} data
- * @param {function} valueAccessor
- * @returns {Array} domain
+ * @type {typeof import('./data-scale-utils').getLinearDomain}
*/
-export function getLinearDomain(data, valueAccessor = null) {
+export function getLinearDomain(data, valueAccessor) {
const range = typeof valueAccessor === 'function' ? extent(data, valueAccessor) : extent(data);
-
+ // @ts-ignore
return range.map((d, i) => (d === undefined ? i : d));
}
/**
* return linear domain for an array of data. A log scale domain cannot contain 0
- * @param {Array} data
- * @param {function} valueAccessor
- * @returns {Array} domain
+ * @type {typeof import('./data-scale-utils').getLogDomain}
*/
export function getLogDomain(data, valueAccessor) {
const [d0, d1] = getLinearDomain(data, valueAccessor);
diff --git a/src/utils/data-utils.d.ts b/src/utils/data-utils.d.ts
new file mode 100644
index 000000000..3c815441d
--- /dev/null
+++ b/src/utils/data-utils.d.ts
@@ -0,0 +1,25 @@
+import {Millisecond} from 'reducers/types';
+import {Layer} from 'reducers/vis-state-updaters';
+import {Bounds} from 'reducers/map-state-updaters';
+
+export function maybeToDate(
+ isTime: boolean,
+ fieldIdx: number,
+ format: string,
+ d: any[]
+): any;
+
+export function timeToUnixMilli(value: any, format: string): Millisecond | null;
+export function notNullorUndefined(d: any): boolean
+export function isPlainObject(d: any): boolean
+export function numberSort(a: any, b: any): any
+export function unique(values: any[]): any[]
+export function getSortingFunction(fieldType: string): numberSort | undefined;
+export function preciseRound(num: number, decimals: number): string;
+export function parseFieldValue(value: any, type: string): string;
+export function getSampleData(
+ data: any[],
+ sampleSize?: number,
+ getValue?: any
+): any[];
+export function findMapBounds(layers: Layer[]): Bounds | null;
\ No newline at end of file
diff --git a/src/utils/data-utils.js b/src/utils/data-utils.js
index dffa4b683..367ca95ab 100644
--- a/src/utils/data-utils.js
+++ b/src/utils/data-utils.js
@@ -48,7 +48,6 @@ export function unique(values) {
/**
* return center of map from given points
* @param {array} layers
- * @param {string} dataId
* @returns {object} coordinates of map center, empty if not found
*/
export function findMapBounds(layers) {
@@ -110,8 +109,7 @@ export function getSampleData(data, sampleSize = 500, getValue = d => d) {
/**
* Convert different time format to unix milliseconds
- * @param {*} value
- * @param {*} format
+ * @type {typeof import('./data-utils').timeToUnixMilli}
*/
export function timeToUnixMilli(value, format) {
if (notNullorUndefined(value)) {
@@ -124,6 +122,10 @@ export function timeToUnixMilli(value, format) {
return null;
}
+/**
+ *
+ * @type {typeof import('./data-utils').maybeToDate}
+ */
export function maybeToDate(isTime, fieldIdx, format, d) {
if (isTime) {
return timeToUnixMilli(d[fieldIdx], format);
@@ -134,20 +136,29 @@ export function maybeToDate(isTime, fieldIdx, format, d) {
/**
* whether null or undefined
- * @returns {boolean} - yes or no
+ * @type {typeof import('./data-utils').notNullorUndefined}
*/
export function notNullorUndefined(d) {
return d !== undefined && d !== null;
}
+/**
+ * whether null or undefined
+ */
export function isPlainObject(obj) {
return obj === Object(obj) && typeof obj !== 'function' && !Array.isArray(obj);
}
+/**
+ * @type {typeof import('./data-utils').numberSort}
+ */
export function numberSort(a, b) {
return a - b;
}
+/**
+ * @type {typeof import('./data-utils').getSortingFunction}
+ */
export function getSortingFunction(fieldType) {
switch (fieldType) {
case ALL_FIELD_TYPES.real:
@@ -162,9 +173,7 @@ export function getSortingFunction(fieldType) {
/**
* round number with exact number of decimals
* return as a string
- * @param {number} num
- * @param {number} decimals
- * @returns {string} - a rounded number in string format
+ * @type {typeof import('./data-utils').preciseRound}
*/
export function preciseRound(num, decimals) {
const t = Math.pow(10, decimals);
@@ -248,9 +257,7 @@ export const FIELD_DISPLAY_FORMAT = {
/**
* Parse field value and type and return a string representation
- * @param {string} value the field value
- * @param {string} type the field type
- * @return {*}
+ * @type {typeof import('./data-utils').parseFieldValue}
*/
export const parseFieldValue = (value, type) => {
if (!notNullorUndefined(value)) {
diff --git a/src/utils/dataset-utils.d.ts b/src/utils/dataset-utils.d.ts
new file mode 100644
index 000000000..cf6309b79
--- /dev/null
+++ b/src/utils/dataset-utils.d.ts
@@ -0,0 +1,16 @@
+
+import {Dataset, Datasets, FieldPair} from '../reducers/vis-state-updaters';
+import {ProtoDataset} from '../actions';
+import {RGBColor} from 'reducers/types';
+
+export function createNewDataEntry(data: ProtoDataset, datasets: Datasets): Datasets
+
+export function getNewDatasetColor(ds: Datasets): RGBColor;
+
+export function findPointFieldPairs(fields: Feild[]): FieldPair[];
+
+export function sortDatasetByColumn(
+ dataset: Dataset,
+ column: string,
+ mode?: string
+): Dataset
\ No newline at end of file
diff --git a/src/utils/dataset-utils.js b/src/utils/dataset-utils.js
index 42f7a032d..29ff12c74 100644
--- a/src/utils/dataset-utils.js
+++ b/src/utils/dataset-utils.js
@@ -39,6 +39,7 @@ const datasetColors = [
/**
* Random color generator
+ * @return {Generator<import('reducers/types').RGBColor>}
*/
function* generateColor() {
let index = 0;
@@ -52,6 +53,7 @@ function* generateColor() {
export const datasetColorMaker = generateColor();
+/** @type {typeof import('./dataset-utils').getNewDatasetColor} */
function getNewDatasetColor(datasets) {
const presetColors = datasetColors.map(String);
const usedColors = uniq(Object.values(datasets).map(d => String(d.color))).filter(c =>
@@ -71,7 +73,11 @@ function getNewDatasetColor(datasets) {
return color;
}
-export function createNewDataEntry({info = {}, data}, datasets = {}) {
+/**
+ * Take datasets payload from addDataToMap, create datasets entry save to visState
+ * @type {typeof import('./dataset-utils').createNewDataEntry}
+ */
+export function createNewDataEntry({info, data}, datasets = {}) {
const validatedData = validateInputData(data);
if (!validatedData) {
return {};
@@ -81,7 +87,7 @@ export function createNewDataEntry({info = {}, data}, datasets = {}) {
const datasetInfo = {
id: generateHashId(4),
label: 'new dataset',
- ...info
+ ...(info || {})
};
const dataId = datasetInfo.id;
@@ -121,8 +127,9 @@ export function removeSuffixAndDelimiters(layerName, suffix) {
/**
* Find point fields pairs from fields
*
- * @param {Array} fields
- * @returns {Array} found point fields
+ * @param fields
+ * @returns found point fields
+ * @type {typeof import('./dataset-utils').findPointFieldPairs}
*/
export function findPointFieldPairs(fields) {
const allNames = fields.map(f => f.name.toLowerCase());
@@ -163,6 +170,13 @@ export function findPointFieldPairs(fields) {
}, []);
}
+/**
+ *
+ * @param dataset
+ * @param column
+ * @param mode
+ * @type {typeof import('./dataset-utils').sortDatasetByColumn}
+ */
export function sortDatasetByColumn(dataset, column, mode) {
const {allIndexes, fields, allData} = dataset;
const fieldIndex = fields.findIndex(f => f.name === column);
diff --git a/src/utils/dom-to-image.js b/src/utils/dom-to-image.js
index 08a26651f..6c3a75ded 100644
--- a/src/utils/dom-to-image.js
+++ b/src/utils/dom-to-image.js
@@ -74,16 +74,16 @@ const domtoimage = {
/**
* @param {Node} node - The DOM Node object to render
* @param {Object} options - Rendering options
- * @param {Function} options.filter - Should return true if passed node should be included in the output
+ * @param {Function} [options.filter] - Should return true if passed node should be included in the output
* (excluding node means excluding it's children as well). Not called on the root node.
- * @param {String} options.bgcolor - color for the background, any valid CSS color value.
- * @param {Number} options.width - width to be applied to node before rendering.
- * @param {Number} options.height - height to be applied to node before rendering.
- * @param {Object} options.style - an object whose properties to be copied to node's style before rendering.
- * @param {Number} options.quality - a Number between 0 and 1 indicating image quality (applicable to JPEG only),
+ * @param {String} [options.bgcolor] - color for the background, any valid CSS color value.
+ * @param {Number} [options.width] - width to be applied to node before rendering.
+ * @param {Number} [options.height] - height to be applied to node before rendering.
+ * @param {Object} [options.style] - an object whose properties to be copied to node's style before rendering.
+ * @param {Number} [options.quality] - a Number between 0 and 1 indicating image quality (applicable to JPEG only),
defaults to 1.0.
- * @param {String} options.imagePlaceholder - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
- * @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
+ * @param {String} [options.imagePlaceholder] - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
+ * @param {Boolean} [options.cacheBust] - set to true to cache bust by appending the time to the request url
* @return {Promise} - A promise that is fulfilled with a SVG image data URL
* */
function toSvg(node, options) {
@@ -325,7 +325,7 @@ function newFontFaces() {
};
function resolveAll() {
- return readAll(document)
+ return readAll()
.then(webFonts => {
return Promise.all(webFonts.map(webFont => webFont.resolve()));
})
diff --git a/src/utils/export-utils.js b/src/utils/export-utils.js
index 1a5d2ac4f..ab1af0322 100644
--- a/src/utils/export-utils.js
+++ b/src/utils/export-utils.js
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import domtoimage from 'utils/dom-to-image';
import {Blob, URL, atob, Uint8Array, ArrayBuffer, document} from 'global/window';
import {
diff --git a/src/utils/filter-utils.d.ts b/src/utils/filter-utils.d.ts
new file mode 100644
index 000000000..8b9d8e55a
--- /dev/null
+++ b/src/utils/filter-utils.d.ts
@@ -0,0 +1,175 @@
+import {
+ Filter,
+ FilterBase,
+ PolygonFilter,
+ Dataset,
+ Datasets,
+ FilterRecord,
+ FieldDomain,
+ TimeRangeFieldDomain,
+ HistogramBin,
+ Feature,
+ FeatureValue,
+ VisState,
+ Field,
+ LineChart
+} from '../reducers/vis-state-updaters';
+import {Layer} from 'layers';
+import {Field} from 'reducers/types';
+
+export function applyFilterFieldName(
+ filter: Filter,
+ dataset: Dataset,
+ fieldName: string,
+ filterDatasetIndex?: number,
+ option?: {mergeDomain: boolean}
+): {
+ filter: Filter | null;
+ dataset: Dataset;
+};
+
+export function getDefaultFilter(dataId: string | null | string[]): FilterBase;
+export function shouldApplyFilter(filter: Filter, datasetId: string): boolean;
+export function validatePolygonFilter(
+ dataset: Dataset,
+ filter: PolygonFilter,
+ layers: Layer[]
+): {filter: PolygonFilter | null; dataset: Dataset};
+
+export function validateFilter(
+ dataset: Dataset,
+ filter: Filter
+): {filter: PolygonFilter | null; dataset: Dataset};
+
+export function adjustValueToFilterDomain(value: Filter['value'], Filter): any;
+
+export type FilterDatasetOpt = {
+ // only allow cpu filtering
+ cpuOnly?: boolean;
+ // ignore filter for domain calculation
+ ignoreDomain?: boolean;
+};
+export function filterDataset(
+ dataset: Dataset,
+ filters: Filter[],
+ layers: Layer[],
+ opt?: FilterDatasetOpt
+): Dataset;
+export function applyFiltersToDatasets(
+ datasetIds: string[],
+ datasets: Datasets,
+ filters: Filter[],
+ layers: Layer[]
+): Datasets;
+export function getFilterRecord(
+ dataId: string,
+ filters: Filter[],
+ option?: FilterDatasetOpt
+): FilterRecord;
+
+function filterFunction(data: any[], index?: number): boolean;
+
+export function isValidFilterValue(type: string | null, value: any): boolean;
+export function getFilterFunction(
+ field: Field | null,
+ dataId: string,
+ filter: Filter,
+ layers: Layer[]
+): typeof filterFunction;
+
+export type FilterResult = {
+ filteredIndexForDomain?: number[];
+ filteredIndex?: number[];
+};
+export function filterDataByFilterTypes(
+ filters: {
+ dynamicDomainFilters: Filter[] | null;
+ cpuFilters: Filter[] | null;
+ filterFuncs: {
+ [key: string]: typeof filterFunction;
+ };
+ },
+ allData: Dataset['allData']
+): FilterResult;
+
+export type FilterChanged = {
+ [key in keyof FilterRecord]: {
+ [key: string]: 'added' | 'deleted' | 'name_changed' | 'value_changed' | 'dataId_changed';
+ } | null;
+};
+export function diffFilters(
+ filterRecord: FilterRecord,
+ oldFilterRecord?: FilterRecord | {}
+): FilterChanged;
+
+export type FilterDomain = any;
+
+export function getFieldDomain(allData: Dataset['allData'], filed: Field): FieldDomain;
+
+export function dataValueAccessor(data: any[]): number | null;
+export function getTimestampFieldDomain(
+ data: Dataset['allData'],
+ valueAccessor: typeof dataValueAccessor
+): TimeRangeFieldDomain;
+
+export function getNumericFieldDomain(
+ data: Dataset['allData'],
+ valueAccessor: typeof dataValueAccessor
+): RangeFieldDomain;
+
+export function histogramConstruct(
+ domain: [number, number],
+ mappedValue: (Millisecond | null | number)[],
+ bins: number
+): HistogramBin[];
+
+export function getHistogram(
+ domain: [number, number],
+ mappedValue: (Millisecond | null | number)[]
+): {histogram: HistogramBin[]; enlargedHistogram: HistogramBin[]};
+
+export function getNumericStepSize(diff: number): number;
+
+export function mergeFilterDomainStep(filter: Filter, filterProps?: any): Filter | null;
+
+export function getFilterProps(
+ allData: Dataset['allData'],
+ field: Field
+): Partiel<Filter> & {fieldType: string};
+
+export function generatePolygonFilter(layers: Layer[], feature: Feature): PolygonFilter;
+
+export function filterDatasetCPU(state: VisState, dataId: string): VisState;
+
+export function validateFilterWithData(
+ dataset: Dataset,
+ filter: Filter,
+ layers: Layer[]
+): {filter: Filter; dataset: Dataset};
+export function featureToFilterValue(
+ feature: Feature,
+ filterId: string,
+ properties?: {}
+): FeatureValue;
+
+export function getDefaultFilterPlotType(filter: Filter): string | null;
+export function getFilterPlot(
+ filter: Filter,
+ allData: Dataset['allData']
+): {lineChart: LineChart; yAxs: Field} | {};
+export function getFilterIdInFeature(f: FeatureValue): string;
+export function isInRange(v: any, domain: number[]): boolean;
+export function updateFilterDataId(dataId: string): FilterBase;
+
+export const FILTER_UPDATER_PROPS: {
+ dataId: string;
+ name: string;
+ layerId: string;
+};
+export const LIMITED_FILTER_EFFECT_PROPS: {
+ name: string;
+};
+export const PLOT_TYPES: {
+ histogram: string;
+ lineChart: string;
+};
diff --git a/src/utils/filter-utils.js b/src/utils/filter-utils.js
index 029340f22..4e7cf5d4f 100644
--- a/src/utils/filter-utils.js
+++ b/src/utils/filter-utils.js
@@ -31,6 +31,10 @@ import {LAYER_TYPES} from '../constants';
import {generateHashId, set, toArray} from './utils';
import {getGpuFilterProps, getDatasetFieldIndexForFilter} from './gpu-filter-utils';
+// TYPE
+/** @typedef {import('../reducers/vis-state-updaters').FilterRecord} FilterRecord */
+/** @typedef {import('./filter-utils').FilterResult} FilterResult */
+
export const TimestampStepMap = [
{max: 1, step: 0.05},
{max: 10, step: 0.1},
@@ -123,8 +127,7 @@ export const LAYER_FILTERS = [FILTER_TYPES.polygon];
/**
* Generates a filter with a dataset id as dataId
- * @param {[string]} dataId
- * @return {object} filter
+ * @type {typeof import('./filter-utils').getDefaultFilter}
*/
export function getDefaultFilter(dataId) {
return {
@@ -137,9 +140,10 @@ export function getDefaultFilter(dataId) {
/**
* Check if a filter is valid based on the given dataId
- * @param {object} filter to validate
- * @param {string} dataset id to validate filter against
- * @return {boolean} true if a filter is valid, false otherwise
+ * @param filter to validate
+ * @param datasetId id to validate filter against
+ * @return true if a filter is valid, false otherwise
+ * @type {typeof import('./filter-utils').shouldApplyFilter}
*/
export function shouldApplyFilter(filter, datasetId) {
const dataIds = toArray(filter.dataId);
@@ -151,7 +155,8 @@ export function shouldApplyFilter(filter, datasetId) {
* @param dataset
* @param filter
* @param layers
- * @return {object}
+ * @return - {filter, dataset}
+ * @type {typeof import('./filter-utils').validatePolygonFilter}
*/
export function validatePolygonFilter(dataset, filter, layers) {
const failed = {dataset, filter: null};
@@ -185,7 +190,6 @@ export function validatePolygonFilter(dataset, filter, layers) {
/**
* Custom filter validators
- * @type {Function}
*/
const filterValidators = {
[FILTER_TYPES.polygon]: validatePolygonFilter
@@ -195,7 +199,8 @@ const filterValidators = {
* Default validate filter function
* @param dataset
* @param filter
- * @return {*}
+ * @return - {filter, dataset}
+ * @type {typeof import('./filter-utils').validateFilter}
*/
export function validateFilter(dataset, filter) {
// match filter.dataId
@@ -244,11 +249,14 @@ export function validateFilter(dataset, filter) {
* Validate saved filter config with new data,
* calculate domain and fieldIdx based new fields and data
*
- * @param {Object} dataset
- * @param {Object} filter - filter to be validate
- * @return {Object | null} - validated filter
+ * @param dataset
+ * @param filter - filter to be validate
+ * @param layers - layers
+ * @return validated filter
+ * @type {typeof import('./filter-utils').validateFilterWithData}
*/
export function validateFilterWithData(dataset, filter, layers) {
+ // @ts-ignore
return filterValidators.hasOwnProperty(filter.type)
? filterValidators[filter.type](dataset, filter, layers)
: validateFilter(dataset, filter);
@@ -284,9 +292,10 @@ function validateFilterYAxis(filter, dataset) {
/**
* Get default filter prop based on field type
*
- * @param {Array<Array>} allData
- * @param {Object} field
- * @returns {Object} default filter
+ * @param allData
+ * @param field
+ * @returns default filter
+ * @type {typeof import('./filter-utils').getFilterProps}
*/
export function getFilterProps(allData, field) {
const filterProps = {
@@ -340,9 +349,7 @@ export function getFilterProps(allData, field) {
/**
* Calculate field domain based on field type and data
*
- * @param {Array<Array>} allData
- * @param {Object} field
- * @returns {Object} with domain as key
+ * @type {typeof import('./filter-utils').getFieldDomain}
*/
export function getFieldDomain(allData, field) {
const fieldIdx = field.tableFieldIndex - 1;
@@ -404,11 +411,13 @@ export const getPolygonFilterFunctor = (layer, filter) => {
* @param dataId Dataset id
* @param filter Filter object
* @param layers list of layers to filter upon
- * @return {*}
+ * @return filterFunction
+ * @type {typeof import('./filter-utils').getFilterFunction}
*/
export function getFilterFunction(field, dataId, filter, layers) {
- // field could be null
+ // field could be null in polygon filter
const valueAccessor = data => (field ? data[field.tableFieldIndex - 1] : null);
+ const defaultFunc = d => true;
switch (filter.type) {
case FILTER_TYPES.range:
@@ -418,6 +427,9 @@ export function getFilterFunction(field, dataId, filter, layers) {
case FILTER_TYPES.select:
return data => valueAccessor(data) === filter.value;
case FILTER_TYPES.timeRange:
+ if (!field) {
+ return defaultFunc;
+ }
const mappedValue = get(field, ['filterProps', 'mappedValue']);
const accessor = Array.isArray(mappedValue)
? (data, index) => mappedValue[index]
@@ -425,9 +437,9 @@ export function getFilterFunction(field, dataId, filter, layers) {
return (data, index) => isInRange(accessor(data, index), filter.value);
case FILTER_TYPES.polygon:
if (!layers || !layers.length) {
- return () => true;
+ return defaultFunc;
}
-
+ // @ts-ignore
const layerFilterFunctions = filter.layerId
.map(id => layers.find(l => l.id === id))
.filter(l => l && l.config.dataId === dataId)
@@ -435,7 +447,7 @@ export function getFilterFunction(field, dataId, filter, layers) {
return data => layerFilterFunctions.every(filterFunc => filterFunc(data));
default:
- return () => true;
+ return defaultFunc;
}
}
@@ -445,21 +457,13 @@ export function updateFilterDataId(dataId) {
/**
* Filter data based on an array of filters
- *
- * @param {Object} dataset
- * @param {Array<Object>} filters
- * @param {Object} opt
- * @param {Object} opt.cpuOnly only allow cpu filtering
- * @param {Object} opt.ignoreDomain ignore filter for domain calculation
- * @returns {Object} dataset
- * @returns {Array<Number>} dataset.filteredIndex
- * @returns {Array<Number>} dataset.filteredIndexForDomain
+ * @type {typeof import('./filter-utils').filterDataset}
*/
-export function filterDataset(dataset, filters, layers, opt = {}) {
+export function filterDataset(dataset, filters, layers, opt) {
const {allData, id: dataId, filterRecord: oldFilterRecord, fields} = dataset;
// if there is no filters
- const filterRecord = getFilterRecord(dataId, filters, opt);
+ const filterRecord = getFilterRecord(dataId, filters, opt || {});
const newDataset = set(['filterRecord'], filterRecord, dataset);
@@ -509,14 +513,9 @@ export function filterDataset(dataset, filters, layers, opt = {}) {
}
/**
- *
- * @param {Object} filters
- * @param {Array|null} filters.dynamicDomainFilters
- * @param {Array|null} filters.cpuFilters
- * @param {Object} filters.filterFuncs
- * @returns {{filteredIndex: Array, filteredIndexForDomain: Array}} filteredIndex and filteredIndexForDomain
+ * @type {typeof import('./filter-utils').filterDataByFilterTypes}
*/
-function filterDataByFilterTypes({dynamicDomainFilters, cpuFilters, filterFuncs}, allData) {
+export function filterDataByFilterTypes({dynamicDomainFilters, cpuFilters, filterFuncs}, allData) {
const result = {
...(dynamicDomainFilters ? {filteredIndexForDomain: []} : {}),
...(cpuFilters ? {filteredIndex: []} : {})
@@ -529,12 +528,14 @@ function filterDataByFilterTypes({dynamicDomainFilters, cpuFilters, filterFuncs}
dynamicDomainFilters && dynamicDomainFilters.every(filter => filterFuncs[filter.id](d, i));
if (matchForDomain) {
+ // @ts-ignore
result.filteredIndexForDomain.push(i);
}
const matchForRender = cpuFilters && cpuFilters.every(filter => filterFuncs[filter.id](d, i));
if (matchForRender) {
+ // @ts-ignore
result.filteredIndex.push(i);
}
}
@@ -544,13 +545,12 @@ function filterDataByFilterTypes({dynamicDomainFilters, cpuFilters, filterFuncs}
/**
* Get a record of filters based on domain type and gpu / cpu
- * @param {string} dataId
- * @param {Array<Object>} filters
- * @param {Object} opt.cpuOnly only allow cpu filtering
- * @param {Object} opt.ignoreDomain ignore filter for domain calculation
- * @returns {{dynamicDomain: Array, fixedDomain: Array, cpu: Array, gpu: Array}} filterRecord
+ * @type {typeof import('./filter-utils').getFilterRecord}
*/
export function getFilterRecord(dataId, filters, opt = {}) {
+ /**
+ * @type {FilterRecord}
+ */
const filterRecord = {
dynamicDomain: [],
fixedDomain: [],
@@ -574,9 +574,7 @@ export function getFilterRecord(dataId, filters, opt = {}) {
/**
* Compare filter records to get what has changed
- * @param {Object} filterRecord
- * @param {Object} oldFilterRecord
- * @returns {{dynamicDomain: Object, fixedDomain: Object, cpu: Object, gpu: Object}} changed filters based on type
+ * @type {typeof import('./filter-utils').diffFilters}
*/
export function diffFilters(filterRecord, oldFilterRecord = {}) {
let filterChanged = {};
@@ -610,6 +608,7 @@ export function diffFilters(filterRecord, oldFilterRecord = {}) {
}
});
+ // @ts-ignore
return filterChanged;
}
/**
@@ -617,10 +616,8 @@ export function diffFilters(filterRecord, oldFilterRecord = {}) {
* Check if value of filter within filter domain, if not adjust it to match
* filter domain
*
- * @param {Array<string> | string | Number | Array<Number>} value
- * @param {Array} filter.domain
- * @param {String} filter.type
- * @returns {*} - adjusted value to match filter or null to remove filter
+ * @type {typeof import('./filter-utils').adjustValueToFilterDomain}
+ * @returns value - adjusted value to match filter or null to remove filter
*/
/* eslint-disable complexity */
export function adjustValueToFilterDomain(value, {domain, type}) {
@@ -656,9 +653,7 @@ export function adjustValueToFilterDomain(value, {domain, type}) {
/**
* Calculate numeric domain and suitable step
*
- * @param {Object[]} data
- * @param {function} valueAccessor
- * @returns {object} domain and step
+ * @type {typeof import('./filter-utils').getNumericFieldDomain}
*/
export function getNumericFieldDomain(data, valueAccessor) {
let domain = [0, 1];
@@ -680,11 +675,17 @@ export function getNumericFieldDomain(data, valueAccessor) {
domain[1] = formatNumberByStep(domain[1], step, 'ceil');
}
+ // @ts-ignore
const {histogram, enlargedHistogram} = getHistogram(domain, mappedValue);
return {domain, step, histogram, enlargedHistogram};
}
+/**
+ * Calculate step size for range and timerange filter
+ *
+ * @type {typeof import('./filter-utils').getNumericStepSize}
+ */
export function getNumericStepSize(diff) {
diff = Math.abs(diff);
@@ -694,37 +695,27 @@ export function getNumericStepSize(diff) {
return 0.01;
} else if (diff > 1) {
return 0.001;
- } else if (diff <= 1) {
- // Try to get at least 1000 steps - and keep the step size below that of
- // the (diff > 1) case.
- const x = diff / 1000;
- // Find the exponent and truncate to 10 to the power of that exponent
-
- const exponentialForm = x.toExponential();
- const exponent = parseFloat(exponentialForm.split('e')[1]);
-
- // Getting ready for node 12
- // this is why we need decimal.js
- // Math.pow(10, -5) = 0.000009999999999999999
- // the above result shows in browser and node 10
- // node 12 behaves correctly
-
- return new Decimal(10).pow(exponent).toNumber();
}
+ // Try to get at least 1000 steps - and keep the step size below that of
+ // the (diff > 1) case.
+ const x = diff / 1000;
+ // Find the exponent and truncate to 10 to the power of that exponent
+
+ const exponentialForm = x.toExponential();
+ const exponent = parseFloat(exponentialForm.split('e')[1]);
+
+ // Getting ready for node 12
+ // this is why we need decimal.js
+ // Math.pow(10, -5) = 0.000009999999999999999
+ // the above result shows in browser and node 10
+ // node 12 behaves correctly
+ return new Decimal(10).pow(exponent).toNumber();
}
/**
* Calculate timestamp domain and suitable step
*
- * @param {Array<Array>} data
- * @param {Function} valueAccessor
- * @returns {{
- * domain: Array<Number>,
- * step: Number,
- * mappedValue: Array<Number>,
- * histogram: Array<Object>,
- * enlargedHistogram: Array<Object>
- * }} timestamp field domain
+ * @type {typeof import('./filter-utils').getTimestampFieldDomain}
*/
export function getTimestampFieldDomain(data, valueAccessor) {
// to avoid converting string format time to epoch
@@ -747,10 +738,7 @@ export function getTimestampFieldDomain(data, valueAccessor) {
/**
*
- * @param {Array<Number>} domain
- * @param {Array<Number>} mappedValue
- * @param {Number} bins
- * @returns {Array<{count: Number, x0: Number, x1: number}>} histogram
+ * @type {typeof import('./filter-utils').histogramConstruct}
*/
export function histogramConstruct(domain, mappedValue, bins) {
return d3Histogram()
@@ -765,9 +753,7 @@ export function histogramConstruct(domain, mappedValue, bins) {
/**
* Calculate histogram from domain and array of values
*
- * @param {Array<Number>} domain
- * @param {Array<Object>} mappedValue
- * @returns {{histogram: Array<Object>, enlargedHistogram: Array<Object>}} 2 sets of histogram
+ * @type {typeof import('./filter-utils').getHistogram}
*/
export function getHistogram(domain, mappedValue) {
const histogram = histogramConstruct(domain, mappedValue, histogramBins);
@@ -792,6 +778,10 @@ export function formatNumberByStep(val, step, bound) {
return Math.ceil(val * (1 / step)) / (1 / step);
}
+/**
+ *
+ * @type {typeof import('./filter-utils').isInRange}
+ */
export function isInRange(val, domain) {
if (!Array.isArray(domain)) {
return false;
@@ -843,9 +833,7 @@ export function getTimeWidgetHintFormatter(domain) {
/**
* Sanity check on filters to prepare for save
- * @param {String} type - filter type
- * @param {*} value - filter value
- * @returns {boolean} whether filter is value
+ * @type {typeof import('./filter-utils').isValidFilterValue}
*/
/* eslint-disable complexity */
export function isValidFilterValue(type, value) {
@@ -875,13 +863,17 @@ export function isValidFilterValue(type, value) {
}
}
+/**
+ *
+ * @type {typeof import('./filter-utils').getFilterPlot}
+ */
export function getFilterPlot(filter, allData) {
if (filter.plotType === PLOT_TYPES.histogram || !filter.yAxis) {
// histogram should be calculated when create filter
return {};
}
- const {mappedValue} = filter;
+ const {mappedValue = []} = filter;
const {yAxis} = filter;
// return lineChart
@@ -917,7 +909,8 @@ export function getDefaultFilterPlotType(filter) {
* @param datasetIds list of dataset ids to be filtered
* @param datasets all datasets
* @param filters all filters to be applied to datasets
- * @return {{[datasetId: string]: Object}} datasets - new updated datasets
+ * @return datasets - new updated datasets
+ * @type {typeof import('./filter-utils').applyFiltersToDatasets}
*/
export function applyFiltersToDatasets(datasetIds, datasets, filters, layers) {
const dataIds = toArray(datasetIds);
@@ -927,29 +920,24 @@ export function applyFiltersToDatasets(datasetIds, datasets, filters, layers) {
return {
...acc,
- [dataId]: filterDataset(datasets[dataId], appliedFilters, layersToFilter)
+ [dataId]: filterDataset(datasets[dataId], appliedFilters, layersToFilter, {})
};
}, datasets);
}
/**
* Applies a new field name value to fielter and update both filter and dataset
- * @param {Object} filter - to be applied the new field name on
- * @param {Object} dataset - dataset the field belongs to
- * @param {string} fieldName - field.name
- * @param {Number} filterDatasetIndex - field.name
- * @param {Number} filters - current
- * @param {Object} option
- * @return {Object} {filter, datasets}
+ * @param filter - to be applied the new field name on
+ * @param dataset - dataset the field belongs to
+ * @param fieldName - field.name
+ * @param filterDatasetIndex - field.name
+ * @param option
+ * @return - {filter, datasets}
+ * @type {typeof import('./filter-utils').applyFilterFieldName}
*/
-export function applyFilterFieldName(
- filter,
- dataset,
- fieldName,
- filterDatasetIndex = 0,
- {mergeDomain = false} = {}
-) {
+export function applyFilterFieldName(filter, dataset, fieldName, filterDatasetIndex = 0, option) {
// using filterDatasetIndex we can filter only the specified dataset
+ const mergeDomain = option && option.hasOwnProperty('mergeDomain') ? option.mergeDomain : false;
const {fields, allData} = dataset;
const fieldIndex = fields.findIndex(f => f.name === fieldName);
@@ -967,8 +955,8 @@ export function applyFilterFieldName(
const newFilter = {
...(mergeDomain ? mergeFilterDomainStep(filter, filterProps) : {...filter, ...filterProps}),
- name: Object.assign([].concat(filter.name), {[filterDatasetIndex]: field.name}),
- fieldIdx: Object.assign([].concat(filter.fieldIdx), {
+ name: Object.assign([...toArray(filter.name)], {[filterDatasetIndex]: field.name}),
+ fieldIdx: Object.assign([...toArray(filter.fieldIdx)], {
[filterDatasetIndex]: field.tableFieldIndex - 1
}),
// TODO, since we allow to add multiple fields to a filter we can no longer freeze the filter
@@ -980,7 +968,7 @@ export function applyFilterFieldName(
filterProps
};
- const newFields = Object.assign([].concat(fields), {[fieldIndex]: fieldWithFilterProps});
+ const newFields = Object.assign([...fields], {[fieldIndex]: fieldWithFilterProps});
return {
filter: newFilter,
@@ -993,11 +981,7 @@ export function applyFilterFieldName(
/**
* Merge one filter with other filter prop domain
- * @param filter
- * @param filterProps
- * @param fieldIndex
- * @param datasetIndex
- * @return {*}
+ * @type {typeof import('./filter-utils').mergeFilterDomainStep}
*/
/* eslint-disable complexity */
export function mergeFilterDomainStep(filter, filterProps) {
@@ -1032,6 +1016,7 @@ export function mergeFilterDomainStep(filter, filterProps) {
};
case ALL_FIELD_TYPES.timestamp:
+ // @ts-ignore
const step = filter.step < filterProps.step ? filter.step : filterProps.step;
return {
@@ -1046,6 +1031,10 @@ export function mergeFilterDomainStep(filter, filterProps) {
}
/* eslint-enable complexity */
+/**
+ * Generates polygon filter
+ * @type {typeof import('./filter-utils').featureToFilterValue}
+ */
export const featureToFilterValue = (feature, filterId, properties = {}) => ({
...feature,
id: feature.id,
@@ -1056,29 +1045,20 @@ export const featureToFilterValue = (feature, filterId, properties = {}) => ({
}
});
+/**
+ * @type {typeof import('./filter-utils').getFilterIdInFeature}
+ */
export const getFilterIdInFeature = f => get(f, ['properties', 'filterId']);
/**
* Generates polygon filter
- * @param layers array of layers
- * @param feature polygon to use
- * @return {object} filter
+ * @type {typeof import('./filter-utils').generatePolygonFilter}
*/
export function generatePolygonFilter(layers, feature) {
- const {dataId, layerId, name} = layers.reduce(
- (acc, layer) => ({
- ...acc,
- dataId: [...acc.dataId, layer.config.dataId],
- layerId: [...acc.layerId, layer.id],
- name: [...acc.name, layer.config.label]
- }),
- {
- dataId: [],
- layerId: [],
- name: []
- }
- );
-
+ const dataId = layers.map(l => l.config.dataId).filter(d => d);
+ const layerId = layers.map(l => l.id);
+ const name = layers.map(l => l.config.label);
+ // @ts-ignore
const filter = getDefaultFilter(dataId);
return {
...filter,
@@ -1092,9 +1072,7 @@ export function generatePolygonFilter(layers, feature) {
/**
* Run filter entirely on CPU
- * @param {Object} state - visState
- * @param {string} dataId
- * @return {Object} state state with updated datasets
+ * @type {typeof import('./filter-utils').filterDatasetCPU}
*/
export function filterDatasetCPU(state, dataId) {
const datasetFilters = state.filters.filter(f => f.dataId.includes(dataId));
@@ -1134,7 +1112,7 @@ export function filterDatasetCPU(state, dataId) {
const copied = {
...selectedDataset,
filterRecord: selectedDataset.filterRecordCPU,
- filteredIndex: selectedDataset.filteredIdxCPU
+ filteredIndex: selectedDataset.filteredIdxCPU || []
};
const filtered = filterDataset(copied, state.filters, state.layers, opt);
diff --git a/src/utils/gpu-filter-utils.d.ts b/src/utils/gpu-filter-utils.d.ts
new file mode 100644
index 000000000..1c4cc3c15
--- /dev/null
+++ b/src/utils/gpu-filter-utils.d.ts
@@ -0,0 +1,28 @@
+// Copyright (c) 2020 Uber Technologies, Inc.
+//
+// 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.
+
+import {Filter, Field, GpuFilter} from 'reducers/vis-state-updaters';
+
+export function setFilterGpuMode(filter: Filter, filters: Filter[]): Filter;
+export function assignGpuChannel(filter: Filter, filters: Filter[]): Filter;
+export function assignGpuChannels(allFilters: Filter[]): Filter[];
+export function resetFilterGpuMode( filters: Filter[]): Filter[];
+export function getGpuFilterProps(filters: Filter[], dataId: string, fields: Field[]): GpuFilter;
+export function getDatasetFieldIndexForFilter(dataId: string, filter: Filter): number;
diff --git a/src/utils/gpu-filter-utils.js b/src/utils/gpu-filter-utils.js
index 28b208cb9..a3fa2e385 100644
--- a/src/utils/gpu-filter-utils.js
+++ b/src/utils/gpu-filter-utils.js
@@ -25,8 +25,7 @@ import moment from 'moment';
/**
* Set gpu mode based on current number of gpu filters exists
- * @param {Object} gpuFilter
- * @param {Array<Object>} filters
+ * @type {typeof import('./gpu-filter-utils').setFilterGpuMode}
*/
export function setFilterGpuMode(filter, filters) {
// filter can be apply to multiple dataset, hence gpu filter mode should also be
@@ -45,6 +44,10 @@ export function setFilterGpuMode(filter, filters) {
return filter;
}
+/**
+ * Scan though all filters and assign gpu chanel to gpu filter
+ * @type {typeof import('./gpu-filter-utils').assignGpuChannels}
+ */
export function assignGpuChannels(allFilters) {
return allFilters.reduce((accu, f, index) => {
let filters = accu;
@@ -60,8 +63,7 @@ export function assignGpuChannels(allFilters) {
}
/**
* Assign a new gpu filter a channel based on first availability
- * @param {Object} filter
- * @param {Array<Object>} filters
+ * @type {typeof import('./gpu-filter-utils').assignGpuChannel}
*/
export function assignGpuChannel(filter, filters) {
// find first available channel
@@ -115,8 +117,7 @@ export function assignGpuChannel(filter, filters) {
/**
* Edit filter.gpu to ensure that only
* X number of gpu filers can coexist.
- * @param {Array<Object>} filters
- * @returns {Array<Object>} updated filters
+ * @type {typeof import('./gpu-filter-utils').resetFilterGpuMode}
*/
export function resetFilterGpuMode(filters) {
const gpuPerDataset = {};
@@ -185,9 +186,7 @@ const getFilterValueAccessor = (channels, dataId, fields) => (
/**
* Get filter properties for gpu filtering
- * @param {Array<Object>} filters
- * @param {string} dataId
- * @returns {{filterRange: {Object}, filterValueUpdateTriggers: Object, getFilterValue: Function}}
+ * @type {typeof import('./gpu-filter-utils').getGpuFilterProps}
*/
export function getGpuFilterProps(filters, dataId, fields) {
const filterRange = getEmptyFilterRange();
@@ -198,10 +197,16 @@ export function getGpuFilterProps(filters, dataId, fields) {
for (let i = 0; i < MAX_GPU_FILTERS; i++) {
const filter = filters.find(
- f => f.gpu && f.dataId.includes(dataId) && f.gpuChannel[f.dataId.indexOf(dataId)] === i
+ f =>
+ f.gpu &&
+ f.dataId.includes(dataId) &&
+ f.gpuChannel &&
+ f.gpuChannel[f.dataId.indexOf(dataId)] === i
);
+ // @ts-ignore
filterRange[i][0] = filter ? filter.value[0] - filter.domain[0] : 0;
+ // @ts-ignore
filterRange[i][1] = filter ? filter.value[1] - filter.domain[0] : 0;
triggers[`gpuFilter_${i}`] = filter ? filter.name[filter.dataId.indexOf(dataId)] : null;
@@ -220,9 +225,7 @@ export function getGpuFilterProps(filters, dataId, fields) {
/**
* Return dataset field index from filter.fieldIdx
* The index matches the same dataset index for filter.dataId
- * @param dataset
- * @param filter
- * @return {*}
+ * @type {typeof import('./gpu-filter-utils').getDatasetFieldIndexForFilter}
*/
export function getDatasetFieldIndexForFilter(dataId, filter) {
const datasetIndex = toArray(filter.dataId).indexOf(dataId);
diff --git a/src/utils/interaction-utils.d.ts b/src/utils/interaction-utils.d.ts
new file mode 100644
index 000000000..d7fceb469
--- /dev/null
+++ b/src/utils/interaction-utils.d.ts
@@ -0,0 +1,6 @@
+import {InteractionConfig, Field} from '../reducers/vis-state-updaters'
+
+export function getDefaultInteraction(): InteractionConfig;
+export function findFieldsToShow(p: {fields: Field[], id: string}): {
+ [key: string]: string[]
+}
diff --git a/src/utils/interaction-utils.js b/src/utils/interaction-utils.js
index 57382b15f..217007141 100644
--- a/src/utils/interaction-utils.js
+++ b/src/utils/interaction-utils.js
@@ -26,6 +26,9 @@ import {
} from 'constants/default-settings';
import {Messages, Crosshairs, CursorClick, Pin} from 'components/common/icons/index';
+/**
+ * @type {typeof import('./interaction-utils').getDefaultInteraction}
+ */
export function getDefaultInteraction() {
return {
tooltip: {
@@ -68,6 +71,9 @@ export const BRUSH_CONFIG = {
range: [0, 50]
};
+/**
+ * @type {typeof import('./interaction-utils').findFieldsToShow}
+ */
export function findFieldsToShow({fields, id}) {
// first find default tooltip fields for trips
const fieldsToShow = DEFAULT_TOOLTIP_FIELDS.reduce((prev, curr) => {
diff --git a/src/utils/layer-utils/layer-utils.d.ts b/src/utils/layer-utils/layer-utils.d.ts
new file mode 100644
index 000000000..cf77a9b4d
--- /dev/null
+++ b/src/utils/layer-utils/layer-utils.d.ts
@@ -0,0 +1,19 @@
+import {Layer, LayerClasses} from 'layers';
+import {VisState, Dataset} from 'reducers/vis-state-updaters';
+
+export function calculateLayerData(
+ layer: Layer,
+ state: VisState,
+ oldLayerData?: any
+): {
+ layerData: any;
+ layer: Layer;
+};
+type FoundLayerProp = {
+ type: string; dataId: string
+};
+
+export function findDefaultLayer(
+ dataset: Dataset,
+ layerClasses: LayerClasses
+): FoundLayerProp[]
\ No newline at end of file
diff --git a/src/utils/layer-utils/layer-utils.js b/src/utils/layer-utils/layer-utils.js
index bc034940a..8f31efb2a 100644
--- a/src/utils/layer-utils/layer-utils.js
+++ b/src/utils/layer-utils/layer-utils.js
@@ -20,10 +20,7 @@
/**
* Find default layers from fields
- *
- * @param {Object} dataset
- * @param {Object} layerClasses
- * @returns {Array} found layers
+ * @type {typeof import('./layer-utils').findDefaultLayer}
*/
export function findDefaultLayer(dataset, layerClasses = {}) {
if (!dataset) {
@@ -59,10 +56,7 @@ export function findDefaultLayer(dataset, layerClasses = {}) {
/**
* calculate layer data based on layer type, col Config,
* return updated layer if colorDomain, dataMap has changed
- * @param {Object} layer
- * @param {Object} state
- * @param {Object} oldLayerData
- * @returns {{layerData: Array<Object>, layer: Object | undefined}}
+ * @type {typeof import('./layer-utils').calculateLayerData}
*/
export function calculateLayerData(layer, state, oldLayerData) {
const {type} = layer;
diff --git a/src/utils/map-style-utils/mapbox-gl-style-editor.js b/src/utils/map-style-utils/mapbox-gl-style-editor.js
index 85214a0fc..ff90ffcfe 100644
--- a/src/utils/map-style-utils/mapbox-gl-style-editor.js
+++ b/src/utils/map-style-utils/mapbox-gl-style-editor.js
@@ -121,8 +121,8 @@ export function getStyleDownloadUrl(styleUrl, accessToken, mapboxApiUrl) {
* @param {string} param.mapboxApiAccessToken
* @param {string} param.mapboxApiUrl
* @param {Object} param.mapState
- * @param {numbers} param.mapW
- * @param {numbers} param.mapH
+ * @param {number} param.mapW
+ * @param {number} param.mapH
*/
export function getStyleImageIcon({
styleUrl,
@@ -149,6 +149,7 @@ export function getStyleImageIcon({
export function scaleMapStyleByResolution(mapboxStyle, scale) {
if (scale !== 1 && mapboxStyle) {
const labelLayerGroup = DEFAULT_LAYER_GROUPS.find(lg => lg.slug === 'label');
+ // @ts-ignore
const {filter: labelLayerFilter} = labelLayerGroup;
const zoomOffset = Math.log2(scale);
diff --git a/src/utils/notifications-utils.js b/src/utils/notifications-utils.js
index 27cdb550d..ed1f13926 100644
--- a/src/utils/notifications-utils.js
+++ b/src/utils/notifications-utils.js
@@ -31,11 +31,12 @@ import {BUG_REPORT_LINK} from 'constants/user-guides';
/**
* Creates a notofication
- * @param {string} message - Message to display during the notification
- * @param {string} [type] - The type of message. One of DEFAULT_NOTIFICATION_TYPES
- * @param {string} [topic] - The topic the notification belongs to. One of DEFAULT_NOTIFICATION_TOPICS
- * @param {string} [id] optional id for notification. If not provided it will be generated by the method
- * @param {object} [options] - Extra parameters to store as part of hte notification
+ * @param {object} opt
+ * @param {string} opt.message - Message to display during the notification
+ * @param {string} opt.type - The type of message. One of DEFAULT_NOTIFICATION_TYPES
+ * @param {string} opt.topic - The topic the notification belongs to. One of DEFAULT_NOTIFICATION_TOPICS
+ * @param {string} opt.id optional id for notification. If not provided it will be generated by the method
+ * @param {object} opt.options - Extra parameters to store as part of hte notification
* @returns {object}
*/
export function createNotification({
diff --git a/src/utils/split-map-utils.js b/src/utils/split-map-utils.js
index 2d8726acc..82acc1a59 100644
--- a/src/utils/split-map-utils.js
+++ b/src/utils/split-map-utils.js
@@ -41,6 +41,7 @@ export function addNewLayersToSplitMap(splitMaps, layers) {
...settings.layers,
...newLayers.reduce(
(accu, newLayer) =>
+ // @ts-ignore
[newLayer.id] in settings.layers || !newLayer.config.isVisible
? accu
: {
diff --git a/src/utils/utils.js b/src/utils/utils.js
index a872c1493..11b02308f 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-ignore
import window from 'global/window';
/**
@@ -143,6 +144,7 @@ const setPath = ([key, ...next], value, obj) => {
return insertValue(obj, key, value);
}
+ // @ts-ignore
return insertValue(obj, key, setPath(next, value, obj.hasOwnProperty(key) ? obj[key] : {}));
};
@@ -153,6 +155,7 @@ const setPath = ([key, ...next], value, obj) => {
* @param {Object} obj
* @returns {Object}
*/
+// @ts-ignore
export const set = (path, value, obj) => (obj === null ? obj : setPath(path, value, obj));
/**
@@ -183,5 +186,6 @@ export function getError(err) {
: JSON.stringify(err);
}
+ // @ts-ignore
return null;
}
diff --git a/test/browser/components/geocoder-panel-test.js b/test/browser/components/geocoder-panel-test.js
index be84324b4..27bc1cc83 100644
--- a/test/browser/components/geocoder-panel-test.js
+++ b/test/browser/components/geocoder-panel-test.js
@@ -139,7 +139,7 @@ test('GeocoderPanel - render', t => {
instance.onSelected(null, mockGeoItem);
t.deepEqual(
dispatch.getCall(0).args,
- [{type: '@@kepler.gl/REMOVE_DATASET', key: 'geocoder_dataset'}],
+ [{type: '@@kepler.gl/REMOVE_DATASET', dataId: 'geocoder_dataset'}],
'Should be dispatching removeDataset action on onSelected'
);
t.deepEqual(
@@ -163,14 +163,14 @@ test('GeocoderPanel - render', t => {
instance.removeMarker();
t.deepEqual(
dispatch.getCall(6).args,
- [{type: '@@kepler.gl/REMOVE_DATASET', key: 'geocoder_dataset'}],
+ [{type: '@@kepler.gl/REMOVE_DATASET', dataId: 'geocoder_dataset'}],
'Should be dispatching removeDataset action on removeMarker'
);
instance.removeGeocoderDataset();
t.deepEqual(
dispatch.getCall(7).args,
- [{type: '@@kepler.gl/REMOVE_DATASET', key: 'geocoder_dataset'}],
+ [{type: '@@kepler.gl/REMOVE_DATASET', dataId: 'geocoder_dataset'}],
'Should be dispatching removeDataset action on removeGeocoderDataset'
);
diff --git a/test/node/reducers/provider-state-test.js b/test/node/reducers/provider-state-test.js
index 1018e1dd4..efd3311cb 100644
--- a/test/node/reducers/provider-state-test.js
+++ b/test/node/reducers/provider-state-test.js
@@ -102,7 +102,8 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD', t => {
currentProvider: 'taro',
successInfo: {},
initialState: {},
- mapSaved: null
+ mapSaved: null,
+ visualizations: []
},
'Should set isProviderLoading and current provider'
);
@@ -134,7 +135,8 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD', t => {
currentProvider: 'taro',
initialState: {},
mapSaved: 'taro',
- successInfo: {url: 'taro_and_blue'}
+ successInfo: {url: 'taro_and_blue'},
+ visualizations: []
},
'Should set isProviderLoading to false and successInfo, mapSaved to taro'
);
@@ -152,7 +154,8 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD', t => {
currentProvider: 'taro',
initialState: {},
mapSaved: null,
- successInfo: {}
+ successInfo: {},
+ visualizations: []
},
'Should set isLoading to false and error'
);
@@ -238,7 +241,8 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t =
currentProvider: 'taro',
mapSaved: 'taro',
initialState: {},
- successInfo: {url: 'taro_and_blue'}
+ successInfo: {url: 'taro_and_blue'},
+ visualizations: []
},
'Should set isProviderLoading to false and successInfo'
);
@@ -267,7 +271,8 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t =
mapSaved: 'taro',
initialState: {},
successInfo: {url: 'taro_and_blue'},
- modalId: null
+ modalId: null,
+ visualizations: []
},
'Should call toggleModal(null'
);
@@ -283,7 +288,8 @@ test('#providerStateReducer -> EXPORT_FILE_TO_CLOUD -> onSuccess : onError', t =
mapSaved: 'taro',
initialState: {},
successInfo: {},
- modalId: null
+ modalId: null,
+ visualizations: []
},
'Should call resetProviderStatus'
);
@@ -324,7 +330,8 @@ test('#providerStateReducer -> RESET_PROVIDER_STATUS', t => {
currentProvider: 'taro',
successInfo: {},
initialState: {},
- mapSaved: null
+ mapSaved: null,
+ visualizations: []
},
'Should resetProviderStatus'
);
@@ -343,7 +350,8 @@ test('#providerStateReducer -> SET_CLOUD_PROVIDER', t => {
currentProvider: 'blue',
successInfo: {},
mapSaved: null,
- initialState: {}
+ initialState: {},
+ visualizations: []
},
'Should setCloudProvider'
);
diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.js
index fd25b1a4a..b315011cc 100644
--- a/test/node/reducers/vis-state-test.js
+++ b/test/node/reducers/vis-state-test.js
@@ -26,7 +26,7 @@ import * as VisStateActions from 'actions/vis-state-actions';
import * as MapStateActions from 'actions/map-state-actions';
import reducer from 'reducers/vis-state';
-import {INITIAL_VIS_STATE, defaultAnimationConfig} from 'reducers/vis-state-updaters';
+import {INITIAL_VIS_STATE, DEFAULT_ANIMATION_CONFIG} from 'reducers/vis-state-updaters';
import {getDefaultInteraction} from 'utils/interaction-utils';
import {getDefaultFilter} from 'utils/filter-utils';
@@ -474,7 +474,7 @@ test('#visStateReducer -> LAYER_TYPE_CHANGE.3 -> animationConfig', t => {
t.deepEqual(
nextState.animationConfig,
{
- ...defaultAnimationConfig,
+ ...DEFAULT_ANIMATION_CONFIG,
domain: timeStampDomain,
currentTime: timeStampDomain[0]
},
@@ -495,7 +495,7 @@ test('#visStateReducer -> LAYER_TYPE_CHANGE.3 -> animationConfig', t => {
t.deepEqual(
nextState2.animationConfig,
- defaultAnimationConfig,
+ DEFAULT_ANIMATION_CONFIG,
'should set animationConfig to default'
);
@@ -514,7 +514,7 @@ test('#visStateReducer -> LAYER_CONFIG_CHANGE -> isVisible -> animationConfig',
t.deepEqual(
nextState.animationConfig,
- defaultAnimationConfig,
+ DEFAULT_ANIMATION_CONFIG,
'should set animationConfig to default'
);
@@ -836,7 +836,7 @@ test('#visStateReducer -> REMOVE_LAYER', t => {
picked: true
},
splitMaps: [],
- animationConfig: defaultAnimationConfig
+ animationConfig: DEFAULT_ANIMATION_CONFIG
};
const newReducer = reducer(oldState, VisStateActions.removeLayer(1));
@@ -853,7 +853,7 @@ test('#visStateReducer -> REMOVE_LAYER', t => {
picked: true
},
splitMaps: [],
- animationConfig: defaultAnimationConfig
+ animationConfig: DEFAULT_ANIMATION_CONFIG
},
'should remove layer and layerData'
);
@@ -2519,7 +2519,7 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_LAYER', t => {
}
}
],
- animationConfig: defaultAnimationConfig
+ animationConfig: DEFAULT_ANIMATION_CONFIG
};
const newReducer = reducer(oldState, VisStateActions.removeLayer(1));
@@ -2547,7 +2547,7 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_LAYER', t => {
}
}
],
- animationConfig: defaultAnimationConfig
+ animationConfig: DEFAULT_ANIMATION_CONFIG
},
'should remove layer and layerData in split mode'
);
@@ -2603,7 +2603,7 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_LAYER', t => {
const newReducer3 = reducer(newReducer2, VisStateActions.removeLayer(2));
t.deepEqual(
newReducer3.animationConfig,
- defaultAnimationConfig,
+ DEFAULT_ANIMATION_CONFIG,
'remove last animation layer and set animation config to default'
);
@@ -2650,7 +2650,7 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_DATASET', t => {
clicked: oldState.clicked,
mousePos: oldState.mousePos,
layerClasses: oldState.layerClasses,
- animationConfig: defaultAnimationConfig,
+ animationConfig: DEFAULT_ANIMATION_CONFIG,
initialState: [],
layerToBeMerged: [],
filterToBeMerged: [],
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 000000000..755941485
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,43 @@
+{
+ "compilerOptions": {
+ "target": "es2020",
+ "allowJs": true,
+ "checkJs": true,
+ "jsx": "react",
+ "noEmit": true,
+ "module": "esnext",
+ "moduleResolution": "node",
+ "noImplicitAny": false,
+ "noImplicitReturns": true,
+ "noImplicitThis": true,
+ "noUnusedLocals": true,
+ "outDir": "build/dist",
+ "sourceMap": true,
+ "strictNullChecks": true,
+ "suppressImplicitAnyIndexErrors": true,
+ "esModuleInterop": true,
+ "allowSyntheticDefaultImports": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "baseUrl": "./src"
+ },
+ "include": [
+ "src/actions",
+ "src/cloud-providers",
+ "src/processors",
+ "src/reducers",
+ "src/schemas",
+ "src/utils",
+
+ // TODO: add types
+ // "src/components",
+ // "src/constants",
+ // "src/deckgl-layers",
+ // "src/layers"
+ // "src/localization",
+ // "src/middleware",
+ // "src/tasks"
+ ]
+}
diff --git a/typedoc/README.md b/typedoc/README.md
new file mode 100644
index 000000000..9888f9494
--- /dev/null
+++ b/typedoc/README.md
@@ -0,0 +1,656 @@
+[kepler.gl](README.md) › [Globals](globals.md)
+
+# kepler.gl
+
+<p align="right">
+ <a href="https://npmjs.org/package/kepler.gl">
+ <img src="https://img.shields.io/npm/v/kepler.gl.svg?style=flat" alt="version" />
+ </a>
+ <a href="https://travis-ci.com/keplergl/kepler.gl">
+ <img src="https://api.travis-ci.com/keplergl/kepler.gl.svg?branch=master" alt="build" />
+ </a>
+ <a href="https://github.com/keplergl/kepler.gl">
+ <img src="https://img.shields.io/github/stars/keplergl/kepler.gl.svg?style=flat" alt="stars" />
+ </a>
+ <a href='https://opensource.org/licenses/MIT'>
+ <img src='https://img.shields.io/badge/License-MIT-blue.svg' alt='MIT License' />
+ </a>
+ <a href='https://app.fossa.com/projects/custom%2B4458%2Fgithub.com%2Fkeplergl%2Fkepler.gl?ref=badge_shield'>
+ <img src='https://app.fossa.com/api/projects/custom%2B4458%2Fgithub.com%2Fkeplergl%2Fkepler.gl.svg?type=shield' alt='Fossa' />
+ </a>
+ <a href="https://app.netlify.com/sites/keplergl/deploys" alt="Netlify Status">
+ <img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fdeveloper.oswaldlabs.com%2Fnetlify-status%2F0c9b895c-acd0-43fd-8af7-fe960181b686?style=flat" />
+ </a>
+</p>
+
+<h1 align="center">
+ kepler.gl | <a href="http://kepler.gl">Website</a> | <a href="http://kepler.gl/#/demo">Demo App</a> | <a href="https://docs.kepler.gl/">Docs</a>
+</h1>
+<h3></h3>
+
+[<img width="120" alt="Kepler.gl" src="https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/website/icons/kepler.gl-logo.png">](http://kepler.gl)
+
+[<img width="600" alt="Kepler.gl Demo" src="https://eng.uber.com/wp-content/uploads/2018/05/image4-3-768x493.png">](http://kepler.gl/#/demo)
+
+[Kepler.gl][web] is a data-agnostic, high-performance web-based application for visual exploration of large-scale geolocation data sets. Built on top of [Mapbox GL](https://www.mapbox.com) and [deck.gl](http://uber.github.io/deck.gl/#/), kepler.gl can render millions of points representing thousands of trips and perform spatial aggregations on the fly.
+
+Kepler.gl is also a React component that uses [Redux](https://redux.js.org/) to manage its state and data flow. It can be embedded into other React-Redux applications and is highly customizable. For information on how to embed kepler.gl in your app take a look at this step-by-step [tutorial][vis-academy] on vis.academy.
+
+## Links
+
+- [Website][web]
+- [Demo][demo-app]
+- [Examples][examples]
+- [Get Started][get-started]
+- [App User Guide][user-guide]
+- [Jupyter Widget User Guide][user-guide-jupyter]
+- [Tutorial][vis-academy]
+- [Stack Overflow][stack]
+- [Contribution Guidelines][contributing]
+- [Api Reference][api-reference]
+- [Roadmap][roadmap]
+
+## Env
+
+Use Node 10.15.0 or above, older node versions have not been supported/ tested.
+For best results, use [nvm](https://github.com/creationix/nvm) `nvm install`.
+
+## Install kepler.gl
+
+Install node (`> 10.15.0`), yarn, and project dependencies
+
+```sh
+npm install --save kepler.gl
+// or
+yarn add kepler.gl
+```
+
+kepler.gl is built upon [mapbox][mapbox]. You will need a [Mapbox Access Token][mapbox-token] to use it.
+
+If you don't use a module bundler, it's also fine. Kepler.gl npm package includes precompiled production UMD builds in the [umd folder](https://unpkg.com/kepler.gl/umd).
+You can add the script tag to your html file as it follows:
+
+```html
+<script src="https://unpkg.com/kepler.gl/umd/keplergl.min.js" />
+```
+
+or if you would like, you can load a specific version
+
+```html
+<script src="https://unpkg.com/[email protected]/umd/keplergl.min.js" />
+```
+
+## Develop kepler.gl
+
+Take a look at the [development guide][developers] to develop kepler.gl locally.
+
+## Basic Usage
+
+Here are the basic steps to import kepler.gl into your app. You also take a look at the examples folder. Each example in the folder can be installed and run locally.
+
+### 1. Mount reducer
+
+Kepler.gl uses Redux to manage its internal state, along with [react-palm][react-palm] middleware to handle side effects.
+
+You need to add `taskMiddleware` of `react-palm` to your store too. We are actively working on a solution where
+`react-palm` will not be required, however it is still a very lightweight side effects management tool that is easier to test than react-thunk.
+
+```js
+import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
+import keplerGlReducer from 'kepler.gl/reducers';
+import {enhanceReduxMiddleware} from 'kepler.gl/middleware';
+
+const initialState = {};
+const reducers = combineReducers({
+ // <-- mount kepler.gl reducer in your app
+ keplerGl: keplerGlReducer,
+
+ // Your other reducers here
+ app: appReducer
+});
+
+// using createStore
+export default createStore(
+ reducer,
+ initialState,
+ applyMiddleware(
+ enhanceReduxMiddleware([
+ /* Add other middlewares here */
+ ])
+ )
+);
+```
+
+Or if use enhancer:
+
+```js
+// using enhancers
+const initialState = {};
+const middlewares = enhanceReduxMiddleware([
+ // Add other middlewares here
+]);
+const enhancers = [applyMiddleware(...middlewares)];
+
+export default createStore(reducer, initialState, compose(...enhancers));
+```
+
+If you mount kepler.gl reducer in another address instead of `keplerGl`, or the kepler.gl reducer is not
+mounted at root of your state, you will need to specify the path to it when you mount the component
+with the `getState` prop.
+
+Read more about [Reducers][reducers].
+
+### 2. Mount Component
+
+```js
+import KeplerGl from 'kepler.gl';
+
+const Map = props => (
+ <KeplerGl
+ id="foo"
+ width={width}
+ mapboxApiAccessToken={token}
+ height={height}
+ />
+);
+```
+
+#### Props
+
+##### `id` (String, required)
+
+- Default: `map`
+
+The id of this KeplerGl instance. `id` is required if you have multiple
+KeplerGl instances in your app. It defines the prop name of the KeplerGl state that is
+stored in the KeplerGl reducer. For example, the state of the KeplerGl component with id `foo` is
+stored in `state.keplerGl.foo`.
+
+In case you create multiple kepler.gl instances using the same id, the kepler.gl state defined by the entry will be
+overridden by the latest instance and reset to a blank state.
+
+##### `mapboxApiAccessToken` (String, required)
+
+- Default: `undefined`
+
+You can create a free account at [mapbox][mapbox] and create a token at [www.mapbox.com/account/access-tokens][mapbox-token]
+
+##### `getState` (Function, optional)
+
+- Default: `state => state.keplerGl`
+
+The path to the root keplerGl state in your reducer.
+
+##### `width` (Number, optional)
+
+- Default: `800`
+
+Width of the KeplerGl UI.
+
+##### `height` (Number, optional)
+
+- Default: `800`
+
+##### `appName` (String, optional)
+
+- Default: `Kepler.Gl`
+
+App name displayed in side panel header
+
+##### `version` (String, optional)
+
+- Default: `v1.0`
+
+version displayed in side panel header
+
+##### `onSaveMap` (Function, optional)
+
+- Default: `undefined`
+
+Action called when click Save Map Url in side panel header.
+
+##### `onViewStateChange` (Function, optional)
+
+- Default: `undefined`
+- Parameter: `viewState` - An updated view state object containing parameters such as longitude, latitude, zoom etc
+
+Action triggered when map viewport is updated.
+
+##### `getMapboxRef(mapbox, index)` (Function, optional)
+
+- Default: `undefined`
+
+Function called when `KeplerGL` adds or removes a `MapContainer` component having an inner Mapbox map.
+
+The `mapbox` argument is an [`InteractiveMap`](https://uber.github.io/react-map-gl/#/Documentation/api-reference/interactive-map) when added or `null` when removed.
+
+The `index` argument is 0 for a single map or 1 for an additional map (since `KeplerGL` supports an optional split map view).
+
+##### `actions` (Object, optional)
+
+- Default: `{}`
+
+Actions creators to replace default kepler.gl action creator. Only use custom action when you want to modify action payload.
+
+##### `mint` (Boolean, optional)
+
+- Default: `true`
+
+Whether to load a fresh empty state when component is mounted. when parse `mint: true` kepler.gl component will always load a fresh state when re-mount the same component, state inside this component will be destroyed once its unmounted.
+By Parsing `mint: false` kepler.gl will keep the component state in the store even when it is unmounted, and use it as initial state when re-mounted again. This is useful when mounting kepler.gl in a modal, and keep the same map when re-open.
+
+Read more about [Components][components].
+
+##### `theme` (Object | String, optional)
+
+- default: `null`
+
+One of `"dark"`, `"light"` or `"base"`
+You can pass theme name or object used to customize Kepler.gl style. Kepler.gl provide an `'light'` theme besides the default 'dark' theme. When pass in a theme object Kepler.gl will use the value passed as input to override values from [theme](https://github.com/keplergl/kepler.gl/blob/master/src/styles/base.js).
+
+Read more about [Custom Theme][custom-theme]
+
+#### `mapboxApiUrl` (String, optional)
+
+- Default: `https://api.mapbox.com`
+
+If you are using your own mapbox tile server, you can pass in your own tile server api url.
+
+#### `mapStylesReplaceDefault` (Boolean, optional)
+
+- Default: `false`
+
+kepler.gl provide 4 map styles to choose from. Pass `true` if you want to supply your own `mapStyles`. See Below.
+
+#### `mapStyles` (Array, optional)
+
+- Default: `[]`
+
+You can supply additional map styles to be displayed in [map style selection panel](https://github.com/keplergl/kepler.gl/blob/master/docs/user-guides/f-map-styles/1-base-map-styles.md). By default, additional map styles will be added to default map styles. If pass `mapStylesReplaceDefault: true`, they will replace the default ones. kepler.gl will attempt to group layers of your style based on its `id` naming convention and use it to allow toggle visibility of [base map layers](https://github.com/keplergl/kepler.gl/blob/master/docs/user-guides/f-map-styles/2-map-layers.md). Supply your own `layerGroups` to override default for more accurate layer grouping.
+
+Each `mapStyles` should has the following properties:
+
+- `id` (String, required) unique string that should **not** be one of these reserved `dark` `light` `muted`. `muted_night`
+- `label` (String, required) name to be displayed in map style selection panel
+- `url` (String, required) mapbox style url or a url pointing to the map style json object
+- `icon` (String, optional) image icon of the style, it can be a url, or an [image data url](https://flaviocopes.com/data-urls/#how-does-a-data-url-look)
+- `layerGroups` (Array, optional)
+
+```js
+const mapStyles = [
+ {
+ id: 'my_dark_map',
+ label: 'Dark Streets 9',
+ url: 'mapbox://styles/mapbox/dark-v9',
+ icon: `${apiHost}/styles/v1/mapbox/dark-v9/static/-122.3391,37.7922,9.19,0,0/400x300?access_token=${accessToken}&logo=false&attribution=false`,
+ layerGroups: [
+ {
+ slug: 'label',
+ filter: ({id}) => id.match(/(?=(label|place-|poi-))/),
+ defaultVisibility: true
+ },
+ {
+ // adding this will keep the 3d building option
+ slug: '3d building',
+ filter: () => false,
+ defaultVisibility: false
+ }
+ ]
+ }
+];
+```
+
+### 3. Dispatch custom actions to `keplerGl` reducer.
+
+One advantage of using the reducer over React component state to handle keplerGl state is the flexibility
+to customize its behavior. If you only have one `KeplerGl` instance in your app or never intend to dispatch actions to KeplerGl from outside the component itself,
+you don’t need to worry about forwarding dispatch and can move on to the next section. But life is full of customizations, and we want to make yours as enjoyable as possible.
+
+There are multiple ways to dispatch actions to a specific `KeplerGl` instance.
+
+- In the root reducer, with reducer updaters.
+
+Each action is mapped to a reducer updater in kepler.gl. You can import the reducer updater corresponding to a specific action, and call it with the previous state and action payload to get the updated state.
+e.g. `updateVisDataUpdater` is the updater for `ActionTypes.UPDATE_VIS_DATA` (take a look at each reducer `reducers/vis-state.js` for action to updater mapping).
+Here is an example how you can listen to an app action `QUERY_SUCCESS` and call `updateVisDataUpdater` to load data into Kepler.Gl.
+
+```js
+import keplerGlReducer, {visStateUpdaters} from 'kepler.gl/reducers';
+
+// Root Reducer
+const reducers = combineReducers({
+ keplerGl: keplerGlReducer,
+
+ app: appReducer
+});
+
+const composedReducer = (state, action) => {
+ switch (action.type) {
+ case 'QUERY_SUCCESS':
+ return {
+ ...state,
+ keplerGl: {
+ ...state.keplerGl,
+
+ // 'map' is the id of the keplerGl instance
+ map: {
+ ...state.keplerGl.map,
+ visState: visStateUpdaters.updateVisDataUpdater(
+ state.keplerGl.map.visState,
+ {datasets: action.payload}
+ )
+ }
+ }
+ };
+ }
+ return reducers(state, action);
+};
+
+export default composedReducer;
+```
+
+Read more about [using updaters to modify kepler.gl state][using-updaters]
+
+- Using redux `connect`
+
+You can add a dispatch function to your component that dispatches actions to a specific `keplerGl` component,
+using connect.
+
+```js
+// component
+import KeplerGl from 'kepler.gl';
+
+// action and forward dispatcher
+import {toggleFullScreen, forwardTo} from 'kepler.gl/actions';
+import {connect} from 'react-redux';
+
+const MapContainer = props => (
+ <div>
+ <button onClick={() => props.keplerGlDispatch(toggleFullScreen())}/>
+ <KeplerGl
+ id="foo"
+ />
+ </div>
+)
+
+const mapStateToProps = state => state
+const mapDispatchToProps = (dispatch, props) => ({
+ dispatch,
+ keplerGlDispatch: forwardTo(‘foo’, dispatch)
+});
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(MapContainer);
+```
+
+- Wrap action payload
+
+You can also simply wrap an action into a forward action with the `wrapTo` helper
+
+```js
+// component
+import KeplerGl from 'kepler.gl';
+
+// action and forward dispatcher
+import {toggleFullScreen, wrapTo} from 'kepler.gl/actions';
+
+// create a function to wrapper action payload to 'foo'
+const wrapToMap = wrapTo('foo');
+const MapContainer = ({dispatch}) => (
+ <div>
+ <button onClick={() => dispatch(wrapToMap(toggleFullScreen())} />
+ <KeplerGl
+ id="foo"
+ />
+ </div>
+);
+
+```
+
+Read more about [forward dispatching actions][forward-actions]
+
+### 4. Customize style.
+
+Kepler.gl implements css styling using [Styled-Components](https://www.styled-components.com/). By using said framework Kepler.gl offers the ability to customize its style/theme using the following approaches:
+
+- Passing a Theme prop
+- Styled-Components ThemeProvider
+
+The available properties to customize are listed here [theme](https://github.com/keplergl/kepler.gl/blob/master/src/styles/base.js).
+
+[Custom theme example](https://github.com/keplergl/kepler.gl/tree/master/examples/custom-theme).
+
+#### Passing a Theme prop.
+
+You can customize Kepler.gl theme by passing a **theme** props to Kepler.gl react component as it follows:
+
+```javascript
+const white = '#ffffff';
+const customTheme = {
+ sidePanelBg: white,
+ titleTextColor: '#000000',
+ sidePanelHeaderBg: '#f7f7F7',
+ subtextColorActive: '#2473bd'
+};
+
+return (
+ <KeplerGl
+ mapboxApiAccessToken={MAPBOX_TOKEN}
+ id="map"
+ width={800}
+ height={800}
+ theme={customTheme}
+ />
+);
+```
+
+As you can see the customTheme object defines certain properties which will override Kepler.gl default style rules.
+
+#### Styled-Components Theme Provider.
+
+In order to customize Kepler.gl theme using [ThemeProvider](https://www.styled-components.com/docs/api#themeprovider) you can simply wrap Kepler.gl using ThemeProvider as it follows:
+
+```javascript
+import {ThemeProvider} from 'styled-components';
+
+const white = '#ffffff';
+const customTheme = {
+ sidePanelBg: white,
+ titleTextColor: '#000000',
+ sidePanelHeaderBg: '#f7f7F7',
+ subtextColorActive: '#2473bd'
+};
+
+return (
+ <ThemeProvider theme={customTheme}>
+ <KeplerGl
+ mapboxApiAccessToken={MAPBOX_TOKEN}
+ id="map"
+ width={800}
+ height={800}
+ />
+ </ThemeProvider>
+);
+```
+
+### 5. Render Custom UI components.
+
+Everyone wants the flexibility to render custom kepler.gl components. Kepler.gl has a dependency injection system that allow you to inject
+components to KeplerGl replacing existing ones. All you need to do is to create a component factory for the one you want to replace, import the original component factory
+and call `injectComponents` at the root component of your app where `KeplerGl` is mounted.
+Take a look at `examples/demo-app/src/app.js` and see how it renders a custom side panel header in kepler.gl
+
+```javascript
+import {injectComponents, PanelHeaderFactory} from 'kepler.gl/components';
+
+// define custom header
+const CustomHeader = () => <div>My kepler.gl app</div>;
+const myCustomHeaderFactory = () => CustomHeader;
+
+// Inject custom header into Kepler.gl, replacing default
+const KeplerGl = injectComponents([
+ [PanelHeaderFactory, myCustomHeaderFactory]
+]);
+
+// render KeplerGl, it will render your custom header instead of the default
+const MapContainer = () => (
+ <div>
+ <KeplerGl id="foo" />
+ </div>
+);
+```
+
+Using `withState` helper to add reducer state and actions to customized component as additional props.
+
+```js
+import {
+ withState,
+ injectComponents,
+ PanelHeaderFactory
+} from 'kepler.gl/components';
+import {visStateLens} from 'kepler.gl/reducers';
+
+// custom action wrap to mounted instance
+const addTodo = text =>
+ wrapTo('map', {
+ type: 'ADD_TODO',
+ text
+ });
+
+// define custom header
+const CustomHeader = ({visState, addTodo}) => (
+ <div onClick={() => addTodo('hello')}>{`${
+ Object.keys(visState.datasets).length
+ } dataset loaded`}</div>
+);
+
+// now CustomHeader will receive `visState` and `addTodo` as additional props.
+const myCustomHeaderFactory = () =>
+ withState(
+ // keplerGl state lenses
+ [visStateLens],
+ // customMapStateToProps
+ headerStateToProps,
+ // actions
+ {addTodo}
+ )(CustomHeader);
+```
+
+Read more about [replacing UI component][replace-ui-component]
+
+### 6. How to add data to map
+
+To interact with a kepler.gl instance and add new data to it, you can dispatch the **`addDataToMap`** action from anywhere inside your app. It adds a dataset or multiple datasets to a kepler.gl instance and updates the full configuration (mapState, mapStyle, visState).
+
+#### Parameters
+
+- `data` **[Object][40]** **\*required**
+ - `datasets` **([Array][41]&lt;[Object][40]> | [Object][40])** **\*required** datasets can be a dataset or an array of datasets
+ Each dataset object needs to have `info` and `data` property.
+ - `datasets.info` **[Object][40]** \-info of a dataset
+ - `datasets.info.id` **[string][42]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
+ - `datasets.info.label` **[string][42]** A display name of this dataset
+ - `datasets.data` **[Object][40]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
+ - `datasets.data.fields` **[Array][41]&lt;[Object][40]>** **\*required** Array of fields,
+ - `datasets.data.fields.name` **[string][42]** **\*required** Name of the field,
+ - `datasets.data.rows` **[Array][41]&lt;[Array][41]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
+ - `options` **[Object][40]**
+
+ - `options.centerMap` **[boolean][43]** `default: true` if `centerMap` is set to `true` kepler.gl will place the map view within the data points boundaries
+ - `options.readOnly` **[boolean][43]** `default: false` if `readOnly` is set to `true`
+ the left setting panel will be hidden
+ - `options.keepExistingConfig` **[boolean][43]** `default: false` whether to keep exiting map config, including layers, filters and splitMaps.
+
+- `config` **[Object][40]** this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
+
+Kepler.gl provides an easy API `KeplerGlSchema.getConfigToSave` to generate a json blob of the current kepler instance configuration.
+
+#### Examples
+
+```javascript
+// app.js
+import {addDataToMap} from 'kepler.gl/actions';
+
+const sampleTripData = {
+ fields: [
+ {name: 'tpep_pickup_datetime', format: 'YYYY-M-D H:m:s', type: 'timestamp'},
+ {name: 'pickup_longitude', format: '', type: 'real'},
+ {name: 'pickup_latitude', format: '', type: 'real'}
+ ],
+ rows: [
+ ['2015-01-15 19:05:39 +00:00', -73.99389648, 40.75011063],
+ ['2015-01-15 19:05:39 +00:00', -73.97642517, 40.73981094],
+ ['2015-01-15 19:05:40 +00:00', -73.96870422, 40.75424576]
+ ]
+};
+
+const sampleConfig = {
+ visState: {
+ filters: [
+ {
+ id: 'me',
+ dataId: 'test_trip_data',
+ name: 'tpep_pickup_datetime',
+ type: 'timeRange',
+ enlarged: true
+ }
+ ]
+ }
+};
+
+this.props.dispatch(
+ addDataToMap({
+ datasets: {
+ info: {
+ label: 'Sample Taxi Trips in New York City',
+ id: 'test_trip_data'
+ },
+ data: sampleTripData
+ },
+ option: {
+ centerMap: true,
+ readOnly: false
+ },
+ config: sampleConfig
+ })
+);
+```
+
+Read more about [addDataToMap](./docs/api-reference/actions/actions.md#adddatatomap) and [Saving and loading maps with schema manager][saving-loading-w-schema].
+
+[contributing]: contributing/README.md
+[demo-app]: http://kepler.gl/#/demo
+[github]: https://github.com/keplergl/kepler.gl
+[github-pr]: https://help.github.com/articles/creating-a-pull-request/
+[mapbox]: https://www.mapbox.com
+[mapbox-token]: https://www.mapbox.com/help/define-access-token/
+[developers]: contributing/DEVELOPERS.md
+[examples]: https://github.com/keplergl/kepler.gl/tree/master/examples
+[react-palm]: https://github.com/btford/react-palm
+[roadmap]: https://github.com/keplergl/kepler.gl/wiki/Kepler.gl-2019-Roadmap
+[stack]: https://stackoverflow.com/questions/tagged/kepler.gl
+[web]: http://www.kepler.gl/
+[vis-academy]: http://vis.academy/#/kepler.gl/
+[user-guide]: docs/user-guides/README.md
+[user-guide-jupyter]: docs/keplergl-jupyter/README.md
+[api-reference]: docs/api-reference/README.md
+[get-started]: ./docs/api-reference/get-started.md
+[reducers]: docs/api-reference/reducers/README.md
+[components]: docs/api-reference/components/README.md
+[custom-theme]: docs/api-reference/custom-theme/README.md
+[reducers]: docs/api-reference/reducers/README.md
+[actions-updaters]: docs/api-reference/actions/README.md
+[processors]: docs/api-reference/processors/README.md
+[schemas]: docs/api-reference/schemas/README.md
+[using-updaters]: ./docs/api-reference/advanced-usages/using-updaters.md
+[forward-actions]: ./docs/api-reference/advanced-usages/forward-actions.md
+[replace-ui-component]: ./docs/api-reference/advanced-usages/replace-ui-component.md
+[saving-loading-w-schema]: ./docs/api-reference/advanced-usages/saving-loading-w-schema.md
+[40]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
+[41]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
+[42]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
+[43]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
+[44]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
+[45]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
diff --git a/typedoc/globals.md b/typedoc/globals.md
new file mode 100644
index 000000000..0f8b7f062
--- /dev/null
+++ b/typedoc/globals.md
@@ -0,0 +1,49 @@
+[kepler.gl](README.md) › [Globals](globals.md)
+
+# kepler.gl
+
+## Index
+
+### Modules
+
+* ["actions/action-wrapper"](modules/_actions_action_wrapper_.md)
+* ["actions/actions"](modules/_actions_actions_.md)
+* ["actions/actions.d"](modules/_actions_actions_d_.md)
+* ["actions/identity-actions"](modules/_actions_identity_actions_.md)
+* ["actions/identity-actions.d"](modules/_actions_identity_actions_d_.md)
+* ["actions/index"](modules/_actions_index_.md)
+* ["actions/index.d"](modules/_actions_index_d_.md)
+* ["actions/map-state-actions"](modules/_actions_map_state_actions_.md)
+* ["actions/map-state-actions.d"](modules/_actions_map_state_actions_d_.md)
+* ["actions/map-style-actions"](modules/_actions_map_style_actions_.md)
+* ["actions/map-style-actions.d"](modules/_actions_map_style_actions_d_.md)
+* ["actions/provider-actions"](modules/_actions_provider_actions_.md)
+* ["actions/provider-actions.d"](modules/_actions_provider_actions_d_.md)
+* ["actions/ui-state-actions"](modules/_actions_ui_state_actions_.md)
+* ["actions/ui-state-actions.d"](modules/_actions_ui_state_actions_d_.md)
+* ["actions/vis-state-actions"](modules/_actions_vis_state_actions_.md)
+* ["actions/vis-state-actions.d"](modules/_actions_vis_state_actions_d_.md)
+* ["reducers/combined-updaters"](modules/_reducers_combined_updaters_.md)
+* ["reducers/combined-updaters.d"](modules/_reducers_combined_updaters_d_.md)
+* ["reducers/composers"](modules/_reducers_composers_.md)
+* ["reducers/core"](modules/_reducers_core_.md)
+* ["reducers/index"](modules/_reducers_index_.md)
+* ["reducers/map-state"](modules/_reducers_map_state_.md)
+* ["reducers/map-state-updaters"](modules/_reducers_map_state_updaters_.md)
+* ["reducers/map-state-updaters.d"](modules/_reducers_map_state_updaters_d_.md)
+* ["reducers/map-style"](modules/_reducers_map_style_.md)
+* ["reducers/map-style-updaters"](modules/_reducers_map_style_updaters_.md)
+* ["reducers/map-style-updaters.d"](modules/_reducers_map_style_updaters_d_.md)
+* ["reducers/provider-state"](modules/_reducers_provider_state_.md)
+* ["reducers/provider-state-updaters"](modules/_reducers_provider_state_updaters_.md)
+* ["reducers/provider-state-updaters.d"](modules/_reducers_provider_state_updaters_d_.md)
+* ["reducers/root"](modules/_reducers_root_.md)
+* ["reducers/types.d"](modules/_reducers_types_d_.md)
+* ["reducers/ui-state"](modules/_reducers_ui_state_.md)
+* ["reducers/ui-state-updaters"](modules/_reducers_ui_state_updaters_.md)
+* ["reducers/ui-state-updaters.d"](modules/_reducers_ui_state_updaters_d_.md)
+* ["reducers/vis-state"](modules/_reducers_vis_state_.md)
+* ["reducers/vis-state-merger"](modules/_reducers_vis_state_merger_.md)
+* ["reducers/vis-state-merger.d"](modules/_reducers_vis_state_merger_d_.md)
+* ["reducers/vis-state-updaters"](modules/_reducers_vis_state_updaters_.md)
+* ["reducers/vis-state-updaters.d"](modules/_reducers_vis_state_updaters_d_.md)
diff --git a/yarn.lock b/yarn.lock
index e2363ba08..3bac91ee3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2675,6 +2675,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
+"@types/d3-array@^2.0.0":
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/@types/d3-array/-/d3-array-2.0.0.tgz#a0d63a296a2d8435a9ec59393dcac746c6174a96"
+ integrity sha512-rGqfPVowNDTszSFvwoZIXvrPG7s/qKzm9piCRIH6xwTTRu7pPZ3ootULFnPkTt74B6i5lN0FpLQL24qGOw1uZA==
+
"@types/events@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
@@ -7744,6 +7749,18 @@ handlebars@^4.0.3, handlebars@^4.1.2, handlebars@^4.4.0:
optionalDependencies:
uglify-js "^3.1.4"
+handlebars@^4.7.3, handlebars@^4.7.6:
+ version "4.7.6"
+ resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
+ integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
+ dependencies:
+ minimist "^1.2.5"
+ neo-async "^2.6.0"
+ source-map "^0.6.1"
+ wordwrap "^1.0.0"
+ optionalDependencies:
+ uglify-js "^3.1.4"
+
har-schema@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92"
@@ -7888,6 +7905,11 @@ [email protected], he@^1.1.0:
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
+highlight.js@^10.0.0:
+ version "10.0.3"
+ resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.0.3.tgz#5effcc58420f113f279a0badb8ac50c4be06e63b"
+ integrity sha512-9FG7SSzv9yOY5CGGxfI6NDm7xLYtMOjKtPBxw7Zff3t5UcRcUNTGEeS8lNjhceL34KeetLMoGMFTGoaa83HwyQ==
+
highlight.js@^9.15.5:
version "9.18.0"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.0.tgz#6b1763cfcd53744313bd3f31f1210f7beb962c79"
@@ -8356,7 +8378,7 @@ internal-ip@^4.3.0:
default-gateway "^4.2.0"
ipaddr.js "^1.9.0"
[email protected], interpret@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296"
integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==
@@ -10121,6 +10143,11 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"
+lunr@^2.3.8:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.8.tgz#a8b89c31f30b5a044b97d2d28e2da191b6ba2072"
+ integrity sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg==
+
macos-release@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f"
@@ -10253,6 +10280,11 @@ markdown-table@^1.1.0:
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60"
integrity sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q==
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/marked/-/marked-1.0.0.tgz#d35784245a04871e5988a491e28867362e941693"
+ integrity sha512-Wo+L1pWTVibfrSr+TTtMuiMfNzmZWiOPeO7rZsQUY5bgsxpHesBEcIWJloWVTFnrMXnf/TL30eTFSGJddmQAng==
+
material-colors@^1.2.1:
version "1.2.6"
resolved "https://registry.yarnpkg.com/material-colors/-/material-colors-1.2.6.tgz#6d1958871126992ceecc72f4bcc4d8f010865f46"
@@ -10605,7 +10637,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1:
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"
integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=
-"minimatch@2 || 3", minimatch@^3.0.2, minimatch@^3.0.4:
+"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
@@ -10635,6 +10667,11 @@ [email protected], minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=
+minimist@^1.2.5:
+ version "1.2.5"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
+ integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
+
minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
@@ -12264,7 +12301,7 @@ progress@^1.1.8:
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"
integrity sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=
-progress@^2.0.0, progress@^2.0.1:
+progress@^2.0.0, progress@^2.0.1, progress@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
@@ -13050,6 +13087,13 @@ realpath-native@^1.1.0:
dependencies:
util.promisify "^1.0.0"
+rechoir@^0.6.2:
+ version "0.6.2"
+ resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
+ integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=
+ dependencies:
+ resolve "^1.1.6"
+
redbox-react@^1.3.6:
version "1.6.0"
resolved "https://registry.yarnpkg.com/redbox-react/-/redbox-react-1.6.0.tgz#e753ac02595bc1bf695b3935889a4f5b1b5a21a1"
@@ -13567,6 +13611,13 @@ resolve@^1.1.3, resolve@^1.1.4, resolve@^1.10.0, resolve@^1.13.1, resolve@^1.14.
dependencies:
path-parse "^1.0.6"
+resolve@^1.1.6:
+ version "1.17.0"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444"
+ integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==
+ dependencies:
+ path-parse "^1.0.6"
+
resolve@~1.14.2:
version "1.14.2"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.14.2.tgz#dbf31d0fa98b1f29aa5169783b9c290cb865fea2"
@@ -13990,6 +14041,15 @@ shell-quote@^1.4.2, shell-quote@^1.6.1:
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"
integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==
+shelljs@^0.8.4:
+ version "0.8.4"
+ resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
+ integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
+ dependencies:
+ glob "^7.0.0"
+ interpret "^1.0.0"
+ rechoir "^0.6.2"
+
shellwords@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
@@ -15350,6 +15410,42 @@ typedarray@^0.0.6, typedarray@~0.0.5:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
+typedoc-default-themes@^0.10.1:
+ version "0.10.1"
+ resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.10.1.tgz#eb27b7d689457c7ec843e47ec0d3e500581296a7"
+ integrity sha512-SuqAQI0CkwhqSJ2kaVTgl37cWs733uy9UGUqwtcds8pkFK8oRF4rZmCq+FXTGIb9hIUOu40rf5Kojg0Ha6akeg==
+ dependencies:
+ lunr "^2.3.8"
+
+typedoc-plugin-markdown@^2.2.17:
+ version "2.2.17"
+ resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.2.17.tgz#aaef7420e8268170e62c764f43740e10f842548d"
+ integrity sha512-eE6cTeqsZIbjur6RG91Lhx1vTwjR49OHwVPRlmsxY3dthS4FNRL8sHxT5Y9pkosBwv1kSmNGQEPHjMYy1Ag6DQ==
+ dependencies:
+ fs-extra "^8.1.0"
+ handlebars "^4.7.3"
+
+typedoc@^0.17.7:
+ version "0.17.7"
+ resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.17.7.tgz#70797401140403a5f91589ed3f4f24c03841bf7a"
+ integrity sha512-PEnzjwQAGjb0O8a6VDE0lxyLAadqNujN5LltsTUhZETolRMiIJv6Ox+Toa8h0XhKHqAOh8MOmB0eBVcWz6nuAw==
+ dependencies:
+ fs-extra "^8.1.0"
+ handlebars "^4.7.6"
+ highlight.js "^10.0.0"
+ lodash "^4.17.15"
+ lunr "^2.3.8"
+ marked "1.0.0"
+ minimatch "^3.0.0"
+ progress "^2.0.3"
+ shelljs "^0.8.4"
+ typedoc-default-themes "^0.10.1"
+
+ version "3.8.3"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
+ integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
+
ua-parser-js@^0.7.18:
version "0.7.21"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777"
@@ -16280,6 +16376,11 @@ word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
+wordwrap@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
+ integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=
+
wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"