Skip to content

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

[Feat] Improved data table rendering (#1010)

Shan He597e352cb025
diff --git a/examples/demo-app/src/app.js b/examples/demo-app/src/app.js
index fd682cc34..b9da3a01b 100644
--- a/examples/demo-app/src/app.js
+++ b/examples/demo-app/src/app.js
@@ -176,11 +176,11 @@ class App extends Component {
}
_loadSampleData() {
- // this._loadPointData();
- // this._loadGeojsonData();
+ this._loadPointData();
+ this._loadGeojsonData();
// this._loadTripGeoJson();
- // this._loadIconData();
- // this._loadH3HexagonData();
+ this._loadIconData();
+ this._loadH3HexagonData();
this._loadS2Data();
// this._loadScenegraphLayer();
}
diff --git a/package.json b/package.json
index a932cb69c..92e6382f9 100644
--- a/package.json
+++ b/package.json
@@ -92,6 +92,7 @@
"@turf/helpers": "^6.1.4",
"classnames": "^2.2.1",
"colorbrewer": "^1.0.0",
+ "copy-to-clipboard": "^3.3.1",
"d3-array": "^1.2.0",
"d3-axis": "^1.0.8",
"d3-brush": "^1.0.4",
@@ -102,6 +103,7 @@
"d3-request": "^1.0.6",
"d3-scale": "^1.0.6",
"decimal.js": "^10.2.0",
+ "exenv": "^1.2.2",
"fuzzy": "^0.1.3",
"global": "^4.3.0",
"h3-js": "^3.1.0",
@@ -201,7 +203,7 @@
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.13.0",
"gl": "^4.2.2",
- "jsdom": "^11.1.0",
+ "jsdom": "^16.2.1",
"json-loader": "^0.5.4",
"nyc": "^11.4.1",
"ocular-dev-tools": "^0.0.30",
diff --git a/src/actions/vis-state-actions.js b/src/actions/vis-state-actions.js
index 4df22000b..080bc556c 100644
--- a/src/actions/vis-state-actions.js
+++ b/src/actions/vis-state-actions.js
@@ -275,6 +275,47 @@ export function showDatasetTable(dataId) {
};
}
+/**
+ * Sort dataset column, for table display
+ * @param {string} dataId
+ * @param {string} column
+ * @param {string} mode
+ */
+export function sortTableColumn(dataId, column, mode) {
+ return {
+ type: ActionTypes.SORT_TABLE_COLUMN,
+ dataId,
+ column,
+ mode
+ };
+}
+
+/**
+ * Pin dataset column, for table display
+ * @param {string} dataId
+ * @param {string} column
+ */
+export function pinTableColumn(dataId, column) {
+ return {
+ type: ActionTypes.PIN_TABLE_COLUMN,
+ dataId,
+ column
+ };
+}
+
+/**
+ * Copy column, for table display
+ * @param {string} dataId
+ * @param {string} column
+ */
+export function copyTableColumn(dataId, column) {
+ return {
+ type: ActionTypes.COPY_TABLE_COLUMN,
+ dataId,
+ column
+ };
+}
+
/**
* Add new dataset to `visState`, with option to load a map config along with the datasets
* @memberof visStateActions
diff --git a/src/components/common/data-table/button.js b/src/components/common/data-table/button.js
new file mode 100644
index 000000000..1d1a9e79e
--- /dev/null
+++ b/src/components/common/data-table/button.js
@@ -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.
+
+import React from 'react';
+import styled from 'styled-components';
+
+const StyledButton = styled.button`
+ color: ${props => props.theme.optionButtonColor};
+ background-color: transparent;
+ border: none;
+ cursor: pointer;
+ outline: none;
+ transition: ${props => props.theme.transition};
+ height: 2rem;
+ display: flex;
+ align-items: center;
+ padding: 0;
+
+ &:hover {
+ opacity: 0.8;
+ }
+`;
+const noop = () => {};
+const TableHeaderButton = ({onClick = noop, disabled, text, children, ...props}) => (
+ <StyledButton {...props} onClick={disabled ? null : onClick}>
+ {text || children}
+ </StyledButton>
+);
+
+export default TableHeaderButton;
diff --git a/src/components/common/data-table/canvas.js b/src/components/common/data-table/canvas.js
new file mode 100644
index 000000000..dddbb4ad0
--- /dev/null
+++ b/src/components/common/data-table/canvas.js
@@ -0,0 +1,43 @@
+// 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 styled from 'styled-components';
+
+/*
+ ScrollSync works by getting a callback about the dom elements scroll amount
+ and then using that to pass into how much to scroll all child components,
+ it works great!
+
+ Except... Because scrolling is managed by a separate thread, and JavaScript
+ is only periodically notified of the updated position, there's some latency
+ issues with this.
+
+ We can hack around this by using a niche property of canvas that removes the
+ delay in scroll event firing! Easiest way to reproduce: enable "Trace React updates"
+ in React DevTools (it works by overlaying a viewport-wide canvas over the document).
+ */
+export default styled.canvas`
+ height: 100%;
+ left: 0;
+ pointer-events: none;
+ position: absolute;
+ top: 0;
+ width: 100%;
+`;
diff --git a/src/components/common/data-table/cell-size.js b/src/components/common/data-table/cell-size.js
new file mode 100644
index 000000000..c83cd9d93
--- /dev/null
+++ b/src/components/common/data-table/cell-size.js
@@ -0,0 +1,178 @@
+// 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 document from 'global/document';
+import {parseFieldValue} from 'utils/data-utils';
+
+const MIN_GHOST_CELL_SIZE = 200;
+
+/**
+ * Measure rows and column content to determin min width for each column
+ * @param {*} param0
+ */
+export function renderedSize({
+ text: {rows, column},
+ type = 'string',
+ colIdx,
+ numRowsToCalculate = 10,
+ fontSize = 12,
+ font = 'Lato',
+ cellPadding = 30,
+ maxCellSize = 400,
+ maxHeaderSize = 150,
+ minCellSize = 45,
+ optionsButton = 30
+}) {
+ if (!document) {
+ return {
+ row: 0,
+ header: 0
+ };
+ }
+ const textCanvas = document.createElement('canvas');
+ document.body.appendChild(textCanvas);
+ const context = textCanvas.getContext('2d');
+ context.font = [fontSize, font].join('px ');
+ let rowsToSample = [...Array(numRowsToCalculate)].map(() =>
+ Math.floor(Math.random() * (rows.length - 1 - 0 + 1))
+ );
+
+ // IF we have less than 10 rows, lets measure all of them
+ if (rows.length < numRowsToCalculate) {
+ rowsToSample = Array.from(Array(rows.length).keys());
+ }
+ const rowWidth = Math.max(
+ ...rowsToSample.map(
+ rowIdx =>
+ Math.ceil(context.measureText(parseFieldValue(rows[rowIdx][colIdx], type)).width) +
+ cellPadding
+ )
+ );
+ // header cell only has left padding
+ const headerWidth =
+ Math.ceil(context.measureText(column).width) + cellPadding / 2 + optionsButton;
+
+ const minRowWidth = minCellSize + cellPadding;
+ const minHeaderWidth = minCellSize + cellPadding / 2 + optionsButton;
+
+ const clampedRowWidth = clamp(minRowWidth, maxCellSize, rowWidth);
+ const clampedHeaderWidth = clamp(minHeaderWidth, maxHeaderSize, headerWidth);
+
+ // cleanup
+ textCanvas.parentElement.removeChild(textCanvas);
+
+ return {
+ row: clampedRowWidth,
+ header: clampedHeaderWidth
+ };
+}
+
+function clamp(min, max, value) {
+ return Math.max(Math.min(max, value), min);
+}
+
+function getColumnOrder(pinnedColumns = [], unpinnedColumns = []) {
+ return [...pinnedColumns, ...unpinnedColumns];
+}
+
+function getMinCellSize(cellSizeCache) {
+ return Object.keys(cellSizeCache).reduce(
+ (accu, col) => ({
+ ...accu,
+ [col]: cellSizeCache[col].row
+ }),
+ {}
+ );
+}
+
+function getSizeSum(sizeCache, key) {
+ return Object.keys(sizeCache).reduce(
+ (acc, val) => acc + (key ? sizeCache[val][key] : sizeCache[val]),
+ 0
+ );
+}
+
+/**
+ * Expand cell to fit both row and header, if there is still room left,
+ * expand last cell to fit the entire width of the container
+ * @param {object} cellSizeCache
+ * @param {string[]} columnOrder
+ * @param {number} containerWidth
+ * @param {number} roomToFill
+ */
+function expandCellSize(cellSizeCache, columnOrder, containerWidth, roomToFill) {
+ let remaining = roomToFill;
+
+ const expandedCellSize = columnOrder.reduce((accu, col) => {
+ let size = cellSizeCache[col].row;
+ if (cellSizeCache[col].row < cellSizeCache[col].header && remaining > 0) {
+ // if we are cutting off the header, expand to fit it
+ size =
+ cellSizeCache[col].header - cellSizeCache[col].row < remaining
+ ? cellSizeCache[col].header
+ : cellSizeCache[col].row + remaining;
+ remaining -= size - cellSizeCache[col].row;
+ }
+
+ return {
+ ...accu,
+ [col]: size
+ };
+ }, {});
+
+ let ghost = null;
+ if (remaining > 0 && remaining < MIN_GHOST_CELL_SIZE) {
+ // expand last cell
+ const lastCell = columnOrder[columnOrder.length - 1];
+ expandedCellSize[lastCell] += remaining;
+ } else if (remaining >= MIN_GHOST_CELL_SIZE) {
+ // if too much left add a ghost cell
+ ghost = remaining;
+ }
+
+ return {
+ cellSizeCache: expandedCellSize,
+ ghost
+ };
+}
+
+/**
+ * Adjust cell size based on container width
+ * @param {number} containerWidth
+ * @param {Object} cellSizeCache
+ * @param {string[]} pinnedColumns
+ * @param {string[]} unpinnedColumns
+ */
+export function adjustCellsToContainer(
+ containerWidth,
+ cellSizeCache,
+ pinnedColumns,
+ unpinnedColumns
+) {
+ const minRowSum = getSizeSum(cellSizeCache, 'row');
+ if (minRowSum >= containerWidth) {
+ // we apply the min Width to all cells
+ return {cellSizeCache: getMinCellSize(cellSizeCache)};
+ }
+
+ // if we have some room to expand
+ const columnOrder = getColumnOrder(pinnedColumns, unpinnedColumns);
+ return expandCellSize(cellSizeCache, columnOrder, containerWidth, containerWidth - minRowSum);
+}
diff --git a/src/components/common/data-table/grid.js b/src/components/common/data-table/grid.js
new file mode 100644
index 000000000..7ee7c173d
--- /dev/null
+++ b/src/components/common/data-table/grid.js
@@ -0,0 +1,55 @@
+// 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 React, {PureComponent} from 'react';
+import {Grid} from 'react-virtualized';
+import isEqual from 'lodash.isequal';
+
+export default class GridHack extends PureComponent {
+ componentDidUpdate(preProps) {
+ /*
+ * This hack exists because in react-virtualized the
+ * _columnWidthGetter is only called in the constructor
+ * even though it is reassigned with new props resulting in
+ * a new width for cells not being calculated so we must
+ * force trigger a resize.
+ *
+ * https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/Grid.js#L322
+ *
+ */
+ if (!isEqual(preProps.cellSizeCache, this.props.cellSizeCache)) {
+ this.grid.recomputeGridSize();
+ }
+ }
+
+ render() {
+ const {setGridRef, ...rest} = this.props;
+ return (
+ <Grid
+ ref={x => {
+ if (setGridRef) setGridRef(x);
+ this.grid = x;
+ }}
+ key="grid-hack"
+ {...rest}
+ />
+ );
+ }
+}
diff --git a/src/components/common/data-table/index.js b/src/components/common/data-table/index.js
new file mode 100644
index 000000000..f2651e9fa
--- /dev/null
+++ b/src/components/common/data-table/index.js
@@ -0,0 +1,626 @@
+// 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 React, {Component, createRef} from 'react';
+import {ScrollSync, AutoSizer} from 'react-virtualized';
+import styled, {withTheme} from 'styled-components';
+import classnames from 'classnames';
+import {createSelector} from 'reselect';
+import get from 'lodash.get';
+import debounce from 'lodash.debounce';
+
+import OptionDropdown from './option-dropdown';
+
+import Grid from './grid';
+import Button from './button';
+import {ArrowUp, ArrowDown} from 'components/common/icons';
+import {VertThreeDots} from 'components/common/icons';
+import FieldToken from 'components/common/field-token';
+
+import {parseFieldValue} from 'utils/data-utils';
+import {adjustCellsToContainer} from './cell-size';
+
+import {ALL_FIELD_TYPES, SORT_ORDER} from 'constants/default-settings';
+
+const defaultHeaderRowHeight = 55;
+const defaultRowHeight = 32;
+const overscanColumnCount = 10;
+const overscanRowCount = 10;
+const fieldToAlignRight = {
+ [ALL_FIELD_TYPES.integer]: true,
+ [ALL_FIELD_TYPES.real]: true
+};
+
+export const Container = styled.div`
+ display: flex;
+ font-size: 11px;
+ flex-grow: 1;
+ color: ${props => props.theme.textColorLT};
+ width: 100%;
+
+ .ReactVirtualized__Grid:focus,
+ .ReactVirtualized__Grid:active {
+ outline: 0;
+ }
+
+ .cell {
+ &::-webkit-scrollbar {
+ display: none;
+ }
+ }
+
+ *:focus {
+ outline: 0;
+ }
+
+ .results-table-wrapper {
+ position: relative;
+ min-height: 100%;
+ max-height: 100%;
+ display: flex;
+ flex-direction: row;
+ flex-grow: 1;
+ overflow: hidden;
+ border-top: none;
+
+ .scroll-in-ui-thread::after {
+ content: '';
+ height: 100%;
+ left: 0;
+ position: absolute;
+ pointer-events: none;
+ top: 0;
+ width: 100%;
+ }
+
+ .grid-row {
+ position: relative;
+ display: flex;
+ flex-direction: row;
+ }
+ .grid-column {
+ display: flex;
+ flex-direction: column;
+ flex: 1 1 auto;
+ }
+ .pinned-grid-container {
+ flex: 0 0 75px;
+ z-index: 10;
+ position: absolute;
+ left: 0;
+ top: 0;
+ border-right: 2px solid ${props => props.theme.pinnedGridBorderColor};
+ }
+
+ .header-grid {
+ overflow: hidden !important;
+ }
+
+ .body-grid {
+ overflow: overlay !important;
+ }
+
+ .pinned-grid {
+ overflow: overlay !important;
+ }
+
+ .even-row {
+ background-color: ${props => props.theme.evenRowBackground};
+ }
+ .odd-row {
+ background-color: ${props => props.theme.oddRowBackground};
+ }
+ .cell,
+ .header-cell {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: flex-start;
+ text-align: center;
+ overflow: hidden;
+
+ .n-sort-idx {
+ font-size: 9px;
+ }
+ }
+ .cell {
+ border-bottom: 1px solid ${props => props.theme.cellBorderColor};
+ border-right: 1px solid ${props => props.theme.cellBorderColor};
+ white-space: nowrap;
+ overflow: auto;
+ padding: 0 ${props => props.theme.cellPaddingSide}px;
+ font-size: ${props => props.theme.cellFontSize}px;
+
+ .result-link {
+ text-decoration: none;
+ }
+ }
+ .cell.end-cell,
+ .header-cell.end-cell {
+ border-right: none;
+ padding-right: ${props => props.theme.cellPaddingSide + props.theme.edgeCellPaddingSide}px;
+ }
+ .cell.first-cell,
+ .header-cell.first-cell {
+ padding-left: ${props => props.theme.cellPaddingSide + props.theme.edgeCellPaddingSide}px;
+ }
+ .cell.bottom-cell {
+ border-bottom: none;
+ }
+ .cell.align-right {
+ align-items: flex-end;
+ }
+ .header-cell {
+ border-bottom: 1px solid ${props => props.theme.headerCellBorderColor};
+ border-top: 1px solid ${props => props.theme.headerCellBorderColor};
+ padding-top: ${props => props.theme.headerPaddingTop}px;
+ padding-right: 0;
+ padding-bottom: ${props => props.theme.headerPaddingBottom}px;
+ padding-left: ${props => props.theme.cellPaddingSide}px;
+ align-items: center;
+ justify-content: space-between;
+ display: flex;
+ flex-direction: row;
+ background-color: ${props => props.theme.headerCellBackground};
+
+ &:hover {
+ .more {
+ color: ${props => props.theme.headerCellIconColor};
+ }
+ }
+ .n-sort-idx {
+ font-size: 9px;
+ }
+ .details {
+ font-weight: 500;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-around;
+ height: 100%;
+ overflow: hidden;
+ flex-grow: 1;
+ .col-name {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+
+ .col-name__left {
+ display: flex;
+ align-items: center;
+ overflow: hidden;
+ svg {
+ margin-left: 6px;
+ }
+ }
+ .col-name__name {
+ overflow: hidden;
+ white-space: nowrap;
+ }
+ .col-name__sort {
+ cursor: pointer;
+ }
+ }
+ }
+
+ .more {
+ color: transparent;
+ margin-left: 5px;
+ }
+ }
+ }
+
+ :focus {
+ outline: none;
+ }
+`;
+
+const validateCellDataSize = (data, {cellSizeLimit = 10000}) => {
+ if (`${data}`.length <= cellSizeLimit) {
+ return data;
+ }
+ return 'Data too large, download CSV';
+};
+
+const defaultColumnWidth = 200;
+
+const columnWidthFunction = (columns, cellSizeCache, ghost) => ({index}) => {
+ return (columns[index] || {}).ghost ? ghost : cellSizeCache[columns[index]] || defaultColumnWidth;
+};
+
+/*
+ * This is an accessor method used to generalize getting a cell from a data row
+ */
+const getRowCell = ({rows, columns, column, colMeta, rowIndex, sortColumn, sortOrder}) => {
+ const rowIdx = sortOrder && sortOrder.length ? get(sortOrder, rowIndex) : rowIndex;
+ const type = colMeta[column];
+
+ return parseFieldValue(get(rows, [rowIdx, columns.indexOf(column)], 'Err'), type);
+};
+
+const renderHeaderCell = (columns, isPinned, props, toggleMoreOptions, moreOptionsColumn) => {
+ // eslint-disable-next-line react/display-name
+ return cellInfo => {
+ const {columnIndex, key, style} = cellInfo;
+ const {
+ colMeta,
+ sortColumn,
+ sortTableColumn,
+ unsortColumn,
+ pinTableColumn,
+ copyTableColumn,
+ dataId
+ } = props;
+
+ const column = columns[columnIndex];
+ const isGhost = column.ghost;
+ const isSorted = sortColumn[column];
+ const firstCell = columnIndex === 0;
+
+ return (
+ <div
+ className={classnames('header-cell', {
+ [`column-${columnIndex}`]: true,
+ 'pinned-header-cell': isPinned,
+ 'first-cell': firstCell
+ })}
+ key={key}
+ style={style}
+ onClick={e => {
+ e.shiftKey ? sortTableColumn(dataId, column) : null;
+ }}
+ onDoubleClick={() => sortTableColumn(dataId, column)}
+ title={column}
+ >
+ {isGhost ? (
+ <div />
+ ) : (
+ <>
+ <section className="details">
+ <div className="col-name">
+ <div className="col-name__left">
+ <div className="col-name__name">{column}</div>
+ <Button
+ className="col-name__sort"
+ onClick={() => sortTableColumn(dataId, column)}
+ >
+ {isSorted ? (
+ isSorted === SORT_ORDER.ASCENDING ? (
+ <ArrowUp height="14px" />
+ ) : (
+ <ArrowDown height="14px" />
+ )
+ ) : null}
+ </Button>
+ </div>
+ <Button className="more" onClick={() => toggleMoreOptions(column)}>
+ <VertThreeDots height="14px" />
+ </Button>
+ </div>
+
+ <FieldToken type={colMeta[column]} />
+ </section>
+
+ <section className="options">
+ <OptionDropdown
+ isOpened={moreOptionsColumn === column}
+ type={colMeta[column]}
+ column={column}
+ toggleMoreOptions={toggleMoreOptions}
+ sortTableColumn={mode => sortTableColumn(dataId, column, mode)}
+ sortMode={sortColumn && sortColumn[column]}
+ pinTableColumn={() => pinTableColumn(dataId, column)}
+ copyTableColumn={() => copyTableColumn(dataId, column)}
+ isSorted={isSorted}
+ isPinned={isPinned}
+ unsortColumn={unsortColumn}
+ />
+ </section>
+ </>
+ )}
+ </div>
+ );
+ };
+};
+
+const renderDataCell = (columns, isPinned, props) => {
+ return cellInfo => {
+ const {columnIndex, key, style, rowIndex} = cellInfo;
+ const {cellSizeLimit, rows, colMeta} = props;
+ const column = columns[columnIndex];
+ const isGhost = column.ghost;
+
+ const rowCell = isGhost
+ ? ''
+ : validateCellDataSize(getRowCell({...props, column, rowIndex}), {cellSizeLimit});
+ const type = isGhost ? null : colMeta[column];
+
+ const endCell = columnIndex === columns.length - 1;
+ const firstCell = columnIndex === 0;
+ const bottomCell = rowIndex === rows.length - 1;
+ const alignRight = fieldToAlignRight[type];
+
+ const cell = (
+ <div
+ className={classnames('cell', {
+ [rowIndex % 2 === 0 ? 'even-row' : 'odd-row']: true,
+ [`row-${rowIndex}`]: true,
+ 'pinned-cell': isPinned,
+ 'first-cell': firstCell,
+ 'end-cell': endCell,
+ 'bottom-cell': bottomCell,
+ 'align-right': alignRight
+ })}
+ key={key}
+ style={style}
+ title={isGhost ? undefined : rowCell}
+ >
+ {`${rowCell}${endCell ? '\n' : '\t'}`}
+ </div>
+ );
+
+ return cell;
+ };
+};
+
+export const TableSection = ({
+ classList,
+ isPinned,
+ columns,
+ headerGridProps,
+ fixedWidth,
+ fixedHeight,
+ onScroll,
+ scrollTop,
+ dataGridProps,
+ columnWidth,
+ setGridRef,
+ headerCellRender,
+ dataCellRender,
+ scrollLeft
+}) => (
+ <AutoSizer>
+ {({width, height}) => {
+ const gridDimension = {
+ columnCount: columns.length,
+ columnWidth,
+ width: fixedWidth || width
+ };
+ const dataGridHeight = fixedHeight || height;
+ return (
+ <>
+ <div className={classnames('scroll-in-ui-thread', classList.header)}>
+ <Grid
+ cellRenderer={headerCellRender}
+ {...headerGridProps}
+ {...gridDimension}
+ scrollLeft={scrollLeft}
+ />
+ </div>
+ <div
+ className={classnames('scroll-in-ui-thread', classList.rows)}
+ style={{
+ top: headerGridProps.height
+ }}
+ >
+ <Grid
+ cellRenderer={dataCellRender}
+ {...dataGridProps}
+ {...gridDimension}
+ className={isPinned ? 'pinned-grid' : 'body-grid'}
+ height={dataGridHeight - headerGridProps.height}
+ onScroll={onScroll}
+ scrollTop={scrollTop}
+ setGridRef={setGridRef}
+ />
+ </div>
+ </>
+ );
+ }}
+ </AutoSizer>
+);
+
+export class DataTable extends Component {
+ static defaultProps = {
+ rows: [],
+ pinnedColumns: [],
+ colMeta: {},
+ cellSizeCache: {},
+ sortColumn: {},
+ fixedWidth: null,
+ fixedHeight: null,
+ theme: {}
+ };
+
+ state = {
+ cellSizeCache: {},
+ moreOptionsColumn: null
+ };
+
+ componentDidMount() {
+ window.addEventListener('resize', this.scaleCellsToWidth);
+ this.scaleCellsToWidth();
+ }
+
+ componentDidUpdate(prevProps) {
+ if (
+ this.props.cellSizeCache !== prevProps.cellSizeCache ||
+ this.props.pinnedColumns !== prevProps.pinnedColumns
+ ) {
+ this.scaleCellsToWidth();
+ }
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener('resize', this.scaleCellsToWidth);
+ }
+ root = createRef();
+ columns = props => props.columns;
+ pinnedColumns = props => props.pinnedColumns;
+ unpinnedColumns = createSelector(this.columns, this.pinnedColumns, (columns, pinnedColumns) =>
+ !Array.isArray(pinnedColumns) ? columns : columns.filter(c => !pinnedColumns.includes(c))
+ );
+
+ toggleMoreOptions = moreOptionsColumn =>
+ this.setState({
+ moreOptionsColumn:
+ this.state.moreOptionsColumn === moreOptionsColumn ? null : moreOptionsColumn
+ });
+
+ getCellSizeCache = () => {
+ const {cellSizeCache: propsCache, fixedWidth, pinnedColumns} = this.props;
+ const unpinnedColumns = this.unpinnedColumns(this.props);
+
+ const width = fixedWidth ? fixedWidth : this.root.current ? this.root.current.clientWidth : 0;
+
+ // pin column border is 2 pixel vs 1 pixel
+ const adjustWidth = pinnedColumns.length ? width - 1 : width;
+ const {cellSizeCache, ghost} = adjustCellsToContainer(
+ adjustWidth,
+ propsCache,
+ pinnedColumns,
+ unpinnedColumns
+ );
+ return {
+ cellSizeCache,
+ ghost
+ };
+ };
+
+ doScaleCellsToWidth = () => {
+ this.setState(this.getCellSizeCache());
+ };
+
+ scaleCellsToWidth = debounce(this.doScaleCellsToWidth, 300);
+
+ render() {
+ const {rows, pinnedColumns, theme = {}, fixedWidth, fixedHeight} = this.props;
+ const unpinnedColumns = this.unpinnedColumns(this.props);
+
+ const {cellSizeCache, moreOptionsColumn, ghost} = this.state;
+ const unpinnedColumnsGhost = ghost ? [...unpinnedColumns, {ghost: true}] : unpinnedColumns;
+ const pinnedColumnsWidth = pinnedColumns.reduce(
+ (acc, val) => acc + get(cellSizeCache, val, 0),
+ 0
+ );
+
+ const hasPinnedColumns = Boolean(pinnedColumns.length);
+ const {headerRowHeight = defaultHeaderRowHeight, rowHeight = defaultRowHeight} = theme;
+
+ const headerGridProps = {
+ cellSizeCache,
+ className: 'header-grid',
+ height: headerRowHeight,
+ rowCount: 1,
+ rowHeight: headerRowHeight
+ };
+
+ const dataGridProps = {
+ cellSizeCache,
+ overscanColumnCount,
+ overscanRowCount,
+ rowCount: (rows || []).length,
+ rowHeight
+ };
+
+ return (
+ <Container className="data-table-container" ref={this.root}>
+ {Object.keys(cellSizeCache).length && (
+ <ScrollSync>
+ {({onScroll, scrollLeft, scrollTop}) => {
+ return (
+ <div className="results-table-wrapper">
+ {hasPinnedColumns && (
+ <div key="pinned-columns" className="pinned-columns grid-row">
+ <TableSection
+ classList={{
+ header: 'pinned-columns--header pinned-grid-container',
+ rows: 'pinned-columns--rows pinned-grid-container'
+ }}
+ isPinned
+ columns={pinnedColumns}
+ headerGridProps={headerGridProps}
+ fixedWidth={pinnedColumnsWidth}
+ onScroll={args => onScroll({...args, scrollLeft})}
+ scrollTop={scrollTop}
+ dataGridProps={dataGridProps}
+ setGridRef={pinnedGrid => (this.pinnedGrid = pinnedGrid)}
+ columnWidth={columnWidthFunction(pinnedColumns, cellSizeCache)}
+ headerCellRender={renderHeaderCell(
+ pinnedColumns,
+ true,
+ this.props,
+ this.toggleMoreOptions,
+ moreOptionsColumn
+ )}
+ dataCellRender={renderDataCell(pinnedColumns, true, this.props)}
+ />
+ </div>
+ )}
+ <div
+ key="unpinned-columns"
+ style={{
+ marginLeft: `${hasPinnedColumns ? `${pinnedColumnsWidth}px` : '0'}`
+ }}
+ className="unpinned-columns grid-column"
+ >
+ <TableSection
+ classList={{
+ header: 'unpinned-columns--header unpinned-grid-container',
+ rows: 'unpinned-columns--rows unpinned-grid-container'
+ }}
+ isPinned={false}
+ columns={unpinnedColumnsGhost}
+ ghost={ghost}
+ headerGridProps={headerGridProps}
+ fixedWidth={fixedWidth}
+ fixedHeight={fixedHeight}
+ onScroll={onScroll}
+ scrollTop={scrollTop}
+ scrollLeft={scrollLeft}
+ dataGridProps={dataGridProps}
+ setGridRef={unpinnedGrid => (this.unpinnedGrid = unpinnedGrid)}
+ columnWidth={columnWidthFunction(unpinnedColumnsGhost, cellSizeCache, ghost)}
+ headerCellRender={renderHeaderCell(
+ unpinnedColumnsGhost,
+ false,
+ this.props,
+ this.toggleMoreOptions,
+ moreOptionsColumn
+ )}
+ dataCellRender={renderDataCell(unpinnedColumnsGhost, false, this.props)}
+ />
+ </div>
+ </div>
+ );
+ }}
+ </ScrollSync>
+ )}
+ </Container>
+ );
+ }
+}
+
+function DataTableFactory() {
+ return withTheme(DataTable);
+}
+
+export default DataTableFactory;
diff --git a/src/components/common/data-table/option-dropdown.js b/src/components/common/data-table/option-dropdown.js
new file mode 100644
index 000000000..017a73a45
--- /dev/null
+++ b/src/components/common/data-table/option-dropdown.js
@@ -0,0 +1,110 @@
+// 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 React, {useCallback} from 'react';
+import styled from 'styled-components';
+import Portaled from 'components/common/portaled';
+import DropdownList from 'components/common/item-selector/dropdown-list';
+import {SORT_ORDER, TABLE_OPTION, TABLE_OPTION_LIST} from 'constants/default-settings';
+
+const ListItem = ({value}) => (
+ <div>
+ <value.icon height="13px" />
+ {value.display}
+ </div>
+);
+
+const StyledOptionsDropdown = styled.div`
+ .list-selector {
+ border-top: 0;
+ width: max-content;
+ padding: 8px 0;
+ }
+
+ .list__item > div {
+ display: flex;
+ align-items: center;
+ flex-direction: row;
+ justify-content: flex-start;
+ line-height: 18px;
+
+ svg {
+ margin-right: 5px;
+ }
+ }
+`;
+
+const OptionDropdown = props => {
+ const {
+ isOpened,
+ column,
+ toggleMoreOptions,
+ sortTableColumn,
+ pinTableColumn,
+ copyTableColumn
+ } = props;
+ const onOptionSelected = useCallback(
+ ({value}) => {
+ switch (value) {
+ case TABLE_OPTION.SORT_ASC:
+ sortTableColumn(SORT_ORDER.ASCENDING);
+ break;
+ case TABLE_OPTION.SORT_DES:
+ sortTableColumn(SORT_ORDER.DESCENDING);
+ break;
+ case TABLE_OPTION.UNSORT:
+ sortTableColumn(SORT_ORDER.UNSORT);
+ break;
+ case TABLE_OPTION.PIN:
+ pinTableColumn();
+ break;
+ case TABLE_OPTION.UNPIN:
+ pinTableColumn();
+ break;
+ case TABLE_OPTION.COPY:
+ copyTableColumn();
+ break;
+ default:
+ break;
+ }
+
+ toggleMoreOptions(column);
+ },
+ [column, sortTableColumn, pinTableColumn, copyTableColumn, toggleMoreOptions]
+ );
+
+ const options = TABLE_OPTION_LIST.filter(op => !op.condition || op.condition(props));
+
+ return (
+ <Portaled right={120} top={20} isOpened={isOpened} onClose={() => toggleMoreOptions(column)}>
+ <StyledOptionsDropdown className="more-options">
+ <DropdownList
+ displayOption={d => d.display}
+ options={options}
+ customListItemComponent={ListItem}
+ onOptionSelected={onOptionSelected}
+ light
+ />
+ </StyledOptionsDropdown>
+ </Portaled>
+ );
+};
+
+export default OptionDropdown;
diff --git a/src/components/common/datagrid.js b/src/components/common/datagrid.js
deleted file mode 100644
index fd6a1e47d..000000000
--- a/src/components/common/datagrid.js
+++ /dev/null
@@ -1,240 +0,0 @@
-// 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 React, {PureComponent} from 'react';
-import PropTypes from 'prop-types';
-import {MultiGrid} from 'react-virtualized';
-import styled, {withTheme} from 'styled-components';
-import {createSelector} from 'reselect';
-import classnames from 'classnames';
-import FieldToken from 'components/common/field-token';
-import {Clock} from 'components/common/icons/index';
-import {parseFieldValue} from 'utils/data-utils';
-import {ALL_FIELD_TYPES} from 'constants';
-
-const DataGridWrapper = styled.div`
- width: 100%;
- overflow-x: auto;
-
- .ReactVirtualized__Grid:focus,
- .ReactVirtualized__Grid:active {
- outline: 0;
- }
- .ReactVirtualized__Grid__innerScrollContainer {
- ${props => props.theme.modalScrollBar};
- }
-
- .ReactVirtualized__Grid {
- .column-0 .cell {
- padding-left: ${props => props.theme.gridPaddingSide}px;
- }
-
- .header-0 .header-cell {
- padding-left: ${props => props.theme.gridPaddingSide}px;
- }
-
- .cell {
- overflow-y: auto;
- overflow-x: hidden;
- padding-right: ${props => props.theme.cellPaddingSide}px;
- }
-
- .last {
- .cell {
- padding-right: ${props => props.theme.gridPaddingSide}px;
- }
- .header-cell {
- padding-right: ${props => props.theme.gridPaddingSide}px;
- }
- }
- }
-`;
-
-const StyledFieldHeader = styled.div`
- display: flex;
- align-items: center;
- justify-content: left;
- border-right: 0;
- border-bottom: 0;
- background: ${props => props.theme.panelBackgroundLT};
- color: ${props => props.theme.titleColorLT};
- height: 100%;
-
- .header-content {
- display: flex;
- flex-direction: column;
- }
-
- .label-wrapper {
- display: flex;
- align-items: center;
- }
-
- .icon-wrapper {
- margin-right: ${props => (props.type === 'timestamp' ? '2px' : '0')};
- height: 16px;
- }
-`;
-
-export const FieldHeaderFactory = () => {
- const Header = ({className, value, type}) => (
- <StyledFieldHeader className={className || ''} type={type} title={value}>
- <div className="field-header-content">
- <div className="label-wrapper">
- <div className="icon-wrapper">
- {type === 'timestamp' ? <Clock height="16px" /> : null}
- </div>
- <span>{value}</span>
- </div>
- <div className="field-wrapper">
- <FieldToken type={type} />
- </div>
- </div>
- </StyledFieldHeader>
- );
-
- Header.displayName = 'Header';
-
- return Header;
-};
-
-const StyledCell = styled.div`
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- border-right: 0;
- border-bottom: ${props => props.theme.panelBorderLT};
- color: ${props => props.theme.labelColorLT};
- text-overflow: ellipsis;
- height: 100%;
- width: 100%;
-
- span {
- text-overflow: ellipsis;
- white-space: pre-wrap;
- word-wrap: break-word;
- width: 100%;
- }
-`;
-
-export const CellFactory = () => {
- const Cell = ({className, value}) => (
- <StyledCell className={className || ''} title={value}>
- <span>{value}</span>
- </StyledCell>
- );
-
- Cell.displayName = 'Cell';
-
- return Cell;
-};
-
-DataGridFactory.deps = [FieldHeaderFactory, CellFactory];
-
-function DataGridFactory(FieldHeader, Cell) {
- class DataGrid extends PureComponent {
- static propTypes = {
- theme: PropTypes.object,
- columns: PropTypes.arrayOf(PropTypes.object).isRequired,
- height: PropTypes.number.isRequired,
- rows: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.any)).isRequired,
- width: PropTypes.number.isRequired
- };
-
- columnsSelector = props => props.columns;
- hasGeojson = createSelector(this.columnsSelector, columns =>
- columns.some(c => c.type === ALL_FIELD_TYPES.geojson)
- );
-
- _cellRenderer = ({columnIndex, key, rowIndex, style}) => {
- const {columns, rows} = this.props;
- const isLast = columnIndex === columns.length - 1;
- const type = columns[columnIndex].type;
-
- // rowIndex -1 because data rows start rendering at index 1 and we normalize back using the -1 param
- const className = classnames({
- last: isLast,
- [`header-${columnIndex}`]: rowIndex === 0,
- [`row-${rowIndex - 1} column-${columnIndex}`]: rowIndex > 0
- });
-
- return (
- <div key={key} style={style} className={className}>
- {rowIndex === 0 ? (
- <FieldHeader
- className={`header-cell ${type}`}
- value={columns[columnIndex].name}
- type={type}
- />
- ) : (
- <Cell
- className={`cell ${type}`}
- value={parseFieldValue(rows[rowIndex - 1][columnIndex], type)}
- type={type}
- />
- )}
- </div>
- );
- };
-
- _rowHeight = ({index}) =>
- index === 0
- ? this.props.theme.cellHeaderHeight
- : this.hasGeojson(this.props)
- ? this.props.theme.extendCellHeight
- : this.props.theme.cellHeight;
-
- _columnWidth = ({index}) => {
- const isGeojsonField = this.props.columns[index].type === ALL_FIELD_TYPES.geojson;
- return isGeojsonField ? this.props.theme.extendColumnWidth : this.props.theme.columnWidth;
- };
-
- render() {
- const {columns, height, rows, theme, width} = this.props;
-
- return (
- <DataGridWrapper className="datagrid-wrapper">
- <MultiGrid
- cellRenderer={this._cellRenderer}
- columnWidth={this._columnWidth}
- columnCount={columns.length}
- fixedRowCount={1}
- enableFixedRowScroll={true}
- width={width || theme.gridDefaultWidth}
- height={height || theme.gridDefaultHeight}
- rowHeight={this._rowHeight}
- rowCount={rows.length + 1}
- hideTopRightGridScrollbar={true}
- hideBottomLeftGridScrollbar={true}
- />
- </DataGridWrapper>
- );
- }
- }
-
- DataGrid.displayName = 'DataGrid';
-
- // Wrapping the component using withTheme because we need to
- // access variables outside styled-components context
- return withTheme(DataGrid);
-}
-
-export default DataGridFactory;
diff --git a/src/components/common/dataset-label.js b/src/components/common/dataset-label.js
index db30ef62e..ec0b49047 100644
--- a/src/components/common/dataset-label.js
+++ b/src/components/common/dataset-label.js
@@ -22,7 +22,9 @@ import React from 'react';
import styled from 'styled-components';
import {CenterFlexbox, DatasetSquare} from 'components/common/styled-components';
-const DatasetName = styled.div`
+const DatasetName = styled.div.attrs({
+ className: 'dataset-name'
+})`
font-weight: 500;
font-size: 12px;
color: ${props => props.theme.titleColorLT};
@@ -31,7 +33,7 @@ const DatasetName = styled.div`
const DatasetLabel = ({dataset}) => (
<CenterFlexbox>
<DatasetSquare className="dataset-clolor" color={dataset.color} />
- <DatasetName className="dataset-name">{dataset.label}</DatasetName>
+ <DatasetName>{dataset.label}</DatasetName>
</CenterFlexbox>
);
diff --git a/src/components/common/icons/arrow-down-alt.js b/src/components/common/icons/arrow-down-alt.js
new file mode 100644
index 000000000..57ab57543
--- /dev/null
+++ b/src/components/common/icons/arrow-down-alt.js
@@ -0,0 +1,43 @@
+// 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 React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base from './base';
+
+export default class ArrowDownAlt extends Component {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-arrow_down_alt'
+ };
+
+ render() {
+ return (
+ <Base {...this.props}>
+ <path d="M30.9874294,23.8822323 L21.4022168,35.7397323 L21.4022168,3.80585729 C21.4022168,2.11829479 20.0731075,0.750419792 18.4333707,0.750419792 C16.7936338,0.750419792 15.4645245,2.11829479 15.4645245,3.80585729 L15.4645245,35.7397323 L5.87742937,23.8822323 C4.82882614,22.5802323 2.95282411,22.4077948 1.69713585,23.4869823 C0.433917229,24.5661698 0.26260144,26.4920448 1.31308727,27.789201 L16.1516703,46.1479823 C16.7155063,46.846451 17.552318,47.2504198 18.4333707,47.2504198 C19.3144233,47.2504198 20.151235,46.846451 20.7150711,46.1479823 L35.556478,27.789201 C36.6041399,26.4920448 36.4309415,24.5661698 35.1724294,23.4869823 C33.9007391,22.4077948 32.0407391,22.5802323 30.9874294,23.8822323 Z" />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/icons/arrow-down-solid .js b/src/components/common/icons/arrow-down-solid .js
new file mode 100644
index 000000000..cb43ddb41
--- /dev/null
+++ b/src/components/common/icons/arrow-down-solid .js
@@ -0,0 +1,43 @@
+// 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 React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base from './base';
+
+export default class ArrowDownSolid extends Component {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-arrowdown-solid'
+ };
+
+ render() {
+ return (
+ <Base {...this.props}>
+ <polygon points="6.4,20.8 56.4,20.8 31.4,45.8 " />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/icons/arrow-down.js b/src/components/common/icons/arrow-down.js
index 713a23818..1a568167d 100644
--- a/src/components/common/icons/arrow-down.js
+++ b/src/components/common/icons/arrow-down.js
@@ -36,7 +36,10 @@ export default class ArrowDown extends Component {
render() {
return (
<Base {...this.props}>
- <path d="M53,26.21l-4.2-4.3a1,1,0,0,0-1.4,0L32,37.67,16.61,21.92a1,1,0,0,0-1.4,0L11,26.21a1,1,0,0,0,0,1.43L27.1,44.11l4.2,4.3a1,1,0,0,0,1.4,0l4.2-4.3L53,27.65a1,1,0,0,0,0-1.43" />
+ <path
+ d="M13.1,17.5c0.4-0.4,1.1-0.4,1.6,0L32,34.8l17.4-17.4c0.4-0.4,1.1-0.4,1.6,0l4.7,4.7c0.4,0.4,0.4,1.1,0,1.6L32.8,46.7
+ c-0.4,0.4-1.1,0.4-1.6,0L8.3,23.8c-0.4-0.4-0.4-1.1,0-1.6L13.1,17.5z"
+ />{' '}
</Base>
);
}
diff --git a/src/components/common/icons/arrow-up-alt.js b/src/components/common/icons/arrow-up-alt.js
new file mode 100644
index 000000000..2f4da9350
--- /dev/null
+++ b/src/components/common/icons/arrow-up-alt.js
@@ -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 React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base from './base';
+
+export default class ArrowUpAlt extends Component {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-arrow_up_alt'
+ };
+
+ render() {
+ return (
+ <Base {...this.props}>
+ <path
+ d="M35.1724294,23.4869823 C33.9007391,22.4077948 32.0407391,22.5802323 30.9874294,23.8822323 L21.4022168,35.7397323 L21.4022168,3.80585729 C21.4022168,2.11829479 20.0731075,0.750419792 18.4333707,0.750419792 C16.7936338,0.750419792 15.4645245,2.11829479 15.4645245,3.80585729 L15.4645245,35.7397323 L5.87742937,23.8822323 C4.82882614,22.5802323 2.95282411,22.4077948 1.69713585,23.4869823 C0.433917229,24.5661698 0.26260144,26.4920448 1.31308727,27.789201 L16.1516703,46.1479823 C16.7155063,46.846451 17.552318,47.2504198 18.4333707,47.2504198 C19.3144233,47.2504198 20.151235,46.846451 20.7150711,46.1479823 L35.556478,27.789201 C36.6041399,26.4920448 36.4309415,24.5661698 35.1724294,23.4869823"
+ transform="rotate(-180.000000)"
+ />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/icons/arrow-up-solid.js b/src/components/common/icons/arrow-up-solid.js
new file mode 100644
index 000000000..97276f9e0
--- /dev/null
+++ b/src/components/common/icons/arrow-up-solid.js
@@ -0,0 +1,43 @@
+// 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 React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base from './base';
+
+export default class ArrowUpSolid extends Component {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-arrowup-solid'
+ };
+
+ render() {
+ return (
+ <Base {...this.props}>
+ <polygon points="32.3,20 57.3,45 7.3,45 " />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/icons/arrow-up.js b/src/components/common/icons/arrow-up.js
new file mode 100644
index 000000000..3ee077b90
--- /dev/null
+++ b/src/components/common/icons/arrow-up.js
@@ -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 React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base from './base';
+
+export default class ArrowUp extends Component {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-arrow_up'
+ };
+
+ render() {
+ return (
+ <Base {...this.props}>
+ <path
+ d="M50.9,46.7c-0.4,0.4-1.1,0.4-1.6,0L32,29.3L14.6,46.7c-0.4,0.4-1.1,0.4-1.6,0l-4.7-4.7c-0.4-0.4-0.4-1.1,0-1.6l22.9-22.9
+ c0.4-0.4,1.1-0.4,1.6,0l22.9,22.9c0.4,0.4,0.4,1.1,0,1.6L50.9,46.7z"
+ />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/icons/cancel.js b/src/components/common/icons/cancel.js
new file mode 100644
index 000000000..696bb91be
--- /dev/null
+++ b/src/components/common/icons/cancel.js
@@ -0,0 +1,43 @@
+// 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 React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base from './base';
+
+export default class Cancel extends Component {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-cancel'
+ };
+
+ render() {
+ return (
+ <Base {...this.props}>
+ <path d="M16.7240288,20.6999691 C14.3839567,23.8581781 13,27.7674688 13,32 C13,42.4934102 21.5065898,51 32,51 C36.2325312,51 40.1418219,49.6160433 43.3000309,47.2759712 L16.7240288,20.6999691 Z M20.2014265,17.106299 L46.893701,43.7985735 C49.4645783,40.5576433 51,36.4581301 51,32 C51,21.5065898 42.4934102,13 32,13 C27.5418699,13 23.4423567,14.5354217 20.2014265,17.106299 Z M32,56 C18.745166,56 8,45.254834 8,32 C8,18.745166 18.745166,8 32,8 C45.254834,8 56,18.745166 56,32 C56,45.254834 45.254834,56 32,56 Z" />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/icons/clipboard.js b/src/components/common/icons/clipboard.js
new file mode 100644
index 000000000..f5d23535b
--- /dev/null
+++ b/src/components/common/icons/clipboard.js
@@ -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 React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import Base from './base';
+
+export default class Clipboard extends Component {
+ static propTypes = {
+ /** Set the height of the icon, ex. '16px' */
+ height: PropTypes.string
+ };
+
+ static defaultProps = {
+ height: '16px',
+ predefinedClassName: 'data-ex-icons-clipboard'
+ };
+
+ render() {
+ return (
+ <Base {...this.props}>
+ <path
+ transform="translate(6.000000, 0.000000)"
+ d="M46.8184484,5.81818182 L34.5871288,5.81818182 C33.3581445,2.44363636 30.1393762,7.10542736e-15 26.3353772,7.10542736e-15 C22.5313783,7.10542736e-15 19.31261,2.44363636 18.0836257,5.81818182 L5.85230605,5.81818182 C2.63353772,5.81818182 0,8.43636364 0,11.6363636 L0,58.1818182 C0,61.3818182 2.63353772,64 5.85230605,64 L46.8184484,64 C50.0372167,64 52.6707545,61.3818182 52.6707545,58.1818182 L52.6707545,11.6363636 C52.6707545,8.43636364 50.0372167,5.81818182 46.8184484,5.81818182 L46.8184484,5.81818182 Z M26.3353772,5.81818182 C27.9447614,5.81818182 29.2615303,7.12727273 29.2615303,8.72727273 C29.2615303,10.3272727 27.9447614,11.6363636 26.3353772,11.6363636 C24.7259931,11.6363636 23.4092242,10.3272727 23.4092242,8.72727273 C23.4092242,7.12727273 24.7259931,5.81818182 26.3353772,5.81818182 L26.3353772,5.81818182 Z M46.8184484,58.1818182 L5.85230605,58.1818182 L5.85230605,11.6363636 L11.7046121,11.6363636 L11.7046121,20.3636364 L40.9661424,20.3636364 L40.9661424,11.6363636 L46.8184484,11.6363636 L46.8184484,58.1818182 L46.8184484,58.1818182 Z"
+ />
+ </Base>
+ );
+ }
+}
diff --git a/src/components/common/icons/index.js b/src/components/common/icons/index.js
index 09be27bd2..1ddd9d995 100644
--- a/src/components/common/icons/index.js
+++ b/src/components/common/icons/index.js
@@ -20,11 +20,18 @@
export {default as Add} from './add';
export {default as ArrowDown} from './arrow-down';
+export {default as ArrowDownAlt} from './arrow-down-alt';
+export {default as ArrowDownSolid} from './arrow-down-alt';
export {default as ArrowLeft} from './arrow-left';
export {default as ArrowRight} from './arrow-right';
+export {default as ArrowUpSolid} from './arrow-up-solid';
+export {default as ArrowUpAlt} from './arrow-up-alt';
+export {default as ArrowUp} from './arrow-up';
export {default as Base} from './base';
export {default as Bug} from './bug';
+export {default as Cancel} from './cancel';
export {default as Checkmark} from './checkmark';
+export {default as Clipboard} from './clipboard';
export {default as Clock} from './clock';
export {default as Close} from './close';
export {default as Crosshairs} from './crosshairs';
diff --git a/src/components/common/item-selector/dropdown-list.js b/src/components/common/item-selector/dropdown-list.js
index a82b19e18..3db381761 100644
--- a/src/components/common/item-selector/dropdown-list.js
+++ b/src/components/common/item-selector/dropdown-list.js
@@ -37,9 +37,10 @@ export const ListItem = ({value, displayOption = defaultDisplay}) => (
);
const DropdownListWrapper = styled.div`
- background-color: ${props => props.theme.dropdownListBgd};
+ background-color: ${props =>
+ props.light ? props.theme.dropdownListBgdLT : props.theme.dropdownListBgd};
border-top: 1px solid ${props => props.theme.dropdownListBorderTop};
- ${props => props.theme.dropdownList};
+ ${props => (props.light ? props.theme.dropdownListLT : props.theme.dropdownList)};
`;
export default class DropdownList extends Component {
@@ -77,7 +78,7 @@ export default class DropdownList extends Component {
}
render() {
- const {fixedOptions} = this.props;
+ const {fixedOptions, light} = this.props;
const display = this.props.displayOption;
// Don't render if there are no options to display
@@ -90,7 +91,7 @@ export default class DropdownList extends Component {
// For some reason onClick is not fired when clicked on an option
// onMouseDown is used here as a workaround of #205 and other
return (
- <DropdownListWrapper className={classList.list}>
+ <DropdownListWrapper className={classList.list} light={light}>
{this.props.customListHeaderComponent ? (
<div className={classList.listHeader}>
<this.props.customListHeaderComponent />
diff --git a/src/components/common/modal.js b/src/components/common/modal.js
index 4a3c83ce3..730ffd1b7 100644
--- a/src/components/common/modal.js
+++ b/src/components/common/modal.js
@@ -28,7 +28,7 @@ import {Button} from 'components/common/styled-components';
import {media} from 'styles/media-breakpoints';
const ModalContentWrapper = styled.div`
- overflow-y: scroll;
+ overflow-y: auto;
max-width: 70vw;
max-height: 85vh;
padding: 24px 72px 40px;
diff --git a/src/components/common/portaled.js b/src/components/common/portaled.js
new file mode 100644
index 000000000..166d60ed7
--- /dev/null
+++ b/src/components/common/portaled.js
@@ -0,0 +1,258 @@
+// 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 React, {Component, createRef} from 'react';
+import debounce from 'lodash.debounce';
+import isEqual from 'lodash.isequal';
+
+import {canUseDOM} from 'exenv';
+import {withTheme} from 'styled-components';
+import {RootContext} from 'components/context';
+import Modal from 'react-modal';
+import window from 'global/window';
+import {theme} from 'styles/base';
+
+const listeners = {};
+
+const startListening = () => Object.keys(listeners).forEach(key => listeners[key]());
+
+const getPageOffset = () => ({
+ x:
+ window.pageXOffset !== undefined
+ ? window.pageXOffset
+ : (document.documentElement || document.body.parentNode || document.body).scrollLeft,
+ y:
+ window.pageYOffset !== undefined
+ ? window.pageYOffset
+ : (document.documentElement || document.body.parentNode || document.body).scrollTop
+});
+
+const addEventListeners = () => {
+ if (document && document.body)
+ document.body.addEventListener('mousewheel', debounce(startListening, 100, true));
+ window.addEventListener('resize', debounce(startListening, 50, true));
+};
+
+export const getChildPos = ({offsets, rect, childRect, pageOffset, padding}) => {
+ const {topOffset, leftOffset, rightOffset} = offsets;
+
+ const anchorLeft = leftOffset !== undefined;
+ const pos = {
+ top: pageOffset.y + rect.top + (topOffset || 0),
+ ...(anchorLeft
+ ? {left: pageOffset.x + rect.left + leftOffset}
+ : {right: window.innerWidth - rect.right - pageOffset.x + (rightOffset || 0)})
+ };
+
+ const leftOrRight = anchorLeft ? 'left' : 'right';
+
+ if (pos[leftOrRight] && pos[leftOrRight] < 0) {
+ pos[leftOrRight] = padding;
+ } else if (pos[leftOrRight] && pos[leftOrRight] + childRect.width > window.innerWidth) {
+ pos[leftOrRight] = window.innerWidth - childRect.width - padding;
+ }
+
+ if (pos.top < 0) {
+ pos.top = padding;
+ } else if (pos.top + childRect.height > window.innerHeight) {
+ pos.top = window.innerHeight - childRect.height - padding;
+ }
+
+ return pos;
+};
+
+if (canUseDOM) {
+ if (document.body) {
+ addEventListeners();
+ } else {
+ document.addEventListener('DOMContentLoaded', addEventListeners);
+ }
+}
+
+let listenerIdCounter = 0;
+function subscribe(fn) {
+ listenerIdCounter += 1;
+ const id = listenerIdCounter;
+ listeners[id] = fn;
+ return () => delete listeners[id];
+}
+
+const defaultModalStyle = {
+ content: {
+ top: 0,
+ left: 0,
+ border: 0,
+ right: 'auto',
+ bottom: 'auto',
+ padding: '0px 0px 0px 0px'
+ },
+ overlay: {
+ right: 'auto',
+ bottom: 'auto',
+ width: '100vw',
+ height: '100vh',
+ backgroundColor: 'rgba(0, 0, 0, 0)'
+ }
+};
+
+const WINDOW_PAD = 40;
+
+const noop = () => {};
+
+class Portaled extends Component {
+ static defaultProps = {
+ component: 'div',
+ onClose: noop,
+ theme
+ };
+
+ state = {
+ pos: null,
+ isVisible: false
+ };
+
+ componentDidMount() {
+ // relative
+ this.unsubscribe = subscribe(this.handleScroll);
+ this.handleScroll();
+ }
+
+ componentDidUpdate(prevProps) {
+ const didOpen = this.props.isOpened && !prevProps.isOpened;
+ const didClose = !this.props.isOpened && prevProps.isOpened;
+ if (didOpen || didClose) {
+ window.requestAnimationFrame(() => {
+ if (this._unmounted) return;
+ this.setState({isVisible: didOpen});
+ });
+ }
+
+ this.handleScroll();
+ }
+
+ componentWillUnmount() {
+ this._unmounted = true;
+ this.unsubscribe();
+ }
+
+ element = createRef();
+ child = createRef();
+
+ // eslint-disable-next-line complexity
+ handleScroll = () => {
+ if (this.child.current) {
+ const rect = this.element.current.getBoundingClientRect();
+ const childRect = this.child.current && this.child.current.getBoundingClientRect();
+ const pageOffset = getPageOffset();
+ const {top: topOffset, left: leftOffset, right: rightOffset} = this.props;
+
+ const pos = getChildPos({
+ offsets: {topOffset, leftOffset, rightOffset},
+ rect,
+ childRect,
+ pageOffset,
+ padding: WINDOW_PAD
+ });
+
+ if (!isEqual(pos, this.state.pos)) {
+ this.setState({pos});
+ }
+ }
+ };
+
+ render() {
+ const {
+ // relative
+ component: Comp,
+ overlayZIndex,
+ isOpened,
+ onClose,
+
+ // Mordal
+ children,
+ modalProps
+ } = this.props;
+
+ const {isVisible, pos} = this.state;
+
+ const modalStyle = {
+ ...defaultModalStyle,
+ overlay: {
+ ...defaultModalStyle.overlay,
+ // needs to be on top of existing modal
+ zIndex: overlayZIndex || 9999
+ }
+ };
+
+ return (
+ <RootContext.Consumer>
+ {context => (
+ <Comp ref={this.element}>
+ {isOpened ? (
+ <Modal
+ className="modal-portal"
+ {...modalProps}
+ ariaHideApp={false}
+ isOpen
+ style={modalStyle}
+ parentSelector={() => {
+ // React modal issue: https://github.com/reactjs/react-modal/issues/769
+ // failed to execute removeChild on parent node when it is already unmounted
+ return (
+ (context && context.current) || {
+ removeChild: () => {},
+ appendChild: () => {}
+ }
+ );
+ }}
+ onRequestClose={onClose}
+ >
+ <div
+ className="portaled-content"
+ key="item"
+ style={{
+ position: 'fixed',
+ opacity: isVisible ? 1 : 0,
+ top: this.state.top,
+ transition: this.props.theme.transition,
+ marginTop: isVisible ? '0px' : '14px',
+ ...pos
+ }}
+ >
+ <div
+ ref={this.child}
+ style={{
+ position: 'absolute',
+ zIndex: overlayZIndex ? overlayZIndex + 1 : 10000
+ }}
+ >
+ {children}
+ </div>
+ </div>
+ </Modal>
+ ) : null}
+ </Comp>
+ )}
+ </RootContext.Consumer>
+ );
+ }
+}
+
+export default withTheme(Portaled);
diff --git a/src/components/common/styled-components.js b/src/components/common/styled-components.js
index abfad25cb..c6947ab73 100644
--- a/src/components/common/styled-components.js
+++ b/src/components/common/styled-components.js
@@ -291,7 +291,8 @@ export const StyledPanelHeader = styled.div`
export const StyledPanelDropdown = styled.div`
${props => props.theme.panelDropdownScrollBar}
- background-color: ${props => props.theme.panelBackground};
+ background-color: ${props =>
+ props.type === 'light' ? props.theme.modalDropdownBackground : props.theme.panelBackground};
overflow-y: auto;
box-shadow: ${props => props.theme.panelBoxShadow};
border-radius: ${props => props.theme.panelBorderRadius};
diff --git a/src/components/context.js b/src/components/context.js
index a24f4c241..f91e8766f 100644
--- a/src/components/context.js
+++ b/src/components/context.js
@@ -27,4 +27,6 @@ const KeplerGlContext = createContext({
id: 'map'
});
+export const RootContext = createContext(null);
+
export default KeplerGlContext;
diff --git a/src/components/kepler-gl.js b/src/components/kepler-gl.js
index b3440e488..12baf74ce 100644
--- a/src/components/kepler-gl.js
+++ b/src/components/kepler-gl.js
@@ -24,6 +24,7 @@ import {bindActionCreators} from 'redux';
import styled, {ThemeProvider, withTheme} from 'styled-components';
import {createSelector} from 'reselect';
import {connect as keplerGlConnect} from 'connect/keplergl-connect';
+import {RootContext} from 'components/context';
import * as VisStateActions from 'actions/vis-state-actions';
import * as MapStateActions from 'actions/map-state-actions';
@@ -138,6 +139,7 @@ function KeplerGlFactory(
}
root = createRef();
+ static contextType = RootContext;
/* selectors */
themeSelector = props => props.theme;
@@ -333,67 +335,71 @@ function KeplerGlFactory(
const theme = this.availableThemeSelector(this.props);
return (
- <ThemeProvider theme={theme}>
- <GlobalStyle
- width={width}
- height={height}
- className="kepler-gl"
- id={`kepler-gl__${id}`}
- ref={this.root}
- >
- <NotificationPanel {...notificationPanelFields} />
- {!uiState.readOnly && <SidePanel {...sideFields} />}
- <div className="maps" style={{display: 'flex'}}>
- {mapContainers}
- </div>
- {isExporting && (
- <PlotContainer
- width={width}
- height={height}
- exportImageSetting={uiState.exportImage}
- mapFields={mapFields}
- addNotification={uiStateActions.addNotification}
- startExportingImage={uiStateActions.startExportingImage}
- setExportImageDataUri={uiStateActions.setExportImageDataUri}
- setExportImageError={uiStateActions.setExportImageError}
+ <RootContext.Provider value={this.root}>
+ <ThemeProvider theme={theme}>
+ <GlobalStyle
+ width={width}
+ height={height}
+ className="kepler-gl"
+ id={`kepler-gl__${id}`}
+ ref={this.root}
+ >
+ <NotificationPanel {...notificationPanelFields} />
+ {!uiState.readOnly && <SidePanel {...sideFields} />}
+ <div className="maps" style={{display: 'flex'}}>
+ {mapContainers}
+ </div>
+ {isExporting && (
+ <PlotContainer
+ width={width}
+ height={height}
+ exportImageSetting={uiState.exportImage}
+ mapFields={mapFields}
+ addNotification={uiStateActions.addNotification}
+ startExportingImage={uiStateActions.startExportingImage}
+ setExportImageDataUri={uiStateActions.setExportImageDataUri}
+ setExportImageError={uiStateActions.setExportImageError}
+ />
+ )}
+ <BottomWidget
+ filters={filters}
+ datasets={datasets}
+ uiState={uiState}
+ layers={layers}
+ animationConfig={animationConfig}
+ visStateActions={visStateActions}
+ sidePanelWidth={
+ uiState.readOnly
+ ? 0
+ : this.props.sidePanelWidth + DIMENSIONS.sidePanel.margin.left
+ }
+ containerW={containerW}
/>
- )}
- <BottomWidget
- filters={filters}
- datasets={datasets}
- uiState={uiState}
- layers={layers}
- animationConfig={animationConfig}
- visStateActions={visStateActions}
- sidePanelWidth={
- uiState.readOnly ? 0 : this.props.sidePanelWidth + DIMENSIONS.sidePanel.margin.left
- }
- containerW={containerW}
- />
- <ModalContainer
- mapStyle={mapStyle}
- visState={visState}
- mapState={mapState}
- uiState={uiState}
- mapboxApiAccessToken={mapboxApiAccessToken}
- mapboxApiUrl={mapboxApiUrl}
- visStateActions={visStateActions}
- uiStateActions={uiStateActions}
- mapStyleActions={mapStyleActions}
- providerActions={providerActions}
- rootNode={this.root.current}
- containerW={containerW}
- containerH={mapState.height}
- providerState={this.props.providerState}
- // User defined cloud provider props
- cloudProviders={this.props.cloudProviders}
- onExportToCloudSuccess={this.props.onExportToCloudSuccess}
- onLoadCloudMapSuccess={this.props.onLoadCloudMapSuccess}
- onLoadCloudMapError={this.props.onLoadCloudMapError}
- onExportToCloudError={this.props.onExportToCloudError}
- />
- </GlobalStyle>
- </ThemeProvider>
+ <ModalContainer
+ mapStyle={mapStyle}
+ visState={visState}
+ mapState={mapState}
+ uiState={uiState}
+ mapboxApiAccessToken={mapboxApiAccessToken}
+ mapboxApiUrl={mapboxApiUrl}
+ visStateActions={visStateActions}
+ uiStateActions={uiStateActions}
+ mapStyleActions={mapStyleActions}
+ providerActions={providerActions}
+ rootNode={this.root.current}
+ containerW={containerW}
+ containerH={mapState.height}
+ providerState={this.props.providerState}
+ // User defined cloud provider props
+ cloudProviders={this.props.cloudProviders}
+ onExportToCloudSuccess={this.props.onExportToCloudSuccess}
+ onLoadCloudMapSuccess={this.props.onLoadCloudMapSuccess}
+ onLoadCloudMapError={this.props.onLoadCloudMapError}
+ onExportToCloudError={this.props.onExportToCloudError}
+ />
+ </GlobalStyle>
+ </ThemeProvider>
+ </RootContext.Provider>
);
}
}
diff --git a/src/components/modal-container.js b/src/components/modal-container.js
index ebf3b5bd8..58856e375 100644
--- a/src/components/modal-container.js
+++ b/src/components/modal-container.js
@@ -63,6 +63,8 @@ import {EXPORT_MAP_FORMATS} from '../constants/default-settings';
const DataTableModalStyle = css`
top: 80px;
padding: 32px 0 0 0;
+ width: 90vw;
+ max-width: 90vw;
${media.portable`
padding: 0;
@@ -263,6 +265,9 @@ export default function ModalContainerFactory(
datasets={datasets}
dataId={editingDataset}
showDatasetTable={visStateActions.showDatasetTable}
+ sortTableColumn={visStateActions.sortTableColumn}
+ pinTableColumn={visStateActions.pinTableColumn}
+ copyTableColumn={visStateActions.copyTableColumn}
/>
);
diff --git a/src/components/modals/data-table-modal.js b/src/components/modals/data-table-modal.js
index d649e3df9..9c9bc5bb2 100644
--- a/src/components/modals/data-table-modal.js
+++ b/src/components/modals/data-table-modal.js
@@ -19,9 +19,12 @@
// THE SOFTWARE.
import React from 'react';
-import styled from 'styled-components';
-import DataGridFactory from 'components/common/datagrid';
+import styled, {withTheme} from 'styled-components';
import DatasetLabel from 'components/common/dataset-label';
+import DataTableFactory from 'components/common/data-table';
+import {createSelector} from 'reselect';
+import {renderedSize} from 'components/common/data-table/cell-size';
+import CanvasHack from 'components/common/data-table/canvas';
const dgSettings = {
sidePadding: '38px',
@@ -71,31 +74,120 @@ export const DatasetTabs = React.memo(({activeDataset, datasets, showDatasetTabl
DatasetTabs.displayName = 'DatasetTabs';
-DataTableModalFactory.deps = [DataGridFactory];
+DataTableModalFactory.deps = [DataTableFactory];
-function DataTableModalFactory(DataGrid) {
- const DataTableModal = React.memo(({datasets, dataId, height, showDatasetTable, width}) => {
- if (!datasets || !dataId) {
- return null;
- }
+const TableContainer = styled.div`
+ display: flex;
+ flex-direction: column;
+ flex-grow: 1;
+ min-height: 70vh;
+ max-height: 70vh;
+`;
- const activeDataset = datasets[dataId];
- const rows = activeDataset.allData;
-
- return (
- <StyledModal className="dataset-modal">
- <DatasetTabs
- activeDataset={activeDataset}
- datasets={datasets}
- showDatasetTable={showDatasetTable}
- />
- <DataGrid width={width} height={height} rows={rows} columns={activeDataset.fields} />
- </StyledModal>
+function DataTableModalFactory(DataTable) {
+ class DataTableModal extends React.Component {
+ datasetCellSizeCache = {};
+ dataId = props => props.dataId;
+ datasets = props => props.datasets;
+ fields = props => (props.datasets[props.dataId] || {}).fields;
+ columns = createSelector(this.fields, fields => fields.map(f => f.name));
+ colMeta = createSelector(this.fields, fields =>
+ fields.reduce(
+ (acc, {name, type}) => ({
+ ...acc,
+ [name]: type
+ }),
+ {}
+ )
);
- });
+ cellSizeCache = createSelector(this.dataId, this.datasets, (dataId, datasets) => {
+ if (!this.props.datasets[dataId]) {
+ return {};
+ }
+ const {fields, allData} = this.props.datasets[dataId];
+
+ let showCalculate = null;
+ if (!this.datasetCellSizeCache[dataId]) {
+ showCalculate = true;
+ } else if (
+ this.datasetCellSizeCache[dataId].fields !== fields ||
+ this.datasetCellSizeCache[dataId].allData !== allData
+ ) {
+ showCalculate = true;
+ }
+
+ if (!showCalculate) {
+ return this.datasetCellSizeCache[dataId].cellSizeCache;
+ }
+
+ const cellSizeCache = fields.reduce(
+ (acc, field, colIdx) => ({
+ ...acc,
+ [field.name]: renderedSize({
+ text: {
+ rows: allData,
+ column: field.name
+ },
+ colIdx,
+ type: field.type,
+ fontSize: this.props.theme.cellFontSize,
+ font: this.props.theme.fontFamily
+ })
+ }),
+ {}
+ );
+ // save it to cache
+ this.datasetCellSizeCache[dataId] = {
+ cellSizeCache,
+ fields,
+ allData
+ };
+ return cellSizeCache;
+ });
+
+ render() {
+ const {datasets, dataId, showDatasetTable} = this.props;
+ if (!datasets || !dataId) {
+ return null;
+ }
+
+ const activeDataset = datasets[dataId];
+ const columns = this.columns(this.props);
+ const colMeta = this.colMeta(this.props);
+ const cellSizeCache = this.cellSizeCache(this.props);
+
+ return (
+ <StyledModal className="dataset-modal" id="dataset-modal">
+ <CanvasHack />
+ <TableContainer>
+ <DatasetTabs
+ activeDataset={activeDataset}
+ datasets={datasets}
+ showDatasetTable={showDatasetTable}
+ />
+ {datasets[dataId] ? (
+ <DataTable
+ key={dataId}
+ dataId={dataId}
+ columns={columns}
+ colMeta={colMeta}
+ cellSizeCache={cellSizeCache}
+ rows={activeDataset.allData}
+ pinnedColumns={activeDataset.pinnedColumns}
+ sortOrder={activeDataset.sortOrder}
+ sortColumn={activeDataset.sortColumn}
+ copyTableColumn={this.props.copyTableColumn}
+ pinTableColumn={this.props.pinTableColumn}
+ sortTableColumn={this.props.sortTableColumn}
+ />
+ ) : null}
+ </TableContainer>
+ </StyledModal>
+ );
+ }
+ }
- DataTableModal.displayName = 'DataTableModal';
- return DataTableModal;
+ return withTheme(DataTableModal);
}
export default DataTableModalFactory;
diff --git a/src/components/side-panel/layer-panel/custom-palette.js b/src/components/side-panel/layer-panel/custom-palette.js
index 857a2ef49..d4d32e28f 100644
--- a/src/components/side-panel/layer-panel/custom-palette.js
+++ b/src/components/side-panel/layer-panel/custom-palette.js
@@ -21,10 +21,9 @@
import React, {Component, createRef} from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
-import {createSelector} from 'reselect';
-import styled, {withTheme, css} from 'styled-components';
+import styled, {css} from 'styled-components';
import {sortableContainer, sortableElement, sortableHandle} from 'react-sortable-hoc';
-import Modal from 'react-modal';
+import Portaled from 'components/common/portaled';
import {Button, InlineInput} from 'components/common/styled-components';
import {VertDots, Trash} from 'components/common/icons';
@@ -147,69 +146,15 @@ class CustomPalette extends Component {
colors: PropTypes.arrayOf(PropTypes.string)
}),
setCustomPalette: PropTypes.func,
- showSketcher: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
- theme: PropTypes.object,
- defaultSketcherPos: PropTypes.object,
- sketcherHeight: PropTypes.number,
- bottomBuffer: PropTypes.number
- };
-
- static defaultProps = {
- defaultSketcherPos: {top: '320px', left: '320px'},
- sketcherHeight: 228,
- bottomBuffer: 212
+ showSketcher: PropTypes.oneOfType([PropTypes.bool, PropTypes.number])
};
state = {
- // currentSwatchIndex: null,
isSorting: false
};
root = createRef();
- // derive sketcher position based on root component
- showSketcherSelector = props => props.showSketcher;
- themeSelector = props => props.theme;
- sketcherPosSelector = createSelector(this.showSketcherSelector, (showSketcher, theme = {}) => {
- const {defaultSketcherPos, bottomBuffer, sketcherHeight} = this.props;
- if (showSketcher === false || !this.root || !this.root.current) return defaultSketcherPos;
- const {sidePanelInnerPadding = 16, sidePanel = {}, sidePanelScrollBarWidth = 10} = theme;
- const sidePanelLeft = (sidePanel.margin || {}).left || 20;
- const offsetX = sidePanelInnerPadding + sidePanelLeft + sidePanelScrollBarWidth;
- // find component Root position
- const bounding = this.root.current.getBoundingClientRect();
- const {x, y, width} = bounding;
-
- // set the top so it won't collide with bottom widget
- const top =
- y + sketcherHeight <= window.innerHeight - bottomBuffer
- ? y
- : window.innerHeight - bottomBuffer - sketcherHeight;
-
- return {top: `${top}px`, left: `${x + width + offsetX}px`};
- });
-
- modalStylesSelector = createSelector(
- this.themeSelector,
- this.sketcherPosSelector,
- (theme, sketcherPos) => ({
- content: {
- top: 0,
- left: 0,
- border: 0,
- right: 'auto',
- bottom: 'auto',
- padding: '0px 0px 0px 0px',
- borderRadius: theme.panelBorderRadius || '2px'
- },
- overlay: {
- ...sketcherPos,
- right: 'auto',
- bottom: 'auto',
- backgroundColor: 'rgba(0, 0, 0, 0)'
- }
- })
- );
_setColorPaletteUI(colors) {
this.props.setCustomPalette({
colors
@@ -274,7 +219,6 @@ class CustomPalette extends Component {
render() {
const {colors} = this.props.customPalette;
- const modalStyles = this.modalStylesSelector(this.props);
return (
<div className="custom-palette-panel" ref={this.root}>
@@ -324,36 +268,20 @@ class CustomPalette extends Component {
Confirm
</Button>
<Button link onClick={this.props.onCancel}>
- {' '}
Cancel
</Button>
</StyledButtonContainer>
- {this.props.showSketcher !== false ? (
- <Modal
- isOpen
- style={modalStyles}
- ariaHideApp={false}
- parentSelector={() => {
- // React modal issue: https://github.com/reactjs/react-modal/issues/769
- // failed to execute removeChild on parent node when it is already unmounted
- return (
- this.root.current || {
- removeChild: () => {},
- appendChild: () => {}
- }
- );
- }}
- >
- <CustomPicker
- color={colors[this.props.showSketcher]}
- onChange={this._onPickerUpdate}
- onSwatchClose={this._onSwatchClose}
- />
- </Modal>
- ) : null}
+
+ <Portaled isOpened={this.props.showSketcher !== false} left={280} top={-300}>
+ <CustomPicker
+ color={colors[this.props.showSketcher]}
+ onChange={this._onPickerUpdate}
+ onSwatchClose={this._onSwatchClose}
+ />
+ </Portaled>
</div>
);
}
}
-export default withTheme(CustomPalette);
+export default CustomPalette;
diff --git a/src/components/side-panel/panel-dropdown.js b/src/components/side-panel/panel-dropdown.js
index cd0dbf98d..e02448a85 100644
--- a/src/components/side-panel/panel-dropdown.js
+++ b/src/components/side-panel/panel-dropdown.js
@@ -26,11 +26,13 @@ import listensToClickOutside from 'react-onclickoutside';
class ClickOutsideCloseDropdown extends Component {
static propTypes = {
onClose: PropTypes.func,
- show: PropTypes.bool
+ show: PropTypes.bool,
+ type: PropTypes.string
};
static defaultProps = {
- show: true
+ show: true,
+ type: 'dark'
};
handleClickOutside = e => {
@@ -41,7 +43,7 @@ class ClickOutsideCloseDropdown extends Component {
render() {
return (
- <StyledPanelDropdown className={this.props.className}>
+ <StyledPanelDropdown type={this.props.type} className={this.props.className}>
{this.props.children}
</StyledPanelDropdown>
);
diff --git a/src/constants/action-types.js b/src/constants/action-types.js
index 04c44e445..9e1304adb 100644
--- a/src/constants/action-types.js
+++ b/src/constants/action-types.js
@@ -98,6 +98,9 @@ const ActionTypes = keyMirror({
TOGGLE_FEATURE_LAYER: null,
APPLY_CPU_FILTER: null,
SET_MAP_INFO: null,
+ SORT_TABLE_COLUMN: null,
+ PIN_TABLE_COLUMN: null,
+ COPY_TABLE_COLUMN: null,
// mapState
UPDATE_MAP: null,
diff --git a/src/constants/default-settings.js b/src/constants/default-settings.js
index 18e603592..2b7d2051d 100644
--- a/src/constants/default-settings.js
+++ b/src/constants/default-settings.js
@@ -30,6 +30,18 @@ import {
scaleLog,
scalePoint
} from 'd3-scale';
+import {
+ Layers,
+ FilterFunnel,
+ Settings,
+ CursorClick,
+ Pin,
+ ArrowDown,
+ ArrowUp,
+ Clipboard,
+ Cancel
+} from 'components/common/icons';
+import {getHTMLMapModeTileUrl} from 'utils/utils';
export const ACTION_PREFIX = '@@kepler.gl/';
export const CLOUDFRONT = 'https://d1a3f4spazzrp4.cloudfront.net/kepler.gl';
@@ -108,9 +120,6 @@ export const OVERWRITE_MAP_ID = 'overwriteMap';
*/
export const SHARE_MAP_ID = 'shareMap';
-import {Layers, FilterFunnel, Settings, CursorClick} from 'components/common/icons';
-import {getHTMLMapModeTileUrl} from 'utils/utils';
-
export const KEPLER_GL_NAME = 'kepler.gl';
// __PACKAGE_VERSION__ is automatically injected by Babel/Webpack during the building process
@@ -308,6 +317,51 @@ export const ALL_FIELD_TYPES = keyMirror({
point: null
});
+// Data Table
+export const SORT_ORDER = keyMirror({
+ ASCENDING: null,
+ DESCENDING: null,
+ UNSORT: null
+});
+
+export const TABLE_OPTION = keyMirror({
+ SORT_ASC: null,
+ SORT_DES: null,
+ UNSORT: null,
+ PIN: null,
+ UNPIN: null,
+ COPY: null
+});
+
+export const TABLE_OPTION_LIST = [
+ {
+ value: TABLE_OPTION.SORT_ASC,
+ display: 'Sort Ascending',
+ icon: ArrowUp,
+ condition: props => props.sortMode !== SORT_ORDER.ASCENDING
+ },
+ {
+ value: TABLE_OPTION.SORT_DES,
+ display: 'Sort Descending',
+ icon: ArrowDown,
+ condition: props => props.sortMode !== SORT_ORDER.DESCENDING
+ },
+ {
+ value: TABLE_OPTION.UNSORT,
+ display: 'Unsort Column',
+ icon: Cancel,
+ condition: props => props.isSorted
+ },
+ {value: TABLE_OPTION.PIN, display: 'Pin Column', icon: Pin, condition: props => !props.isPinned},
+ {
+ value: TABLE_OPTION.UNPIN,
+ display: 'Unpin Column',
+ icon: Cancel,
+ condition: props => props.isPinned
+ },
+ {value: TABLE_OPTION.COPY, display: 'Copy Column', icon: Clipboard}
+];
+
const ORANGE = '248, 194, 28';
const PINK = '231, 189, 194';
const PURPLE = '160, 106, 206';
diff --git a/src/reducers/vis-state-updaters.js b/src/reducers/vis-state-updaters.js
index 532cc04d4..0b22b8d12 100644
--- a/src/reducers/vis-state-updaters.js
+++ b/src/reducers/vis-state-updaters.js
@@ -24,6 +24,8 @@ import cloneDeep from 'lodash.clonedeep';
import uniq from 'lodash.uniq';
import get from 'lodash.get';
import xor from 'lodash.xor';
+import copy from 'copy-to-clipboard';
+import {parseFieldValue} from 'utils/data-utils';
// Tasks
import {LOAD_FILE_TASK, ACTION_TASK} from 'tasks/tasks';
@@ -50,7 +52,7 @@ import {
updateFilterDataId
} from 'utils/filter-utils';
import {setFilterGpuMode, assignGpuChannel} from 'utils/gpu-filter-utils';
-import {createNewDataEntry} from 'utils/dataset-utils';
+import {createNewDataEntry, sortDatasetByColumn} from 'utils/dataset-utils';
import {set, toArray, generateHashId} from 'utils/utils';
import {findDefaultLayer, calculateLayerData} from 'utils/layer-utils/layer-utils';
@@ -72,7 +74,7 @@ import {
import {Layer, LayerClasses} from 'layers';
import {DEFAULT_TEXT_LABEL} from 'layers/layer-factory';
-import {EDITOR_MODES, DATASET_FORMATS} from 'constants/default-settings';
+import {EDITOR_MODES, DATASET_FORMATS, SORT_ORDER} from 'constants/default-settings';
// react-palm
// disable capture exception for react-palm call to withTask
@@ -1527,7 +1529,6 @@ export function updateAllLayerDomainData(state, dataId, updatedFilter) {
const {layerData, layer} = calculateLayerData(newLayer, state, state.layerData[i]);
- // console.log('LayerData', layerData);
newLayers.push(layer);
newLayerData.push(layerData);
} else {
@@ -1774,6 +1775,60 @@ export function setPolygonFilterLayerUpdater(state, payload) {
});
}
+export function sortTableColumnUpdater(state, {dataId, column, mode}) {
+ const dataset = state.datasets[dataId];
+ if (!dataset) {
+ return state;
+ }
+ if (!mode) {
+ const currentMode = get(dataset, ['sortColumn', column]);
+ mode = currentMode
+ ? Object.keys(SORT_ORDER).find(m => m !== currentMode)
+ : SORT_ORDER.ASCENDING;
+ }
+
+ const sorted = sortDatasetByColumn(dataset, column, mode);
+ return set(['datasets', dataId], sorted, state);
+}
+
+export function pinTableColumnUpdater(state, {dataId, column}) {
+ const dataset = state.datasets[dataId];
+ if (!dataset) {
+ return state;
+ }
+ const field = dataset.fields.find(f => f.name === column);
+ if (!field) {
+ return state;
+ }
+
+ let pinnedColumns;
+ if (Array.isArray(dataset.pinnedColumns) && dataset.pinnedColumns.includes(field.name)) {
+ // unpin it
+ pinnedColumns = dataset.pinnedColumns.filter(co => co !== field.name);
+ } else {
+ pinnedColumns = (dataset.pinnedColumns || []).concat(field.name);
+ }
+
+ return set(['datasets', dataId, 'pinnedColumns'], pinnedColumns, state);
+}
+
+export function copyTableColumnUpdater(state, {dataId, column}) {
+ const dataset = state.datasets[dataId];
+ if (!dataset) {
+ return state;
+ }
+ const fieldIdx = dataset.fields.findIndex(f => f.name === column);
+ if (fieldIdx < 0) {
+ return state;
+ }
+ const {type} = dataset.fields[fieldIdx];
+ const text = dataset.allData.map(d => parseFieldValue(d[fieldIdx], type)).join('\n');
+
+ copy(text);
+
+ return state;
+}
+
/**
* Update editor
* @param {Object} state `visState`
diff --git a/src/reducers/vis-state.js b/src/reducers/vis-state.js
index 46041dbd5..73e36b2a6 100644
--- a/src/reducers/vis-state.js
+++ b/src/reducers/vis-state.js
@@ -113,7 +113,13 @@ const actionHandler = {
[ActionTypes.TOGGLE_FILTER_FEATURE]: visStateUpdaters.toggleFilterFeatureUpdater,
- [ActionTypes.APPLY_CPU_FILTER]: visStateUpdaters.applyCPUFilterUpdater
+ [ActionTypes.APPLY_CPU_FILTER]: visStateUpdaters.applyCPUFilterUpdater,
+
+ [ActionTypes.SORT_TABLE_COLUMN]: visStateUpdaters.sortTableColumnUpdater,
+
+ [ActionTypes.PIN_TABLE_COLUMN]: visStateUpdaters.pinTableColumnUpdater,
+
+ [ActionTypes.COPY_TABLE_COLUMN]: visStateUpdaters.copyTableColumnUpdater
};
// construct vis-state reducer
diff --git a/src/styles/base.js b/src/styles/base.js
index 335d9beda..50b712f4c 100644
--- a/src/styles/base.js
+++ b/src/styles/base.js
@@ -50,7 +50,7 @@ export const subtextColorActive = '#FFFFFF';
export const titleTextColor = '#FFFFFF';
export const textColorHl = '#F0F0F0';
-export const textColorHlLT = '#F1F1F1';
+export const textColorHlLT = '#000000';
export const activeColor = '#1FBAD6';
export const activeColorLT = '#2473BD';
export const activeColorHover = '#108188';
@@ -74,7 +74,7 @@ export const secondaryBtnBgdHover = '#A0A7B4';
export const linkBtnBgd = 'transparent';
export const linkBtnActBgd = linkBtnBgd;
export const linkBtnColor = '#A0A7B4';
-export const linkBtnActColor = textColorHlLT;
+export const linkBtnActColor = '#F1F1F1';
export const linkBtnActBgdHover = linkBtnBgd;
export const negativeBtnBgd = errorColor;
@@ -137,8 +137,10 @@ export const selectBorderRadius = '1px';
export const selectBorder = 0;
export const dropdownListHighlightBg = '#6A7485';
+export const dropdownListHighlightBgLT = '#F8F8F9';
export const dropdownListShadow = '0 6px 12px 0 rgba(0,0,0,0.16)';
export const dropdownListBgd = '#3A414C';
+export const dropdownListBgdLT = '#FFFFFF';
export const dropdownListBorderTop = '#242730';
export const dropdownWrapperZ = 100;
// Switch
@@ -188,7 +190,7 @@ export const panelHeaderIconActive = '#A0A7B4';
export const panelHeaderHeight = 48;
export const panelBoxShadow = '0 6px 12px 0 rgba(0,0,0,0.16)';
export const panelBorderRadius = '2px';
-export const panelBackgroundLT = '#f8f8f9';
+export const panelBackgroundLT = '#F8F8F9';
export const panelBorderColor = '#3A414C';
export const panelBorder = `1px solid ${borderColor}`;
@@ -220,6 +222,7 @@ export const modalContentZ = 10002;
export const modalFooterZ = 10001;
export const modalTitleZ = 10003;
export const modalButtonZ = 10005;
+export const modalDropdownBackground = '#FFFFFF';
// Modal Dialog (Dark)
export const modalDialogBgd = '#3A414C';
@@ -258,16 +261,23 @@ export const notificationPanelWidth = 240;
export const notificationPanelItemWidth = notificationPanelWidth - 60;
export const notificationPanelItemHeight = 60;
-// Datagrid
-const columnWidth = 200;
-const cellHeaderHeight = 72;
-const cellHeight = 24;
-const cellPaddingSide = 18;
-const extendCellHeight = 2 * cellHeight;
-const extendColumnWidth = 2 * columnWidth;
-const gridDefaultWidth = 800;
-const gridDefaultHeight = 600;
+// Data Table
+const headerRowHeight = 70;
+const rowHeight = 32;
+const headerPaddingTop = 6;
+const headerPaddingBottom = 12;
+const cellPaddingSide = 10;
+const edgeCellPaddingSide = 10;
+const cellFontSize = 10;
const gridPaddingSide = 24;
+const headerCellBackground = '#FFFFFF';
+const headerCellBorderColor = '#E0E0E0';
+const headerCellIconColor = '#666666';
+const cellBorderColor = '#E0E0E0';
+const evenRowBackground = '#FFFFFF';
+const oddRowBackground = '#F7F7F7';
+const optionButtonColor = '#6A7485';
+const pinnedGridBorderColor = '#E0E0E0';
// Floating Time display
const timeDisplayBorderRadius = 32;
@@ -627,11 +637,15 @@ const dropdownListAnchor = css`
padding-left: 3px;
`;
-const dropdownListItem = css`
+const dropdownListSize = css`
font-size: 11px;
padding: 3px 9px;
font-weight: 500;
+ white-space: nowrap;
+`;
+const dropdownListItem = css`
+ ${dropdownListSize}
&.hover,
&:hover {
cursor: pointer;
@@ -643,6 +657,22 @@ const dropdownListItem = css`
}
`;
+const dropdownListItemLT = css`
+ ${dropdownListSize}
+ color: ${props => props.theme.textColorLT};
+
+ &.hover,
+ &:hover {
+ cursor: pointer;
+ color: ${props => props.theme.textColorHlLT};
+ background-color: ${props => props.theme.dropdownListHighlightBgLT};
+
+ .list__item__anchor {
+ color: ${props => props.theme.textColorHlLT};
+ }
+ }
+`;
+
const dropdownListHeader = css`
font-size: 11px;
padding: 5px 9px;
@@ -679,6 +709,12 @@ const dropdownList = css`
${props => props.theme.dropdownScrollBar};
`;
+const dropdownListLT = css`
+ ${dropdownList}
+ .list__item {
+ ${props => props.theme.dropdownListItemLT};
+ }
+`;
const sidePanelScrollBar = css`
::-webkit-scrollbar {
height: ${props => props.theme.sidePanelScrollBarHeight}px;
@@ -812,7 +848,9 @@ export const theme = {
secondaryInput,
dropdownScrollBar,
dropdownList,
+ dropdownListLT,
dropdownListItem,
+ dropdownListItemLT,
dropdownListAnchor,
dropdownListHeader,
dropdownListSection,
@@ -841,7 +879,9 @@ export const theme = {
boxShadow,
errorColor,
dropdownListHighlightBg,
+ dropdownListHighlightBgLT,
dropdownListBgd,
+ dropdownListBgdLT,
dropdownListBorderTop,
labelColor,
@@ -972,6 +1012,7 @@ export const theme = {
modalFooterZ,
modalTitleZ,
modalButtonZ,
+ modalDropdownBackground,
// Side Panel
sidePanelBg,
@@ -1048,17 +1089,23 @@ export const theme = {
notificationPanelItemWidth,
notificationPanelItemHeight,
- // datagrid
- columnWidth,
- extendColumnWidth,
- cellHeaderHeight,
- cellHeight,
+ // Data Table
+ headerRowHeight,
+ rowHeight,
+ headerPaddingTop,
+ headerPaddingBottom,
cellPaddingSide,
- extendCellHeight,
- gridDefaultWidth,
- gridDefaultHeight,
+ edgeCellPaddingSide,
+ cellFontSize,
gridPaddingSide,
-
+ optionButtonColor,
+ headerCellBackground,
+ headerCellBorderColor,
+ headerCellIconColor,
+ cellBorderColor,
+ evenRowBackground,
+ oddRowBackground,
+ pinnedGridBorderColor,
// time display
timeDisplayBorderRadius,
timeDisplayHeight,
diff --git a/src/utils/dataset-utils.js b/src/utils/dataset-utils.js
index 6c168b2ad..7883b24d1 100644
--- a/src/utils/dataset-utils.js
+++ b/src/utils/dataset-utils.js
@@ -18,13 +18,33 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// 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 tdahe 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 {hexToRgb} from './color-utils';
import uniq from 'lodash.uniq';
-import {TRIP_POINT_FIELDS} from 'constants/default-settings';
+import {TRIP_POINT_FIELDS, SORT_ORDER} from 'constants/default-settings';
import {generateHashId} from './utils';
import {validateInputData} from 'processors/data-processor';
import {getGpuFilterProps} from 'utils/gpu-filter-utils';
-
+import {ascending, descending} from 'd3-array';
// apply a color for each dataset
// to use as label colors
const datasetColors = [
@@ -162,3 +182,34 @@ export function findPointFieldPairs(fields) {
return carry;
}, []);
}
+
+export function sortDatasetByColumn(dataset, column, mode) {
+ const {allIndexes, fields, allData} = dataset;
+ const fieldIndex = fields.findIndex(f => f.name === column);
+ if (fieldIndex < 0) {
+ return dataset;
+ }
+
+ const sortBy = SORT_ORDER[mode] || SORT_ORDER.ASCENDING;
+
+ if (sortBy === SORT_ORDER.UNSORT) {
+ return {
+ ...dataset,
+ sortColumn: {},
+ sortOrder: null
+ };
+ }
+
+ const sortFunction = sortBy === SORT_ORDER.ASCENDING ? ascending : descending;
+ const sortOrder = allIndexes
+ .slice()
+ .sort((a, b) => sortFunction(allData[a][fieldIndex], allData[b][fieldIndex]));
+
+ return {
+ ...dataset,
+ sortColumn: {
+ [column]: sortBy
+ },
+ sortOrder
+ };
+}
diff --git a/test/browser/components/modals/data-table-modal-test.js b/test/browser/components/modals/data-table-modal-test.js
index c538a50e1..a116b0741 100644
--- a/test/browser/components/modals/data-table-modal-test.js
+++ b/test/browser/components/modals/data-table-modal-test.js
@@ -19,111 +19,333 @@
// THE SOFTWARE.
import React from 'react';
-import test from 'tape';
+import test from 'tape-catch';
+import global from 'global';
+import sinon from 'sinon';
+import flatten from 'lodash.flattendeep';
+import {mount} from 'enzyme';
import {mountWithTheme} from 'test/helpers/component-utils';
+import CloneDeep from 'lodash.clonedeep';
+import * as VisStateActions from 'actions/vis-state-actions';
+import visStateReducer from 'reducers/vis-state';
+import FieldToken from 'components/common/field-token';
+import {VertThreeDots, ArrowUp} from 'components/common/icons';
import DataTableModalFactory, {
DatasetTabs,
DatasetModalTab
} from 'components/modals/data-table-modal';
-import DataGridFactory, {FieldHeaderFactory, CellFactory} from 'components/common/datagrid';
+import {DataTable} from 'components/common/data-table';
+import OptionDropdown from 'components/common/data-table/option-dropdown';
+
import {testFields, testAllData} from 'test/fixtures/test-csv-data';
import {geoStyleFields, geoStyleRows} from 'test/fixtures/geojson';
+import {StateWFiles, testCsvDataId, testGeoJsonDataId} from 'test/helpers/mock-state';
+
+const DataTableModal = DataTableModalFactory(DataTable);
+
+const expectedCellSizeCache = {
+ 'gps_data.utc_timestamp': {row: 145, header: 150},
+ 'gps_data.lat': {row: 96, header: 108},
+ 'gps_data.lng': {row: 96, header: 110},
+ 'gps_data.types': {row: 125, header: 123},
+ epoch: {row: 121, header: 90},
+ has_result: {row: 75, header: 99},
+ id: {row: 75, header: 90},
+ time: {row: 180, header: 90},
+ begintrip_ts_utc: {row: 182, header: 129},
+ begintrip_ts_local: {row: 182, header: 137},
+ date: {row: 95, header: 90}
+};
+
+const expectedExpandedCellSize = {
+ cellSizeCache: {
+ 'gps_data.utc_timestamp': 145,
+ 'gps_data.lat': 96,
+ 'gps_data.lng': 96,
+ 'gps_data.types': 125,
+ epoch: 121,
+ has_result: 75,
+ id: 75,
+ time: 180,
+ begintrip_ts_utc: 182,
+ begintrip_ts_local: 182,
+ date: 95
+ },
+ ghost: undefined
+};
-const FieldHeader = FieldHeaderFactory();
-const Cell = CellFactory();
-const DataGrid = DataGridFactory(FieldHeader, Cell);
-const DataTableModal = DataTableModalFactory(DataGrid);
+// This is to Mock Canvas.measureText response which we will not be testing
+const testMeasure = [573, 17, 87, 566, 87, 447, 17, 87];
+const texts = [
+ [
+ '{"type":"Polygon","coordinates":[[[-74.158491,40.835947],[-74.157914,40.83902],[-74.148473,40.834522]]]}',
+ 7.5,
+ 'C_Medium_High'
+ ],
+ [
+ '{"type":"Polygon","coordinates":[[[-74.31687,40.656696],[-74.319449,40.658154],[-74.31687,40.656696]]]}',
+ null,
+ 'C_Medium_High'
+ ],
+ [
+ '{"type":"Polygon","coordinates":[[[-74.387589,40.632238],[-74.387589,40.632238]]]}',
+ 7.6,
+ 'C_Medium_High'
+ ]
+];
+const testColumns = ['_geojson', 'income level of people over 65', 'engagement'];
+const testColumnMeasure = [46, 159, 65];
+function mockCanvas(globalWindow) {
+ globalWindow.HTMLCanvasElement.prototype.getContext = function mockGetContext() {
+ return {
+ measureText: text => {
+ const index = flatten(texts).indexOf(text);
+ if (index >= 0) {
+ return {width: testMeasure[index]};
+ }
+ const cIdx = testColumns.indexOf(text);
+ if (cIdx >= 0) {
+ return {width: testColumnMeasure[cIdx]};
+ }
+ return {width: 0};
+ }
+ };
+ };
+}
-// This makes sure react-virtualized renders the full grid
+let oldGetContext;
+function prepareMockCanvas() {
+ oldGetContext = global.window.HTMLCanvasElement.prototype.getContext;
+ mockCanvas(global.window);
+}
-// width needs to be large enough to fit all
-const WIDTH = 2100;
-const HEIGHT = 800;
-const rows = testAllData.length;
+function restoreMockCanvas() {
+ global.window.HTMLCanvasElement.prototype.getContext = oldGetContext;
+}
/* eslint-disable max-statements */
test('Components -> DataTableModal.render: csv 1', t => {
t.doesNotThrow(() => {
- mountWithTheme(<DataTableModal width={WIDTH} height={HEIGHT} />);
+ mountWithTheme(<DataTableModal />);
}, 'Show not fail without data');
+ const wrapper = mountWithTheme(
+ <DataTableModal datasets={StateWFiles.visState.datasets} dataId={testCsvDataId} />
+ );
+
+ t.equal(wrapper.find(DataTableModal).length, 1, 'should render DataTableModal data');
+ t.equal(wrapper.find(DatasetTabs).length, 1, 'should render DatasetTabs');
+ t.equal(wrapper.find(DatasetModalTab).length, 2, 'should render 1 DatasetModalTab');
+ t.equal(wrapper.find(DataTable).length, 1, 'should render 1 DataTable');
+
+ const props = wrapper
+ .find(DataTable)
+ .at(0)
+ .props();
+ const expectedColumns = [
+ 'gps_data.utc_timestamp',
+ 'gps_data.lat',
+ 'gps_data.lng',
+ 'gps_data.types',
+ 'epoch',
+ 'has_result',
+ 'id',
+ 'time',
+ 'begintrip_ts_utc',
+ 'begintrip_ts_local',
+ 'date'
+ ];
+
+ const expectedColMeta = {
+ 'gps_data.utc_timestamp': 'timestamp',
+ 'gps_data.lat': 'real',
+ 'gps_data.lng': 'real',
+ 'gps_data.types': 'string',
+ epoch: 'timestamp',
+ has_result: 'boolean',
+ id: 'integer',
+ time: 'timestamp',
+ begintrip_ts_utc: 'timestamp',
+ begintrip_ts_local: 'timestamp',
+ date: 'date'
+ };
+
+ t.deepEqual(props.columns, expectedColumns, 'DataTable should have the correct props.columns');
+ t.deepEqual(props.colMeta, expectedColMeta, 'DataTable should have the correct props.colMeta');
+ t.equal(props.rows, testAllData, 'DataTable should have the correct props.rows');
+ // we can't test it without mocking the canvas response
+ t.deepEqual(
+ Object.keys(props.cellSizeCache),
+ Object.keys(expectedColMeta),
+ 'DataTable props.cellSizeCache should have all column keys'
+ );
+
+ t.end();
+});
+
+test('Components -> DataTableModal -> click tab', t => {
+ const showDatasetTable = sinon.spy();
+
const wrapper = mountWithTheme(
<DataTableModal
- width={WIDTH}
- height={HEIGHT}
- datasets={{
- smoothie: {
- id: 'smoothie',
- allData: testAllData,
- fields: testFields,
- color: [113, 113, 113]
- }
- }}
- dataId="smoothie"
+ datasets={StateWFiles.visState.datasets}
+ dataId={testCsvDataId}
+ showDatasetTable={showDatasetTable}
/>
);
- // console.log(wrapper.debug());
+ t.equal(wrapper.find(DatasetModalTab).length, 2, 'should render 2 DatasetModalTab');
+ t.equal(
+ wrapper
+ .find(DatasetModalTab)
+ .at(0)
+ .prop('active'),
+ true,
+ 'prop 0 active should be true'
+ );
+ t.equal(
+ wrapper
+ .find(DatasetModalTab)
+ .at(0)
+ .find('.dataset-name')
+ .text(),
+ 'hello.csv',
+ 'dataset name should be correct'
+ );
+ t.equal(
+ wrapper
+ .find(DatasetModalTab)
+ .at(1)
+ .prop('active'),
+ false,
+ 'prop 1 active should be true'
+ );
+ t.equal(
+ wrapper
+ .find(DatasetModalTab)
+ .at(1)
+ .find('.dataset-name')
+ .text(),
+ 'zip.geojson',
+ 'dataset name should be correct'
+ );
+
+ wrapper
+ .find(DatasetModalTab)
+ .at(1)
+ .simulate('click');
+ t.ok(showDatasetTable.calledWith(testGeoJsonDataId));
+
+ t.end();
+});
+
+test('Components -> DataTableModal -> render DataTable: csv 1', t => {
+ const wrapper = mountWithTheme(
+ <DataTableModal datasets={StateWFiles.visState.datasets} dataId={testCsvDataId} />
+ );
+
+ t.equal(wrapper.find(DataTable).length, 1, 'should render 1 DataTable');
+
+ const props = wrapper
+ .find(DataTable)
+ .at(0)
+ .props();
+
+ // mock cellSizeCache, width and height
+ const enriched = {
+ ...props,
+ cellSizeCache: expectedCellSizeCache,
+ fixedWidth: 1300,
+ fixedHeight: 800,
+ theme: {}
+ };
+
+ const wrapper2 = mount(<DataTable {...enriched} />);
+ const componentInstance = wrapper2.instance();
+ const result = componentInstance.getCellSizeCache();
+
+ t.deepEqual(result, expectedExpandedCellSize, 'should calculate correct cell expansion');
+
+ // manully setting the state and update the component
+ wrapper2.setState(result);
+ wrapper2.update();
- t.equal(wrapper.find(DataTableModal).length, 1, 'should render DataTableModal data');
- t.equal(wrapper.find(DatasetTabs).length, 1, 'should render DatasetTabs');
- t.equal(wrapper.find(DatasetModalTab).length, 1, 'should render 1 dataset-modal-catalog');
t.equal(
- wrapper.find('Header').length,
+ wrapper2.find('.header-cell').length,
testFields.length,
`should render ${testFields.length} headers`
);
+
t.equal(
- wrapper.find('Cell').length,
- testFields.length * rows,
- `should render ${testFields.length * rows} cells`
- );
- t.equal(
- wrapper.find('StyledComponent.cell.boolean').length,
- rows,
- `should render ${rows.length} boolean cells`
+ wrapper2.find('.cell').length,
+ testFields.length * testAllData.length,
+ `should render ${testFields.length * testAllData.length} cells`
);
const expectedRows = {
0: [
- '2016-09-17 00:09:55',
- '29.9900937',
- '31.2590542',
- 'driver_analytics_0',
- '1472688000000',
- 'false',
- '1',
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:41:39+00:00',
- '2016-10-01 09:41:39+00:00',
- '2016-09-23'
+ '2016-09-17 00:09:55\t',
+ '29.9900937\t',
+ '31.2590542\t',
+ 'driver_analytics_0\t',
+ '1472688000000\t',
+ 'false\t',
+ '1\t',
+ '2016-09-23T00:00:00.000Z\t',
+ '2016-10-01 09:41:39+00:00\t',
+ '2016-10-01 09:41:39+00:00\t',
+ '2016-09-23\n'
+ ],
+ 1: [
+ '2016-09-17 00:10:56\t',
+ '29.9927699\t',
+ '31.2461142\t',
+ 'driver_analytics\t',
+ '1472688000000\t',
+ 'false\t',
+ '2\t',
+ '2016-09-23T00:00:00.000Z\t',
+ '2016-10-01 09:46:37+00:00\t',
+ '2016-10-01 16:46:37+00:00\t',
+ '2016-09-23\n'
],
2: [
- '2016-09-17 00:11:56',
- '29.9907261',
- '31.2312742',
- 'driver_analytics',
- '1472688000000',
- 'false',
- '3',
- '2016-09-23T00:00:00.000Z',
- '',
- '',
- '2016-09-23'
+ '2016-09-17 00:11:56\t',
+ '29.9907261\t',
+ '31.2312742\t',
+ 'driver_analytics\t',
+ '1472688000000\t',
+ 'false\t',
+ '3\t',
+ '2016-09-23T00:00:00.000Z\t',
+ '\t',
+ '\t',
+ '2016-09-23\n'
+ ],
+ 13: [
+ '2016-09-17 00:22:20\t',
+ '30.034391\t',
+ '31.2193991\t',
+ 'driver_analytics\t',
+ '1472754400000\t',
+ '\t',
+ '\t',
+ '2016-09-23T06:00:00.000Z\t',
+ '\t',
+ '\t',
+ '\n'
]
};
Object.entries(expectedRows).forEach(keyAndRow => {
const [index, expectedRow] = keyAndRow;
- const cells = wrapper.find(`.row-${index}`);
- t.equal(cells.length, 11, `should render 11 cells for index ${index}`);
+ const cells = wrapper2.find(`.row-${index}`);
+
+ t.equal(cells.length, testFields.length, 'should render 11 cells');
for (let c = 0; c < cells.length; c++) {
- const cellText = cells
- .at(c)
- .find('span')
- .text();
+ const cellText = cells.at(c).text();
t.equal(cellText, expectedRow[c], `should render cell ${expectedRow[c]} correctly`);
}
});
@@ -131,11 +353,147 @@ test('Components -> DataTableModal.render: csv 1', t => {
t.end();
});
+test('Components -> DataTableModal -> render DataTable: sort and pin', t => {
+ const initialState = CloneDeep(StateWFiles.visState);
+
+ // sort column
+ const nextState1 = visStateReducer(
+ initialState,
+ VisStateActions.sortTableColumn(testCsvDataId, 'gps_data.lat')
+ );
+
+ // pin column
+ const nextState2 = visStateReducer(
+ nextState1,
+ VisStateActions.pinTableColumn(testCsvDataId, 'has_result')
+ );
+
+ const wrapper = mountWithTheme(
+ <DataTableModal datasets={nextState2.datasets} dataId={testCsvDataId} />
+ );
+
+ const props = wrapper
+ .find(DataTable)
+ .at(0)
+ .props();
+
+ // mock cellSizeCache, width and height
+ const enriched = {
+ ...props,
+ cellSizeCache: expectedCellSizeCache,
+ fixedWidth: 1300,
+ fixedHeight: 800,
+ theme: {}
+ };
+
+ const wrapper2 = mount(<DataTable {...enriched} />);
+ const componentInstance = wrapper2.instance();
+ const result = componentInstance.getCellSizeCache();
+ // manully setting the state and update the component
+ wrapper2.setState(result);
+ wrapper2.update();
+
+ const expectedHeaders = [
+ 'has_result',
+ 'gps_data.utc_timestamp',
+ 'gps_data.lat',
+ 'gps_data.lng',
+ 'gps_data.types',
+ 'epoch',
+ 'id',
+ 'time',
+ 'begintrip_ts_utc',
+ 'begintrip_ts_local',
+ 'date'
+ ];
+ t.equal(
+ wrapper2.find('.header-cell').length,
+ testFields.length,
+ `should render ${testFields.length} headers`
+ );
+ t.ok(
+ wrapper2
+ .find('.header-cell')
+ .at(0)
+ .hasClass('pinned-header-cell'),
+ 'should assign pinned-header-cell class'
+ );
+ t.ok(
+ wrapper2
+ .find('.header-cell')
+ .at(0)
+ .hasClass('first-cell'),
+ 'should assign first-cell class'
+ );
+ new Array(testFields.length).fill(0).forEach((d, i) => {
+ t.equal(
+ wrapper2
+ .find('.header-cell')
+ .at(i)
+ .find('.col-name__name')
+ .text(),
+ expectedHeaders[i],
+ 'should render corrected pinned columns'
+ );
+ });
+
+ t.equal(
+ wrapper2
+ .find('.header-cell')
+ .at(2)
+ .find(ArrowUp).length,
+ 1,
+ 'should render sort icon'
+ );
+
+ t.end();
+});
+
+test('Components -> cellSize -> renderedSize', t => {
+ prepareMockCanvas();
+
+ const wrapper = mountWithTheme(
+ <DataTableModal
+ datasets={{
+ smoothie: {
+ id: 'smoothie',
+ allData: texts,
+ fields: [
+ {name: testColumns[0], type: 'geojson'},
+ {name: testColumns[1], type: 'real'},
+ {name: testColumns[2], type: 'string'}
+ ],
+ color: [113, 113, 113]
+ }
+ }}
+ dataId="smoothie"
+ />
+ );
+
+ const props = wrapper
+ .find(DataTable)
+ .at(0)
+ .props();
+
+ const expected = {
+ _geojson: {row: 400, header: 91},
+ 'income level of people over 65': {row: 117, header: 150},
+ engagement: {row: 117, header: 110}
+ };
+
+ t.deepEqual(
+ props.cellSizeCache,
+ expected,
+ 'DataTable should have the correct props.cellSizeCache'
+ );
+
+ restoreMockCanvas();
+ t.end();
+});
+
test('Components -> DataTableModal.render: csv 2', t => {
const wrapper = mountWithTheme(
<DataTableModal
- width={WIDTH}
- height={HEIGHT}
datasets={{
smoothie: {
id: 'smoothie',
@@ -148,59 +506,115 @@ test('Components -> DataTableModal.render: csv 2', t => {
dataId="smoothie"
/>
);
+ const props = wrapper
+ .find(DataTable)
+ .at(0)
+ .props();
+ const cellSizeCache = {
+ _geojson: {row: 400, header: 91},
+ fillColor: {row: 75, header: 90},
+ lineColor: {row: 75, header: 94},
+ lineWidth: {row: 75, header: 98},
+ elevation: {row: 75, header: 94},
+ radius: {row: 75, header: 90}
+ };
+ const enriched = {
+ ...props,
+ cellSizeCache,
+ fixedWidth: 1200,
+ fixedHeight: 800,
+ theme: {}
+ };
- t.equal(wrapper.find(DataTableModal).length, 1, 'should render DataTableModal data');
- t.equal(wrapper.find(DatasetTabs).length, 1, 'should render DatasetTabs');
- t.equal(wrapper.find(DatasetModalTab).length, 1, 'should render 1 dataset-modal-catalog');
- t.equal(
- wrapper.find('Header').length,
- geoStyleFields.length,
- `should render ${geoStyleFields.length} headers`
- );
- t.equal(
- wrapper.find('Cell').length,
- geoStyleFields.length * geoStyleRows.length,
- `should render ${geoStyleFields.length * geoStyleRows.length} cells`
- );
+ const expectedExpandedCellSizeGeo = {
+ cellSizeCache: {
+ _geojson: 400,
+ fillColor: 90,
+ lineColor: 94,
+ lineWidth: 98,
+ elevation: 94,
+ radius: 90
+ },
+ ghost: 334
+ };
+ const wrapper2 = mount(<DataTable {...enriched} />);
+ const componentInstance = wrapper2.instance();
+ const result = componentInstance.getCellSizeCache();
+ t.deepEqual(result, expectedExpandedCellSizeGeo, 'should calculate correct cell expansion');
+
+ wrapper2.setState(result);
+ wrapper2.update();
+
+ t.equal(wrapper2.find('.header-cell').length, 7, `should render 7 header cells`);
+
+ // test header cell
+ const expectedHeaders = [
+ geoStyleFields[0].name,
+ geoStyleFields[1].name,
+ geoStyleFields[2].name,
+ geoStyleFields[3].name,
+ geoStyleFields[4].name,
+ geoStyleFields[5].name,
+ ''
+ ];
+
+ expectedHeaders.forEach((name, index) => {
+ const header = wrapper2.find(`.header-cell.column-${index}`);
+ t.equal(header.length, 1, 'should render 1 header');
+
+ if (index < 6) {
+ const cellText = header.find('.col-name__name').text();
+ t.equal(cellText, expectedHeaders[index], 'should render correct column name');
+ const cellType = header.find(FieldToken);
+ t.equal(cellType.prop('type'), geoStyleFields[index].type, 'should render correct cell type');
+ t.equal(header.find(VertThreeDots).length, 1, 'should render more button');
+ t.equal(header.find(OptionDropdown).length, 1, 'should render OptionDropdown');
+ } else {
+ // if ghost cell
+ t.equal(header.text(), '', 'cell should be empty');
+ }
+ });
+
+ t.equal(wrapper2.find('.cell').length, 21, `should render 21 data cells`);
const expectedRows = {
0: [
- '{"type":"Feature","properties":{"fillColor":[1,2,3],"lineColor":[4,5,6],"lineWidth":1,"elevation":10,"radius":5},"geometry":{"type":"Point","coordinates":[-122.1,37.3]}}',
- '[1,2,3]',
- '[4,5,6]',
- '1',
- '10',
- '5'
+ '{"type":"Feature","properties":{"fillColor":[1,2,3],"lineColor":[4,5,6],"lineWidth":1,"elevation":10,"radius":5},"geometry":{"type":"Point","coordinates":[-122.1,37.3]}}\t',
+ '[1,2,3]\t',
+ '[4,5,6]\t',
+ '1\t',
+ '10\t',
+ '5\t',
+ '\n'
],
1: [
- '{"type":"Feature","properties":{"fillColor":[7,8,9],"lineColor":[4,5,6],"lineWidth":3,"elevation":10,"radius":5},"geometry":{"type":"Point","coordinates":[-122.2,37.2]}}',
- '[7,8,9]',
- '[4,5,6]',
- '3',
- '10',
- '5'
+ '{"type":"Feature","properties":{"fillColor":[7,8,9],"lineColor":[4,5,6],"lineWidth":3,"elevation":10,"radius":5},"geometry":{"type":"Point","coordinates":[-122.2,37.2]}}\t',
+ '[7,8,9]\t',
+ '[4,5,6]\t',
+ '3\t',
+ '10\t',
+ '5\t',
+ '\n'
],
2: [
- '{"type":"Feature","properties":{"fillColor":[1,2,3],"lineColor":[4,5,6],"lineWidth":4,"elevation":10,"radius":5},"geometry":{"type":"Point","coordinates":[-122.3,37.1]}}',
- '[1,2,3]',
- '[4,5,6]',
- '4',
- '10',
- '5'
+ '{"type":"Feature","properties":{"fillColor":[1,2,3],"lineColor":[4,5,6],"lineWidth":4,"elevation":10,"radius":5},"geometry":{"type":"Point","coordinates":[-122.3,37.1]}}\t',
+ '[1,2,3]\t',
+ '[4,5,6]\t',
+ '4\t',
+ '10\t',
+ '5\t',
+ '\n'
]
};
Object.entries(expectedRows).forEach(keyAndRow => {
const [index, expectedRow] = keyAndRow;
- const cells = wrapper.find(`.row-${index}`);
- t.equal(cells.length, 6, 'should render 6 cells');
+ const cells = wrapper2.find(`.row-${index}`);
+ t.equal(cells.length, 7, 'should render 6 cells and 1 ghost cell');
for (let c = 0; c < cells.length; c++) {
- const cellText = cells
- .at(c)
- .find('span')
- .text();
+ const cellText = cells.at(c).text();
t.equal(cellText, expectedRow[c], `should render cell ${expectedRow[c]} correctly`);
}
});
diff --git a/test/browser/index.js b/test/browser/index.js
index 72c3991d3..2c3559879 100644
--- a/test/browser/index.js
+++ b/test/browser/index.js
@@ -23,3 +23,6 @@ import './components';
// test layers
import './layer-tests';
+
+// test reducers
+import './reducers';
diff --git a/test/browser/reducers/index.js b/test/browser/reducers/index.js
new file mode 100644
index 000000000..df2f0a8f5
--- /dev/null
+++ b/test/browser/reducers/index.js
@@ -0,0 +1,49 @@
+// 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 reducer from 'reducers/vis-state';
+import CloneDeep from 'lodash.clonedeep';
+import test from 'tape-catch';
+import {StateWFiles, testCsvDataId, testGeoJsonDataId} from 'test/helpers/mock-state';
+import * as VisStateActions from 'actions/vis-state-actions';
+
+test('#visStateReducer -> COPY_TABLE_COLUMN', t => {
+ const initialState = CloneDeep(StateWFiles.visState);
+ const nextState = reducer(initialState, VisStateActions.copyTableColumn());
+ t.equal(nextState, initialState, 'state should not change when input is not given');
+
+ reducer(nextState, VisStateActions.copyTableColumn(testCsvDataId, 'gps_data.lat'));
+ const expectedCopy =
+ '29.9900937\n29.9927699\n29.9907261\n29.9870074\n29.9923041\n29.9968249\n30.0037217\n30.0116207\n30.0208925\n30.0218999\n30.0229344\n30.0264237\n30.0292134\n30.034391\n30.0352752\n30.0395918\n30.0497387\n30.0538936\n30.060911\n30.060334\n30.0554663\n30.0614122\n30.0612697\n30.0610977';
+
+ t.equal(window.clipboardData.data().text, expectedCopy, 'should copy to clipboard');
+
+ reducer(nextState, VisStateActions.copyTableColumn(testGeoJsonDataId, '_geojson'));
+
+ const expectedCopy2 =
+ `{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.40115971858505,37.78202426695214],[-122.40037436684331,37.78264451554517],[-122.40001902006377,37.782925153640136],[-122.39989147796784,37.783025880124256],[-122.398930331093,37.783784933304034]]]},"properties":{"OBJECTID":1,"ZIP_CODE":94107,"ID":94107,"TRIPS":11,"RATE":"a","OBJ":{"id":1},"index":0}}\n` +
+ `{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.39249932896719,37.79376881413398],[-122.39189026034138,37.79427854456892],[-122.39166672864975,37.794132425256194],[-122.39172303426619,37.79410061945832],[-122.39249932896719,37.79376881413398]]]},"properties":{"OBJECTID":2,"ZIP_CODE":94105,"ID":94105,"TRIPS":4,"RATE":"b","OBJ":{"id":2},"index":1}}\n` +
+ `{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.39249932896719,37.79376881413398],[-122.39189026034138,37.79427854456892],[-122.39198201510793,37.79387190612868],[-122.39249932896719,37.79376881413398]]]},"properties":{"OBJECTID":3,"ZIP_CODE":94109,"ID":94109,"TRIPS":20,"RATE":null,"OBJ":{"id":3},"index":2}}\n` +
+ `{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.39249932896719,37.79376881413398],[-122.39166672864975,37.794132425256194],[-122.39172303426619,37.79410061945832],[-122.3916732283519,37.7940478541246],[-122.39198201510793,37.79387190612868],[-122.39249932896719,37.79376881413398]]]},"properties":{"OBJECTID":4,"ZIP_CODE":94111,"ID":94111,"RATE":"c","OBJ":{"id":4},"TRIPS":null,"index":3}}\n` +
+ `{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-122.39249932896719,37.79376881413398],[-122.39189026034138,37.79427854456892],[-122.39178886557242,37.794170982455135],[-122.39249932896719,37.79376881413398]]]},"properties":{"OBJECTID":5,"ZIP_CODE":94107,"ID":9409,"RATE":"c","OBJ":{"id":5},"TRIPS":null,"index":4}}`;
+
+ t.equal(window.clipboardData.data().text, expectedCopy2, 'should copy to clipboard');
+ t.end();
+});
diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.js
index c765f8666..ab7f742b6 100644
--- a/test/node/reducers/vis-state-test.js
+++ b/test/node/reducers/vis-state-test.js
@@ -48,7 +48,7 @@ import {
} from 'test/fixtures/geojson';
import tripGeojson, {timeStampDomain} from 'test/fixtures/trip-geojson';
-import {mockPolygonFeature, mockPolygonData} from '../../fixtures/polygon';
+import {mockPolygonFeature, mockPolygonData} from 'test/fixtures/polygon';
// test helpers
import {
@@ -64,12 +64,12 @@ import {
StateWSplitMaps,
StateWFilters,
StateWFiles,
+ StateWFilesFiltersLayerColor,
testCsvDataId,
testGeoJsonDataId
} from 'test/helpers/mock-state';
import {LAYER_VIS_CONFIGS, DEFAULT_TEXT_LABEL, DEFAULT_COLOR_UI} from 'layers/layer-factory';
import {getNextColorMakerValue} from 'test/helpers/layer-utils';
-import {StateWFilesFiltersLayerColor} from 'test/helpers/mock-state';
const mockData = {
fields: [
@@ -3981,3 +3981,145 @@ test('#visStateReducer -> APPLY_CPU_FILTER. has multi datsets', t => {
t.end();
});
+
+test('#visStateReducer -> SORT_TABLE_COLUMN', t => {
+ const initialState = CloneDeep(StateWFiles.visState);
+ const previousDataset1 = initialState.datasets[testCsvDataId];
+
+ // sort with default mode
+ const nextState = reducer(initialState, VisStateActions.sortTableColumn());
+ t.equal(nextState, initialState, 'state should not change when input is given');
+
+ // sort with
+ const nextState2 = reducer(
+ initialState,
+ VisStateActions.sortTableColumn(testCsvDataId, 'gps_data.lat')
+ );
+ t.ok(nextState2.datasets[testCsvDataId].sortOrder, 'should create sortOrder');
+
+ const expectedOrder = [
+ 3,
+ 0,
+ 2,
+ 4,
+ 1,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12,
+ 13,
+ 14,
+ 15,
+ 16,
+ 17,
+ 20,
+ 19,
+ 18,
+ 23,
+ 22,
+ 21
+ ];
+ const newKeys = Object.keys(nextState2.datasets[testCsvDataId]);
+ const addedKeys = newKeys.filter(k => !Object.keys(previousDataset1).includes(k));
+
+ t.deepEqual(
+ addedKeys,
+ ['sortColumn', 'sortOrder'],
+ 'should add sortColumn and sortOrder to dataset'
+ );
+ t.deepEqual(nextState2.datasets[testCsvDataId].sortOrder, expectedOrder, 'should sort correctly');
+ t.deepEqual(
+ nextState2.datasets[testCsvDataId].sortColumn,
+ {'gps_data.lat': 'ASCENDING'},
+ 'should save sortOrder'
+ );
+
+ // sort again
+ const nextState3 = reducer(
+ nextState2,
+ VisStateActions.sortTableColumn(testCsvDataId, 'gps_data.lat')
+ );
+
+ const expectedOrder3 = [...expectedOrder].reverse();
+
+ t.deepEqual(
+ nextState3.datasets[testCsvDataId].sortOrder,
+ expectedOrder3,
+ 'should sort correctly'
+ );
+ t.deepEqual(
+ nextState3.datasets[testCsvDataId].sortColumn,
+ {'gps_data.lat': 'DESCENDING'},
+ 'should correctly sort'
+ );
+
+ // unsort
+ const nextState4 = reducer(
+ nextState3,
+ VisStateActions.sortTableColumn(testCsvDataId, 'gps_data.lat', 'UNSORT')
+ );
+ t.deepEqual(nextState4.datasets[testCsvDataId].sortOrder, null, 'should reset sortOrder');
+ t.deepEqual(nextState4.datasets[testCsvDataId].sortColumn, {}, 'should reset sortColumn');
+
+ // sort with mode
+ const nextState5 = reducer(
+ nextState4,
+ VisStateActions.sortTableColumn(testCsvDataId, 'gps_data.lat', 'DESCENDING')
+ );
+
+ t.deepEqual(
+ nextState5.datasets[testCsvDataId].sortOrder,
+ expectedOrder3,
+ 'should sort correctly'
+ );
+ t.deepEqual(
+ nextState5.datasets[testCsvDataId].sortColumn,
+ {'gps_data.lat': 'DESCENDING'},
+ 'should correctly sort'
+ );
+ t.end();
+});
+
+test('#visStateReducer -> PIN_TABLE_COLUMN', t => {
+ const initialState = CloneDeep(StateWFiles.visState);
+ const previousDataset1 = initialState.datasets[testCsvDataId];
+
+ // pin with empty arg
+ const nextState = reducer(initialState, VisStateActions.pinTableColumn());
+ t.equal(nextState, initialState, 'state should not change when input is not given');
+
+ // pin gps_data.lat
+ const nextState1 = reducer(
+ nextState,
+ VisStateActions.pinTableColumn(testCsvDataId, 'gps_data.lat')
+ );
+
+ const newKeys = Object.keys(nextState1.datasets[testCsvDataId]);
+ const addedKeys = newKeys.filter(k => !Object.keys(previousDataset1).includes(k));
+
+ t.deepEqual(addedKeys, ['pinnedColumns'], 'should add pinnedColumns to dataset');
+
+ t.deepEqual(
+ nextState1.datasets[testCsvDataId].pinnedColumns,
+ ['gps_data.lat'],
+ 'should add to pinned columns'
+ );
+
+ // unpin
+ const nextState2 = reducer(
+ nextState1,
+ VisStateActions.pinTableColumn(testCsvDataId, 'gps_data.lat')
+ );
+
+ t.deepEqual(
+ nextState2.datasets[testCsvDataId].pinnedColumns,
+ [],
+ 'should remove from pinned columns'
+ );
+
+ t.end();
+});
diff --git a/test/setup-browser-env.js b/test/setup-browser-env.js
index 59c7ce791..a483787df 100644
--- a/test/setup-browser-env.js
+++ b/test/setup-browser-env.js
@@ -43,6 +43,31 @@ Object.defineProperty(window, 'fetch', {
writable: true
});
+Object.defineProperty(window, 'prompt', {
+ value: () => {},
+ writable: true
+});
+
+function mockClipboardData() {
+ let data = null;
+ const obj = {};
+ obj.data = () => {
+ return data;
+ };
+
+ obj.setData = (format, text) => {
+ data = {format, text};
+ };
+ obj.clearData = () => {};
+
+ return obj;
+}
+
+Object.defineProperty(window, 'clipboardData', {
+ value: mockClipboardData(),
+ writable: true
+});
+
const nop = () => {};
function mockCanvas(globalWindow) {
diff --git a/yarn.lock b/yarn.lock
index fec24e8b8..efca785a0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2513,7 +2513,7 @@ JSONStream@^1.0.3, JSONStream@^1.0.4, JSONStream@^1.3.4:
jsonparse "^1.2.0"
through ">=2.2.7 <3"
-abab@^2.0.0:
+abab@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a"
integrity sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg==
@@ -2531,13 +2531,13 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7:
mime-types "~2.1.24"
negotiator "0.6.2"
-acorn-globals@^4.1.0:
- version "4.3.4"
- resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.3.4.tgz#9fa1926addc11c97308c4e66d7add0d40c3272e7"
- integrity sha512-clfQEh21R+D0leSbUdWf3OcfqyaCSAQ8Ryq00bofSekfr9W8u1jyYZo6ir0xu9Gtcf7BjcHJpnbZH7JOCpP60A==
+acorn-globals@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-6.0.0.tgz#46cdd39f0f8ff08a876619b55f5ac8a6dc770b45"
+ integrity sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==
dependencies:
- acorn "^6.0.1"
- acorn-walk "^6.0.1"
+ acorn "^7.1.1"
+ acorn-walk "^7.1.1"
acorn-jsx@^3.0.0:
version "3.0.1"
@@ -2560,7 +2560,7 @@ acorn-node@^1.2.0, acorn-node@^1.3.0, acorn-node@^1.5.2, acorn-node@^1.6.1:
acorn-walk "^7.0.0"
xtend "^4.0.2"
-acorn-walk@^6.0.1, acorn-walk@^6.1.1:
+acorn-walk@^6.1.1:
version "6.2.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.2.0.tgz#123cb8f3b84c2171f1f7fb252615b1c78a6b1a8c"
integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==
@@ -2570,17 +2570,22 @@ acorn-walk@^7.0.0:
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.0.0.tgz#c8ba6f0f1aac4b0a9e32d1f0af12be769528f36b"
integrity sha512-7Bv1We7ZGuU79zZbb6rRqcpxo3OY+zrdtloZWoyD8fmGX+FeXRjE+iuGkZjSXLVovLzrsvMGMy0EkwA0E0umxg==
+acorn-walk@^7.1.1:
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.1.1.tgz#345f0dffad5c735e7373d2fec9a1023e6a44b83e"
+ integrity sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==
+
acorn@^3.0.4:
version "3.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
integrity sha1-ReN/s56No/JbruP/U2niu18iAXo=
-acorn@^5.2.1, acorn@^5.5.0, acorn@^5.5.3:
+acorn@^5.2.1, acorn@^5.5.0:
version "5.7.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==
-acorn@^6.0.1, acorn@^6.0.7, acorn@^6.2.1:
+acorn@^6.0.7, acorn@^6.2.1:
version "6.4.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.0.tgz#b659d2ffbafa24baf5db1cdbb2c94a983ecd2784"
integrity sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==
@@ -2590,6 +2595,11 @@ acorn@^7.0.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c"
integrity sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==
+acorn@^7.1.1:
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf"
+ integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==
+
agent-base@4, agent-base@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"
@@ -2807,11 +2817,6 @@ array-differ@^2.0.3:
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-2.1.0.tgz#4b9c1c3f14b906757082925769e8ab904f4801b1"
integrity sha512-KbUpJgx909ZscOc/7CLATBFam7P1Z1QRQInvgT0UztM9Q72aGKCunKASAl7WNW0tnPmPyEMeMhdsfWhfmW037w==
-array-equal@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
- integrity sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=
-
array-filter@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83"
@@ -3359,10 +3364,10 @@ browser-pack@^6.0.1:
through2 "^2.0.0"
umd "^3.0.0"
-browser-process-hrtime@^0.1.2:
- version "0.1.3"
- resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz#616f00faef1df7ec1b5bf9cfe2bdc3170f26c7b4"
- integrity sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==
+browser-process-hrtime@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626"
+ integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==
browser-resolve@^1.11.0, browser-resolve@^1.7.0:
version "1.11.3"
@@ -4316,6 +4321,13 @@ copy-to-clipboard@^3:
dependencies:
toggle-selection "^1.0.6"
+copy-to-clipboard@^3.3.1:
+ version "3.3.1"
+ resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.3.1.tgz#115aa1a9998ffab6196f93076ad6da3b913662ae"
+ integrity sha512-i13qo6kIHTTpCm8/Wup+0b1mVWETvu2kIMzKoK8FpkLkFxlt0znUAHcMzox+T8sPlqtZXq3CulEjQHsYiGFJUw==
+ dependencies:
+ toggle-selection "^1.0.6"
+
core-js-compat@^3.6.2:
version "3.6.4"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.6.4.tgz#938476569ebb6cda80d339bcf199fae4f16fff17"
@@ -4491,17 +4503,22 @@ csscolorparser@~1.0.2:
resolved "https://registry.yarnpkg.com/csscolorparser/-/csscolorparser-1.0.3.tgz#b34f391eea4da8f3e98231e2ccd8df9c041f171b"
integrity sha1-s085HupNqPPpgjHizNjfnAQfFxs=
[email protected], "cssom@>= 0.3.2 < 0.4.0":
+cssom@^0.4.4:
+ version "0.4.4"
+ resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10"
+ integrity sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==
+
+cssom@~0.3.6:
version "0.3.8"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a"
integrity sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==
-cssstyle@^1.0.0:
- version "1.4.0"
- resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-1.4.0.tgz#9d31328229d3c565c61e586b02041a28fccdccf1"
- integrity sha512-GBrLZYZ4X4x6/QEoBnIrqb8B/f5l4+8me2dkom/j1Gtbxy0kBv6OGzKuAsGM75bkGwGAFkt56Iwg28S3XTZgSA==
+cssstyle@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-2.2.0.tgz#e4c44debccd6b7911ed617a4395e5754bba59992"
+ integrity sha512-sEb3XFPx3jNnCAMtqrXPDeSgQr+jojtCeNf8cvMNMh1cG970+lljssvQDzPq6lmmJu2Vhqood/gtEomBiHOGnA==
dependencies:
- cssom "0.3.x"
+ cssom "~0.3.6"
csstype@^2.6.7:
version "2.6.8"
@@ -4716,14 +4733,14 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"
-data-urls@^1.0.0:
- version "1.1.0"
- resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-1.1.0.tgz#15ee0582baa5e22bb59c77140da8f9c76963bbfe"
- integrity sha512-YTWYI9se1P55u58gL5GkQHW4P6VJBJ5iBT+B5a7i2Tjadhv52paJG0qHX4A0OR6/t52odI64KP2YvFpkDOi3eQ==
+data-urls@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-2.0.0.tgz#156485a72963a970f5d5821aaf642bef2bf2db9b"
+ integrity sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==
dependencies:
- abab "^2.0.0"
- whatwg-mimetype "^2.2.0"
- whatwg-url "^7.0.0"
+ abab "^2.0.3"
+ whatwg-mimetype "^2.3.0"
+ whatwg-url "^8.0.0"
dateformat@^3.0.0:
version "3.0.3"
@@ -5223,12 +5240,12 @@ domelementtype@^2.0.1:
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.0.1.tgz#1f8bdfe91f5a78063274e803b4bdcedf6e94f94d"
integrity sha512-5HOHUDsYZWV8FGWN0Njbr/Rn7f/eWSQi1v7+HsUVwXgn8nWWlL64zKDkS0n8ZmQ3mlWOMuXOnR+7Nx/5tMO5AQ==
-domexception@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90"
- integrity sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==
+domexception@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/domexception/-/domexception-2.0.1.tgz#fb44aefba793e1574b0af6aed2801d057529f304"
+ integrity sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==
dependencies:
- webidl-conversions "^4.0.2"
+ webidl-conversions "^5.0.0"
domhandler@^2.3.0:
version "2.4.2"
@@ -5574,10 +5591,10 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
-escodegen@^1.9.1:
- version "1.13.0"
- resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.13.0.tgz#c7adf9bd3f3cc675bb752f202f79a720189cab29"
- integrity sha512-eYk2dCkxR07DsHA/X2hRBj0CFAZeri/LyDMc0C8JT1Hqi6JnVpMhJ7XFITbb0+yZS3lVkaPL2oCkZ3AVmeVbMw==
+escodegen@^1.14.1:
+ version "1.14.1"
+ resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.1.tgz#ba01d0c8278b5e95a9a45350142026659027a457"
+ integrity sha512-Bmt7NcRySdIfNPfU2ZoXDrrXsG9ZjvDxcAlMfDUgRBjLOWTuIACXPBFJH7Z+cLb40JeQco5toikyc9t9P8E9SQ==
dependencies:
esprima "^4.0.1"
estraverse "^4.2.0"
@@ -5917,7 +5934,7 @@ execa@^1.0.0:
signal-exit "^3.0.0"
strip-eof "^1.0.0"
-exenv@^1.2.0:
+exenv@^1.2.0, exenv@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/exenv/-/exenv-1.2.2.tgz#2ae78e85d9894158670b03d47bec1f03bd91bb9d"
integrity sha1-KueOhdmJQVhnCwPUe+wfA72Ru50=
@@ -6939,7 +6956,7 @@ har-schema@^2.0.0:
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92"
integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=
-har-validator@~5.1.0:
+har-validator@~5.1.0, har-validator@~5.1.3:
version "5.1.3"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.3.tgz#1ef89ebd3e4996557675eed9893110dc350fa080"
integrity sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==
@@ -7133,12 +7150,12 @@ html-element-map@^1.2.0:
dependencies:
array-filter "^1.0.0"
-html-encoding-sniffer@^1.0.2:
- version "1.0.2"
- resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz#e70d84b94da53aa375e11fe3a351be6642ca46f8"
- integrity sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==
+html-encoding-sniffer@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz#42a6dc4fd33f00281176e8b23759ca4e4fa185f3"
+ integrity sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==
dependencies:
- whatwg-encoding "^1.0.1"
+ whatwg-encoding "^1.0.5"
html-entities@^1.2.0, html-entities@^1.2.1:
version "1.2.1"
@@ -7852,6 +7869,11 @@ is-posix-bracket@^0.1.0:
resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"
integrity sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=
+is-potential-custom-element-name@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz#0c52e54bcca391bb2c494b21e8626d7336c6e397"
+ integrity sha1-DFLlS8yjkbssSUsh6GJtczbG45c=
+
is-primitive@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575"
@@ -8147,36 +8169,36 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
-jsdom@^11.1.0:
- version "11.12.0"
- resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.12.0.tgz#1a80d40ddd378a1de59656e9e6dc5a3ba8657bc8"
- integrity sha512-y8Px43oyiBM13Zc1z780FrfNLJCXTL40EWlty/LXUtcjykRBNgLlCjWXpfSPBl2iv+N7koQN+dvqszHZgT/Fjw==
- dependencies:
- abab "^2.0.0"
- acorn "^5.5.3"
- acorn-globals "^4.1.0"
- array-equal "^1.0.0"
- cssom ">= 0.3.2 < 0.4.0"
- cssstyle "^1.0.0"
- data-urls "^1.0.0"
- domexception "^1.0.1"
- escodegen "^1.9.1"
- html-encoding-sniffer "^1.0.2"
- left-pad "^1.3.0"
- nwsapi "^2.0.7"
- parse5 "4.0.0"
- pn "^1.1.0"
- request "^2.87.0"
- request-promise-native "^1.0.5"
- sax "^1.2.4"
- symbol-tree "^3.2.2"
- tough-cookie "^2.3.4"
- w3c-hr-time "^1.0.1"
- webidl-conversions "^4.0.2"
- whatwg-encoding "^1.0.3"
- whatwg-mimetype "^2.1.0"
- whatwg-url "^6.4.1"
- ws "^5.2.0"
+jsdom@^16.2.1:
+ version "16.2.1"
+ resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.2.1.tgz#df934649ab9175daeeff3e6f1e2b2268ed1470cd"
+ integrity sha512-3p0gHs5EfT7PxW9v8Phz3mrq//4Dy8MQenU/PoKxhdT+c45S7NjIjKbGT3Ph0nkICweE1r36+yaknXA5WfVNAg==
+ dependencies:
+ abab "^2.0.3"
+ acorn "^7.1.1"
+ acorn-globals "^6.0.0"
+ cssom "^0.4.4"
+ cssstyle "^2.2.0"
+ data-urls "^2.0.0"
+ decimal.js "^10.2.0"
+ domexception "^2.0.1"
+ escodegen "^1.14.1"
+ html-encoding-sniffer "^2.0.1"
+ is-potential-custom-element-name "^1.0.0"
+ nwsapi "^2.2.0"
+ parse5 "5.1.1"
+ request "^2.88.2"
+ request-promise-native "^1.0.8"
+ saxes "^5.0.0"
+ symbol-tree "^3.2.4"
+ tough-cookie "^3.0.1"
+ w3c-hr-time "^1.0.2"
+ w3c-xmlserializer "^2.0.0"
+ webidl-conversions "^5.0.0"
+ whatwg-encoding "^1.0.5"
+ whatwg-mimetype "^2.3.0"
+ whatwg-url "^8.0.0"
+ ws "^7.2.1"
xml-name-validator "^3.0.0"
jsesc@^1.3.0:
@@ -8397,11 +8419,6 @@ lead@^1.0.0:
dependencies:
flush-write-stream "^1.0.2"
-left-pad@^1.3.0:
- version "1.3.0"
- resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e"
- integrity sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==
-
lerna@^3.14.1:
version "3.20.2"
resolved "https://registry.yarnpkg.com/lerna/-/lerna-3.20.2.tgz#abf84e73055fe84ee21b46e64baf37b496c24864"
@@ -9738,7 +9755,7 @@ number-is-nan@^1.0.0:
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
-nwsapi@^2.0.7:
+nwsapi@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7"
integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==
@@ -10352,10 +10369,10 @@ parse-url@^5.0.0:
parse-path "^4.0.0"
protocols "^1.4.0"
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608"
- integrity sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==
+ version "5.1.1"
+ resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.1.tgz#f68e4e5ba1852ac2cadc00f4555fff6c2abb6178"
+ integrity sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==
parse5@^3.0.1:
version "3.0.3"
@@ -10567,11 +10584,6 @@ pluralize@^7.0.0:
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"
integrity sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==
-pn@^1.1.0:
- version "1.1.0"
- resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
- integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==
-
pngjs@^3.0.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.4.0.tgz#99ca7d725965fb655814eaf65f38f12bbdbf555f"
@@ -11796,7 +11808,7 @@ [email protected]:
dependencies:
lodash "^4.17.15"
-request-promise-native@^1.0.5:
+request-promise-native@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.8.tgz#a455b960b826e44e2bf8999af64dff2bfe58cb36"
integrity sha512-dapwLGqkHtwL5AEbfenuzjTYg35Jd6KPytsC2/TLkVMz8rm+tNt72MGUWT1RP/aYawMpN6HqbNGBQaRcBtjQMQ==
@@ -11831,6 +11843,32 @@ request@^2.87.0, request@^2.88.0:
tunnel-agent "^0.6.0"
uuid "^3.3.2"
+request@^2.88.2:
+ version "2.88.2"
+ resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3"
+ integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==
+ dependencies:
+ aws-sign2 "~0.7.0"
+ aws4 "^1.8.0"
+ caseless "~0.12.0"
+ combined-stream "~1.0.6"
+ extend "~3.0.2"
+ forever-agent "~0.6.1"
+ form-data "~2.3.2"
+ har-validator "~5.1.3"
+ http-signature "~1.2.0"
+ is-typedarray "~1.0.0"
+ isstream "~0.1.2"
+ json-stringify-safe "~5.0.1"
+ mime-types "~2.1.19"
+ oauth-sign "~0.9.0"
+ performance-now "^2.1.0"
+ qs "~6.5.2"
+ safe-buffer "^5.1.2"
+ tough-cookie "~2.5.0"
+ tunnel-agent "^0.6.0"
+ uuid "^3.3.2"
+
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
@@ -12081,10 +12119,12 @@ [email protected], samsam@^1.1.3:
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50"
integrity sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==
-sax@^1.2.4:
- version "1.2.4"
- resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
- integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
+saxes@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/saxes/-/saxes-5.0.0.tgz#b7d30284d7583a5ca6ad0248b56d8889da53788b"
+ integrity sha512-LXTZygxhf8lfwKaTP/8N9CsVdjTlea3teze4lL6u37ivbgGbV0GGMuNtS/I9rnD/HC2/txUM7Df4S2LVl1qhiA==
+ dependencies:
+ xmlchars "^2.2.0"
scheduler@^0.18.0:
version "0.18.0"
@@ -12941,7 +12981,7 @@ symbol-observable@^1.0.3:
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==
-symbol-tree@^3.2.2:
+symbol-tree@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==
@@ -13354,7 +13394,7 @@ toposort@^1.0.0:
resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.7.tgz#2e68442d9f64ec720b8cc89e6443ac6caa950029"
integrity sha1-LmhELZ9k7HILjMieZEOsbKqVACk=
-tough-cookie@^2.3.3, tough-cookie@^2.3.4:
+tough-cookie@^2.3.3, tough-cookie@~2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2"
integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==
@@ -13362,6 +13402,15 @@ tough-cookie@^2.3.3, tough-cookie@^2.3.4:
psl "^1.1.28"
punycode "^2.1.1"
+tough-cookie@^3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-3.0.1.tgz#9df4f57e739c26930a018184887f4adb7dca73b2"
+ integrity sha512-yQyJ0u4pZsv9D4clxO69OEjLWYw+jbgspjTue4lTQZLfV0c5l1VmK2y1JK8E9ahdpltPOaAThPcp5nKPUgSnsg==
+ dependencies:
+ ip-regex "^2.1.0"
+ psl "^1.1.28"
+ punycode "^2.1.1"
+
tough-cookie@~2.4.3:
version "2.4.3"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781"
@@ -13377,6 +13426,13 @@ tr46@^1.0.1:
dependencies:
punycode "^2.1.0"
+tr46@^2.0.0:
+ version "2.0.2"
+ resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.0.2.tgz#03273586def1595ae08fedb38d7733cee91d2479"
+ integrity sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg==
+ dependencies:
+ punycode "^2.1.1"
+
trim-lines@^1.0.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/trim-lines/-/trim-lines-1.1.3.tgz#839514be82428fd9e7ec89e35081afe8f6f93115"
@@ -14034,12 +14090,19 @@ vue-template-compiler@^2.5.16:
de-indent "^1.0.2"
he "^1.1.0"
-w3c-hr-time@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045"
- integrity sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=
+w3c-hr-time@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"
+ integrity sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==
+ dependencies:
+ browser-process-hrtime "^1.0.0"
+
+w3c-xmlserializer@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz#3e7104a05b75146cc60f564380b7f683acf1020a"
+ integrity sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==
dependencies:
- browser-process-hrtime "^0.1.2"
+ xml-name-validator "^3.0.0"
warning@^4.0.3:
version "4.0.3"
@@ -14089,6 +14152,11 @@ webidl-conversions@^4.0.2:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==
+webidl-conversions@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
+ integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==
+
webpack-bundle-analyzer@^3.0.3, webpack-bundle-analyzer@^3.3.2:
version "3.6.0"
resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.6.0.tgz#39b3a8f829ca044682bc6f9e011c95deb554aefd"
@@ -14262,7 +14330,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/wgs84/-/wgs84-0.0.0.tgz#34fdc555917b6e57cf2a282ed043710c049cdc76"
integrity sha1-NP3FVZF7blfPKigu0ENxDASc3HY=
-whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
+whatwg-encoding@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz#5abacf777c32166a51d085d6b4f3e7d27113ddb0"
integrity sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==
@@ -14274,20 +14342,11 @@ whatwg-fetch@>=0.10.0:
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb"
integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==
-whatwg-mimetype@^2.1.0, whatwg-mimetype@^2.2.0:
+whatwg-mimetype@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"
integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==
-whatwg-url@^6.4.1:
- version "6.5.0"
- resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8"
- integrity sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==
- dependencies:
- lodash.sortby "^4.7.0"
- tr46 "^1.0.1"
- webidl-conversions "^4.0.2"
-
whatwg-url@^7.0.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06"
@@ -14297,6 +14356,15 @@ whatwg-url@^7.0.0:
tr46 "^1.0.1"
webidl-conversions "^4.0.2"
+whatwg-url@^8.0.0:
+ version "8.0.0"
+ resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.0.0.tgz#37f256cb746398e19b107bd6ef820b4ae2d15871"
+ integrity sha512-41ou2Dugpij8/LPO5Pq64K5q++MnRCBpEHvQr26/mArEKTkCV5aoXIqyhuYtE0pkqScXwhf2JP57rkRTYM29lQ==
+ dependencies:
+ lodash.sortby "^4.7.0"
+ tr46 "^2.0.0"
+ webidl-conversions "^5.0.0"
+
which-module@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
@@ -14438,13 +14506,6 @@ write@^0.2.1:
dependencies:
mkdirp "^0.5.1"
-ws@^5.2.0:
- version "5.2.2"
- resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f"
- integrity sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==
- dependencies:
- async-limiter "~1.0.0"
-
ws@^6.0.0, ws@^6.1.0, ws@^6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb"
@@ -14452,6 +14513,11 @@ ws@^6.0.0, ws@^6.1.0, ws@^6.2.1:
dependencies:
async-limiter "~1.0.0"
+ws@^7.2.1:
+ version "7.2.3"
+ resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46"
+ integrity sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==
+
x-is-string@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/x-is-string/-/x-is-string-0.1.0.tgz#474b50865af3a49a9c4657f05acd145458f77d82"
@@ -14469,6 +14535,11 @@ xml-name-validator@^3.0.0:
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==
+xmlchars@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
+ integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
+
xmlhttprequest@1:
version "1.8.0"
resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc"