@akshar-technosoft/ui 1.0.13 → 1.0.14

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