Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
939e035
- refactor: isolate dash component layer from component implementation
Aug 29, 2018
6b38f3a
merge with master
Aug 29, 2018
24f8be7
update for build js/py
Aug 29, 2018
9b403c5
- fix python component packaging regression
Aug 29, 2018
81ee2c8
Fix visual tests regression
Aug 29, 2018
b40dc70
(wip) refactor controlled table
Aug 29, 2018
3364c09
@types
Aug 29, 2018
8367945
refactor table clipboard usage
Aug 29, 2018
81ad7b2
clean up
Aug 29, 2018
1c0ff08
rename
Aug 29, 2018
1147ba6
pr review fixes
Aug 29, 2018
e2439aa
fix bug in test script
Aug 30, 2018
ba37ad8
fix test
Aug 30, 2018
56e59fe
update test script
Aug 30, 2018
6b3e1f6
fix tests
Aug 30, 2018
9651bcf
fix tests
Aug 30, 2018
f123fee
tests -- remove async/await syntax
Aug 30, 2018
0dfbd90
fix tests
Aug 30, 2018
cc6bb94
- remove row component
Aug 30, 2018
c0994c9
remove test code
Aug 30, 2018
ee98b20
fix test
Aug 30, 2018
79747bd
remove test / broken by Cypress.io
Aug 30, 2018
35da207
cypress version
Aug 30, 2018
6ba6193
fix cell selection test
Aug 31, 2018
ffd0752
fix percy tests
Aug 31, 2018
98d1a96
prevent useless cell updates once again
Aug 31, 2018
0b4481d
styling, copy/paste, navigation regressions
Aug 31, 2018
55c6228
build, variables renamed
Aug 31, 2018
46e5f36
fix next/previous regression
Aug 31, 2018
1f48808
fix test regressions
Aug 31, 2018
d0a18a2
table styling regression
Aug 31, 2018
4447d54
- fixed rows/columns regression testing + fixes
Sep 4, 2018
f81b6e8
fix test?
Sep 4, 2018
e84918b
fix test?
Sep 4, 2018
1309173
revert percy removal
Sep 4, 2018
b730168
multi and single column sorting support
Sep 4, 2018
4f2767b
basic sorting e2e test
Sep 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions @Types/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module 'sheetclip' {
const value: any;
export default value;
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Changelog

## RC6 - Sorting props

- Additional sorting_type prop that can take value 'multi' or 'single'
This prop defines whether the user can sort based on multiple columns or can only sort by one column at a time. The default value is 'single'.
6 changes: 3 additions & 3 deletions dash_table/bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dash_table/demo.js

Large diffs are not rendered by default.

35 changes: 32 additions & 3 deletions dash_table/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"src/dash-table/components/Table.js": {
"src/dash-table/Table.js": {
"description": "",
"displayName": "Table",
"methods": [],
Expand Down Expand Up @@ -134,6 +134,10 @@
{
"value": "'multi'",
"computed": false
},
{
"value": "false",
"computed": false
}
]
},
Expand Down Expand Up @@ -236,7 +240,11 @@
"computed": false
},
{
"value": "'none'",
"value": "true",
"computed": false
},
{
"value": "false",
"computed": false
}
]
Expand Down Expand Up @@ -532,6 +540,27 @@
"computed": false
}
},
"sorting_type": {
"type": {
"name": "enum",
"value": [
{
"value": "'single'",
"computed": false
},
{
"value": "'multi'",
"computed": false
}
]
},
"required": false,
"description": "",
"defaultValue": {
"value": "'single'",
"computed": false
}
},
"sorting_settings": {
"type": {
"name": "arrayOf",
Expand Down Expand Up @@ -639,7 +668,7 @@
},
"base_styles": {
"defaultValue": {
"value": "{\n numeric: {\n 'text-align': 'right',\n 'font-family': \"'Droid Sans Mono', Courier, monospace\",\n },\n\n string: {\n 'text-align': 'left',\n },\n\n input: {\n padding: 0,\n margin: 0,\n width: '80px',\n border: 'none',\n 'font-size': '1rem',\n },\n\n 'input-active': {\n outline: '#7FDBFF auto 3px',\n },\n\n table: {},\n\n thead: {},\n\n th: {},\n\n td: {},\n}",
"value": "{\n numeric: {\n 'text-align': 'right',\n 'font-family': `'Droid Sans Mono', Courier, monospace`\n },\n\n string: {\n 'text-align': 'left'\n },\n\n input: {\n padding: 0,\n margin: 0,\n width: '80px',\n border: 'none',\n 'font-size': '1rem'\n },\n\n 'input-active': {\n outline: '#7FDBFF auto 3px'\n },\n\n table: {},\n\n thead: {},\n\n th: {},\n\n td: {}\n}",
"computed": false
},
"required": false
Expand Down
14 changes: 8 additions & 6 deletions dash_table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc5",
"version": "3.0.0rc6",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand All @@ -16,14 +16,15 @@
"private::lint.js": "eslint src",
"private::lint.ts": "tslint --project . src/**/*.ts",
"private::opentests": "cypress open",
"private::runtests": "cypress run",
"private::snapshots": "build-storybook && percy-storybook",
"private::runtests": "cypress run --browser chrome",
"private::test-e2e": "run-p --race private::host* private::runtests",
"private::test-visual": "build-storybook && percy-storybook",
"build.watch": "webpack-dev-server --content-base dash_table --mode development",
"build:js-dev": "run-s \"private::build -- --mode development\"",
"build:js": "run-s \"private::build -- --mode production\"",
"build:py": "./extract-meta src/dash-table/components/Table.js > dash_table/metadata.json && cp package.json dash_table",
"build:py": "./extract-meta src/dash-table/Table.js > dash_table/metadata.json && cp package.json dash_table",
"lint": "run-s private::lint.js private::lint.ts",
"test": "run-p --race private::host* private::runtests private::snapshots",
"test": "run-s private::test-*",
"test.watch": "run-p --race \"private::build -- --mode development --watch\" --race private::host* private::opentests"
},
"author": "Chris P <chris@plot.ly",
Expand All @@ -42,13 +43,14 @@
"@storybook/cli": "^4.0.0-alpha.16",
"@storybook/react": "^4.0.0-alpha.16",
"@types/ramda": "^0.25.36",
"@types/react-select": "^1.2.1",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.11",
"cypress": "^3.0.3",
"cypress": "^3.1.0",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.12.0",
Expand Down
12 changes: 8 additions & 4 deletions demo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import * as R from 'ramda';
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {Table} from 'dash-table';
import { Table } from 'dash-table';
import {mockData} from './data';
import { memoizeOne } from 'core/memoizer';

const clone = o => JSON.parse(JSON.stringify(o));


class App extends Component {
constructor() {
super();
Expand All @@ -27,9 +28,9 @@ class App extends Component {
editable: true,
filtering: true,
sorting: true,
// n_fixed_rows: 3,
// n_fixed_columns: 2,
merge_duplicate_headers: true,
n_fixed_rows: 3,
n_fixed_columns: 2,
merge_duplicate_headers: false,
row_deletable: true,
row_selectable: 'single',
column_static_dropdown: [
Expand All @@ -41,6 +42,9 @@ class App extends Component {
}))
}
],
table_style: [
{ selector: '.dash-spreadsheet.freeze-left', rule: 'width: 1000px' }
]
}
};

Expand Down
2 changes: 1 addition & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import App from './App';

import Logger, { DebugLevel, LogLevel } from 'core/Logger';

Logger.setDebugLevel(DebugLevel.NONE);
Logger.setDebugLevel(DebugLevel.DEBUG);
Logger.setLogLevel(LogLevel.WARNING);

ReactDOM.render(<App />, document.getElementById('root'));
11 changes: 10 additions & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc5",
"version": "3.0.0rc6",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand All @@ -16,14 +16,15 @@
"private::lint.js": "eslint src",
"private::lint.ts": "tslint --project . src/**/*.ts",
"private::opentests": "cypress open",
"private::runtests": "cypress run",
"private::snapshots": "build-storybook && percy-storybook",
"private::runtests": "cypress run --browser chrome",
"private::test-e2e": "run-p --race private::host* private::runtests",
"private::test-visual": "build-storybook && percy-storybook",
"build.watch": "webpack-dev-server --content-base dash_table --mode development",
"build:js-dev": "run-s \"private::build -- --mode development\"",
"build:js": "run-s \"private::build -- --mode production\"",
"build:py": "./extract-meta src/dash-table/components/Table.js > dash_table/metadata.json && cp package.json dash_table",
"build:py": "./extract-meta src/dash-table/Table.js > dash_table/metadata.json && cp package.json dash_table",
"lint": "run-s private::lint.js private::lint.ts",
"test": "run-p --race private::host* private::runtests private::snapshots",
"test": "run-s private::test-*",
"test.watch": "run-p --race \"private::build -- --mode development --watch\" --race private::host* private::opentests"
},
"author": "Chris P <chris@plot.ly",
Expand All @@ -42,13 +43,14 @@
"@storybook/cli": "^4.0.0-alpha.16",
"@storybook/react": "^4.0.0-alpha.16",
"@types/ramda": "^0.25.36",
"@types/react-select": "^1.2.1",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.11",
"cypress": "^3.0.3",
"cypress": "^3.1.0",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.12.0",
Expand Down
42 changes: 42 additions & 0 deletions src/core/Clipboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export default class Clipboard {
public static set(value: string): void {
const el = document.createElement('textarea');
el.value = value;

// (Adapted from https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f)
// Make it readonly to be tamper-proof
el.setAttribute('readonly', '');
// el.style.position = 'absolute';
// Move outside the screen to make it invisible
// el.style.left = '-9999px';
// Append the <textarea> element to the HTML document
document.body.appendChild(el);

// Check if there is any content selected previously
let selected;
if (document.getSelection().rangeCount > 0) {
// Store selection if found
selected = document.getSelection().getRangeAt(0);
}

// Select the <textarea> content
el.select();
// Copy - only works as a result of a user action (e.g. click events)
document.execCommand('copy');
// Remove the <textarea> element
document.body.removeChild(el);
// If a selection existed before copying
if (selected) {
// Unselect everything on the HTML document
document.getSelection().removeAllRanges();
// Restore the original selection
document.getSelection().addRange(selected);
}
}

public static get(ev: ClipboardEvent) {
return ev.clipboardData ?
ev.clipboardData.getData('text/plain') :
undefined;
}
}
6 changes: 5 additions & 1 deletion src/core/Stylesheet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Logger from 'core/Logger';

interface IRule {
cssText: string;
selectorText: string;
Expand Down Expand Up @@ -84,13 +86,15 @@ export default class Stylesheet {

const result = this.stylesheet.findRule(selector);
if (result) {
if (result.rule.cssText === css) {

if (result.rule.cssText === css || result.rule.cssText === `${selector} { ${css} }`) {
return;
} else {
this.stylesheet.deleteRule(result.index);
}
}

this.stylesheet.addRule(selector, css);
Logger.debug('stylesheet', selector, css);
}
}
7 changes: 7 additions & 0 deletions src/core/math/random.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default (seed: number | undefined = undefined) => {
let lcg = (a: number) => a * 48271 % 2147483647;

let safeSeed = seed !== undefined ? lcg(seed) : lcg(Math.random());

return () => (safeSeed = lcg(safeSeed)) / 2147483648;
};
28 changes: 0 additions & 28 deletions src/core/sorting/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as R from 'ramda';
import Logger from 'core/Logger';

export interface ISortSetting {
columnId: string | number;
Expand All @@ -14,33 +13,6 @@ export enum SortDirection {

export type SortSettings = ISortSetting[];

export function updateSettings(
settings: SortSettings,
setting: ISortSetting
): SortSettings {
Logger.trace('updateSettings', settings, setting);

settings = R.clone(settings);

if (setting.direction === SortDirection.None) {
const currentIndex = R.findIndex(s => s.columnId === setting.columnId, settings);

if (currentIndex !== -1) {
settings.splice(currentIndex, 1);
}
} else {
const currentSetting = R.find(s => s.columnId === setting.columnId, settings);

if (currentSetting) {
currentSetting.direction = setting.direction;
} else {
settings.push(setting);
}
}

return settings;
}

export default (dataframe: any[], settings: SortSettings): any[] => {
if (!settings.length) {
return dataframe;
Expand Down
31 changes: 31 additions & 0 deletions src/core/sorting/multi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as R from 'ramda';

import Logger from 'core/Logger';
import { SortSettings, ISortSetting, SortDirection } from 'core/sorting';

export default (
settings: SortSettings,
setting: ISortSetting
): SortSettings => {
Logger.trace('multi - updateSettings', settings, setting);

settings = R.clone(settings);

if (setting.direction === SortDirection.None) {
const currentIndex = R.findIndex(s => s.columnId === setting.columnId, settings);

if (currentIndex !== -1) {
settings.splice(currentIndex, 1);
}
} else {
const currentSetting = R.find(s => s.columnId === setting.columnId, settings);

if (currentSetting) {
currentSetting.direction = setting.direction;
} else {
settings.push(setting);
}
}

return settings;
};
Loading