UNPKG

1.8 kBJavaScriptView Raw
1/* eslint-disable react/no-multi-comp */
2import classNames from 'classnames';
3import * as React from 'react';
4import Anchor from '@restart/ui/Anchor';
5import { jsx as _jsx } from "react/jsx-runtime";
6import { jsxs as _jsxs } from "react/jsx-runtime";
7const PageItem = /*#__PURE__*/React.forwardRef(({
8 active = false,
9 disabled = false,
10 className,
11 style,
12 activeLabel = '(current)',
13 children,
14 linkStyle,
15 linkClassName,
16 ...props
17}, ref) => {
18 const Component = active || disabled ? 'span' : Anchor;
19 return /*#__PURE__*/_jsx("li", {
20 ref: ref,
21 style: style,
22 className: classNames(className, 'page-item', {
23 active,
24 disabled
25 }),
26 children: /*#__PURE__*/_jsxs(Component, {
27 className: classNames('page-link', linkClassName),
28 style: linkStyle,
29 ...props,
30 children: [children, active && activeLabel && /*#__PURE__*/_jsx("span", {
31 className: "visually-hidden",
32 children: activeLabel
33 })]
34 })
35 });
36});
37PageItem.displayName = 'PageItem';
38export default PageItem;
39function createButton(name, defaultValue, label = name) {
40 const Button = /*#__PURE__*/React.forwardRef(({
41 children,
42 ...props
43 }, ref) => /*#__PURE__*/_jsxs(PageItem, {
44 ...props,
45 ref: ref,
46 children: [/*#__PURE__*/_jsx("span", {
47 "aria-hidden": "true",
48 children: children || defaultValue
49 }), /*#__PURE__*/_jsx("span", {
50 className: "visually-hidden",
51 children: label
52 })]
53 }));
54 Button.displayName = name;
55 return Button;
56}
57export const First = createButton('First', '«');
58export const Prev = createButton('Prev', '‹', 'Previous');
59export const Ellipsis = createButton('Ellipsis', '…', 'More');
60export const Next = createButton('Next', '›');
61export const Last = createButton('Last', '»');
\No newline at end of file