Skip to content

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

Add types to top-level KeplerGl component (#1188)

Ib Green995024e86880
diff --git a/src/components/kepler-gl.d.ts b/src/components/kepler-gl.d.ts
new file mode 100644
index 000000000..39e980d5b
--- /dev/null
+++ b/src/components/kepler-gl.d.ts
@@ -0,0 +1,16 @@
+import React from 'react';
+
+export type KeplerGlProps = {
+ mapStyles: object[];
+ mapStylesReplaceDefault: boolean;
+ mapboxApiUrl: string;
+ width: number;
+ height: number;
+ appName: string;
+ version: string;
+ sidePanelWidth: number;
+ theme: object;
+ cloudProviders: object[];
+};
+
+export default function KeplerGlFactory(): React.Component<KeplerGlProps>;
diff --git a/src/components/kepler-gl.js b/src/components/kepler-gl.js
index 2f1129319..2c3d777ab 100644
--- a/src/components/kepler-gl.js
+++ b/src/components/kepler-gl.js
@@ -110,6 +110,8 @@ function KeplerGlFactory(
PlotContainer,
NotificationPanel
) {
+ /** @typedef {import('./kepler-gl').KeplerGlProps} KeplerGlProps */
+ /** @augments React.Component<KeplerGlProps> */
class KeplerGL extends Component {
static defaultProps = {
mapStyles: [],
diff --git a/src/components/modal-container.d.ts b/src/components/modal-container.d.ts
new file mode 100644
index 000000000..d715f94cb
--- /dev/null
+++ b/src/components/modal-container.d.ts
@@ -0,0 +1,20 @@
+import React from 'react';
+
+export type ModelContainerProps = {
+ rootNode: object;
+ containerW: number;
+ containerH: number;
+ mapboxApiAccessToken: string;
+ mapboxApiUrl?: string;
+ mapState: object;
+ mapStyle: object;
+ uiState: object;
+ visState: object;
+ visStateActions: object;
+ uiStateActions: object;
+ mapStyleActions: object;
+ onSaveToStorage: () => void,
+ cloudProviders: object[]
+};
+
+export default function ModalContainerFactory(): React.Component<ModelContainerProps>;
diff --git a/src/components/modal-container.js b/src/components/modal-container.js
index 8a982fd43..310a4c91c 100644
--- a/src/components/modal-container.js
+++ b/src/components/modal-container.js
@@ -117,7 +117,10 @@ export default function ModalContainerFactory(
SaveMapModal,
ShareMapModal
) {
- class ModalWrapper extends Component {
+ /** @typedef {import('./modal-container').ModalContainer} ModalContainer */
+ /** @augments React.Component<ModalContainer> */
+ class ModalContainer extends Component {
+ // TODO - remove when prop types are fully exported
static propTypes = {
rootNode: PropTypes.object,
containerW: PropTypes.number,
@@ -134,7 +137,6 @@ export default function ModalContainerFactory(
onSaveToStorage: PropTypes.func,
cloudProviders: PropTypes.arrayOf(PropTypes.object)
};
-
componentDidMount = () => {
document.addEventListener('keyup', this._onKeyUp);
};
@@ -522,5 +524,5 @@ export default function ModalContainerFactory(
/* eslint-enable complexity */
}
- return ModalWrapper;
+ return ModalContainer;
}
diff --git a/tsconfig.json b/tsconfig.json
index a706eeb7f..2dec2ece9 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -32,7 +32,8 @@
"src/utils",
"src/components/common/file-uploader",
"src/components/common/progress-bar.js",
- "src/components/modals/load-data-modal.js"
+ "src/components/modals/load-data-modal.js",
+ "src/components/kepler.gl"
// TODO: add types
// "src/constants",