@molecule/app-pagination-bar-vue
Feature · pagination-bar · App (browser) · v1.1.1 · Apache-2.0
Vue PaginationBar with page-window, size-select, and "Showing X of Y" text
npm install @molecule/app-pagination-bar-vueHow it works
@molecule/app-pagination-bar-vue is a ready-made pagination-bar feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { defineComponent, h, ref } from 'vue'
import { PaginationBar } from '@molecule/app-pagination-bar-vue'
const OrderList = defineComponent({
props: { total: { type: Number, required: true } },
setup(props) {
const page = ref(1)
const pageSize = ref(10)
return () =>
h(PaginationBar, {
page: page.value,
totalPages: Math.max(1, Math.ceil(props.total / pageSize.value)),
pageSize: pageSize.value,
total: props.total,
onPageChange: (next: number) => {
page.value = next
},
pageSizeOptions: [10, 25, 50],
onPageSizeChange: (size: number) => {
pageSize.value = size
page.value = 1
},
})
},
})Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue PaginationBar — page-window + "Showing X of Y" text + optional page-size selector.
Built on <Button> and <Select> from @molecule/app-ui-vue so it
inherits the wired ClassMap styling. Apps drive the i18n noun via the
showingKey prop ("Showing 1 to 10 of 123 tags" vs. "…orders") — the key
takes start, end, and total interpolation values. It is the Vue
counterpart of @molecule/app-pagination-bar-react: the same props (React
names) and the same DOM for the same input.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { defineComponent, h, ref } from 'vue'
import { PaginationBar } from '@molecule/app-pagination-bar-vue'
const OrderList = defineComponent({
props: { total: { type: Number, required: true } },
setup(props) {
const page = ref(1)
const pageSize = ref(10)
return () =>
h(PaginationBar, {
page: page.value,
totalPages: Math.max(1, Math.ceil(props.total / pageSize.value)),
pageSize: pageSize.value,
total: props.total,
onPageChange: (next: number) => {
page.value = next
},
pageSizeOptions: [10, 25, 50],
onPageSizeChange: (size: number) => {
pageSize.value = size
page.value = 1
},
})
},
})
Type
feature
Installation
npm install @molecule/app-pagination-bar-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
PaginationBarProps
Props accepted by the PaginationBar component.
interface PaginationBarProps {
/** Current page (1-indexed). */
page: number
/** Total page count (>= 1). */
totalPages: number
/** Items per page. */
pageSize: number
/** Total item count across all pages. */
total: number
/** Called when the user changes page. */
onPageChange: (page: number) => void
/** Called when the user changes page-size (when allowed via `pageSizeOptions`). */
onPageSizeChange?: (size: number) => void
/** Available page-size options. When omitted, the size selector is hidden. */
pageSizeOptions?: number[]
/** i18n key for the "Showing X to Y of Z items" text — takes interpolation vars `start`, `end`, `total`. */
showingKey?: string
/** Default English fallback for the showing text. */
showingDefault?: string
/** Extra classes on the outer wrapper. */
className?: string
}
Constants
PaginationBar
Paginator with a [showing text, prev, page-window, next, size-select] layout.
The "Showing X to Y of Z items" text is driven by an i18n key so apps can
specialize the noun ("tags", "orders", "transactions"). Page-size selector
is hidden unless pageSizeOptions + onPageSizeChange are supplied.
const PaginationBar: DefineComponent<
ExtractPropTypes<{
page: { type: NumberConstructor; required: true }
totalPages: { type: NumberConstructor; required: true }
pageSize: { type: NumberConstructor; required: true }
total: { type: NumberConstructor; required: true }
onPageChange: { type: PropType<PaginationBarProps['onPageChange']>; required: true }
onPageSizeChange: { type: PropType<PaginationBarProps['onPageSizeChange']> }
pageSizeOptions: { type: PropType<number[]> }
showingKey: { type: StringConstructor; default: string }
showingDefault: { type: StringConstructor; default: string }
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
page: { type: NumberConstructor; required: true }
totalPages: { type: NumberConstructor; required: true }
pageSize: { type: NumberConstructor; required: true }
total: { type: NumberConstructor; required: true }
onPageChange: { type: PropType<PaginationBarProps['onPageChange']>; required: true }
onPageSizeChange: { type: PropType<PaginationBarProps['onPageSizeChange']> }
pageSizeOptions: { type: PropType<number[]> }
showingKey: { type: StringConstructor; default: string }
showingDefault: { type: StringConstructor; default: string }
className: StringConstructor
}>
> &
Readonly<{}>,
{ showingKey: string; showingDefault: string },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seePaginationBarProps).
Returns: The pagination bar component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.5.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
Companion locale bond: @molecule/app-locales-pagination-bar (keys
pagination.previous, pagination.next, pagination.pageSize, plus your
showingKey). The page-size <Select> is hidden unless BOTH
pageSizeOptions and onPageSizeChange are supplied; when shown it wires
the <Select>'s typed onValueChange and parses the selected value to a
number, so onPageSizeChange always receives a real page size (e.g. 25),
never NaN. Requires the Vue binding's i18n plugin and a wired ClassMap
bond. Distinct from @molecule/app-ui-vue's lower-level <Pagination>
(page window only — no showing-text or size selector).
Translations
Translation strings are provided by @molecule/app-locales-pagination-bar.