<commit_before>import React from 'react';
import { storiesOf } from '@storybook/react';
import {
  text,
  select,
  boolean,
  number
} from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
import { State, Store } from '@sambego/storybook-state';
import ImmutableHelper from '../../utils/helpers/immutable';
import OptionsHelper from '../../utils/helpers/options-helper';
import notes from './notes.md';
import DropdownFilterAjax from './dropdown-filter-ajax';

const store = new Store({
  value: ''
});

const create = (evt, component) => component.state.filter;

// Shared Props
const onChange = (evt) => {
  store.set({ value: evt.target.value });
  action('change')(evt);
};
const autoFocus = boolean('autoFocus', false);
const cacheVisibleValue = boolean('cacheVisibleValue', true);
const disabled = boolean('disabled', false);
const name = text('name', 'Name');
const readOnly = boolean('readOnly', false);
const timeToDisappear = number('timeToDisappear', 0);
const label = text('label', 'Dropdown Label');
const labelInline = boolean('labelInline', true);
const labelWidth = labelInline ? text('labelWidth', '') : null;
const labelAlign = labelInline ? select('labelAlign', OptionsHelper.alignBinary) : null;
const labelHelp = text('labelHelp', 'This is help text');
const inputWidth = text('inputWidth', '');
const fieldHelp = text('fieldHelp', 'This is field help text');
const fieldHelpInline = boolean('fieldHelpInline', false);
const createText = text('createText', '');
const createIconType = text('createIconType', '');
const suggest = boolean('suggest', false);
const freetext = boolean('freetext', false);
const path = text('path', '/');
const acceptHeader = text('acceptHeader', DropdownFilterAjax.defaultProps.acceptHeader);
const rowsPerRequest = number('rowsPerRequest', DropdownFilterAjax.defaultProps.rowsPerRequest);
const dataRequestTimeout = number(
  'dataRequestTimeout',
  DropdownFilterAjax.defaultProps.dataRequestTimeout
);
const withCredentials = boolean('withCredentials', false);
const options = ImmutableHelper.parseJSON([
  {
    id: 1, name: 'Orange'
  }, {
    id: 2, name: 'Blue'
  }
]);

storiesOf('DropdownFilterAjax', module)
  .addParameters({
    info: {
      propTablesExclude: [State]
    }
  })
  .add('default', () => {
    return (
      <State store={ store }>
        <DropdownFilterAjax
          autoFocus={ autoFocus }
          cacheVisibleValue={ cacheVisibleValue }
          disabled={ disabled }
          name={ name }
          readOnly={ readOnly }
          timeToDisappear={ timeToDisappear }
          label={ label }
          labelInline={ labelInline }
          labelWidth={ labelWidth }
          labelAlign={ labelAlign }
          labelHelp={ labelHelp }
          inputWidth={ inputWidth }
          fieldHelp={ fieldHelp }
          fieldHelpInline={ fieldHelpInline }
          createText={ createText }
          createIconType={ createIconType }
          suggest={ suggest }
          freetext={ freetext }
          path={ path }
          acceptHeader={ acceptHeader }
          rowsPerRequest={ rowsPerRequest }
          getCustomHeaders={ () => true }
          dataRequestTimeout={ dataRequestTimeout }
          withCredentials={ withCredentials }
          options={ options }
          onChange={ onChange }
          value={ store.get('value') }
        />
      </State>
    );
  }, {
    notes: { markdown: notes }
  })
  .add('withCreate', () => {
    return (
      <State store={ store }>
        <DropdownFilterAjax
          autoFocus={ autoFocus }
          cacheVisibleValue={ cacheVisibleValue }
          disabled={ disabled }
          name={ name }
          readOnly={ readOnly }
          timeToDisappear={ timeToDisappear }
          label={ label }
          labelInline={ labelInline }
          labelWidth={ labelWidth }
          labelAlign={ labelAlign }
          labelHelp={ labelHelp }
          inputWidth={ inputWidth }
          fieldHelp={ fieldHelp }
          fieldHelpInline={ fieldHelpInline }
          createText={ createText }
          createIconType={ createIconType }
          suggest={ suggest }
          freetext={ freetext }
          create={ create }
          path={ path }
          acceptHeader={ acceptHeader }
          rowsPerRequest={ rowsPerRequest }
          getCustomHeaders={ () => true }
          dataRequestTimeout={ dataRequestTimeout }
          withCredentials={ withCredentials }
          options={ options }
          onChange={ onChange }
          value={ store.get('value') }
        />
      </State>
    );
  }, {
    notes: { markdown: notes }
  });
<commit_msg>Updates Dropdown Filter Ajax Story with Mock Ajax<commit_after>import React from 'react';
import { storiesOf } from '@storybook/react';
import {
  text,
  select,
  boolean,
  number
} from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
import { State, Store } from '@sambego/storybook-state';
import ImmutableHelper from '../../utils/helpers/immutable';
import OptionsHelper from '../../utils/helpers/options-helper';
import notes from './notes.md';
import DropdownFilterAjax from './dropdown-filter-ajax';
import { enableMock } from '../../../demo/xhr-mock';

const store = new Store({
  value: '',
  visibleValue: ''
});

enableMock();
const create = (evt, component) => component.state.filter;

// Shared Props
const onChange = (evt) => {
  store.set({ 
    visibleValue: evt.target.visibleValue,
    value: evt.target.visibleValue
  });
  action('change')(evt);
};
const autoFocus = boolean('autoFocus', false);
const cacheVisibleValue = boolean('cacheVisibleValue', false);
const disabled = boolean('disabled', false);
const name = text('name', 'Name');
const readOnly = boolean('readOnly', false);
const timeToDisappear = number('timeToDisappear', 0);
const label = text('label', 'Dropdown Label');
const labelInline = boolean('labelInline', true);
const labelWidth = labelInline ? text('labelWidth', '') : null;
const labelAlign = labelInline ? select('labelAlign', OptionsHelper.alignBinary) : null;
const labelHelp = text('labelHelp', 'This is help text');
const inputWidth = text('inputWidth', '');
const fieldHelp = text('fieldHelp', 'This is field help text');
const fieldHelpInline = boolean('fieldHelpInline', false);
const createText = text('createText', '');
const createIconType = text('createIconType', '');
const suggest = boolean('suggest', false);
const freetext = boolean('freetext', false);
const path = text('path', '/countries');
const acceptHeader = text('acceptHeader', DropdownFilterAjax.defaultProps.acceptHeader);
const rowsPerRequest = number('rowsPerRequest', DropdownFilterAjax.defaultProps.rowsPerRequest);
const dataRequestTimeout = number(
  'dataRequestTimeout',
  DropdownFilterAjax.defaultProps.dataRequestTimeout
);
const withCredentials = boolean('withCredentials', false);
const options = ImmutableHelper.parseJSON([
  {
    id: 1, name: 'Orange'
  }, {
    id: 2, name: 'Blue'
  }
]);

storiesOf('DropdownFilterAjax', module)
  .addParameters({
    info: {
      propTablesExclude: [State]
    }
  })
  .add('default', () => {
    return (
      <State store={ store }>
        <DropdownFilterAjax
          autoFocus={ autoFocus }
          cacheVisibleValue={ cacheVisibleValue }
          disabled={ disabled }
          name={ name }
          readOnly={ readOnly }
          timeToDisappear={ timeToDisappear }
          label={ label }
          labelInline={ labelInline }
          labelWidth={ labelWidth }
          labelAlign={ labelAlign }
          labelHelp={ labelHelp }
          inputWidth={ inputWidth }
          fieldHelp={ fieldHelp }
          fieldHelpInline={ fieldHelpInline }
          createText={ createText }
          createIconType={ createIconType }
          suggest={ suggest }
          freetext={ freetext }
          path={ path }
          acceptHeader={ acceptHeader }
          rowsPerRequest={ rowsPerRequest }
          getCustomHeaders={ () => ({}) }
          dataRequestTimeout={ dataRequestTimeout }
          withCredentials={ withCredentials }
          options={ options }
          onChange={ onChange }
        />
      </State>
    );
  }, {
    notes: { markdown: notes }
  })
  .add('withCreate', () => {
    return (
      <State store={ store }>
        <DropdownFilterAjax
          autoFocus={ autoFocus }
          cacheVisibleValue={ cacheVisibleValue }
          disabled={ disabled }
          name={ name }
          readOnly={ readOnly }
          timeToDisappear={ timeToDisappear }
          label={ label }
          labelInline={ labelInline }
          labelWidth={ labelWidth }
          labelAlign={ labelAlign }
          labelHelp={ labelHelp }
          inputWidth={ inputWidth }
          fieldHelp={ fieldHelp }
          fieldHelpInline={ fieldHelpInline }
          createText={ createText }
          createIconType={ createIconType }
          suggest={ suggest }
          freetext={ freetext }
          create={ create }
          path={ path }
          acceptHeader={ acceptHeader }
          rowsPerRequest={ rowsPerRequest }
          getCustomHeaders={ () => ({}) }
          dataRequestTimeout={ dataRequestTimeout }
          withCredentials={ withCredentials }
          options={ options }
          onChange={ onChange }
        />
      </State>
    );
  }, {
    notes: { markdown: notes }
  });

{'fraction_non_alphanumeric': 0.12943300063707794, 'fraction_numerical': 0.0006370779358674878, 'mean_word_length': 2.8905410987195372, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, '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': '375582', 'n_tokens_mistral': 2504, 'n_tokens_neox': 2560, 'n_words': 622}