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

Issue 280 - Refactor cell content #281

Merged
merged 42 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
31aa600
bump version
Nov 27, 2018
7a454de
Refactor demo app
Nov 27, 2018
6884635
Run standalone tests for all app modes
Nov 27, 2018
d2f185a
Lint fix
Nov 27, 2018
45c7e60
Expose environment params
Nov 27, 2018
32e251b
Update viewport usage to virtualized + offset
Nov 27, 2018
ffd5d43
Lint fix
Nov 27, 2018
fb6068e
Apply scrolling and styling
Nov 27, 2018
8426c1b
Dev build
Nov 27, 2018
a635ac6
Add virtualization prop
Nov 27, 2018
4f7f989
Virtualization specific tests
Nov 27, 2018
6145753
Build artefacts
Nov 27, 2018
0e8e524
Remove duplicated tests
Nov 27, 2018
1fb178b
Fix regressions
Nov 27, 2018
2684898
Test regression
Nov 27, 2018
e921e61
No virtualization code if not virtualized
Nov 27, 2018
371fc41
Fix test regression
Nov 27, 2018
21a4b4a
Fix test regression
Nov 27, 2018
0e1fb4b
Fix styling regression
Nov 27, 2018
2b15526
Revert pagination_mode default change
Nov 27, 2018
6ecad3e
Fix visual test regression
Nov 27, 2018
e324db0
Virtualization review app
Nov 27, 2018
abc382b
Merge remote-tracking branch 'origin/master' into 3.1-issue234-virtua…
Nov 29, 2018
238b7b8
- refactor cellinput into cellcontent
Dec 3, 2018
8551e54
- add CellLabel, refactor label case
Dec 3, 2018
e63739a
- refactor content input and dropdown
Dec 3, 2018
07d4451
fix lint
Dec 3, 2018
80c2d3a
- fix focus regression
Dec 3, 2018
63efb23
- refactor dropdown as standalone component
Dec 3, 2018
186f284
- fix dropdown choice
Dec 3, 2018
57951d2
- fix navigation test regression
Dec 3, 2018
0f3c26b
- fix virtualization regression
Dec 3, 2018
886d32b
- small optimization for uiHeaders and uiCell
Dec 3, 2018
d51ed0c
Merge remote-tracking branch 'origin/master' into 3.1-issue234-virtua…
Dec 3, 2018
7a1383d
Merge remote-tracking branch 'origin/3.1-issue234-virtualization-2' i…
Dec 3, 2018
aac3c89
- refactor contents, clean up props and types
Dec 3, 2018
3c7bb28
Merge remote-tracking branch 'origin/master' into 3.1-rework-cell-con…
Dec 4, 2018
b6dbee2
bump version
Dec 4, 2018
ad5e56f
- removal conditionals of
Dec 4, 2018
96726d0
merge master onto 3.1-rework-cell-content
Dec 5, 2018
dc46220
- improve dropdown typing
Dec 6, 2018
891062a
- improve types
Dec 6, 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: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# testing
/coverage
/tests/e2e/cypress/screenshots/**
/tests/cypress/screenshots/**
/storybook-static/**

# misc
Expand Down Expand Up @@ -36,4 +36,4 @@ dist
*__pycache__*
__pycache__/

*.pyc
*.pyc
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [3.1.9-rc1] - 2018-12-03
### Changed
- Refactoring in preparation for data types

## [3.1.8] - 2018-12-04
### Added
- Virtualization [#234](https://github.com/plotly/dash-table/issues/234)
Expand All @@ -12,6 +16,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Update dependencies [#274](https://github.com/plotly/dash-table/pull/274)
- Update dependencies [#251](https://github.com/plotly/dash-table/pull/251)


## [3.1.7] - 2018-11-19
### Fixed
- Visual offset with vertical scroll [#216](https://github.com/plotly/dash-table/issues/216)
Expand Down
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.

2 changes: 1 addition & 1 deletion dash_table/package-info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.1.8",
"version": "3.1.9-rc1",
"description": "Dash table",
"main": "dash_table/bundle.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.1.8",
"version": "3.1.9-rc1",
"description": "Dash table",
"main": "dash_table/bundle.js",
"scripts": {
Expand Down
78 changes: 78 additions & 0 deletions src/dash-table/components/CellDropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, {
ChangeEvent,
PureComponent
} from 'react';
import Dropdown from 'react-select';

import DOM from 'core/browser/DOM';

import dropdownHelper from 'dash-table/components/dropdownHelper';

import { IDropdownOptions } from './types';

interface IProps {
active: boolean;
clearable?: boolean;
dropdown: IDropdownOptions;
onChange: (e: ChangeEvent) => void;
value: any;
}

export default class CellDropdown extends PureComponent<IProps> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Standalone Dropdown component pulled out of pre-existing CellInput comp

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well it still uses react-select in the end :(

render() {
const {
clearable,
dropdown,
onChange,
value
} = this.props;

return (<div className='dash-dropdown-cell-value-container dash-cell-value-container'>
<div className='dropdown-cell-value-shadow cell-value-shadow'>
{(dropdown.find(entry => entry.value === value) || { label: undefined }).label}
</div>
<Dropdown
ref='dropdown'
clearable={clearable}
onChange={(newValue: any) => {
onChange(newValue ? newValue.value : newValue);
}}
onOpen={this.handleOpenDropdown}
options={dropdown}
placeholder={''}
value={value}
/>
</div>);
}

componentDidUpdate() {
this.setFocus();
}

componentDidMount() {
this.setFocus();
}

private setFocus() {
const { active } = this.props;
if (!active) {
return;
}

const dropdown = this.refs.dropdown as any;

if (dropdown && document.activeElement !== dropdown) {
// Limitation. If React >= 16 --> Use React.createRef instead to pass parent ref to child
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not be possible to pass a ref down from the parent, regardless of React >= 16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what I have in mind: ref forwarding (added in React 16.3)
https://reactjs.org/docs/forwarding-refs.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha. Yeah that would be nice!

const tdParent = DOM.getFirstParentOfType(dropdown.wrapper, 'td');
if (tdParent) {
tdParent.focus();
}
}
}

private handleOpenDropdown = () => {
const { dropdown }: { [key: string]: any } = this.refs;

dropdownHelper(dropdown.wrapper.querySelector('.Select-menu-outer'));
}
}
11 changes: 5 additions & 6 deletions src/dash-table/components/CellFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import { ICellFactoryProps } from 'dash-table/components/Table/props';
import derivedCellWrappers from 'dash-table/derived/cell/wrappers';
import derivedCellInputs from 'dash-table/derived/cell/inputs';
import derivedCellContents from 'dash-table/derived/cell/contents';
import derivedCellOperations from 'dash-table/derived/cell/operations';
import derivedCellStyles from 'dash-table/derived/cell/wrapperStyles';
import derivedDropdowns from 'dash-table/derived/cell/dropdowns';
Expand All @@ -12,7 +12,7 @@ import { matrixMap3 } from 'core/math/matrixZipMap';
import { arrayMap } from 'core/math/arrayZipMap';

export default class CellFactory {
private readonly cellInputs = derivedCellInputs();
private readonly cellContents = derivedCellContents();
private readonly cellOperations = derivedCellOperations();
private readonly cellDropdowns = derivedDropdowns();

Expand Down Expand Up @@ -92,23 +92,22 @@ export default class CellFactory {
dropdown_properties
);

const inputs = this.cellInputs(
const contents = this.cellContents(
active_cell,
columns,
virtualized.data,
virtualized.offset,
editable,
!!is_focused,
id,
dropdowns,
this.propsFn
);

const cells = matrixMap3(
wrappers,
wrapperStyles,
inputs,
(w, s, i) => React.cloneElement(w, { children: [i], style: s })
contents,
(w, s, c) => React.cloneElement(w, { children: [c], style: s })
);

return arrayMap(
Expand Down
Loading