import * as React from "react"; import styled from "styled-components"; import { BulkActionsMenu } from "../"; import { BulkSelectedActionsProps, BulkSelectedActionsPropsLocation, } from "../types"; import styles from "./styles"; interface sProps { location: BulkSelectedActionsPropsLocation; } const BulkSelectedActionsWrapper = styled.div` position: fixed; ${(p) => p.location === BulkSelectedActionsPropsLocation.TOP ? `top: 0;` : `bottom: 0;`} left: 0; right: 0; width: 100%; border-top: 1px solid #eee; box-shadow: -5px 0 7px 3px #eee; background-color: white; `; /** * Shows when there are one or more items selected. Provides a quick way to perform bulk actions on the selected list */ const BulkSelectedActions: React.FC = ( props: BulkSelectedActionsProps ) => { const { showActionButtons, actionButtons, showBulkActionsMenuButton, bulkActionsMenuSettings, location, children, data, } = props; return (
{children && (
{typeof children === "function" ? children(props) : children}
)} {!children && (
{data.length} item{data.length !== 1 && `s`} selected
)} {showActionButtons && (
{actionButtons && actionButtons.map((Btn, key) => ( ))}
)} {showBulkActionsMenuButton && bulkActionsMenuSettings && ( )}
); }; BulkSelectedActions.defaultProps = { data: [], location: BulkSelectedActionsPropsLocation.BOTTOM, showActionButtons: false, showBulkActionsMenuButton: false, }; export default BulkSelectedActions;