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