-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Feat add cellRenderer (successor of #2942) #3621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
181a1e6
Feat cell renderer
Wroud 05f6126
Merge remote-tracking branch 'upstream/main' into cell-renderer
Wroud dcad4da
chore: rename cellRenderer -> renderCell
Wroud 5d4d5db
Merge remote-tracking branch 'upstream/main' into cell-renderer
Wroud 333d30f
chore: codestyle
Wroud 3a7fec4
chore: add renderCell tests and readme
Wroud 4341329
chore: pr review fixes
Wroud c5515be
Merge branch 'main' into cell-renderer
Wroud 6c82655
fix typo
Wroud f6c8083
Merge branch 'main' into cell-renderer
Wroud 3be0a69
Merge branch 'main' into cell-renderer
Wroud dc5b9be
Merge branch 'main' into cell-renderer
Wroud 923837e
Merge branch 'main' into cell-renderer
Wroud 6e0c393
Merge branch 'main' into cell-renderer
Wroud 1509ffc
Merge remote-tracking branch 'upstream/main' into cell-renderer
Wroud 2f3881d
Merge remote-tracking branch 'upstream/main' into cell-renderer
sergeyteleshev 025ab95
Refactor setupProvider function signature in renderers.test.tsx
sergeyteleshev ffa2b23
Merge remote-tracking branch 'origin/main' into cell-renderer
Liooo c3068ef
fix typing
Liooo 0e614dc
allow passing style to cellRenderer
Liooo 233a625
Merge branch 'main' into cell-renderer
Liooo 35004a0
use object spread operator
Liooo 6c62ed1
Merge branch 'main' into cell-renderer
Liooo 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
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||
| import { memo } from 'react'; | ||||||||||||
| import { forwardRef, memo, type RefAttributes } from 'react'; | ||||||||||||
| import { css } from '@linaria/core'; | ||||||||||||
|
|
||||||||||||
| import { useRovingTabIndex } from './hooks'; | ||||||||||||
|
|
@@ -25,31 +25,37 @@ const cellDraggedOver = css` | |||||||||||
|
|
||||||||||||
| const cellDraggedOverClassname = `rdg-cell-dragged-over ${cellDraggedOver}`; | ||||||||||||
|
|
||||||||||||
| function Cell<R, SR>({ | ||||||||||||
| column, | ||||||||||||
| colSpan, | ||||||||||||
| isCellSelected, | ||||||||||||
| isCopied, | ||||||||||||
| isDraggedOver, | ||||||||||||
| row, | ||||||||||||
| rowIdx, | ||||||||||||
| onClick, | ||||||||||||
| onDoubleClick, | ||||||||||||
| onContextMenu, | ||||||||||||
| onRowChange, | ||||||||||||
| selectCell, | ||||||||||||
| ...props | ||||||||||||
| }: CellRendererProps<R, SR>) { | ||||||||||||
| function Cell<R, SR>( | ||||||||||||
| { | ||||||||||||
| column, | ||||||||||||
| colSpan, | ||||||||||||
| isCellSelected, | ||||||||||||
| isCopied, | ||||||||||||
| isDraggedOver, | ||||||||||||
| row, | ||||||||||||
| rowIdx, | ||||||||||||
| className, | ||||||||||||
| onClick, | ||||||||||||
| onDoubleClick, | ||||||||||||
| onContextMenu, | ||||||||||||
| onRowChange, | ||||||||||||
| selectCell, | ||||||||||||
| style, | ||||||||||||
| ...props | ||||||||||||
| }: CellRendererProps<R, SR>, | ||||||||||||
| ref: React.Ref<HTMLDivElement> | ||||||||||||
| ) { | ||||||||||||
| const { tabIndex, childTabIndex, onFocus } = useRovingTabIndex(isCellSelected); | ||||||||||||
|
|
||||||||||||
| const { cellClass } = column; | ||||||||||||
| const className = getCellClassname( | ||||||||||||
| className = getCellClassname( | ||||||||||||
| column, | ||||||||||||
| { | ||||||||||||
| [cellCopiedClassname]: isCopied, | ||||||||||||
| [cellDraggedOverClassname]: isDraggedOver | ||||||||||||
| }, | ||||||||||||
| typeof cellClass === 'function' ? cellClass(row) : cellClass | ||||||||||||
| typeof cellClass === 'function' ? cellClass(row) : cellClass, | ||||||||||||
| className | ||||||||||||
| ); | ||||||||||||
| const isEditable = isCellEditableUtil(column, row); | ||||||||||||
|
|
||||||||||||
|
|
@@ -88,16 +94,25 @@ function Cell<R, SR>({ | |||||||||||
| onRowChange(column, newRow); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const cellStyle = getCellStyle(column, colSpan); | ||||||||||||
| if (style) { | ||||||||||||
| let key: keyof React.CSSProperties; | ||||||||||||
| for (key in style) { | ||||||||||||
| (cellStyle as any)[key] = style[key]; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| return ( | ||||||||||||
| <div | ||||||||||||
| role="gridcell" | ||||||||||||
| aria-colindex={column.idx + 1} // aria-colindex is 1-based | ||||||||||||
| aria-colspan={colSpan} | ||||||||||||
| aria-selected={isCellSelected} | ||||||||||||
| aria-readonly={!isEditable || undefined} | ||||||||||||
| ref={ref} | ||||||||||||
| tabIndex={tabIndex} | ||||||||||||
| className={className} | ||||||||||||
| style={getCellStyle(column, colSpan)} | ||||||||||||
| style={cellStyle} | ||||||||||||
|
||||||||||||
| style={cellStyle} | |
| style={{ | |
| ...getCellStyle(column, colSpan), | |
| ...style | |
| }} |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amanmahajan7 applied in 35004a0 🙏
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
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
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.