-
Notifications
You must be signed in to change notification settings - Fork 5
/
SimpleStringTable.tsx
53 lines (51 loc) · 1.54 KB
/
SimpleStringTable.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { ActionIcon, Flex, TextInput } from "@mantine/core"
import { LuTrash2 } from "react-icons/lu"
import CopyTextButton from "~/components/CopyTextButton"
import { DataTable } from "~/components/DataTable"
type SimpleStringTableProps = {
data: string[]
readOnly?: boolean
onDelete: (value: string) => void
}
const SimpleStringTable = ({ data, readOnly, onDelete }: SimpleStringTableProps) => {
return (
data && (
<DataTable
data={data?.map((value) => {
return {
userAgent: {
element: <TextInput readOnly miw={300} value={value} />,
cellProps: {
style: { paddingLeft: 0, paddingRight: 0 },
},
},
action: {
element: (
<Flex gap="lg" justify="flex-end">
<CopyTextButton value={value} />
{!readOnly && (
<ActionIcon
aria-label="Delete value"
radius="xl"
size={40}
variant="outline"
onClick={() => onDelete(value)}
>
<LuTrash2 size={18} />
</ActionIcon>
)}
</Flex>
),
cellProps: {
style: { minWidth: "130px", paddingLeft: 0, paddingRight: 0 },
width: "130px",
},
},
}
})}
paginate={false}
/>
)
)
}
export default SimpleStringTable