<commit_before>'use strict'

import init from './component/init'
import classify from './component/classify'
import css from './module/css'
import events from './component/events'
import insert from './component/insert'
import offset from './element/offset'

import create from './element/create'

import bind from './module/bind'
import merge from './module/merge'
import emitter from './module/emitter'

import List from './list'
import Item from './item'
import Divider from './divider'

const defaults = {
  prefix: 'material',
  class: 'menu',
  tag: 'div',
  modules: [emitter, events, bind, insert]
}

/**
 * This Class represents a menu.
 *
 * @return {parent} The class instance
 * @example new Container({
 *   container: document.body
 * });
 */
class Menu {
  /**
   * Constructor
   * @param  {Object} options - Component options
   * @return {Object} Class instance
   */
  constructor (options) {
    this.options = merge(defaults, options || {})

    init(this)
    this.build(this.options)
    this.setup()

    if (this.options.bind) {
      this.bind(this.options.bind)
    }

    this.emit('ready')

    return this
  }

  /**
   * Build Method
   * @return {Object} This class instance
   */
  build (options) {
    var tag = options.tag || 'div'
    this.wrapper = create(tag, options.css)

    classify(this.wrapper, options)

    if (options.container) {
      this.insert(options.container)
    }

    if (this.options.list) {
      this.list = new List({
        wrapper: this.wrapper,
        list: this.options.list,
        target: '.material-item',
        height: 600,
        label: 'Flat',
        render: (info) => {
          var item

          if (info.type === 'divider') {
            item = new Divider()
          } else {
            item = new Item({
              name: info.name,
              text: info.name
            })
          }

          return item
        },
        select: (item) => {
          this.selected = item
          this.hide()
        }
      })
    }

    this.emit('built', this.wrapper)

    return this
  }

  setup () {
    // this.subscribe('click', () => {
    //   console.log('click');
    //   this.close();
    // });
  }

  show (e) {
    css.add(this.wrapper, this.class + '-show')
    var offs = offset(e.target)

    var offsw = offset(this.wrapper)

    this.wrapper.style.top = offs.top + 'px'
    this.wrapper.style.left = offs.left - offsw.width + offs.width + 'px'
  }

  hide () {
    css.remove(this.wrapper, this.class + '-show')
  }
}

export default Menu<commit_msg>Remove item and divider imports<commit_after>'use strict'

import init from './component/init'
import classify from './component/classify'
import css from './module/css'
import events from './component/events'
import insert from './component/insert'
import offset from './element/offset'

import create from './element/create'

import bind from './module/bind'
import merge from './module/merge'
import emitter from './module/emitter'

import List from './list'

const defaults = {
  prefix: 'material',
  class: 'menu',
  tag: 'div',
  modules: [emitter, events, bind, insert]
}

/**
 * This Class represents a menu.
 *
 * @return {parent} The class instance
 * @example new Container({
 *   container: document.body
 * });
 */
class Menu {
  /**
   * Constructor
   * @param  {Object} options - Component options
   * @return {Object} Class instance
   */
  constructor (options) {
    this.options = merge(defaults, options || {})

    init(this)
    this.build(this.options)
    this.setup()

    if (this.options.bind) {
      this.bind(this.options.bind)
    }

    this.emit('ready')

    return this
  }

  /**
   * Build Method
   * @return {Object} This class instance
   */
  build (options) {
    var tag = options.tag || 'div'
    this.wrapper = create(tag, options.css)

    classify(this.wrapper, options)

    if (options.container) {
      this.insert(options.container)
    }

    if (this.options.list) {
      this.list = new List({
        wrapper: this.wrapper,
        list: this.options.list,
        target: '.material-item',
        height: 600,
        label: 'Flat',
        select: (item) => {
          this.selected = item
          this.hide()
        }
      })
    }

    this.emit('built', this.wrapper)

    return this
  }

  setup () {
    // this.subscribe('click', () => {
    //   console.log('click');
    //   this.close();
    // });
  }

  show (e) {
    console.log('show', e);
    css.add(this.wrapper, this.options.class + '-show')
    var offs = offset(e.target)

    var offsw = offset(this.wrapper)

    this.wrapper.style.top = offs.top + 'px'
    this.wrapper.style.left = offs.left - offsw.width + offs.width + 'px'
  }

  hide () {
    css.remove(this.wrapper, this.class + '-show')
  }
}

export default Menu
{'fraction_non_alphanumeric': 0.15025906735751296, 'fraction_numerical': 0.001243523316062176, 'mean_word_length': 2.2586090479405807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '6455789', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1487, 'n_words': 383}