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