@akshar-technosoft/ui 1.0.7 → 1.0.8

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
- import{flexRender as Xe,getCoreRowModel as To,getFilteredRowModel as zo,getPaginationRowModel as Mo,getSortedRowModel as Ro,useReactTable as Io}from"@tanstack/react-table";import{Loader2 as zt,ChevronUp as Ke,ChevronDown as Qe,ChevronsUpDown as _o,MoreHorizontal as Fo,MoveRightIcon as Vo,PinOffIcon as Bo}from"lucide-react";import{Slot as Xt}from"radix-ui";import{cva as Kt}from"class-variance-authority";import{clsx as qt}from"clsx";import{twMerge as Jt}from"tailwind-merge";function o(...e){return Jt(qt(e))}import{jsx as Qt}from"react/jsx-runtime";var we=Kt("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 w({className:e,variant:a,size:i,asChild:p=!1,...P}){let x=p?Xt.Slot:"button";return Qt(x,{"data-slot":"button",className:o(we({variant:a,size:i,className:e}),"transition-none"),...P})}import{jsx as K}from"react/jsx-runtime";function Oe({className:e,...a}){return K("div",{"data-slot":"table-container",className:"relative w-full overflow-auto max-h-full",children:K("table",{"data-slot":"table",className:o("w-full caption-bottom text-sm",e),...a})})}function dt({className:e,...a}){return K("thead",{"data-slot":"table-header",className:o("[&_tr]:border-b",e),...a})}function ct({className:e,...a}){return K("tbody",{"data-slot":"table-body",className:o("[&_tr:last-child]:border-0",e),...a})}function ut({className:e,...a}){return K("tfoot",{"data-slot":"table-footer",className:o("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",e),...a})}function de({className:e,...a}){return K("tr",{"data-slot":"table-row",className:o("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...a})}function mt({className:e,...a}){return K("th",{"data-slot":"table-head",className:o("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap",e),...a})}function ye({className:e,...a}){return K("td",{"data-slot":"table-cell",className:o("p-2 align-middle whitespace-nowrap",e),...a})}import{jsx as pt}from"react/jsx-runtime";function Pe({className:e,...a}){return pt("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...a})}function Ne({className:e,...a}){return pt("div",{"data-slot":"card-content",className:o("px-6",e),...a})}import{Tooltip as Yt}from"radix-ui";import{jsx as Zt,jsxs as tn}from"react/jsx-runtime";function gt({delayDuration:e=0,...a}){return Zt(Yt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...a})}import{Search as yt,RefreshCw as fo,Download as bo,Settings2 as vo,Filter as Pt,ArrowUpDown as xo,PinOff as ho,Pin as Co,ChevronDown as wo}from"lucide-react";import{jsx as eo}from"react/jsx-runtime";function je({className:e,type:a,...i}){return eo("input",{type:a,"data-slot":"input",className:o("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),...i})}import{Select as B}from"radix-ui";import{CheckIcon as to,ChevronDownIcon as ft,ChevronUpIcon as oo}from"lucide-react";import{jsx as z,jsxs as Ue}from"react/jsx-runtime";function Se({...e}){return z(B.Root,{"data-slot":"select",...e})}function De({...e}){return z(B.Value,{"data-slot":"select-value",...e})}function ke({className:e,size:a="default",children:i,...p}){return Ue(B.Trigger,{"data-slot":"select-trigger","data-size":a,className:o("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),...p,children:[i,z(B.Icon,{asChild:!0,children:z(ft,{className:"size-4 opacity-50"})})]})}function Te({className:e,children:a,position:i="popper",...p}){return z(B.Portal,{children:Ue(B.Content,{"data-slot":"select-content",className:o("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",i==="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:i,...p,children:[z(no,{}),z(B.Viewport,{className:o("p-1",i==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),z(ao,{})]})})}function ce({className:e,children:a,...i}){return Ue(B.Item,{"data-slot":"select-item",className:o("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),...i,children:[z("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:z(B.ItemIndicator,{children:z(to,{className:"size-4"})})}),z(B.ItemText,{children:a})]})}function no({className:e,...a}){return z(B.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:o("flex cursor-default items-center justify-center py-1",e),...a,children:z(oo,{className:"size-4"})})}function ao({className:e,...a}){return z(B.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:o("flex cursor-default items-center justify-center py-1",e),...a,children:z(ft,{className:"size-4"})})}import{DropdownMenu as O}from"radix-ui";import{CheckIcon as ro,ChevronRightIcon as gn,CircleIcon as fn}from"lucide-react";import{jsx as G,jsxs as io}from"react/jsx-runtime";function ue({...e}){return G(O.Root,{"data-slot":"dropdown-menu",...e})}function me({...e}){return G(O.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function pe({className:e,sideOffset:a=4,...i}){return G(O.Portal,{children:G(O.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,className:o("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),...i})})}function Ee({...e}){return G(O.Group,{"data-slot":"dropdown-menu-group",...e})}function A({className:e,inset:a,variant:i="default",...p}){return G(O.Item,{"data-slot":"dropdown-menu-item","data-inset":a,"data-variant":i,className:o("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),...p})}function $e({className:e,children:a,checked:i,...p}){return io(O.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:o("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 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",e),checked:i,...p,children:[G("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:G(O.ItemIndicator,{children:G(ro,{className:"size-4"})})}),a]})}function U({className:e,inset:a,...i}){return G(O.Label,{"data-slot":"dropdown-menu-label","data-inset":a,className:o("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...i})}function Z({className:e,...a}){return G(O.Separator,{"data-slot":"dropdown-menu-separator",className:o("bg-border -mx-1 my-1 h-px",e),...a})}import{useState as Nt}from"react";import{useEffect as po,useState as We}from"react";import{Calendar as go}from"lucide-react";import{format as ge}from"date-fns";import{Popover as ze}from"radix-ui";import{jsx as Me}from"react/jsx-runtime";function bt({...e}){return Me(ze.Root,{"data-slot":"popover",...e})}function vt({...e}){return Me(ze.Trigger,{"data-slot":"popover-trigger",...e})}function xt({className:e,align:a="center",sideOffset:i=4,...p}){return Me(ze.Portal,{children:Me(ze.Content,{"data-slot":"popover-content",align:a,sideOffset:i,className:o("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 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...p})})}import*as Re from"react";import{ChevronDownIcon as so,ChevronLeftIcon as lo,ChevronRightIcon as co}from"lucide-react";import{DayPicker as uo,getDefaultClassNames as ht}from"react-day-picker";import{jsx as Q}from"react/jsx-runtime";function Ct({className:e,classNames:a,showOutsideDays:i=!0,captionLayout:p="label",buttonVariant:P="ghost",formatters:x,components:I,...$}){let b=ht();return Q(uo,{showOutsideDays:i,className:o("bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:p,formatters:{formatMonthDropdown:C=>C.toLocaleString("default",{month:"short"}),...x},classNames:{root:o("w-fit",b.root),months:o("flex gap-4 flex-col md:flex-row relative",b.months),month:o("flex flex-col w-full gap-4",b.month),nav:o("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",b.nav),button_previous:o(we({variant:P}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",b.button_previous),button_next:o(we({variant:P}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",b.button_next),month_caption:o("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",b.month_caption),dropdowns:o("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",b.dropdowns),dropdown_root:o("relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",b.dropdown_root),dropdown:o("absolute bg-popover inset-0 opacity-0",b.dropdown),caption_label:o("select-none font-medium",p==="label"?"text-sm":"rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",b.caption_label),table:"w-full border-collapse",weekdays:o("flex",b.weekdays),weekday:o("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",b.weekday),week:o("flex w-full mt-2",b.week),week_number_header:o("select-none w-(--cell-size)",b.week_number_header),week_number:o("text-[0.8rem] select-none text-muted-foreground",b.week_number),day:o("relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",b.day),range_start:o("rounded-l-md bg-accent",b.range_start),range_middle:o("rounded-none",b.range_middle),range_end:o("rounded-r-md bg-accent",b.range_end),today:o("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",b.today),outside:o("text-muted-foreground aria-selected:text-muted-foreground",b.outside),disabled:o("text-muted-foreground opacity-50",b.disabled),hidden:o("invisible",b.hidden),...a},components:{Root:({className:C,rootRef:k,...F})=>Q("div",{"data-slot":"calendar",ref:k,className:o(C),...F}),Chevron:({className:C,orientation:k,...F})=>k==="left"?Q(lo,{className:o("size-4",C),...F}):k==="right"?Q(co,{className:o("size-4",C),...F}):Q(so,{className:o("size-4",C),...F}),DayButton:mo,WeekNumber:({children:C,...k})=>Q("td",{...k,children:Q("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:C})}),...I},...$})}function mo({className:e,day:a,modifiers:i,...p}){let P=ht(),x=Re.useRef(null);return Re.useEffect(()=>{i.focused&&x.current?.focus()},[i.focused]),Q(w,{ref:x,variant:"ghost",size:"icon","data-day":a.date.toLocaleDateString(),"data-selected-single":i.selected&&!i.range_start&&!i.range_end&&!i.range_middle,"data-range-start":i.range_start,"data-range-end":i.range_end,"data-range-middle":i.range_middle,className:o("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",P.day,e),...p})}import{jsx as ee,jsxs as fe}from"react/jsx-runtime";function wt({value:e,onChange:a,placeholder:i,mode:p,externalSearch:P,onExternalChange:x,onlyExternal:I=!1}){let[$,b]=We(!1),[C,k]=We(e),[F,S]=We(e);po(()=>{I||S(e)},[e,I]);let W=()=>{I||a(C),S(C),P&&x&&x(C),b(!1)},H=()=>{k(F),b(!1)},q=()=>{let g=p==="single"?null:{from:null,to:null};k(g),I||a(g),S(g),P&&x&&x(g),b(!1)},J=()=>{let g=I?F:e;return g?p==="single"?ge(g,"PPP"):g.from&&g.to?`${ge(g.from,"MMM dd")} - ${ge(g.to,"MMM dd, yyyy")}`:g.from?`From ${ge(g.from,"MMM dd, yyyy")}`:g.to?`To ${ge(g.to,"MMM dd, yyyy")}`:i:i},M=g=>{k(p==="single"?g:g||{from:null,to:null})};return fe(bt,{open:$,onOpenChange:b,children:[ee(vt,{asChild:!0,children:fe(w,{variant:"outline",className:o("w-full justify-start text-left font-normal h-9",!J()&&"text-muted-foreground"),children:[ee(go,{className:"mr-2 h-4 w-4"}),J()]})}),fe(xt,{className:"w-auto p-0",align:"start",children:[ee("div",{className:"p-3",children:ee(Ct,{mode:p,selected:C,onSelect:M,numberOfMonths:p==="range"?2:1,className:"rounded-md border",...p==="range"&&{required:!0}})}),fe("div",{className:"flex items-center justify-between p-3 border-t",children:[ee(w,{variant:"ghost",size:"sm",onClick:q,children:"Clear"}),fe("div",{className:"flex gap-2",children:[ee(w,{variant:"outline",size:"sm",onClick:H,children:"Cancel"}),ee(w,{size:"sm",onClick:W,disabled:p==="range"&&(!C?.from||!C?.to),children:"Apply"})]})]})]})]})}import{Fragment as yo,jsx as l,jsxs as y}from"react/jsx-runtime";function St({table:e,filters:a=[],globalFilter:i,onGlobalFilterChange:p,enableGlobalFilter:P=!0,onExport:x,onRefresh:I,loading:$=!1,enableColumnVisibility:b=!0,data:C,onClearSorting:k,onClearFilters:F,enableColumnPinning:S=!1,onExternalSearch:W,onCustomFilterChange:H}){let[q,J]=Nt({}),[M,g]=Nt({}),ve=()=>e.getAllLeafColumns().filter(t=>t.getCanHide?.()!==!1),xe=()=>e.getAllColumns().filter(t=>!e.getAllLeafColumns().includes(t)&&t.columns?.length&&t.columns.some(u=>u.getCanHide?.()!==!1)),se=()=>{let t=new Set(xe().flatMap(u=>u.columns?.filter(f=>f.getCanHide?.()!==!1).map(f=>f.id)||[]));return ve().filter(u=>!t.has(u.id))},he=(t,u)=>u&&t.startsWith(`${u}.`)?t.replace(`${u}.`,"").split("_").map(j=>j.slice(1)).join(" "):t.split("_").map(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" "),te=(t,u)=>{let f={...q,[t]:u};J(f)},_e=(t,u)=>{let f={...M,[t]:u};g(f),H&&H(t,u),a.find(j=>j.key===t)?.externalSearch&&te(t,u)},Fe=()=>{W&&W(q)},oe=()=>{J({}),g({}),F(),W&&W({}),H&&Object.keys(M).forEach(t=>{H(t,"")})},le=t=>a.find(f=>f.key===t)?.customFilter?M[t]??"":e.getColumn(t)?.getFilterValue(),ne=(t,u)=>{let f=a.find(j=>j.key===t);f?.customFilter?_e(t,u):(e.getColumn(t)?.setFilterValue(u),f?.externalSearch&&te(t,u))};return l("div",{className:"rounded-xl",children:l("div",{className:"px-2",children:l("div",{className:"flex flex-col gap-6",children:y("div",{className:"flex items-center justify-between",children:[l("div",{className:"flex items-center gap-3",children:a.length>0&&y("div",{className:"flex items-center gap-3 flex-wrap",children:[l("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:l(Pt,{className:"h-4 w-4"})}),a.map(t=>!e.getColumn(t.key)&&!t.customFilter&&!t.externalSearch?null:l("div",{className:o("relative min-w-[150px]",t.width),children:t.type==="select"?y(Se,{value:le(t.key)??"",onValueChange:f=>{ne(t.key,f==="all"?"":f)},children:[t.icon&&l("span",{children:l(t.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"})}),l(ke,{className:o("h-9 rounded-lg w-full",t.icon&&"pl-9"),children:l(De,{placeholder:t.placeholder})}),y(Te,{className:"rounded-lg",children:[l(ce,{value:"all",children:"All"}),t.options?.map(f=>l(ce,{value:f.value,children:f.label},f.label))]})]}):t.type==="date"?l(wt,{value:le(t.key),onChange:f=>{t.onlyExternal||ne(t.key,f)},placeholder:t.placeholder,mode:t.dateMode||"single",externalSearch:t.externalSearch,onlyExternal:t.onlyExternal,onExternalChange:f=>te(t.key,f)}):y("div",{className:"relative",children:[t.icon&&l("span",{children:l(t.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"})}),l(je,{placeholder:t.placeholder,value:le(t.key)??"",onChange:f=>{ne(t.key,f.target.value)},className:o("h-9 rounded-lg",t.icon&&"pl-9"),type:t.type==="number"?"number":"text"})]})},t.key)),(a.some(t=>t.externalSearch)||a.some(t=>t.customFilter))&&y(w,{variant:"default",size:"sm",onClick:Fe,className:"rounded-lg",children:[l(yt,{className:"mr-2 h-4 w-4"}),a.find(t=>t.externalSearch||t.customFilter)?.searchButtonText||"Search"]})]})}),y("div",{className:"flex items-center gap-2",children:[P&&y("div",{className:"relative",children:[l(yt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),l(je,{placeholder:"Global search...",value:i??"",onChange:t=>p(t.target.value),className:"pl-9 max-w-max"})]}),x&&y(w,{variant:"outline",size:"sm",onClick:()=>x(C),className:"rounded-lg",children:[l(bo,{className:"mr-2 h-4 w-4"}),"Export"]}),b&&y(ue,{children:[l(me,{asChild:!0,children:y(w,{variant:"outline",size:"sm",className:"rounded-lg gap-1",children:[l("span",{children:"Columns"}),l(wo,{className:"h-4 w-4 opacity-50"})]})}),y(pe,{align:"end",className:"w-[220px] rounded-lg max-h-[400px] overflow-y-auto",children:[l(U,{className:"px-4 py-2 text-sm font-medium",children:"Toggle Columns"}),l(Z,{}),se().length>0&&y(Ee,{children:[l(U,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:"General"}),se().map(t=>l($e,{className:"text-sm",checked:t.getIsVisible(),onCheckedChange:u=>t.toggleVisibility(!!u),children:he(t.id)},t.id))]}),xe().map(t=>y(Ee,{children:[l(Z,{}),l(U,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:t.id}),t.columns?.filter(u=>u.getCanHide?.()!==!1).map(u=>l($e,{className:"text-sm",checked:u.getIsVisible(),onCheckedChange:f=>u.toggleVisibility(!!f),children:he(u.id,t.id)},u.id))]},t.id))]})]}),y(ue,{children:[l(me,{asChild:!0,children:l(w,{variant:"outline",size:"sm",className:"rounded-lg",children:l(vo,{className:"h-4 w-4"})})}),y(pe,{align:"end",className:"w-[200px] rounded-lg",children:[l(U,{children:"Table Settings"}),l(Z,{}),y(A,{onClick:k,children:[l(xo,{className:"mr-2 h-4 w-4"}),"Clear All Sorting"]}),y(A,{onClick:oe,children:[l(Pt,{className:"mr-2 h-4 w-4"}),"Clear All Filters"]}),S&&y(yo,{children:[l(Z,{}),l(U,{children:"Column Pinning"}),y(A,{onClick:()=>e.setColumnPinning({left:[],right:[]}),children:[l(ho,{className:"mr-2 h-4 w-4"}),"Reset All Pinning"]}),y(A,{onClick:()=>{let t=ve().filter(u=>u.getCanPin?.()!==!1).map(u=>u.id);e.setColumnPinning({left:[],right:t})},children:[l(Co,{className:"mr-2 h-4 w-4 -rotate-90"}),"Pin All Right"]})]})]})]}),I&&l(w,{variant:"outline",size:"sm",onClick:I,disabled:$,className:"rounded-lg",children:l(fo,{className:o("h-4 w-4",$&&"animate-spin")})})]})]})})})})}import{jsx as R,jsxs as ie}from"react/jsx-runtime";function Dt({table:e,config:a}){return a.enabled?R("div",{className:"rounded-xl",children:R("div",{children:ie("div",{className:"flex items-center justify-between",children:[R("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:a.showInfo!==!1&&ie("span",{children:["Showing ",e.getState().pagination.pageIndex*e.getState().pagination.pageSize+1," to"," ",Math.min((e.getState().pagination.pageIndex+1)*e.getState().pagination.pageSize,e.getFilteredRowModel().rows.length)," ","of ",e.getFilteredRowModel().rows.length," entries"]})}),ie("div",{className:"flex items-center gap-4",children:[a.pageSizeOptions&&ie("div",{className:"flex items-center gap-2",children:[R("span",{className:"text-sm font-medium",children:"Rows per page:"}),ie(Se,{value:`${e.getState().pagination.pageSize}`,onValueChange:i=>e.setPageSize(Number(i)),children:[R(ke,{className:"h-9 w-[70px] rounded-lg",children:R(De,{})}),R(Te,{side:"top",className:"rounded-lg",children:a.pageSizeOptions.map(i=>R(ce,{value:`${i}`,children:i},i))})]})]}),ie("div",{className:"flex items-center gap-2",children:[R(w,{variant:"outline",size:"sm",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),className:"rounded-lg",children:"First"}),R(w,{variant:"outline",size:"sm",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),className:"rounded-lg",children:"Previous"}),a.showPageNumbers&&R("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,e.getPageCount())},(i,p)=>{let P=e.getState().pagination.pageIndex,x=P+p;return x<1||x>e.getPageCount()?null:R(w,{variant:x===P+1?"default":"outline",size:"sm",className:"size-8 p-0 rounded-lg",onClick:()=>e.setPageIndex(x-1),children:x},x)})}),R(w,{variant:"outline",size:"sm",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),className:"rounded-lg",children:"Next"}),R(w,{variant:"outline",size:"sm",onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),className:"rounded-lg",children:"Last"})]})]})]})})}):null}import{Toggle as Po}from"radix-ui";import{cva as No}from"class-variance-authority";import{jsx as Do}from"react/jsx-runtime";var So=No("inline-flex cursor-pointer items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{sm:"h-7 px-0 min-w-7",default:"h-8 px-1 min-w-8",lg:"h-9 px-2 min-w-10"},bg:{enabled:"data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",disabled:""}},defaultVariants:{variant:"default",size:"default",bg:"enabled"}});function kt({className:e,variant:a,size:i,noBg:p,...P}){return Do(Po.Root,{"data-slot":"toggle",className:o(So({className:e,variant:a,size:i,bg:p?"disabled":"enabled"})),...P})}import{Checkbox as Tt}from"radix-ui";import{CheckIcon as ko}from"lucide-react";import{jsx as qe}from"react/jsx-runtime";function Je({className:e,...a}){return qe(Tt.Root,{"data-slot":"checkbox",className:o("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),...a,children:qe(Tt.Indicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:qe(ko,{className:"size-3.5"})})})}import{useCallback as Ie,useEffect as be,useMemo as Lo,useState as E}from"react";import{Fragment as Mt,jsx as r,jsxs as N}from"react/jsx-runtime";function Na({data:e,columns:a,filters:i=[],pagination:p={enabled:!1},settings:P={},header:x,footer:I,className:$="",maxHeight:b="600px",loading:C=!1,error:k,emptyMessage:F="No data available",onRowSelectionChange:S,onExport:W,onRefresh:H,onTableReady:q,children:J,isRowDisabled:M,isRowSelectable:g,onExternalSearch:ve}){let[xe,se]=E([]),[he,te]=E([]),[_e,Fe]=E({}),[oe,le]=E({}),[ne,t]=E(""),[u,f]=E([]),[j,Rt]=E(P.enableColumnPinning?{left:[],right:[]}:{}),[Ve,It]=E({}),[Ye,Ze]=E(e),{enableSorting:Be=!0,enableFiltering:Le=!0,enableGlobalFilter:et=!0,enableColumnVisibility:Ge=!0,enableRowSelection:T=!0,stickyHeader:_t=!0,toolbar:Ft=!1,showSerialNumbers:Y=!0,fixedCheckboxColumn:Ce=!0,striped:Vt=!0,hoverable:Bt=!0,compact:tt=!0,bordered:ot=!0,fullHeight:Lt=!1,enableColumnResizing:nt=!1,enableColumnPinning:_=!0,hideHeader:Gt=!1,selectionMode:X="multiple",showCheckBox:At=!0,checkboxColumnPosition:at=0}=P;be(()=>{if(Object.keys(Ve).length===0){Ze(e);return}let d=e.filter(c=>Object.entries(Ve).every(([n,m])=>{if(!m||m==="")return!0;let s=Ht(c,n);return typeof m=="string"?String(s).toLowerCase().includes(m.toLowerCase()):s===m}));Ze(d)},[e,Ve]);let Ht=(d,c)=>c.split(".").reduce((n,m)=>n&&n[m],d),Ot=Ie((d,c)=>{It(n=>{let m={...n};return c===""||c===null||c===void 0?delete m[d]:m[d]=c,m})},[]),Ae=Lo(()=>{let d=[...a],c=s=>s.map(v=>{if(v.id==="select"||v.id==="serialNumber")return v;let D={...v,enablePinning:!0};return v.columns&&(D.columns=c(v.columns)),D}),n=c(d),m={id:"select",header:({table:s})=>{if(X==="single")return null;let v=s.getRowModel().rows.filter(V=>!M?.(V.original)&&(g?g(V.original):!0)),D=v.length>0&&v.every(V=>V.getIsSelected()),L=v.some(V=>V.getIsSelected());return r(Je,{checked:D||L&&"indeterminate",onCheckedChange:V=>{v.forEach(ae=>ae.toggleSelected(!!V))},"aria-label":"Select all selectable rows"})},cell:({row:s})=>{let v=M?M(s.original):!1,D=g?g(s.original):!0;return r("div",{className:o("flex items-center justify-center",v&&"opacity-50"),children:X==="multiple"?r(Je,{checked:s.getIsSelected(),onCheckedChange:L=>D&&s.toggleSelected(!!L),"aria-label":"Select row",disabled:v||!D}):At?r("input",{type:"radio",checked:s.getIsSelected(),onChange:()=>D&&s.toggleSelected(!0),disabled:v||!D,className:"h-4 w-4 rounded-full border-primary text-primary focus:ring-primary"}):null})},enableSorting:!1,enableHiding:!1,enablePinning:!0,headerAlign:"center",size:X==="multiple"?40:30};if(T){let s=at;s<0&&(s=n.length+s+1),s=Math.max(0,Math.min(s,n.length)),n.splice(s,0,m)}if(Y){let s={id:"serialNumber",header:"No.",cell:({row:v})=>r("div",{className:"text-center font-medium text-muted-foreground",children:v.index+1}),enableSorting:!0,enableHiding:!1,enablePinning:!0,size:60,headerAlign:"center"};n.unshift(s)}return n},[a,Y,T,Ce,M,g,X,at]),h=Io({data:Ye,columns:Ae,onSortingChange:Be?se:void 0,onColumnFiltersChange:Le?te:void 0,onGlobalFilterChange:et?t:void 0,getCoreRowModel:To(),getPaginationRowModel:p.enabled?Mo():void 0,getSortedRowModel:Be?Ro():void 0,getFilteredRowModel:Le?zo():void 0,onColumnVisibilityChange:Ge?Fe:void 0,onRowSelectionChange:T?le:void 0,onColumnOrderChange:f,onColumnPinningChange:_?Rt:void 0,state:{sorting:Be?xe:void 0,columnFilters:Le?he:void 0,columnVisibility:Ge?_e:void 0,rowSelection:T?oe:{},globalFilter:ne,columnOrder:u,columnPinning:_?j:{}},initialState:{pagination:p.enabled?{pageSize:p.pageSize||10}:void 0,columnPinning:_?{left:[...Y?["serialNumber"]:[],...T?["select"]:[]],right:[]}:void 0},enableRowSelection:T,enableColumnResizing:nt,enableColumnPinning:_,columnResizeMode:"onChange"});be(()=>{if(T&&S){let d=h.getFilteredSelectedRowModel().rows.filter(c=>!M?.(c.original)&&(g?g(c.original):!0)).map(c=>c.original);S(d)}},[oe,T,S,h,M,g]);let jt=Ie(d=>{X==="single"?(h.resetRowSelection(),d.toggleSelected(!0)):d.toggleSelected()},[X,h]);be(()=>{q&&q(h)},[h,q]),be(()=>{if(T&&S){let d=h.getFilteredSelectedRowModel().rows.map(c=>c.original);S(d)}},[oe,T,S,h]),be(()=>{if(T&&S){let d=h.getFilteredSelectedRowModel().rows.filter(c=>!M?.(c.original)&&(g?g(c.original):!0)).map(c=>c.original);S(d)}},[oe,T,S,h,M,g]);let Ut=Ie(()=>{se([])},[]),Et=Ie(()=>{te([]),t("")},[]),rt=(d,c)=>{if(!_)return;let n=[...Y?["serialNumber"]:[],...T&&Ce?["select"]:[]],m={left:[...(j.left??[]).filter(s=>n.includes(s))],right:[...j.right??[]]};c===!1?(m.left=m.left.filter(s=>s!==d),m.right=m.right.filter(s=>s!==d)):c==="right"?(m.left=m.left.filter(s=>s!==d),m.right.includes(d)||m.right.push(d)):c==="left"&&(m.right=m.right.filter(s=>s!==d),!m.left.includes(d)&&!n.includes(d)&&m.left.push(d)),h.setColumnPinning(m)},$t=()=>r(dt,{className:o(_t&&"sticky top-0 bg-sidebar z-20"),children:h.getHeaderGroups().map((d,c)=>r(de,{className:"hover:bg-transparent",children:d.headers.map((n,m)=>{let s=n.depth===0&&n.colSpan>1,v=_&&(n.column.getIsPinned()==="left"||n.column.id==="serialNumber"||n.column.id==="select"&&T),D=_&&n.column.getIsPinned()==="right",L=n.column.getCanSort(),V=_&&n.column.columnDef.enablePinning!==!1,ae=n.column.id==="serialNumber",He=n.column.id==="select",lt=ae||He&&Ce,re=n.column.columnDef.headerAlign||"left",Wt={left:"justify-start",center:"justify-center",right:"justify-end"}[re];return N(mt,{colSpan:n.colSpan,className:o("font-semibold text-foreground bg-sidebar group px-0",!tt&&"py-2",ot&&m<d.headers.length-1&&"border-r","relative",v&&"sticky left-0 z-15 bg-sidebar",D&&"sticky right-0 z-15 bg-sidebar",(ae||He)&&"sticky left-0 z-15 bg-sidebar",s?"text-center":"text-left"),style:{width:n.getSize()!==150?n.getSize():"auto",minWidth:n.getSize()!==150?n.getSize():"auto",...v&&{left:ae?0:He?Y&&h.getColumn("serialNumber")?.getSize()||0:it(n.column)},...D&&{right:st(n.column)},...ae&&{left:0}},children:[s?r("div",{className:"flex items-center justify-center",children:Xe(n.column.columnDef.header,n.getContext())}):N("div",{className:o("relative flex items-center w-full px-2",Wt),children:[N("div",{className:"flex items-center gap-1",children:[L&&re==="right"&&r("span",{className:"ml-1 order-2",children:n.column.getIsSorted()&&{asc:r(Ke,{className:"h-4 w-4"}),desc:r(Qe,{className:"h-4 w-4"})}[n.column.getIsSorted()]}),n.isPlaceholder?null:Xe(n.column.columnDef.header,n.getContext()),L&&re!=="right"&&n.column.getIsSorted()&&r("span",{className:"ml-1 order-2",children:n.column.getIsSorted()&&{asc:r(Ke,{className:"h-4 w-4"}),desc:r(Qe,{className:"h-4 w-4"})}[n.column.getIsSorted()]})]}),(L||V&&!lt)&&N(ue,{children:[r(me,{asChild:!0,className:o("absolute",re==="left"&&"right-1",re==="center"&&"right-1",re==="right"&&"left-1"),children:r(kt,{variant:"default",size:"sm",noBg:!0,tabIndex:-1,className:"opacity-0 group-hover:opacity-70 hover:opacity-100 data-[state=open]:opacity-100",children:r(Fo,{className:"h-4 w-4"})})}),N(pe,{align:"end",className:"w-48",children:[L&&N(Mt,{children:[r(U,{children:"Sorting"}),N(A,{onClick:()=>n.column.toggleSorting(!1),children:[r(Ke,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),N(A,{onClick:()=>n.column.toggleSorting(!0),children:[r(Qe,{className:"mr-2 h-4 w-4"}),"Sort Descending"]}),N(A,{onClick:()=>n.column.clearSorting(),disabled:!n.column.getIsSorted(),children:[r(_o,{className:"mr-2 h-4 w-4"}),"Clear Sort"]}),r(Z,{})]}),V&&!lt&&N(Mt,{children:[r(U,{children:"Pin Column"}),N(A,{onClick:()=>rt(n.column.id,"right"),disabled:n.column.getIsPinned()==="right",children:[r(Vo,{}),"Pin Right"]}),N(A,{onClick:()=>rt(n.column.id,!1),disabled:!n.column.getIsPinned(),children:[r(Bo,{}),"Unpin"]})]})]})]})]}),nt&&n.column.getCanResize()&&!s&&n.colSpan===1&&r("div",{className:"absolute right-0 top-0 h-full w-1 bg-border hover:bg-primary cursor-col-resize opacity-0 hover:opacity-100 transition-opacity",onMouseDown:n.getResizeHandler()})]},n.id)})},d.id))}),it=d=>{if(!_)return;let c=0,n=h.getLeftHeaderGroups()[0]?.headers||[],m=[...Y?["serialNumber"]:[],...T?["select"]:[]];for(let s of n){if(s.id===d.id)break;if(m.includes(s.id)){let v=h.getColumn(s.id);v&&(c+=v.getSize())}}return c},st=d=>{if(!_)return;let c=h.getState().columnPinning.right||[],n=c.indexOf(d.id);if(n===-1)return;let m=0;for(let s=n+1;s<c.length;s++){let v=h.getColumn(c[s]);v&&(m+=v.getSize())}return m};return k?r(Pe,{className:"w-full rounded-xl shadow-sm",children:r(Ne,{className:"flex items-center justify-center",children:N("div",{className:"text-center",children:[r("div",{className:"text-red-500 mb-3 text-2xl",children:"\u26A0\uFE0F"}),r("p",{className:"text-sm text-muted-foreground mb-4",children:k}),H&&N(w,{variant:"outline",size:"sm",onClick:H,className:"rounded-lg",children:[r(zt,{className:"mr-2 h-4 w-4"}),"Try Again"]})]})})}):r(gt,{children:N("div",{className:o("w-full space-y-2 flex flex-col h-full",$),children:[x&&r(Pe,{className:"rounded-2xl py-2 sticky top-0 z-20",children:r(Ne,{className:"px-2",children:x})}),Ft&&r(St,{table:h,filters:i,globalFilter:ne,onGlobalFilterChange:t,enableGlobalFilter:et,onExport:W,onRefresh:H,loading:C,enableColumnVisibility:Ge,enableColumnPinning:_,data:Ye,onClearSorting:Ut,onClearFilters:Et,onExternalSearch:ve,onCustomFilterChange:Ot}),r(Pe,{className:o("shadow-sm overflow-auto py-0",Lt&&"flex-1"),children:r(Ne,{className:"p-0 h-full",children:N("div",{className:"relative flex flex-col h-full justify-between",children:[C&&r("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm z-50 flex items-center justify-center rounded-xl",children:N("div",{className:"flex items-center gap-3 bg-background/90 px-4 py-3 rounded-lg shadow-sm",children:[r(zt,{className:"size-5 animate-spin text-primary"}),r("span",{className:"text-sm font-medium text-muted-foreground",children:"Loading..."})]})}),r("div",{className:"relative rounded-t-xl overflow-auto border-b",children:N(Oe,{className:"border-collapse w-full",children:[!Gt&&$t(),r(ct,{children:h.getRowModel().rows?.length?h.getRowModel().rows.map((d,c)=>r(de,{"data-state":d.getIsSelected()&&"selected",className:o(Bt&&"hover:bg-muted/50",Vt&&c%2===0&&"bg-muted/20",d.getIsSelected()&&"bg-muted","border-b last:border-b-0",X==="single"&&"cursor-pointer"),onClick:()=>{X==="single"&&jt(d)},children:d.getVisibleCells().map((n,m)=>{let s=_&&(n.column.getIsPinned()==="left"||n.column.id==="serialNumber"||n.column.id==="select"&&T),v=_&&n.column.getIsPinned()==="right",D=n.column.id==="serialNumber",L=n.column.id==="select",V=D||L&&Ce;return r(ye,{className:o(tt?"py-2":"py-4",ot&&m<d.getVisibleCells().length&&"border-r",s&&"sticky left-0 z-10 bg-sidebar/97",v&&"sticky right-0 z-10 bg-sidebar/97",D&&"sticky left-0 z-10 bg-sidebar/97","p-1"),style:{width:n.column.getSize()!==150?n.column.getSize():"auto",minWidth:n.column.getSize()!==150?n.column.getSize():"auto",...s&&{left:D?0:L?Y&&h.getColumn("serialNumber")?.getSize()||0:it(n.column)},...v&&{right:st(n.column)},...D&&{left:0}},children:Xe(n.column.columnDef.cell,n.getContext())},n.id)})},d.id)):r(de,{children:r(ye,{colSpan:Ae.length,className:"h-32 text-center border-0",children:N("div",{className:"flex flex-col items-center gap-3",children:[r("div",{className:"text-muted-foreground text-6xl",children:"\u{1F4CB}"}),r("p",{className:"text-muted-foreground font-medium",children:F})]})})})})]})}),I&&r("div",{className:"sticky bottom-0 bg-sidebar w-full z-20",style:{width:"100%",minWidth:"fit-content"},children:r(Oe,{children:r(ut,{children:r(de,{className:"bg-sidebar",children:r(ye,{colSpan:Ae.length,className:"p-2",children:I})})})})})]})})}),r(Dt,{table:h,config:p}),J&&J(h)]})})}export{Na as DataTable};
2
+ import{flexRender as Xe,getCoreRowModel as To,getFilteredRowModel as zo,getPaginationRowModel as Mo,getSortedRowModel as Ro,useReactTable as Io}from"@tanstack/react-table";import{Loader2 as Tt,ChevronUp as Ke,ChevronDown as Qe,ChevronsUpDown as _o,MoreHorizontal as Fo,MoveRightIcon as Vo,PinOffIcon as Bo}from"lucide-react";import{Slot as Xt}from"radix-ui";import{cva as Kt}from"class-variance-authority";import{clsx as qt}from"clsx";import{twMerge as Jt}from"tailwind-merge";function o(...e){return Jt(qt(e))}import{jsx as Qt}from"react/jsx-runtime";var Ce=Kt("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 w({className:e,variant:a,size:i,asChild:m=!1,...P}){let x=m?Xt.Slot:"button";return Qt(x,{"data-slot":"button",className:o(Ce({variant:a,size:i,className:e}),"transition-none"),...P})}import{jsx as X}from"react/jsx-runtime";function Oe({className:e,...a}){return X("div",{"data-slot":"table-container",className:"relative w-full overflow-auto max-h-full",children:X("table",{"data-slot":"table",className:o("w-full caption-bottom text-sm",e),...a})})}function lt({className:e,...a}){return X("thead",{"data-slot":"table-header",className:o("[&_tr]:border-b",e),...a})}function dt({className:e,...a}){return X("tbody",{"data-slot":"table-body",className:o("[&_tr:last-child]:border-0",e),...a})}function ct({className:e,...a}){return X("tfoot",{"data-slot":"table-footer",className:o("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",e),...a})}function de({className:e,...a}){return X("tr",{"data-slot":"table-row",className:o("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...a})}function ut({className:e,...a}){return X("th",{"data-slot":"table-head",className:o("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap",e),...a})}function we({className:e,...a}){return X("td",{"data-slot":"table-cell",className:o("p-2 align-middle whitespace-nowrap",e),...a})}import{jsx as mt}from"react/jsx-runtime";function ye({className:e,...a}){return mt("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...a})}function Pe({className:e,...a}){return mt("div",{"data-slot":"card-content",className:o("px-6",e),...a})}import{Tooltip as Yt}from"radix-ui";import{jsx as Zt,jsxs as en}from"react/jsx-runtime";function pt({delayDuration:e=0,...a}){return Zt(Yt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...a})}import{Search as wt,RefreshCw as fo,Download as bo,Settings2 as vo,Filter as yt,ArrowUpDown as xo,PinOff as ho,Pin as Co,ChevronDown as wo}from"lucide-react";import{jsx as eo}from"react/jsx-runtime";function je({className:e,type:a,...i}){return eo("input",{type:a,"data-slot":"input",className:o("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),...i})}import{Select as B}from"radix-ui";import{CheckIcon as to,ChevronDownIcon as gt,ChevronUpIcon as oo}from"lucide-react";import{jsx as z,jsxs as Ue}from"react/jsx-runtime";function Ne({...e}){return z(B.Root,{"data-slot":"select",...e})}function Se({...e}){return z(B.Value,{"data-slot":"select-value",...e})}function ke({className:e,size:a="default",children:i,...m}){return Ue(B.Trigger,{"data-slot":"select-trigger","data-size":a,className:o("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:[i,z(B.Icon,{asChild:!0,children:z(gt,{className:"size-4 opacity-50"})})]})}function De({className:e,children:a,position:i="popper",...m}){return z(B.Portal,{children:Ue(B.Content,{"data-slot":"select-content",className:o("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",i==="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:i,...m,children:[z(no,{}),z(B.Viewport,{className:o("p-1",i==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),z(ao,{})]})})}function ce({className:e,children:a,...i}){return Ue(B.Item,{"data-slot":"select-item",className:o("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),...i,children:[z("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:z(B.ItemIndicator,{children:z(to,{className:"size-4"})})}),z(B.ItemText,{children:a})]})}function no({className:e,...a}){return z(B.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:o("flex cursor-default items-center justify-center py-1",e),...a,children:z(oo,{className:"size-4"})})}function ao({className:e,...a}){return z(B.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:o("flex cursor-default items-center justify-center py-1",e),...a,children:z(gt,{className:"size-4"})})}import{DropdownMenu as O}from"radix-ui";import{CheckIcon as ro,ChevronRightIcon as pn,CircleIcon as gn}from"lucide-react";import{jsx as G,jsxs as io}from"react/jsx-runtime";function ue({...e}){return G(O.Root,{"data-slot":"dropdown-menu",...e})}function me({...e}){return G(O.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function pe({className:e,sideOffset:a=4,...i}){return G(O.Portal,{children:G(O.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,className:o("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),...i})})}function Ee({...e}){return G(O.Group,{"data-slot":"dropdown-menu-group",...e})}function A({className:e,inset:a,variant:i="default",...m}){return G(O.Item,{"data-slot":"dropdown-menu-item","data-inset":a,"data-variant":i,className:o("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 $e({className:e,children:a,checked:i,...m}){return io(O.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:o("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 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",e),checked:i,...m,children:[G("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:G(O.ItemIndicator,{children:G(ro,{className:"size-4"})})}),a]})}function U({className:e,inset:a,...i}){return G(O.Label,{"data-slot":"dropdown-menu-label","data-inset":a,className:o("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...i})}function Z({className:e,...a}){return G(O.Separator,{"data-slot":"dropdown-menu-separator",className:o("bg-border -mx-1 my-1 h-px",e),...a})}import{useState as Pt}from"react";import{useEffect as po,useState as We}from"react";import{Calendar as go}from"lucide-react";import{format as ge}from"date-fns";import{Popover as Te}from"radix-ui";import{jsx as ze}from"react/jsx-runtime";function ft({...e}){return ze(Te.Root,{"data-slot":"popover",...e})}function bt({...e}){return ze(Te.Trigger,{"data-slot":"popover-trigger",...e})}function vt({className:e,align:a="center",sideOffset:i=4,...m}){return ze(Te.Portal,{children:ze(Te.Content,{"data-slot":"popover-content",align:a,sideOffset:i,className:o("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 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...m})})}import*as Me from"react";import{ChevronDownIcon as so,ChevronLeftIcon as lo,ChevronRightIcon as co}from"lucide-react";import{DayPicker as uo,getDefaultClassNames as xt}from"react-day-picker";import{jsx as K}from"react/jsx-runtime";function ht({className:e,classNames:a,showOutsideDays:i=!0,captionLayout:m="label",buttonVariant:P="ghost",formatters:x,components:I,...E}){let b=xt();return K(uo,{showOutsideDays:i,className:o("bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:m,formatters:{formatMonthDropdown:C=>C.toLocaleString("default",{month:"short"}),...x},classNames:{root:o("w-fit",b.root),months:o("flex gap-4 flex-col md:flex-row relative",b.months),month:o("flex flex-col w-full gap-4",b.month),nav:o("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",b.nav),button_previous:o(Ce({variant:P}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",b.button_previous),button_next:o(Ce({variant:P}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",b.button_next),month_caption:o("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",b.month_caption),dropdowns:o("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",b.dropdowns),dropdown_root:o("relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",b.dropdown_root),dropdown:o("absolute bg-popover inset-0 opacity-0",b.dropdown),caption_label:o("select-none font-medium",m==="label"?"text-sm":"rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",b.caption_label),table:"w-full border-collapse",weekdays:o("flex",b.weekdays),weekday:o("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",b.weekday),week:o("flex w-full mt-2",b.week),week_number_header:o("select-none w-(--cell-size)",b.week_number_header),week_number:o("text-[0.8rem] select-none text-muted-foreground",b.week_number),day:o("relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",b.day),range_start:o("rounded-l-md bg-accent",b.range_start),range_middle:o("rounded-none",b.range_middle),range_end:o("rounded-r-md bg-accent",b.range_end),today:o("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",b.today),outside:o("text-muted-foreground aria-selected:text-muted-foreground",b.outside),disabled:o("text-muted-foreground opacity-50",b.disabled),hidden:o("invisible",b.hidden),...a},components:{Root:({className:C,rootRef:D,...F})=>K("div",{"data-slot":"calendar",ref:D,className:o(C),...F}),Chevron:({className:C,orientation:D,...F})=>D==="left"?K(lo,{className:o("size-4",C),...F}):D==="right"?K(co,{className:o("size-4",C),...F}):K(so,{className:o("size-4",C),...F}),DayButton:mo,WeekNumber:({children:C,...D})=>K("td",{...D,children:K("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:C})}),...I},...E})}function mo({className:e,day:a,modifiers:i,...m}){let P=xt(),x=Me.useRef(null);return Me.useEffect(()=>{i.focused&&x.current?.focus()},[i.focused]),K(w,{ref:x,variant:"ghost",size:"icon","data-day":a.date.toLocaleDateString(),"data-selected-single":i.selected&&!i.range_start&&!i.range_end&&!i.range_middle,"data-range-start":i.range_start,"data-range-end":i.range_end,"data-range-middle":i.range_middle,className:o("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",P.day,e),...m})}import{jsx as ee,jsxs as fe}from"react/jsx-runtime";function Ct({value:e,onChange:a,placeholder:i,mode:m,externalSearch:P,onExternalChange:x,onlyExternal:I=!1}){let[E,b]=We(!1),[C,D]=We(e),[F,S]=We(e);po(()=>{I||S(e)},[e,I]);let $=()=>{I||a(C),S(C),P&&x&&x(C),b(!1)},H=()=>{D(F),b(!1)},W=()=>{let p=m==="single"?null:{from:null,to:null};D(p),I||a(p),S(p),P&&x&&x(p),b(!1)},q=()=>{let p=I?F:e;return p?m==="single"?ge(p,"PPP"):p.from&&p.to?`${ge(p.from,"MMM dd")} - ${ge(p.to,"MMM dd, yyyy")}`:p.from?`From ${ge(p.from,"MMM dd, yyyy")}`:p.to?`To ${ge(p.to,"MMM dd, yyyy")}`:i:i},M=p=>{D(m==="single"?p:p||{from:null,to:null})};return fe(ft,{open:E,onOpenChange:b,children:[ee(bt,{asChild:!0,children:fe(w,{variant:"outline",className:o("w-full justify-start text-left font-normal h-9",!q()&&"text-muted-foreground"),children:[ee(go,{className:"mr-2 h-4 w-4"}),q()]})}),fe(vt,{className:"w-auto p-0",align:"start",children:[ee("div",{className:"p-3",children:ee(ht,{mode:m,selected:C,onSelect:M,numberOfMonths:m==="range"?2:1,className:"rounded-md border",...m==="range"&&{required:!0}})}),fe("div",{className:"flex items-center justify-between p-3 border-t",children:[ee(w,{variant:"ghost",size:"sm",onClick:W,children:"Clear"}),fe("div",{className:"flex gap-2",children:[ee(w,{variant:"outline",size:"sm",onClick:H,children:"Cancel"}),ee(w,{size:"sm",onClick:$,disabled:m==="range"&&(!C?.from||!C?.to),children:"Apply"})]})]})]})]})}import{Fragment as yo,jsx as l,jsxs as y}from"react/jsx-runtime";function Nt({table:e,filters:a=[],globalFilter:i,onGlobalFilterChange:m,enableGlobalFilter:P=!0,onExport:x,onRefresh:I,loading:E=!1,enableColumnVisibility:b=!0,data:C,onClearSorting:D,onClearFilters:F,enableColumnPinning:S=!1,onExternalSearch:$,onCustomFilterChange:H}){let[W,q]=Pt({}),[M,p]=Pt({}),be=()=>e.getAllLeafColumns().filter(t=>t.getCanHide?.()!==!1),ve=()=>e.getAllColumns().filter(t=>!e.getAllLeafColumns().includes(t)&&t.columns?.length&&t.columns.some(u=>u.getCanHide?.()!==!1)),se=()=>{let t=new Set(ve().flatMap(u=>u.columns?.filter(g=>g.getCanHide?.()!==!1).map(g=>g.id)||[]));return be().filter(u=>!t.has(u.id))},xe=(t,u)=>u&&t.startsWith(`${u}.`)?t.replace(`${u}.`,"").split("_").map(j=>j.slice(1)).join(" "):t.split("_").map(g=>g.charAt(0).toUpperCase()+g.slice(1)).join(" "),te=(t,u)=>{let g={...W,[t]:u};q(g)},_e=(t,u)=>{let g={...M,[t]:u};p(g),H&&H(t,u),a.find(j=>j.key===t)?.externalSearch&&te(t,u)},Fe=()=>{$&&$(W)},oe=()=>{q({}),p({}),F(),$&&$({}),H&&Object.keys(M).forEach(t=>{H(t,"")})},le=t=>a.find(g=>g.key===t)?.customFilter?M[t]??"":e.getColumn(t)?.getFilterValue(),ne=(t,u)=>{let g=a.find(j=>j.key===t);g?.customFilter?_e(t,u):(e.getColumn(t)?.setFilterValue(u),g?.externalSearch&&te(t,u))};return l("div",{className:"rounded-xl",children:l("div",{className:"px-2",children:l("div",{className:"flex flex-col gap-6",children:y("div",{className:"flex items-center justify-between",children:[l("div",{className:"flex items-center gap-3",children:a.length>0&&y("div",{className:"flex items-center gap-3 flex-wrap",children:[l("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:l(yt,{className:"h-4 w-4"})}),a.map(t=>!e.getColumn(t.key)&&!t.customFilter&&!t.externalSearch?null:l("div",{className:o("relative min-w-[150px]",t.width),children:t.type==="select"?y(Ne,{value:le(t.key)??"",onValueChange:g=>{ne(t.key,g==="all"?"":g)},children:[t.icon&&l("span",{children:l(t.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"})}),l(ke,{className:o("h-9 rounded-lg w-full",t.icon&&"pl-9"),children:l(Se,{placeholder:t.placeholder})}),y(De,{className:"rounded-lg",children:[l(ce,{value:"all",children:"All"}),t.options?.map(g=>l(ce,{value:g.value,children:g.label},g.label))]})]}):t.type==="date"?l(Ct,{value:le(t.key),onChange:g=>{t.onlyExternal||ne(t.key,g)},placeholder:t.placeholder,mode:t.dateMode||"single",externalSearch:t.externalSearch,onlyExternal:t.onlyExternal,onExternalChange:g=>te(t.key,g)}):y("div",{className:"relative",children:[t.icon&&l("span",{children:l(t.icon,{className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"})}),l(je,{placeholder:t.placeholder,value:le(t.key)??"",onChange:g=>{ne(t.key,g.target.value)},className:o("h-9 rounded-lg",t.icon&&"pl-9"),type:t.type==="number"?"number":"text"})]})},t.key)),(a.some(t=>t.externalSearch)||a.some(t=>t.customFilter))&&y(w,{variant:"default",size:"sm",onClick:Fe,className:"rounded-lg",children:[l(wt,{className:"mr-2 h-4 w-4"}),a.find(t=>t.externalSearch||t.customFilter)?.searchButtonText||"Search"]})]})}),y("div",{className:"flex items-center gap-2",children:[P&&y("div",{className:"relative",children:[l(wt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),l(je,{placeholder:"Global search...",value:i??"",onChange:t=>m(t.target.value),className:"pl-9 max-w-max"})]}),x&&y(w,{variant:"outline",size:"sm",onClick:()=>x(C),className:"rounded-lg",children:[l(bo,{className:"mr-2 h-4 w-4"}),"Export"]}),b&&y(ue,{children:[l(me,{asChild:!0,children:y(w,{variant:"outline",size:"sm",className:"rounded-lg gap-1",children:[l("span",{children:"Columns"}),l(wo,{className:"h-4 w-4 opacity-50"})]})}),y(pe,{align:"end",className:"w-[220px] rounded-lg max-h-[400px] overflow-y-auto",children:[l(U,{className:"px-4 py-2 text-sm font-medium",children:"Toggle Columns"}),l(Z,{}),se().length>0&&y(Ee,{children:[l(U,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:"General"}),se().map(t=>l($e,{className:"text-sm",checked:t.getIsVisible(),onCheckedChange:u=>t.toggleVisibility(!!u),children:xe(t.id)},t.id))]}),ve().map(t=>y(Ee,{children:[l(Z,{}),l(U,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:t.id}),t.columns?.filter(u=>u.getCanHide?.()!==!1).map(u=>l($e,{className:"text-sm",checked:u.getIsVisible(),onCheckedChange:g=>u.toggleVisibility(!!g),children:xe(u.id,t.id)},u.id))]},t.id))]})]}),y(ue,{children:[l(me,{asChild:!0,children:l(w,{variant:"outline",size:"sm",className:"rounded-lg",children:l(vo,{className:"h-4 w-4"})})}),y(pe,{align:"end",className:"w-[200px] rounded-lg",children:[l(U,{children:"Table Settings"}),l(Z,{}),y(A,{onClick:D,children:[l(xo,{className:"mr-2 h-4 w-4"}),"Clear All Sorting"]}),y(A,{onClick:oe,children:[l(yt,{className:"mr-2 h-4 w-4"}),"Clear All Filters"]}),S&&y(yo,{children:[l(Z,{}),l(U,{children:"Column Pinning"}),y(A,{onClick:()=>e.setColumnPinning({left:[],right:[]}),children:[l(ho,{className:"mr-2 h-4 w-4"}),"Reset All Pinning"]}),y(A,{onClick:()=>{let t=be().filter(u=>u.getCanPin?.()!==!1).map(u=>u.id);e.setColumnPinning({left:[],right:t})},children:[l(Co,{className:"mr-2 h-4 w-4 -rotate-90"}),"Pin All Right"]})]})]})]}),I&&l(w,{variant:"outline",size:"sm",onClick:I,disabled:E,className:"rounded-lg",children:l(fo,{className:o("h-4 w-4",E&&"animate-spin")})})]})]})})})})}import{jsx as R,jsxs as ie}from"react/jsx-runtime";function St({table:e,config:a}){return a.enabled?R("div",{className:"rounded-xl",children:R("div",{children:ie("div",{className:"flex items-center justify-between",children:[R("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:a.showInfo!==!1&&ie("span",{children:["Showing ",e.getState().pagination.pageIndex*e.getState().pagination.pageSize+1," to"," ",Math.min((e.getState().pagination.pageIndex+1)*e.getState().pagination.pageSize,e.getFilteredRowModel().rows.length)," ","of ",e.getFilteredRowModel().rows.length," entries"]})}),ie("div",{className:"flex items-center gap-4",children:[a.pageSizeOptions&&ie("div",{className:"flex items-center gap-2",children:[R("span",{className:"text-sm font-medium",children:"Rows per page:"}),ie(Ne,{value:`${e.getState().pagination.pageSize}`,onValueChange:i=>e.setPageSize(Number(i)),children:[R(ke,{className:"h-9 w-[70px] rounded-lg",children:R(Se,{})}),R(De,{side:"top",className:"rounded-lg",children:a.pageSizeOptions.map(i=>R(ce,{value:`${i}`,children:i},i))})]})]}),ie("div",{className:"flex items-center gap-2",children:[R(w,{variant:"outline",size:"sm",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),className:"rounded-lg",children:"First"}),R(w,{variant:"outline",size:"sm",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),className:"rounded-lg",children:"Previous"}),a.showPageNumbers&&R("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,e.getPageCount())},(i,m)=>{let P=e.getState().pagination.pageIndex,x=P+m;return x<1||x>e.getPageCount()?null:R(w,{variant:x===P+1?"default":"outline",size:"sm",className:"size-8 p-0 rounded-lg",onClick:()=>e.setPageIndex(x-1),children:x},x)})}),R(w,{variant:"outline",size:"sm",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),className:"rounded-lg",children:"Next"}),R(w,{variant:"outline",size:"sm",onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),className:"rounded-lg",children:"Last"})]})]})]})})}):null}import{Toggle as Po}from"radix-ui";import{cva as No}from"class-variance-authority";import{jsx as ko}from"react/jsx-runtime";var So=No("inline-flex cursor-pointer items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{sm:"h-7 px-0 min-w-7",default:"h-8 px-1 min-w-8",lg:"h-9 px-2 min-w-10"},bg:{enabled:"data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",disabled:""}},defaultVariants:{variant:"default",size:"default",bg:"enabled"}});function kt({className:e,variant:a,size:i,noBg:m,...P}){return ko(Po.Root,{"data-slot":"toggle",className:o(So({className:e,variant:a,size:i,bg:m?"disabled":"enabled"})),...P})}import{Checkbox as Dt}from"radix-ui";import{CheckIcon as Do}from"lucide-react";import{jsx as qe}from"react/jsx-runtime";function Je({className:e,...a}){return qe(Dt.Root,{"data-slot":"checkbox",className:o("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),...a,children:qe(Dt.Indicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:qe(Do,{className:"size-3.5"})})})}import{useCallback as Re,useEffect as Ie,useMemo as zt,useState as Q}from"react";import{Fragment as Mt,jsx as r,jsxs as N}from"react/jsx-runtime";function Pa({data:e,columns:a,filters:i=[],pagination:m={enabled:!1},settings:P={},header:x,footer:I,className:E="",maxHeight:b="600px",loading:C=!1,error:D,emptyMessage:F="No data available",onRowSelectionChange:S,onExport:$,onRefresh:H,onTableReady:W,children:q,isRowDisabled:M,isRowSelectable:p,onExternalSearch:be}){let[ve,se]=Q([]),[xe,te]=Q([]),[_e,Fe]=Q({}),[oe,le]=Q({}),[ne,t]=Q(""),[u,g]=Q([]),[j,Rt]=Q(P.enableColumnPinning?{left:[],right:[]}:{}),[Ve,It]=Q({}),Ye=zt(()=>Object.keys(Ve).length===0?e:e.filter(d=>Object.entries(Ve).every(([c,n])=>{if(!n||n==="")return!0;let f=Ht(d,c);return typeof n=="string"?String(f).toLowerCase().includes(n.toLowerCase()):f===n})),[e,Ve]),{enableSorting:Be=!0,enableFiltering:Le=!0,enableGlobalFilter:Ze=!0,enableColumnVisibility:Ge=!0,enableRowSelection:T=!0,stickyHeader:_t=!0,toolbar:Ft=!1,showSerialNumbers:Y=!0,fixedCheckboxColumn:he=!0,striped:Vt=!0,hoverable:Bt=!0,compact:et=!0,bordered:tt=!0,fullHeight:Lt=!1,enableColumnResizing:ot=!1,enableColumnPinning:_=!0,hideHeader:Gt=!1,selectionMode:J="multiple",showCheckBox:At=!0,checkboxColumnPosition:nt=0}=P,Ht=(d,c)=>c.split(".").reduce((n,f)=>n&&n[f],d),Ot=Re((d,c)=>{It(n=>{let f={...n};return c===""||c===null||c===void 0?delete f[d]:f[d]=c,f})},[]),Ae=zt(()=>{let d=[...a],c=s=>s.map(v=>{if(v.id==="select"||v.id==="serialNumber")return v;let k={...v,enablePinning:!0};return v.columns&&(k.columns=c(v.columns)),k}),n=c(d),f={id:"select",header:({table:s})=>{if(J==="single")return null;let v=s.getRowModel().rows.filter(V=>!M?.(V.original)&&(p?p(V.original):!0)),k=v.length>0&&v.every(V=>V.getIsSelected()),L=v.some(V=>V.getIsSelected());return r(Je,{checked:k||L&&"indeterminate",onCheckedChange:V=>{v.forEach(ae=>ae.toggleSelected(!!V))},"aria-label":"Select all selectable rows"})},cell:({row:s})=>{let v=M?M(s.original):!1,k=p?p(s.original):!0;return r("div",{className:o("flex items-center justify-center",v&&"opacity-50"),children:J==="multiple"?r(Je,{checked:s.getIsSelected(),onCheckedChange:L=>k&&s.toggleSelected(!!L),"aria-label":"Select row",disabled:v||!k}):At?r("input",{type:"radio",checked:s.getIsSelected(),onChange:()=>k&&s.toggleSelected(!0),disabled:v||!k,className:"h-4 w-4 rounded-full border-primary text-primary focus:ring-primary"}):null})},enableSorting:!1,enableHiding:!1,enablePinning:!0,headerAlign:"center",size:J==="multiple"?40:30};if(T){let s=nt;s<0&&(s=n.length+s+1),s=Math.max(0,Math.min(s,n.length)),n.splice(s,0,f)}if(Y){let s={id:"serialNumber",header:"No.",cell:({row:v})=>r("div",{className:"text-center font-medium text-muted-foreground",children:v.index+1}),enableSorting:!0,enableHiding:!1,enablePinning:!0,size:60,headerAlign:"center"};n.unshift(s)}return n},[a,Y,T,he,M,p,J,nt]),h=Io({data:Ye,columns:Ae,onSortingChange:Be?se:void 0,onColumnFiltersChange:Le?te:void 0,onGlobalFilterChange:Ze?t:void 0,getCoreRowModel:To(),getPaginationRowModel:m.enabled?Mo():void 0,getSortedRowModel:Be?Ro():void 0,getFilteredRowModel:Le?zo():void 0,onColumnVisibilityChange:Ge?Fe:void 0,onRowSelectionChange:T?le:void 0,onColumnOrderChange:g,onColumnPinningChange:_?Rt:void 0,state:{sorting:Be?ve:void 0,columnFilters:Le?xe:void 0,columnVisibility:Ge?_e:void 0,rowSelection:T?oe:{},globalFilter:ne,columnOrder:u,columnPinning:_?j:{}},initialState:{pagination:m.enabled?{pageSize:m.pageSize||10}:void 0,columnPinning:_?{left:[...Y?["serialNumber"]:[],...T?["select"]:[]],right:[]}:void 0},enableRowSelection:T,enableColumnResizing:ot,enableColumnPinning:_,columnResizeMode:"onChange"});Ie(()=>{if(T&&S){let d=h.getFilteredSelectedRowModel().rows.filter(c=>!M?.(c.original)&&(p?p(c.original):!0)).map(c=>c.original);S(d)}},[oe,T,S,h,M,p]);let jt=Re(d=>{J==="single"?(h.resetRowSelection(),d.toggleSelected(!0)):d.toggleSelected()},[J,h]);Ie(()=>{W&&W(h)},[h,W]),Ie(()=>{if(T&&S){let d=h.getFilteredSelectedRowModel().rows.map(c=>c.original);S(d)}},[oe,T,S,h]),Ie(()=>{if(T&&S){let d=h.getFilteredSelectedRowModel().rows.filter(c=>!M?.(c.original)&&(p?p(c.original):!0)).map(c=>c.original);S(d)}},[oe,T,S,h,M,p]);let Ut=Re(()=>{se([])},[]),Et=Re(()=>{te([]),t("")},[]),at=(d,c)=>{if(!_)return;let n=[...Y?["serialNumber"]:[],...T&&he?["select"]:[]],f={left:[...(j.left??[]).filter(s=>n.includes(s))],right:[...j.right??[]]};c===!1?(f.left=f.left.filter(s=>s!==d),f.right=f.right.filter(s=>s!==d)):c==="right"?(f.left=f.left.filter(s=>s!==d),f.right.includes(d)||f.right.push(d)):c==="left"&&(f.right=f.right.filter(s=>s!==d),!f.left.includes(d)&&!n.includes(d)&&f.left.push(d)),h.setColumnPinning(f)},$t=()=>r(lt,{className:o(_t&&"sticky top-0 bg-sidebar z-20"),children:h.getHeaderGroups().map((d,c)=>r(de,{className:"hover:bg-transparent",children:d.headers.map((n,f)=>{let s=n.depth===0&&n.colSpan>1,v=_&&(n.column.getIsPinned()==="left"||n.column.id==="serialNumber"||n.column.id==="select"&&T),k=_&&n.column.getIsPinned()==="right",L=n.column.getCanSort(),V=_&&n.column.columnDef.enablePinning!==!1,ae=n.column.id==="serialNumber",He=n.column.id==="select",st=ae||He&&he,re=n.column.columnDef.headerAlign||"left",Wt={left:"justify-start",center:"justify-center",right:"justify-end"}[re];return N(ut,{colSpan:n.colSpan,className:o("font-semibold text-foreground bg-sidebar group px-0",!et&&"py-2",tt&&f<d.headers.length-1&&"border-r","relative",v&&"sticky left-0 z-15 bg-sidebar",k&&"sticky right-0 z-15 bg-sidebar",(ae||He)&&"sticky left-0 z-15 bg-sidebar",s?"text-center":"text-left"),style:{width:n.getSize()!==150?n.getSize():"auto",minWidth:n.getSize()!==150?n.getSize():"auto",...v&&{left:ae?0:He?Y&&h.getColumn("serialNumber")?.getSize()||0:rt(n.column)},...k&&{right:it(n.column)},...ae&&{left:0}},children:[s?r("div",{className:"flex items-center justify-center",children:Xe(n.column.columnDef.header,n.getContext())}):N("div",{className:o("relative flex items-center w-full px-2",Wt),children:[N("div",{className:"flex items-center gap-1",children:[L&&re==="right"&&r("span",{className:"ml-1 order-2",children:n.column.getIsSorted()&&{asc:r(Ke,{className:"h-4 w-4"}),desc:r(Qe,{className:"h-4 w-4"})}[n.column.getIsSorted()]}),n.isPlaceholder?null:Xe(n.column.columnDef.header,n.getContext()),L&&re!=="right"&&n.column.getIsSorted()&&r("span",{className:"ml-1 order-2",children:n.column.getIsSorted()&&{asc:r(Ke,{className:"h-4 w-4"}),desc:r(Qe,{className:"h-4 w-4"})}[n.column.getIsSorted()]})]}),(L||V&&!st)&&N(ue,{children:[r(me,{asChild:!0,className:o("absolute",re==="left"&&"right-1",re==="center"&&"right-1",re==="right"&&"left-1"),children:r(kt,{variant:"default",size:"sm",noBg:!0,tabIndex:-1,className:"opacity-0 group-hover:opacity-70 hover:opacity-100 data-[state=open]:opacity-100",children:r(Fo,{className:"h-4 w-4"})})}),N(pe,{align:"end",className:"w-48",children:[L&&N(Mt,{children:[r(U,{children:"Sorting"}),N(A,{onClick:()=>n.column.toggleSorting(!1),children:[r(Ke,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),N(A,{onClick:()=>n.column.toggleSorting(!0),children:[r(Qe,{className:"mr-2 h-4 w-4"}),"Sort Descending"]}),N(A,{onClick:()=>n.column.clearSorting(),disabled:!n.column.getIsSorted(),children:[r(_o,{className:"mr-2 h-4 w-4"}),"Clear Sort"]}),r(Z,{})]}),V&&!st&&N(Mt,{children:[r(U,{children:"Pin Column"}),N(A,{onClick:()=>at(n.column.id,"right"),disabled:n.column.getIsPinned()==="right",children:[r(Vo,{}),"Pin Right"]}),N(A,{onClick:()=>at(n.column.id,!1),disabled:!n.column.getIsPinned(),children:[r(Bo,{}),"Unpin"]})]})]})]})]}),ot&&n.column.getCanResize()&&!s&&n.colSpan===1&&r("div",{className:"absolute right-0 top-0 h-full w-1 bg-border hover:bg-primary cursor-col-resize opacity-0 hover:opacity-100 transition-opacity",onMouseDown:n.getResizeHandler()})]},n.id)})},d.id))}),rt=d=>{if(!_)return;let c=0,n=h.getLeftHeaderGroups()[0]?.headers||[],f=[...Y?["serialNumber"]:[],...T?["select"]:[]];for(let s of n){if(s.id===d.id)break;if(f.includes(s.id)){let v=h.getColumn(s.id);v&&(c+=v.getSize())}}return c},it=d=>{if(!_)return;let c=h.getState().columnPinning.right||[],n=c.indexOf(d.id);if(n===-1)return;let f=0;for(let s=n+1;s<c.length;s++){let v=h.getColumn(c[s]);v&&(f+=v.getSize())}return f};return D?r(ye,{className:"w-full rounded-xl shadow-sm",children:r(Pe,{className:"flex items-center justify-center",children:N("div",{className:"text-center",children:[r("div",{className:"text-red-500 mb-3 text-2xl",children:"\u26A0\uFE0F"}),r("p",{className:"text-sm text-muted-foreground mb-4",children:D}),H&&N(w,{variant:"outline",size:"sm",onClick:H,className:"rounded-lg",children:[r(Tt,{className:"mr-2 h-4 w-4"}),"Try Again"]})]})})}):r(pt,{children:N("div",{className:o("w-full space-y-2 flex flex-col h-full",E),children:[x&&r(ye,{className:"rounded-2xl py-2 sticky top-0 z-20",children:r(Pe,{className:"px-2",children:x})}),Ft&&r(Nt,{table:h,filters:i,globalFilter:ne,onGlobalFilterChange:t,enableGlobalFilter:Ze,onExport:$,onRefresh:H,loading:C,enableColumnVisibility:Ge,enableColumnPinning:_,data:Ye,onClearSorting:Ut,onClearFilters:Et,onExternalSearch:be,onCustomFilterChange:Ot}),r(ye,{className:o("shadow-sm overflow-auto py-0",Lt&&"flex-1"),children:r(Pe,{className:"p-0 h-full",children:N("div",{className:"relative flex flex-col h-full justify-between",children:[C&&r("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm z-50 flex items-center justify-center rounded-xl",children:N("div",{className:"flex items-center gap-3 bg-background/90 px-4 py-3 rounded-lg shadow-sm",children:[r(Tt,{className:"size-5 animate-spin text-primary"}),r("span",{className:"text-sm font-medium text-muted-foreground",children:"Loading..."})]})}),r("div",{className:"relative rounded-t-xl overflow-auto border-b",children:N(Oe,{className:"border-collapse w-full",children:[!Gt&&$t(),r(dt,{children:h.getRowModel().rows?.length?h.getRowModel().rows.map((d,c)=>r(de,{"data-state":d.getIsSelected()&&"selected",className:o(Bt&&"hover:bg-muted/50",Vt&&c%2===0&&"bg-muted/20",d.getIsSelected()&&"bg-muted","border-b last:border-b-0",J==="single"&&"cursor-pointer"),onClick:()=>{J==="single"&&jt(d)},children:d.getVisibleCells().map((n,f)=>{let s=_&&(n.column.getIsPinned()==="left"||n.column.id==="serialNumber"||n.column.id==="select"&&T),v=_&&n.column.getIsPinned()==="right",k=n.column.id==="serialNumber",L=n.column.id==="select",V=k||L&&he;return r(we,{className:o(et?"py-2":"py-4",tt&&f<d.getVisibleCells().length&&"border-r",s&&"sticky left-0 z-10 bg-sidebar/97",v&&"sticky right-0 z-10 bg-sidebar/97",k&&"sticky left-0 z-10 bg-sidebar/97","p-1"),style:{width:n.column.getSize()!==150?n.column.getSize():"auto",minWidth:n.column.getSize()!==150?n.column.getSize():"auto",...s&&{left:k?0:L?Y&&h.getColumn("serialNumber")?.getSize()||0:rt(n.column)},...v&&{right:it(n.column)},...k&&{left:0}},children:Xe(n.column.columnDef.cell,n.getContext())},n.id)})},d.id)):r(de,{children:r(we,{colSpan:Ae.length,className:"h-32 text-center border-0",children:N("div",{className:"flex flex-col items-center gap-3",children:[r("div",{className:"text-muted-foreground text-6xl",children:"\u{1F4CB}"}),r("p",{className:"text-muted-foreground font-medium",children:F})]})})})})]})}),I&&r("div",{className:"sticky bottom-0 bg-sidebar w-full z-20",style:{width:"100%",minWidth:"fit-content"},children:r(Oe,{children:r(ct,{children:r(de,{className:"bg-sidebar",children:r(we,{colSpan:Ae.length,className:"p-2",children:I})})})})})]})})}),r(St,{table:h,config:m}),q&&q(h)]})})}export{Pa as DataTable};
3
3
  //# sourceMappingURL=data-table.js.map