<commit_before>/**
  * Modal.jsx
  * Created by <NAME> 03/24/17
  */

import React from 'react';
import PropTypes from 'prop-types';
import Modal from 'react-aria-modal';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

const propTypes = {
    onConfirm: PropTypes.func,
    onCancel: PropTypes.func,
    content: PropTypes.node,
    isOpen: PropTypes.bool,
    cancel: PropTypes.bool,
    confirmText: PropTypes.string
};

const defaultProps = {
    onConfirm: () => {},
    onCancel: () => {},
    content: null,
    isOpen: false,
    cancel: false,
    confirmText: 'Ok'
};

export default class ErrorModal extends React.Component {
    constructor(props) {
        super(props);

        this.cancel = this.cancel.bind(this);
        this.confirm = this.confirm.bind(this);
    }

    cancel(e) {
        return typeof this.props.onCancel === 'function' ? this.props.onCancel(e) : null;
    }

    confirm(e) {
        return typeof this.props.onConfirm === 'function' ? this.props.onConfirm(e) : null;
    }

    render() {
        return (
            <Modal
                mounted={this.props.isOpen}
                onExit={this.cancel}
                underlayClickExits
                verticallyCenter
                initialFocus="#usa-da-shared-confirm-button"
                titleId="usa-da-modal">
                <div className="usa-da-modal-page">
                    <div id="usa-da-modal" className="usa-da-shared-modal">
                        {this.props.cancel ?
                            <button<commit_msg>Setting initialfocus to close button if provided<commit_after>/**
  * Modal.jsx
  * Created by <NAME> 03/24/17
  */

import React from 'react';
import PropTypes from 'prop-types';
import Modal from 'react-aria-modal';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

const propTypes = {
    onConfirm: PropTypes.func,
    onCancel: PropTypes.func,
    content: PropTypes.node,
    isOpen: PropTypes.bool,
    cancel: PropTypes.bool,
    confirmText: PropTypes.string
};

const defaultProps = {
    onConfirm: () => {},
    onCancel: () => {},
    content: null,
    isOpen: false,
    cancel: false,
    confirmText: 'Ok'
};

export default class ErrorModal extends React.Component {
    constructor(props) {
        super(props);

        this.cancel = this.cancel.bind(this);
        this.confirm = this.confirm.bind(this);
    }

    cancel(e) {
        return typeof this.props.onCancel === 'function' ? this.props.onCancel(e) : null;
    }

    confirm(e) {
        return typeof this.props.onConfirm === 'function' ? this.props.onConfirm(e) : null;
    }

    render() {
        const initialFocus = this.cancel ? '#usa-da-shared-close-button' : 'usa-da-shared-confirm-button';
        return (
            <Modal
                mounted={this.props.isOpen}
                onExit={this.cancel}
                underlayClickExits
                verticallyCenter
                initialFocus={initialFocus}
                titleId="usa-da-modal">
                <div className="usa-da-modal-page">
                    <div id="usa-da-modal" className="usa-da-shared-modal">
                        {this.props.cancel ?
                            <button
{'fraction_non_alphanumeric': 0.1265078874110733, 'fraction_numerical': 0.0037117228580266005, 'mean_word_length': 2.0977011494252875, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6335719', 'n_tokens_mistral': 960, 'n_tokens_neox': 937, 'n_words': 190}