@akshar-technosoft/ui 1.0.14 → 1.0.15

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