<commit_before>import React, { Children } from 'react';
import classnames from 'classnames';
import { connectField, filterDOMProps, joinName } from 'uniforms';

import ListItemField from './ListItemField';
import ListAddField from './ListAddField';

const List = ({
  children,
  className,
  disabled,
  error,
  errorMessage,
  initialCount,
  itemProps,
  label,
  name,
  required,
  showInlineError,
  value,
  ...props
}) => {
  const listAddFieldProps = {
    name: `${name}.$`,
    initialCount,
    className: 'right floated',
  };
  return (
    <div
      className={classnames(
        'ui',
        className,
        { disabled },
        'grouped fitted fields list',
      )}
      {...filterDOMProps(props)}
    >
      {label && (
        <div className={classnames({ error, required }, 'field item')}>
          <label className="left floated">{label}</label>

          <ListAddField {...listAddFieldProps} />
        </div>
      )}

      {label && (
        <div className="ui fitted hidden clearing horizontal divider" />
      )}

      {!!(error && showInlineError) && (
        <div className="ui red basic label">{errorMessage}</div>
      )}

      {children
        ? value.map((item, index) =>
            Children.map(children, child =>
              React.cloneElement(child, {
                key: index,
                label: null,
                name: joinName(
                  name,
                  child.props.name && child.props.name.replace('$', index),
                ),
              }),
            ),
          )
        : value.map((item, index) => (
            <ListItemField
              key={index}
              label={null}
              name={joinName(name, index)}
              {...itemProps}
            />
          ))}
    </div>
  );
};

export default connectField(List, { includeInChain: false });<commit_msg>Added ListField types in uniforms-semantic.<commit_after>import React, { Children, HTMLProps, ReactNode } from 'react';
import classnames from 'classnames';
import { connectField, filterDOMProps, joinName } from 'uniforms';

import ListItemField from './ListItemField';
import ListAddField from './ListAddField';

type ListFieldProps<T> = {
  children?: ReactNode;
  name: string;
  error?: boolean;
  errorMessage?: string;
  initialCount?: number;
  value: T[];
  itemProps?: {};
  showInlineError?: boolean;
} & Omit<HTMLProps<HTMLUListElement>, 'children' | 'name'>;

function List<T>({
  children,
  className,
  disabled,
  error,
  errorMessage,
  initialCount,
  itemProps,
  label,
  name,
  required,
  showInlineError,
  value,
  ...props
}: ListFieldProps<T>) {
  const listAddFieldProps = {
    name: `${name}.$`,
    initialCount,
    className: 'right floated',
  };
  return (
    <ul
      className={classnames(
        'ui',
        className,
        { disabled },
        'grouped fitted fields list',
      )}
      {...filterDOMProps(props)}
    >
      {label && (
        <div className={classnames({ error, required }, 'field item')}>
          <label className="left floated">{label}</label>

          <ListAddField {...listAddFieldProps} />
        </div>
      )}

      {label && (
        <div className="ui fitted hidden clearing horizontal divider" />
      )}

      {!!(error && showInlineError) && (
        <div className="ui red basic label">{errorMessage}</div>
      )}

      {children
        ? value.map((item, index) =>
            Children.map(children as JSX.Element, child =>
              React.cloneElement(child, {
                key: index,
                label: null,
                name: joinName(
                  name,
                  child.props.name && child.props.name.replace('$', index),
                ),
              }),
            ),
          )
        : value.map((item, index) => (
            <ListItemField
              key={index}
              label={undefined}
              name={joinName(name, index)}
              {...itemProps}
            />
          ))}
    </ul>
  );
}

export default connectField<ListFieldProps<any>>(List, {
  includeInChain: false,
});
{'fraction_non_alphanumeric': 0.14015518913676042, 'fraction_numerical': 0.0, 'mean_word_length': 1.9485346676197284, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 39, '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': '1877475', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1159, 'n_words': 259}