<commit_before>import React from "react";
import PropTypes from "prop-types";

import { types, AVAILABLE_TYPES } from "../types";

import {
  Content,
  DismissButton,
  InteractionsWrapper,
  Message,
  Notification,
  Wrapper
} from "./presenters";
import IconBackground from "../presenters/IconBackground";

/**
 * @typedef {Object} BannerPresenterProps
 * @property {string} [type]
 * @property {any} [actions]
 * @property {string} [dismissButtonTitle]
 * @property {Function} [onDismiss]
 * @property {boolean} [isWrappingContent]
 * @property {function(HTMLDivElement): any} [refContent]
 * @property {function(HTMLParagraphElement): any} [refNotification]
 * @property {function(HTMLDivElement): any} [refInteractionsWrapper]
 * @property {any} [children]
 */

/**
 * @param {BannerPresenterProps} props
 * @returns {JSX.Element}
 * @type {Component<BannerPresenterProps>}
 */
export default function BannerPresenter(props) {
  const {
    type,
    actions,
    dismissButtonTitle,
    onDismiss,
    isWrappingContent,
    refContent,
    refNotification,
    refInteractionsWrapper,
    children: message
  } = props;

  const hasActions = React.Children.count(actions) > 0;

  return (
    <Wrapper
      type={type}
      hasActions={hasActions}
      isWrappingContent={isWrappingContent}
    >
      <IconBackground type={type} />
      <Content isWrappingContent innerRef={refContent}>
        <Notification innerRef={refNotification}>
          <Message>{message}</Message>
        </Notification>
        {hasActions ? (
          <InteractionsWrapper innerRef={refInteractionsWrapper}>
            {actions}
          </InteractionsWrapper>
        ) : null}
      </Content>
      <DismissButton title={dismissButtonTitle} onClick={onDismiss} />
    </Wrapper>
  );
}

/** @type {BannerPresenterProps} */
BannerPresenter.defaultProps = {
  type: types.PRIMARY,
  dismissButtonTitle: "Dismiss",
  isWrappingContent: false,
  children: "Message"
};

BannerPresenter.propTypes = {
  /** Indicates the style of banner */<commit_msg>feat: dismiss button when there is no onDismiss function passed<commit_after>import React from "react";
import PropTypes from "prop-types";

import { types, AVAILABLE_TYPES } from "../types";

import {
  Content,
  DismissButton,
  InteractionsWrapper,
  Message,
  Notification,
  Wrapper
} from "./presenters";
import IconBackground from "../presenters/IconBackground";

/**
 * @typedef {Object} BannerPresenterProps
 * @property {string} [type]
 * @property {any} [actions]
 * @property {string} [dismissButtonTitle]
 * @property {Function} [onDismiss]
 * @property {boolean} [isWrappingContent]
 * @property {function(HTMLDivElement): any} [refContent]
 * @property {function(HTMLParagraphElement): any} [refNotification]
 * @property {function(HTMLDivElement): any} [refInteractionsWrapper]
 * @property {any} [children]
 */

/**
 * @param {BannerPresenterProps} props
 * @returns {JSX.Element}
 * @type {Component<BannerPresenterProps>}
 */
export default function BannerPresenter(props) {
  const {
    type,
    actions,
    dismissButtonTitle,
    onDismiss,
    isWrappingContent,
    refContent,
    refNotification,
    refInteractionsWrapper,
    children: message
  } = props;

  const hasActions = React.Children.count(actions) > 0;

  return (
    <Wrapper
      type={type}
      hasActions={hasActions}
      isWrappingContent={isWrappingContent}
    >
      <IconBackground type={type} />
      <Content isWrappingContent innerRef={refContent}>
        <Notification innerRef={refNotification}>
          <Message>{message}</Message>
        </Notification>
        {hasActions ? (
          <InteractionsWrapper innerRef={refInteractionsWrapper}>
            {actions}
          </InteractionsWrapper>
        ) : null}
      </Content>
      {
        onDismiss ? <DismissButton title={dismissButtonTitle} onClick={onDismiss} /> : null
      }
    </Wrapper>
  );
}

/** @type {BannerPresenterProps} */
BannerPresenter.defaultProps = {
  type: types.PRIMARY,
  dismissButtonTitle: "Dismiss",
  isWrappingContent: false,
  children: "Message"
};

BannerPresenter.propTypes = {
  /** Indicates the style of banner */
{'fraction_non_alphanumeric': 0.12455175711212049, 'fraction_numerical': 0.0004781257470714798, 'mean_word_length': 3.776255707762557, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4328802', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1232, 'n_words': 267}