<commit_before>import {
  Button, Col, ManagedTextInputField as Input,
  Row
} from '@tlon/indigo-react';
import { Form, Formik, FormikHelpers } from 'formik';
import React from 'react';
import * as Yup from 'yup';
import { AsyncButton } from '../../../components/AsyncButton';
import { MarkdownField } from './MarkdownField';

interface PostFormProps {
  initial: PostFormSchema;
  cancel?: boolean;
  history?: any;
  onSubmit: (
    values: PostFormSchema,
    actions: FormikHelpers<PostFormSchema>
  ) => Promise<any>;
  submitLabel: string;
  loadingText: string;
}

const formSchema = Yup.object({
  title: Yup.string().required('Title cannot be blank'),
  body: Yup.string().required('Post cannot be blank')
});

export interface PostFormSchema {
  title: string;
  body: string;
}

export function PostForm(props: PostFormProps) {
  const { initial, onSubmit, submitLabel, loadingText, cancel, history } = props;

  return (
    <Col width="100%" height="100%" p={[2, 4]}>
      <Formik
        validationSchema={formSchema}
        initialValues={initial}
        onSubmit={onSubmit}
        validateOnBlur
      >
        <Form style={{ display: 'contents' }}>
          <Row flexShrink={0} flexDirection={['column-reverse', 'row']} mb={4} gapX={4} justifyContent='space-between'>
            <Input maxWidth='40rem' width='100%' flexShrink={[0, 1]} placeholder="Post Title" id="title" />
              <Row flexDirection={['column', 'row']} mb={[4,0]}>
              <AsyncButton
                ml={[0,2]}
                flexShrink={0}
                primary
                loadingText={loadingText}
              >
                {submitLabel}
              </AsyncButton><commit_msg>NoteForm: do not validate on blur<commit_after>import {
  Button, Col, ManagedTextInputField as Input,
  Row
} from '@tlon/indigo-react';
import { Form, Formik, FormikHelpers } from 'formik';
import React from 'react';
import * as Yup from 'yup';
import { AsyncButton } from '../../../components/AsyncButton';
import { MarkdownField } from './MarkdownField';

interface PostFormProps {
  initial: PostFormSchema;
  cancel?: boolean;
  history?: any;
  onSubmit: (
    values: PostFormSchema,
    actions: FormikHelpers<PostFormSchema>
  ) => Promise<any>;
  submitLabel: string;
  loadingText: string;
}

const formSchema = Yup.object({
  title: Yup.string().required('Title cannot be blank'),
  body: Yup.string().required('Post cannot be blank')
});

export interface PostFormSchema {
  title: string;
  body: string;
}

export function PostForm(props: PostFormProps) {
  const { initial, onSubmit, submitLabel, loadingText, cancel, history } = props;

  return (
    <Col width="100%" height="100%" p={[2, 4]}>
      <Formik
        validationSchema={formSchema}
        initialValues={initial}
        onSubmit={onSubmit}
      >
        <Form style={{ display: 'contents' }}>
          <Row flexShrink={0} flexDirection={['column-reverse', 'row']} mb={4} gapX={4} justifyContent='space-between'>
            <Input maxWidth='40rem' width='100%' flexShrink={[0, 1]} placeholder="Post Title" id="title" />
              <Row flexDirection={['column', 'row']} mb={[4,0]}>
              <AsyncButton
                ml={[0,2]}
                flexShrink={0}
                primary
                loadingText={loadingText}
              >
                {submitLabel}
              </AsyncButton>
{'fraction_non_alphanumeric': 0.1443693031461335, 'fraction_numerical': 0.013525433695971773, 'mean_word_length': 2.9789473684210526, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '6718643', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1008, 'n_words': 253}