UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

162 lines (158 loc) 6.79 kB
"use client"; "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // elements/pagination/index.ts var pagination_exports = {}; __export(pagination_exports, { Pagination: () => Pagination }); module.exports = __toCommonJS(pagination_exports); // elements/pagination/Pagination.tsx var import_react = __toESM(require("react")); var import_react_headless_pagination = require("react-headless-pagination"); // util/index.ts var import_clsx = require("clsx"); var import_tailwind_merge = require("tailwind-merge"); function cn(...inputs) { return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs)); } // elements/pagination/Pagination.tsx var Pagination = ({ direction, totalPages, currentPage }) => { const [page, setPage] = import_react.default.useState(currentPage || 0); const handlePageChange = (page2) => { setPage(page2); }; return /* @__PURE__ */ import_react.default.createElement( import_react_headless_pagination.Pagination, { totalPages, edgePageCount: 2, middlePagesSiblingCount: 1, currentPage: page, setCurrentPage: handlePageChange, className: "hawa-flex hawa-h-9 hawa-w-full hawa-select-none hawa-items-center hawa-text-sm hawa-transition-all", truncableText: "...", truncableClassName: "hawa-w-10 hawa-px-0.5 hawa-text-center" }, /* @__PURE__ */ import_react.default.createElement( import_react_headless_pagination.Pagination.PrevButton, { as: /* @__PURE__ */ import_react.default.createElement( "button", { "aria-label": "Previous Table Page", className: cn( "hawa-min-w-9 hawa-flex hawa-h-9 hawa-w-9 hawa-items-center hawa-justify-center hawa-rounded hawa-border hawa-bg-card", direction === "rtl" && "hawa-rotate-180" ), style: { minWidth: 36 } }, /* @__PURE__ */ import_react.default.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ import_react.default.createElement("path", { d: "m15 18-6-6 6-6" }) ) ), className: cn( "hawa-mr-2 hawa-flex hawa-items-center hawa-text-gray-500 hover:hawa-text-gray-600 dark:hover:hawa-text-gray-200", { "hawa-cursor-pointer": page !== 0, "hawa-opacity-50": page === 0 } ) }, "Previous" ), /* @__PURE__ */ import_react.default.createElement("nav", { className: "hawa-flex hawa-flex-grow hawa-justify-center" }, /* @__PURE__ */ import_react.default.createElement("ul", { className: "hawa-flex hawa-items-center hawa-gap-1" }, /* @__PURE__ */ import_react.default.createElement( import_react_headless_pagination.Pagination.PageButton, { className: "hawa-tap-highlight-transparent hawa-text-default-foreground data-[focus-visible=true]:hawa-outline-focus data-[disabled=true]:hawa-text-default-300 hawa-min-w-9 hawa-text-small hawa-box-border hawa-flex hawa-h-9 hawa-w-9 hawa-cursor-pointer hawa-touch-none hawa-select-none hawa-flex-wrap hawa-items-center hawa-justify-center hawa-truncate hawa-rounded hawa-border hawa-bg-card hawa-outline-none hawa-transition-all hover:hawa-scale-[1.1] data-[disabled=true]:hawa-pointer-events-none data-[focus-visible=true]:hawa-z-10 data-[pressed=true]:hawa-scale-[0.97] data-[focus-visible=true]:hawa-outline-2 data-[focus-visible=true]:hawa-outline-offset-2", activeClassName: "hawa-bg-primary hawa-text-primary-foreground hawa-transition-all" } ))), /* @__PURE__ */ import_react.default.createElement( import_react_headless_pagination.Pagination.NextButton, { as: /* @__PURE__ */ import_react.default.createElement( "button", { "aria-label": "Previous Table Page", className: cn( "hawa-min-w-9 hawa-flex hawa-h-9 hawa-w-9 hawa-items-center hawa-justify-center hawa-rounded hawa-border hawa-bg-card", direction === "ltr" && "hawa-rotate-180" ), style: { minWidth: 36 } }, /* @__PURE__ */ import_react.default.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ import_react.default.createElement("path", { d: "m15 18-6-6 6-6" }) ) ), className: cn( "hawa-mr-2 hawa-flex hawa-items-center hawa-text-gray-500 hover:hawa-text-gray-600 dark:hover:hawa-text-gray-200", { "hawa-cursor-pointer": page !== totalPages - 1, "hawa-opacity-50": page === totalPages - 1 } ) }, "Next" ) ); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Pagination }); //# sourceMappingURL=index.js.map