@akshar-technosoft/ui 1.0.16 → 1.0.18

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.
@@ -1,3 +1,3 @@
1
1
  "use client"
2
- import{Search as ze,RefreshCw as it,Download as st,Settings2 as lt,Filter as Re,ArrowUpDown as dt,PinOff as ct,Pin as ut,ChevronDown as Ie,Calculator as se}from"lucide-react";import{Slot as Ue}from"radix-ui";import{cva as Ee}from"class-variance-authority";import{clsx as je}from"clsx";import{twMerge as Oe}from"tailwind-merge";function o(...t){return Oe(je(t))}import{jsx as $e}from"react/jsx-runtime";var G=Ee("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 f({className:t,variant:r,size:i,asChild:c=!1,...y}){let v=c?Ue.Slot:"button";return $e(v,{"data-slot":"button",className:o(G({variant:r,size:i,className:t}),"transition-none"),...y})}import{jsx as qe}from"react/jsx-runtime";function te({className:t,type:r,...i}){return qe("input",{type:r,"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",t),...i})}import{Select as w}from"radix-ui";import{CheckIcon as He,ChevronDownIcon as pe,ChevronUpIcon as We}from"lucide-react";import{jsx as g,jsxs as ne}from"react/jsx-runtime";function me({...t}){return g(w.Root,{"data-slot":"select",...t})}function ge({...t}){return g(w.Value,{"data-slot":"select-value",...t})}function fe({className:t,size:r="default",children:i,...c}){return ne(w.Trigger,{"data-slot":"select-trigger","data-size":r,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",t),...c,children:[i,g(w.Icon,{asChild:!0,children:g(pe,{className:"size-4 opacity-50"})})]})}function ve({className:t,children:r,position:i="popper",...c}){return g(w.Portal,{children:ne(w.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",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",t),position:i,...c,children:[g(Xe,{}),g(w.Viewport,{className:o("p-1",i==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),g(Je,{})]})})}function oe({className:t,children:r,...i}){return ne(w.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",t),...i,children:[g("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:g(w.ItemIndicator,{children:g(He,{className:"size-4"})})}),g(w.ItemText,{children:r})]})}function Xe({className:t,...r}){return g(w.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:o("flex cursor-default items-center justify-center py-1",t),...r,children:g(We,{className:"size-4"})})}function Je({className:t,...r}){return g(w.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:o("flex cursor-default items-center justify-center py-1",t),...r,children:g(pe,{className:"size-4"})})}import{DropdownMenu as h}from"radix-ui";import{CheckIcon as Ke,ChevronRightIcon as Qe,CircleIcon as _t}from"lucide-react";import{jsx as b,jsxs as we}from"react/jsx-runtime";function j({...t}){return b(h.Root,{"data-slot":"dropdown-menu",...t})}function O({...t}){return b(h.Trigger,{"data-slot":"dropdown-menu-trigger",...t})}function U({className:t,sideOffset:r=4,...i}){return b(h.Portal,{children:b(h.Content,{"data-slot":"dropdown-menu-content",sideOffset:r,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",t),...i})})}function ae({...t}){return b(h.Group,{"data-slot":"dropdown-menu-group",...t})}function F({className:t,inset:r,variant:i="default",...c}){return b(h.Item,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":i,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",t),...c})}function E({className:t,children:r,checked:i,...c}){return we(h.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",t),checked:i,...c,children:[b("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:b(h.ItemIndicator,{children:b(Ke,{className:"size-4"})})}),r]})}function M({className:t,inset:r,...i}){return b(h.Label,{"data-slot":"dropdown-menu-label","data-inset":r,className:o("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...i})}function V({className:t,...r}){return b(h.Separator,{"data-slot":"dropdown-menu-separator",className:o("bg-border -mx-1 my-1 h-px",t),...r})}function be({...t}){return b(h.Sub,{"data-slot":"dropdown-menu-sub",...t})}function xe({className:t,inset:r,children:i,...c}){return we(h.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":r,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",t),...c,children:[i,b(Qe,{className:"ml-auto size-4"})]})}function he({className:t,...r}){return b(h.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",t),...r})}import{useState as _e}from"react";import{useEffect as nt,useState as re}from"react";import{Calendar as at}from"lucide-react";import{format as A}from"date-fns";import{Popover as $}from"radix-ui";import{jsx as q}from"react/jsx-runtime";function ye({...t}){return q($.Root,{"data-slot":"popover",...t})}function Ce({...t}){return q($.Trigger,{"data-slot":"popover-trigger",...t})}function Pe({className:t,align:r="center",sideOffset:i=4,...c}){return q($.Portal,{children:q($.Content,{"data-slot":"popover-content",align:r,sideOffset:i,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",t),...c})})}import*as H from"react";import{ChevronDownIcon as Ye,ChevronLeftIcon as Ze,ChevronRightIcon as et}from"lucide-react";import{DayPicker as tt,getDefaultClassNames as Ne}from"react-day-picker";import{jsx as S}from"react/jsx-runtime";function De({className:t,classNames:r,showOutsideDays:i=!0,captionLayout:c="label",buttonVariant:y="ghost",formatters:v,components:P,...I}){let d=Ne();return S(tt,{showOutsideDays:i,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`,t),captionLayout:c,formatters:{formatMonthDropdown:m=>m.toLocaleString("default",{month:"short"}),...v},classNames:{root:o("w-fit",d.root),months:o("flex gap-4 flex-col md:flex-row relative",d.months),month:o("flex flex-col w-full gap-4",d.month),nav:o("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",d.nav),button_previous:o(G({variant:y}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",d.button_previous),button_next:o(G({variant:y}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",d.button_next),month_caption:o("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",d.month_caption),dropdowns:o("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",d.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",d.dropdown_root),dropdown:o("absolute bg-popover inset-0 opacity-0",d.dropdown),caption_label:o("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",d.caption_label),table:"w-full border-collapse",weekdays:o("flex",d.weekdays),weekday:o("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",d.weekday),week:o("flex w-full mt-2",d.week),week_number_header:o("select-none w-(--cell-size)",d.week_number_header),week_number:o("text-[0.8rem] select-none text-muted-foreground",d.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",d.day),range_start:o("rounded-l-md bg-accent",d.range_start),range_middle:o("rounded-none",d.range_middle),range_end:o("rounded-r-md bg-accent",d.range_end),today:o("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",d.today),outside:o("text-muted-foreground aria-selected:text-muted-foreground",d.outside),disabled:o("text-muted-foreground opacity-50",d.disabled),hidden:o("invisible",d.hidden),...r},components:{Root:({className:m,rootRef:x,...N})=>S("div",{"data-slot":"calendar",ref:x,className:o(m),...N}),Chevron:({className:m,orientation:x,...N})=>x==="left"?S(Ze,{className:o("size-4",m),...N}):x==="right"?S(et,{className:o("size-4",m),...N}):S(Ye,{className:o("size-4",m),...N}),DayButton:ot,WeekNumber:({children:m,...x})=>S("td",{...x,children:S("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:m})}),...P},...I})}function ot({className:t,day:r,modifiers:i,...c}){let y=Ne(),v=H.useRef(null);return H.useEffect(()=>{i.focused&&v.current?.focus()},[i.focused]),S(f,{ref:v,variant:"ghost",size:"icon","data-day":r.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: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",y.day,t),...c})}import{jsx as R,jsxs as B}from"react/jsx-runtime";function ke({value:t,onChange:r,placeholder:i,mode:c,externalSearch:y,onExternalChange:v,onlyExternal:P=!1}){let[I,d]=re(!1),[m,x]=re(t),[N,z]=re(t);nt(()=>{P||z(t)},[t,P]);let _=()=>{P||r(m),z(m),y&&v&&v(m),d(!1)},T=()=>{x(N),d(!1)},k=()=>{let u=c==="single"?null:{from:null,to:null};x(u),P||r(u),z(u),y&&v&&v(u),d(!1)},D=()=>{let u=P?N:t;return u?c==="single"?A(u,"PPP"):u.from&&u.to?`${A(u.from,"MMM dd")} - ${A(u.to,"MMM dd, yyyy")}`:u.from?`From ${A(u.from,"MMM dd, yyyy")}`:u.to?`To ${A(u.to,"MMM dd, yyyy")}`:i:i},L=u=>{x(c==="single"?u:u||{from:null,to:null})};return B(ye,{open:I,onOpenChange:d,children:[R(Ce,{asChild:!0,children:B(f,{variant:"outline",className:o("w-full justify-start text-left font-normal h-9",!D()&&"text-muted-foreground"),children:[R(at,{className:"mr-2 h-4 w-4"}),D()]})}),B(Pe,{className:"w-auto p-0",align:"start",children:[R("div",{className:"p-3",children:R(De,{mode:c,selected:m,onSelect:L,numberOfMonths:c==="range"?2:1,className:"rounded-md border",...c==="range"&&{required:!0}})}),B("div",{className:"flex items-center justify-between p-3 border-t",children:[R(f,{variant:"ghost",size:"sm",onClick:k,children:"Clear"}),B("div",{className:"flex gap-2",children:[R(f,{variant:"outline",size:"sm",onClick:T,children:"Cancel"}),R(f,{size:"sm",onClick:_,disabled:c==="range"&&(!m?.from||!m?.to),children:"Apply"})]})]})]})]})}import{Checkbox as Me}from"radix-ui";import{CheckIcon as rt}from"lucide-react";import{jsx as ie}from"react/jsx-runtime";function Se({className:t,...r}){return ie(Me.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",t),...r,children:ie(Me.Indicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:ie(rt,{className:"size-3.5"})})})}import{Fragment as pt,jsx as n,jsxs as l}from"react/jsx-runtime";var Te=[{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 ho({table:t,filters:r=[],globalFilter:i,onGlobalFilterChange:c,enableGlobalFilter:y=!0,onExport:v,onRefresh:P,loading:I=!1,enableColumnVisibility:d=!0,data:m,onClearSorting:x,onClearFilters:N,enableColumnPinning:z=!1,onExternalSearch:_,onCustomFilterChange:T,aggregations:k={},onAggregationChange:D}){let[L,u]=_e({}),[W,le]=_e({}),X=()=>t.getAllLeafColumns().filter(e=>e.getCanHide?.()!==!1),de=()=>t.getAllColumns().filter(e=>!t.getAllLeafColumns().includes(e)&&e.columns?.length&&e.columns.some(a=>a.getCanHide?.()!==!1)),ce=()=>{let e=new Set(de().flatMap(a=>a.columns?.filter(s=>s.getCanHide?.()!==!1).map(s=>s.id)||[]));return X().filter(a=>!e.has(a.id))},J=(e,a)=>a&&e.startsWith(`${a}.`)?e.replace(`${a}.`,"").split("_").map(p=>p.slice(1)).join(" "):e.split("_").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "),K=(e,a)=>{let s={...L,[e]:a};u(s)},Fe=(e,a)=>{let s={...W,[e]:a};le(s),T&&T(e,a),r.find(p=>p.key===e)?.externalSearch&&K(e,a)},Ve=()=>{_&&_(L)},Ae=()=>{u({}),le({}),N(),_&&_({}),T&&Object.keys(W).forEach(e=>{T(e,"")})},Q=e=>r.find(s=>s.key===e)?.customFilter?W[e]??"":t.getColumn(e)?.getFilterValue(),Y=(e,a)=>{let s=r.find(p=>p.key===e);s?.customFilter?Fe(e,a):(t.getColumn(e)?.setFilterValue(a),s?.externalSearch&&K(e,a))},Be=e=>{if(D){let a=k[e],s={enabled:!a?.enabled,functions:a?.functions||["sum","average"]};D(e,s)}},Le=(e,a)=>{if(D){let p=k[e]?.functions||[],C=p.includes(a)?p.filter(Ge=>Ge!==a):[...p,a];D(e,{enabled:C.length>0,functions:C})}},ue=()=>{D&&Object.keys(k).forEach(e=>{let a=k[e];a&&D(e,{...a,enabled:!1,functions:[]})})},Z=X().filter(e=>e.id==="select"||e.id==="serialNumber"?!1:e.columnDef.meta?.aggregatable?!0:t.getRowModel().rows.slice(0,5).some(p=>{let C=p.getValue(e.id);return typeof C=="number"||typeof C=="string"&&!isNaN(parseFloat(String(C)))||typeof C=="object"&&C!==null&&"props"in C})),ee=Object.values(k).some(e=>e?.enabled);return n("div",{className:"rounded-xl",children:n("div",{className:"px-2",children:n("div",{className:"flex flex-col gap-6",children:l("div",{className:"flex items-center justify-between",children:[n("div",{className:"flex items-center gap-3",children:r.length>0&&l("div",{className:"flex flex-wrap items-center gap-3",children:[n("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:n(Re,{className:"size-4"})}),r.map(e=>!t.getColumn(e.key)&&!e.customFilter&&!e.externalSearch?null:n("div",{className:o("relative min-w-[150px]",e.width),children:e.type==="select"?l(me,{value:Q(e.key)??"",onValueChange:s=>{Y(e.key,s==="all"?"":s)},children:[e.icon&&n("span",{children:n(e.icon,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground"})}),n(fe,{className:o("h-9 rounded-lg w-full",e.icon&&"pl-9"),children:n(ge,{placeholder:e.placeholder})}),l(ve,{className:"rounded-lg",children:[n(oe,{value:"all",children:"All"}),e.options?.map(s=>n(oe,{value:s.value,children:s.label},s.label))]})]}):e.type==="date"?n(ke,{value:Q(e.key),onChange:s=>{e.onlyExternal||Y(e.key,s)},placeholder:e.placeholder,mode:e.dateMode||"single",externalSearch:e.externalSearch,onlyExternal:e.onlyExternal,onExternalChange:s=>K(e.key,s)}):l("div",{className:"relative",children:[e.icon&&n("span",{children:n(e.icon,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground"})}),n(te,{placeholder:e.placeholder,value:Q(e.key)??"",onChange:s=>{Y(e.key,s.target.value)},className:o("h-7 rounded-lg",e.icon&&"pl-9"),type:e.type==="number"?"number":"text"})]})},e.key)),(r.some(e=>e.externalSearch)||r.some(e=>e.customFilter))&&l(f,{variant:"default",size:"sm",onClick:Ve,className:"rounded-lg h-7",children:[n(ze,{className:"size-4"}),r.find(e=>e.externalSearch||e.customFilter)?.searchButtonText||"Search"]})]})}),l("div",{className:"flex items-center gap-2",children:[y&&l("div",{className:"relative",children:[n(ze,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground"}),n(te,{placeholder:"Global search...",value:i??"",onChange:e=>c(e.target.value),className:"pl-9 h-7 max-w-max"})]}),Z.length>0&&D&&l(j,{children:[n(O,{asChild:!0,children:l(f,{variant:"outline",size:"sm",className:o("rounded-lg gap-1",ee&&"bg-primary/10 dark:bg-primary/10 border-primary/20 dark:border-primary/20"),children:[n(se,{className:"size-4"}),n("span",{children:"Aggregations"}),n(Ie,{className:"opacity-50 size-4"})]})}),l(U,{align:"end",className:"w-64 rounded-lg max-h-[500px] overflow-y-auto",children:[l(M,{className:"flex items-center justify-between px-4 py-2",children:[n("span",{className:"text-sm font-medium",children:"Column Aggregations"}),ee&&n(f,{variant:"ghost",size:"sm",onClick:ue,className:"h-6 px-2 text-xs",children:"Clear All"})]}),n(V,{}),Z.map(e=>{let a=k[e.id],s=a?.enabled;return l(be,{children:[n(xe,{className:"text-sm",children:l("div",{className:"flex items-center w-full gap-2",children:[n(Se,{checked:s,onCheckedChange:()=>Be(e.id),className:"data-[state=checked]:bg-primary"}),n("span",{className:o("flex-1",s&&"font-medium text-primary"),children:J(e.id)}),s&&l("div",{className:"flex items-center gap-1",children:[a?.functions?.slice(0,2).map(p=>n("div",{className:"w-2 h-2 rounded-full bg-primary",title:Te.find(C=>C.value===p)?.label},p)),a?.functions&&a.functions.length>2&&l("div",{className:"text-xs text-muted-foreground",children:["+",a.functions.length-2]})]})]})}),l(he,{className:"w-48 rounded-lg",children:[n(M,{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Select Functions"}),Te.map(p=>n(E,{checked:a?.functions?.includes(p.value)||!1,onCheckedChange:()=>Le(e.id,p.value),className:"py-2 text-sm",children:l("div",{className:"flex flex-col",children:[n("span",{children:p.label}),n("span",{className:"text-xs text-muted-foreground",children:p.description})]})},p.value))]})]},e.id)}),Z.length===0&&l("div",{className:"px-3 py-4 text-center",children:[n(se,{className:"w-8 h-8 mx-auto mb-2 opacity-50 text-muted-foreground"}),n("p",{className:"text-sm text-muted-foreground",children:"No numeric columns available for aggregation"})]})]})]}),v&&l(f,{variant:"outline",size:"sm",onClick:()=>v(m),className:"rounded-lg",children:[n(st,{className:"size-4"}),"Export"]}),d&&l(j,{children:[n(O,{asChild:!0,className:"h-7",children:l(f,{variant:"outline",size:"sm",className:"gap-1 rounded-lg",children:[n("span",{children:"Columns"}),n(Ie,{className:"opacity-50 size-4"})]})}),l(U,{align:"end",className:"w-[220px] rounded-lg max-h-[400px] overflow-y-auto",children:[n(M,{className:"px-4 py-2 text-sm font-medium",children:"Toggle Columns"}),n(V,{}),ce().length>0&&l(ae,{children:[n(M,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:"General"}),ce().map(e=>n(E,{className:"text-sm",checked:e.getIsVisible(),onCheckedChange:a=>e.toggleVisibility(!!a),children:J(e.id)},e.id))]}),de().map(e=>l(ae,{children:[n(V,{}),n(M,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:e.id}),e.columns?.filter(a=>a.getCanHide?.()!==!1).map(a=>n(E,{className:"text-sm",checked:a.getIsVisible(),onCheckedChange:s=>a.toggleVisibility(!!s),children:J(a.id,e.id)},a.id))]},e.id))]})]}),l(j,{children:[n(O,{asChild:!0,className:"h-7",children:n(f,{variant:"outline",size:"sm",className:"rounded-lg h-7",children:n(lt,{className:"size-4"})})}),l(U,{align:"end",className:"w-[200px] rounded-lg",children:[n(M,{children:"Table Settings"}),n(V,{}),l(F,{onClick:x,children:[n(dt,{className:"size-4"}),"Clear All Sorting"]}),l(F,{onClick:Ae,children:[n(Re,{className:"size-4"}),"Clear All Filters"]}),ee&&l(F,{onClick:ue,children:[n(se,{className:"size-4"}),"Clear Aggregations"]}),z&&l(pt,{children:[n(V,{}),n(M,{children:"Column Pinning"}),l(F,{onClick:()=>t.setColumnPinning({left:[],right:[]}),children:[n(ct,{className:"size-4"}),"Reset All Pinning"]}),l(F,{onClick:()=>{let e=X().filter(a=>a.getCanPin?.()!==!1).map(a=>a.id);t.setColumnPinning({left:[],right:e})},children:[n(ut,{className:"-rotate-90 size-4"}),"Pin All Right"]})]})]})]}),P&&n(f,{variant:"outline",size:"sm",onClick:P,disabled:I,className:"rounded-lg",children:n(it,{className:o("h-4 w-4",I&&"animate-spin")})})]})]})})})})}export{ho as DataTableToolbar};
2
+ import{Search as Te,RefreshCw as st,Download as dt,Settings2 as lt,Filter as Ie,ArrowUpDown as mt,PinOff as ut,Pin as ct,ChevronDown as me,Calculator as ue,Check as Fe}from"lucide-react";import{Slot as qe}from"radix-ui";import{cva as Ue}from"class-variance-authority";import{clsx as He}from"clsx";import{twMerge as $e}from"tailwind-merge";function o(...t){return $e(He(t))}import{jsx as We}from"react/jsx-runtime";var E=Ue("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 g({className:t,variant:r,size:d,asChild:m=!1,...h}){let f=m?qe.Slot:"button";return We(f,{"data-slot":"button",className:o(E({variant:r,size:d,className:t}),"transition-none"),...h})}import{jsx as Xe}from"react/jsx-runtime";function re({className:t,type:r,...d}){return Xe("input",{type:r,"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",t),...d})}import{Command as F}from"cmdk";import{SearchIcon as Je}from"lucide-react";import{Dialog as Mt}from"radix-ui";import{XIcon as zt}from"lucide-react";import{jsx as Tt,jsxs as It}from"react/jsx-runtime";import{jsx as z,jsxs as Ke}from"react/jsx-runtime";function xe({className:t,...r}){return z(F,{"data-slot":"command",className:o("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...r})}function he({className:t,...r}){return Ke("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[z(Je,{className:"size-4 shrink-0 opacity-50"}),z(F.Input,{"data-slot":"command-input",className:o("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...r})]})}function ye({className:t,...r}){return z(F.List,{"data-slot":"command-list",className:o("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...r})}function Ce({...t}){return z(F.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function we({className:t,...r}){return z(F.Group,{"data-slot":"command-group",className:o("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...r})}function ie({className:t,...r}){return z(F.Item,{"data-slot":"command-item",className:o("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}import{DropdownMenu as x}from"radix-ui";import{CheckIcon as Qe,ChevronRightIcon as Ye,CircleIcon as Xt}from"lucide-react";import{jsx as v,jsxs as Ne}from"react/jsx-runtime";function j({...t}){return v(x.Root,{"data-slot":"dropdown-menu",...t})}function H({...t}){return v(x.Trigger,{"data-slot":"dropdown-menu-trigger",...t})}function $({className:t,sideOffset:r=4,...d}){return v(x.Portal,{children:v(x.Content,{"data-slot":"dropdown-menu-content",sideOffset:r,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",t),...d})})}function se({...t}){return v(x.Group,{"data-slot":"dropdown-menu-group",...t})}function A({className:t,inset:r,variant:d="default",...m}){return v(x.Item,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":d,className:o("cursor-pointer focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...m})}function q({className:t,children:r,checked:d,...m}){return Ne(x.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",t),checked:d,...m,children:[v("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:v(x.ItemIndicator,{children:v(Qe,{className:"size-4"})})}),r]})}function k({className:t,inset:r,...d}){return v(x.Label,{"data-slot":"dropdown-menu-label","data-inset":r,className:o("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...d})}function V({className:t,...r}){return v(x.Separator,{"data-slot":"dropdown-menu-separator",className:o("bg-border -mx-1 my-1 h-px",t),...r})}function De({...t}){return v(x.Sub,{"data-slot":"dropdown-menu-sub",...t})}function Pe({className:t,inset:r,children:d,...m}){return Ne(x.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":r,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",t),...m,children:[d,v(Ye,{className:"ml-auto size-4"})]})}function ke({className:t,...r}){return v(x.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",t),...r})}import{useState as ce}from"react";import{useEffect as at,useState as de}from"react";import{Calendar as rt}from"lucide-react";import{format as L}from"date-fns";import{Popover as U}from"radix-ui";import{jsx as W}from"react/jsx-runtime";function X({...t}){return W(U.Root,{"data-slot":"popover",...t})}function J({...t}){return W(U.Trigger,{"data-slot":"popover-trigger",...t})}function K({className:t,align:r="center",sideOffset:d=4,...m}){return W(U.Portal,{children:W(U.Content,{"data-slot":"popover-content",align:r,sideOffset:d,className:o("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...m})})}import*as Q from"react";import{ChevronDownIcon as Ze,ChevronLeftIcon as et,ChevronRightIcon as tt}from"lucide-react";import{DayPicker as ot,getDefaultClassNames as Me}from"react-day-picker";import{jsx as N}from"react/jsx-runtime";function Re({className:t,classNames:r,showOutsideDays:d=!0,captionLayout:m="label",buttonVariant:h="ghost",formatters:f,components:C,...S}){let l=Me();return N(ot,{showOutsideDays:d,className:o("bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,t),captionLayout:m,formatters:{formatMonthDropdown:p=>p.toLocaleString("default",{month:"short"}),...f},classNames:{root:o("w-fit",l.root),months:o("flex gap-4 flex-col md:flex-row relative",l.months),month:o("flex flex-col w-full gap-4",l.month),nav:o("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",l.nav),button_previous:o(E({variant:h}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",l.button_previous),button_next:o(E({variant:h}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",l.button_next),month_caption:o("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",l.month_caption),dropdowns:o("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",l.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",l.dropdown_root),dropdown:o("absolute bg-popover inset-0 opacity-0",l.dropdown),caption_label:o("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",l.caption_label),table:"w-full border-collapse",weekdays:o("flex",l.weekdays),weekday:o("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",l.weekday),week:o("flex w-full mt-2",l.week),week_number_header:o("select-none w-(--cell-size)",l.week_number_header),week_number:o("text-[0.8rem] select-none text-muted-foreground",l.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",l.day),range_start:o("rounded-l-md bg-accent",l.range_start),range_middle:o("rounded-none",l.range_middle),range_end:o("rounded-r-md bg-accent",l.range_end),today:o("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",l.today),outside:o("text-muted-foreground aria-selected:text-muted-foreground",l.outside),disabled:o("text-muted-foreground opacity-50",l.disabled),hidden:o("invisible",l.hidden),...r},components:{Root:({className:p,rootRef:b,...w})=>N("div",{"data-slot":"calendar",ref:b,className:o(p),...w}),Chevron:({className:p,orientation:b,...w})=>b==="left"?N(et,{className:o("size-4",p),...w}):b==="right"?N(tt,{className:o("size-4",p),...w}):N(Ze,{className:o("size-4",p),...w}),DayButton:nt,WeekNumber:({children:p,...b})=>N("td",{...b,children:N("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:p})}),...C},...S})}function nt({className:t,day:r,modifiers:d,...m}){let h=Me(),f=Q.useRef(null);return Q.useEffect(()=>{d.focused&&f.current?.focus()},[d.focused]),N(g,{ref:f,variant:"ghost",size:"icon","data-day":r.date.toLocaleDateString(),"data-selected-single":d.selected&&!d.range_start&&!d.range_end&&!d.range_middle,"data-range-start":d.range_start,"data-range-end":d.range_end,"data-range-middle":d.range_middle,className:o("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",h.day,t),...m})}import{jsx as _,jsxs as B}from"react/jsx-runtime";function ze({value:t,onChange:r,placeholder:d,mode:m,externalSearch:h,onExternalChange:f,onlyExternal:C=!1}){let[S,l]=de(!1),[p,b]=de(t),[w,M]=de(t);at(()=>{C||M(t)},[t,C]);let T=()=>{C||r(p),M(p),h&&f&&f(p),l(!1)},I=()=>{b(w),l(!1)},P=()=>{let u=m==="single"?null:{from:null,to:null};b(u),C||r(u),M(u),h&&f&&f(u),l(!1)},D=()=>{let u=C?w:t;return u?m==="single"?L(u,"PPP"):u.from&&u.to?`${L(u.from,"MMM dd")} - ${L(u.to,"MMM dd, yyyy")}`:u.from?`From ${L(u.from,"MMM dd, yyyy")}`:u.to?`To ${L(u.to,"MMM dd, yyyy")}`:d:d},G=u=>{b(m==="single"?u:u||{from:null,to:null})};return B(X,{open:S,onOpenChange:l,children:[_(J,{className:"h-8",asChild:!0,children:B(g,{variant:"outline",className:o("w-full justify-start text-left font-normal h-9",!D()&&"text-muted-foreground"),children:[_(rt,{className:"mr-2 h-4 w-4"}),D()]})}),B(K,{className:"w-auto p-0",align:"start",children:[_("div",{className:"p-3",children:_(Re,{mode:m,selected:p,onSelect:G,numberOfMonths:m==="range"?2:1,className:"rounded-md border",...m==="range"&&{required:!0}})}),B("div",{className:"flex items-center justify-between p-3 border-t",children:[_(g,{variant:"ghost",size:"sm",onClick:P,children:"Clear"}),B("div",{className:"flex gap-2",children:[_(g,{variant:"outline",size:"sm",onClick:I,children:"Cancel"}),_(g,{size:"sm",onClick:T,disabled:m==="range"&&(!p?.from||!p?.to),children:"Apply"})]})]})]})]})}import{Checkbox as _e}from"radix-ui";import{CheckIcon as it}from"lucide-react";import{jsx as le}from"react/jsx-runtime";function Se({className:t,...r}){return le(_e.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",t),...r,children:le(_e.Indicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:le(it,{className:"size-3.5"})})})}import{Fragment as pt,jsx as n,jsxs as s}from"react/jsx-runtime";var Ae=[{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 Lo({table:t,filters:r=[],globalFilter:d,onGlobalFilterChange:m,enableGlobalFilter:h=!0,onExport:f,onRefresh:C,loading:S=!1,enableColumnVisibility:l=!0,data:p,onClearSorting:b,onClearFilters:w,enableColumnPinning:M=!1,onExternalSearch:T,onCustomFilterChange:I,aggregations:P={},onAggregationChange:D}){let[G,u]=ce({}),[Y,pe]=ce({}),[ge,Ve]=ce({}),Z=()=>t.getAllLeafColumns().filter(e=>e.getCanHide?.()!==!1),fe=()=>t.getAllColumns().filter(e=>!t.getAllLeafColumns().includes(e)&&e.columns?.length&&e.columns.some(a=>a.getCanHide?.()!==!1)),ve=()=>{let e=new Set(fe().flatMap(a=>a.columns?.filter(i=>i.getCanHide?.()!==!1).map(i=>i.id)||[]));return Z().filter(a=>!e.has(a.id))},ee=(e,a)=>a&&e.startsWith(`${a}.`)?e.replace(`${a}.`,"").split("_").map(c=>c.slice(1)).join(" "):e.split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "),te=(e,a)=>{let i={...G,[e]:a};u(i)},Le=(e,a)=>{let i={...Y,[e]:a};pe(i),I&&I(e,a),r.find(c=>c.key===e)?.externalSearch&&te(e,a)},Be=()=>{T&&T(G)},Ge=()=>{u({}),pe({}),w(),T&&T({}),I&&Object.keys(Y).forEach(e=>{I(e,"")})},R=e=>r.find(i=>i.key===e)?.customFilter?Y[e]??"":t.getColumn(e)?.getFilterValue(),O=(e,a)=>{let i=r.find(c=>c.key===e);i?.customFilter?Le(e,a):(t.getColumn(e)?.setFilterValue(a),i?.externalSearch&&te(e,a))},oe=(e,a)=>{Ve(i=>({...i,[e]:a}))},Oe=e=>{if(D){let a=P[e],i={enabled:!a?.enabled,functions:a?.functions||["sum","average"]};D(e,i)}},Ee=(e,a)=>{if(D){let c=P[e]?.functions||[],y=c.includes(a)?c.filter(je=>je!==a):[...c,a];D(e,{enabled:y.length>0,functions:y})}},be=()=>{D&&Object.keys(P).forEach(e=>{let a=P[e];a&&D(e,{...a,enabled:!1,functions:[]})})},ne=Z().filter(e=>e.id==="select"||e.id==="serialNumber"?!1:e.columnDef.meta?.aggregatable?!0:t.getRowModel().rows.slice(0,5).some(c=>{let y=c.getValue(e.id);return typeof y=="number"||typeof y=="string"&&!isNaN(parseFloat(String(y)))||typeof y=="object"&&y!==null&&"props"in y})),ae=Object.values(P).some(e=>e?.enabled);return n("div",{className:"rounded-xl",children:n("div",{className:"px-2",children:n("div",{className:"flex flex-col gap-6",children:s("div",{className:"flex items-center justify-between",children:[n("div",{className:"flex items-center gap-3",children:r.length>0&&s("div",{className:"flex flex-wrap items-center gap-3",children:[n("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:n(Ie,{className:"size-4"})}),r.map(e=>!t.getColumn(e.key)&&!e.customFilter&&!e.externalSearch?null:n("div",{className:o("relative min-w-[150px]",e.width),children:e.type==="select"?s(X,{open:ge[e.key],onOpenChange:i=>oe(e.key,i),children:[n(J,{asChild:!0,children:s("div",{className:"relative w-full",children:[e.icon&&n(e.icon,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground pointer-events-none z-10"}),s(g,{variant:"outline",role:"combobox","aria-expanded":ge[e.key],className:o("h-8 sm:h-8 rounded-lg w-full justify-between font-normal",!R(e.key)&&"text-muted-foreground"),children:[n("span",{className:o("truncate",e.icon&&"pl-6"),children:R(e.key)?e.options?.find(i=>i.value===R(e.key))?.label:e.placeholder}),n(me,{className:"ml-2 opacity-50 size-4 shrink-0"})]})]})}),n(K,{className:"w-[--radix-popover-trigger-width] p-0 rounded-lg",children:s(xe,{className:"rounded-lg",children:[n(he,{placeholder:`Search ${e.placeholder?.toLowerCase()}...`}),s(ye,{children:[n(Ce,{children:"No option found."}),s(we,{children:[s(ie,{value:"all",onSelect:()=>{O(e.key,""),oe(e.key,!1)},className:"flex items-center cursor-pointer",children:[n(Fe,{className:o("mr-2 size-4 shrink-0",R(e.key)?"opacity-0":"opacity-100")}),n("span",{children:"All"})]}),e.options?.map(i=>s(ie,{value:i.label,onSelect:()=>{O(e.key,i.value),oe(e.key,!1)},className:"flex items-center cursor-pointer",children:[n(Fe,{className:o("mr-2 size-4 shrink-0",R(e.key)===i.value?"opacity-100":"opacity-0")}),n("span",{children:i.label})]},i.label))]})]})]})})]}):e.type==="date"?n(ze,{value:R(e.key),onChange:i=>{e.onlyExternal||O(e.key,i)},placeholder:e.placeholder,mode:e.dateMode||"single",externalSearch:e.externalSearch,onlyExternal:e.onlyExternal,onExternalChange:i=>te(e.key,i)}):s("div",{className:"relative",children:[e.icon&&n(e.icon,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground"}),n(re,{placeholder:e.placeholder,value:R(e.key)??"",onChange:i=>{O(e.key,i.target.value)},className:o("h-8 rounded-lg",e.icon&&"pl-9"),type:e.type==="number"?"number":"text"})]})},e.key)),(r.some(e=>e.externalSearch)||r.some(e=>e.customFilter))&&s(g,{variant:"default",size:"sm",onClick:Be,className:"rounded-lg h-7",children:[n(Te,{className:"size-4"}),r.find(e=>e.externalSearch||e.customFilter)?.searchButtonText||"Search"]})]})}),s("div",{className:"flex items-center gap-2",children:[h&&s("div",{className:"relative",children:[n(Te,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground"}),n(re,{placeholder:"Global search...",value:d??"",onChange:e=>m(e.target.value),className:"pl-9 h-8 max-w-max"})]}),ne.length>0&&D&&s(j,{children:[n(H,{asChild:!0,children:s(g,{variant:"outline",size:"sm",className:o("rounded-lg gap-1",ae&&"bg-primary/10 dark:bg-primary/10 border-primary/20 dark:border-primary/20"),children:[n(ue,{className:"size-4"}),n("span",{children:"Aggregations"}),n(me,{className:"opacity-50 size-4"})]})}),s($,{align:"end",className:"w-64 rounded-lg max-h-[500px] overflow-y-auto",children:[s(k,{className:"flex items-center justify-between px-4 py-2",children:[n("span",{className:"text-sm font-medium",children:"Column Aggregations"}),ae&&n(g,{variant:"ghost",size:"sm",onClick:be,className:"h-6 px-2 text-xs",children:"Clear All"})]}),n(V,{}),ne.map(e=>{let a=P[e.id],i=a?.enabled;return s(De,{children:[n(Pe,{className:"text-sm",children:s("div",{className:"flex items-center w-full gap-2",children:[n(Se,{checked:i,onCheckedChange:()=>Oe(e.id),className:"data-[state=checked]:bg-primary"}),n("span",{className:o("flex-1",i&&"font-medium text-primary"),children:ee(e.id)}),i&&s("div",{className:"flex items-center gap-1",children:[a?.functions?.slice(0,2).map(c=>n("div",{className:"w-2 h-2 rounded-full bg-primary",title:Ae.find(y=>y.value===c)?.label},c)),a?.functions&&a.functions.length>2&&s("div",{className:"text-xs text-muted-foreground",children:["+",a.functions.length-2]})]})]})}),s(ke,{className:"w-48 rounded-lg",children:[n(k,{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Select Functions"}),Ae.map(c=>n(q,{checked:a?.functions?.includes(c.value)||!1,onCheckedChange:()=>Ee(e.id,c.value),className:"py-2 text-sm",children:s("div",{className:"flex flex-col",children:[n("span",{children:c.label}),n("span",{className:"text-xs text-muted-foreground",children:c.description})]})},c.value))]})]},e.id)}),ne.length===0&&s("div",{className:"px-3 py-4 text-center",children:[n(ue,{className:"w-8 h-8 mx-auto mb-2 opacity-50 text-muted-foreground"}),n("p",{className:"text-sm text-muted-foreground",children:"No numeric columns available for aggregation"})]})]})]}),f&&s(g,{variant:"outline",size:"sm",onClick:()=>f(p),className:"rounded-lg",children:[n(dt,{className:"size-4"}),"Export"]}),l&&s(j,{children:[n(H,{asChild:!0,className:"h-7",children:s(g,{variant:"outline",size:"sm",className:"gap-1 rounded-lg",children:[n("span",{children:"Columns"}),n(me,{className:"opacity-50 size-4"})]})}),s($,{align:"end",className:"w-[220px] rounded-lg max-h-[400px] overflow-y-auto",children:[n(k,{className:"px-4 py-2 text-sm font-medium",children:"Toggle Columns"}),n(V,{}),ve().length>0&&s(se,{children:[n(k,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:"General"}),ve().map(e=>n(q,{className:"text-sm",checked:e.getIsVisible(),onCheckedChange:a=>e.toggleVisibility(!!a),children:ee(e.id)},e.id))]}),fe().map(e=>s(se,{children:[n(V,{}),n(k,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:e.id}),e.columns?.filter(a=>a.getCanHide?.()!==!1).map(a=>n(q,{className:"text-sm",checked:a.getIsVisible(),onCheckedChange:i=>a.toggleVisibility(!!i),children:ee(a.id,e.id)},a.id))]},e.id))]})]}),s(j,{children:[n(H,{asChild:!0,className:"h-7",children:n(g,{variant:"outline",size:"sm",className:"rounded-lg h-7",children:n(lt,{className:"size-4"})})}),s($,{align:"end",className:"w-[200px] rounded-lg",children:[n(k,{children:"Table Settings"}),n(V,{}),s(A,{onClick:b,children:[n(mt,{className:"size-4"}),"Clear All Sorting"]}),s(A,{onClick:Ge,children:[n(Ie,{className:"size-4"}),"Clear All Filters"]}),ae&&s(A,{onClick:be,children:[n(ue,{className:"size-4"}),"Clear Aggregations"]}),M&&s(pt,{children:[n(V,{}),n(k,{children:"Column Pinning"}),s(A,{onClick:()=>t.setColumnPinning({left:[],right:[]}),children:[n(ut,{className:"size-4"}),"Reset All Pinning"]}),s(A,{onClick:()=>{let e=Z().filter(a=>a.getCanPin?.()!==!1).map(a=>a.id);t.setColumnPinning({left:[],right:e})},children:[n(ct,{className:"-rotate-90 size-4"}),"Pin All Right"]})]})]})]}),C&&n(g,{variant:"outline",size:"sm",onClick:C,disabled:S,className:"rounded-lg",children:n(st,{className:o("h-4 w-4",S&&"animate-spin")})})]})]})})})})}export{Lo as DataTableToolbar};
3
3
  //# sourceMappingURL=data-table-toolbar.js.map