<commit_before>import { mdiAlert } from '@mdi/js'
import './icons.css'

const { h: v3h } = require('vue') // import vue3's render function
const isV2 = v3h === undefined

const versionDependentOpts = isV2
  ? { functional: true } // for v2.x
  : {} // for v3.x

const ucFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
const toName = (str) => str.split('-').map(ucFirst).join('')

const renderWithIcons = mdi => function render(v2h, v2ctx) {
  const data = isV2 ? v2ctx.data : this
  const props = isV2 ? v2ctx.props : this
  const attrs = isV2 ? v2ctx.attrs : this.$attrs
  const h = isV2 ? v2h : v3h
  const iconPath = mdi[`mdi${toName(props.name)}`] || mdiAlert

  const spanAttrs = {
    role: props.role,
    'aria-label': props.ariaLabel,
    ...attrs
  }
  const svgAttrs = {
    fill: 'currentColor',
    width: props.width || props.size,
    height: props.height || props.size,
    viewBox: props.viewBox,
    xmlns: props.xmlns
  }
  const pathAttrs = {
    d: iconPath
  }

  return h('span', {
    ...(isV2 ? { attrs: spanAttrs } : spanAttrs),
    class: {
      ...(
        data.staticClass !== undefined
          ? { [data.staticClass]: true }
          : {}
      ),
      [`mdi mdi-${props.name}`]: true,
      'mdi-spin': props.spin === true
    }
  }, [
    h('svg', {
      ...(isV2 ? { attrs: svgAttrs } : svgAttrs)
    }, [
      ...[props.title ? h('title', [props.title]) : undefined],
      h('path', {
        ...(isV2 ? { attrs: pathAttrs } : pathAttrs)
      })
    ])
  ])
}

export default {
  install(app, { icons }) {

    if (icons === undefined) {
      throw new Error('Icons must be provided separately')
    }
  
    app.component('mdicon', {
      name: 'MDIcon',
      ...versionDependentOpts,
      props: {
        title: [String],
        spin: [Boolean],
        width: [Number, String],
        height: [Number, String],
        ariaLabel: [String],
        staticClass: [String], // hides: property access warning for ts with vue 3
        name: {
          type: String,
          required: true,
          default: 'alert'
        },
        size: {
          type: [Number, String],
          default: 24
        },
        viewBox: {
          type: String,
          default: '0 0 24 24'
        },
        xmlns: {
          type: String,
          default: 'http://www.w3.org/2000/svg'
        },
        role: {
          type: String,
          default: 'img'
        },
        spin: {
          type: Boolean,
          default: false
        }
      },
      render: renderWithIcons(icons)
    })
  }
}
<commit_msg>fix: add dynamic class prop to component<commit_after>import { mdiAlert } from '@mdi/js'
import './icons.css'

const { h: v3h } = require('vue') // import vue3's render function
const isV2 = v3h === undefined

const versionDependentOpts = isV2
  ? { functional: true } // for v2.x
  : {} // for v3.x

const ucFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
const toName = (str) => str.split('-').map(ucFirst).join('')

const renderWithIcons = mdi => function render(v2h, v2ctx) {
  const data = isV2 ? v2ctx.data : this
  const props = isV2 ? v2ctx.props : this
  const attrs = isV2 ? v2ctx.attrs : this.$attrs
  const h = isV2 ? v2h : v3h
  const iconPath = mdi[`mdi${toName(props.name)}`] || mdiAlert

  const spanAttrs = {
    role: props.role,
    'aria-label': props.ariaLabel,
    ...attrs
  }
  const svgAttrs = {
    fill: 'currentColor',
    width: props.width || props.size,
    height: props.height || props.size,
    viewBox: props.viewBox,
    xmlns: props.xmlns
  }
  const pathAttrs = {
    d: iconPath
  }

  return h('span', {
    ...(isV2 ? { attrs: spanAttrs } : spanAttrs),
    class: {
      ...(
        data.staticClass !== undefined
          ? { [data.staticClass]: true }
          : {}
      ),
      [`mdi mdi-${props.name}`]: true,
      'mdi-spin': props.spin === true,
      ...data.class
    }
  }, [
    h('svg', {
      ...(isV2 ? { attrs: svgAttrs } : svgAttrs)
    }, [
      ...[props.title ? h('title', [props.title]) : undefined],
      h('path', {
        ...(isV2 ? { attrs: pathAttrs } : pathAttrs)
      })
    ])
  ])
}

export default {
  install(app, { icons }) {

    if (icons === undefined) {
      throw new Error('Icons must be provided separately')
    }
  
    app.component('mdicon', {
      name: 'MDIcon',
      ...versionDependentOpts,
      props: {
        title: [String],
        spin: [Boolean],
        width: [Number, String],
        height: [Number, String],
        ariaLabel: [String],
        staticClass: [String], // hides: property access warning for ts with vue 3
        name: {
          type: String,
          required: true,
          default: 'alert'
        },
        size: {
          type: [Number, String],
          default: 24
        },
        viewBox: {
          type: String,
          default: '0 0 24 24'
        },
        xmlns: {
          type: String,
          default: 'http://www.w3.org/2000/svg'
        },
        role: {
          type: String,
          default: 'img'
        },
        spin: {
          type: Boolean,
          default: false
        }
      },
      render: renderWithIcons(icons)
    })
  }
}

{'fraction_non_alphanumeric': 0.1575920245398773, 'fraction_numerical': 0.014187116564417178, 'mean_word_length': 1.8664835164835165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, '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': '148240', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1772, 'n_words': 411}