This repository was archived by the owner on Aug 29, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 72
Border colors 2 #424
Merged
Merged
Border colors 2 #424
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
6bf7a93
- edges generation
781513e
- tweak border calculations
afa1f0e
reconcile styles
2d2bdb4
reconcile edges in transition zones
971c265
improve styles applied on operation columns
63c5434
improve default props
8cd350c
- improved caching
e016bb5
- add basic border styling visual tests
06ee116
update border style visual tests
a6d2fb5
new approach to reconcile borders
87ea8f8
fix edge unit tests
6d67d68
update edge tests
128da30
clean up
46cab57
simulacrum of immutability through types
5a4253d
Merge branch 'master' into border-colors-2
Marc-Andre-Rivet 634ddcb
clean up ops vs. other edges usage
330f11c
Merge remote-tracking branch 'origin/master' into border-colors
ea151ca
- rework
204c240
revert filter styling regression
f57165f
revert border styling
e371078
rework style_as_list_view
1ab4982
support active cell styling again
307b650
fix active_cell (0,0) case
fa197c4
rework active_cell rework...
630d3f4
fix edge unit tests
6e592b4
fix edge tests
dcc9257
var(--accent) active border color (revert)
41c46e0
update fixture height to show border as before
e679827
simplify undefined test
2c1e4d6
edge tests
58472ed
additional case
525c36d
refactor out filter mapping logic from the filter factory
ba26e74
fix filters on update and init
2c3f41e
handle fixed rows/columns for edges
26ebf34
performance
a6ed2e3
remove css overrides & cleanup unused changes
d4af434
add it back.. does not handle fixed inside a fragment
ce238a4
refactor border style tests
2e036f7
fix filter test
1c9749f
fix standalone filter reset test
bc35085
fix ops columns styling
6d1a386
disappearing invalid filter test (will fail)
98801b9
fix disappearing invalid filter test
2be996f
add new operation columns visual tests
ea31de1
messy ops styling
f2409c3
update border visual tests
0816c53
n_fixed_rows misalignment
ea48933
update changelog
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,70 +2,109 @@ import * as R from 'ramda'; | |
|
|
||
| type Matrix<T> = T[][]; | ||
|
|
||
| export function matrixMap<T1, T2, TR>( | ||
| export function matrixMap<T1, TR>( | ||
| m1: Matrix<T1>, | ||
| m2: Matrix<T2>, | ||
| cb: (d1: T1, d2: T2, i: number, j: number) => TR | ||
| cb: (d1: T1, i: number, j: number) => TR | ||
| ) { | ||
| const mapMatrix = R.addIndex<T1[], TR[]>(R.map); | ||
| const mapRow = R.addIndex<T1, TR>(R.map); | ||
|
|
||
| return mapMatrix((iRow, i) => | ||
| mapRow( | ||
| (ijValue, j) => cb(ijValue, m2[i][j], i, j), | ||
| (ijValue, j) => cb(ijValue, i, j), | ||
| iRow | ||
| ), m1 | ||
| ); | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a 1-matrix map -- otherwise all below is essentially dealing with undefined cases |
||
|
|
||
| export function matrixMap2<T1, T2, TR>( | ||
| m1: Matrix<T1>, | ||
| m2: Matrix<T2> | undefined, | ||
| cb: (d1: T1, d2: T2 | undefined, i: number, j: number) => TR | ||
| ) { | ||
| const mapMatrix = R.addIndex<T1[], TR[]>(R.map); | ||
| const mapRow = R.addIndex<T1, TR>(R.map); | ||
|
|
||
| return mapMatrix((iRow, i) => | ||
| mapRow( | ||
| (ijValue, j) => cb( | ||
| ijValue, | ||
| m2 ? m2[i][j] : undefined, | ||
| i, | ||
| j | ||
| ), | ||
| iRow | ||
| ), m1 | ||
| ); | ||
| } | ||
|
|
||
| export function matrixMap3<T1, T2, T3, TR>( | ||
| m1: Matrix<T1>, | ||
| m2: Matrix<T2>, | ||
| m3: Matrix<T3>, | ||
| cb: (d1: T1, d2: T2, d3: T3, i: number, j: number) => TR | ||
| m2: Matrix<T2> | undefined, | ||
| m3: Matrix<T3> | undefined, | ||
| cb: (d1: T1, d2: T2 | undefined, d3: T3 | undefined, i: number, j: number) => TR | ||
| ) { | ||
| const mapMatrix = R.addIndex<T1[], TR[]>(R.map); | ||
| const mapRow = R.addIndex<T1, TR>(R.map); | ||
|
|
||
| return mapMatrix((iRow, i) => | ||
| mapRow( | ||
| (ijValue, j) => cb(ijValue, m2[i][j], m3[i][j], i, j), | ||
| (ijValue, j) => cb( | ||
| ijValue, | ||
| m2 ? m2[i][j] : undefined, | ||
| m3 ? m3[i][j] : undefined, | ||
| i, | ||
| j | ||
| ), | ||
| iRow | ||
| ), m1 | ||
| ); | ||
| } | ||
|
|
||
| export function matrixMap4<T1, T2, T3, T4, TR>( | ||
| m1: Matrix<T1>, | ||
| m2: Matrix<T2>, | ||
| m3: Matrix<T3>, | ||
| m4: Matrix<T4>, | ||
| cb: (d1: T1, d2: T2, d3: T3, d4: T4, i: number, j: number) => TR | ||
| m2: Matrix<T2> | undefined, | ||
| m3: Matrix<T3> | undefined, | ||
| m4: Matrix<T4> | undefined, | ||
| cb: (d1: T1, d2: T2 | undefined, d3: T3 | undefined, d4: T4 | undefined, i: number, j: number) => TR | ||
| ) { | ||
| const mapMatrix = R.addIndex<T1[], TR[]>(R.map); | ||
| const mapRow = R.addIndex<T1, TR>(R.map); | ||
|
|
||
| return mapMatrix((iRow, i) => | ||
| mapRow( | ||
| (ijValue, j) => cb(ijValue, m2[i][j], m3[i][j], m4[i][j], i, j), | ||
| (ijValue, j) => cb( | ||
| ijValue, | ||
| m2 ? m2[i][j] : undefined, | ||
| m3 ? m3[i][j] : undefined, | ||
| m4 ? m4[i][j] : undefined, | ||
| i, | ||
| j | ||
| ), | ||
| iRow | ||
| ), m1 | ||
| ); | ||
| } | ||
|
|
||
| export function matrixMapN<TR>( | ||
| cb: (i: number, j: number, ...args: any[]) => TR, | ||
| ...matrices: (any[][])[] | ||
| m1: Matrix<any>, | ||
| ...matrices: (any[][] | undefined)[] | ||
| ) { | ||
| const m1 = matrices.slice(0, 1); | ||
| const ms = matrices.slice(1); | ||
|
|
||
| const mapMatrix = R.addIndex<any[], TR[]>(R.map); | ||
| const mapRow = R.addIndex<any, TR>(R.map); | ||
|
|
||
| return mapMatrix((iRow, i) => | ||
| mapRow( | ||
| (ijValue, j) => cb(i, j, [ijValue, ...ms.map(m => m[i][j])]), | ||
| (ijValue, j) => cb( | ||
| i, | ||
| j, | ||
| [ | ||
| ijValue, | ||
| m1[i][j], | ||
| ...matrices.map(m => m ? m[i][j] : undefined) | ||
| ] | ||
| ), | ||
| iRow | ||
| ), m1 | ||
| ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,10 @@ | ||
| export type OptionalMap<T, TR extends keyof T, M> = { | ||
| [tr in TR]?: M | ||
| }; | ||
| export type RequiredPluck<T, R extends keyof T> = { [r in R]: T[r] }; | ||
| export type OptionalPluck<T, R extends keyof T> = { [r in R]?: T[r] }; | ||
|
|
||
| export type RequiredProp<T, R extends keyof T> = T[R]; | ||
| export type OptionalProp<T, R extends keyof T> = T[R] | undefined; | ||
|
|
||
| export type PropOf<T, R extends keyof T> = R; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just defining some types to do TypeScript stuff later.. |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,17 @@ | ||
| import * as R from 'ramda'; | ||
| import React from 'react'; | ||
|
|
||
| import { matrixMap2, matrixMap3 } from 'core/math/matrixZipMap'; | ||
| import { arrayMap2 } from 'core/math/arrayZipMap'; | ||
|
|
||
| import { ICellFactoryProps } from 'dash-table/components/Table/props'; | ||
| import derivedCellWrappers from 'dash-table/derived/cell/wrappers'; | ||
| 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 derivedCellStyles, { derivedDataOpStyles } from 'dash-table/derived/cell/wrapperStyles'; | ||
| import derivedDropdowns from 'dash-table/derived/cell/dropdowns'; | ||
| import { derivedRelevantCellStyles } from 'dash-table/derived/style'; | ||
|
|
||
| import { matrixMap3 } from 'core/math/matrixZipMap'; | ||
| import { arrayMap } from 'core/math/arrayZipMap'; | ||
| import { IEdgesMatrices } from 'dash-table/derived/edges/type'; | ||
|
|
||
| export default class CellFactory { | ||
|
|
||
|
|
@@ -23,11 +25,12 @@ export default class CellFactory { | |
| private readonly cellDropdowns = derivedDropdowns(), | ||
| private readonly cellOperations = derivedCellOperations(), | ||
| private readonly cellStyles = derivedCellStyles(), | ||
| private readonly dataOpStyles = derivedDataOpStyles(), | ||
| private readonly cellWrappers = derivedCellWrappers(propsFn), | ||
| private readonly relevantStyles = derivedRelevantCellStyles() | ||
| ) { } | ||
|
|
||
| public createCells() { | ||
| public createCells(dataEdges: IEdgesMatrices | undefined, dataOpEdges: IEdgesMatrices | undefined) { | ||
| const { | ||
| active_cell, | ||
| columns, | ||
|
|
@@ -49,30 +52,27 @@ export default class CellFactory { | |
| virtualized | ||
| } = this.props; | ||
|
|
||
| const operations = this.cellOperations( | ||
| data, | ||
| virtualized.data, | ||
| virtualized.indices, | ||
| row_selectable, | ||
| row_deletable, | ||
| selected_rows, | ||
| setProps | ||
| ); | ||
|
|
||
| const relevantStyles = this.relevantStyles( | ||
| style_cell, | ||
| style_data, | ||
| style_cell_conditional, | ||
| style_data_conditional | ||
| ); | ||
|
|
||
| const wrapperStyles = this.cellStyles( | ||
| const cellStyles = this.cellStyles( | ||
| columns, | ||
| relevantStyles, | ||
| virtualized.data, | ||
| virtualized.offset | ||
| ); | ||
|
|
||
| const dataOpStyles = this.dataOpStyles( | ||
| (row_selectable ? 1 : 0) + (row_deletable ? 1 : 0), | ||
| relevantStyles, | ||
| virtualized.data, | ||
| virtualized.offset | ||
| ); | ||
|
|
||
| const dropdowns = this.cellDropdowns( | ||
| columns, | ||
| virtualized.data, | ||
|
|
@@ -82,15 +82,25 @@ export default class CellFactory { | |
| dropdown_properties | ||
| ); | ||
|
|
||
| const wrappers = this.cellWrappers( | ||
| const operations = this.cellOperations( | ||
| data, | ||
| virtualized.data, | ||
| virtualized.indices, | ||
| row_selectable, | ||
| row_deletable, | ||
| selected_rows, | ||
| setProps | ||
| ); | ||
|
|
||
| const cellWrappers = this.cellWrappers( | ||
| active_cell, | ||
| columns, | ||
| virtualized.data, | ||
| virtualized.offset, | ||
| selected_cells | ||
| ); | ||
|
|
||
| const contents = this.cellContents( | ||
| const cellContents = this.cellContents( | ||
| active_cell, | ||
| columns, | ||
| virtualized.data, | ||
|
|
@@ -100,15 +110,33 @@ export default class CellFactory { | |
| dropdowns | ||
| ); | ||
|
|
||
| const ops = matrixMap2( | ||
| operations, | ||
| dataOpStyles, | ||
| (o, s, i, j) => React.cloneElement(o, { | ||
| style: R.mergeAll([ | ||
| dataOpEdges && dataOpEdges.getStyle(i, j), | ||
| s, | ||
| o.props.style | ||
| ]) | ||
| }) | ||
| ); | ||
|
|
||
| const cells = matrixMap3( | ||
| wrappers, | ||
| wrapperStyles, | ||
| contents, | ||
| (w, s, c) => React.cloneElement(w, { children: [c], style: s }) | ||
| cellWrappers, | ||
| cellStyles, | ||
| cellContents, | ||
| (w, s, c, i, j) => React.cloneElement(w, { | ||
| children: [c], | ||
| style: R.mergeAll([ | ||
| s, | ||
| dataEdges && dataEdges.getStyle(i, j) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and above in ops, obtaining the calculated borders for this specific cell |
||
| ]) | ||
| }) | ||
| ); | ||
|
|
||
| return arrayMap( | ||
| operations, | ||
| return arrayMap2( | ||
| ops, | ||
| cells, | ||
| (o, c) => Array.prototype.concat(o, c) | ||
| ); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.