96 lines
2.3 KiB
JavaScript
96 lines
2.3 KiB
JavaScript
import { createContext } from "../shared/createContext.js";
|
|
import { useForwardExpose } from "../shared/useForwardExpose.js";
|
|
import { Primitive } from "../Primitive/Primitive.js";
|
|
import { computed, createBlock, defineComponent, openBlock, renderSlot, toRefs, unref, withCtx } from "vue";
|
|
import { useVModel } from "@vueuse/core";
|
|
|
|
//#region src/Pagination/PaginationRoot.vue?vue&type=script&setup=true&lang.ts
|
|
const [injectPaginationRootContext, providePaginationRootContext] = createContext("PaginationRoot");
|
|
var PaginationRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
__name: "PaginationRoot",
|
|
props: {
|
|
page: {
|
|
type: Number,
|
|
required: false
|
|
},
|
|
defaultPage: {
|
|
type: Number,
|
|
required: false,
|
|
default: 1
|
|
},
|
|
itemsPerPage: {
|
|
type: Number,
|
|
required: true
|
|
},
|
|
total: {
|
|
type: Number,
|
|
required: false,
|
|
default: 0
|
|
},
|
|
siblingCount: {
|
|
type: Number,
|
|
required: false,
|
|
default: 2
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
required: false
|
|
},
|
|
showEdges: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
},
|
|
asChild: {
|
|
type: Boolean,
|
|
required: false
|
|
},
|
|
as: {
|
|
type: null,
|
|
required: false,
|
|
default: "nav"
|
|
}
|
|
},
|
|
emits: ["update:page"],
|
|
setup(__props, { emit: __emit }) {
|
|
const props = __props;
|
|
const emits = __emit;
|
|
const { siblingCount, disabled, showEdges } = toRefs(props);
|
|
useForwardExpose();
|
|
const page = useVModel(props, "page", emits, {
|
|
defaultValue: props.defaultPage,
|
|
passive: props.page === void 0
|
|
});
|
|
const pageCount = computed(() => Math.max(1, Math.ceil(props.total / (props.itemsPerPage || 1))));
|
|
providePaginationRootContext({
|
|
page,
|
|
onPageChange(value) {
|
|
page.value = value;
|
|
},
|
|
pageCount,
|
|
siblingCount,
|
|
disabled,
|
|
showEdges
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return openBlock(), createBlock(unref(Primitive), {
|
|
as: _ctx.as,
|
|
"as-child": _ctx.asChild
|
|
}, {
|
|
default: withCtx(() => [renderSlot(_ctx.$slots, "default", {
|
|
page: unref(page),
|
|
pageCount: pageCount.value
|
|
})]),
|
|
_: 3
|
|
}, 8, ["as", "as-child"]);
|
|
};
|
|
}
|
|
});
|
|
|
|
//#endregion
|
|
//#region src/Pagination/PaginationRoot.vue
|
|
var PaginationRoot_default = PaginationRoot_vue_vue_type_script_setup_true_lang_default;
|
|
|
|
//#endregion
|
|
export { PaginationRoot_default, injectPaginationRootContext };
|
|
//# sourceMappingURL=PaginationRoot.js.map
|