Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

review apps - apps demonstrating typical usage #108

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7394393
refactor virtualization, virtualization settings, and derived props
Sep 20, 2018
81e0802
refactor renaming paging / pagination props
Sep 20, 2018
646068b
refactor virtual, viewport and pagination into adapters
Sep 20, 2018
3b13dbb
isolate derived props
Sep 20, 2018
4e0ecad
build update
Sep 20, 2018
fadbe4b
fix regression
Sep 20, 2018
8c60f0b
improve typing
Sep 20, 2018
7013574
fix test regression
Sep 20, 2018
b606834
simplify pagination adapter / refactor
Sep 20, 2018
ec68944
lint
Sep 20, 2018
ba80945
clean up unused props
Sep 20, 2018
f9ce473
- change factory
Sep 20, 2018
78a1844
Merge remote-tracking branch 'origin/master' into 3.0-props-refactoring
Sep 20, 2018
452de9b
fix lint
Sep 20, 2018
8ec667e
bump version
Sep 21, 2018
b334918
add dash level props for virtual_dataframe
Sep 21, 2018
80a2c02
refactor fp / derived props
Sep 23, 2018
2b674ee
derived props
Sep 23, 2018
b2fc917
refactor viewport and virtual controlled props
Sep 23, 2018
6ba5403
fix fp regression
Sep 23, 2018
e546390
fix fp regression
Sep 23, 2018
a520da6
refactor controlled table / table fp
Sep 23, 2018
d9e294d
controlled table purecomponent
Sep 23, 2018
770effa
fix test (rebrake it!)
Sep 23, 2018
6577df5
fix selection regression for be paging/sorting/filtering
Sep 24, 2018
e86b8fd
improve re-renders & controlled props
Sep 24, 2018
c816691
fix test regressions
Sep 24, 2018
f02ee15
update inner-selection fixture
Sep 24, 2018
cd06e6c
merge master into 3.0-props-refactoring
Sep 24, 2018
5af4a70
remove useless spy
Sep 24, 2018
9b12845
- fix pr comment
Sep 25, 2018
231ab9d
clean up
Sep 25, 2018
1d5f257
:bar_chart: integration app - dataframe updating chart
chriddyp Sep 24, 2018
1d63ebb
:pencil: add documentation to the example and a list of unexpected be…
chriddyp Sep 24, 2018
e1fbc7e
:pencil: sizing document
chriddyp Sep 24, 2018
d31210e
:zap: rework the intro
chriddyp Sep 24, 2018
a18602b
:truck: refactor into multiple files
chriddyp Sep 24, 2018
1b008a5
:truck: move column alignment into the styling chapter
chriddyp Sep 24, 2018
e4a3aba
:sparkles: update the data for the styling chapter
chriddyp Sep 24, 2018
78aa40c
:black_large_square: `black`
chriddyp Sep 24, 2018
3c0a459
:construction: update the example from feedback
chriddyp Sep 25, 2018
217c191
:black_circle: black
chriddyp Sep 25, 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
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

# Version 3.0 (ALPHA)

Version 3.0 of the Dash-Table expands vastly on the capability of the 2.x table and provides features:

- visually freezing rows and/or columns
- filtering in either FE or BE, basic filtering UI
- sorting in either FE or BE, basic sorting UI
- pagination in either FE or BE, basic pagination UI
- performance optimizations
- basic coverage through e2e, integration and unit tests

## RC1, RC2, RC3, RC4 (Virtualization, Freeze, Deletable & Editable Columns, Performance)

### Virtualization
Expand Down Expand Up @@ -188,3 +199,37 @@
Issue: https://github.com/plotly/dash-table/issues/91

Sorting arrow will no longer highlight.

# Version 3.1 (BETA)

Version 3.1 of the Dash-Table builds upon the 3.0 table and solidifies the external facing API of the table

- introducing the notion of derived properties

- virtual and viewport dataframe and indices for more flexibility
- code refactoring to simplify and improve the existing implementation / prepare for the future
- documentation of the API and table features
- additional e2e, integration and unit tests for a more mature development platform

### Derived Properties

Derived properties are new to 3.1
They are readonly properties that represent a transform from multiple 'first-class' properties of the component.

For example, derived_viewport_dataframe is a readonly view based on
f(dataframe, filtering params, sorting params, pagination params) --> derived_viewport_dataframe

Derived properties allow the component to expose complex state that can be useful for a Dash Server developer but without introducing dual states, a situation where multiple properties may represent the same state within the component, making it necessary to reconcile them on each prop update.

## RC1 - Virtual and Viewport Dataframe

- 4 new external facing derived properties and 4 internal facing controlled properties that represent:
1. the filtered and sorted dataframe and the indices mapping
2. the filtered, sorted and paginated dataframe and the indices mapping

- derived_viewport_dataframe
- derived_viewport_indices
- derived_virtual_dataframe
- derived_virtual_indices

In the event where sorting, filtering or pagination is done on the Dash Server, it is possible that some or all derived dataframes will be equal to the dataframe prop.
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.

63 changes: 28 additions & 35 deletions dash_table/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
"computed": false
}
},
"virtualization": {
"pagination_mode": {
"type": {
"name": "enum",
"value": [
Expand Down Expand Up @@ -256,7 +256,7 @@
"computed": false
}
},
"virtualization_settings": {
"pagination_settings": {
"type": {
"name": "shape",
"value": {
Expand Down Expand Up @@ -647,7 +647,7 @@
"required": false,
"description": ""
},
"virtual_dataframe": {
"derived_viewport_dataframe": {
"type": {
"name": "arrayOf",
"value": {
Expand All @@ -661,7 +661,7 @@
"computed": false
}
},
"virtual_dataframe_indices": {
"derived_viewport_indices": {
"type": {
"name": "arrayOf",
"value": {
Expand All @@ -675,51 +675,44 @@
"computed": false
}
},
"dropdown_properties": {
"derived_virtual_dataframe": {
"type": {
"name": "any"
"name": "arrayOf",
"value": {
"name": "object"
}
},
"required": false,
"description": ""
},
"column_conditional_styles": {
"description": "",
"defaultValue": {
"value": "[]",
"computed": false
},
"required": false
},
"changed_data": {
"defaultValue": {
"value": "{}",
"computed": false
},
"required": false
}
},
"index_name": {
"defaultValue": {
"value": "''",
"computed": false
"derived_virtual_indices": {
"type": {
"name": "arrayOf",
"value": {
"name": "number"
}
},
"required": false
},
"types": {
"required": false,
"description": "",
"defaultValue": {
"value": "{}",
"value": "[]",
"computed": false
},
"required": false
}
},
"merged_styles": {
"defaultValue": {
"value": "{}",
"computed": false
"dropdown_properties": {
"type": {
"name": "any"
},
"required": false
"required": false,
"description": ""
},
"base_styles": {
"column_conditional_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": "[]",
"computed": false
},
"required": false
Expand Down
2 changes: 1 addition & 1 deletion dash_table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc22",
"version": "3.1.0rc1",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc22",
"version": "3.1.0rc1",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand Down
31 changes: 31 additions & 0 deletions src/core/memoizer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { isEqualArgs } from 'core/comparer';
import { ResultFn } from 'core/generic';

interface ICachedResultFn<TEntry> {
result: TEntry;
cached: boolean;
first: boolean;
}

export function memoizeOne<
TArgs extends any[],
TEntry
Expand All @@ -15,6 +21,31 @@ export function memoizeOne<
};
}

export function memoizeOneFactory<
TArgs extends any[],
TEntry
>(fn: ResultFn<TArgs, TEntry>): () => ResultFn<TArgs, TEntry> {
return () => memoizeOne(fn);
}

export function memoizeOneWithFlag<
TArgs extends any[],
TEntry
>(fn: ResultFn<TArgs, TEntry>): ResultFn<TArgs, ICachedResultFn<TEntry>> {
let lastArgs: any[] | null = null;
let lastResult: any;
let isFirst = true;

return (...args: TArgs): ICachedResultFn<TEntry> => {
let res = isEqualArgs(lastArgs, args) ?
{ cached: true, first: isFirst, result: lastResult } :
{ cached: false, first: isFirst, result: (lastArgs = args) && (lastResult = fn(...args)) };
isFirst = false;

return res;
};
}

export function memoizeAll<
TArgs extends any[],
TEntry
Expand Down
56 changes: 13 additions & 43 deletions src/dash-table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default class Table extends Component {
}

export const defaultProps = {
virtualization: 'fe',
virtualization_settings: {
pagination_mode: 'fe',
pagination_settings: {
displayed_pages: 1,
current_page: 0,
page_size: 250
Expand All @@ -28,8 +28,10 @@ export const defaultProps = {
sorting_type: 'single',
sorting_settings: [],

virtual_dataframe: [],
virtual_dataframe_indices: [],
derived_viewport_dataframe: [],
derived_viewport_indices: [],
derived_virtual_dataframe: [],
derived_virtual_indices: [],

column_conditional_dropdowns: [],
column_static_dropdown: [],
Expand All @@ -40,48 +42,14 @@ export const defaultProps = {
row_conditional_styles: [],
row_static_style: {},

changed_data: {},
dataframe: [],
columns: [],
editable: false,
active_cell: [],
index_name: '',
types: {},
merged_styles: {},
selected_cell: [[]],
selected_rows: [],
row_selectable: false,
table_style: [],
base_styles: {
numeric: {
'text-align': 'right',
'font-family': `'Droid Sans Mono', Courier, monospace`
},

string: {
'text-align': 'left'
},

input: {
padding: 0,
margin: 0,
width: '80px',
border: 'none',
'font-size': '1rem'
},

'input-active': {
outline: '#7FDBFF auto 3px'
},

table: {},

thead: {},

th: {},

td: {}
}
table_style: []
};

export const propTypes = {
Expand Down Expand Up @@ -111,8 +79,8 @@ export const propTypes = {
rule: PropTypes.string
})),

virtualization: PropTypes.oneOf(['fe', 'be', true, false]),
virtualization_settings: PropTypes.shape({
pagination_mode: PropTypes.oneOf(['fe', 'be', true, false]),
pagination_settings: PropTypes.shape({
displayed_pages: PropTypes.number,
current_page: PropTypes.number,
page_size: PropTypes.number
Expand Down Expand Up @@ -171,8 +139,10 @@ export const propTypes = {
})),
sorting_treat_empty_string_as_none: PropTypes.bool,

virtual_dataframe: PropTypes.arrayOf(PropTypes.object),
virtual_dataframe_indices: PropTypes.arrayOf(PropTypes.number),
derived_viewport_dataframe: PropTypes.arrayOf(PropTypes.object),
derived_viewport_indices: PropTypes.arrayOf(PropTypes.number),
derived_virtual_dataframe: PropTypes.arrayOf(PropTypes.object),
derived_virtual_indices: PropTypes.arrayOf(PropTypes.number),

dropdown_properties: PropTypes.any,
};
Expand Down
16 changes: 7 additions & 9 deletions src/dash-table/components/CellFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,17 @@ export default class CellFactory {
row_deletable,
row_selectable,
selected_cell,
virtualizer
viewport
} = this.props;

const { dataframe, indices } = virtualizer;

const visibleColumns = columns.filter(column => !column.hidden);

const offset =
(row_deletable ? 1 : 0) +
(row_selectable ? 1 : 0);

return dataframe.map((datum, virtualIdx) => {
const realIdx = indices[virtualIdx];
return viewport.dataframe.map((datum, viewportIdx) => {
const realIdx = viewport.indices[viewportIdx];

const deleteCell = this.rowDeleteCell(realIdx);
const selectCell = this.rowSelectCell(realIdx);
Expand Down Expand Up @@ -267,20 +265,20 @@ export default class CellFactory {

return (<Cell
key={`${column.id}-${visibleIndex}`}
active={active_cell[0] === virtualIdx && active_cell[1] === index + offset}
active={active_cell[0] === viewportIdx && active_cell[1] === index + offset}
classes={classes}
clearable={column.clearable}
conditionalDropdowns={conditionalDropdowns}
conditionalStyles={conditionalStyles}
datum={datum}
editable={editable}
focused={!!is_focused}
onClick={this.getEventHandler(this.handleClick, virtualIdx, index)}
onDoubleClick={this.getEventHandler(this.handleDoubleClick, virtualIdx, index)}
onClick={this.getEventHandler(this.handleClick, viewportIdx, index)}
onDoubleClick={this.getEventHandler(this.handleDoubleClick, viewportIdx, index)}
onPaste={this.handlePaste}
onChange={this.getEventHandler(this.handleChange, realIdx, index)}
property={column.id}
selected={R.contains([virtualIdx, index + offset], selected_cell)}
selected={R.contains([viewportIdx, index + offset], selected_cell)}
staticDropdown={staticDropdown}
staticStyle={staticStyle}
tableId={id}
Expand Down
Loading