<commit_before>import { h } from '@cycle/dom'
import { html } from 'snabbdom-jsx'
import classes from 'classnames'

require('./style.css')

const getToolTip = (tooltip, toggleCondition) => !toggleCondition ? {'data-tooltip': tooltip} : undefined

export default function Menu (options) {
  const defaults = {
    toggled: false,
    disabled: false,

    icon: '',
    klass: '',
    wrapperKlass: '',
    arrow: true,

    contentPosition: 'right',
    subItems: false,

    tooltip: '',
    tooltipPos: 'bottom',

    content: undefined
  }
  const {toggled, disabled, icon, klass, wrapperKlass, arrow, contentPosition, subItems, tooltip, tooltipPos, content} = Object.assign({}, defaults, options)

  const subItemsIndicator = subItems ? <span className='subItemsIndicator' /> : ''
  // arrow related
  const borderNotch = arrow ? <b className='border-notch notch' /> : ''
  const notch = arrow ? <b className='notch' /> : ''

  const button = h('button', {
    props: {
      disabled: disabled,
      className: classes(klass, `tooltip-${tooltipPos}`, {active: toggled})
    },
    attrs: getToolTip(tooltip, toggled)
  },
    [
      h('span', {props: {innerHTML: icon}}),
      subItemsIndicator
    ])

  let innerContent = ''
  if (content !== undefined && toggled) {
    innerContent = <div
      className={classes('menu', `menu-${contentPosition}`, {'active-content': toggled, arrowOffset: arrow})}>
      {content}
      {borderNotch}
      {notch}
    </div>
  }

  const rootClassNames = classes('toolTipButtonContainer', wrapperKlass, {disabled})
  return <span className={rootClassNames}>
    {button}
    {innerContent}
  </span>
}<commit_msg>refactor(Menu): internal cleanup of Menu widget<commit_after>import {b, div, span, button} from '@cycle/dom'
import classes from 'classnames'

require('./style.css')

const getToolTip = (tooltip, toggleCondition) => !toggleCondition ? {'data-tooltip': tooltip} : undefined

export default function Menu (options) {
  const defaults = {
    toggled: false,
    disabled: false,

    icon: undefined,
    klass: '',
    wrapperKlass: '',
    arrow: true,

    contentPosition: 'right',
    subItems: false,

    tooltip: '',
    tooltipPos: 'bottom',

    content: undefined
  }
  const {toggled, disabled, icon, klass, wrapperKlass, arrow,
    contentPosition, subItems, tooltip, tooltipPos, content} = {...defaults, ...options}

  const subItemsIndicator = subItems ? span('.subItemsIndicator') : undefined
  // arrow related
  const borderNotch = arrow ? b('.border-notch notch') : undefined
  const notch = arrow ? b('.notch') : ''

  const togglerButton = button({
    props: {
      disabled: disabled,
      className: classes(klass, `tooltip-${tooltipPos}`, {active: toggled})
    },
    attrs: getToolTip(tooltip, toggled)
  },
    [
      icon ? span({props: {innerHTML: icon}}) : 'some text',
      subItemsIndicator
    ]
  )

  let innerContent = ''
  if (content !== undefined && toggled) {
    const contentClassNames = classes('menu', `menu-${contentPosition}`, {'active-content': toggled, arrowOffset: arrow})
    innerContent = div({props: {className: contentClassNames}}, [
      content,
      borderNotch,
      notch
    ])
  }

  const rootClassNames = classes(wrapperKlass, 'toolTipButtonContainer', {disabled})
  return span({props: {className: rootClassNames}}, [
    togglerButton,
    innerContent
  ])
}
{'fraction_non_alphanumeric': 0.14450014744913006, 'fraction_numerical': 0.0, 'mean_word_length': 3.608695652173913, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, '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': '4598904', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1017, 'n_words': 262}