<commit_before>import { li, ul } from '@cycle/dom';
import { keys, map } from 'ramda';
import xs from 'xstream';
import { IDOMOnlySinks } from '../interfaces/sinks';
import { ISources } from '../interfaces/sources';
import { RequestMessageTypes } from '../protocol/request-messages/types';

export default function MessageSelector(sources: ISources): IDOMOnlySinks  {

  const toListItem = (type: string) => li(type);
  const arrayToList = map(toListItem);
  const requestMessageTypeNames = keys(RequestMessageTypes);
  const requestMessageList = arrayToList(requestMessageTypeNames);

  const html = xs.of(ul('.h-50 .w-100 .pa2. .mt2 .mb2 .MessageSelector', 'message selector', requestMessageList));

  return {
    DOM: html,
  };
}<commit_msg>selectable list of events<commit_after>import { DOMSource, li, ul, VNode } from '@cycle/dom';
import { keys, map } from 'ramda';
import xs, { Stream } from 'xstream';
import { IDOMOnlySinks } from '../interfaces/sinks';
import { ISources } from '../interfaces/sources';
import { RequestMessageTypes } from '../protocol/request-messages/types';

function intent(domSource: DOMSource): Stream<string> {
  return domSource.select('.MessageSelector-item').events('click')
    .map((e) => {
      const el = e.srcElement;
      console.log('el', el);
      if (!el) {
        return '';
      }
      return el.getAttribute('data-type') || '';
    })
    .debug((e) => console.log('clicked', e));
}

function view(): Stream<VNode> {
  const toListItem = (type: string) => li('.MessageSelector-item', { attrs: { 'data-type': type } }, type);
  const arrayToList = map(toListItem);
  const requestMessageTypeNames = keys(RequestMessageTypes);
  const requestMessageList = arrayToList(requestMessageTypeNames);

  return xs.of(ul('.h-50 .w-100 .pa2. .mt2 .mb2 .MessageSelector', 'message selector', requestMessageList));
}

export default function MessageSelector(sources: ISources): IDOMOnlySinks  {
  const actions$ = intent(sources.DOM);

  // TODO: remove this once we do something useful with click.
  actions$.addListener({ next: (e) => console.log('actions', e) });

  const html$ = view();
  return {
    DOM: html$,
  };
}
{'fraction_non_alphanumeric': 0.1558321807284463, 'fraction_numerical': 0.007376671277086215, 'mean_word_length': 4.241545893719807, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '1346588', 'n_tokens_mistral': 673, 'n_tokens_neox': 655, 'n_words': 173}