@tirth_jasoliya/ui 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data/data-template/data-template.cjs +1 -1
- package/dist/components/data/data-template/data-template.cjs.map +1 -1
- package/dist/components/data/data-template/data-template.js +1 -1
- package/dist/components/data/data-template/data-template.js.map +1 -1
- package/dist/components/data/data-template/index.cjs +1 -1
- package/dist/components/data/data-template/index.cjs.map +1 -1
- package/dist/components/data/data-template/index.js +1 -1
- package/dist/components/data/data-template/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import{useState as G,useEffect as Xe,useMemo as Te,useCallback as W,useRef as Mt}from"react";import{Loader2 as Ze}from"lucide-react";import{clsx as dt}from"clsx";import{twMerge as ct}from"tailwind-merge";function a(...e){return ct(dt(e))}import{jsx as Ee}from"react/jsx-runtime";function se({className:e,...t}){return Ee("div",{"data-slot":"card",className:a("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function le({className:e,...t}){return Ee("div",{"data-slot":"card-content",className:a("px-6",e),...t})}import{Slot as mt}from"radix-ui";import{cva as pt}from"class-variance-authority";import{jsx as ft}from"react/jsx-runtime";var ut=pt("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function f({className:e,variant:t,size:o,asChild:d=!1,...c}){let w=d?mt.Slot:"button";return ft(w,{"data-slot":"button",className:a(ut({variant:t,size:o,className:e}),"transition-none"),...c})}import{Checkbox as Ue}from"radix-ui";import{CheckIcon as gt}from"lucide-react";import{jsx as be}from"react/jsx-runtime";function We({className:e,...t}){return be(Ue.Root,{"data-slot":"checkbox",className:a("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:be(Ue.Indicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:be(gt,{className:"size-3.5"})})})}import{Search as yt,Download as wt,RefreshCw as St,Filter as Nt,ChevronDown as Tt,Settings2 as Pt}from"lucide-react";import{jsx as vt}from"react/jsx-runtime";function xe({className:e,type:t,...o}){return vt("input",{type:t,"data-slot":"input",className:a("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...o})}import{DropdownMenu as V}from"radix-ui";import{CheckIcon as uo,ChevronRightIcon as fo,CircleIcon as go}from"lucide-react";import{jsx as j,jsxs as xo}from"react/jsx-runtime";function he({...e}){return j(V.Root,{"data-slot":"dropdown-menu",...e})}function Ce({...e}){return j(V.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function ye({className:e,sideOffset:t=4,...o}){return j(V.Portal,{children:j(V.Content,{"data-slot":"dropdown-menu-content",sideOffset:t,className:a("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) rounded-md border p-1 shadow-md",e),...o})})}function U({className:e,inset:t,variant:o="default",...d}){return j(V.Item,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":o,className:a("cursor-pointer focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d})}function we({className:e,inset:t,...o}){return j(V.Label,{"data-slot":"dropdown-menu-label","data-inset":t,className:a("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...o})}function de({className:e,...t}){return j(V.Separator,{"data-slot":"dropdown-menu-separator",className:a("bg-border -mx-1 my-1 h-px",e),...t})}import{Select as S}from"radix-ui";import{CheckIcon as bt,ChevronDownIcon as qe,ChevronUpIcon as xt}from"lucide-react";import{jsx as x,jsxs as Se}from"react/jsx-runtime";function ce({...e}){return x(S.Root,{"data-slot":"select",...e})}function me({...e}){return x(S.Value,{"data-slot":"select-value",...e})}function pe({className:e,size:t="default",children:o,...d}){return Se(S.Trigger,{"data-slot":"select-trigger","data-size":t,className:a("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d,children:[o,x(S.Icon,{asChild:!0,children:x(qe,{className:"size-4 opacity-50"})})]})}function ue({className:e,children:t,position:o="popper",...d}){return x(S.Portal,{children:Se(S.Content,{"data-slot":"select-content",className:a("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:o,...d,children:[x(ht,{}),x(S.Viewport,{className:a("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),x(Ct,{})]})})}function te({className:e,children:t,...o}){return Se(S.Item,{"data-slot":"select-item",className:a("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...o,children:[x("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:x(S.ItemIndicator,{children:x(bt,{className:"size-4"})})}),x(S.ItemText,{children:t})]})}function ht({className:e,...t}){return x(S.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:a("flex cursor-default items-center justify-center py-1",e),...t,children:x(xt,{className:"size-4"})})}function Ct({className:e,...t}){return x(S.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:a("flex cursor-default items-center justify-center py-1",e),...t,children:x(qe,{className:"size-4"})})}import{Fragment as Dt,jsx as n,jsxs as g}from"react/jsx-runtime";function Ne({fields:e,filters:t,globalFilter:o,onGlobalFilterChange:d,fieldFilters:c,onFieldFilterChange:w,sortField:y,sortDirection:R,onSortChange:N,selectedCount:z,totalCount:M,visibleCount:B,onExport:A,onRefresh:h,loading:T,onClearFilters:u,onClearSorting:I}){let X=e.filter(r=>r.sortable),fe=Object.values(c).some(r=>r!=null&&r!=="")||o!=="",ae=y!=="";return n("div",{className:"rounded-xl p-0.5",children:n("div",{className:"px-2",children:n("div",{className:"flex flex-col gap-6",children:g("div",{className:"flex items-center justify-between",children:[n("div",{className:"flex items-center gap-3",children:t.length>0&&g("div",{className:"flex items-center gap-3 flex-wrap",children:[n("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:n(Nt,{className:"h-4 w-4"})}),t.map(r=>n("div",{className:"relative min-w-[150px]",children:r.type==="select"?g(ce,{value:c[r.key]||"all",onValueChange:v=>w(r.key,v),children:[r.icon&&n(r.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),n(pe,{className:a("h-9 rounded-lg w-full",r.icon&&"pl-9"),children:n(me,{placeholder:r.placeholder||"Select..."})}),g(ue,{className:"rounded-lg",children:[n(te,{value:"all",children:"All"}),r.options?.map(v=>n(te,{value:v.value,children:v.label},v.value))]})]}):g("div",{className:"relative",children:[r.icon&&n(r.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),n(xe,{type:r.type,placeholder:r.placeholder,value:c[r.key]||"",onChange:v=>w(r.key,v.target.value),className:a("h-9 rounded-lg",r.icon&&"pl-9")})]})},String(r.key)))]})}),g("div",{className:"flex items-center gap-2",children:[g("div",{className:"relative",children:[n(yt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n(xe,{placeholder:"Global search...",value:o,onChange:r=>d(r.target.value),className:"pl-9 h-9 rounded-lg max-w-max"})]}),X.length>0&&g(he,{children:[n(Ce,{asChild:!0,children:g(f,{variant:"outline",size:"sm",className:"rounded-lg gap-1",children:[n("span",{children:"Sort"}),n(Tt,{className:"h-4 w-4 opacity-50"})]})}),g(ye,{align:"end",className:"w-[200px] rounded-lg",children:[n(we,{children:"Sort By"}),n(de,{}),X.map(r=>g("div",{children:[g(U,{onClick:()=>N(r.key,"asc"),children:[r.label," (A-Z)"]}),g(U,{onClick:()=>N(r.key,"desc"),children:[r.label," (Z-A)"]})]},String(r.key))),ae&&g(Dt,{children:[n(de,{}),n(U,{onClick:I,children:"Clear All Sorting"})]})]})]}),g(he,{children:[n(Ce,{asChild:!0,children:n(f,{variant:"outline",size:"sm",className:"rounded-lg",children:n(Pt,{className:"h-4 w-4"})})}),g(ye,{align:"end",className:"w-[200px] rounded-lg",children:[n(we,{children:"Table Settings"}),n(de,{}),n(U,{onClick:I,children:"Clear All Sorting"}),n(U,{onClick:u,children:"Clear All Filters"})]})]}),A&&g(f,{variant:"outline",size:"sm",onClick:A,className:"rounded-lg",children:[n(wt,{className:"mr-2 h-4 w-4"}),"Export"]}),h&&n(f,{variant:"outline",size:"sm",onClick:h,disabled:T,className:"rounded-lg",children:n(St,{className:a("h-4 w-4",T&&"animate-spin")})})]})]})})})})}import{ChevronLeft as kt,ChevronRight as Rt,ChevronsLeft as zt,ChevronsRight as It}from"lucide-react";import{jsx as p,jsxs as k}from"react/jsx-runtime";function Ke({currentPage:e,totalPages:t,pageSize:o,totalItems:d,onPageChange:c,onPageSizeChange:w,config:y}){if(!y.enabled)return null;let R=y.pageSizeOptions||[10,20,50,100],N=(e-1)*o+1,z=Math.min(e*o,d),M=e>1,B=e<t,A=()=>{let T=[],u=[];for(let I=Math.max(2,e-2);I<=Math.min(t-1,e+2);I++)T.push(I);return e-2>2?u.push(1,"..."):u.push(1),u.push(...T),e+2<t-1?u.push("...",t):t>1&&u.push(t),u};return p("div",{className:"rounded-xl",children:k("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4",children:[p("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:y.showInfo!==!1&&k("span",{children:["Showing ",N," to ",z," of ",d," entries"]})}),k("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[R&&k("div",{className:"flex items-center gap-2",children:[p("span",{className:"text-sm font-medium whitespace-nowrap",children:"Page size:"}),k(ce,{value:`${o}`,onValueChange:h=>w(Number(h)),children:[p(pe,{className:"h-9 w-[70px] rounded-lg",children:p(me,{})}),p(ue,{side:"top",className:"rounded-lg",children:R.map(h=>p(te,{value:`${h}`,children:h},h))})]})]}),k("div",{className:"flex items-center gap-2",children:[k(f,{variant:"outline",size:"sm",onClick:()=>c(1),disabled:!M,className:"hidden sm:flex rounded-lg",children:[p(zt,{className:"h-4 w-4"}),p("span",{className:"sr-only",children:"Go to first page"})]}),k(f,{variant:"outline",size:"sm",onClick:()=>c(e-1),disabled:!M,className:"rounded-lg",children:[p(kt,{className:"h-4 w-4 sm:mr-2"}),p("span",{className:"hidden sm:inline",children:"Previous"}),p("span",{className:"sr-only sm:hidden",children:"Go to previous page"})]}),y.showPageNumbers&&t>1&&p("div",{className:"hidden sm:flex items-center gap-1",children:A().map((h,T)=>{if(h==="...")return p("span",{className:"px-2 py-1 text-sm text-muted-foreground",children:"..."},`dots-${T}`);let u=h;return p(f,{variant:u===e?"default":"outline",size:"sm",className:"w-9 h-9 p-0 rounded-lg",onClick:()=>c(u),children:u},u)})}),k("div",{className:"sm:hidden flex items-center gap-2 px-3 py-1 text-sm font-medium bg-muted rounded-lg",children:[e," of ",t]}),k(f,{variant:"outline",size:"sm",onClick:()=>c(e+1),disabled:!B,className:"rounded-lg",children:[p("span",{className:"hidden sm:inline",children:"Next"}),p(Rt,{className:"h-4 w-4 sm:ml-2"}),p("span",{className:"sr-only sm:hidden",children:"Go to next page"})]}),k(f,{variant:"outline",size:"sm",onClick:()=>c(t),disabled:!B,className:"hidden sm:flex rounded-lg",children:[p(It,{className:"h-4 w-4"}),p("span",{className:"sr-only",children:"Go to last page"})]})]})]})]})})}import{jsx as m,jsxs as $}from"react/jsx-runtime";function Bt({data:e,template:t,fields:o=[],filters:d=[],pagination:c={enabled:!1},settings:w={},header:y,footer:R,className:N="",loading:z=!1,error:M,emptyMessage:B="No items found",emptyIcon:A,onSelectionChange:h,onExport:T,onRefresh:u,onTemplateReady:I,children:X}){let{enableSorting:fe=!0,enableFiltering:ae=!0,enableGlobalSearch:r=!0,enableSelection:v=!1,enableExport:Qe=!1,toolbar:Ye=!0,selectionMode:Z="multiple",gridCols:et={default:3,sm:1,md:2,lg:3,xl:4,"2xl":6},gap:ze=4,aspectRatio:Ie="auto",minCardWidth:Me=350,maxCardWidth:Be=350}=w,[H,Ae]=G(""),[J,Fe]=G({}),[O,_e]=G(""),[Q,Ge]=G("asc"),[F,re]=G(new Set),[ne,ie]=G(1),[E,tt]=G(c.pageSize||12),[Le,Ut]=G(et.default),b=Te(()=>{let i=[...e];if(r&&H){let l=o.filter(s=>s.searchable!==!1);i=i.filter(s=>l.some(P=>s[P.key]?.toString().toLowerCase().includes(H.toLowerCase())))}if(ae&&Object.keys(J).forEach(l=>{let s=J[l];if(s!=null&&s!==""){let P=o.find(D=>D.key===l);P&&(i=i.filter(D=>{let _=D[l];return P.type==="boolean"?_===(s==="true"):P.type==="number"?_===Number(s):_?.toString().toLowerCase().includes(String(s).toLowerCase())}))}}),fe&&O){let l=o.find(s=>s.key===O);l&&i.sort((s,P)=>{let D=s[O],_=P[O];if(l.type==="number")return Q==="asc"?Number(D)-Number(_):Number(_)-Number(D);if(l.type==="date"){let Y=new Date(D),ee=new Date(_);return Q==="asc"?Y.getTime()-ee.getTime():ee.getTime()-Y.getTime()}else{let Y=String(D).toLowerCase(),ee=String(_).toLowerCase();return Q==="asc"?Y.localeCompare(ee):ee.localeCompare(Y)}})}return i},[e,H,J,O,Q,o,r,ae,fe]),Ve=Te(()=>{if(!c.enabled)return b;let i=(ne-1)*E,l=i+E;return b.slice(i,l)},[b,ne,E,c.enabled]),ot=Math.ceil(b.length/E),ge=W(i=>{v&&re(l=>{let s=new Set(l);return Z==="single"?(s.clear(),s.add(i)):s.has(i)?s.delete(i):s.add(i),s})},[v,Z]),je=W(()=>{!v||Z==="single"||(F.size===b.length?re(new Set):re(new Set(b.map((i,l)=>l))))},[v,Z,F.size,b.length]),at=W((i,l)=>{Fe(s=>({...s,[i]:l})),ie(1)},[]),rt=W((i,l)=>{_e(i),Ge(l)},[]),$e=W(()=>{Ae(""),Fe({}),ie(1)},[]),nt=W(()=>{_e(""),Ge("asc")},[]),Oe=Te(()=>({getSelectedItems:()=>Array.from(F).map(i=>b[i]),clearSelection:()=>re(new Set),selectAll:je,getFilteredData:()=>b,getTotalCount:()=>e.length,getVisibleCount:()=>b.length,refresh:()=>u?.(),exportData:()=>T?.(b)}),[F,b,e.length,je,u,T]),ve=Mt(null);ve.current=Oe,Xe(()=>{I&&ve.current&&I(ve.current)},[]),Xe(()=>{if(v&&h){let i=Array.from(F).map(l=>b[l]);h(i)}},[F]);let it=a("w-full","overflow-hidden",N),st=a("grid",`gap-${ze}`,"w-full","mx-auto","items-start"),lt={gridTemplateColumns:Le===0?`repeat(auto-fill, minmax(clamp(${Me}px, 30%, ${Be}px), 1fr))`:`repeat(auto-fill, minmax(clamp(${Me}px, calc(100%/${Le} - ${ze*4}px), ${Be}px), 1fr))`,justifyItems:"center",alignItems:"stretch",gridAutoRows:"1fr",gridAutoFlow:"dense"};return M?m(se,{className:"w-full",children:m(le,{className:"flex items-center justify-center py-12",children:$("div",{className:"text-center",children:[m("div",{className:"text-red-500 mb-3 text-2xl",children:"\u26A0\uFE0F"}),m("p",{className:"text-sm text-muted-foreground mb-4",children:M}),u&&$(f,{variant:"outline",size:"sm",onClick:u,children:[m(Ze,{className:"mr-2 h-4 w-4"}),"Try Again"]})]})})}):$("div",{className:a("w-full flex gap-2 flex-col h-full",it),children:[y&&m(se,{className:"shadow-sm border-0 py-0 text-xl font-bold",children:m(le,{className:"p-2",children:y})}),Ye&&m(Ne,{fields:o,filters:d,globalFilter:H,onGlobalFilterChange:Ae,fieldFilters:J,onFieldFilterChange:at,sortField:O,sortDirection:Q,onSortChange:rt,selectedCount:F.size,totalCount:e.length,visibleCount:b.length,onExport:Qe?()=>T?.(b):void 0,onRefresh:u,loading:z,onClearFilters:$e,onClearSorting:nt}),m(se,{className:"border-0 overflow-auto shadow-none py-0 p-2 flex-1",children:m(le,{className:"px-0",children:$("div",{className:"relative",children:[z&&m("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm z-50 flex items-center justify-center rounded-lg",children:$("div",{className:"flex items-center gap-3 bg-background/90 px-4 py-3 rounded-lg shadow-sm",children:[m(Ze,{className:"size-5 animate-spin text-primary"}),m("span",{className:"text-sm font-medium text-muted-foreground",children:"Loading..."})]})}),Ve.length>0?m("div",{className:a(st),style:lt,children:Ve.map((i,l)=>{let s=c.enabled?(ne-1)*E+l:l,P=F.has(s);return $("div",{className:a("relative h-full w-full flex flex-col","transition-all duration-200 overflow-hidden","rounded-2xl","border border-border/20 hover:border-border/50",Ie==="square"?"aspect-square":"",Ie==="video"?"aspect-video":"",v?"cursor-pointer":"",P?"ring-2 ring-primary":""),onClick:()=>v&&ge(s),children:[v&&Z==="multiple"&&m("div",{className:"absolute top-2 right-2 z-10",children:m(We,{checked:P,onCheckedChange:()=>ge(s),className:"bg-background/80 backdrop-blur-sm",onClick:D=>D.stopPropagation()})}),t(i,l,P,()=>ge(s))]},s)})}):$("div",{className:"flex flex-col gap-4 items-center justify-center py-12 text-center",children:[m("div",{className:"text-6xl",children:A||"\u{1F4CB}"}),m("p",{className:"text-lg font-medium text-muted-foreground mb-2",children:B}),(H||Object.values(J).some(i=>i))&&m(f,{variant:"outline",onClick:$e,children:"Clear Filters"})]})]})})}),c.enabled&&m("div",{className:"pb-1",children:m(Ke,{currentPage:ne,totalPages:ot,pageSize:E,totalItems:b.length,onPageChange:ie,onPageSizeChange:i=>{tt(i),ie(1)},config:c})}),R&&m("div",{className:"p-2 m-0.5",children:R}),X&&X(Oe)]})}import{Separator as At}from"radix-ui";import{jsx as Ft}from"react/jsx-runtime";function He({className:e,orientation:t="horizontal",decorative:o=!0,...d}){return Ft(At.Root,{"data-slot":"separator-root",decorative:o,orientation:t,className:a("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...d})}import{Tooltip as q}from"radix-ui";import{jsx as K,jsxs as _t}from"react/jsx-runtime";function Pe({delayDuration:e=0,...t}){return K(q.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function De({...e}){return K(Pe,{children:K(q.Root,{"data-slot":"tooltip",...e})})}function ke({...e}){return K(q.Trigger,{"data-slot":"tooltip-trigger",...e})}function Re({className:e,sideOffset:t=0,children:o,...d}){return K(q.Portal,{children:_t(q.Content,{"data-slot":"tooltip-content",sideOffset:t,className:a("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...d,children:[o,K(q.Arrow,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}import{Loader as Gt,X as Lt}from"lucide-react";import{AnimatePresence as Vt,motion as jt}from"framer-motion";import*as L from"react";import*as Je from"react-dom";import{jsx as C,jsxs as oe}from"react/jsx-runtime";function $t({controller:e,visible:t,container:o,children:d,className:c,...w}){let[y,R]=L.useState(!1);L.useLayoutEffect(()=>{R(!0)},[]),L.useEffect(()=>{function B(A){A.key==="Escape"&&e&&e.clearSelection()}return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);let N=o??(y?globalThis.document?.body:null);if(!N||!e)return null;let z=e.getSelectedItems(),M=t??z.length>0;return Je.createPortal(C(Vt,{children:M&&C(jt.div,{role:"toolbar","aria-orientation":"horizontal",initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.3,ease:"easeInOut"},className:a("fixed inset-x-0 bottom-6 z-50 mx-auto flex w-fit flex-wrap items-center justify-center gap-2 rounded-xl border bg-primary/10 backdrop-blur-sm p-3 text-foreground ring-8 ring-primary/5",c),...w,children:C(Pe,{children:d})})}),N)}function Ot({size:e="sm",variant:t="secondary",tooltip:o,isPending:d,disabled:c,className:w,children:y,onClick:R,...N}){let z=C(f,{variant:t,size:e,className:a("gap-1.5 rounded-lg border border-secondary bg-secondary/50 hover:bg-secondary/70 transition-all duration-200",e==="icon"?"size-8":"h-8 px-3",w),disabled:c||d,onClick:R,...N,children:d?C(Gt,{className:"animate-spin"}):y});return o?oe(De,{children:[C(ke,{asChild:!0,children:z}),C(Re,{sideOffset:8,className:"rounded-lg border font-semibold text-foreground bg-secondary [&>span]:hidden",children:C("p",{children:o})})]}):z}function Et({controller:e}){let t=L.useCallback(()=>{e&&e.clearSelection()},[e]);if(!e)return null;let o=e.getSelectedItems();return oe("div",{className:"flex h-8 items-center rounded-lg border bg-muted/50 pr-1 pl-3",children:[oe("span",{className:"whitespace-nowrap text-sm font-medium",children:[o.length," selected"]}),C(He,{orientation:"vertical",className:"mr-2 ml-3 data-[orientation=vertical]:h-4"}),oe(De,{children:[C(ke,{asChild:!0,children:C(f,{variant:"ghost",size:"icon",className:"size-6 rounded-md",onClick:t,children:C(Lt,{className:"size-3.5"})})}),oe(Re,{sideOffset:10,className:"flex items-center gap-2 rounded-lg border px-3 py-2 font-semibold text-foreground bg-secondary [&>span]:hidden",children:[C("p",{children:"Clear selection"}),C("kbd",{className:"select-none rounded border bg-primary/50 px-2 py-1 font-mono font-normal text-[0.7rem] text-foreground shadow-sm",children:C("abbr",{title:"Escape",className:"no-underline",children:"Esc"})})]})]})]})}export{Bt as DataTemplate,$t as DataTemplateActionBar,Ot as DataTemplateActionBarAction,Et as DataTemplateActionBarSelection,Ne as DataTemplateToolbar};
|
|
2
|
+
import{useState as G,useEffect as qe,useMemo as Te,useCallback as W,useRef as Mt}from"react";import{Loader2 as Ke}from"lucide-react";import{clsx as dt}from"clsx";import{twMerge as ct}from"tailwind-merge";function a(...e){return ct(dt(e))}import{jsx as Oe}from"react/jsx-runtime";function se({className:e,...t}){return Oe("div",{"data-slot":"card",className:a("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function le({className:e,...t}){return Oe("div",{"data-slot":"card-content",className:a("px-6",e),...t})}import{Slot as mt}from"radix-ui";import{cva as pt}from"class-variance-authority";import{jsx as ft}from"react/jsx-runtime";var ut=pt("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function f({className:e,variant:t,size:o,asChild:d=!1,...c}){let w=d?mt.Slot:"button";return ft(w,{"data-slot":"button",className:a(ut({variant:t,size:o,className:e}),"transition-none"),...c})}import{Checkbox as Ee}from"radix-ui";import{CheckIcon as gt}from"lucide-react";import{jsx as be}from"react/jsx-runtime";function $e({className:e,...t}){return be(Ee.Root,{"data-slot":"checkbox",className:a("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:be(Ee.Indicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:be(gt,{className:"size-3.5"})})})}import{Search as yt,Download as wt,RefreshCw as St,Filter as Nt,ChevronDown as Tt,Settings2 as Pt}from"lucide-react";import{jsx as vt}from"react/jsx-runtime";function xe({className:e,type:t,...o}){return vt("input",{type:t,"data-slot":"input",className:a("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...o})}import{DropdownMenu as V}from"radix-ui";import{CheckIcon as uo,ChevronRightIcon as fo,CircleIcon as go}from"lucide-react";import{jsx as j,jsxs as xo}from"react/jsx-runtime";function he({...e}){return j(V.Root,{"data-slot":"dropdown-menu",...e})}function Ce({...e}){return j(V.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function ye({className:e,sideOffset:t=4,...o}){return j(V.Portal,{children:j(V.Content,{"data-slot":"dropdown-menu-content",sideOffset:t,className:a("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) rounded-md border p-1 shadow-md",e),...o})})}function U({className:e,inset:t,variant:o="default",...d}){return j(V.Item,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":o,className:a("cursor-pointer focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d})}function we({className:e,inset:t,...o}){return j(V.Label,{"data-slot":"dropdown-menu-label","data-inset":t,className:a("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...o})}function de({className:e,...t}){return j(V.Separator,{"data-slot":"dropdown-menu-separator",className:a("bg-border -mx-1 my-1 h-px",e),...t})}import{Select as S}from"radix-ui";import{CheckIcon as bt,ChevronDownIcon as Ue,ChevronUpIcon as xt}from"lucide-react";import{jsx as x,jsxs as Se}from"react/jsx-runtime";function ce({...e}){return x(S.Root,{"data-slot":"select",...e})}function me({...e}){return x(S.Value,{"data-slot":"select-value",...e})}function pe({className:e,size:t="default",children:o,...d}){return Se(S.Trigger,{"data-slot":"select-trigger","data-size":t,className:a("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d,children:[o,x(S.Icon,{asChild:!0,children:x(Ue,{className:"size-4 opacity-50"})})]})}function ue({className:e,children:t,position:o="popper",...d}){return x(S.Portal,{children:Se(S.Content,{"data-slot":"select-content",className:a("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:o,...d,children:[x(ht,{}),x(S.Viewport,{className:a("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),x(Ct,{})]})})}function te({className:e,children:t,...o}){return Se(S.Item,{"data-slot":"select-item",className:a("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...o,children:[x("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:x(S.ItemIndicator,{children:x(bt,{className:"size-4"})})}),x(S.ItemText,{children:t})]})}function ht({className:e,...t}){return x(S.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:a("flex cursor-default items-center justify-center py-1",e),...t,children:x(xt,{className:"size-4"})})}function Ct({className:e,...t}){return x(S.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:a("flex cursor-default items-center justify-center py-1",e),...t,children:x(Ue,{className:"size-4"})})}import{Fragment as Dt,jsx as n,jsxs as g}from"react/jsx-runtime";function Ne({fields:e,filters:t,globalFilter:o,onGlobalFilterChange:d,fieldFilters:c,onFieldFilterChange:w,sortField:y,sortDirection:R,onSortChange:N,selectedCount:z,totalCount:M,visibleCount:B,onExport:A,onRefresh:h,loading:T,onClearFilters:u,onClearSorting:I}){let X=e.filter(r=>r.sortable),fe=Object.values(c).some(r=>r!=null&&r!=="")||o!=="",ae=y!=="";return n("div",{className:"rounded-xl p-0.5",children:n("div",{className:"px-2",children:n("div",{className:"flex flex-col gap-6",children:g("div",{className:"flex items-center justify-between",children:[n("div",{className:"flex items-center gap-3",children:t.length>0&&g("div",{className:"flex items-center gap-3 flex-wrap",children:[n("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:n(Nt,{className:"h-4 w-4"})}),t.map(r=>n("div",{className:"relative min-w-[150px]",children:r.type==="select"?g(ce,{value:c[r.key]||"all",onValueChange:v=>w(r.key,v),children:[r.icon&&n(r.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),n(pe,{className:a("h-9 rounded-lg w-full",r.icon&&"pl-9"),children:n(me,{placeholder:r.placeholder||"Select..."})}),g(ue,{className:"rounded-lg",children:[n(te,{value:"all",children:"All"}),r.options?.map(v=>n(te,{value:v.value,children:v.label},v.value))]})]}):g("div",{className:"relative",children:[r.icon&&n(r.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),n(xe,{type:r.type,placeholder:r.placeholder,value:c[r.key]||"",onChange:v=>w(r.key,v.target.value),className:a("h-9 rounded-lg",r.icon&&"pl-9")})]})},String(r.key)))]})}),g("div",{className:"flex items-center gap-2",children:[g("div",{className:"relative",children:[n(yt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n(xe,{placeholder:"Global search...",value:o,onChange:r=>d(r.target.value),className:"pl-9 h-9 rounded-lg max-w-max"})]}),X.length>0&&g(he,{children:[n(Ce,{asChild:!0,children:g(f,{variant:"outline",size:"sm",className:"rounded-lg gap-1",children:[n("span",{children:"Sort"}),n(Tt,{className:"h-4 w-4 opacity-50"})]})}),g(ye,{align:"end",className:"w-[200px] rounded-lg",children:[n(we,{children:"Sort By"}),n(de,{}),X.map(r=>g("div",{children:[g(U,{onClick:()=>N(r.key,"asc"),children:[r.label," (A-Z)"]}),g(U,{onClick:()=>N(r.key,"desc"),children:[r.label," (Z-A)"]})]},String(r.key))),ae&&g(Dt,{children:[n(de,{}),n(U,{onClick:I,children:"Clear All Sorting"})]})]})]}),g(he,{children:[n(Ce,{asChild:!0,children:n(f,{variant:"outline",size:"sm",className:"rounded-lg",children:n(Pt,{className:"h-4 w-4"})})}),g(ye,{align:"end",className:"w-[200px] rounded-lg",children:[n(we,{children:"Table Settings"}),n(de,{}),n(U,{onClick:I,children:"Clear All Sorting"}),n(U,{onClick:u,children:"Clear All Filters"})]})]}),A&&g(f,{variant:"outline",size:"sm",onClick:A,className:"rounded-lg",children:[n(wt,{className:"mr-2 h-4 w-4"}),"Export"]}),h&&n(f,{variant:"outline",size:"sm",onClick:h,disabled:T,className:"rounded-lg",children:n(St,{className:a("h-4 w-4",T&&"animate-spin")})})]})]})})})})}import{ChevronLeft as kt,ChevronRight as Rt,ChevronsLeft as zt,ChevronsRight as It}from"lucide-react";import{jsx as p,jsxs as k}from"react/jsx-runtime";function We({currentPage:e,totalPages:t,pageSize:o,totalItems:d,onPageChange:c,onPageSizeChange:w,config:y}){if(!y.enabled)return null;let R=y.pageSizeOptions||[10,20,50,100],N=(e-1)*o+1,z=Math.min(e*o,d),M=e>1,B=e<t,A=()=>{let T=[],u=[];for(let I=Math.max(2,e-2);I<=Math.min(t-1,e+2);I++)T.push(I);return e-2>2?u.push(1,"..."):u.push(1),u.push(...T),e+2<t-1?u.push("...",t):t>1&&u.push(t),u};return p("div",{className:"rounded-xl",children:k("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4",children:[p("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:y.showInfo!==!1&&k("span",{children:["Showing ",N," to ",z," of ",d," entries"]})}),k("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[R&&k("div",{className:"flex items-center gap-2",children:[p("span",{className:"text-sm font-medium whitespace-nowrap",children:"Page size:"}),k(ce,{value:`${o}`,onValueChange:h=>w(Number(h)),children:[p(pe,{className:"h-9 w-[70px] rounded-lg",children:p(me,{})}),p(ue,{side:"top",className:"rounded-lg",children:R.map(h=>p(te,{value:`${h}`,children:h},h))})]})]}),k("div",{className:"flex items-center gap-2",children:[k(f,{variant:"outline",size:"sm",onClick:()=>c(1),disabled:!M,className:"hidden sm:flex rounded-lg",children:[p(zt,{className:"h-4 w-4"}),p("span",{className:"sr-only",children:"Go to first page"})]}),k(f,{variant:"outline",size:"sm",onClick:()=>c(e-1),disabled:!M,className:"rounded-lg",children:[p(kt,{className:"h-4 w-4 sm:mr-2"}),p("span",{className:"hidden sm:inline",children:"Previous"}),p("span",{className:"sr-only sm:hidden",children:"Go to previous page"})]}),y.showPageNumbers&&t>1&&p("div",{className:"hidden sm:flex items-center gap-1",children:A().map((h,T)=>{if(h==="...")return p("span",{className:"px-2 py-1 text-sm text-muted-foreground",children:"..."},`dots-${T}`);let u=h;return p(f,{variant:u===e?"default":"outline",size:"sm",className:"w-9 h-9 p-0 rounded-lg",onClick:()=>c(u),children:u},u)})}),k("div",{className:"sm:hidden flex items-center gap-2 px-3 py-1 text-sm font-medium bg-muted rounded-lg",children:[e," of ",t]}),k(f,{variant:"outline",size:"sm",onClick:()=>c(e+1),disabled:!B,className:"rounded-lg",children:[p("span",{className:"hidden sm:inline",children:"Next"}),p(Rt,{className:"h-4 w-4 sm:ml-2"}),p("span",{className:"sr-only sm:hidden",children:"Go to next page"})]}),k(f,{variant:"outline",size:"sm",onClick:()=>c(t),disabled:!B,className:"hidden sm:flex rounded-lg",children:[p(It,{className:"h-4 w-4"}),p("span",{className:"sr-only",children:"Go to last page"})]})]})]})]})})}import{jsx as m,jsxs as O}from"react/jsx-runtime";function Bt({data:e,template:t,fields:o=[],filters:d=[],pagination:c={enabled:!1},settings:w={},header:y,footer:R,className:N="",loading:z=!1,error:M,emptyMessage:B="No items found",emptyIcon:A,onSelectionChange:h,onExport:T,onRefresh:u,onTemplateReady:I,children:X}){let{enableSorting:fe=!0,enableFiltering:ae=!0,enableGlobalSearch:r=!0,enableSelection:v=!1,enableExport:He=!1,toolbar:Je=!0,selectionMode:Z="multiple",gridCols:Qe={default:3,sm:1,md:2,lg:3,xl:4,"2xl":6},gap:ze=4,aspectRatio:Ie="auto",minCardWidth:Ye=350,maxCardWidth:et=350}=w,[H,Me]=G(""),[J,Be]=G({}),[E,Ae]=G(""),[Q,Fe]=G("asc"),[F,re]=G(new Set),[ne,ie]=G(1),[$,tt]=G(c.pageSize||12),[_e,Ut]=G(Qe.default),b=Te(()=>{let i=[...e];if(r&&H){let l=o.filter(s=>s.searchable!==!1);i=i.filter(s=>l.some(P=>s[P.key]?.toString().toLowerCase().includes(H.toLowerCase())))}if(ae&&Object.keys(J).forEach(l=>{let s=J[l];if(s!=null&&s!==""){let P=o.find(D=>D.key===l);P&&(i=i.filter(D=>{let _=D[l];return P.type==="boolean"?_===(s==="true"):P.type==="number"?_===Number(s):_?.toString().toLowerCase().includes(String(s).toLowerCase())}))}}),fe&&E){let l=o.find(s=>s.key===E);l&&i.sort((s,P)=>{let D=s[E],_=P[E];if(l.type==="number")return Q==="asc"?Number(D)-Number(_):Number(_)-Number(D);if(l.type==="date"){let Y=new Date(D),ee=new Date(_);return Q==="asc"?Y.getTime()-ee.getTime():ee.getTime()-Y.getTime()}else{let Y=String(D).toLowerCase(),ee=String(_).toLowerCase();return Q==="asc"?Y.localeCompare(ee):ee.localeCompare(Y)}})}return i},[e,H,J,E,Q,o,r,ae,fe]),Ge=Te(()=>{if(!c.enabled)return b;let i=(ne-1)*$,l=i+$;return b.slice(i,l)},[b,ne,$,c.enabled]),ot=Math.ceil(b.length/$),ge=W(i=>{v&&re(l=>{let s=new Set(l);return Z==="single"?(s.clear(),s.add(i)):s.has(i)?s.delete(i):s.add(i),s})},[v,Z]),Le=W(()=>{!v||Z==="single"||(F.size===b.length?re(new Set):re(new Set(b.map((i,l)=>l))))},[v,Z,F.size,b.length]),at=W((i,l)=>{Be(s=>({...s,[i]:l})),ie(1)},[]),rt=W((i,l)=>{Ae(i),Fe(l)},[]),Ve=W(()=>{Me(""),Be({}),ie(1)},[]),nt=W(()=>{Ae(""),Fe("asc")},[]),je=Te(()=>({getSelectedItems:()=>Array.from(F).map(i=>b[i]),clearSelection:()=>re(new Set),selectAll:Le,getFilteredData:()=>b,getTotalCount:()=>e.length,getVisibleCount:()=>b.length,refresh:()=>u?.(),exportData:()=>T?.(b)}),[F,b,e.length,Le,u,T]),ve=Mt(null);ve.current=je,qe(()=>{I&&ve.current&&I(ve.current)},[]),qe(()=>{if(v&&h){let i=Array.from(F).map(l=>b[l]);h(i)}},[F]);let it=a("w-full","overflow-hidden",N),st=a("grid",`gap-${ze}`,"w-full","mx-auto","items-start"),lt={gridTemplateColumns:_e===0?"repeat(auto-fill, 1fr)":`repeat(auto-fill, minmax(clamp(${Ye}px, calc(100%/${_e} - ${ze*4}px), ${et}px), 1fr))`,justifyItems:"center",alignItems:"stretch",gridAutoRows:"1fr",gridAutoFlow:"dense"};return M?m(se,{className:"w-full",children:m(le,{className:"flex items-center justify-center py-12",children:O("div",{className:"text-center",children:[m("div",{className:"text-red-500 mb-3 text-2xl",children:"\u26A0\uFE0F"}),m("p",{className:"text-sm text-muted-foreground mb-4",children:M}),u&&O(f,{variant:"outline",size:"sm",onClick:u,children:[m(Ke,{className:"mr-2 h-4 w-4"}),"Try Again"]})]})})}):O("div",{className:a("w-full flex gap-2 flex-col h-full",it),children:[y&&m(se,{className:"shadow-sm border-0 py-0 text-xl font-bold",children:m(le,{className:"p-2",children:y})}),Je&&m(Ne,{fields:o,filters:d,globalFilter:H,onGlobalFilterChange:Me,fieldFilters:J,onFieldFilterChange:at,sortField:E,sortDirection:Q,onSortChange:rt,selectedCount:F.size,totalCount:e.length,visibleCount:b.length,onExport:He?()=>T?.(b):void 0,onRefresh:u,loading:z,onClearFilters:Ve,onClearSorting:nt}),m(se,{className:"border-0 overflow-auto shadow-none py-0 p-2 flex-1",children:m(le,{className:"px-0",children:O("div",{className:"relative",children:[z&&m("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm z-50 flex items-center justify-center rounded-lg",children:O("div",{className:"flex items-center gap-3 bg-background/90 px-4 py-3 rounded-lg shadow-sm",children:[m(Ke,{className:"size-5 animate-spin text-primary"}),m("span",{className:"text-sm font-medium text-muted-foreground",children:"Loading..."})]})}),Ge.length>0?m("div",{className:a(st),style:lt,children:Ge.map((i,l)=>{let s=c.enabled?(ne-1)*$+l:l,P=F.has(s);return O("div",{className:a("relative h-full w-full flex flex-col","transition-all duration-200 overflow-hidden","rounded-2xl","border border-border/20 hover:border-border/50",Ie==="square"?"aspect-square":"",Ie==="video"?"aspect-video":"",v?"cursor-pointer":"",P?"ring-2 ring-primary":""),onClick:()=>v&&ge(s),children:[v&&Z==="multiple"&&m("div",{className:"absolute top-2 right-2 z-10",children:m($e,{checked:P,onCheckedChange:()=>ge(s),className:"bg-background/80 backdrop-blur-sm",onClick:D=>D.stopPropagation()})}),t(i,l,P,()=>ge(s))]},s)})}):O("div",{className:"flex flex-col gap-4 items-center justify-center py-12 text-center",children:[m("div",{className:"text-6xl",children:A||"\u{1F4CB}"}),m("p",{className:"text-lg font-medium text-muted-foreground mb-2",children:B}),(H||Object.values(J).some(i=>i))&&m(f,{variant:"outline",onClick:Ve,children:"Clear Filters"})]})]})})}),c.enabled&&m("div",{className:"pb-1",children:m(We,{currentPage:ne,totalPages:ot,pageSize:$,totalItems:b.length,onPageChange:ie,onPageSizeChange:i=>{tt(i),ie(1)},config:c})}),R&&m("div",{className:"p-2 m-0.5",children:R}),X&&X(je)]})}import{Separator as At}from"radix-ui";import{jsx as Ft}from"react/jsx-runtime";function Xe({className:e,orientation:t="horizontal",decorative:o=!0,...d}){return Ft(At.Root,{"data-slot":"separator-root",decorative:o,orientation:t,className:a("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...d})}import{Tooltip as q}from"radix-ui";import{jsx as K,jsxs as _t}from"react/jsx-runtime";function Pe({delayDuration:e=0,...t}){return K(q.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function De({...e}){return K(Pe,{children:K(q.Root,{"data-slot":"tooltip",...e})})}function ke({...e}){return K(q.Trigger,{"data-slot":"tooltip-trigger",...e})}function Re({className:e,sideOffset:t=0,children:o,...d}){return K(q.Portal,{children:_t(q.Content,{"data-slot":"tooltip-content",sideOffset:t,className:a("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...d,children:[o,K(q.Arrow,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}import{Loader as Gt,X as Lt}from"lucide-react";import{AnimatePresence as Vt,motion as jt}from"framer-motion";import*as L from"react";import*as Ze from"react-dom";import{jsx as C,jsxs as oe}from"react/jsx-runtime";function Ot({controller:e,visible:t,container:o,children:d,className:c,...w}){let[y,R]=L.useState(!1);L.useLayoutEffect(()=>{R(!0)},[]),L.useEffect(()=>{function B(A){A.key==="Escape"&&e&&e.clearSelection()}return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);let N=o??(y?globalThis.document?.body:null);if(!N||!e)return null;let z=e.getSelectedItems(),M=t??z.length>0;return Ze.createPortal(C(Vt,{children:M&&C(jt.div,{role:"toolbar","aria-orientation":"horizontal",initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.3,ease:"easeInOut"},className:a("fixed inset-x-0 bottom-6 z-50 mx-auto flex w-fit flex-wrap items-center justify-center gap-2 rounded-xl border bg-primary/10 backdrop-blur-sm p-3 text-foreground ring-8 ring-primary/5",c),...w,children:C(Pe,{children:d})})}),N)}function Et({size:e="sm",variant:t="secondary",tooltip:o,isPending:d,disabled:c,className:w,children:y,onClick:R,...N}){let z=C(f,{variant:t,size:e,className:a("gap-1.5 rounded-lg border border-secondary bg-secondary/50 hover:bg-secondary/70 transition-all duration-200",e==="icon"?"size-8":"h-8 px-3",w),disabled:c||d,onClick:R,...N,children:d?C(Gt,{className:"animate-spin"}):y});return o?oe(De,{children:[C(ke,{asChild:!0,children:z}),C(Re,{sideOffset:8,className:"rounded-lg border font-semibold text-foreground bg-secondary [&>span]:hidden",children:C("p",{children:o})})]}):z}function $t({controller:e}){let t=L.useCallback(()=>{e&&e.clearSelection()},[e]);if(!e)return null;let o=e.getSelectedItems();return oe("div",{className:"flex h-8 items-center rounded-lg border bg-muted/50 pr-1 pl-3",children:[oe("span",{className:"whitespace-nowrap text-sm font-medium",children:[o.length," selected"]}),C(Xe,{orientation:"vertical",className:"mr-2 ml-3 data-[orientation=vertical]:h-4"}),oe(De,{children:[C(ke,{asChild:!0,children:C(f,{variant:"ghost",size:"icon",className:"size-6 rounded-md",onClick:t,children:C(Lt,{className:"size-3.5"})})}),oe(Re,{sideOffset:10,className:"flex items-center gap-2 rounded-lg border px-3 py-2 font-semibold text-foreground bg-secondary [&>span]:hidden",children:[C("p",{children:"Clear selection"}),C("kbd",{className:"select-none rounded border bg-primary/50 px-2 py-1 font-mono font-normal text-[0.7rem] text-foreground shadow-sm",children:C("abbr",{title:"Escape",className:"no-underline",children:"Esc"})})]})]})]})}export{Bt as DataTemplate,Ot as DataTemplateActionBar,Et as DataTemplateActionBarAction,$t as DataTemplateActionBarSelection,Ne as DataTemplateToolbar};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|