feat(Pagination): new component (#257)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
Co-authored-by: Haytham A. Salama <haythamasalama@gmail.com>
This commit is contained in:
Sylvain Marroufin
2023-06-09 18:12:40 +02:00
committed by GitHub
parent f7a34c8fee
commit f0b24ba25d
11 changed files with 625 additions and 13 deletions

View File

@@ -18,14 +18,18 @@ export const omit = (obj: object, keys: string[]) => {
export const getSlotsChildren = (slots: any) => {
let children = slots.default?.()
if (children.length) {
if (typeof children[0].type === 'symbol') {
// @ts-ignore-next
children = children[0].children
// @ts-ignore-next
} else if (children[0].type.name === 'ContentSlot') {
// @ts-ignore-next
children = children[0].ctx.slots.default?.()
}
children = children.flatMap(c => {
if (typeof c.type === 'symbol') {
if (typeof c.children === 'string') {
// `v-if="false"` or commented node
return
}
return c.children
} else if (c.type.name === 'ContentSlot') {
return c.ctx.slots.default?.()
}
return c
}).filter(Boolean)
}
return children
}