@akshar-technosoft/ui 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data/data-table/data-table-toolbar.cjs +1 -1
- package/dist/components/data/data-table/data-table-toolbar.cjs.map +1 -1
- package/dist/components/data/data-table/data-table-toolbar.d.cts +4 -1
- package/dist/components/data/data-table/data-table-toolbar.d.ts +4 -1
- package/dist/components/data/data-table/data-table-toolbar.js +1 -1
- package/dist/components/data/data-table/data-table-toolbar.js.map +1 -1
- package/dist/components/data/data-table/data-table-types.cjs.map +1 -1
- package/dist/components/data/data-table/data-table-types.d.cts +1 -0
- package/dist/components/data/data-table/data-table-types.d.ts +1 -0
- package/dist/components/data/data-table/data-table.cjs +1 -1
- package/dist/components/data/data-table/data-table.cjs.map +1 -1
- package/dist/components/data/data-table/data-table.js +1 -1
- package/dist/components/data/data-table/data-table.js.map +1 -1
- package/dist/components/data/data-table/index.cjs +1 -1
- package/dist/components/data/data-table/index.cjs.map +1 -1
- package/dist/components/data/data-table/index.js +1 -1
- package/dist/components/data/data-table/index.js.map +1 -1
- package/dist/components/layouts/app-content.cjs +1 -1
- package/dist/components/layouts/app-content.cjs.map +1 -1
- package/dist/components/layouts/app-content.js +1 -1
- package/dist/components/layouts/app-content.js.map +1 -1
- package/dist/components/layouts/factories.cjs +1 -1
- package/dist/components/layouts/factories.cjs.map +1 -1
- package/dist/components/layouts/factories.js +1 -1
- package/dist/components/layouts/factories.js.map +1 -1
- package/dist/components/layouts/index.cjs +1 -1
- package/dist/components/layouts/index.cjs.map +1 -1
- package/dist/components/layouts/index.js +1 -1
- package/dist/components/layouts/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import{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};
|
|
2
|
+
import{Search as Be,RefreshCw as vt,Download as bt,Settings2 as xt,Filter as Oe,ArrowUpDown as ht,PinOff as yt,Pin as Ct,ChevronDown as ee,Calculator as ge,Check as fe}from"lucide-react";import{Slot as et}from"radix-ui";import{cva as tt}from"class-variance-authority";import{clsx as Ye}from"clsx";import{twMerge as Ze}from"tailwind-merge";function o(...n){return Ze(Ye(n))}import{jsx as ot}from"react/jsx-runtime";var U=tt("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:n,variant:r,size:d,asChild:m=!1,...h}){let f=m?et.Slot:"button";return ot(f,{"data-slot":"button",className:o(U({variant:r,size:d,className:n}),"transition-none"),...h})}import{jsx as nt}from"react/jsx-runtime";function le({className:n,type:r,...d}){return nt("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",n),...d})}import{Command as V}from"cmdk";import{SearchIcon as at}from"lucide-react";import{Dialog as At}from"radix-ui";import{XIcon as Lt}from"lucide-react";import{jsx as Gt,jsxs as Et}from"react/jsx-runtime";import{jsx as _,jsxs as rt}from"react/jsx-runtime";function Pe({className:n,...r}){return _(V,{"data-slot":"command",className:o("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",n),...r})}function Ne({className:n,...r}){return rt("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[_(at,{className:"size-4 shrink-0 opacity-50"}),_(V.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",n),...r})]})}function ke({className:n,...r}){return _(V.List,{"data-slot":"command-list",className:o("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",n),...r})}function Me({...n}){return _(V.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...n})}function ze({className:n,...r}){return _(V.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",n),...r})}function me({className:n,...r}){return _(V.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",n),...r})}import{DropdownMenu as x}from"radix-ui";import{CheckIcon as it,ChevronRightIcon as st,CircleIcon as oo}from"lucide-react";import{jsx as v,jsxs as Te}from"react/jsx-runtime";function B({...n}){return v(x.Root,{"data-slot":"dropdown-menu",...n})}function O({...n}){return v(x.Trigger,{"data-slot":"dropdown-menu-trigger",...n})}function G({className:n,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",n),...d})})}function ce({...n}){return v(x.Group,{"data-slot":"dropdown-menu-group",...n})}function S({className:n,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",n),...m})}function W({className:n,children:r,checked:d,...m}){return Te(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",n),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(it,{className:"size-4"})})}),r]})}function N({className:n,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",n),...d})}function L({className:n,...r}){return v(x.Separator,{"data-slot":"dropdown-menu-separator",className:o("bg-border -mx-1 my-1 h-px",n),...r})}function Re({...n}){return v(x.Sub,{"data-slot":"dropdown-menu-sub",...n})}function _e({className:n,inset:r,children:d,...m}){return Te(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",n),...m,children:[d,v(st,{className:"ml-auto size-4"})]})}function Se({className:n,...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",n),...r})}import{useState as te}from"react";import{useEffect as pt,useState as ue}from"react";import{Calendar as gt}from"lucide-react";import{format as E}from"date-fns";import{Popover as X}from"radix-ui";import{jsx as J}from"react/jsx-runtime";function K({...n}){return J(X.Root,{"data-slot":"popover",...n})}function Q({...n}){return J(X.Trigger,{"data-slot":"popover-trigger",...n})}function Y({className:n,align:r="center",sideOffset:d=4,...m}){return J(X.Portal,{children:J(X.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",n),...m})})}import*as Z from"react";import{ChevronDownIcon as dt,ChevronLeftIcon as lt,ChevronRightIcon as mt}from"lucide-react";import{DayPicker as ct,getDefaultClassNames as Ie}from"react-day-picker";import{jsx as k}from"react/jsx-runtime";function Fe({className:n,classNames:r,showOutsideDays:d=!0,captionLayout:m="label",buttonVariant:h="ghost",formatters:f,components:C,...I}){let l=Ie();return k(ct,{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`,n),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(U({variant:h}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",l.button_previous),button_next:o(U({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})=>k("div",{"data-slot":"calendar",ref:b,className:o(p),...w}),Chevron:({className:p,orientation:b,...w})=>b==="left"?k(lt,{className:o("size-4",p),...w}):b==="right"?k(mt,{className:o("size-4",p),...w}):k(dt,{className:o("size-4",p),...w}),DayButton:ut,WeekNumber:({children:p,...b})=>k("td",{...b,children:k("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:p})}),...C},...I})}function ut({className:n,day:r,modifiers:d,...m}){let h=Ie(),f=Z.useRef(null);return Z.useEffect(()=>{d.focused&&f.current?.focus()},[d.focused]),k(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,n),...m})}import{jsx as T,jsxs as j}from"react/jsx-runtime";function Ae({value:n,onChange:r,placeholder:d,mode:m,externalSearch:h,onExternalChange:f,onlyExternal:C=!1}){let[I,l]=ue(!1),[p,b]=ue(n),[w,M]=ue(n);pt(()=>{C||M(n)},[n,C]);let F=()=>{C||r(p),M(p),h&&f&&f(p),l(!1)},A=()=>{b(w),l(!1)},P=()=>{let c=m==="single"?null:{from:null,to:null};b(c),C||r(c),M(c),h&&f&&f(c),l(!1)},D=()=>{let c=C?w:n;return c?m==="single"?E(c,"PPP"):c.from&&c.to?`${E(c.from,"MMM dd")} - ${E(c.to,"MMM dd, yyyy")}`:c.from?`From ${E(c.from,"MMM dd, yyyy")}`:c.to?`To ${E(c.to,"MMM dd, yyyy")}`:d:d},z=c=>{b(m==="single"?c:c||{from:null,to:null})};return j(K,{open:I,onOpenChange:l,children:[T(Q,{className:"h-8",asChild:!0,children:j(g,{variant:"outline",className:o("w-full justify-start text-left font-normal h-9",!D()&&"text-muted-foreground"),children:[T(gt,{className:"mr-2 h-4 w-4"}),D()]})}),j(Y,{className:"w-auto p-0",align:"start",children:[T("div",{className:"p-3",children:T(Fe,{mode:m,selected:p,onSelect:z,numberOfMonths:m==="range"?2:1,className:"rounded-md border",...m==="range"&&{required:!0}})}),j("div",{className:"flex items-center justify-between p-3 border-t",children:[T(g,{variant:"ghost",size:"sm",onClick:P,children:"Clear"}),j("div",{className:"flex gap-2",children:[T(g,{variant:"outline",size:"sm",onClick:A,children:"Cancel"}),T(g,{size:"sm",onClick:F,disabled:m==="range"&&(!p?.from||!p?.to),children:"Apply"})]})]})]})]})}import{Checkbox as Ve}from"radix-ui";import{CheckIcon as ft}from"lucide-react";import{jsx as pe}from"react/jsx-runtime";function Le({className:n,...r}){return pe(Ve.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",n),...r,children:pe(Ve.Indicator,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:pe(ft,{className:"size-3.5"})})})}import{Fragment as wt,jsx as t,jsxs as s}from"react/jsx-runtime";var Ge=[{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 qo({table:n,filters:r=[],globalFilter:d,onGlobalFilterChange:m,enableGlobalFilter:h=!0,onExport:f,onRefresh:C,loading:I=!1,enableColumnVisibility:l=!0,data:p,onClearSorting:b,onClearFilters:w,enableColumnPinning:M=!1,onExternalSearch:F,onCustomFilterChange:A,aggregations:P={},onAggregationChange:D,enableGroupedGlobalFilter:z=!1,groupedFilterLabel:c="Search in",onGroupedFilterChange:H}){let[ve,be]=te({}),[oe,xe]=te({}),[he,Ee]=te({}),[$,je]=te("all"),ne=()=>n.getAllLeafColumns().filter(e=>e.getCanHide?.()!==!1),ye=()=>n.getAllColumns().filter(e=>!n.getAllLeafColumns().includes(e)&&e.columns?.length&&e.columns.some(a=>a.getCanHide?.()!==!1)),Ce=()=>{let e=new Set(ye().flatMap(a=>a.columns?.filter(i=>i.getCanHide?.()!==!1).map(i=>i.id)||[]));return ne().filter(a=>!e.has(a.id))},ae=(e,a)=>a&&e.startsWith(`${a}.`)?e.replace(`${a}.`,"").split("_").map(u=>u.slice(1)).join(" "):e.split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "),re=(e,a)=>{let i={...ve,[e]:a};be(i)},He=(e,a)=>{let i={...oe,[e]:a};xe(i),A&&A(e,a),r.find(u=>u.key===e)?.externalSearch&&re(e,a)},$e=()=>{F&&F(ve)},qe=()=>{be({}),xe({}),w(),F&&F({}),A&&Object.keys(oe).forEach(e=>{A(e,"")})},R=e=>r.find(i=>i.key===e)?.customFilter?oe[e]??"":n.getColumn(e)?.getFilterValue(),q=(e,a)=>{let i=r.find(u=>u.key===e);i?.customFilter?He(e,a):(n.getColumn(e)?.setFilterValue(a),i?.externalSearch&&re(e,a))},ie=(e,a)=>{Ee(i=>({...i,[e]:a}))},Ue=e=>{if(D){let a=P[e],i={enabled:!a?.enabled,functions:a?.functions||["sum","average"]};D(e,i)}},We=(e,a)=>{if(D){let u=P[e]?.functions||[],y=u.includes(a)?u.filter(Qe=>Qe!==a):[...u,a];D(e,{enabled:y.length>0,functions:y})}},we=()=>{D&&Object.keys(P).forEach(e=>{let a=P[e];a&&D(e,{...a,enabled:!1,functions:[]})})},Xe=()=>ne().filter(e=>e.id==="select"||e.id==="serialNumber"?!1:e.columnDef.meta?.aggregatable?!0:n.getRowModel().rows.slice(0,5).some(u=>{let y=u.getValue(e.id);return typeof y=="number"||typeof y=="string"&&!isNaN(parseFloat(String(y)))||typeof y=="object"&&y!==null&&"props"in y})),Je=e=>{je(e),H&&H(e,d)},Ke=e=>{m(e),H&&z&&H($,e)},se=Xe(),de=Object.values(P).some(e=>e?.enabled),De=[{value:"all",label:"All Fields"},...r.map(e=>({value:e.key,label:e.placeholder}))];return t("div",{className:"rounded-xl",children:t("div",{className:"px-2",children:t("div",{className:"flex flex-col gap-6",children:s("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-3",children:r.length>0&&s("div",{className:"flex flex-wrap items-center gap-3",children:[t("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:t(Oe,{className:"size-4"})}),r.map(e=>!n.getColumn(e.key)&&!e.customFilter&&!e.externalSearch?null:t("div",{className:o("relative min-w-[150px]",e.width),children:e.type==="select"?s(K,{open:he[e.key],onOpenChange:i=>ie(e.key,i),children:[t(Q,{asChild:!0,children:s("div",{className:"relative w-full",children:[e.icon&&t(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":he[e.key],className:o("h-8 sm:h-8 rounded-lg w-full justify-between font-normal",!R(e.key)&&"text-muted-foreground"),children:[t("span",{className:o("truncate",e.icon&&"pl-6"),children:R(e.key)?e.options?.find(i=>i.value===R(e.key))?.label:e.placeholder}),t(ee,{className:"ml-2 opacity-50 size-4 shrink-0"})]})]})}),t(Y,{className:"w-[--radix-popover-trigger-width] p-0 rounded-lg",children:s(Pe,{className:"rounded-lg",children:[t(Ne,{placeholder:`Search ${e.placeholder?.toLowerCase()}...`}),s(ke,{children:[t(Me,{children:"No option found."}),s(ze,{children:[s(me,{value:"all",onSelect:()=>{q(e.key,""),ie(e.key,!1)},className:"flex items-center cursor-pointer",children:[t(fe,{className:o("mr-2 size-4 shrink-0",R(e.key)?"opacity-0":"opacity-100")}),t("span",{children:"All"})]}),e.options?.map(i=>s(me,{value:i.label,onSelect:()=>{q(e.key,i.value),ie(e.key,!1)},className:"flex items-center cursor-pointer",children:[t(fe,{className:o("mr-2 size-4 shrink-0",R(e.key)===i.value?"opacity-100":"opacity-0")}),t("span",{children:i.label})]},i.label))]})]})]})})]}):e.type==="date"?t(Ae,{value:R(e.key),onChange:i=>{e.onlyExternal||q(e.key,i)},placeholder:e.placeholder,mode:e.dateMode||"single",externalSearch:e.externalSearch,onlyExternal:e.onlyExternal,onExternalChange:i=>re(e.key,i)}):s("div",{className:"relative",children:[e.icon&&t(e.icon,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground"}),t(le,{placeholder:e.placeholder,value:R(e.key)??"",onChange:i=>{q(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:$e,className:"rounded-lg h-7",children:[t(Be,{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:o("flex items-center",z?"bg-background border rounded-lg":""),children:[z&&s(B,{children:[t(O,{asChild:!0,children:s(g,{variant:"ghost",size:"sm",className:"gap-1 border-0 border-r rounded-r-none hover:bg-transparent",children:[t("span",{className:"text-sm font-medium",children:c}),t(ee,{className:"opacity-50 size-4"})]})}),t(G,{align:"end",className:"w-48 rounded-lg",children:De.map(e=>s(S,{onClick:()=>Je(e.value),className:"flex items-center justify-between",children:[t("span",{children:e.label}),$===e.value&&t(fe,{className:"size-4 text-primary"})]},e.value))})]}),s("div",{className:"relative flex-1",children:[t(Be,{className:"absolute -translate-y-1/2 size-4 left-3 top-1/2 text-muted-foreground"}),t(le,{placeholder:z&&$!=="all"?`Search in ${De.find(e=>e.value===$)?.label}...`:"Global search...",value:d??"",onChange:e=>Ke(e.target.value),className:o("pl-9 h-8 max-w-max",z&&"border-0 rounded-l-none")})]})]}),se.length>0&&D&&s(B,{children:[t(O,{asChild:!0,children:s(g,{variant:"outline",size:"sm",className:o("rounded-lg gap-1",de&&"bg-primary/10 dark:bg-primary/10 border-primary/20 dark:border-primary/20"),children:[t(ge,{className:"size-4"}),t("span",{children:"Aggregations"}),t(ee,{className:"opacity-50 size-4"})]})}),s(G,{align:"end",className:"w-64 rounded-lg max-h-[500px] overflow-y-auto",children:[s(N,{className:"flex items-center justify-between px-4 py-2",children:[t("span",{className:"text-sm font-medium",children:"Column Aggregations"}),de&&t(g,{variant:"ghost",size:"sm",onClick:we,className:"h-6 px-2 text-xs",children:"Clear All"})]}),t(L,{}),se.map(e=>{let a=P[e.id],i=a?.enabled;return s(Re,{children:[t(_e,{className:"text-sm",children:s("div",{className:"flex items-center w-full gap-2",children:[t(Le,{checked:i,onCheckedChange:()=>Ue(e.id),className:"data-[state=checked]:bg-primary"}),t("span",{className:o("flex-1",i&&"font-medium text-primary"),children:ae(e.id)}),i&&s("div",{className:"flex items-center gap-1",children:[a?.functions?.slice(0,2).map(u=>t("div",{className:"w-2 h-2 rounded-full bg-primary",title:Ge.find(y=>y.value===u)?.label},u)),a?.functions&&a.functions.length>2&&s("div",{className:"text-xs text-muted-foreground",children:["+",a.functions.length-2]})]})]})}),s(Se,{className:"w-48 rounded-lg",children:[t(N,{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Select Functions"}),Ge.map(u=>t(W,{checked:a?.functions?.includes(u.value)||!1,onCheckedChange:()=>We(e.id,u.value),className:"py-2 text-sm",children:s("div",{className:"flex flex-col",children:[t("span",{children:u.label}),t("span",{className:"text-xs text-muted-foreground",children:u.description})]})},u.value))]})]},e.id)}),se.length===0&&s("div",{className:"px-3 py-4 text-center",children:[t(ge,{className:"w-8 h-8 mx-auto mb-2 opacity-50 text-muted-foreground"}),t("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:[t(bt,{className:"size-4"}),"Export"]}),l&&s(B,{children:[t(O,{asChild:!0,className:"h-7",children:s(g,{variant:"outline",size:"sm",className:"gap-1 rounded-lg",children:[t("span",{children:"Columns"}),t(ee,{className:"opacity-50 size-4"})]})}),s(G,{align:"end",className:"w-[220px] rounded-lg max-h-[400px] overflow-y-auto",children:[t(N,{className:"px-4 py-2 text-sm font-medium",children:"Toggle Columns"}),t(L,{}),Ce().length>0&&s(ce,{children:[t(N,{className:"px-4 py-1.5 text-sm font-medium text-muted-foreground",children:"General"}),Ce().map(e=>t(W,{className:"text-sm",checked:e.getIsVisible(),onCheckedChange:a=>e.toggleVisibility(!!a),children:ae(e.id)},e.id))]}),ye().map(e=>s(ce,{children:[t(L,{}),t(N,{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=>t(W,{className:"text-sm",checked:a.getIsVisible(),onCheckedChange:i=>a.toggleVisibility(!!i),children:ae(a.id,e.id)},a.id))]},e.id))]})]}),s(B,{children:[t(O,{asChild:!0,className:"h-7",children:t(g,{variant:"outline",size:"sm",className:"rounded-lg h-7",children:t(xt,{className:"size-4"})})}),s(G,{align:"end",className:"w-[200px] rounded-lg",children:[t(N,{children:"Table Settings"}),t(L,{}),s(S,{onClick:b,children:[t(ht,{className:"size-4"}),"Clear All Sorting"]}),s(S,{onClick:qe,children:[t(Oe,{className:"size-4"}),"Clear All Filters"]}),de&&s(S,{onClick:we,children:[t(ge,{className:"size-4"}),"Clear Aggregations"]}),M&&s(wt,{children:[t(L,{}),t(N,{children:"Column Pinning"}),s(S,{onClick:()=>n.setColumnPinning({left:[],right:[]}),children:[t(yt,{className:"size-4"}),"Reset All Pinning"]}),s(S,{onClick:()=>{let e=ne().filter(a=>a.getCanPin?.()!==!1).map(a=>a.id);n.setColumnPinning({left:[],right:e})},children:[t(Ct,{className:"-rotate-90 size-4"}),"Pin All Right"]})]})]})]}),C&&t(g,{variant:"outline",size:"sm",onClick:C,disabled:I,className:"rounded-lg",children:t(vt,{className:o("h-4 w-4",I&&"animate-spin")})})]})]})})})})}export{qo as DataTableToolbar};
|
|
3
3
|
//# sourceMappingURL=data-table-toolbar.js.map
|