import { Button, Card, IconButton, TableCell, TableFooter, TableHead, TableRow } from "@material-ui/core"; import DeleteIcon from "@material-ui/icons/Delete"; 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 { AttributeValueListFragment_edges_node } from "@saleor/fragments/types/AttributeValueListFragment"; import { makeStyles } from "@saleor/macaw-ui"; import { renderCollection, stopPropagation } from "@saleor/misc"; import { ListProps, ReorderAction } from "@saleor/types"; import { AttributeInputTypeEnum } from "@saleor/types/globalTypes"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; export interface AttributeValuesProps extends Pick> { disabled: boolean; values: AttributeValueListFragment_edges_node[]; 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: { "&:last-child": { paddingRight: theme.spacing() }, width: 80 }, 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) => ( onValueUpdate(value.id) : undefined} key={value?.id} index={valueIndex || 0} > {isSwatch && (
)} {value?.slug ?? } {value?.name ?? } onValueDelete(value.id))} > ), () => ( ) )} ); }; AttributeValues.displayName = "AttributeValues"; export default AttributeValues;