feat: migrate Pagination Header and InputOTP with field and event regressions
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user