reka-ui
Version:
Vue port for Radix UI Primitives.
59 lines (56 loc) • 2 kB
JavaScript
import { useForwardExpose } from "../shared/useForwardExpose.js";
import { Primitive } from "../Primitive/Primitive.js";
import { injectPaginationRootContext } from "./PaginationRoot.js";
import { computed, createBlock, createTextVNode, defineComponent, mergeProps, openBlock, renderSlot, toDisplayString, unref, withCtx } from "vue";
//#region src/Pagination/PaginationListItem.vue?vue&type=script&setup=true&lang.ts
var PaginationListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
__name: "PaginationListItem",
props: {
value: {
type: Number,
required: true
},
asChild: {
type: Boolean,
required: false
},
as: {
type: null,
required: false,
default: "button"
}
},
setup(__props) {
const props = __props;
useForwardExpose();
const rootContext = injectPaginationRootContext();
const isSelected = computed(() => rootContext.page.value === props.value);
const disabled = computed(() => rootContext.disabled.value);
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(Primitive), mergeProps(props, {
"data-type": "page",
"aria-label": `Page ${_ctx.value}`,
"aria-current": isSelected.value ? "page" : void 0,
"data-selected": isSelected.value ? "true" : void 0,
disabled: disabled.value,
type: _ctx.as === "button" ? "button" : void 0,
onClick: _cache[0] || (_cache[0] = ($event) => !disabled.value && unref(rootContext).onPageChange(_ctx.value))
}), {
default: withCtx(() => [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(_ctx.value), 1)])]),
_: 3
}, 16, [
"aria-label",
"aria-current",
"data-selected",
"disabled",
"type"
]);
};
}
});
//#endregion
//#region src/Pagination/PaginationListItem.vue
var PaginationListItem_default = PaginationListItem_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { PaginationListItem_default };
//# sourceMappingURL=PaginationListItem.js.map