Skip to content

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

[Chore] Remove default props and react-onclickoutside in react functional components (#2679)

Shan He5764b06994bf
diff --git a/examples/demo-app/esbuild.config.mjs b/examples/demo-app/esbuild.config.mjs
index bb5796910..956bfa34b 100644
--- a/examples/demo-app/esbuild.config.mjs
+++ b/examples/demo-app/esbuild.config.mjs
@@ -5,7 +5,7 @@ import process from 'node:process';
import fs from 'node:fs';
import {spawn} from 'node:child_process';
import {join} from 'node:path';
-import KeplerPackage from '../../package.json' with {type: 'json'};
+import KeplerPackage from '../../package.json' assert {type: 'json'};
const args = process.argv;
const LIB_DIR = '../../';
@@ -59,7 +59,7 @@ const config = {
// automatically injected kepler.gl package version into the bundle
replace({
__PACKAGE_VERSION__: KeplerPackage.version,
- exclude: /node_modules/
+ include: /constants\/src\/default-settings\.ts/
})
]
};
diff --git a/examples/demo-app/package.json b/examples/demo-app/package.json
index e7b5e2997..d16668557 100644
--- a/examples/demo-app/package.json
+++ b/examples/demo-app/package.json
@@ -1,7 +1,7 @@
{
"scripts": {
"start": "node esbuild.config.mjs --start",
- "start:local": "NODE_ENV=local node esbuild.config.mjs --start --env.deck",
+ "start:local": "NODE_ENV=local node esbuild.config.mjs --start",
"start:local-deck": "NODE_ENV=local node esbuild.config.mjs --start --env.deck",
"start:local-deck-src": "NODE_ENV=local node esbuild.config.mjs --start --env.deck_src",
"start:local-loaders-src": "NODE_ENV=local node esbuild.config.mjs --start --env.loaders_src",
diff --git a/examples/demo-app/src/factories/load-data-modal.js b/examples/demo-app/src/factories/load-data-modal.js
index 6496561c5..3a964e4b6 100644
--- a/examples/demo-app/src/factories/load-data-modal.js
+++ b/examples/demo-app/src/factories/load-data-modal.js
@@ -11,7 +11,7 @@ import {loadRemoteMap, loadSample, loadSampleConfigurations} from '../actions';
const CustomLoadDataModalFactory = (...deps) => {
const LoadDataModal = LoadDataModalFactory(...deps);
- const defaultLoadingMethods = LoadDataModal.defaultProps.loadingMethods;
+ const defaultLoadingMethods = LoadDataModal.defaultLoadingMethods;
const additionalMethods = {
remote: {
id: LOADING_METHODS.remote,
@@ -27,21 +27,22 @@ const CustomLoadDataModalFactory = (...deps) => {
};
// add more loading methods
- LoadDataModal.defaultProps = {
- ...LoadDataModal.defaultProps,
- loadingMethods: [
- defaultLoadingMethods.find(lm => lm.id === 'upload'),
- additionalMethods.remote,
- defaultLoadingMethods.find(lm => lm.id === 'storage'),
- additionalMethods.sample
- ]
- };
+ const loadingMethods = [
+ defaultLoadingMethods.find(lm => lm.id === 'upload'),
+ additionalMethods.remote,
+ defaultLoadingMethods.find(lm => lm.id === 'storage'),
+ additionalMethods.sample
+ ];
- return withState([], state => ({...state.demo.app, ...state.demo.keplerGl.map.uiState}), {
- onLoadSample: loadSample,
- onLoadRemoteMap: loadRemoteMap,
- loadSampleConfigurations
- })(LoadDataModal);
+ return withState(
+ [],
+ state => ({...state.demo.app, ...state.demo.keplerGl.map.uiState, loadingMethods}),
+ {
+ onLoadSample: loadSample,
+ onLoadRemoteMap: loadRemoteMap,
+ loadSampleConfigurations
+ }
+ )(LoadDataModal);
};
CustomLoadDataModalFactory.deps = LoadDataModalFactory.deps;
diff --git a/examples/replace-component/README.md b/examples/replace-component/README.md
index 49b5122b2..cd1d45811 100644
--- a/examples/replace-component/README.md
+++ b/examples/replace-component/README.md
@@ -5,17 +5,11 @@ Example showing how to replace kepler.gl default components using `injectCompone
#### 1. Install
```sh
-npm install
+yarn install
```
-or
-
-```sh
-yarn
-```
-
-
#### 2. Mapbox Token
+
add mapbox access token to node env
```sh
@@ -25,5 +19,5 @@ export MapboxAccessToken=<your_mapbox_token>
#### 3. Start the app
```sh
-npm start
+yarn start
```
diff --git a/examples/replace-component/esbuild.config.mjs b/examples/replace-component/esbuild.config.mjs
new file mode 100644
index 000000000..956bfa34b
--- /dev/null
+++ b/examples/replace-component/esbuild.config.mjs
@@ -0,0 +1,220 @@
+import esbuild from 'esbuild';
+import {replace} from 'esbuild-plugin-replace';
+
+import process from 'node:process';
+import fs from 'node:fs';
+import {spawn} from 'node:child_process';
+import {join} from 'node:path';
+import KeplerPackage from '../../package.json' assert {type: 'json'};
+
+const args = process.argv;
+const LIB_DIR = '../../';
+const NODE_MODULES_DIR = join(LIB_DIR, 'node_modules');
+const SRC_DIR = join(LIB_DIR, 'src');
+
+// For debugging deck.gl, load deck.gl from external deck.gl directory
+const EXTERNAL_DECK_SRC = join(LIB_DIR, 'deck.gl');
+
+// For debugging loaders.gl, load loaders.gl from external loaders.gl directory
+const EXTERNAL_LOADERS_SRC = join(LIB_DIR, 'loaders.gl');
+
+// For debugging hubble.gl, load hubble.gl from external hubble.gl directory
+const EXTERNAL_HUBBLE_SRC = join(LIB_DIR, '../../hubble.gl');
+
+const port = 8080;
+
+// add alias to serve from kepler src, resolve libraries so there is only one copy of them
+const RESOLVE_LOCAL_ALIASES = {
+ react: `${NODE_MODULES_DIR}/react`,
+ 'react-dom': `${NODE_MODULES_DIR}/react-dom`,
+ 'react-redux': `${NODE_MODULES_DIR}/react-redux/lib`,
+ 'styled-components': `${NODE_MODULES_DIR}/styled-components`,
+ 'react-intl': `${NODE_MODULES_DIR}/react-intl`,
+ // Suppress useless warnings from react-date-picker's dep
+ 'tiny-warning': `${SRC_DIR}/utils/src/noop.ts`,
+ // kepler.gl and loaders.gl need to use same apache-arrow
+ 'apache-arrow': `${NODE_MODULES_DIR}/apache-arrow`
+};
+
+const config = {
+ platform: 'browser',
+ format: 'iife',
+ logLevel: 'info',
+ loader: {'.js': 'jsx'},
+ entryPoints: ['src/main.js'],
+ outfile: 'dist/bundle.js',
+ bundle: true,
+ define: {
+ NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'production'),
+ 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken), // eslint-disable-line
+ 'process.env.DropboxClientId': JSON.stringify(process.env.DropboxClientId), // eslint-disable-line
+ 'process.env.MapboxExportToken': JSON.stringify(process.env.MapboxExportToken), // eslint-disable-line
+ 'process.env.CartoClientId': JSON.stringify(process.env.CartoClientId), // eslint-disable-line
+ 'process.env.FoursquareClientId': JSON.stringify(process.env.FoursquareClientId), // eslint-disable-line
+ 'process.env.FoursquareDomain': JSON.stringify(process.env.FoursquareDomain), // eslint-disable-line
+ 'process.env.FoursquareAPIURL': JSON.stringify(process.env.FoursquareAPIURL), // eslint-disable-line
+ 'process.env.FoursquareUserMapsURL': JSON.stringify(process.env.FoursquareUserMapsURL) // eslint-disable-line
+ },
+ plugins: [
+ // automatically injected kepler.gl package version into the bundle
+ replace({
+ __PACKAGE_VERSION__: KeplerPackage.version,
+ include: /constants\/src\/default-settings\.ts/
+ })
+ ]
+};
+
+function addAliases(externals, args) {
+ const resolveAlias = RESOLVE_LOCAL_ALIASES;
+
+ // Combine flags
+ const useLocalDeck = args.includes('--env.deck') || args.includes('--env.hubble_src');
+ const useRepoDeck = args.includes('--env.deck_src');
+
+ // resolve deck.gl from local dir
+ if (useLocalDeck || useRepoDeck) {
+ // Load deck.gl from root node_modules
+ // if env.deck_src Load deck.gl from deck.gl/modules/main/src folder parallel to kepler.gl
+ resolveAlias['deck.gl'] = useLocalDeck
+ ? `${NODE_MODULES_DIR}/deck.gl/src`
+ : `${EXTERNAL_DECK_SRC}/modules/main/src`;
+
+ // if env.deck Load @deck.gl modules from root node_modules/@deck.gl
+ // if env.deck_src Load @deck.gl modules from deck.gl/modules folder parallel to kepler.gl
+ externals['deck.gl'].forEach(mdl => {
+ resolveAlias[`@deck.gl/${mdl}`] = useLocalDeck
+ ? `${NODE_MODULES_DIR}/@deck.gl/${mdl}/src`
+ : `${EXTERNAL_DECK_SRC}/modules/${mdl}/src`;
+ // types are stored in different directory
+ resolveAlias[`@deck.gl/${mdl}/typed`] = useLocalDeck
+ ? `${NODE_MODULES_DIR}/@deck.gl/${mdl}/typed`
+ : `${EXTERNAL_DECK_SRC}/modules/${mdl}/src/types`;
+ });
+
+ ['luma.gl', 'probe.gl', 'loaders.gl'].forEach(name => {
+ // if env.deck Load ${name} from root node_modules
+ // if env.deck_src Load ${name} from deck.gl/node_modules folder parallel to kepler.gl
+ resolveAlias[name] = useLocalDeck
+ ? `${NODE_MODULES_DIR}/${name}/src`
+ : name === 'probe.gl'
+ ? `${EXTERNAL_DECK_SRC}/node_modules/${name}/src`
+ : `${EXTERNAL_DECK_SRC}/node_modules/@${name}/core/src`;
+
+ // if env.deck Load @${name} modules from root node_modules/@${name}
+ // if env.deck_src Load @${name} modules from deck.gl/node_modules/@${name} folder parallel to kepler.gl`
+ externals[name].forEach(mdl => {
+ resolveAlias[`@${name}/${mdl}`] = useLocalDeck
+ ? `${NODE_MODULES_DIR}/@${name}/${mdl}/src`
+ : `${EXTERNAL_DECK_SRC}/node_modules/@${name}/${mdl}/src`;
+ });
+ });
+ }
+
+ if (args.includes('--env.loaders_src')) {
+ externals['loaders.gl'].forEach(mdl => {
+ resolveAlias[`@loaders.gl/${mdl}`] = `${EXTERNAL_LOADERS_SRC}/modules/${mdl}/src`;
+ });
+ }
+
+ if (args.includes('--env.hubble_src')) {
+ externals['hubble.gl'].forEach(mdl => {
+ resolveAlias[`@hubble.gl/${mdl}`] = `${EXTERNAL_HUBBLE_SRC}/modules/${mdl}/src`;
+ });
+ }
+
+ return resolveAlias;
+}
+
+function openURL(url) {
+ // Could potentially be replaced by https://www.npmjs.com/package/open, it was throwing an error when tried last
+ const cmd = {
+ darwin: ['open'],
+ linux: ['xdg-open'],
+ win32: ['cmd', '/c', 'start']
+ };
+ const command = cmd[process.platform];
+ if (command) {
+ spawn(command[0], [...command.slice(1), url]);
+ }
+}
+
+(async () => {
+ // local dev
+
+ const modules = ['@deck.gl', '@loaders.gl', '@luma.gl', '@probe.gl', '@hubble.gl'];
+ const loadAllDirs = modules.map(
+ dir =>
+ new Promise(success => {
+ fs.readdir(join(NODE_MODULES_DIR, dir), (err, items) => {
+ if (err) {
+ const colorRed = '\x1b[31m';
+ const colorReset = '\x1b[0m';
+ console.log(
+ `${colorRed}%s${colorReset}`,
+ `Cannot find ${dir} in node_modules, make sure it is installed. ${err}`
+ );
+
+ success(null);
+ }
+ success(items);
+ });
+ })
+ );
+
+ const externals = await Promise.all(loadAllDirs).then(results => ({
+ 'deck.gl': results[0],
+ 'loaders.gl': results[1],
+ 'luma.gl': results[2],
+ 'probe.gl': results[3],
+ 'hubble.gl': results[4]
+ }));
+
+ const localAliases = addAliases(externals, args);
+
+ if (args.includes('--build')) {
+ await esbuild
+ .build({
+ ...config,
+
+ minify: true,
+ sourcemap: false
+ })
+ .catch(e => {
+ console.error(e);
+ process.exit(1);
+ });
+ }
+
+ if (args.includes('--start')) {
+ await esbuild
+ .context({
+ ...config,
+ minify: false,
+ sourcemap: true,
+ // add alias to resolve libraries so there is only one copy of them
+ ...(process.env.NODE_ENV === 'local' ? {alias: localAliases} : {}),
+ banner: {
+ js: `new EventSource('/esbuild').addEventListener('change', () => location.reload());`
+ }
+ })
+ .then(async ctx => {
+ await ctx.watch();
+ await ctx.serve({
+ servedir: 'dist',
+ port,
+ fallback: 'dist/index.html',
+ onRequest: ({remoteAddress, method, path, status, timeInMS}) => {
+ console.info(remoteAddress, status, `"${method} ${path}" [${timeInMS}ms]`);
+ }
+ });
+ console.info(
+ `kepler.gl demo app running at ${`http://localhost:${port}`}, press Ctrl+C to stop`
+ );
+ openURL(`http://localhost:${port}`);
+ })
+ .catch(e => {
+ console.error(e);
+ process.exit(1);
+ });
+ }
+})();
diff --git a/examples/replace-component/index.html b/examples/replace-component/index.html
deleted file mode 100644
index 75839a0a9..000000000
--- a/examples/replace-component/index.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset='UTF-8' />
- <title>kepler.gl demo</title>
- <link rel="stylesheet" href="//d1a3f4spazzrp4.cloudfront.net/kepler.gl/uber-fonts/4.0.0/superfine.css">
- <link href="https://unpkg.com/maplibre-gl@^3/dist/maplibre-gl.css" rel="stylesheet">
- <style type="text/css">
- body {margin: 0; padding: 0; overflow: hidden;}
- </style>
- </head>
- <body>
- <div id="root" />
- <script src='bundle.js'></script>
- </body>
-</html>
diff --git a/examples/replace-component/package.json b/examples/replace-component/package.json
index 706910121..585610936 100644
--- a/examples/replace-component/package.json
+++ b/examples/replace-component/package.json
@@ -1,7 +1,7 @@
{
"scripts": {
- "start": "webpack-dev-server --progress --hot --open",
- "start-local": "webpack-dev-server --env.es6 --progress --hot --open"
+ "start": "node esbuild.config.mjs --start",
+ "start:local": "NODE_ENV=local node esbuild.config.mjs --start"
},
"dependencies": {
"@kepler.gl/actions": "^3.0.0-alpha.1",
@@ -9,6 +9,7 @@
"@kepler.gl/reducers": "^3.0.0-alpha.1",
"@kepler.gl/schemas": "^3.0.0-alpha.1",
"@kepler.gl/styles": "^3.0.0-alpha.1",
+ "esbuild": "^0.23.1",
"global": "^4.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
@@ -19,21 +20,14 @@
"styled-components": "^4.1.3"
},
"devDependencies": {
- "@babel/core": "^7.12.1",
- "@babel/plugin-transform-class-properties": "^7.12.1",
- "@babel/plugin-transform-export-namespace-from": "^7.12.1",
- "@babel/plugin-transform-modules-commonjs": "^7.12.1",
- "@babel/plugin-transform-optional-chaining": "^7.12.1",
- "@babel/plugin-transform-runtime": "^7.12.1",
- "@babel/plugin-transform-typescript": "^7.16.8",
- "@babel/preset-env": "^7.12.1",
- "@babel/preset-react": "^7.12.1",
- "@babel/preset-typescript": "^7.16.7",
- "babel-loader": "^8.0.0",
- "webpack": "^4.29.0",
- "webpack-cli": "^3.2.1",
- "webpack-dev-middleware": "^3.5.1",
- "webpack-dev-server": "^3.1.14",
- "webpack-hot-middleware": "^2.24.3"
- }
+ "esbuild-plugin-replace": "^1.4.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "volta": {
+ "node": "18.18.2",
+ "yarn": "4.4.0"
+ },
+ "packageManager": "[email protected]"
}
diff --git a/examples/replace-component/src/components/custom-panel.js b/examples/replace-component/src/components/custom-panel.js
index 2f2672bfc..ca54a9ea2 100644
--- a/examples/replace-component/src/components/custom-panel.js
+++ b/examples/replace-component/src/components/custom-panel.js
@@ -5,6 +5,21 @@ import React from 'react';
import {Icons} from '@kepler.gl/components';
function CustomSidePanelsFactory() {
+ const defaultPanels = [
+ {
+ id: 'rocket',
+ label: 'Rocket',
+ iconComponent: Icons.Rocket
+ },
+ {
+ id: 'chart',
+ label: 'Chart',
+ iconComponent: Icons.LineChart
+ }
+ ];
+ const defaultGetProps = props => ({
+ layers: props.layers
+ });
const CustomPanels = props => {
if (props.activeSidePanel === 'rocket') {
return <div className="rocket-panel">Rocket</div>;
@@ -15,23 +30,8 @@ function CustomSidePanelsFactory() {
return null;
};
- CustomPanels.defaultProps = {
- panels: [
- {
- id: 'rocket',
- label: 'Rocket',
- iconComponent: Icons.Rocket
- },
- {
- id: 'chart',
- label: 'Chart',
- iconComponent: Icons.LineChart
- }
- ],
- getProps: props => ({
- layers: props.layers
- })
- };
+ CustomPanels.panels = defaultPanels;
+ CustomPanels.getProps = defaultGetProps;
return CustomPanels;
}
diff --git a/examples/replace-component/webpack.config.js b/examples/replace-component/webpack.config.js
deleted file mode 100644
index 9478149e7..000000000
--- a/examples/replace-component/webpack.config.js
+++ /dev/null
@@ -1,53 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-// NOTE: To use this example standalone (e.g. outside of deck.gl repo)
-// delete the local development overrides at the bottom of this file
-
-// avoid destructuring for older Node version support
-const resolve = require('path').resolve;
-const join = require('path').join;
-const webpack = require('webpack');
-
-const CONFIG = {
- // bundle app.js and everything it imports, recursively.
- entry: {
- app: resolve('./src/main.js')
- },
- output: {
- path: resolve(__dirname, 'build'),
- filename: 'bundle.js',
- publicPath: '/'
- },
-
- devtool: 'source-map',
-
- module: {
- rules: [
- {
- test: /\.(js|ts|tsx)$/,
- loader: 'babel-loader',
- include: join(__dirname, 'src'),
- exclude: [/node_modules/]
- },
- // fix for arrow-related errors
- {
- test: /\.mjs$/,
- include: /node_modules/,
- type: 'javascript/auto'
- }
- ]
- },
-
- node: {
- fs: 'empty'
- },
-
- // Optional: Enables reading mapbox token from environment variable
- plugins: [new webpack.EnvironmentPlugin(['MapboxAccessToken'])]
-};
-
-// This line enables bundling against src in this repo rather than installed deck.gl module
-module.exports = env => {
- return env ? require('../webpack.config.local')(CONFIG, __dirname)(env) : CONFIG;
-};
diff --git a/package.json b/package.json
index 33ac8e97c..08eb02306 100644
--- a/package.json
+++ b/package.json
@@ -63,7 +63,7 @@
"start:loaders-src": "NODE_OPTIONS=--openssl-legacy-provider yarn install-and-start examples/demo-app start:local-loaders-src",
"start:open-modal": "yarn install-and-start examples/open-modal start-local",
"start:custom-reducer": "yarn install-and-start examples/custom-reducer start-local",
- "start:replace-component": "yarn install-and-start examples/replace-component start-local",
+ "start:replace-component": "yarn install-and-start examples/replace-component start:local",
"start:custom-theme": "yarn install-and-start examples/custom-theme start-local",
"start:custom-map-style": "yarn install-and-start examples/custom-map-style start-local",
"start:node-app": "yarn install-and-start examples/node-app start-local",
diff --git a/src/components/package.json b/src/components/package.json
index c75caff69..041e3e2ca 100644
--- a/src/components/package.json
+++ b/src/components/package.json
@@ -73,7 +73,6 @@
"@types/react-lifecycles-compat": "^3.0.1",
"@types/react-map-gl": "^6.1.3",
"@types/react-modal": "^3.13.1",
- "@types/react-onclickoutside": "^6.7.4",
"@types/react-redux": "^7.1.23",
"@types/react-virtualized": "^9.21.30",
"@types/react-vis": "1.11.7",
@@ -115,7 +114,6 @@
"react-map-gl": "^7.1.6",
"react-markdown": "^6.0.3",
"react-modal": "^3.12.1",
- "react-onclickoutside": "^6.7.1",
"react-redux": "^8.0.5",
"react-sortable-hoc": "^1.8.3",
"react-time-picker": "^6.2.0",
diff --git a/src/components/src/common/animation-control/animation-speed-slider.tsx b/src/components/src/common/animation-control/animation-speed-slider.tsx
index b27892164..82d44dd27 100644
--- a/src/components/src/common/animation-control/animation-speed-slider.tsx
+++ b/src/components/src/common/animation-control/animation-speed-slider.tsx
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
-import React, {Component, ComponentType} from 'react';
+import React, {useCallback} from 'react';
import styled from 'styled-components';
import RangeSliderFactory from '../range-slider';
-import onClickOutside from 'react-onclickoutside';
import {SPEED_CONTROL_RANGE, SPEED_CONTROL_STEP} from '@kepler.gl/constants';
+import useOnClickOutside from '../../hooks/use-on-click-outside';
const SliderWrapper = styled.div`
position: relative;
@@ -36,34 +36,33 @@ interface AnimationSpeedSliderProps {
export default function AnimationSpeedSliderFactory(
RangeSlider: ReturnType<typeof RangeSliderFactory>
-): ComponentType<AnimationSpeedSliderProps> {
- class AnimationSpeedSlider extends Component<AnimationSpeedSliderProps> {
- handleClickOutside = () => {
- this.props.onHide();
- };
+): React.FC<AnimationSpeedSliderProps> {
+ const AnimationSpeedSlider: React.FC<AnimationSpeedSliderProps> = ({
+ onHide,
+ speed,
+ updateAnimationSpeed
+ }) => {
+ const ref = useOnClickOutside<HTMLDivElement>(onHide);
- _onChange = v => this.props.updateAnimationSpeed(v[1]);
+ const onChange = useCallback(v => updateAnimationSpeed(v[1]), [updateAnimationSpeed]);
- render() {
- return (
- <SpeedSliderContainer className="animation-control__speed-slider">
- <SliderWrapper>
- <RangeSlider
- range={SPEED_CONTROL_RANGE}
- step={SPEED_CONTROL_STEP}
- value0={0}
- value1={this.props.speed}
- onChange={this._onChange}
- isRanged={false}
- showInput
- inputTheme="secondary"
- inputSize="tiny"
- />
- </SliderWrapper>
- </SpeedSliderContainer>
- );
- }
- }
-
- return onClickOutside(AnimationSpeedSlider);
+ return (
+ <SpeedSliderContainer className="animation-control__speed-slider" ref={ref}>
+ <SliderWrapper>
+ <RangeSlider
+ range={SPEED_CONTROL_RANGE}
+ step={SPEED_CONTROL_STEP}
+ value0={0}
+ value1={speed}
+ onChange={onChange}
+ isRanged={false}
+ showInput
+ inputTheme="secondary"
+ inputSize="tiny"
+ />
+ </SliderWrapper>
+ </SpeedSliderContainer>
+ );
+ };
+ return AnimationSpeedSlider;
}
diff --git a/src/components/src/common/animation-control/playback-controls.tsx b/src/components/src/common/animation-control/playback-controls.tsx
index cfbbba52c..334acb5cf 100644
--- a/src/components/src/common/animation-control/playback-controls.tsx
+++ b/src/components/src/common/animation-control/playback-controls.tsx
@@ -103,20 +103,20 @@ function PlaybackControlsFactory(
// eslint-disable-next-line complexity
const PlaybackControls: React.FC<PlaybackControlsProps> = ({
isAnimatable,
- isAnimating,
+ isAnimating = true,
width,
speed,
- animationWindow,
+ animationWindow = ANIMATION_WINDOW.free,
setFilterAnimationWindow,
updateAnimationSpeed,
- pauseAnimation,
- resetAnimation,
- startAnimation,
- playbackIcons,
- animationItems,
- buttonStyle,
- buttonHeight,
- playbackActionItems = []
+ pauseAnimation = nop,
+ resetAnimation = nop,
+ startAnimation = nop,
+ playbackIcons = DEFAULT_ICONS,
+ animationItems = DEFAULT_ANIMATE_ITEMS,
+ buttonStyle = 'secondary',
+ buttonHeight = DEFAULT_BUTTON_HEIGHT,
+ playbackActionItems = PLAYBACK_CONTROLS_DEFAULT_ACTION_COMPONENTS
}) => {
const [isSpeedControlVisible, toggleSpeedControl] = useState(false);
const [showAnimationWindowControl, setShowAnimationWindowControl] = useState(false);
@@ -169,19 +169,6 @@ function PlaybackControlsFactory(
);
};
- PlaybackControls.defaultProps = {
- playbackIcons: DEFAULT_ICONS,
- animationItems: DEFAULT_ANIMATE_ITEMS,
- buttonStyle: 'secondary',
- buttonHeight: DEFAULT_BUTTON_HEIGHT,
- playbackActionItems: PLAYBACK_CONTROLS_DEFAULT_ACTION_COMPONENTS,
- animationWindow: ANIMATION_WINDOW.free,
- isAnimatable: true,
- pauseAnimation: nop,
- resetAnimation: nop,
- startAnimation: nop
- };
-
return PlaybackControls;
}
diff --git a/src/components/src/common/icons/free-window.tsx b/src/components/src/common/icons/free-window.tsx
index b42cfb016..23d89a5aa 100644
--- a/src/components/src/common/icons/free-window.tsx
+++ b/src/components/src/common/icons/free-window.tsx
@@ -4,28 +4,37 @@
import React from 'react';
import Base, {BaseProps} from './base';
-const FreeWindow = (props: Partial<BaseProps>) => (
- <Base {...props}>
- <path
- fillRule="evenodd"
- clipRule="evenodd"
- d="M3.75665 4.67861C3.75665 4.40246 3.98051 4.17861 4.25665 4.17861H11.7433C12.0195 4.17861 12.2433 4.40246 12.2433 4.67861V11.3214C12.2433 11.5975 12.0195 11.8214 11.7433 11.8214H4.25665C3.98051 11.8214 3.75665 11.5975 3.75665 11.3214V4.67861ZM4.75665 5.17861V10.8214H11.2433V5.17861H4.75665Z"
- />
- <path
- fillRule="evenodd"
- clipRule="evenodd"
- d="M2.25611 10.2511C2.03735 10.4196 1.7234 10.3789 1.55487 10.1601L0.125822 8.30514C-0.0127244 8.1253 -0.0127244 7.8747 0.125822 7.69486L1.55487 5.83988C1.7234 5.62113 2.03735 5.58041 2.25611 5.74894C2.47486 5.91746 2.51558 6.23142 2.34705 6.45017L1.15308 8L2.34705 9.54983C2.51558 9.76858 2.47486 10.0825 2.25611 10.2511Z"
- />
- <path
- fillRule="evenodd"
- clipRule="evenodd"
- d="M13.7439 5.76226C13.9626 5.59374 14.2766 5.63446 14.4451 5.85321L15.8742 7.70818C16.0127 7.88802 16.0127 8.13863 15.8742 8.31847L14.4451 10.1734C14.2766 10.3922 13.9626 10.4329 13.7439 10.2644C13.5251 10.0959 13.4844 9.78191 13.6529 9.56316L14.8469 8.01333L13.6529 6.4635C13.4844 6.24474 13.5251 5.93079 13.7439 5.76226Z"
- />
- </Base>
-);
-FreeWindow.defaultProps = {
- height: '16px',
- viewBox: '0 0 16 16',
- predefinedClassName: 'data-ex-icons-freewindow'
+const FreeWindow = ({
+ height = '16px',
+ viewBox = '0 0 16 16',
+ predefinedClassName = 'data-ex-icons-freewindow',
+ ...restProps
+}: Partial<BaseProps>) => {
+ const props = {
+ height,
+ viewBox,
+ predefinedClassName,
+ ...restProps
+ };
+ return (
+ <Base {...props}>
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M3.75665 4.67861C3.75665 4.40246 3.98051 4.17861 4.25665 4.17861H11.7433C12.0195 4.17861 12.2433 4.40246 12.2433 4.67861V11.3214C12.2433 11.5975 12.0195 11.8214 11.7433 11.8214H4.25665C3.98051 11.8214 3.75665 11.5975 3.75665 11.3214V4.67861ZM4.75665 5.17861V10.8214H11.2433V5.17861H4.75665Z"
+ />
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M2.25611 10.2511C2.03735 10.4196 1.7234 10.3789 1.55487 10.1601L0.125822 8.30514C-0.0127244 8.1253 -0.0127244 7.8747 0.125822 7.69486L1.55487 5.83988C1.7234 5.62113 2.03735 5.58041 2.25611 5.74894C2.47486 5.91746 2.51558 6.23142 2.34705 6.45017L1.15308 8L2.34705 9.54983C2.51558 9.76858 2.47486 10.0825 2.25611 10.2511Z"
+ />
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M13.7439 5.76226C13.9626 5.59374 14.2766 5.63446 14.4451 5.85321L15.8742 7.70818C16.0127 7.88802 16.0127 8.13863 15.8742 8.31847L14.4451 10.1734C14.2766 10.3922 13.9626 10.4329 13.7439 10.2644C13.5251 10.0959 13.4844 9.78191 13.6529 9.56316L14.8469 8.01333L13.6529 6.4635C13.4844 6.24474 13.5251 5.93079 13.7439 5.76226Z"
+ />
+ </Base>
+ );
};
+
export default FreeWindow;
diff --git a/src/components/src/common/icons/order-by-dataset.tsx b/src/components/src/common/icons/order-by-dataset.tsx
index 0e96ec5fb..58627c701 100644
--- a/src/components/src/common/icons/order-by-dataset.tsx
+++ b/src/components/src/common/icons/order-by-dataset.tsx
@@ -4,29 +4,37 @@
import React from 'react';
import Base, {BaseProps} from './base';
-const OrderByDataset = (props: Partial<BaseProps>) => (
- <Base {...props}>
- <path
- d="M14.7225 13.7778C14.7225 14.1294 14.6183 14.4731 14.4229 14.7655C14.2276 15.0578 13.9499 15.2857 13.6251 15.4202C13.3003 15.5548 12.9428 15.59 12.5979 15.5214C12.2531 15.4528 11.9363 15.2835 11.6877 15.0349C11.4391 14.7862 11.2697 14.4695 11.2012 14.1246C11.1326 13.7798 11.1678 13.4223 11.3023 13.0975C11.4369 12.7726 11.6647 12.495 11.9571 12.2996C12.2494 12.1043 12.5932 12 12.9448 12C13.4163 12 13.8685 12.1873 14.2018 12.5207C14.5352 12.8541 14.7225 13.3063 14.7225 13.7778ZM23.5003 13.7778C23.5003 13.542 23.4067 13.3159 23.24 13.1492C23.0733 12.9825 22.8472 12.8889 22.6114 12.8889H18.2781C18.0424 12.8889 17.8163 12.9825 17.6496 13.1492C17.4829 13.3159 17.3892 13.542 17.3892 13.7778C17.3892 14.0135 17.4829 14.2396 17.6496 14.4063C17.8163 14.573 18.0424 14.6667 18.2781 14.6667H22.6114C22.8472 14.6667 23.0733 14.573 23.24 14.4063C23.4067 14.2396 23.5003 14.0135 23.5003 13.7778ZM12.9448 18.2222C12.5932 18.2222 12.2494 18.3265 11.9571 18.5218C11.6647 18.7172 11.4369 18.9948 11.3023 19.3197C11.1678 19.6445 11.1326 20.002 11.2012 20.3468C11.2697 20.6917 11.4391 21.0085 11.6877 21.2571C11.9363 21.5057 12.2531 21.675 12.5979 21.7436C12.9428 21.8122 13.3003 21.777 13.6251 21.6425C13.9499 21.5079 14.2276 21.28 14.4229 20.9877C14.6183 20.6953 14.7225 20.3516 14.7225 20C14.7225 19.5285 14.5352 19.0763 14.2018 18.7429C13.8685 18.4095 13.4163 18.2222 12.9448 18.2222ZM23.5003 20C23.5003 19.7643 23.4067 19.5382 23.24 19.3715C23.0733 19.2048 22.8472 19.1111 22.6114 19.1111H18.2781C18.0424 19.1111 17.8163 19.2048 17.6496 19.3715C17.4829 19.5382 17.3892 19.7643 17.3892 20C17.3892 20.2357 17.4829 20.4618 17.6496 20.6285C17.8163 20.7952 18.0424 20.8889 18.2781 20.8889H22.6114C22.8472 20.8889 23.0733 20.7952 23.24 20.6285C23.4067 20.4618 23.5003 20.2357 23.5003 20Z"
- fill={props.fill}
- />
- <path
- d="M6.77778 6C6.42617 6 6.08245 6.10426 5.7901 6.29961C5.49774 6.49495 5.26988 6.7726 5.13533 7.09745C5.00077 7.4223 4.96556 7.77975 5.03416 8.1246C5.10276 8.46946 5.27207 8.78623 5.5207 9.03486C5.76933 9.28348 6.0861 9.4528 6.43095 9.5214C6.77581 9.58999 7.13326 9.55479 7.4581 9.42023C7.78295 9.28567 8.0606 9.05781 8.25595 8.76546C8.45129 8.4731 8.55556 8.12939 8.55556 7.77778C8.55556 7.30628 8.36826 6.8541 8.03486 6.5207C7.70146 6.1873 7.24927 6 6.77778 6ZM23.3333 7.77778C23.3333 7.54203 23.2397 7.31594 23.073 7.14924C22.9063 6.98254 22.6802 6.88889 22.4444 6.88889H12.1111C11.8754 6.88889 11.6493 6.98254 11.4826 7.14924C11.3159 7.31594 11.2222 7.54203 11.2222 7.77778C11.2222 8.01353 11.3159 8.23962 11.4826 8.40632C11.6493 8.57302 11.8754 8.66667 12.1111 8.66667H22.4444C22.6802 8.66667 22.9063 8.57302 23.073 8.40632C23.2397 8.23962 23.3333 8.01353 23.3333 7.77778Z"
- fill={props.fill}
- />
- <path
- fillRule="evenodd"
- clipRule="evenodd"
- d="M7.2998 9H6.2998V19.5V20V20.5H11.2998V19.5H7.2998V14.4H11.4004V13.4H7.2998V9Z"
- fill={props.fill}
- />
- </Base>
-);
-OrderByDataset.defaultProps = {
- height: '20px',
- fill: 'currentColor',
- viewBox: '0 0 24 24',
- predefinedClassName: 'data-ex-icons-order-by-dataset'
+const OrderByDataset = ({
+ height = '20px',
+ fill = 'currentColor',
+ viewBox = '0 0 24 24',
+ predefinedClassName = 'data-ex-icons-order-by-dataset',
+ ...restProps
+}: Partial<BaseProps>) => {
+ const props = {
+ height,
+ fill,
+ viewBox,
+ predefinedClassName,
+ ...restProps
+ };
+ return (
+ <Base {...props}>
+ <path
+ d="M14.7225 13.7778C14.7225 14.1294 14.6183 14.4731 14.4229 14.7655C14.2276 15.0578 13.9499 15.2857 13.6251 15.4202C13.3003 15.5548 12.9428 15.59 12.5979 15.5214C12.2531 15.4528 11.9363 15.2835 11.6877 15.0349C11.4391 14.7862 11.2697 14.4695 11.2012 14.1246C11.1326 13.7798 11.1678 13.4223 11.3023 13.0975C11.4369 12.7726 11.6647 12.495 11.9571 12.2996C12.2494 12.1043 12.5932 12 12.9448 12C13.4163 12 13.8685 12.1873 14.2018 12.5207C14.5352 12.8541 14.7225 13.3063 14.7225 13.7778ZM23.5003 13.7778C23.5003 13.542 23.4067 13.3159 23.24 13.1492C23.0733 12.9825 22.8472 12.8889 22.6114 12.8889H18.2781C18.0424 12.8889 17.8163 12.9825 17.6496 13.1492C17.4829 13.3159 17.3892 13.542 17.3892 13.7778C17.3892 14.0135 17.4829 14.2396 17.6496 14.4063C17.8163 14.573 18.0424 14.6667 18.2781 14.6667H22.6114C22.8472 14.6667 23.0733 14.573 23.24 14.4063C23.4067 14.2396 23.5003 14.0135 23.5003 13.7778ZM12.9448 18.2222C12.5932 18.2222 12.2494 18.3265 11.9571 18.5218C11.6647 18.7172 11.4369 18.9948 11.3023 19.3197C11.1678 19.6445 11.1326 20.002 11.2012 20.3468C11.2697 20.6917 11.4391 21.0085 11.6877 21.2571C11.9363 21.5057 12.2531 21.675 12.5979 21.7436C12.9428 21.8122 13.3003 21.777 13.6251 21.6425C13.9499 21.5079 14.2276 21.28 14.4229 20.9877C14.6183 20.6953 14.7225 20.3516 14.7225 20C14.7225 19.5285 14.5352 19.0763 14.2018 18.7429C13.8685 18.4095 13.4163 18.2222 12.9448 18.2222ZM23.5003 20C23.5003 19.7643 23.4067 19.5382 23.24 19.3715C23.0733 19.2048 22.8472 19.1111 22.6114 19.1111H18.2781C18.0424 19.1111 17.8163 19.2048 17.6496 19.3715C17.4829 19.5382 17.3892 19.7643 17.3892 20C17.3892 20.2357 17.4829 20.4618 17.6496 20.6285C17.8163 20.7952 18.0424 20.8889 18.2781 20.8889H22.6114C22.8472 20.8889 23.0733 20.7952 23.24 20.6285C23.4067 20.4618 23.5003 20.2357 23.5003 20Z"
+ fill={props.fill}
+ />
+ <path
+ d="M6.77778 6C6.42617 6 6.08245 6.10426 5.7901 6.29961C5.49774 6.49495 5.26988 6.7726 5.13533 7.09745C5.00077 7.4223 4.96556 7.77975 5.03416 8.1246C5.10276 8.46946 5.27207 8.78623 5.5207 9.03486C5.76933 9.28348 6.0861 9.4528 6.43095 9.5214C6.77581 9.58999 7.13326 9.55479 7.4581 9.42023C7.78295 9.28567 8.0606 9.05781 8.25595 8.76546C8.45129 8.4731 8.55556 8.12939 8.55556 7.77778C8.55556 7.30628 8.36826 6.8541 8.03486 6.5207C7.70146 6.1873 7.24927 6 6.77778 6ZM23.3333 7.77778C23.3333 7.54203 23.2397 7.31594 23.073 7.14924C22.9063 6.98254 22.6802 6.88889 22.4444 6.88889H12.1111C11.8754 6.88889 11.6493 6.98254 11.4826 7.14924C11.3159 7.31594 11.2222 7.54203 11.2222 7.77778C11.2222 8.01353 11.3159 8.23962 11.4826 8.40632C11.6493 8.57302 11.8754 8.66667 12.1111 8.66667H22.4444C22.6802 8.66667 22.9063 8.57302 23.073 8.40632C23.2397 8.23962 23.3333 8.01353 23.3333 7.77778Z"
+ fill={props.fill}
+ />
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M7.2998 9H6.2998V19.5V20V20.5H11.2998V19.5H7.2998V14.4H11.4004V13.4H7.2998V9Z"
+ fill={props.fill}
+ />
+ </Base>
+ );
};
-
export default OrderByDataset;
diff --git a/src/components/src/common/icons/order-by-list.tsx b/src/components/src/common/icons/order-by-list.tsx
index 6922c81e0..09a469824 100644
--- a/src/components/src/common/icons/order-by-list.tsx
+++ b/src/components/src/common/icons/order-by-list.tsx
@@ -4,19 +4,28 @@
import React from 'react';
import Base, {BaseProps} from './base';
-const OrderByList = (props: Partial<BaseProps>) => (
- <Base {...props}>
- <path
- d="M8.55556 14C8.55556 14.3516 8.45129 14.6953 8.25595 14.9877C8.0606 15.28 7.78295 15.5079 7.4581 15.6425C7.13326 15.777 6.77581 15.8122 6.43095 15.7436C6.0861 15.675 5.76933 15.5057 5.5207 15.2571C5.27207 15.0085 5.10276 14.6917 5.03416 14.3468C4.96556 14.002 5.00077 13.6445 5.13533 13.3197C5.26988 12.9948 5.49774 12.7172 5.7901 12.5218C6.08245 12.3265 6.42617 12.2222 6.77778 12.2222C7.24927 12.2222 7.70146 12.4095 8.03486 12.7429C8.36826 13.0763 8.55556 13.5285 8.55556 14ZM23.3333 14C23.3333 13.7643 23.2397 13.5382 23.073 13.3715C22.9063 13.2048 22.6802 13.1111 22.4444 13.1111H12.1111C11.8754 13.1111 11.6493 13.2048 11.4826 13.3715C11.3159 13.5382 11.2222 13.7643 11.2222 14C11.2222 14.2357 11.3159 14.4618 11.4826 14.6285C11.6493 14.7952 11.8754 14.8889 12.1111 14.8889H22.4444C22.6802 14.8889 22.9063 14.7952 23.073 14.6285C23.2397 14.4618 23.3333 14.2357 23.3333 14ZM6.77778 6C6.42617 6 6.08245 6.10426 5.7901 6.29961C5.49774 6.49495 5.26988 6.7726 5.13533 7.09745C5.00077 7.4223 4.96556 7.77975 5.03416 8.1246C5.10276 8.46946 5.27207 8.78623 5.5207 9.03486C5.76933 9.28348 6.0861 9.4528 6.43095 9.5214C6.77581 9.58999 7.13326 9.55479 7.4581 9.42023C7.78295 9.28567 8.0606 9.05781 8.25595 8.76546C8.45129 8.4731 8.55556 8.12939 8.55556 7.77778C8.55556 7.30628 8.36826 6.8541 8.03486 6.5207C7.70146 6.1873 7.24927 6 6.77778 6ZM23.3333 7.77778C23.3333 7.54203 23.2397 7.31594 23.073 7.14924C22.9063 6.98254 22.6802 6.88889 22.4444 6.88889H12.1111C11.8754 6.88889 11.6493 6.98254 11.4826 7.14924C11.3159 7.31594 11.2222 7.54203 11.2222 7.77778C11.2222 8.01353 11.3159 8.23962 11.4826 8.40632C11.6493 8.57302 11.8754 8.66667 12.1111 8.66667H22.4444C22.6802 8.66667 22.9063 8.57302 23.073 8.40632C23.2397 8.23962 23.3333 8.01353 23.3333 7.77778ZM6.77778 18.4444C6.42617 18.4444 6.08245 18.5487 5.7901 18.7441C5.49774 18.9394 5.26988 19.217 5.13533 19.5419C5.00077 19.8667 4.96556 20.2242 5.03416 20.569C5.10276 20.9139 5.27207 21.2307 5.5207 21.4793C5.76933 21.7279 6.0861 21.8972 6.43095 21.9658C6.77581 22.0344 7.13326 21.9992 7.4581 21.8647C7.78295 21.7301 8.0606 21.5023 8.25595 21.2099C8.45129 20.9175 8.55556 20.5738 8.55556 20.2222C8.55556 19.7507 8.36826 19.2985 8.03486 18.9651C7.70146 18.6317 7.24927 18.4444 6.77778 18.4444ZM23.3333 20.2222C23.3333 19.9865 23.2397 19.7604 23.073 19.5937C22.9063 19.427 22.6802 19.3333 22.4444 19.3333H12.1111C11.8754 19.3333 11.6493 19.427 11.4826 19.5937C11.3159 19.7604 11.2222 19.9865 11.2222 20.2222C11.2222 20.458 11.3159 20.6841 11.4826 20.8508C11.6493 21.0175 11.8754 21.1111 12.1111 21.1111H22.4444C22.6802 21.1111 22.9063 21.0175 23.073 20.8508C23.2397 20.6841 23.3333 20.458 23.3333 20.2222Z"
- fill={props.fill}
- />
- </Base>
-);
-OrderByList.defaultProps = {
- height: '20px',
- fill: 'currentColor',
- viewBox: '0 0 24 24',
- predefinedClassName: 'data-ex-icons-order-by-list'
+const OrderByList = ({
+ height = '20px',
+ fill = 'currentColor',
+ viewBox = '0 0 24 24',
+ predefinedClassName = 'data-ex-icons-order-by-list',
+ ...restProps
+}: Partial<BaseProps>) => {
+ const props = {
+ height,
+ fill,
+ viewBox,
+ predefinedClassName,
+ ...restProps
+ };
+ return (
+ <Base {...props}>
+ <path
+ d="M8.55556 14C8.55556 14.3516 8.45129 14.6953 8.25595 14.9877C8.0606 15.28 7.78295 15.5079 7.4581 15.6425C7.13326 15.777 6.77581 15.8122 6.43095 15.7436C6.0861 15.675 5.76933 15.5057 5.5207 15.2571C5.27207 15.0085 5.10276 14.6917 5.03416 14.3468C4.96556 14.002 5.00077 13.6445 5.13533 13.3197C5.26988 12.9948 5.49774 12.7172 5.7901 12.5218C6.08245 12.3265 6.42617 12.2222 6.77778 12.2222C7.24927 12.2222 7.70146 12.4095 8.03486 12.7429C8.36826 13.0763 8.55556 13.5285 8.55556 14ZM23.3333 14C23.3333 13.7643 23.2397 13.5382 23.073 13.3715C22.9063 13.2048 22.6802 13.1111 22.4444 13.1111H12.1111C11.8754 13.1111 11.6493 13.2048 11.4826 13.3715C11.3159 13.5382 11.2222 13.7643 11.2222 14C11.2222 14.2357 11.3159 14.4618 11.4826 14.6285C11.6493 14.7952 11.8754 14.8889 12.1111 14.8889H22.4444C22.6802 14.8889 22.9063 14.7952 23.073 14.6285C23.2397 14.4618 23.3333 14.2357 23.3333 14ZM6.77778 6C6.42617 6 6.08245 6.10426 5.7901 6.29961C5.49774 6.49495 5.26988 6.7726 5.13533 7.09745C5.00077 7.4223 4.96556 7.77975 5.03416 8.1246C5.10276 8.46946 5.27207 8.78623 5.5207 9.03486C5.76933 9.28348 6.0861 9.4528 6.43095 9.5214C6.77581 9.58999 7.13326 9.55479 7.4581 9.42023C7.78295 9.28567 8.0606 9.05781 8.25595 8.76546C8.45129 8.4731 8.55556 8.12939 8.55556 7.77778C8.55556 7.30628 8.36826 6.8541 8.03486 6.5207C7.70146 6.1873 7.24927 6 6.77778 6ZM23.3333 7.77778C23.3333 7.54203 23.2397 7.31594 23.073 7.14924C22.9063 6.98254 22.6802 6.88889 22.4444 6.88889H12.1111C11.8754 6.88889 11.6493 6.98254 11.4826 7.14924C11.3159 7.31594 11.2222 7.54203 11.2222 7.77778C11.2222 8.01353 11.3159 8.23962 11.4826 8.40632C11.6493 8.57302 11.8754 8.66667 12.1111 8.66667H22.4444C22.6802 8.66667 22.9063 8.57302 23.073 8.40632C23.2397 8.23962 23.3333 8.01353 23.3333 7.77778ZM6.77778 18.4444C6.42617 18.4444 6.08245 18.5487 5.7901 18.7441C5.49774 18.9394 5.26988 19.217 5.13533 19.5419C5.00077 19.8667 4.96556 20.2242 5.03416 20.569C5.10276 20.9139 5.27207 21.2307 5.5207 21.4793C5.76933 21.7279 6.0861 21.8972 6.43095 21.9658C6.77581 22.0344 7.13326 21.9992 7.4581 21.8647C7.78295 21.7301 8.0606 21.5023 8.25595 21.2099C8.45129 20.9175 8.55556 20.5738 8.55556 20.2222C8.55556 19.7507 8.36826 19.2985 8.03486 18.9651C7.70146 18.6317 7.24927 18.4444 6.77778 18.4444ZM23.3333 20.2222C23.3333 19.9865 23.2397 19.7604 23.073 19.5937C22.9063 19.427 22.6802 19.3333 22.4444 19.3333H12.1111C11.8754 19.3333 11.6493 19.427 11.4826 19.5937C11.3159 19.7604 11.2222 19.9865 11.2222 20.2222C11.2222 20.458 11.3159 20.6841 11.4826 20.8508C11.6493 21.0175 11.8754 21.1111 12.1111 21.1111H22.4444C22.6802 21.1111 22.9063 21.0175 23.073 20.8508C23.2397 20.6841 23.3333 20.458 23.3333 20.2222Z"
+ fill={props.fill}
+ />
+ </Base>
+ );
};
export default OrderByList;
diff --git a/src/components/src/editor/feature-action-panel.tsx b/src/components/src/editor/feature-action-panel.tsx
index b53ed20cd..b92ef91fd 100644
--- a/src/components/src/editor/feature-action-panel.tsx
+++ b/src/components/src/editor/feature-action-panel.tsx
@@ -57,7 +57,7 @@ export function PureFeatureActionPanelFactory(): React.FC<FeatureActionPanelProp
className,
datasets,
selectedFeature,
- position,
+ position = null,
layers,
currentFilter,
onToggleLayer,
@@ -157,10 +157,6 @@ export function PureFeatureActionPanelFactory(): React.FC<FeatureActionPanelProp
};
FeatureActionPanel.displayName = 'FeatureActionPanel';
- FeatureActionPanel.defaultProps = {
- position: null,
- actionIcons: defaultActionIcons
- };
return FeatureActionPanel;
}
diff --git a/src/components/src/effects/effect-panel-header.tsx b/src/components/src/effects/effect-panel-header.tsx
index 2346e01b8..ce6bb4b58 100644
--- a/src/components/src/effects/effect-panel-header.tsx
+++ b/src/components/src/effects/effect-panel-header.tsx
@@ -297,7 +297,7 @@ function EffectPanelHeaderFactory(
const EffectPanelHeader = (props: EffectPanelHeaderProps) => {
const {
isConfigActive,
- isDragNDropEnabled,
+ isDragNDropEnabled = true,
type,
onToggleEnableConfig,
listeners,
@@ -336,8 +336,6 @@ function EffectPanelHeaderFactory(
);
};
- EffectPanelHeader.defaultProps = defaultProps;
-
return EffectPanelHeader;
}
diff --git a/src/components/src/hooks/use-on-click-outside.tsx b/src/components/src/hooks/use-on-click-outside.tsx
new file mode 100644
index 000000000..b83f18ba4
--- /dev/null
+++ b/src/components/src/hooks/use-on-click-outside.tsx
@@ -0,0 +1,32 @@
+// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.
+
+import document from 'global/document';
+import {useCallback, useEffect, useRef, MutableRefObject} from 'react';
+export default function useOnClickOutside<T extends HTMLElement>(
+ onClose: (e) => void,
+ disabled = false
+): MutableRefObject<T | null> {
+ const containerRef = useRef<T>(null);
+ const handleClickOutside = useCallback(
+ e => {
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
+ onClose(e);
+ }
+ },
+ [onClose]
+ );
+
+ useEffect(() => {
+ if (disabled) {
+ return;
+ }
+
+ document.addEventListener('click', handleClickOutside, {capture: true});
+
+ return () => {
+ document.removeEventListener('click', handleClickOutside, {capture: true});
+ };
+ }, [handleClickOutside, disabled]);
+
+ return containerRef;
+}
diff --git a/src/components/src/map/map-control.tsx b/src/components/src/map/map-control.tsx
index cee077362..eb78f42a9 100644
--- a/src/components/src/map/map-control.tsx
+++ b/src/components/src/map/map-control.tsx
@@ -104,26 +104,33 @@ function MapControlFactory(
MapLegendPanel
];
- const MapControl: React.FC<MapControlProps> = React.memo(
- ({actionComponents = DEFAULT_ACTIONS, ...props}) => {
- return (
- <StyledMapControl className="map-control" top={props.top}>
- {actionComponents.map((ActionComponent, index) => (
- <ActionComponent key={index} className="map-control-action" {...props} />
- ))}
- </StyledMapControl>
- );
- }
- );
-
- MapControl.defaultProps = {
- isSplit: false,
- top: 0,
- mapIndex: 0,
- logoComponent: LegendLogo,
- actionComponents: DEFAULT_ACTIONS
+ const MapControl: React.FC<MapControlProps> & {
+ defaultActionComponents: MapControlProps['actionComponents'];
+ } = ({
+ actionComponents = DEFAULT_ACTIONS,
+ isSplit = false,
+ top = 0,
+ mapIndex = 0,
+ logoComponent = LegendLogo,
+ ...restProps
+ }) => {
+ const actionComponentProps = {
+ isSplit,
+ mapIndex,
+ logoComponent,
+ ...restProps
+ };
+ return (
+ <StyledMapControl className="map-control" top={top}>
+ {actionComponents.map((ActionComponent, index) => (
+ <ActionComponent key={index} className="map-control-action" {...actionComponentProps} />
+ ))}
+ </StyledMapControl>
+ );
};
+ MapControl.defaultActionComponents = DEFAULT_ACTIONS;
+
MapControl.displayName = 'MapControl';
return MapControl;
diff --git a/src/components/src/modals/load-data-modal.tsx b/src/components/src/modals/load-data-modal.tsx
index c3788854e..51d418f05 100644
--- a/src/components/src/modals/load-data-modal.tsx
+++ b/src/components/src/modals/load-data-modal.tsx
@@ -63,10 +63,36 @@ export function LoadDataModalFactory(
FileUpload: ReturnType<typeof FileUploadFactory>,
LoadStorageMap: ReturnType<typeof LoadStorageMapFactory>
) {
- /** @type {React.FunctionComponent<LoadDataModalProps>} */
- const LoadDataModal: React.FC<LoadDataModalProps> = props => {
+ const defaultLoadingMethods = [
+ {
+ id: LOADING_METHODS.upload,
+ label: 'modal.loadData.upload',
+ elementType: FileUpload
+ },
+ {
+ id: LOADING_METHODS.storage,
+ label: 'modal.loadData.storage',
+ elementType: LoadStorageMap
+ }
+ ];
+
+ const LoadDataModal: React.FC<LoadDataModalProps> & {
+ defaultLoadingMethods: LoadDataModalProps['loadingMethods'];
+ } = ({
+ onFileUpload = noop,
+ fileLoading = false,
+ loadingMethods = defaultLoadingMethods,
+ isCloudMapLoading,
+ ...restProps
+ }) => {
const intl = useIntl();
- const {loadingMethods, isCloudMapLoading} = props;
+ const currentModalProps = {
+ ...restProps,
+ onFileUpload,
+ fileLoading,
+ isCloudMapLoading
+ };
+ // const {loadingMethods, isCloudMapLoading} = props;
const [currentMethod, toggleMethod] = useState(getDefaultMethod(loadingMethods));
const ElementType = currentMethod?.elementType;
@@ -81,28 +107,13 @@ export function LoadDataModalFactory(
{isCloudMapLoading ? (
<LoadingDialog size={64} />
) : (
- ElementType && <ElementType key={currentMethod?.id} intl={intl} {...props} />
+ ElementType && <ElementType key={currentMethod?.id} intl={intl} {...currentModalProps} />
)}
</StyledLoadDataModal>
);
};
- LoadDataModal.defaultProps = {
- onFileUpload: noop,
- fileLoading: false,
- loadingMethods: [
- {
- id: LOADING_METHODS.upload,
- label: 'modal.loadData.upload',
- elementType: FileUpload
- },
- {
- id: LOADING_METHODS.storage,
- label: 'modal.loadData.storage',
- elementType: LoadStorageMap
- }
- ]
- };
+ LoadDataModal.defaultLoadingMethods = defaultLoadingMethods;
return LoadDataModal;
}
diff --git a/src/components/src/modals/modal-tabs.tsx b/src/components/src/modals/modal-tabs.tsx
index 1b29946fd..e77f49c17 100644
--- a/src/components/src/modals/modal-tabs.tsx
+++ b/src/components/src/modals/modal-tabs.tsx
@@ -4,7 +4,6 @@
import React, {useCallback} from 'react';
import classnames from 'classnames';
import styled from 'styled-components';
-import PropTypes from 'prop-types';
import {media} from '@kepler.gl/styles';
import {FormattedMessage, useIntl} from 'react-intl';
import {LoadingMethod} from './load-data-modal';
@@ -66,6 +65,11 @@ interface ModalTabItemProps {
toggleMethod: (method: LoadingMethod) => void;
}
+interface ModalTabProps {
+ loadingMethods: LoadingMethod[];
+ toggleMethod: (method: LoadingMethod) => void;
+ currentMethod?: string;
+}
export const ModalTabItem: React.FC<ModalTabItemProps> = ({
currentMethod,
method,
@@ -89,7 +93,11 @@ export const ModalTabItem: React.FC<ModalTabItemProps> = ({
};
function ModalTabsFactory() {
- const ModalTabs = ({currentMethod, toggleMethod, loadingMethods}) => (
+ const ModalTabs: React.FC<ModalTabProps> = ({
+ currentMethod,
+ toggleMethod = noop,
+ loadingMethods = []
+ }) => (
<ModalTab className="load-data-modal__tab">
<div className="load-data-modal__tab__inner">
{loadingMethods.map(method => (
@@ -104,18 +112,6 @@ function ModalTabsFactory() {
</ModalTab>
);
- ModalTabs.propTypes = {
- toggleMethod: PropTypes.func.isRequired,
- currentMethod: PropTypes.string,
- loadingMethods: PropTypes.arrayOf(PropTypes.object)
- };
-
- ModalTabs.defaultProps = {
- toggleMethod: noop,
- currentMethod: null,
- loadingMethods: []
- };
-
return ModalTabs;
}
diff --git a/src/components/src/side-panel.tsx b/src/components/src/side-panel.tsx
index ee73d7d9c..acb9fbbcf 100644
--- a/src/components/src/side-panel.tsx
+++ b/src/components/src/side-panel.tsx
@@ -27,7 +27,6 @@ import MapManagerFactory from './side-panel/map-manager';
import CustomPanelsFactory from './side-panel/custom-panel';
import styled from 'styled-components';
-import get from 'lodash.get';
import {SidePanelProps, SidePanelItem} from './types';
export const StyledSidePanelContent = styled.div`
@@ -84,16 +83,20 @@ export default function SidePanelFactory(
};
// We should defined sidebar panels here but keeping them for backward compatible
- const fullPanels: SidePanelItem[] = SIDEBAR_PANELS.map(component => ({
+ const defaultSidePanels: SidePanelItem[] = SIDEBAR_PANELS.map(component => ({
...component,
component: SIDEBAR_COMPONENTS[component.id],
iconComponent: SIDEBAR_ICONS[component.id]
}));
- const getCustomPanelProps = get(CustomPanels, ['defaultProps', 'getProps']) || (() => ({}));
+ const fullPanels = [...defaultSidePanels, ...(CustomPanels.panels || [])];
+
+ const getCustomPanelProps = CustomPanels.getProps || (() => ({}));
// eslint-disable-next-line max-statements
- const SidePanel: React.FC<SidePanelProps> = (props: SidePanelProps) => {
+ const SidePanel: React.FC<SidePanelProps> & {defaultPanels: SidePanelProps['panels']} = (
+ props: SidePanelProps
+ ) => {
const {
appName,
appWebsite,
@@ -107,7 +110,7 @@ export default function SidePanelFactory(
layerOrder,
interactionConfig,
panels = fullPanels,
- mapInfo,
+ mapInfo = {},
mapSaved,
mapStateActions,
mapStyle,
@@ -162,7 +165,10 @@ export default function SidePanelFactory(
[activeSidePanel, panels]
);
- const customPanelProps = useMemo(() => getCustomPanelProps(props), [props]);
+ const customPanelProps = useMemo(() => getCustomPanelProps(props), [props]) as Record<
+ string,
+ any
+ >;
const PanelComponent = currentPanel?.component;
return (
@@ -238,10 +244,6 @@ export default function SidePanelFactory(
);
};
- SidePanel.defaultProps = {
- panels: fullPanels,
- mapInfo: {}
- };
-
+ SidePanel.defaultPanels = fullPanels;
return SidePanel;
}
diff --git a/src/components/src/side-panel/common/source-data-selector.tsx b/src/components/src/side-panel/common/source-data-selector.tsx
index 5c424f8c0..8e95d0adc 100644
--- a/src/components/src/side-panel/common/source-data-selector.tsx
+++ b/src/components/src/side-panel/common/source-data-selector.tsx
@@ -8,8 +8,6 @@ import DatasetTagFactory from './dataset-tag';
import {FormattedMessage} from '@kepler.gl/localization';
import {DatasetItemProps, SourceDataSelectorProps} from './types';
-const defaultPlaceHolder = 'Select A Dataset';
-
SourceDataSelectorFactory.deps = [DatasetTagFactory];
export default function SourceDataSelectorFactory(
@@ -22,7 +20,7 @@ export default function SourceDataSelectorFactory(
datasets,
disabled,
onSelect,
- defaultValue,
+ defaultValue = 'Select A Dataset',
inputTheme
}: SourceDataSelectorProps) => {
const dsOptions = useMemo(
@@ -62,8 +60,5 @@ export default function SourceDataSelectorFactory(
);
};
- SourceDataSelector.defaultProps = {
- defaultValue: defaultPlaceHolder
- };
return SourceDataSelector;
}
diff --git a/src/components/src/side-panel/custom-panel.tsx b/src/components/src/side-panel/custom-panel.tsx
index 2c23007eb..1472803e1 100644
--- a/src/components/src/side-panel/custom-panel.tsx
+++ b/src/components/src/side-panel/custom-panel.tsx
@@ -2,37 +2,40 @@
// Copyright contributors to the kepler.gl project
import React from 'react';
-import {SidePanelItem} from '../types';
+import {SidePanelItem, SidePanelProps} from '../types';
+import {RGBColor} from '@kepler.gl/types';
-export type CustomPanelsProps<P> = {
+export type CustomPanelsStaticProps<P> = {
panels: SidePanelItem[];
- getProps?: (props: SidePanelItem) => P;
+ getProps?: (props: SidePanelProps) => P;
+};
+export type CustomPanelsProps = {
+ activeSidePanel: string | null;
+ updateTableColor: (dataId: string, newColor: RGBColor) => void;
};
// This is a dummy component that can be replaced to inject more side panel sub panels into the side bar
function CustomPanelsFactory<P>() {
- const CustomPanels: React.FC<CustomPanelsProps<P>> = () => {
+ const CustomPanels: React.FC<CustomPanelsProps> & CustomPanelsStaticProps<P> = () => {
return <div />;
};
+ // provide a list of additional panels
+ CustomPanels.panels = [
+ // {
+ // id: 'rocket',
+ // label: 'Rocket',
+ // iconComponent: Icons.Rocket
+ // },
+ // {
+ // id: 'chart',
+ // label: 'Chart',
+ // iconComponent: Icons.LineChart
+ // }
+ ];
- CustomPanels.defaultProps = {
- // provide a list of additional panels
- panels: [
- // {
- // id: 'rocket',
- // label: 'Rocket',
- // iconComponent: Icons.Rocket
- // },
- // {
- // id: 'chart',
- // label: 'Chart',
- // iconComponent: Icons.LineChart
- // }
- ],
- // prop selector from side panel props
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- getProps: (sidePanelProps: SidePanelItem) => ({} as P)
- };
+ // prop selector from side panel props
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ CustomPanels.getProps = (sidePanelProps: SidePanelProps) => ({} as P);
return CustomPanels;
}
diff --git a/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx b/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx
index 37c62662d..43dcbe0d0 100644
--- a/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx
+++ b/src/components/src/side-panel/interaction-panel/tooltip-config/tooltip-chicklet.tsx
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
-import React, {Component, ComponentType} from 'react';
+import React, {useState} from 'react';
import styled from 'styled-components';
import classnames from 'classnames';
import {DraggableAttributes} from '@dnd-kit/core';
@@ -12,9 +12,9 @@ import DropdownList from '../../../common/item-selector/dropdown-list';
import {FormattedMessage} from '@kepler.gl/localization';
import {TimeLabelFormat, TooltipFields} from '@kepler.gl/types';
import {getFormatValue, getFormatLabels} from '@kepler.gl/utils';
-import onClickOutside from 'react-onclickoutside';
import TippyTooltip from '../../../common/tippy-tooltip';
import {TooltipFormat} from '@kepler.gl/constants';
+import useOnClickOutside from '../../../hooks/use-on-click-outside';
interface TooltipChickletProps {
disabled: boolean;
@@ -131,142 +131,120 @@ function TooltipChickletFactory(
onChange: (cfg: TooltipConfig) => void,
fields: TooltipFields[],
onDisplayFormatChange
-): ComponentType<TooltipChickletProps> {
- class TooltipChicklet extends Component<TooltipChickletProps> {
- state = {
- show: false
- };
- private node!: HTMLDivElement | null;
-
- componentDidMount() {
- document.addEventListener('mousedown', this.handleClickOutside, false);
+): React.FC<TooltipChickletProps> {
+ const TooltipChicklet: React.FC<TooltipChickletProps> = (props: TooltipChickletProps) => {
+ const {
+ disabled,
+ item,
+ displayOption,
+ remove,
+ attributes,
+ listeners,
+ setNodeRef,
+ transform,
+ transition,
+ isDragging
+ } = props;
+
+ const [show, setShow] = useState(false);
+ const ref = useOnClickOutside<HTMLDivElement>(() => setShow(false));
+ // const {show} = this.state;
+ const tooltipField = config.fieldsToShow[dataId].find(
+ fieldToShow => fieldToShow.name === item.name
+ );
+ if (!tooltipField) {
+ return null;
}
-
- componentWillUnmount() {
- document.removeEventListener('mousedown', this.handleClickOutside, false);
+ const field = fields.find(f => f.name === tooltipField.name);
+ if (!field) {
+ return null;
}
-
- handleClickOutside = (e: any) => {
- if (this.node?.contains(e.target)) {
- return;
- }
- };
-
- render() {
- const {
- disabled,
- item,
- displayOption,
- remove,
- attributes,
- listeners,
- setNodeRef,
- transform,
- transition,
- isDragging
- } = this.props;
-
- const {show} = this.state;
- const tooltipField = config.fieldsToShow[dataId].find(
- fieldToShow => fieldToShow.name === item.name
- );
- if (!tooltipField) {
- return null;
- }
- const field = fields.find(f => f.name === tooltipField.name);
- if (!field) {
- return null;
- }
- const formatLabels = getFormatLabels(fields, tooltipField.name);
- const hasFormat = Boolean(field.displayFormat);
- const selectionIndex = formatLabels.findIndex(
- fl => getFormatValue(fl) === field.displayFormat
- );
- const hashStyle = show ? hashStyles.SHOW : hasFormat ? hashStyles.ACTIVE : null;
-
- return (
- <SortableStyledItem
- ref={setNodeRef}
- className={classnames('sortable-layer-items', {sorting: isDragging})}
- transform={CSS.Translate.toString(transform)}
- transition={transition || ''}
- {...attributes}
- >
- <ChickletButton ref={node => (this.node = node)}>
- <StyledDragHandle {...listeners}>
- <VertDots height="12px" />
- </StyledDragHandle>
- <StyledTag title={displayOption(item)}>{displayOption(item)}</StyledTag>
- {formatLabels.length > 1 && (
- <ChickletAddonWrapper>
- <TippyTooltip
- placement="top"
- render={() => (
- <span>
- {hasFormat ? (
- getFormatTooltip(formatLabels, field.displayName)
- ) : (
- <FormattedMessage id={'fieldSelector.formatting'} />
- )}
- </span>
- )}
- >
- <ChickletAddon>
- <IconDiv status={hashStyle}>
- <Hash
- height="8px"
- onClick={e => {
- e.stopPropagation();
- this.setState({show: Boolean(!show)});
- }}
- />
- </IconDiv>
- </ChickletAddon>
- </TippyTooltip>
- {show && (
- <StyledPopover>
- <DropdownList
- options={formatLabels}
- selectionIndex={selectionIndex}
- displayOption={option => (option as TooltipFormat).label}
- onOptionSelected={(result, e) => {
+ const formatLabels = getFormatLabels(fields, tooltipField.name);
+ const hasFormat = Boolean(field.displayFormat);
+ const selectionIndex = formatLabels.findIndex(fl => getFormatValue(fl) === field.displayFormat);
+ const hashStyle = show ? hashStyles.SHOW : hasFormat ? hashStyles.ACTIVE : null;
+
+ return (
+ <SortableStyledItem
+ ref={setNodeRef}
+ className={classnames('sortable-layer-items', {sorting: isDragging})}
+ transform={CSS.Translate.toString(transform)}
+ transition={transition || ''}
+ {...attributes}
+ >
+ <ChickletButton>
+ <StyledDragHandle {...listeners}>
+ <VertDots height="12px" />
+ </StyledDragHandle>
+ <StyledTag title={displayOption(item)}>{displayOption(item)}</StyledTag>
+ {formatLabels.length > 1 && (
+ <ChickletAddonWrapper>
+ <TippyTooltip
+ placement="top"
+ render={() => (
+ <span>
+ {hasFormat ? (
+ getFormatTooltip(formatLabels, field.displayName)
+ ) : (
+ <FormattedMessage id={'fieldSelector.formatting'} />
+ )}
+ </span>
+ )}
+ >
+ <ChickletAddon>
+ <IconDiv status={hashStyle}>
+ <Hash
+ height="8px"
+ onClick={e => {
e.stopPropagation();
- this.setState({
- show: false
- });
-
- const displayFormat = getFormatValue(result);
- const oldFieldsToShow = config.fieldsToShow[dataId];
- const fieldsToShow = oldFieldsToShow.map(fieldToShow => {
- return fieldToShow.name === tooltipField.name
- ? {
- name: tooltipField.name,
- format: displayFormat
- }
- : fieldToShow;
- });
- const newConfig = {
- ...config,
- fieldsToShow: {
- ...config.fieldsToShow,
- [dataId]: fieldsToShow
- }
- };
- onChange(newConfig);
- onDisplayFormatChange(dataId, field.name, displayFormat);
+ setShow(Boolean(!show));
}}
/>
- </StyledPopover>
- )}
- </ChickletAddonWrapper>
- )}
- <Delete onClick={disabled ? null : remove} />
- </ChickletButton>
- </SortableStyledItem>
- );
- }
- }
- return onClickOutside(TooltipChicklet);
+ </IconDiv>
+ </ChickletAddon>
+ </TippyTooltip>
+ {show && (
+ <StyledPopover ref={ref}>
+ <DropdownList
+ options={formatLabels}
+ selectionIndex={selectionIndex}
+ displayOption={option => (option as TooltipFormat).label}
+ onOptionSelected={(result, e) => {
+ e.stopPropagation();
+ setShow(false);
+
+ const displayFormat = getFormatValue(result);
+ const oldFieldsToShow = config.fieldsToShow[dataId];
+ const fieldsToShow = oldFieldsToShow.map(fieldToShow => {
+ return fieldToShow.name === tooltipField.name
+ ? {
+ name: tooltipField.name,
+ format: displayFormat
+ }
+ : fieldToShow;
+ });
+ const newConfig = {
+ ...config,
+ fieldsToShow: {
+ ...config.fieldsToShow,
+ [dataId]: fieldsToShow
+ }
+ };
+ onChange(newConfig);
+ onDisplayFormatChange(dataId, field.name, displayFormat);
+ }}
+ />
+ </StyledPopover>
+ )}
+ </ChickletAddonWrapper>
+ )}
+ <Delete onClick={disabled ? null : remove} />
+ </ChickletButton>
+ </SortableStyledItem>
+ );
+ };
+
+ return TooltipChicklet;
}
export default TooltipChickletFactory;
diff --git a/src/components/src/side-panel/layer-panel/color-palette.tsx b/src/components/src/side-panel/layer-panel/color-palette.tsx
index 7631344b8..2b0251602 100644
--- a/src/components/src/side-panel/layer-panel/color-palette.tsx
+++ b/src/components/src/side-panel/layer-panel/color-palette.tsx
@@ -14,14 +14,6 @@ type ColorPaletteProps = {
isReversed?: boolean;
};
-const defaultProps = {
- height: 10,
- colors: [],
- className: '',
- isSelected: false,
- isReversed: false
-};
-
const PaletteWrapper = styled.div.attrs({
className: 'color-range-palette__inner'
})`
@@ -52,11 +44,11 @@ const StyledColorBlock = styled.div.attrs({
`;
const ColorPalette: React.FC<ColorPaletteProps> = ({
- colors,
- height,
- className,
- isSelected,
- isReversed
+ colors = [],
+ height = 10,
+ className = '',
+ isSelected = false,
+ isReversed = false
}) => (
<PaletteContainer className={className} isSelected={isSelected}>
<PaletteWrapper style={{height, transform: `scale(${isReversed ? -1 : 1}, 1)`}}>
@@ -67,6 +59,4 @@ const ColorPalette: React.FC<ColorPaletteProps> = ({
</PaletteContainer>
);
-ColorPalette.defaultProps = defaultProps;
-
export default ColorPalette;
diff --git a/src/components/src/side-panel/layer-panel/color-selector.tsx b/src/components/src/side-panel/layer-panel/color-selector.tsx
index cbe0aa196..32d37c357 100644
--- a/src/components/src/side-panel/layer-panel/color-selector.tsx
+++ b/src/components/src/side-panel/layer-panel/color-selector.tsx
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
-import React, {Component, createRef, MouseEvent, ComponentType} from 'react';
+import React, {MouseEvent, ComponentType, useState, useCallback} from 'react';
import styled from 'styled-components';
import {FormattedMessage} from 'react-intl';
import {rgbToHex} from '@kepler.gl/utils';
@@ -9,10 +9,10 @@ import SingleColorPalette from './single-color-palette';
import ColorRangeSelector from './color-range-selector';
import ColorPalette from './color-palette';
import {StyledPanelDropdown, PanelLabel} from '../../common/styled-components';
-import onClickOutside from 'react-onclickoutside';
import {ColorRange} from '@kepler.gl/constants';
import RangeSliderFactory from '../../common/range-slider';
import {NestedPartial, RGBColor, RGBAColor, ColorUI} from '@kepler.gl/types';
+import useOnClickOutside from '../../hooks/use-on-click-outside';
type ColorSelectorInputProps = {
active: boolean;
@@ -87,147 +87,155 @@ export const InputBoxContainer = styled.div`
ColorSelectorFactory.deps = [RangeSliderFactory];
function ColorSelectorFactory(RangeSlider): ComponentType<ColorSelectorProps> {
- class ColorSelector extends Component<ColorSelectorProps> {
- static defaultProps = {
- colorSets: []
- };
-
- state = {
- showDropdown: false
- };
-
- node = createRef<HTMLDivElement>();
-
- handleClickOutside = () => {
- if (this.props.colorUI && Number.isInteger(this.props.colorUI.showSketcher)) {
- // if sketcher is open, let sketch to close itself first
+ const ColorSelector: React.FC<ColorSelectorProps> = ({
+ colorSets = [],
+ colorUI,
+ inputTheme,
+ disabled,
+ useOpacity,
+ setColorUI
+ }) => {
+ const [showDropdown, setShowDropdown] = useState(false);
+ const showSketcher = colorUI ? colorUI.showSketcher : false;
+
+ const editing = colorUI ? colorUI.showDropdown : showDropdown;
+ const currentEditing =
+ typeof editing === 'number' && colorSets[editing] && typeof colorSets[editing] === 'object';
+
+ const closePanelDropdown = useCallback(() => {
+ if (editing === false) {
return;
}
- this._closePanelDropdown();
- };
-
- _getEditing = () => {
- return this.props.colorUI ? this.props.colorUI.showDropdown : this.state.showDropdown;
- };
-
- _closePanelDropdown = () => {
- if (this._getEditing() === false) {
- return;
- }
-
- if (this.props.setColorUI) {
- this.props.setColorUI({showDropdown: false, showSketcher: false});
- } else {
- this.setState({showDropdown: false});
- }
- };
-
- _onSelectColor = (color: RGBColor | ColorRange, e: MouseEvent) => {
- e.stopPropagation();
- const editing = this._getEditing();
- const colorSet = typeof editing === 'number' && this.props.colorSets[editing];
- if (colorSet) {
- this._setColor(colorSet, color, colorSet.selectedColor[3]);
- }
- };
-
- _onSelectOpacity = (opacity: number[], e: MouseEvent) => {
- if (e) e.stopPropagation();
- const editing = this._getEditing();
- const colorSet = typeof editing === 'number' && this.props.colorSets[editing];
- if (colorSet) {
- this._setColor(colorSet, colorSet.selectedColor, Math.round(opacity[1] * 255));
- }
- };
-
- _setColor = (colorSet: ColorSet, color: RGBColor | RGBAColor | ColorRange, opacity: number) => {
- if (this.props.useOpacity && Array.isArray(color)) {
- colorSet.setColor([...color.slice(0, 3), opacity] as RGBAColor);
+ if (setColorUI) {
+ setColorUI({showDropdown: false, showSketcher: false});
} else {
- colorSet.setColor(color);
+ setShowDropdown(false);
}
- };
+ }, [editing, setColorUI, setShowDropdown]);
- _showDropdown = (e, i) => {
- e.stopPropagation();
- e.preventDefault();
-
- if (this.props.setColorUI) {
- this.props.setColorUI({showDropdown: i});
- } else {
- this.setState({showDropdown: i});
+ const handleClickOutside = useCallback(() => {
+ if (Number.isInteger(showSketcher)) {
+ // if sketcher is open, let sketch to close itself first
+ return;
}
- };
-
- render() {
- const {colorSets, useOpacity, disabled, inputTheme, colorUI} = this.props;
-
- const editing = this._getEditing();
- const currentEditing =
- typeof editing === 'number' && colorSets[editing] && typeof colorSets[editing] === 'object';
-
- return (
- <div className="color-selector" ref={this.node}>
- <InputBoxContainer>
- {colorSets.map((cSet, i) => (
- <div className="color-select__input-group" key={i}>
- <ColorSelectorInput
- className="color-selector__selector"
- active={editing === i}
- disabled={disabled}
- inputTheme={inputTheme}
- onMouseDown={e => this._showDropdown(e, i)}
- >
- {cSet.isRange ? (
- <ColorPalette colors={(cSet.selectedColor as ColorRange).colors} />
- ) : (
- <ColorBlock
- className="color-selector__selector__block"
- backgroundcolor={cSet.selectedColor as RGBColor}
- />
- )}
- {cSet.label ? (
- <div className="color-selector__selector__label">{cSet.label}</div>
- ) : null}
- </ColorSelectorInput>
- </div>
- ))}
- </InputBoxContainer>
- {currentEditing ? (
- <StyledPanelDropdown className="color-selector__dropdown">
- {colorSets[editing as number].isRange ? (
- <ColorRangeSelector
- selectedColorRange={colorSets[editing as number].selectedColor as ColorRange}
- onSelectColorRange={this._onSelectColor}
- setColorPaletteUI={this.props.setColorUI}
- colorPaletteUI={colorUI as ColorUI}
- />
- ) : (
- <SingleColorPalette
- selectedColor={rgbToHex(colorSets[editing as number].selectedColor as RGBColor)}
- onSelectColor={this._onSelectColor}
- />
- )}
- {useOpacity ? (
- <OpacitySliderWrapper>
- <PanelLabel>
- <FormattedMessage id="color.opacity" />
- </PanelLabel>
- <RangeSlider
- {...OPACITY_SLIDER_PROPS}
- value1={colorSets[editing as number].selectedColor[3] / 255}
- onChange={this._onSelectOpacity}
+ closePanelDropdown();
+ }, [showSketcher, closePanelDropdown]);
+
+ const ref = useOnClickOutside<HTMLDivElement>(handleClickOutside);
+
+ const onSetColor = useCallback(
+ (colorSet: ColorSet, color: RGBColor | RGBAColor | ColorRange, opacity: number) => {
+ const {setColor} = colorSet || {};
+ if (!setColor) {
+ return;
+ }
+ if (useOpacity && Array.isArray(color)) {
+ setColor([...color.slice(0, 3), opacity] as RGBAColor);
+ } else {
+ setColor(color);
+ }
+ },
+ [useOpacity]
+ );
+
+ const onSelectColor = useCallback(
+ (color: RGBColor | ColorRange, e: MouseEvent) => {
+ e.stopPropagation();
+ const colorSet = typeof editing === 'number' && colorSets[editing];
+ if (colorSet) {
+ onSetColor(colorSet, color, colorSet.selectedColor[3]);
+ }
+ },
+ [editing, colorSets, onSetColor]
+ );
+
+ const onSelectOpacity = useCallback(
+ (opacity: number[], e: MouseEvent) => {
+ if (e) e.stopPropagation();
+ const colorSet = typeof editing === 'number' && colorSets[editing];
+ if (colorSet) {
+ onSetColor(colorSet, colorSet.selectedColor, Math.round(opacity[1] * 255));
+ }
+ },
+ [onSetColor, colorSets, editing]
+ );
+
+ const onToggleDropdown = useCallback(
+ (e, i) => {
+ e.stopPropagation();
+ e.preventDefault();
+
+ if (setColorUI) {
+ setColorUI({showDropdown: i});
+ } else {
+ setShowDropdown(i);
+ }
+ },
+ [setColorUI, setShowDropdown]
+ );
+
+ return (
+ <div className="color-selector">
+ <InputBoxContainer>
+ {colorSets.map((cSet, i) => (
+ <div className="color-select__input-group" key={i}>
+ <ColorSelectorInput
+ className="color-selector__selector"
+ active={editing === i}
+ disabled={disabled}
+ inputTheme={inputTheme}
+ onClick={e => onToggleDropdown(e, i)}
+ >
+ {cSet.isRange ? (
+ <ColorPalette colors={(cSet.selectedColor as ColorRange).colors} />
+ ) : (
+ <ColorBlock
+ className="color-selector__selector__block"
+ backgroundcolor={cSet.selectedColor as RGBColor}
/>
- </OpacitySliderWrapper>
- ) : null}
- </StyledPanelDropdown>
- ) : null}
- </div>
- );
- }
- }
- return onClickOutside(ColorSelector) as ComponentType<ColorSelectorProps>;
+ )}
+ {cSet.label ? (
+ <div className="color-selector__selector__label">{cSet.label}</div>
+ ) : null}
+ </ColorSelectorInput>
+ </div>
+ ))}
+ </InputBoxContainer>
+ {currentEditing ? (
+ <StyledPanelDropdown className="color-selector__dropdown" ref={ref}>
+ {colorSets[editing as number].isRange ? (
+ <ColorRangeSelector
+ selectedColorRange={colorSets[editing as number].selectedColor as ColorRange}
+ onSelectColorRange={onSelectColor}
+ setColorPaletteUI={setColorUI}
+ colorPaletteUI={colorUI as ColorUI}
+ />
+ ) : (
+ <SingleColorPalette
+ selectedColor={rgbToHex(colorSets[editing as number].selectedColor as RGBColor)}
+ onSelectColor={onSelectColor}
+ />
+ )}
+ {useOpacity ? (
+ <OpacitySliderWrapper>
+ <PanelLabel>
+ <FormattedMessage id="color.opacity" />
+ </PanelLabel>
+ <RangeSlider
+ {...OPACITY_SLIDER_PROPS}
+ value1={colorSets[editing as number].selectedColor[3] / 255}
+ onChange={onSelectOpacity}
+ />
+ </OpacitySliderWrapper>
+ ) : null}
+ </StyledPanelDropdown>
+ ) : null}
+ </div>
+ );
+ };
+
+ return ColorSelector;
}
export default ColorSelectorFactory;
diff --git a/src/components/src/side-panel/layer-panel/custom-picker.tsx b/src/components/src/side-panel/layer-panel/custom-picker.tsx
index 82f3c70db..522ee3af2 100644
--- a/src/components/src/side-panel/layer-panel/custom-picker.tsx
+++ b/src/components/src/side-panel/layer-panel/custom-picker.tsx
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
-import React, {Component} from 'react';
+import React, {useMemo} from 'react';
import styled, {withTheme} from 'styled-components';
import {SketchPicker, ColorChangeHandler} from 'react-color';
-import onClickOutside from 'react-onclickoutside';
-import {createSelector} from 'reselect';
+import useOnClickOutside from '../../hooks/use-on-click-outside';
+
// This was put in because 3rd party library react-color doesn't yet cater for customized color of child component <SketchField> which contains HEX/RGB input text box
// Issue raised: https://github.com/casesandberg/react-color/issues/631
@@ -37,37 +37,32 @@ const StyledPicker = styled.div`
const PRESET_COLORS = [];
-class CustomPicker extends Component<CustomPickerProps> {
- themeSelector = (props: CustomPickerProps) => props.theme;
- pickerStyleSelector = createSelector(this.themeSelector, theme => ({
- picker: {
- width: '200px',
- padding: '10px 10px 8px',
- boxSizing: 'initial',
- background: theme.panelBackground
- }
- }));
-
- handleClickOutside = () => {
- this.props.onSwatchClose();
- };
+const CustomPicker: React.FC<CustomPickerProps> = props => {
+ const {color, onChange, theme} = props;
+ const ref = useOnClickOutside<HTMLDivElement>(props.onSwatchClose);
+ const pickerStyle = useMemo(
+ () => ({
+ picker: {
+ width: '200px',
+ padding: '10px 10px 8px',
+ boxSizing: 'initial',
+ background: theme.panelBackground
+ }
+ }),
+ [theme.panelBackground]
+ );
- render() {
- const {color, onChange} = this.props;
- const pickerStyle = this.pickerStyleSelector(this.props);
-
- return (
- <StyledPicker>
- <SketchPicker
- color={color}
- onChange={onChange}
- presetColors={PRESET_COLORS}
- styles={pickerStyle}
- disableAlpha
- />
- </StyledPicker>
- );
- }
-}
+ return (
+ <StyledPicker ref={ref}>
+ <SketchPicker
+ color={color}
+ onChange={onChange}
+ presetColors={PRESET_COLORS}
+ styles={pickerStyle}
+ disableAlpha
+ />
+ </StyledPicker>
+ );
+};
-export default withTheme(onClickOutside(CustomPicker) as React.ComponentType<CustomPickerProps>);
+export default withTheme(CustomPicker);
diff --git a/src/components/src/side-panel/layer-panel/layer-config-group.tsx b/src/components/src/side-panel/layer-panel/layer-config-group.tsx
index 54fe40971..5201aca18 100644
--- a/src/components/src/side-panel/layer-panel/layer-config-group.tsx
+++ b/src/components/src/side-panel/layer-panel/layer-config-group.tsx
@@ -147,6 +147,9 @@ export function LayerConfigGroupLabelFactory(InfoHelper: ReturnType<typeof InfoH
LayerConfigGroupFactory.deps = [LayerConfigGroupLabelFactory];
+function nop() {
+ return;
+}
function LayerConfigGroupFactory(
LayerConfigGroupLabel: ReturnType<typeof LayerConfigGroupLabelFactory>
) {
@@ -155,11 +158,11 @@ function LayerConfigGroupFactory(
children,
property,
layer,
- onChange,
- collapsible,
- description,
- disabled,
- expanded,
+ onChange = nop,
+ collapsible = false,
+ description = '',
+ disabled = false,
+ expanded = false,
IconComponent = VertThreeDots
}) => {
const [collapsed, toggleCollapsed] = useState(!expanded);
@@ -193,15 +196,6 @@ function LayerConfigGroupFactory(
);
};
- LayerConfigGroup.defaultProps = {
- collapsible: false,
- expanded: false,
- onChange: () => {
- return;
- },
- description: '',
- disabled: false
- };
return LayerConfigGroup;
}
diff --git a/src/components/src/side-panel/layer-panel/layer-panel-header.tsx b/src/components/src/side-panel/layer-panel/layer-panel-header.tsx
index 721f84b38..0049058fc 100644
--- a/src/components/src/side-panel/layer-panel/layer-panel-header.tsx
+++ b/src/components/src/side-panel/layer-panel/layer-panel-header.tsx
@@ -84,11 +84,6 @@ type HeaderActionSectionProps = {
export type LayerPanelHeaderActionSectionProps = LayerPanelHeaderProps & HeaderActionSectionProps;
-export const defaultProps = {
- isDragNDropEnabled: true,
- showRemoveLayer: true
-};
-
const getBorderCss = status =>
css`
border-top: 2px solid ${({theme}) => theme.notificationColors[status]};
@@ -282,7 +277,7 @@ export function LayerPanelHeaderActionSectionFactory(
onDuplicateLayer,
onRemoveLayer,
onZoomToLayer,
- showRemoveLayer,
+ showRemoveLayer = true,
isEditingLabel,
// TODO: may not contain all necessary icons for all actions, e.g. actionIcons.duplicate. Need to to merge rather than replace
actionIcons = defaultActionIcons
@@ -386,7 +381,7 @@ function LayerPanelHeaderFactory(
const LayerPanelHeader: React.FC<LayerPanelHeaderProps> = props => {
const {
isConfigActive,
- isDragNDropEnabled,
+ isDragNDropEnabled = true,
isValid,
warning,
label,
@@ -436,8 +431,6 @@ function LayerPanelHeaderFactory(
);
};
- LayerPanelHeader.defaultProps = defaultProps;
-
return LayerPanelHeader;
}
diff --git a/src/components/src/side-panel/panel-dropdown.tsx b/src/components/src/side-panel/panel-dropdown.tsx
deleted file mode 100644
index 6a35f0b47..000000000
--- a/src/components/src/side-panel/panel-dropdown.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import React, {Component} from 'react';
-import {StyledPanelDropdown} from '../common/styled-components';
-import listensToClickOutside from 'react-onclickoutside';
-
-type ClickOutsideCloseDropdownProps = {
- show: boolean;
- type: string;
- className: string;
- onClose: (e: Event) => void;
- children?: React.ReactNode;
-};
-
-class ClickOutsideCloseDropdown extends Component<ClickOutsideCloseDropdownProps> {
- static defaultProps = {
- show: true,
- type: 'dark'
- };
-
- handleClickOutside = (e: Event) => {
- if (typeof this.props.onClose === 'function' && this.props.show) {
- this.props.onClose(e);
- }
- };
-
- render() {
- return (
- <StyledPanelDropdown type={this.props.type} className={this.props.className}>
- {this.props.children}
- </StyledPanelDropdown>
- );
- }
-}
-
-export default listensToClickOutside(ClickOutsideCloseDropdown);
diff --git a/src/components/src/side-panel/panel-header.tsx b/src/components/src/side-panel/panel-header.tsx
index 215f70e45..7d72548fa 100644
--- a/src/components/src/side-panel/panel-header.tsx
+++ b/src/components/src/side-panel/panel-header.tsx
@@ -5,15 +5,15 @@ import React, {Component, useCallback} from 'react';
import styled from 'styled-components';
import classnames from 'classnames';
import {createSelector} from 'reselect';
-import {Tooltip} from '../common/styled-components';
+import {StyledPanelDropdown, Tooltip} from '../common/styled-components';
import KeplerGlLogo from '../common/logo';
import {Save, DataTable, Save2, Picture, Db, Map as MapIcon, Share} from '../common/icons';
-import ClickOutsideCloseDropdown from './panel-dropdown';
import Toolbar from '../common/toolbar';
import ToolbarItem, {ToolbarItemProps} from '../common/toolbar-item';
import {FormattedMessage} from '@kepler.gl/localization';
import {UiState} from '@kepler.gl/types';
import {BaseProps} from '../common/icons';
+import useOnClickOutside from '../hooks/use-on-click-outside';
type StyledPanelActionProps = {
active?: boolean;
@@ -173,24 +173,23 @@ export {PanelAction};
export const PanelHeaderDropdownFactory = () => {
const PanelHeaderDropdown: React.FC<PanelHeaderDropdownProps> = ({items, show, onClose, id}) => {
+ const ref = useOnClickOutside<HTMLDivElement>(onClose);
return (
<StyledToolbar show={show} className={`${id}-dropdown`}>
- <ClickOutsideCloseDropdown
- className="panel-header-dropdown__inner"
- show={show}
- onClose={onClose}
- >
- {items.map(item => (
- <ToolbarItem
- id={item.key}
- key={item.key}
- label={item.label}
- icon={item.icon}
- onClick={item.onClick}
- onClose={onClose}
- />
- ))}
- </ClickOutsideCloseDropdown>
+ {show ? (
+ <StyledPanelDropdown type="dark" ref={ref} className="panel-header-dropdown__inner">
+ {items.map(item => (
+ <ToolbarItem
+ id={item.key}
+ key={item.key}
+ label={item.label}
+ icon={item.icon}
+ onClick={item.onClick}
+ onClose={onClose}
+ />
+ ))}
+ </StyledPanelDropdown>
+ ) : null}
</StyledToolbar>
);
};
@@ -215,52 +214,53 @@ export const SaveExportDropdownFactory = (
) => {
const dropdownItemsSelector = getDropdownItemsSelector();
- const SaveExportDropdown: React.FC<DropdownComponentProps> & {
- defaultProps: {items: ToolbarItemProps[]};
- } = props => (
- <PanelHeaderDropdown
- items={dropdownItemsSelector(props)}
- show={props.show}
- onClose={props.onClose}
- id="save-export"
- />
- );
+ const defaultItems = [
+ {
+ label: 'toolbar.exportImage',
+ icon: Picture,
+ key: 'image',
+ onClick: props => props.onExportImage
+ },
+ {
+ label: 'toolbar.exportData',
+ icon: DataTable,
+ key: 'data',
+ onClick: props => props.onExportData
+ },
+ {
+ label: 'toolbar.exportMap',
+ icon: MapIcon,
+ key: 'map',
+ onClick: props => props.onExportMap
+ },
+ {
+ label: 'toolbar.saveMap',
+ icon: Save2,
+ key: 'save',
+ onClick: props => props.onSaveMap
+ },
+ {
+ label: 'toolbar.shareMapURL',
+ icon: Share,
+ key: 'share',
+ onClick: props => props.onShareMap
+ }
+ ];
- SaveExportDropdown.defaultProps = {
- items: [
- {
- label: 'toolbar.exportImage',
- icon: Picture,
- key: 'image',
- onClick: props => props.onExportImage
- },
- {
- label: 'toolbar.exportData',
- icon: DataTable,
- key: 'data',
- onClick: props => props.onExportData
- },
- {
- label: 'toolbar.exportMap',
- icon: MapIcon,
- key: 'map',
- onClick: props => props.onExportMap
- },
- {
- label: 'toolbar.saveMap',
- icon: Save2,
- key: 'save',
- onClick: props => props.onSaveMap
- },
- {
- label: 'toolbar.shareMapURL',
- icon: Share,
- key: 'share',
- onClick: props => props.onShareMap
- }
- ]
+ const SaveExportDropdown: React.FC<DropdownComponentProps> & {
+ defaultItems: ToolbarItemProps[];
+ } = ({items = defaultItems, ...restProps}) => {
+ const props = {...restProps, items};
+ return (
+ <PanelHeaderDropdown
+ items={dropdownItemsSelector(props)}
+ show={props.show}
+ onClose={props.onClose}
+ id="save-export"
+ />
+ );
};
-
+ SaveExportDropdown.defaultItems = defaultItems;
return SaveExportDropdown;
};
SaveExportDropdownFactory.deps = [PanelHeaderDropdownFactory];
@@ -269,31 +269,34 @@ export const CloudStorageDropdownFactory = (
PanelHeaderDropdown: ReturnType<typeof PanelHeaderDropdownFactory>
) => {
const dropdownItemsSelector = getDropdownItemsSelector();
-
- const CloudStorageDropdown: React.FC<DropdownComponentProps> = props => (
- <PanelHeaderDropdown
- items={dropdownItemsSelector(props)}
- show={props.show}
- onClose={props.onClose}
- id="cloud-storage"
- />
- );
- CloudStorageDropdown.defaultProps = {
- items: [
- {
- label: 'Save',
- icon: Save2,
- key: 'save',
- onClick: props => props.onSaveToStorage
- },
- {
- label: 'Save As',
- icon: Save2,
- key: 'saveAs',
- onClick: props => props.onSaveAsToStorage
- }
- ]
+ const defaultItems = [
+ {
+ label: 'Save',
+ icon: Save2,
+ key: 'save',
+ onClick: props => props.onSaveToStorage
+ },
+ {
+ label: 'Save As',
+ icon: Save2,
+ key: 'saveAs',
+ onClick: props => props.onSaveAsToStorage
+ }
+ ];
+ const CloudStorageDropdown: React.FC<DropdownComponentProps> & {
+ defaultItems: DropdownComponentProps['items'];
+ } = ({items = defaultItems, ...restProps}) => {
+ const props = {...restProps, items};
+ return (
+ <PanelHeaderDropdown
+ items={dropdownItemsSelector(props)}
+ show={props.show}
+ onClose={props.onClose}
+ id="cloud-storage"
+ />
+ );
};
+ CloudStorageDropdown.defaultItems = defaultItems;
return CloudStorageDropdown;
};
CloudStorageDropdownFactory.deps = [PanelHeaderDropdownFactory];
diff --git a/src/utils/src/index.ts b/src/utils/src/index.ts
index 3c683c2fa..4366024bf 100644
--- a/src/utils/src/index.ts
+++ b/src/utils/src/index.ts
@@ -121,8 +121,5 @@ export type {Centroid} from './h3-utils';
export {getCentroid, idToPolygonGeo, h3IsValid, getHexFields} from './h3-utils';
// Application config
-export {
- getApplicationConfig,
- initApplicationConfig,
-} from '../../utils/src/application-config';
+export {getApplicationConfig, initApplicationConfig} from '../../utils/src/application-config';
export type {KeplerApplicationConfig} from '../../utils/src/application-config';
diff --git a/test/browser/components/side-panel/color-selector-test.js b/test/browser/components/side-panel/color-selector-test.js
index ad5558693..65363f9b5 100644
--- a/test/browser/components/side-panel/color-selector-test.js
+++ b/test/browser/components/side-panel/color-selector-test.js
@@ -107,7 +107,7 @@ test('Components -> LayerColorSelector.render -> render layer color', t => {
const csInput = wrapper.find(ColorSelectorInput);
t.equal(csInput.length, 1, 'should render 1 ColorSelectorInput');
- csInput.simulate('mousedown');
+ csInput.simulate('click');
t.ok(updateLayerColorUI.calledOnce, 'should call updateLayerColorUI');
t.ok(updateLayerVisConfig.notCalled, 'should not call updateLayerColorUI');
@@ -235,7 +235,7 @@ test('Components -> ArcLayerColorSelector.render -> render single color', t => {
const csInput = wrapper.find(ColorSelectorInput);
t.equal(csInput.length, 2, 'should render 2 ColorSelectorInput');
- csInput.at(1).simulate('mousedown');
+ csInput.at(1).simulate('click');
t.ok(updateLayerColorUI.calledOnce, 'should call updateLayerColorUI when mousedown 2nd block');
t.ok(
@@ -344,7 +344,7 @@ test('Components -> LayerColorRangeSelector.render -> ColorSelector', t => {
// simulate click
const csInput = wrapper.find(ColorSelectorInput);
t.equal(csInput.length, 1, 'should render 2 ColorSelectorInput');
- csInput.at(0).simulate('mousedown');
+ csInput.at(0).simulate('click');
t.ok(updateLayerColorUI.calledOnce, 'should call updateLayerColorUI when mousedown 2nd block');
t.ok(
@@ -774,7 +774,7 @@ test('Components -> ColorSelector.opacity', t => {
}, 'Mount should not fail');
// show palette
- wrapper.find('.color-selector__selector').at(0).invoke('onMouseDown')({
+ wrapper.find('.color-selector__selector').at(0).invoke('onClick')({
preventDefault() {},
stopPropagation() {}
});
diff --git a/test/browser/components/side-panel/side-panel-test.js b/test/browser/components/side-panel/side-panel-test.js
index 4f411426c..2af2ac22a 100644
--- a/test/browser/components/side-panel/side-panel-test.js
+++ b/test/browser/components/side-panel/side-panel-test.js
@@ -219,34 +219,31 @@ test('Components -> SidePanel -> render custom panel', t => {
return null;
};
- MyPanels.defaultProps = {
- getProps: props => ({
- layers: props.layers
- })
- };
+ MyPanels.getProps = props => ({
+ layers: props.layers
+ });
function CustomSidePanelsFactory() {
return MyPanels;
}
function CustomSidePanelFactory(...deps) {
- const CustomSidePanel = SidePanelFactory(...deps);
- CustomSidePanel.defaultProps = {
- ...CustomSidePanel.defaultProps,
- panels: [
- ...CustomSidePanel.defaultProps.panels,
- {
- id: 'rocket',
- label: 'Rocket',
- iconComponent: RocketIcon
- },
- {
- id: 'chart',
- label: 'Chart',
- iconComponent: ChartIcon
- }
- ]
- };
+ const SidePanel = SidePanelFactory(...deps);
+ const panels = [
+ ...SidePanel.defaultPanels,
+ {
+ id: 'rocket',
+ label: 'Rocket',
+ iconComponent: RocketIcon
+ },
+ {
+ id: 'chart',
+ label: 'Chart',
+ iconComponent: ChartIcon
+ }
+ ];
+
+ const CustomSidePanel = props => <SidePanel {...props} panels={panels} />;
return CustomSidePanel;
}
diff --git a/yarn.lock b/yarn.lock
index 5c032a69b..30b31c264 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2878,7 +2878,6 @@ __metadata:
"@types/react-lifecycles-compat": "npm:^3.0.1"
"@types/react-map-gl": "npm:^6.1.3"
"@types/react-modal": "npm:^3.13.1"
- "@types/react-onclickoutside": "npm:^6.7.4"
"@types/react-redux": "npm:^7.1.23"
"@types/react-virtualized": "npm:^9.21.30"
"@types/react-vis": "npm:1.11.7"
@@ -2920,7 +2919,6 @@ __metadata:
react-map-gl: "npm:^7.1.6"
react-markdown: "npm:^6.0.3"
react-modal: "npm:^3.12.1"
- react-onclickoutside: "npm:^6.7.1"
react-redux: "npm:^8.0.5"
react-sortable-hoc: "npm:^1.8.3"
react-time-picker: "npm:^6.2.0"
@@ -5577,15 +5575,6 @@ __metadata:
languageName: node
linkType: hard
-"@types/react-onclickoutside@npm:^6.7.4":
- version: 6.7.10
- resolution: "@types/react-onclickoutside@npm:6.7.10"
- dependencies:
- "@types/react": "npm:*"
- checksum: 10c0/2ce1c401e142fab4ce6d4212f85e01555c45e52c1e153de29c89e89ce33e2c771302c128e933382f330766db68274c2bdf829e893a6bce95f3791ef12697e826
- languageName: node
- linkType: hard
-
"@types/react-redux@npm:^7.1.23":
version: 7.1.33
resolution: "@types/react-redux@npm:7.1.33"
@@ -19576,7 +19565,7 @@ __metadata:
languageName: node
linkType: hard
-"react-onclickoutside@npm:^6.7.1, react-onclickoutside@npm:^6.9.0":
+"react-onclickoutside@npm:^6.9.0":
version: 6.13.1
resolution: "react-onclickoutside@npm:6.13.1"
peerDependencies: