-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added re-order and move attributes [PT-186024265] [PT-186024290]
This adds a draggable table context with a draggable header element that allows users to re-order columns in the collection and move elements to new collections. This also has some existing missing key cleanup work in it. NOTE: This does not use DnDKit as that does not work with tables.
- Loading branch information
1 parent
4749525
commit 1ae33df
Showing
9 changed files
with
279 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react"; | ||
import { useDraggableTableContext } from "../hooks/useDraggableTable"; | ||
|
||
const border = "3px solid #FBF719"; | ||
const borderLeft = border; | ||
const borderRight = border; | ||
|
||
interface DraggagleTableHeaderProps { | ||
collectionId: number; | ||
attrTitle: string; | ||
colSpan?: number; | ||
} | ||
|
||
export const DraggagleTableHeader: React.FC<DraggagleTableHeaderProps> = ({collectionId, attrTitle, children}) => { | ||
const {dragOverId, dragSide, handleDragStart, handleDragOver, handleOnDrop, handleDragEnter, | ||
handleDragLeave} = useDraggableTableContext(); | ||
const id = `${collectionId}-${attrTitle}`; | ||
const style: React.CSSProperties = id === dragOverId ? (dragSide === "left" ? {borderLeft} : {borderRight}) : {}; | ||
|
||
return ( | ||
<th | ||
data-id={id} | ||
style={style} | ||
draggable={true} | ||
onDragStart={handleDragStart} | ||
onDragOver={handleDragOver} | ||
onDrop={handleOnDrop} | ||
onDragEnter={handleDragEnter} | ||
onDragLeave={handleDragLeave} | ||
> | ||
{children} | ||
</th> | ||
); | ||
}; |
This file contains 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 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 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 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
Oops, something went wrong.