mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { forwardRef } from "react";
|
|
import { IPopoverInlineCellProps } from "../types";
|
|
import { get } from "lodash";
|
|
|
|
import { ButtonBase, Grid, Chip } from "@mui/material";
|
|
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
|
|
|
import ChipList from "components/Table/formatters/ChipList";
|
|
import { get } from "lodash";
|
|
|
|
export const ConnectService = forwardRef(function ConnectService(
|
|
{ value, showPopoverCell, disabled, column }: IPopoverInlineCellProps,
|
|
ref: React.Ref<any>
|
|
) {
|
|
const config = column.config ?? {};
|
|
const displayKey = config.titleKey ?? config.primaryKey;
|
|
return (
|
|
<ButtonBase
|
|
onClick={() => showPopoverCell(true)}
|
|
ref={ref}
|
|
disabled={disabled}
|
|
className="cell-collapse-padding"
|
|
sx={{
|
|
height: "100%",
|
|
font: "inherit",
|
|
color: "inherit !important",
|
|
letterSpacing: "inherit",
|
|
textAlign: "inherit",
|
|
justifyContent: "flex-start",
|
|
}}
|
|
>
|
|
<ChipList>
|
|
{Array.isArray(value) &&
|
|
value.map((snapshot) => (
|
|
<Grid item key={get(snapshot, config.primaryKey)}>
|
|
<Chip label={get(snapshot, displayKey)} size="small" />
|
|
</Grid>
|
|
))}
|
|
</ChipList>
|
|
|
|
{!disabled && (
|
|
<ArrowDropDownIcon
|
|
className="row-hover-iconButton"
|
|
sx={{
|
|
flexShrink: 0,
|
|
mr: 0.5,
|
|
borderRadius: 1,
|
|
p: (32 - 24) / 2 / 8,
|
|
boxSizing: "content-box",
|
|
}}
|
|
/>
|
|
)}
|
|
</ButtonBase>
|
|
);
|
|
});
|
|
|
|
export default ConnectService;
|