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