46 lines
1.2 KiB
Vue
46 lines
1.2 KiB
Vue
<script lang="ts">
|
|
import { defineComponent, h, useAttrs, type VNodeChild } from "vue";
|
|
import PaginationChevronRightIcon from "./PaginationChevronRightIcon.vue";
|
|
|
|
function hasContent(nodes: VNodeChild[] | undefined): boolean {
|
|
if (!nodes || nodes.length === 0) return false;
|
|
return nodes.some((node) => {
|
|
if (node == null || node === false || node === true) return false;
|
|
if (typeof node === "string") return node.trim() !== "";
|
|
if (typeof node === "number") return true;
|
|
return true;
|
|
});
|
|
}
|
|
|
|
export default defineComponent({
|
|
name: "PaginationNextIcon",
|
|
inheritAttrs: false,
|
|
props: {
|
|
/** Render the icon wrapper as a custom element instead of `span`. */
|
|
as: {
|
|
type: String,
|
|
default: "span",
|
|
},
|
|
},
|
|
setup(props, { slots }) {
|
|
const attrs = useAttrs();
|
|
|
|
function render() {
|
|
const content = slots.default?.() as VNodeChild[] | undefined;
|
|
return h(
|
|
props.as,
|
|
{
|
|
...attrs,
|
|
class: attrs.class,
|
|
"aria-hidden": "true",
|
|
"data-slot": "pagination-next-icon",
|
|
},
|
|
hasContent(content) ? content : [h(PaginationChevronRightIcon)],
|
|
);
|
|
}
|
|
|
|
return render;
|
|
},
|
|
});
|
|
</script>
|