Blame view

node_modules/bootstrap-vue/src/components/skeleton/skeleton-wrapper.js 1.26 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
47
import { extend, mergeData } from '../../vue'
import { NAME_SKELETON_WRAPPER } from '../../constants/components'
import { PROP_TYPE_BOOLEAN } from '../../constants/props'
import { SLOT_NAME_DEFAULT, SLOT_NAME_LOADING } from '../../constants/slots'
import { normalizeSlot } from '../../utils/normalize-slot'
import { makeProp, makePropsConfigurable } from '../../utils/props'

// --- Props ---

export const props = makePropsConfigurable(
  {
    loading: makeProp(PROP_TYPE_BOOLEAN, false)
  },
  NAME_SKELETON_WRAPPER
)

// --- Main component ---

// @vue/component
export const BSkeletonWrapper = /*#__PURE__*/ extend({
  name: NAME_SKELETON_WRAPPER,
  functional: true,
  props,
  render(h, { data, props, slots, scopedSlots }) {
    const $slots = slots()
    const $scopedSlots = scopedSlots || {}
    const slotScope = {}

    if (props.loading) {
      return h(
        'div',
        mergeData(data, {
          attrs: {
            role: 'alert',
            'aria-live': 'polite',
            'aria-busy': true
          },
          staticClass: 'b-skeleton-wrapper',
          key: 'loading'
        }),
        normalizeSlot(SLOT_NAME_LOADING, slotScope, $scopedSlots, $slots)
      )
    }

    return normalizeSlot(SLOT_NAME_DEFAULT, slotScope, $scopedSlots, $slots)
  }
})