-
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathStepFlow.ts
More file actions
29 lines (26 loc) · 884 Bytes
/
StepFlow.ts
File metadata and controls
29 lines (26 loc) · 884 Bytes
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
import { defineComponent, h } from 'vue'
import type { Component, PropType } from 'vue'
export default defineComponent({
name: 'StepFlow',
props: {
type: String as PropType<'ul' | 'ol'>,
},
setup(props, { slots }) {
return () => {
const items = (slots.default?.() ?? [])
.filter(vnode => (vnode.type as Component).name === 'StepFlowItem')
.map((vnode) => {
vnode.props = vnode.props ?? {}
return vnode
})
const Tag = props.type === 'ol' ? 'ol' : 'ul'
return h(Tag, { class: 'step-flow' }, items.map((item, index) => {
return h(
'li',
{ 'class': 'step-flow-item', 'data-step': index + 1 },
item,
)
}))
}
},
})