UNPKG

dgz-ui-shared

Version:

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

7 lines (6 loc) 4.31 kB
"use strict";const i=require("./jsx-runtime-h4oGeKUK.cjs"),x=require("./index-BL59b1Bz-COeLljOH.cjs"),p=require("react"),y=require("./button-CdZDBhmr-3yMPCRDo.cjs"),w=require("./chevron-right-HWBijj-I-CZBu0GKg.cjs"),I=require("./createLucideIcon-B950nf2d-DrrWmvZU.cjs"),l=require("./utils-B6fNqzRf-BNysSCt9.cjs"),n=require("./input-mask-DBLFIvhN-C_0RAR2l.cjs"),d=require("./useTranslation-CZf20ucv.cjs");function L(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 f=L(p);/** * @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 M=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],q=I.k("chevron-left",M),h=({className:s,...e})=>x.ae.jsx("nav",{role:"navigation","aria-label":"pagination",className:l.mo("flex w-full justify-center",s),...e});h.displayName="Pagination";const N=f.forwardRef(({className:s,...e},t)=>x.ae.jsx("ul",{ref:t,className:l.mo("flex flex-row items-center gap-1",s),...e}));N.displayName="PaginationContent";const m=f.forwardRef(({className:s,...e},t)=>x.ae.jsx("li",{ref:t,className:l.mo("",s),...e}));m.displayName="PaginationItem";const u=({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});u.displayName="PaginationLink";const v=({className:s,...e})=>x.ae.jsx(u,{"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"})});v.displayName="PaginationPrevious";const R=({className:s,...e})=>x.ae.jsx(u,{"aria-label":"Go to next page",size:"default",className:l.mo("gap-1 px-2.5",s),...e,children:x.ae.jsx(w.e,{className:"h-4 w-4"})});R.displayName="PaginationNext";const z=({currentPage:s=1,totalPages:e=0,onPageChange:t})=>{const{t:o}=d.useTranslation(),r=p.useCallback(()=>{const a=[];a.push(1),s-1>2&&a.push("...");for(let j=Math.max(2,s-1);j<=Math.min(e-1,s+1);j++)a.push(j);return s+1<e-1&&a.push("..."),e>1&&a.push(e),a},[s,e]),E=p.useMemo(()=>{const a=[];for(let c=0;c<e;c++)a.push({value:`${c+1}`,label:`${c+1}`});return a},[e]);return i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center justify-end gap-3 lg:flex-row",children:[i.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[i.jsxRuntimeExports.jsxs("div",{className:"min-w-20 font-semibold",children:[o("Go to page"),":"]}),i.jsxRuntimeExports.jsxs(n.Zx,{onValueChange:a=>t(parseInt(a)),value:`${s}`,children:[i.jsxRuntimeExports.jsx(n.jm,{className:"h-8.5 w-16",children:i.jsxRuntimeExports.jsx(n.Qx,{})}),i.jsxRuntimeExports.jsx(n.Um,{options:E})]})]}),i.jsxRuntimeExports.jsx(h,{className:"justify-end",children:i.jsxRuntimeExports.jsxs(N,{children:[i.jsxRuntimeExports.jsx(m,{children:i.jsxRuntimeExports.jsx(v,{isActive:s>1,size:"sm",className:l.mo(s>1?"disabled":"shadow"),onClick:()=>{s>1&&t(s-1)}})}),r().map((a,c)=>i.jsxRuntimeExports.jsx(m,{onClick:()=>{typeof a=="number"&&t(a)},children:i.jsxRuntimeExports.jsx(u,{size:"sm",className:l.mo("w-9 px-0 text-center",a===s&&"shadow"),isActive:a===s,children:a})},c)),i.jsxRuntimeExports.jsx(m,{children:i.jsxRuntimeExports.jsx(R,{size:"sm",onClick:()=>{s<e&&t(s+1)},className:l.mo(s<e?"disabled":"shadow"),isActive:s<e})})]})})]})},b=50,T=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],g=({defaultValue:s=b,options:e=T,onLimitChange:t})=>{const{t:o}=d.useTranslation();return i.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxRuntimeExports.jsxs("span",{className:"font-semibold",children:[o("Rows per page"),":"]}),i.jsxRuntimeExports.jsxs(n.Zx,{onValueChange:t,value:`${s}`,children:[i.jsxRuntimeExports.jsx(n.jm,{className:"h-8.5 w-17",children:i.jsxRuntimeExports.jsx(n.Qx,{})}),i.jsxRuntimeExports.jsx(n.Jh,{children:e==null?void 0:e.map(r=>i.jsxRuntimeExports.jsx(n.ed,{value:`${r.value}`,children:r.label},r.value))})]})]})};exports.DEFAULT_LIMIT=b;exports.MyLimitSelect=g;exports.MyPagination=z;