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