40 lines
1.1 KiB
Vue
40 lines
1.1 KiB
Vue
<script lang="ts">
|
|
import { defineComponent, h, inject, useAttrs } from "vue";
|
|
import { paginationContextKey } from "./context";
|
|
|
|
export default defineComponent({
|
|
name: "PaginationSummary",
|
|
inheritAttrs: false,
|
|
props: {
|
|
/** Render the summary as a custom element instead of `div`. */
|
|
as: {
|
|
type: String,
|
|
default: "div",
|
|
},
|
|
},
|
|
setup(props, { slots }) {
|
|
const attrs = useAttrs();
|
|
const context = inject(paginationContextKey, null);
|
|
|
|
function render() {
|
|
const { class: cls, dir, ...rest } = attrs as Record<string, unknown>;
|
|
return h(
|
|
props.as,
|
|
{
|
|
...rest,
|
|
// Auto-detect base direction from the summary's own text so mixed
|
|
// number/word content is not bidi-reordered by an RTL ancestor.
|
|
// Explicit `dir` still overrides.
|
|
dir: dir === undefined ? "auto" : dir,
|
|
class: [context?.slots.value.summary(), cls],
|
|
"data-slot": "pagination-summary",
|
|
},
|
|
slots.default?.(),
|
|
);
|
|
}
|
|
|
|
return render;
|
|
},
|
|
});
|
|
</script>
|