import { Card, TableCell, TableFooter, TableHead, TableRow, } from "@material-ui/core"; import { Button } from "@saleor/components/Button"; import CardTitle from "@saleor/components/CardTitle"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import { SortableTableBody, SortableTableRow, } from "@saleor/components/SortableTable"; import TablePagination from "@saleor/components/TablePagination"; import { AttributeInputTypeEnum, AttributeValueListFragment, } from "@saleor/graphql"; import { DeleteIcon, IconButton, makeStyles } from "@saleor/macaw-ui"; import { renderCollection, stopPropagation } from "@saleor/misc"; import { ListProps, PaginateListProps, RelayToFlat, ReorderAction, } from "@saleor/types"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; export interface AttributeValuesProps extends Pick>, PaginateListProps { disabled: boolean; values: RelayToFlat; onValueAdd: () => void; onValueDelete: (id: string) => void; onValueReorder: ReorderAction; onValueUpdate: (id: string) => void; inputType: AttributeInputTypeEnum; } const useStyles = makeStyles( theme => ({ columnSwatch: { width: 100, }, columnAdmin: { width: 300, }, columnDrag: { width: theme.spacing(6 + 1.5), }, columnStore: { width: "auto", }, dragIcon: { cursor: "grab", }, iconCell: { width: 84, }, link: { cursor: "pointer", }, swatch: { width: 32, height: 32, borderRadius: 4, backgroundSize: "cover", backgroundPosition: "center", }, }), { name: "AttributeValues" }, ); const AttributeValues: React.FC = ({ disabled, onValueAdd, onValueDelete, onValueReorder, onValueUpdate, values, settings, onUpdateListSettings, pageInfo, onNextPage, onPreviousPage, inputType, }) => { const classes = useStyles({}); const intl = useIntl(); const isSwatch = inputType === AttributeInputTypeEnum.SWATCH; const numberOfColumns = isSwatch ? 5 : 4; return ( } /> {isSwatch && ( )} {renderCollection( values, (value, valueIndex) => ( className={!!value ? classes.link : undefined} hover={!!value} onClick={!!value ? () => onValueUpdate(value.id) : undefined} key={value?.id} index={valueIndex || 0} > {isSwatch && (
)} {value?.slug ?? } {value?.name ?? } onValueDelete(value.id))} > ), () => ( ), )} ); }; AttributeValues.displayName = "AttributeValues"; export default AttributeValues;