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