Blame view

node_modules/bootstrap-vue/src/components/dropdown/dropdown-header.js 1.2 KB
4cd4fd28   郭伟龙   feat: 初始化项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { extend, mergeData } from '../../vue'
import { NAME_DROPDOWN_HEADER } from '../../constants/components'
import { PROP_TYPE_STRING } from '../../constants/props'
import { isTag } from '../../utils/dom'
import { omit } from '../../utils/object'
import { makeProp, makePropsConfigurable } from '../../utils/props'

// --- Props ---

export const props = makePropsConfigurable(
  {
    id: makeProp(PROP_TYPE_STRING),
    tag: makeProp(PROP_TYPE_STRING, 'header'),
    variant: makeProp(PROP_TYPE_STRING)
  },
  NAME_DROPDOWN_HEADER
)

// --- Main component ---

// @vue/component
export const BDropdownHeader = /*#__PURE__*/ extend({
  name: NAME_DROPDOWN_HEADER,
  functional: true,
  props,
  render(h, { props, data, children }) {
    const { tag, variant } = props

    return h('li', mergeData(omit(data, ['attrs']), { attrs: { role: 'presentation' } }), [
      h(
        tag,
        {
          staticClass: 'dropdown-header',
          class: { [`text-${variant}`]: variant },
          attrs: {
            ...(data.attrs || {}),
            id: props.id || null,
            role: isTag(tag, 'header') ? null : 'heading'
          },
          ref: 'header'
        },
        children
      )
    ])
  }
})