<commit_before>import { ElementType, forwardRef, ReactElement } from 'react';
import { classnames } from '../../helpers';
import Button from '../button/Button';
import DropdownCaret from './DropdownCaret';
import { Box, PolymorphicComponentProps } from '../../helpers/react-polymorphic-box';
import { CircleLoader } from '../loader';

export interface OwnProps {
    loading?: boolean;
    caretClassName?: string;
    hasCaret?: boolean;
    isOpen?: boolean;
}

export type DropdownButtonProps<E extends ElementType> = PolymorphicComponentProps<E, OwnProps>;

const defaultElement = Button;

export const DropdownButton: <E extends ElementType = typeof defaultElement>(
    props: DropdownButtonProps<E>
) => ReactElement | null = forwardRef(
    <E extends ElementType = typeof defaultElement>(
        {
            children,
            className,
            hasCaret = false,
            isOpen = false,
            caretClassName = '',
            loading = false,
            disabled,
            ...rest
        }: DropdownButtonProps<E>,
        ref: typeof rest.ref
    ) => {
        return (
            <Box
                as={defaultElement}
                ref={ref}
                aria-expanded={isOpen}
                aria-busy={loading}
                disabled={loading ? true : disabled}
                data-testid="dropdown-button"
                className={classnames([children && hasCaret && 'flex flex-align-items-center flex-nowrap', className])}
                {...rest}
            >
                {children}
                {loading && (
                    <span className="button-loader-container">
                        <CircleLoader />
                    </span>
                )}
                {hasCaret && (
                    <DropdownCaret
                        className={classnames(['flex-item-noshrink', children ? 'ml0-5' : '', caretClassName])}
                        isOpen={isOpen}
                    />
                )}
            </Box>
        );
    }
);

export default DropdownButton;<commit_msg>Fix DropdownButton react/display-name eslint warning<commit_after>import { ElementType, forwardRef, ReactElement } from 'react';
import { classnames } from '../../helpers';
import Button from '../button/Button';
import DropdownCaret from './DropdownCaret';
import { Box, PolymorphicComponentProps } from '../../helpers/react-polymorphic-box';
import { CircleLoader } from '../loader';

export interface OwnProps {
    loading?: boolean;
    caretClassName?: string;
    hasCaret?: boolean;
    isOpen?: boolean;
}

export type DropdownButtonProps<E extends ElementType> = PolymorphicComponentProps<E, OwnProps>;

const defaultElement = Button;

const DropdownButtonBase = <E extends ElementType = typeof defaultElement>(
    {
        children,
        className,
        hasCaret = false,
        isOpen = false,
        caretClassName = '',
        loading = false,
        disabled,
        ...rest
    }: DropdownButtonProps<E>,
    ref: typeof rest.ref
) => {
    return (
        <Box
            as={defaultElement}
            ref={ref}
            aria-expanded={isOpen}
            aria-busy={loading}
            disabled={loading ? true : disabled}
            data-testid="dropdown-button"
            className={classnames([children && hasCaret && 'flex flex-align-items-center flex-nowrap', className])}
            {...rest}
        >
            {children}
            {loading && (
                <span className="button-loader-container">
                    <CircleLoader />
                </span>
            )}
            {hasCaret && (
                <DropdownCaret
                    className={classnames(['flex-item-noshrink', children ? 'ml0-5' : '', caretClassName])}
                    isOpen={isOpen}
                />
            )}
        </Box>
    );
};

export const DropdownButton: <E extends ElementType = typeof defaultElement>(
    props: DropdownButtonProps<E>
) => ReactElement | null = forwardRef(DropdownButtonBase);

export default DropdownButton;
{'fraction_non_alphanumeric': 0.11747358073236668, 'fraction_numerical': 0.0009830425165888424, 'mean_word_length': 1.8824362606232294, 'pattern_counts': {'":': 0, '<': 27, '<?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': '4261882', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1023, 'n_words': 235}