Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
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
08b1607
- add runtime logger configuration override
Sep 5, 2018
0a4accb
- fix merged cells / hidden cells w/ fixed col & rows
Sep 5, 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;
}
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.

14 changes: 11 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 @@ -639,7 +647,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",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping the version

"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-*",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out the e2e tests and visual tests were racing one another -- visual tests are very short, so e2e tests were never run in CircleCI 😞

"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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying this over / refactoring, leaving comments as is.


// 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;
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapper around the clipboard implementation details (especially the copy portion) -- nothing here is dash or dash table specific

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);
}
}
27 changes: 27 additions & 0 deletions src/core/environment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { DebugLevel, LogLevel } from 'core/Logger';
import CookieStorage from 'core/storage/Cookie';

const DASH_DEBUG = 'dash_debug';
const DASH_LOG = 'dash_log';

export default class Environment {
private static get searchParams() {
return new URL(window.location.href).searchParams;
}

public static get debugLevel(): DebugLevel {
const debug = this.searchParams.get(DASH_DEBUG) || CookieStorage.get(DASH_DEBUG);

return debug ?
(DebugLevel as any)[debug] || DebugLevel.NONE :
DebugLevel.NONE;
}

public static get logLevel(): LogLevel {
const log = this.searchParams.get(DASH_LOG) || CookieStorage.get(DASH_LOG);

return log ?
(LogLevel as any)[log] || LogLevel.ERROR :
LogLevel.ERROR;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making it possible to use cookies or additional params to override dash component behavior. In this case, toggling debug & log levels. Useful when testing against deployed component.

}
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;
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no seed in Math.random.. useful for testing purposes

41 changes: 41 additions & 0 deletions src/core/storage/Cookie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const __1day = 86400 * 1000;
const __20years = 86400 * 1000 * 365 * 20;

export default class CookieStorage {
public static delete(id: string, domain: string = '', path: string = '/') {
let expires = new Date((new Date().getTime() - __1day)).toUTCString();

document.cookie = `${id}=;expires=${expires};domain=${domain};path=${path}`;
}

public static get(id: string) {
if (!id.length) {
return;
}

id = id.toLowerCase();

let cookies = document.cookie.split(';').map(cookie => {
let fragments = cookie.split('=');

return {
id: fragments[0].trim(),
value: fragments[1]
};
});

return (cookies.find(cookie => id === cookie.id.toLocaleLowerCase()) || {} as any).value;
}

public static set(id: string, value: string, domain: string = '', path: string = '/') {
let expires = new Date((new Date().getTime() + __20years)).toUTCString();

let entry = `${id}=${value};expires=${expires};domain=${domain};path=${path}`;

if (CookieStorage.get(id)) {
CookieStorage.delete(id, domain, path);
}

document.cookie = entry;
}
}
Loading