All files / src/material-toolbox/dialog Actions.js

100% Statements 6/6
100% Branches 3/3
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                          5x             8x 8x 1x     7x     8x                
// @flow strict
import React, { useMemo } from 'react';
import cx from 'classnames';
 
import type { Node } from 'react';
 
type Props = {
  children: Node,
  className?: string,
  name?: string,
  reversed?: boolean,
};
 
const DialogActions = ({
  name,
  reversed = false,
  className,
  children,
  ...rest
}: Props) => {
  const childrenA = useMemo(() => {
    if (reversed) {
      return React.Children.toArray(children).reverse();
    }
 
    return children;
  }, [children, reversed]);
 
  return (
    <footer {...rest} className={cx('mdc-dialog__actions', className)}>
      {childrenA}
    </footer>
  );
};
 
export default DialogActions;