UNPKG

dgz-ui-shared

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library

7 lines (6 loc) 4.33 kB
"use strict";const i=require("./jsx-runtime-DUiatUiq.cjs"),x=require("./index-DqTIeHVj-C_gsDkBV.cjs"),u=require("react"),y=require("./check-DE-1lGDl-C_ZPlJ0c.cjs"),l=require("./utils-D0f6bOsw-BmDOeWKv.cjs"),b=require("./chevron-right-HWBijj-I-Bal8Z7kb.cjs"),w=require("./createLucideIcon-B950nf2d-DnAaS9t0.cjs"),a=require("./select-BehdTDP2-DZ8kbyVp.cjs"),p=require("./useTranslation-CZf20ucv.cjs");function A(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const d=A(u);/** * @license lucide-react v0.511.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],q=w.k("chevron-left",g),f=({className:s,...e})=>x.ae.jsx("nav",{role:"navigation","aria-label":"pagination",className:l.mo("flex w-full justify-center",s),...e});f.displayName="Pagination";const h=d.forwardRef(({className:s,...e},t)=>x.ae.jsx("ul",{ref:t,className:l.mo("flex flex-row items-center gap-1",s),...e}));h.displayName="PaginationContent";const c=d.forwardRef(({className:s,...e},t)=>x.ae.jsx("li",{ref:t,className:l.mo("",s),...e}));c.displayName="PaginationItem";const m=({className:s,isActive:e,size:t="icon",...o})=>x.ae.jsx("a",{"aria-current":e?"page":void 0,className:l.mo(y.g({variant:e?"tertiary":"ghost",size:t}),"cursor-pointer",s),...o});m.displayName="PaginationLink";const R=({className:s,...e})=>x.ae.jsx(m,{"aria-label":"Go to previous page",size:"default",className:l.mo("gap-1 px-2.5",s),...e,children:x.ae.jsx(q,{className:"h-4 w-4"})});R.displayName="PaginationPrevious";const N=({className:s,...e})=>x.ae.jsx(m,{"aria-label":"Go to next page",size:"default",className:l.mo("gap-1 px-2.5",s),...e,children:x.ae.jsx(b.e,{className:"h-4 w-4"})});N.displayName="PaginationNext";const I=({currentPage:s=1,totalPages:e=0,onPageChange:t})=>{const{t:o}=p.useTranslation(),v=u.useCallback(()=>{const n=[];n.push(1),s-1>2&&n.push("...");for(let j=Math.max(2,s-1);j<=Math.min(e-1,s+1);j++)n.push(j);return s+1<e-1&&n.push("..."),e>1&&n.push(e),n},[s,e]);return i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col lg:flex-row items-center justify-end gap-3",children:[i.jsxRuntimeExports.jsxs("div",{className:"flex gap-3 text-sm items-center",children:[i.jsxRuntimeExports.jsxs("div",{className:"font-semibold min-w-20",children:[o("Go to page"),":"]}),i.jsxRuntimeExports.jsxs(a.Ax,{onValueChange:n=>t(parseInt(n)),defaultValue:"1",children:[i.jsxRuntimeExports.jsx(a.UA,{className:"w-14 h-8.5",children:i.jsxRuntimeExports.jsx(a.yx,{})}),i.jsxRuntimeExports.jsx(a.jA,{children:new Array(e).fill(0).map((n,r)=>i.jsxRuntimeExports.jsx(a.$A,{value:`${r+1}`,children:r+1},r+1))})]})]}),i.jsxRuntimeExports.jsx(f,{className:"justify-end",children:i.jsxRuntimeExports.jsxs(h,{children:[i.jsxRuntimeExports.jsx(c,{children:i.jsxRuntimeExports.jsx(R,{isActive:s>1,size:"sm",className:l.mo(s>1?"disabled":"shadow"),onClick:()=>{s>1&&t(s-1)}})}),v().map((n,r)=>i.jsxRuntimeExports.jsx(c,{onClick:()=>{typeof n=="number"&&t(n)},children:i.jsxRuntimeExports.jsx(m,{size:"sm",className:l.mo("w-9 text-center px-0",n===s&&"shadow"),isActive:n===s,children:n})},r)),i.jsxRuntimeExports.jsx(c,{children:i.jsxRuntimeExports.jsx(N,{size:"sm",onClick:()=>{s<e&&t(s+1)},className:l.mo(s<e?"disabled":"shadow"),isActive:s<e})})]})})]})},E=50,T=({defaultValue:s=E,onLimitChange:e})=>{const{t}=p.useTranslation();return i.jsxRuntimeExports.jsxs("div",{className:"flex gap-3 items-center",children:[i.jsxRuntimeExports.jsxs("span",{className:"font-semibold",children:[t("Rows per page"),":"]}),i.jsxRuntimeExports.jsxs(a.Ax,{onValueChange:o=>e(o),value:`${s}`,children:[i.jsxRuntimeExports.jsx(a.UA,{className:"w-17 h-8.5",children:i.jsxRuntimeExports.jsx(a.yx,{})}),i.jsxRuntimeExports.jsxs(a.jA,{children:[i.jsxRuntimeExports.jsx(a.$A,{value:"10",children:"10"}),i.jsxRuntimeExports.jsx(a.$A,{value:"20",children:"20"}),i.jsxRuntimeExports.jsx(a.$A,{value:"50",children:"50"}),i.jsxRuntimeExports.jsx(a.$A,{value:"100",children:"100"})]})]})]})};exports.DEFAULT_LIMIT=E;exports.MyLimitSelect=T;exports.MyPagination=I;