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

Commit a70379e

Browse files
- rename selected_cell to selected_cells (#181)
1 parent db4257a commit a70379e

File tree

16 files changed

+59
-55
lines changed

16 files changed

+59
-55
lines changed

CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ Derived properties allow the component to expose complex state that can be usefu
399399

400400
## RC8 - Improve props typing
401401

402-
Issue: https://github.com/plotly/dash-table/issues/143
402+
Issue: https://github.com/plotly/dash-table/issues/143
403403

404404
## RC9 - Sort ascending on first click
405405

@@ -410,7 +410,11 @@ Derived properties allow the component to expose complex state that can be usefu
410410
## RC10 - Improved props docstrings
411411

412412
Issue: https://github.com/plotly/dash-table/issues/163
413-
413+
414414
## RC11 - Style as list view
415415

416416
- Fix regressions linked to the style_as_list_view feature / prop
417+
418+
## RC12 - Rename selected_cell -> selected_cells
419+
420+
Issue: https://github.com/plotly/dash-table/issues/177

dash_table/bundle.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_table/demo.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_table/metadata.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
"computed": false
311311
}
312312
},
313-
"selected_cell": {
313+
"selected_cells": {
314314
"type": {
315315
"name": "arrayOf",
316316
"value": {
@@ -321,7 +321,7 @@
321321
}
322322
},
323323
"required": false,
324-
"description": "`selected_cell` represents the set of cells that are selected.\nThis is similar to `active_cell` except that it contains multiple\ncells. Multiple cells can be selected by holding down shift and\nclicking on a different cell or holding down shift and navigating\nwith the arrow keys.\n\nNOTE - This property may change in the future, subscribe to\n[https://github.com/plotly/dash-table/issues/177](https://github.com/plotly/dash-table/issues/177)\nfor more details.",
324+
"description": "`selected_cells` represents the set of cells that are selected.\nThis is similar to `active_cell` except that it contains multiple\ncells. Multiple cells can be selected by holding down shift and\nclicking on a different cell or holding down shift and navigating\nwith the arrow keys.\n\nNOTE - This property may change in the future, subscribe to\n[https://github.com/plotly/dash-table/issues/177](https://github.com/plotly/dash-table/issues/177)\nfor more details.",
325325
"defaultValue": {
326326
"value": "[[]]",
327327
"computed": false

dash_table/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.1.0rc11",
3+
"version": "3.1.0rc12",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.1.0rc11",
3+
"version": "3.1.0rc12",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {

src/dash-table/Table.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const defaultProps = {
7575
columns: [],
7676
editable: false,
7777
active_cell: [],
78-
selected_cell: [[]],
78+
selected_cells: [[]],
7979
selected_rows: [],
8080
row_selectable: false,
8181

@@ -365,7 +365,7 @@ export const propTypes = {
365365
row_selectable: PropTypes.oneOf(['single', 'multi', false]),
366366

367367
/**
368-
* `selected_cell` represents the set of cells that are selected.
368+
* `selected_cells` represents the set of cells that are selected.
369369
* This is similar to `active_cell` except that it contains multiple
370370
* cells. Multiple cells can be selected by holding down shift and
371371
* clicking on a different cell or holding down shift and navigating
@@ -375,7 +375,7 @@ export const propTypes = {
375375
* [https://github.com/plotly/dash-table/issues/177](https://github.com/plotly/dash-table/issues/177)
376376
* for more details.
377377
*/
378-
selected_cell: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
378+
selected_cells: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
379379

380380
/**
381381
* `selected_rows` contains the indices of the rows that

src/dash-table/components/CellFactory.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class CellFactory {
4040
is_focused,
4141
row_deletable,
4242
row_selectable,
43-
selected_cell,
43+
selected_cells,
4444
selected_rows,
4545
setProps,
4646
style_cell,
@@ -66,7 +66,7 @@ export default class CellFactory {
6666
columns,
6767
viewport.data,
6868
editable,
69-
selected_cell
69+
selected_cells
7070
);
7171

7272
const relevantStyles = this.relevantStyles(

src/dash-table/components/ControlledTable/index.tsx

+19-19
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
6464

6565
componentDidMount() {
6666
if (
67-
this.props.selected_cell.length &&
68-
!R.contains(this.props.active_cell, this.props.selected_cell)
67+
this.props.selected_cells.length &&
68+
!R.contains(this.props.active_cell, this.props.selected_cells)
6969
) {
70-
this.props.setProps({ active_cell: this.props.selected_cell[0] });
70+
this.props.setProps({ active_cell: this.props.selected_cells[0] });
7171
}
7272

7373
this.applyStyle();
@@ -251,7 +251,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
251251
const {
252252
active_cell,
253253
columns,
254-
selected_cell,
254+
selected_cells,
255255
setProps,
256256
viewport
257257
} = this.props;
@@ -268,7 +268,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
268268
// with the "is_focused" prop. We should find the better way.
269269
this.$el.focus();
270270

271-
const hasSelection = selected_cell.length > 1;
271+
const hasSelection = selected_cells.length > 1;
272272
const isEnterOrTab =
273273
e.keyCode === KEY_CODES.ENTER || e.keyCode === KEY_CODES.TAB;
274274

@@ -294,7 +294,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
294294
});
295295
setProps({
296296
is_focused: false,
297-
selected_cell: [nextCell],
297+
selected_cells: [nextCell],
298298
active_cell: nextCell
299299
});
300300
return;
@@ -304,8 +304,8 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
304304
// with shift.
305305
let targetCells: any[] = [];
306306
let removeCells: any[] = [];
307-
const selectedRows = sortNumerical(R.uniq(R.pluck(0, selected_cell)));
308-
const selectedCols = sortNumerical(R.uniq(R.pluck(1, selected_cell)));
307+
const selectedRows = sortNumerical(R.uniq(R.pluck(0, selected_cells)));
308+
const selectedCols = sortNumerical(R.uniq(R.pluck(1, selected_cells)));
309309

310310
const minRow = selectedRows[0];
311311
const minCol = selectedCols[0];
@@ -352,11 +352,11 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
352352

353353
const newSelectedCell = R.without(
354354
removeCells,
355-
R.uniq(R.concat(targetCells, selected_cell))
355+
R.uniq(R.concat(targetCells, selected_cells))
356356
);
357357
setProps({
358358
is_focused: false,
359-
selected_cell: newSelectedCell
359+
selected_cells: newSelectedCell
360360
});
361361
}
362362

@@ -365,7 +365,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
365365
columns,
366366
data,
367367
editable,
368-
selected_cell,
368+
selected_cells,
369369
setProps,
370370
viewport
371371
} = this.props;
@@ -376,7 +376,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
376376

377377
const realCells: [number, number][] = R.map(
378378
cell => [viewport.indices[cell[0]], cell[1]] as [number, number],
379-
selected_cell
379+
selected_cells
380380
);
381381

382382
realCells.forEach(cell => {
@@ -395,7 +395,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
395395
}
396396

397397
getNextCell = (event: any, { restrictToSelection, currentCell }: any) => {
398-
const { columns, selected_cell, viewport } = this.props;
398+
const { columns, selected_cells, viewport } = this.props;
399399

400400
const e = event;
401401

@@ -404,7 +404,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
404404
return restrictToSelection
405405
? selectionCycle(
406406
[currentCell[0], currentCell[1] - 1],
407-
selected_cell
407+
selected_cells
408408
)
409409
: [
410410
currentCell[0],
@@ -416,7 +416,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
416416
return restrictToSelection
417417
? selectionCycle(
418418
[currentCell[0], currentCell[1] + 1],
419-
selected_cell
419+
selected_cells
420420
)
421421
: [
422422
currentCell[0],
@@ -427,7 +427,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
427427
return restrictToSelection
428428
? selectionCycle(
429429
[currentCell[0] - 1, currentCell[1]],
430-
selected_cell
430+
selected_cells
431431
)
432432
: [R.max(0, currentCell[0] - 1), currentCell[1]];
433433

@@ -436,7 +436,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
436436
return restrictToSelection
437437
? selectionCycle(
438438
[currentCell[0] + 1, currentCell[1]],
439-
selected_cell
439+
selected_cells
440440
)
441441
: [
442442
R.min(viewport.data.length - 1, currentCell[0] + 1),
@@ -453,11 +453,11 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
453453
onCopy = (e: any) => {
454454
const {
455455
columns,
456-
selected_cell,
456+
selected_cells,
457457
viewport
458458
} = this.props;
459459

460-
TableClipboardHelper.toClipboard(e, selected_cell, columns, viewport.data);
460+
TableClipboardHelper.toClipboard(e, selected_cells, columns, viewport.data);
461461
this.$el.focus();
462462
}
463463

src/dash-table/components/Table/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default class Table extends Component<PropsWithDefaultsAndDerived> {
136136

137137
if (invalidateSelection) {
138138
newProps.active_cell = undefined;
139-
newProps.selected_cell = undefined;
139+
newProps.selected_cells = undefined;
140140
newProps.selected_rows = undefined;
141141
}
142142

src/dash-table/components/Table/props.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ interface IProps {
129129
n_fixed_rows?: number;
130130
row_deletable?: boolean;
131131
row_selectable?: RowSelection;
132-
selected_cell?: SelectedCells;
132+
selected_cells?: SelectedCells;
133133
selected_rows?: number[];
134134
setProps?: SetProps;
135135
sorting?: Sorting;
@@ -171,7 +171,7 @@ interface IDefaultProps {
171171
n_fixed_rows: number;
172172
row_deletable: boolean;
173173
row_selectable: RowSelection;
174-
selected_cell: SelectedCells;
174+
selected_cells: SelectedCells;
175175
selected_rows: number[];
176176
sorting: Sorting;
177177
sorting_settings: SortSettings;
@@ -229,7 +229,7 @@ export interface ICellFactoryOptions {
229229
paginator: IPaginator;
230230
row_deletable: boolean;
231231
row_selectable: RowSelection;
232-
selected_cell: SelectedCells;
232+
selected_cells: SelectedCells;
233233
selected_rows: number[];
234234
setProps: SetProps;
235235
style_cell: Style;

src/dash-table/handlers/cellEvents.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export const handleClick = (propsFn: () => ICellFactoryOptions, idx: number, i:
99
const {
1010
editable,
1111
is_focused,
12-
selected_cell,
12+
selected_cells,
1313
setProps
1414
} = propsFn();
1515

16-
const selected = isCellSelected(selected_cell, idx, i);
16+
const selected = isCellSelected(selected_cells, idx, i);
1717

1818
if (!editable) {
1919
return;
@@ -34,13 +34,13 @@ export const handleClick = (propsFn: () => ICellFactoryOptions, idx: number, i:
3434
active_cell: cellLocation
3535
};
3636

37-
const selectedRows = R.uniq(R.pluck(0, selected_cell)).sort((a, b) => a - b);
38-
const selectedCols = R.uniq(R.pluck(1, selected_cell)).sort((a, b) => a - b);
37+
const selectedRows = R.uniq(R.pluck(0, selected_cells)).sort((a, b) => a - b);
38+
const selectedCols = R.uniq(R.pluck(1, selected_cells)).sort((a, b) => a - b);
3939
const minRow = selectedRows[0];
4040
const minCol = selectedCols[0];
4141

4242
if (e.shiftKey) {
43-
newProps.selected_cell = R.xprod(
43+
newProps.selected_cells = R.xprod(
4444
R.range(
4545
R.min(minRow, cellLocation[0]),
4646
R.max(minRow, cellLocation[0]) + 1
@@ -51,7 +51,7 @@ export const handleClick = (propsFn: () => ICellFactoryOptions, idx: number, i:
5151
)
5252
) as any;
5353
} else {
54-
newProps.selected_cell = [cellLocation];
54+
newProps.selected_cells = [cellLocation];
5555
}
5656

5757
setProps(newProps);
@@ -73,7 +73,7 @@ export const handleDoubleClick = (propsFn: () => ICellFactoryOptions, idx: numbe
7373
if (!is_focused) {
7474
e.preventDefault();
7575
const newProps = {
76-
selected_cell: [cellLocation],
76+
selected_cells: [cellLocation],
7777
active_cell: cellLocation,
7878
is_focused: true
7979
};

src/dash-table/utils/actions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function deleteColumn(column, columns, headerRowIndex, props) {
4545
// trying to delete
4646
active_cell: [],
4747
end_cell: [],
48-
selected_cell: [],
48+
selected_cells: [],
4949
start_cell: [0]
5050
}
5151
}

src/dash-table/utils/navigation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as R from 'ramda';
22

3-
export function selectionCycle(nextCell, selected_cell) {
4-
const selectedRows = R.uniq(R.pluck(0, selected_cell)).sort((a, b) => a - b);
5-
const selectedCols = R.uniq(R.pluck(1, selected_cell)).sort((a, b) => a - b);
3+
export function selectionCycle(nextCell, selected_cells) {
4+
const selectedRows = R.uniq(R.pluck(0, selected_cells)).sort((a, b) => a - b);
5+
const selectedCols = R.uniq(R.pluck(1, selected_cells)).sort((a, b) => a - b);
66

77
const minRow = selectedRows[0];
88
const minCol = selectedCols[0];

tests/visual/percy-storybook/DashTable.percy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ storiesOf('DashTable/Hidden Columns', module)
181181
id='table'
182182
data={data}
183183
columns={hiddenColumns}
184-
selected_cell={[[1, 1], [1, 2], [2, 1], [2, 2]]}
184+
selected_cells={[[1, 1], [1, 2], [2, 1], [2, 2]]}
185185
style_data_conditional={style_data_conditional}
186186
/>));
187187

0 commit comments

Comments
 (0)