@yamada-ui/pagination 1.0.43-next-20241022143327 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-2SJMAKWY.mjs +173 -0
- package/dist/chunk-2SJMAKWY.mjs.map +1 -0
- package/dist/chunk-LFUBRVFO.mjs +78 -0
- package/dist/chunk-LFUBRVFO.mjs.map +1 -0
- package/dist/index.js +136 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/pagination-item.d.mts +4 -4
- package/dist/pagination-item.d.ts +4 -4
- package/dist/pagination-item.js +46 -44
- package/dist/pagination-item.js.map +1 -1
- package/dist/pagination-item.mjs +1 -1
- package/dist/pagination.d.mts +13 -13
- package/dist/pagination.d.ts +13 -13
- package/dist/pagination.js +136 -138
- package/dist/pagination.js.map +1 -1
- package/dist/pagination.mjs +2 -2
- package/package.json +7 -7
- package/dist/chunk-E35BXOXS.mjs +0 -177
- package/dist/chunk-E35BXOXS.mjs.map +0 -1
- package/dist/chunk-PUQ5FNCP.mjs +0 -76
- package/dist/chunk-PUQ5FNCP.mjs.map +0 -1
@@ -0,0 +1,173 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
PaginationItem
|
4
|
+
} from "./chunk-LFUBRVFO.mjs";
|
5
|
+
import {
|
6
|
+
PaginationProvider,
|
7
|
+
usePagination
|
8
|
+
} from "./chunk-O6EIBNLC.mjs";
|
9
|
+
|
10
|
+
// src/pagination.tsx
|
11
|
+
import {
|
12
|
+
forwardRef,
|
13
|
+
omitThemeProps,
|
14
|
+
ui,
|
15
|
+
useComponentMultiStyle
|
16
|
+
} from "@yamada-ui/core";
|
17
|
+
import { useValue } from "@yamada-ui/use-value";
|
18
|
+
import { cx, dataAttr, handlerAll } from "@yamada-ui/utils";
|
19
|
+
import { useMemo } from "react";
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
21
|
+
var Pagination = forwardRef((props, ref) => {
|
22
|
+
const [styles, mergedProps] = useComponentMultiStyle("Pagination", props);
|
23
|
+
const {
|
24
|
+
className,
|
25
|
+
boundaries,
|
26
|
+
component: Component = PaginationItem,
|
27
|
+
defaultPage,
|
28
|
+
isDisabled,
|
29
|
+
page,
|
30
|
+
siblings,
|
31
|
+
total,
|
32
|
+
withControls: _withControls = true,
|
33
|
+
withEdges: _withEdges = false,
|
34
|
+
containerProps,
|
35
|
+
controlNextProps,
|
36
|
+
controlPrevProps,
|
37
|
+
controlProps,
|
38
|
+
edgeFirstProps,
|
39
|
+
edgeLastProps,
|
40
|
+
edgeProps,
|
41
|
+
itemProps,
|
42
|
+
onChange: onChangeProp,
|
43
|
+
...rest
|
44
|
+
} = omitThemeProps(mergedProps);
|
45
|
+
const withControls = useValue(_withControls);
|
46
|
+
const withEdges = useValue(_withEdges);
|
47
|
+
const { currentPage, range, onChange, onFirst, onLast, onNext, onPrev } = usePagination({
|
48
|
+
boundaries,
|
49
|
+
defaultPage,
|
50
|
+
isDisabled,
|
51
|
+
page,
|
52
|
+
siblings,
|
53
|
+
total,
|
54
|
+
onChange: onChangeProp
|
55
|
+
});
|
56
|
+
const children = useMemo(
|
57
|
+
() => range.map((page2, key) => /* @__PURE__ */ jsx(ui.li, { children: /* @__PURE__ */ jsx(
|
58
|
+
Component,
|
59
|
+
{
|
60
|
+
"aria-label": page2 !== "ellipsis" ? `Go to page ${page2}` : void 0,
|
61
|
+
isActive: currentPage === page2,
|
62
|
+
isDisabled,
|
63
|
+
...itemProps,
|
64
|
+
page: page2,
|
65
|
+
onClick: handlerAll(
|
66
|
+
itemProps == null ? void 0 : itemProps.onClick,
|
67
|
+
page2 !== "ellipsis" ? () => onChange(page2) : void 0
|
68
|
+
)
|
69
|
+
}
|
70
|
+
) }, key)),
|
71
|
+
[Component, currentPage, isDisabled, onChange, range, itemProps]
|
72
|
+
);
|
73
|
+
const css = {
|
74
|
+
...styles.container
|
75
|
+
};
|
76
|
+
return /* @__PURE__ */ jsx(PaginationProvider, { value: styles, children: /* @__PURE__ */ jsx(
|
77
|
+
ui.nav,
|
78
|
+
{
|
79
|
+
ref,
|
80
|
+
className: cx("ui-pagination", className),
|
81
|
+
"data-disabled": dataAttr(isDisabled),
|
82
|
+
__css: css,
|
83
|
+
...containerProps,
|
84
|
+
children: /* @__PURE__ */ jsxs(
|
85
|
+
ui.ul,
|
86
|
+
{
|
87
|
+
className: "ui-pagination-inner",
|
88
|
+
"data-disabled": dataAttr(isDisabled),
|
89
|
+
__css: {
|
90
|
+
alignItems: "center",
|
91
|
+
display: "flex",
|
92
|
+
...styles.inner
|
93
|
+
},
|
94
|
+
...rest,
|
95
|
+
children: [
|
96
|
+
withEdges ? /* @__PURE__ */ jsx(ui.li, { children: /* @__PURE__ */ jsx(
|
97
|
+
Component,
|
98
|
+
{
|
99
|
+
className: "ui-pagination__item--first",
|
100
|
+
"aria-label": "Go to first page",
|
101
|
+
isDisabled: isDisabled || currentPage === 1,
|
102
|
+
page: "first",
|
103
|
+
...edgeProps,
|
104
|
+
...edgeFirstProps,
|
105
|
+
onClick: handlerAll(
|
106
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
107
|
+
edgeFirstProps == null ? void 0 : edgeFirstProps.onClick,
|
108
|
+
onFirst
|
109
|
+
)
|
110
|
+
}
|
111
|
+
) }) : null,
|
112
|
+
withControls ? /* @__PURE__ */ jsx(ui.li, { children: /* @__PURE__ */ jsx(
|
113
|
+
Component,
|
114
|
+
{
|
115
|
+
className: "ui-pagination__item--prev",
|
116
|
+
"aria-label": "Go to previous page",
|
117
|
+
isDisabled: isDisabled || currentPage === 1,
|
118
|
+
page: "prev",
|
119
|
+
...controlProps,
|
120
|
+
...controlPrevProps,
|
121
|
+
onClick: handlerAll(
|
122
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
123
|
+
controlPrevProps == null ? void 0 : controlPrevProps.onClick,
|
124
|
+
onPrev
|
125
|
+
)
|
126
|
+
}
|
127
|
+
) }) : null,
|
128
|
+
children,
|
129
|
+
withControls ? /* @__PURE__ */ jsx(ui.li, { children: /* @__PURE__ */ jsx(
|
130
|
+
Component,
|
131
|
+
{
|
132
|
+
className: "ui-pagination__item--next",
|
133
|
+
"aria-label": "Go to next page",
|
134
|
+
isDisabled: isDisabled || currentPage === total,
|
135
|
+
page: "next",
|
136
|
+
...controlProps,
|
137
|
+
...controlNextProps,
|
138
|
+
onClick: handlerAll(
|
139
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
140
|
+
controlNextProps == null ? void 0 : controlNextProps.onClick,
|
141
|
+
onNext
|
142
|
+
)
|
143
|
+
}
|
144
|
+
) }) : null,
|
145
|
+
withEdges ? /* @__PURE__ */ jsx(ui.li, { children: /* @__PURE__ */ jsx(
|
146
|
+
Component,
|
147
|
+
{
|
148
|
+
className: "ui-pagination__item--last",
|
149
|
+
"aria-label": "Go to last page",
|
150
|
+
isDisabled: isDisabled || currentPage === total,
|
151
|
+
page: "last",
|
152
|
+
...edgeProps,
|
153
|
+
...edgeLastProps,
|
154
|
+
onClick: handlerAll(
|
155
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
156
|
+
edgeLastProps == null ? void 0 : edgeLastProps.onClick,
|
157
|
+
onLast
|
158
|
+
)
|
159
|
+
}
|
160
|
+
) }) : null
|
161
|
+
]
|
162
|
+
}
|
163
|
+
)
|
164
|
+
}
|
165
|
+
) });
|
166
|
+
});
|
167
|
+
Pagination.displayName = "Pagination";
|
168
|
+
Pagination.__ui__ = "Pagination";
|
169
|
+
|
170
|
+
export {
|
171
|
+
Pagination
|
172
|
+
};
|
173
|
+
//# sourceMappingURL=chunk-2SJMAKWY.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/pagination.tsx"],"sourcesContent":["import type {\n CSSUIObject,\n HTMLUIProps,\n ThemeProps,\n Token,\n} from \"@yamada-ui/core\"\nimport type { FC } from \"react\"\nimport type { PaginationItemProps } from \"./pagination-item\"\nimport type { UsePaginationProps } from \"./use-pagination\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { useValue } from \"@yamada-ui/use-value\"\nimport { cx, dataAttr, handlerAll } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport { PaginationItem } from \"./pagination-item\"\nimport { PaginationProvider, usePagination } from \"./use-pagination\"\n\ninterface PaginationOptions {\n /**\n * The pagination button component to use.\n */\n component?: FC<PaginationItemProps>\n /**\n * If `true`, display the control buttons.\n *\n * @default true\n */\n withControls?: Token<boolean>\n /**\n * If `true`, display the edge buttons.\n *\n * @default false\n */\n withEdges?: Token<boolean>\n /**\n * Props for container element.\n */\n containerProps?: HTMLUIProps<\"nav\">\n /**\n * Props for next of the control button element.\n */\n controlNextProps?: Omit<PaginationItemProps, \"page\">\n /**\n * Props for previous of the control button element.\n */\n controlPrevProps?: Omit<PaginationItemProps, \"page\">\n /**\n * Props for control button element.\n */\n controlProps?: Omit<PaginationItemProps, \"page\">\n /**\n * Props for first of the edge button element.\n */\n edgeFirstProps?: Omit<PaginationItemProps, \"page\">\n /**\n * Props for last of the edge button element.\n */\n edgeLastProps?: Omit<PaginationItemProps, \"page\">\n /**\n * Props for edge button element.\n */\n edgeProps?: Omit<PaginationItemProps, \"page\">\n /**\n * Props for button element.\n */\n itemProps?: Omit<PaginationItemProps, \"page\">\n}\n\nexport interface PaginationProps\n extends Omit<HTMLUIProps<\"ul\">, \"children\" | \"onChange\" | \"page\">,\n ThemeProps<\"Pagination\">,\n UsePaginationProps,\n PaginationOptions {}\n\n/**\n * `Pagination` is a component for managing the pagination and navigation of content.\n *\n * @see Docs https://yamada-ui.com/components/navigation/pagination\n */\nexport const Pagination = forwardRef<PaginationProps, \"ul\">((props, ref) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Pagination\", props)\n const {\n className,\n boundaries,\n component: Component = PaginationItem,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n withControls: _withControls = true,\n withEdges: _withEdges = false,\n containerProps,\n controlNextProps,\n controlPrevProps,\n controlProps,\n edgeFirstProps,\n edgeLastProps,\n edgeProps,\n itemProps,\n onChange: onChangeProp,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const withControls = useValue(_withControls)\n const withEdges = useValue(_withEdges)\n\n const { currentPage, range, onChange, onFirst, onLast, onNext, onPrev } =\n usePagination({\n boundaries,\n defaultPage,\n isDisabled,\n page,\n siblings,\n total,\n onChange: onChangeProp,\n })\n\n const children = useMemo(\n () =>\n range.map((page, key) => (\n <ui.li key={key}>\n <Component\n aria-label={page !== \"ellipsis\" ? `Go to page ${page}` : undefined}\n isActive={currentPage === page}\n isDisabled={isDisabled}\n {...itemProps}\n page={page}\n onClick={handlerAll(\n itemProps?.onClick,\n page !== \"ellipsis\" ? () => onChange(page) : undefined,\n )}\n />\n </ui.li>\n )),\n [Component, currentPage, isDisabled, onChange, range, itemProps],\n )\n\n const css: CSSUIObject = {\n ...styles.container,\n }\n\n return (\n <PaginationProvider value={styles}>\n <ui.nav\n ref={ref}\n className={cx(\"ui-pagination\", className)}\n data-disabled={dataAttr(isDisabled)}\n __css={css}\n {...containerProps}\n >\n <ui.ul\n className=\"ui-pagination-inner\"\n data-disabled={dataAttr(isDisabled)}\n __css={{\n alignItems: \"center\",\n display: \"flex\",\n ...styles.inner,\n }}\n {...rest}\n >\n {withEdges ? (\n <ui.li>\n <Component\n className=\"ui-pagination__item--first\"\n aria-label=\"Go to first page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"first\"\n {...edgeProps}\n {...edgeFirstProps}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeFirstProps?.onClick,\n onFirst,\n )}\n />\n </ui.li>\n ) : null}\n\n {withControls ? (\n <ui.li>\n <Component\n className=\"ui-pagination__item--prev\"\n aria-label=\"Go to previous page\"\n isDisabled={isDisabled || currentPage === 1}\n page=\"prev\"\n {...controlProps}\n {...controlPrevProps}\n onClick={handlerAll(\n controlProps?.onClick,\n controlPrevProps?.onClick,\n onPrev,\n )}\n />\n </ui.li>\n ) : null}\n\n {children}\n\n {withControls ? (\n <ui.li>\n <Component\n className=\"ui-pagination__item--next\"\n aria-label=\"Go to next page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"next\"\n {...controlProps}\n {...controlNextProps}\n onClick={handlerAll(\n controlProps?.onClick,\n controlNextProps?.onClick,\n onNext,\n )}\n />\n </ui.li>\n ) : null}\n\n {withEdges ? (\n <ui.li>\n <Component\n className=\"ui-pagination__item--last\"\n aria-label=\"Go to last page\"\n isDisabled={isDisabled || currentPage === total}\n page=\"last\"\n {...edgeProps}\n {...edgeLastProps}\n onClick={handlerAll(\n edgeProps?.onClick,\n edgeLastProps?.onClick,\n onLast,\n )}\n />\n </ui.li>\n ) : null}\n </ui.ul>\n </ui.nav>\n </PaginationProvider>\n )\n})\n\nPagination.displayName = \"Pagination\"\nPagination.__ui__ = \"Pagination\"\n"],"mappings":";;;;;;;;;;AASA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,IAAI,UAAU,kBAAkB;AACzC,SAAS,eAAe;AA6Gd,cA6BF,YA7BE;AA3CH,IAAM,aAAa,WAAkC,CAAC,OAAO,QAAQ;AAC1E,QAAM,CAAC,QAAQ,WAAW,IAAI,uBAAuB,cAAc,KAAK;AACxE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW,YAAY;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,gBAAgB;AAAA,IAC9B,WAAW,aAAa;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,GAAG;AAAA,EACL,IAAI,eAAe,WAAW;AAE9B,QAAM,eAAe,SAAS,aAAa;AAC3C,QAAM,YAAY,SAAS,UAAU;AAErC,QAAM,EAAE,aAAa,OAAO,UAAU,SAAS,QAAQ,QAAQ,OAAO,IACpE,cA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AA,gBACF;AAAA;AAAA,YACF,GACF,IACE;AAAA,YAEH,eACC,oBAAC,GAAG,IAAH,EACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,cAAW;AAAA,gBACX,YAAY,cAAc,gBAAgB;AAAA,gBAC1C,MAAK;AAAA,gBACJ,GAAG;AAAA,gBACH,GAAG;AAAA,gBACJ,SAAS;AAAA,kBACP,6CAAc;AAAA,kBACd,qDAAkB;AAAA,kBAClB;AAAA,gBACF;AAAA;AAAA,YACF,GACF,IACE;AAAA,YAEH;AAAA,YAEA,eACC,oBAAC,GAAG,IAAH,EACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,cAAW;AAAA,gBACX,YAAY,cAAc,gBAAgB;AAAA,gBAC1C,MAAK;AAAA,gBACJ,GAAG;AAAA,gBACH,GAAG;AAAA,gBACJ,SAAS;AAAA,kBACP,6CAAc;AAAA,kBACd,qDAAkB;AAAA,kBAClB;AAAA,gBACF;AAAA;AAAA,YACF,GACF,IACE;AAAA,YAEH,YACC,oBAAC,GAAG,IAAH,EACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,cAAW;AAAA,gBACX,YAAY,cAAc,gBAAgB;AAAA,gBAC1C,MAAK;AAAA,gBACJ,GAAG;AAAA,gBACH,GAAG;AAAA,gBACJ,SAAS;AAAA,kBACP,uCAAW;AAAA,kBACX,+CAAe;AAAA,kBACf;AAAA,gBACF;AAAA;AAAA,YACF,GACF,IACE;AAAA;AAAA;AAAA,MACN;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,SAAS;","names":["page"]}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use client"
|
2
|
+
import {
|
3
|
+
PaginationEllipsisIcon,
|
4
|
+
PaginationFirstIcon,
|
5
|
+
PaginationLastIcon,
|
6
|
+
PaginationNextIcon,
|
7
|
+
PaginationPrevIcon
|
8
|
+
} from "./chunk-VZWGYG76.mjs";
|
9
|
+
import {
|
10
|
+
usePaginationContext
|
11
|
+
} from "./chunk-O6EIBNLC.mjs";
|
12
|
+
|
13
|
+
// src/pagination-item.tsx
|
14
|
+
import { forwardRef, ui } from "@yamada-ui/core";
|
15
|
+
import { Ripple, useRipple } from "@yamada-ui/ripple";
|
16
|
+
import { cx, dataAttr } from "@yamada-ui/utils";
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
18
|
+
var iconMap = {
|
19
|
+
ellipsis: /* @__PURE__ */ jsx(PaginationEllipsisIcon, {}),
|
20
|
+
first: /* @__PURE__ */ jsx(PaginationFirstIcon, {}),
|
21
|
+
last: /* @__PURE__ */ jsx(PaginationLastIcon, {}),
|
22
|
+
next: /* @__PURE__ */ jsx(PaginationNextIcon, {}),
|
23
|
+
prev: /* @__PURE__ */ jsx(PaginationPrevIcon, {})
|
24
|
+
};
|
25
|
+
var PaginationItem = forwardRef(
|
26
|
+
({ className, children, disableRipple, isActive, isDisabled, page, ...rest }, ref) => {
|
27
|
+
var _a;
|
28
|
+
const styles = usePaginationContext();
|
29
|
+
const isEllipsis = page === "ellipsis";
|
30
|
+
const { onPointerDown, ...rippleProps } = useRipple({
|
31
|
+
...rest,
|
32
|
+
isDisabled: disableRipple || isDisabled || isEllipsis
|
33
|
+
});
|
34
|
+
children != null ? children : children = (_a = iconMap[page]) != null ? _a : page;
|
35
|
+
const css = {
|
36
|
+
alignItems: "center",
|
37
|
+
display: "flex",
|
38
|
+
justifyContent: "center",
|
39
|
+
overflow: "hidden",
|
40
|
+
position: "relative",
|
41
|
+
userSelect: "none",
|
42
|
+
...styles.item,
|
43
|
+
...styles[page]
|
44
|
+
};
|
45
|
+
const Component = ui[isEllipsis ? "span" : "button"];
|
46
|
+
return /* @__PURE__ */ jsxs(
|
47
|
+
Component,
|
48
|
+
{
|
49
|
+
ref,
|
50
|
+
...!isEllipsis ? {
|
51
|
+
"data-disabled": dataAttr(isDisabled),
|
52
|
+
"data-selected": dataAttr(isActive),
|
53
|
+
disabled: isDisabled
|
54
|
+
} : {},
|
55
|
+
className: cx(
|
56
|
+
"ui-pagination__item",
|
57
|
+
isEllipsis ? "ui-pagination__item--ellipsis" : void 0,
|
58
|
+
className
|
59
|
+
),
|
60
|
+
tabIndex: !isEllipsis ? 0 : -1,
|
61
|
+
__css: css,
|
62
|
+
...rest,
|
63
|
+
onPointerDown,
|
64
|
+
children: [
|
65
|
+
children,
|
66
|
+
/* @__PURE__ */ jsx(Ripple, { isDisabled: disableRipple || isDisabled, ...rippleProps })
|
67
|
+
]
|
68
|
+
}
|
69
|
+
);
|
70
|
+
}
|
71
|
+
);
|
72
|
+
PaginationItem.displayName = "PaginationItem";
|
73
|
+
PaginationItem.__ui__ = "PaginationItem";
|
74
|
+
|
75
|
+
export {
|
76
|
+
PaginationItem
|
77
|
+
};
|
78
|
+
//# sourceMappingURL=chunk-LFUBRVFO.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/pagination-item.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { ReactNode } from \"react\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { Ripple, useRipple } from \"@yamada-ui/ripple\"\nimport { cx, dataAttr } from \"@yamada-ui/utils\"\nimport {\n PaginationEllipsisIcon,\n PaginationFirstIcon,\n PaginationLastIcon,\n PaginationNextIcon,\n PaginationPrevIcon,\n} from \"./pagination-icon\"\nimport { usePaginationContext } from \"./use-pagination\"\n\ninterface PaginationItemOptions {\n /**\n * The type of the page or item assigned to the pagination item.\n */\n page: \"ellipsis\" | \"first\" | \"last\" | \"next\" | \"prev\" | number\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n disableRipple?: boolean\n /**\n * If `true`, the pagination item will be activated.\n *\n * @default false\n */\n isActive?: boolean\n /**\n * If `true`, the pagination item will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\nexport interface PaginationItemProps\n extends Omit<HTMLUIProps<\"button\">, \"page\">,\n PaginationItemOptions {}\n\nconst iconMap: {\n [key in \"ellipsis\" | \"first\" | \"last\" | \"next\" | \"prev\" | number]: ReactNode\n} = {\n ellipsis: <PaginationEllipsisIcon />,\n first: <PaginationFirstIcon />,\n last: <PaginationLastIcon />,\n next: <PaginationNextIcon />,\n prev: <PaginationPrevIcon />,\n}\n\nexport const PaginationItem = forwardRef<PaginationItemProps, \"button\">(\n (\n { className, children, disableRipple, isActive, isDisabled, page, ...rest },\n ref,\n ) => {\n const styles = usePaginationContext()\n const isEllipsis = page === \"ellipsis\"\n const { onPointerDown, ...rippleProps } = useRipple({\n ...rest,\n isDisabled: disableRipple || isDisabled || isEllipsis,\n })\n\n children ??= iconMap[page] ?? page\n\n const css: CSSUIObject = {\n alignItems: \"center\",\n display: \"flex\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n position: \"relative\",\n userSelect: \"none\",\n ...styles.item,\n ...styles[page],\n }\n\n const Component = ui[isEllipsis ? \"span\" : \"button\"]\n\n return (\n <Component\n ref={ref}\n {...(!isEllipsis\n ? {\n \"data-disabled\": dataAttr(isDisabled),\n \"data-selected\": dataAttr(isActive),\n disabled: isDisabled,\n }\n : {})}\n className={cx(\n \"ui-pagination__item\",\n isEllipsis ? \"ui-pagination__item--ellipsis\" : undefined,\n className,\n )}\n tabIndex={!isEllipsis ? 0 : -1}\n __css={css}\n {...rest}\n onPointerDown={onPointerDown}\n >\n {children}\n\n <Ripple isDisabled={disableRipple || isDisabled} {...rippleProps} />\n </Component>\n )\n },\n)\n\nPaginationItem.displayName = \"PaginationItem\"\nPaginationItem.__ui__ = \"PaginationItem\"\n"],"mappings":";;;;;;;;;;;;;AAEA,SAAS,YAAY,UAAU;AAC/B,SAAS,QAAQ,iBAAiB;AAClC,SAAS,IAAI,gBAAgB;AA0CjB,cAmCN,YAnCM;AAHZ,IAAM,UAEF;AAAA,EACF,UAAU,oBAAC,0BAAuB;AAAA,EAClC,OAAO,o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|
192
192
|
next: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationNextIcon, {}),
|
193
193
|
prev: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationPrevIcon, {})
|
194
194
|
};
|
195
|
-
var PaginationItem = (
|
196
|
-
className,
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
page,
|
202
|
-
...rest
|
203
|
-
}) => {
|
204
|
-
var _a;
|
205
|
-
const styles = usePaginationContext();
|
206
|
-
const { onPointerDown, ...rippleProps } = (0, import_ripple.useRipple)({
|
207
|
-
...rest,
|
208
|
-
isDisabled: disableRipple || isDisabled
|
209
|
-
});
|
210
|
-
children != null ? children : children = (_a = iconMap[page]) != null ? _a : page;
|
211
|
-
const css = {
|
212
|
-
alignItems: "center",
|
213
|
-
display: "flex",
|
214
|
-
justifyContent: "center",
|
215
|
-
overflow: "hidden",
|
216
|
-
position: "relative",
|
217
|
-
userSelect: "none",
|
218
|
-
...styles.item,
|
219
|
-
...styles[page]
|
220
|
-
};
|
221
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
222
|
-
import_core.ui.button,
|
223
|
-
{
|
224
|
-
type: "button",
|
225
|
-
className: (0, import_utils2.cx)("ui-pagination__item", className),
|
226
|
-
"data-disabled": (0, import_utils2.dataAttr)(isDisabled),
|
227
|
-
"data-selected": (0, import_utils2.dataAttr)(isActive),
|
228
|
-
disabled: isDisabled,
|
229
|
-
tabIndex: page !== "ellipsis" ? 0 : -1,
|
230
|
-
__css: css,
|
195
|
+
var PaginationItem = (0, import_core.forwardRef)(
|
196
|
+
({ className, children, disableRipple, isActive, isDisabled, page, ...rest }, ref) => {
|
197
|
+
var _a;
|
198
|
+
const styles = usePaginationContext();
|
199
|
+
const isEllipsis = page === "ellipsis";
|
200
|
+
const { onPointerDown, ...rippleProps } = (0, import_ripple.useRipple)({
|
231
201
|
...rest,
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
202
|
+
isDisabled: disableRipple || isDisabled || isEllipsis
|
203
|
+
});
|
204
|
+
children != null ? children : children = (_a = iconMap[page]) != null ? _a : page;
|
205
|
+
const css = {
|
206
|
+
alignItems: "center",
|
207
|
+
display: "flex",
|
208
|
+
justifyContent: "center",
|
209
|
+
overflow: "hidden",
|
210
|
+
position: "relative",
|
211
|
+
userSelect: "none",
|
212
|
+
...styles.item,
|
213
|
+
...styles[page]
|
214
|
+
};
|
215
|
+
const Component = import_core.ui[isEllipsis ? "span" : "button"];
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
217
|
+
Component,
|
218
|
+
{
|
219
|
+
ref,
|
220
|
+
...!isEllipsis ? {
|
221
|
+
"data-disabled": (0, import_utils2.dataAttr)(isDisabled),
|
222
|
+
"data-selected": (0, import_utils2.dataAttr)(isActive),
|
223
|
+
disabled: isDisabled
|
224
|
+
} : {},
|
225
|
+
className: (0, import_utils2.cx)(
|
226
|
+
"ui-pagination__item",
|
227
|
+
isEllipsis ? "ui-pagination__item--ellipsis" : void 0,
|
228
|
+
className
|
229
|
+
),
|
230
|
+
tabIndex: !isEllipsis ? 0 : -1,
|
231
|
+
__css: css,
|
232
|
+
...rest,
|
233
|
+
onPointerDown,
|
234
|
+
children: [
|
235
|
+
children,
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ripple.Ripple, { isDisabled: disableRipple || isDisabled, ...rippleProps })
|
237
|
+
]
|
238
|
+
}
|
239
|
+
);
|
240
|
+
}
|
241
|
+
);
|
240
242
|
PaginationItem.displayName = "PaginationItem";
|
241
243
|
PaginationItem.__ui__ = "PaginationItem";
|
242
244
|
|
@@ -255,13 +257,13 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
255
257
|
total,
|
256
258
|
withControls: _withControls = true,
|
257
259
|
withEdges: _withEdges = false,
|
260
|
+
containerProps,
|
258
261
|
controlNextProps,
|
259
262
|
controlPrevProps,
|
260
263
|
controlProps,
|
261
264
|
edgeFirstProps,
|
262
265
|
edgeLastProps,
|
263
266
|
edgeProps,
|
264
|
-
innerProps,
|
265
267
|
itemProps,
|
266
268
|
onChange: onChangeProp,
|
267
269
|
...rest
|
@@ -278,117 +280,113 @@ var Pagination = (0, import_core2.forwardRef)((props, ref) => {
|
|
278
280
|
onChange: onChangeProp
|
279
281
|
});
|
280
282
|
const children = (0, import_react2.useMemo)(
|
281
|
-
() => range.map((page2, key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
283
|
+
() => range.map((page2, key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.ui.li, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
282
284
|
Component,
|
283
285
|
{
|
284
|
-
"aria-label": page2
|
286
|
+
"aria-label": page2 !== "ellipsis" ? `Go to page ${page2}` : void 0,
|
285
287
|
isActive: currentPage === page2,
|
286
288
|
isDisabled,
|
287
|
-
page: page2,
|
288
289
|
...itemProps,
|
290
|
+
page: page2,
|
289
291
|
onClick: (0, import_utils3.handlerAll)(
|
290
292
|
itemProps == null ? void 0 : itemProps.onClick,
|
291
293
|
page2 !== "ellipsis" ? () => onChange(page2) : void 0
|
292
294
|
)
|
293
|
-
}
|
294
|
-
|
295
|
-
)),
|
295
|
+
}
|
296
|
+
) }, key)),
|
296
297
|
[Component, currentPage, isDisabled, onChange, range, itemProps]
|
297
298
|
);
|
298
299
|
const css = {
|
299
|
-
alignItems: "center",
|
300
|
-
display: "flex",
|
301
300
|
...styles.container
|
302
301
|
};
|
303
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PaginationProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime3.
|
304
|
-
import_core2.ui.
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PaginationProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
303
|
+
import_core2.ui.nav,
|
305
304
|
{
|
306
305
|
ref,
|
307
306
|
className: (0, import_utils3.cx)("ui-pagination", className),
|
308
|
-
role: "navigation",
|
309
|
-
__css: css,
|
310
|
-
...rest,
|
311
307
|
"data-disabled": (0, import_utils3.dataAttr)(isDisabled),
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
)
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
)
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
308
|
+
__css: css,
|
309
|
+
...containerProps,
|
310
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
311
|
+
import_core2.ui.ul,
|
312
|
+
{
|
313
|
+
className: "ui-pagination-inner",
|
314
|
+
"data-disabled": (0, import_utils3.dataAttr)(isDisabled),
|
315
|
+
__css: {
|
316
|
+
alignItems: "center",
|
317
|
+
display: "flex",
|
318
|
+
...styles.inner
|
319
|
+
},
|
320
|
+
...rest,
|
321
|
+
children: [
|
322
|
+
withEdges ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.ui.li, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
323
|
+
Component,
|
324
|
+
{
|
325
|
+
className: "ui-pagination__item--first",
|
326
|
+
"aria-label": "Go to first page",
|
327
|
+
isDisabled: isDisabled || currentPage === 1,
|
328
|
+
page: "first",
|
329
|
+
...edgeProps,
|
330
|
+
...edgeFirstProps,
|
331
|
+
onClick: (0, import_utils3.handlerAll)(
|
332
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
333
|
+
edgeFirstProps == null ? void 0 : edgeFirstProps.onClick,
|
334
|
+
onFirst
|
335
|
+
)
|
336
|
+
}
|
337
|
+
) }) : null,
|
338
|
+
withControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.ui.li, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
339
|
+
Component,
|
340
|
+
{
|
341
|
+
className: "ui-pagination__item--prev",
|
342
|
+
"aria-label": "Go to previous page",
|
343
|
+
isDisabled: isDisabled || currentPage === 1,
|
344
|
+
page: "prev",
|
345
|
+
...controlProps,
|
346
|
+
...controlPrevProps,
|
347
|
+
onClick: (0, import_utils3.handlerAll)(
|
348
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
349
|
+
controlPrevProps == null ? void 0 : controlPrevProps.onClick,
|
350
|
+
onPrev
|
351
|
+
)
|
352
|
+
}
|
353
|
+
) }) : null,
|
354
|
+
children,
|
355
|
+
withControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.ui.li, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
356
|
+
Component,
|
357
|
+
{
|
358
|
+
className: "ui-pagination__item--next",
|
359
|
+
"aria-label": "Go to next page",
|
360
|
+
isDisabled: isDisabled || currentPage === total,
|
361
|
+
page: "next",
|
362
|
+
...controlProps,
|
363
|
+
...controlNextProps,
|
364
|
+
onClick: (0, import_utils3.handlerAll)(
|
365
|
+
controlProps == null ? void 0 : controlProps.onClick,
|
366
|
+
controlNextProps == null ? void 0 : controlNextProps.onClick,
|
367
|
+
onNext
|
368
|
+
)
|
369
|
+
}
|
370
|
+
) }) : null,
|
371
|
+
withEdges ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.ui.li, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
372
|
+
Component,
|
373
|
+
{
|
374
|
+
className: "ui-pagination__item--last",
|
375
|
+
"aria-label": "Go to last page",
|
376
|
+
isDisabled: isDisabled || currentPage === total,
|
377
|
+
page: "last",
|
378
|
+
...edgeProps,
|
379
|
+
...edgeLastProps,
|
380
|
+
onClick: (0, import_utils3.handlerAll)(
|
381
|
+
edgeProps == null ? void 0 : edgeProps.onClick,
|
382
|
+
edgeLastProps == null ? void 0 : edgeLastProps.onClick,
|
383
|
+
onLast
|
384
|
+
)
|
385
|
+
}
|
386
|
+
) }) : null
|
387
|
+
]
|
388
|
+
}
|
389
|
+
)
|
392
390
|
}
|
393
391
|
) });
|
394
392
|
});
|