dgz-ui-shared
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library
7 lines (6 loc) • 4.3 kB
JavaScript
"use strict";const i=require("./jsx-runtime-DUiatUiq.cjs"),r=require("./index-DqTIeHVj-DlSOwhuZ.cjs"),p=require("react"),E=require("./button-Bp2lHjov-D9UnCnYX.cjs"),l=require("./utils-B6fNqzRf-BNysSCt9.cjs"),y=require("./chevron-right-HWBijj-I-Dp1SvzQb.cjs"),w=require("./createLucideIcon-B950nf2d-CFaVx9a3.cjs"),n=require("./radio-group-CqPTye2U-CXc2TUFE.cjs"),d=require("./useTranslation-CZf20ucv.cjs");function q(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>s[a]})}}return e.default=s,Object.freeze(e)}const f=q(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 T=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],I=w.k("chevron-left",T),h=({className:s,...e})=>r.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},a)=>r.ae.jsx("ul",{ref:a,className:l.mo("flex flex-row items-center gap-1",s),...e}));N.displayName="PaginationContent";const c=f.forwardRef(({className:s,...e},a)=>r.ae.jsx("li",{ref:a,className:l.mo("",s),...e}));c.displayName="PaginationItem";const u=({className:s,isActive:e,size:a="icon",...o})=>r.ae.jsx("a",{"aria-current":e?"page":void 0,className:l.mo(E.g({variant:e?"tertiary":"ghost",size:a}),"cursor-pointer",s),...o});u.displayName="PaginationLink";const R=({className:s,...e})=>r.ae.jsx(u,{"aria-label":"Go to previous page",size:"default",className:l.mo("gap-1 px-2.5",s),...e,children:r.ae.jsx(I,{className:"h-4 w-4"})});R.displayName="PaginationPrevious";const v=({className:s,...e})=>r.ae.jsx(u,{"aria-label":"Go to next page",size:"default",className:l.mo("gap-1 px-2.5",s),...e,children:r.ae.jsx(y.e,{className:"h-4 w-4"})});v.displayName="PaginationNext";const g=({currentPage:s=1,totalPages:e=0,onPageChange:a})=>{const{t:o}=d.useTranslation(),x=p.useCallback(()=>{const t=[];t.push(1),s-1>2&&t.push("...");for(let j=Math.max(2,s-1);j<=Math.min(e-1,s+1);j++)t.push(j);return s+1<e-1&&t.push("..."),e>1&&t.push(e),t},[s,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.xh,{onValueChange:t=>a(parseInt(t)),value:`${s}`,children:[i.jsxRuntimeExports.jsx(n.Ym,{className:"h-8.5 w-14",children:i.jsxRuntimeExports.jsx(n.Fh,{})}),i.jsxRuntimeExports.jsx(n.Wm,{children:new Array(e).fill(0).map((t,m)=>i.jsxRuntimeExports.jsx(n.Xm,{value:`${m+1}`,children:m+1},m+1))})]})]}),i.jsxRuntimeExports.jsx(h,{className:"justify-end",children:i.jsxRuntimeExports.jsxs(N,{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&&a(s-1)}})}),x().map((t,m)=>i.jsxRuntimeExports.jsx(c,{onClick:()=>{typeof t=="number"&&a(t)},children:i.jsxRuntimeExports.jsx(u,{size:"sm",className:l.mo("w-9 px-0 text-center",t===s&&"shadow"),isActive:t===s,children:t})},m)),i.jsxRuntimeExports.jsx(c,{children:i.jsxRuntimeExports.jsx(v,{size:"sm",onClick:()=>{s<e&&a(s+1)},className:l.mo(s<e?"disabled":"shadow"),isActive:s<e})})]})})]})},b=50,z=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],L=({defaultValue:s=b,options:e=z,onLimitChange:a})=>{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.xh,{onValueChange:a,value:`${s}`,children:[i.jsxRuntimeExports.jsx(n.Ym,{className:"h-8.5 w-17",children:i.jsxRuntimeExports.jsx(n.Fh,{})}),i.jsxRuntimeExports.jsx(n.Wm,{children:e==null?void 0:e.map(x=>i.jsxRuntimeExports.jsx(n.Xm,{value:`${x.value}`,children:x.label},x.value))})]})]})};exports.DEFAULT_LIMIT=b;exports.MyLimitSelect=L;exports.MyPagination=g;