<commit_before>import * as React from 'react';
import classNames from 'classnames';
import omit from 'omit.js';
import { Omit } from '../_util/type';
import { IconProps } from './index';

export interface CustomIconProps extends Omit<IconProps, 'type'> {
  viewBox?: string;
  component?: React.ComponentType<CustomIconComponentProps>;
}

export interface CustomIconComponentProps extends Omit<CustomIconProps, 'component'> {
}

const CustomIcon: React.SFC<CustomIconProps> = (props) => {
  const {
    className = '',
    spin,
    viewBox = '0 0 24 24',
    children,
    component: Component,
  } = props;

  const classString = classNames({
    anticon: true,
    'anticon-spin': !!spin,
  }, className);

  let content = (
    <svg
      {...omit(props, ['type', 'spin'])}
      width={'1em'}
      height={'1em'}
      fill={'currentColor'}
      aria-hidden={'true'}
      viewBox={viewBox}
    >
      {children}
    </svg>
  );

  if (Component) {
    content = (
      <Component
        {...omit(props, ['type', 'spin', 'component'])}
        width={'1em'}
        height={'1em'}
        fill={'currentColor'}
        aria-hidden={'true'}
        viewBox={viewBox}
      >
        {children}
      </Component>
    );
  }

  return (
    <i className={classString}>
      {content}
    </i>
  );
};

const customCache = new Set<string>();

export interface CustomIconOptions {
  namespace?: string;
  prefix?: string;
  scriptLink?: string;
  [key: string]: any;
}

export function create(options: CustomIconOptions = {}): React.ComponentClass<IconProps> {
  const { namespace, prefix = '', scriptLink, ...extraCommonProps } = options;

  class Custom extends React.Component<IconProps> {
    render() {
      const { type, className = '', spin } = this.props;
      const classString = classNames({
        anticon: true,
        'anticon-spin': !!spin || type === 'loading',
      }, className);
      return (
        <i className={classString}>
          <svg
            {...extraCommonProps}
            {...omit(this.props, ['type', 'spin', 'viewBox'])}
            width={'1em'}
            height={'1em'}
            fill={'currentColor'}
            aria-hidden={'true'}
          >
            <use xlinkHref={`#${prefix}${type}`} />
          </svg>
        </i>
      );
    }

    componentDidMount() {
      /**
       * DOM API required.
       * The Custom Icon will create a <script/>
       * that loads SVG symbols and insert the SVG Element into the document body.
       */
      if (document && window
        && typeof scriptLink === 'string' && scriptLink.length<commit_msg>hotfix: svg should receive viewBox prop.<commit_after>import * as React from 'react';
import classNames from 'classnames';
import omit from 'omit.js';
import { Omit } from '../_util/type';
import { IconProps } from './index';

export interface CustomIconProps extends Omit<IconProps, 'type'> {
  viewBox?: string;
  component?: React.ComponentType<CustomIconComponentProps>;
}

export interface CustomIconComponentProps extends Omit<CustomIconProps, 'component'> {
}

const CustomIcon: React.SFC<CustomIconProps> = (props) => {
  const {
    className = '',
    spin,
    viewBox = '0 0 24 24',
    children,
    component: Component,
  } = props;

  const classString = classNames({
    anticon: true,
    'anticon-spin': !!spin,
  }, className);

  let content = (
    <svg
      {...omit(props, ['type', 'spin'])}
      width={'1em'}
      height={'1em'}
      fill={'currentColor'}
      aria-hidden={'true'}
      viewBox={viewBox}
    >
      {children}
    </svg>
  );

  if (Component) {
    content = (
      <Component
        {...omit(props, ['type', 'spin', 'component'])}
        width={'1em'}
        height={'1em'}
        fill={'currentColor'}
        aria-hidden={'true'}
        viewBox={viewBox}
      >
        {children}
      </Component>
    );
  }

  return (
    <i className={classString}>
      {content}
    </i>
  );
};

const customCache = new Set<string>();

export interface CustomIconOptions {
  namespace?: string;
  prefix?: string;
  scriptLink?: string;
  [key: string]: any;
}

export function create(options: CustomIconOptions = {}): React.ComponentClass<IconProps> {
  const { namespace, prefix = '', scriptLink, ...extraCommonProps } = options;

  class Custom extends React.Component<IconProps> {
    render() {
      const { type, className = '', spin } = this.props;
      const classString = classNames({
        anticon: true,
        'anticon-spin': !!spin || type === 'loading',
      }, className);
      return (
        <i className={classString}>
          <svg
            {...extraCommonProps}
            {...omit(this.props, ['type', 'spin'])}
            width={'1em'}
            height={'1em'}
            fill={'currentColor'}
            aria-hidden={'true'}
          >
            <use xlinkHref={`#${prefix}${type}`} />
          </svg>
        </i>
      );
    }

    componentDidMount() {
      /**
       * DOM API required.
       * The Custom Icon will create a <script/>
       * that loads SVG symbols and insert the SVG Element into the document body.
       */
      if (document && window
        && typeof scriptLink === 'string' && scriptLink.length
{'fraction_non_alphanumeric': 0.15603514132925897, 'fraction_numerical': 0.004583651642475172, 'mean_word_length': 2.4095052083333335, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 43, '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': '5424594', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1547, 'n_words': 381}