feat(admin,admin-ui,medusa): Add Medusa Admin plugin (#3334)
This commit is contained in:
committed by
GitHub
parent
d6b1ad1ccd
commit
40de54b010
39
packages/admin-ui/ui/src/hooks/use-selection-column.tsx
Normal file
39
packages/admin-ui/ui/src/hooks/use-selection-column.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import React from "react"
|
||||
import Checkbox from "../components/atoms/checkbox"
|
||||
import Table from "../components/molecules/table"
|
||||
|
||||
const IndeterminateCheckbox = React.forwardRef(
|
||||
({ indeterminate, ...rest }, ref) => {
|
||||
const defaultRef = React.useRef()
|
||||
const resolvedRef = ref || defaultRef
|
||||
|
||||
React.useEffect(() => {
|
||||
resolvedRef.current.indeterminate = indeterminate
|
||||
}, [resolvedRef, indeterminate])
|
||||
|
||||
return (
|
||||
<div onClickCapture={(e) => e.stopPropagation()}>
|
||||
<Checkbox
|
||||
className="justify-center"
|
||||
label=""
|
||||
ref={resolvedRef}
|
||||
{...rest}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
export const useSelectionColumn = () => {
|
||||
return {
|
||||
id: "selection",
|
||||
Header: ({ getToggleAllRowsSelectedProps }) => (
|
||||
<IndeterminateCheckbox {...getToggleAllRowsSelectedProps()} />
|
||||
),
|
||||
Cell: ({ row }) => (
|
||||
<Table.Cell className="text-center">
|
||||
<IndeterminateCheckbox {...row.getToggleRowSelectedProps()} />
|
||||
</Table.Cell>
|
||||
),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user