@yamada-ui/pagination
Version:
Yamada UI pagination component
171 lines (167 loc) • 7.7 kB
JavaScript
"use client"
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/pagination-item.tsx
var pagination_item_exports = {};
__export(pagination_item_exports, {
PaginationItem: () => PaginationItem
});
module.exports = __toCommonJS(pagination_item_exports);
var import_core = require("@yamada-ui/core");
var import_ripple = require("@yamada-ui/ripple");
var import_utils2 = require("@yamada-ui/utils");
// src/pagination-icon.tsx
var import_icon = require("@yamada-ui/icon");
var import_jsx_runtime = require("react/jsx-runtime");
var PaginationEllipsisIcon = (props) => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"path",
{
d: "M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z",
fill: "currentColor"
}
) });
};
PaginationEllipsisIcon.displayName = "PaginationEllipsisIcon";
PaginationEllipsisIcon.__ui__ = "PaginationEllipsisIcon";
var PaginationFirstIcon = (props) => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"path",
{
d: "M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z",
fill: "currentColor"
}
) });
};
PaginationFirstIcon.displayName = "PaginationFirstIcon";
PaginationFirstIcon.__ui__ = "PaginationFirstIcon";
var PaginationLastIcon = (props) => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"path",
{
d: "M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z",
fill: "currentColor"
}
) });
};
PaginationLastIcon.displayName = "PaginationLastIcon";
PaginationLastIcon.__ui__ = "PaginationLastIcon";
var PaginationPrevIcon = (props) => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"path",
{
d: "M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z",
fill: "currentColor"
}
) });
};
PaginationPrevIcon.displayName = "PaginationPrevIcon";
PaginationPrevIcon.__ui__ = "PaginationPrevIcon";
var PaginationNextIcon = (props) => {
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.Icon, { viewBox: "0 0 16 16", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"path",
{
d: "M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z",
fill: "currentColor"
}
) });
};
PaginationNextIcon.displayName = "PaginationNextIcon";
PaginationNextIcon.__ui__ = "PaginationNextIcon";
// src/use-pagination.ts
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
var import_use_value = require("@yamada-ui/use-value");
var import_utils = require("@yamada-ui/utils");
var import_react = require("react");
var [PaginationProvider, usePaginationContext] = (0, import_utils.createContext)({
name: "PaginationContext",
errorMessage: `usePaginationContext returned is 'undefined'. Seems you forgot to wrap the components in "<Pagination />"`
});
// src/pagination-item.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var iconMap = {
ellipsis: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationEllipsisIcon, {}),
first: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationFirstIcon, {}),
last: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationLastIcon, {}),
next: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationNextIcon, {}),
prev: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationPrevIcon, {})
};
var PaginationItem = (0, import_core.forwardRef)(
({
className,
isActive,
active = isActive,
page,
children = ((_a) => (_a = iconMap[page]) != null ? _a : page)(),
isDisabled,
disabled = isDisabled,
disableRipple,
...rest
}, ref) => {
const styles = usePaginationContext();
const ellipsis = page === "ellipsis";
const { onPointerDown, ...rippleProps } = (0, import_ripple.useRipple)({
...rest,
disabled: disableRipple || disabled || ellipsis
});
const css = {
alignItems: "center",
display: "flex",
justifyContent: "center",
overflow: "hidden",
position: "relative",
userSelect: "none",
...styles.item,
...styles[page]
};
const Component = import_core.ui[ellipsis ? "span" : "button"];
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
Component,
{
ref,
...!ellipsis ? {
type: "button",
"data-disabled": (0, import_utils2.dataAttr)(disabled),
"data-selected": (0, import_utils2.dataAttr)(active),
disabled
} : {},
className: (0, import_utils2.cx)(
"ui-pagination__item",
ellipsis ? "ui-pagination__item--ellipsis" : void 0,
className
),
tabIndex: !ellipsis ? 0 : -1,
__css: css,
...rest,
onPointerDown,
children: [
children,
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ripple.Ripple, { ...rippleProps })
]
}
);
}
);
PaginationItem.displayName = "PaginationItem";
PaginationItem.__ui__ = "PaginationItem";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PaginationItem
});
//# sourceMappingURL=pagination-item.js.map