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