@superdangerous/app-framework 4.16.37 → 4.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +7 -9
- package/ui/dist/data-table.js +1 -1
- package/ui/dist/data-table.js.map +1 -1
- package/ui/dist/data-table.mjs +1 -1
- package/ui/dist/data-table.mjs.map +1 -1
- package/ui/dist/index.js +37 -48
- package/ui/dist/index.js.map +1 -1
- package/ui/dist/index.mjs +37 -48
- package/ui/dist/index.mjs.map +1 -1
- package/ui/src/styles/app.css +12 -0
- package/ui/src/styles/globals.css +350 -0
- package/ui/src/styles/index.ts +45 -0
package/README.md
CHANGED
|
@@ -54,7 +54,8 @@ npm run typecheck
|
|
|
54
54
|
|
|
55
55
|
#### Test Infrastructure
|
|
56
56
|
|
|
57
|
-
-
|
|
57
|
+
- Vitest with TypeScript support (framework core)
|
|
58
|
+
- Jest with TypeScript support (UI package tests under `ui/`)
|
|
58
59
|
- Built-in TestServer class for app testing
|
|
59
60
|
- Mock implementations for all services
|
|
60
61
|
- Async operation handling
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdangerous/app-framework",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.1",
|
|
4
4
|
"description": "Opinionated TypeScript framework for structured vibecoding - building internal web and desktop apps with batteries included",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -59,9 +59,10 @@
|
|
|
59
59
|
"clean": "rm -rf dist",
|
|
60
60
|
"prebuild": "npm run clean",
|
|
61
61
|
"postbuild": "node ./scripts/postbuild-ensure-cli-executables.cjs",
|
|
62
|
-
"test": "npm run test:unit && npm run test:integration",
|
|
62
|
+
"test": "npm run test:unit && npm run test:integration && npm run test:ui",
|
|
63
63
|
"test:unit": "vitest run --config vitest.config.ts tests/unit",
|
|
64
64
|
"test:integration": "vitest run --config tests/vitest.integration.config.ts tests/integration",
|
|
65
|
+
"test:ui": "npm --prefix ui test -- --runInBand",
|
|
65
66
|
"test:watch": "vitest",
|
|
66
67
|
"test:coverage": "vitest run --config vitest.config.ts --coverage",
|
|
67
68
|
"test:security": "npm audit --audit-level moderate",
|
|
@@ -94,10 +95,6 @@
|
|
|
94
95
|
"url": "git+https://github.com/SuperDangerous/app-framework.git"
|
|
95
96
|
},
|
|
96
97
|
"dependencies": {
|
|
97
|
-
"@types/express-session": "^1.18.2",
|
|
98
|
-
"@types/multer": "^2.0.0",
|
|
99
|
-
"@types/nodemailer": "^7.0.5",
|
|
100
|
-
"archiver": "^7.0.1",
|
|
101
98
|
"boxen": "^8.0.1",
|
|
102
99
|
"chalk": "^5.5.0",
|
|
103
100
|
"commander": "^12.1.0",
|
|
@@ -122,12 +119,14 @@
|
|
|
122
119
|
"zod": "^3.23.8"
|
|
123
120
|
},
|
|
124
121
|
"devDependencies": {
|
|
125
|
-
"@types/archiver": "^6.0.3",
|
|
126
122
|
"@types/boxen": "^2.1.0",
|
|
127
123
|
"@types/cors": "^2.8.17",
|
|
128
124
|
"@types/express": "^4.17.23",
|
|
125
|
+
"@types/express-session": "^1.18.2",
|
|
129
126
|
"@types/fs-extra": "^11.0.4",
|
|
127
|
+
"@types/multer": "^2.0.0",
|
|
130
128
|
"@types/node": "^20.10.0",
|
|
129
|
+
"@types/nodemailer": "^7.0.9",
|
|
131
130
|
"@types/supertest": "^6.0.3",
|
|
132
131
|
"@types/swagger-jsdoc": "^6.0.4",
|
|
133
132
|
"@types/swagger-ui-express": "^4.1.8",
|
|
@@ -141,7 +140,6 @@
|
|
|
141
140
|
"prettier": "^3.5.1",
|
|
142
141
|
"socket.io-client": "^4.8.1",
|
|
143
142
|
"supertest": "^7.1.4",
|
|
144
|
-
"ts-node": "^10.9.2",
|
|
145
143
|
"tsx": "^4.20.4",
|
|
146
144
|
"typedoc": "^0.28.12",
|
|
147
145
|
"typescript": "^5.7.2",
|
|
@@ -154,7 +152,7 @@
|
|
|
154
152
|
"dist/",
|
|
155
153
|
"src/",
|
|
156
154
|
"ui/dist/",
|
|
157
|
-
"ui/styles/",
|
|
155
|
+
"ui/src/styles/",
|
|
158
156
|
"README.md",
|
|
159
157
|
"LICENSE"
|
|
160
158
|
]
|
package/ui/dist/data-table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var G=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),ee=require('@radix-ui/react-tooltip'),lucideReact=require('lucide-react'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),x=require('@radix-ui/react-select'),_=require('@radix-ui/react-popover'),P=require('@radix-ui/react-dropdown-menu'),Pe=require('@radix-ui/react-checkbox');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var G__namespace=/*#__PURE__*/_interopNamespace(G);var ee__namespace=/*#__PURE__*/_interopNamespace(ee);var x__namespace=/*#__PURE__*/_interopNamespace(x);var ___namespace=/*#__PURE__*/_interopNamespace(_);var P__namespace=/*#__PURE__*/_interopNamespace(P);var Pe__namespace=/*#__PURE__*/_interopNamespace(Pe);var Ft=25,Gt=[10,25,50,100];function Ne({data:e,pageSize:t=Ft,storageKey:o}){let[r,m]=G.useState(()=>{if(o)try{let b=localStorage.getItem(`pagination-${o}`);if(b)return {page:1,pageSize:JSON.parse(b).pageSize||t}}catch{}return {page:1,pageSize:t}}),{page:c,pageSize:f}=r,u=G.useMemo(()=>Math.max(1,Math.ceil(e.length/f)),[e.length,f]);G.useEffect(()=>{c>u&&m(b=>({...b,page:Math.max(1,u)}));},[u,c]),G.useEffect(()=>{if(o)try{localStorage.setItem(`pagination-${o}`,JSON.stringify({pageSize:f}));}catch{}},[f,o]);let g=(c-1)*f,a=Math.min(g+f,e.length),l=G.useMemo(()=>e.slice(g,a),[e,g,a]),s=G.useCallback(b=>{m(T=>({...T,page:Math.max(1,Math.min(b,u))}));},[u]),p=G.useCallback(b=>{m({page:1,pageSize:b});},[]),d=G.useCallback(()=>{s(c+1);},[c,s]),v=G.useCallback(()=>{s(c-1);},[c,s]),k=G.useCallback(()=>{s(1);},[s]),B=G.useCallback(()=>{s(u);},[u,s]);return {paginatedData:l,page:c,pageSize:f,totalPages:u,totalItems:e.length,setPage:s,setPageSize:p,nextPage:d,prevPage:v,firstPage:k,lastPage:B,startIndex:g+1,endIndex:a,canGoNext:c<u,canGoPrev:c>1,pageSizeOptions:Gt}}function Re({columns:e,storageKey:t}){let o=`column-visibility-${t}`,[r,m]=G.useState(()=>{let a={};if(e.forEach(l=>{a[l.id]=l.defaultVisible!==false;}),typeof window>"u")return a;try{let l=localStorage.getItem(o);if(l){let s=JSON.parse(l),p={};return e.forEach(d=>{d.locked?p[d.id]=!0:s[d.id]!==void 0?p[d.id]=s[d.id]:p[d.id]=d.defaultVisible!==!1;}),p}}catch(l){console.error("Error loading column visibility state:",l);}return a});G.useEffect(()=>{if(!(typeof window>"u"))try{localStorage.setItem(o,JSON.stringify(r));}catch(a){console.error("Error saving column visibility state:",a);}},[r,o]);let c=G.useCallback(a=>e.find(s=>s.id===a)?.locked?true:r[a]!==false,[r,e]),f=G.useCallback(a=>{e.find(s=>s.id===a)?.locked||m(s=>({...s,[a]:!s[a]}));},[e]),u=G.useCallback(()=>{let a={};e.forEach(l=>{a[l.id]=true;}),m(a);},[e]),g=G.useCallback(()=>{let a={};e.forEach(l=>{a[l.id]=l.locked===true;}),m(a);},[e]);return {visibleColumns:r,isColumnVisible:c,toggleColumn:f,showAllColumns:u,hideAllColumns:g,columns:e}}var it=50,De=150,$t=3;function Me({tableId:e,columns:t,storageKey:o}){let r=o||`table-columns-${e}`,m=G.useCallback(()=>t.reduce((y,h)=>(y[h.key]=h.defaultWidth||De,y),{}),[t]),[c,f]=G.useState(()=>{try{let y=localStorage.getItem(r);if(y){let h=JSON.parse(y);return {widths:{...m(),...h},isResizing:!1,resizingColumn:null}}}catch{}return {widths:m(),isResizing:false,resizingColumn:null}}),u=G.useRef(0),g=G.useRef(0),a=G.useRef(null),l=G.useRef(false),s=G.useRef(t);G.useEffect(()=>{s.current=t;},[t]);let p=G.useCallback(y=>s.current.find(h=>h.key===y),[]);G.useEffect(()=>{try{localStorage.setItem(r,JSON.stringify(c.widths));}catch{}},[c.widths,r]);let d=G.useRef(null);d.current||(d.current={onPointerMove:y=>{if(!a.current)return;let h=y.clientX-u.current;if(!l.current){if(Math.abs(h)<$t)return;l.current=true,f(re=>({...re,isResizing:true,resizingColumn:a.current})),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}let oe=p(a.current),de=oe?.minWidth||it,we=oe?.maxWidth,me=Math.max(de,g.current+h);we&&(me=Math.min(we,me)),f(re=>({...re,widths:{...re.widths,[a.current]:me}}));},onPointerUp:()=>{a.current=null,l.current=false,f(y=>({...y,isResizing:false,resizingColumn:null})),document.removeEventListener("pointermove",d.current.onPointerMove),document.removeEventListener("pointerup",d.current.onPointerUp),document.removeEventListener("pointercancel",d.current.onPointerUp),document.body.style.cursor="",document.body.style.userSelect="";}}),G.useEffect(()=>()=>{d.current&&(document.removeEventListener("pointermove",d.current.onPointerMove),document.removeEventListener("pointerup",d.current.onPointerUp),document.removeEventListener("pointercancel",d.current.onPointerUp)),document.body.style.cursor="",document.body.style.userSelect="";},[]);let v=G.useRef(c.widths);G.useEffect(()=>{v.current=c.widths;},[c.widths]);let k=G.useCallback((y,h)=>{u.current=h,g.current=v.current[y]||De,a.current=y,l.current=false,document.addEventListener("pointermove",d.current.onPointerMove),document.addEventListener("pointerup",d.current.onPointerUp),document.addEventListener("pointercancel",d.current.onPointerUp);},[]),B=G.useCallback(y=>({onPointerDown:h=>{h.preventDefault(),h.stopPropagation(),k(y,h.clientX);},onMouseDown:h=>{h.preventDefault(),h.stopPropagation();},draggable:false,onDragStart:h=>{h.preventDefault(),h.stopPropagation();},className:"resize-handle","data-resizing":c.resizingColumn===y}),[k,c.resizingColumn]),b=G.useCallback(y=>{let h=c.widths[y]||De,de=p(y)?.minWidth||it;return {width:h,minWidth:de,position:"relative"}},[c.widths,p]),T=t.reduce((y,h)=>y+(c.widths[h.key]||h.defaultWidth||De),0),W=G.useCallback(()=>({minWidth:T}),[T]),$=G.useCallback(()=>{f(y=>({...y,widths:m()}));},[m]);return {widths:c.widths,isResizing:c.isResizing,totalWidth:T,getResizeHandleProps:B,getColumnStyle:b,getTableStyle:W,resetToDefaults:$}}function ke({storageKey:e,defaultOrder:t}){let[o,r]=G.useState(()=>{try{let g=localStorage.getItem(e);if(g){let a=JSON.parse(g),l=new Set(a),s=new Set(t),p=a.filter(v=>s.has(v)),d=t.filter(v=>!l.has(v));if(d.length>0){let v=[...p];for(let k of d){let B=t.indexOf(k),b=v.length;for(let T=0;T<v.length;T++)if(t.indexOf(v[T])>B){b=T;break}v.splice(b,0,k);}return v}return p.length>0?p:t}}catch(g){console.warn("Failed to load column order from localStorage:",g);}return t});G.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(o));}catch(g){console.warn("Failed to save column order to localStorage:",g);}},[e,o]);let m=G.useCallback((g,a)=>{g!==a&&r(l=>{let s=[...l],[p]=s.splice(g,1);return p!==void 0&&s.splice(a,0,p),s});},[]),c=G.useCallback((g,a)=>{r(l=>{let s=l.indexOf(g);if(s===-1)return l;let p=a==="left"?Math.max(0,s-1):Math.min(l.length-1,s+1);if(s===p)return l;let d=[...l],[v]=d.splice(s,1);return v!==void 0&&d.splice(p,0,v),d});},[]),f=G.useCallback(()=>{r(t);},[t]),u=G.useCallback(g=>{let a=new Map(g.map(l=>[l.id,l]));return o.map(l=>a.get(l)).filter(l=>l!==void 0)},[o]);return {columnOrder:o,moveColumn:m,moveColumnById:c,resetOrder:f,getOrderedColumns:u}}function Ie(e,t,o=[]){let[r,m]=G.useState({isDragging:false,draggedId:null,dropIndex:null}),c=G.useCallback(s=>{o.includes(s)||m({isDragging:true,draggedId:s,dropIndex:null});},[o]),f=G.useCallback((s,p)=>{if(o.includes(s))return;let d=e.indexOf(s);if(d===-1)return;let v=p.currentTarget.getBoundingClientRect(),k=v.left+v.width/2,B=p.clientX<k?d:d+1;m(b=>({...b,dropIndex:B}));},[o,e]),u=G.useCallback(()=>{if(!r.draggedId||r.dropIndex===null){m({isDragging:false,draggedId:null,dropIndex:null});return}let s=e.indexOf(r.draggedId),p=r.dropIndex;s<p&&(p=p-1),s!==-1&&p!==-1&&s!==p&&t(s,p),m({isDragging:false,draggedId:null,dropIndex:null});},[r.draggedId,r.dropIndex,e,t]),g=G.useCallback(()=>{m({isDragging:false,draggedId:null,dropIndex:null});},[]),a=G.useCallback(s=>({draggable:!o.includes(s),onDragStart:p=>{if(o.includes(s)){p.preventDefault();return}p.dataTransfer.effectAllowed="move",c(s);},onDragOver:p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",f(s,p);},onDrop:p=>{p.preventDefault(),u();},onDragEnd:g}),[o,c,f,u,g]),l=G.useCallback(s=>!r.isDragging||r.dropIndex===null?false:e.indexOf(s)===r.dropIndex,[r.isDragging,r.dropIndex,e]);return {dragState:r,getDragHandleProps:a,showDropIndicator:l}}function i(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var Fe=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:o,className:i("w-full caption-bottom text-sm",e),...t})}));Fe.displayName="Table";var Ge=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("thead",{ref:o,className:i("[&_tr]:border-b",e),...t}));Ge.displayName="TableHeader";var _e=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("tbody",{ref:o,className:i("[&_tr:last-child]:border-0",e),...t}));_e.displayName="TableBody";var jt=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("tfoot",{ref:o,className:i("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));jt.displayName="TableFooter";var ce=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("tr",{ref:o,className:i("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));ce.displayName="TableRow";var pe=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("th",{ref:o,className:i("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));pe.displayName="TableHead";var ae=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("td",{ref:o,className:i("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ae.displayName="TableCell";var Qt=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("caption",{ref:o,className:i("mt-4 text-sm text-muted-foreground",e),...t}));Qt.displayName="TableCaption";var lt=ee__namespace.Provider;var Kt=G__namespace.forwardRef(({className:e,sideOffset:t=4,...o},r)=>jsxRuntime.jsx(ee__namespace.Content,{ref:r,sideOffset:t,className:i("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",e),...o}));Kt.displayName=ee__namespace.Content.displayName;var ro=classVarianceAuthority.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),S=G__namespace.forwardRef(({className:e,variant:t,size:o,asChild:r=false,...m},c)=>jsxRuntime.jsx(r?reactSlot.Slot:"button",{className:i(ro({variant:t,size:o,className:e})),ref:c,...m}));S.displayName="Button";var ze=x__namespace.Root;var Ee=x__namespace.Value,ue=G__namespace.forwardRef(({className:e,children:t,...o},r)=>jsxRuntime.jsxs(x__namespace.Trigger,{ref:r,className:i("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...o,children:[t,jsxRuntime.jsx(x__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ue.displayName=x__namespace.Trigger.displayName;var ct=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.ScrollUpButton,{ref:o,className:i("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-4 w-4"})}));ct.displayName=x__namespace.ScrollUpButton.displayName;var pt=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.ScrollDownButton,{ref:o,className:i("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4"})}));pt.displayName=x__namespace.ScrollDownButton.displayName;var fe=G__namespace.forwardRef(({className:e,children:t,position:o="popper",...r},m)=>jsxRuntime.jsx(x__namespace.Portal,{children:jsxRuntime.jsxs(x__namespace.Content,{ref:m,className:i("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",o==="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:o,...r,children:[jsxRuntime.jsx(ct,{}),jsxRuntime.jsx(x__namespace.Viewport,{className:i("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(pt,{})]})}));fe.displayName=x__namespace.Content.displayName;var so=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.Label,{ref:o,className:i("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));so.displayName=x__namespace.Label.displayName;var ge=G__namespace.forwardRef(({className:e,children:t,...o},r)=>jsxRuntime.jsxs(x__namespace.Item,{ref:r,className:i("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(x__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(x__namespace.ItemText,{children:t})]}));ge.displayName=x__namespace.Item.displayName;var lo=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.Separator,{ref:o,className:i("-mx-1 my-1 h-px bg-muted",e),...t}));lo.displayName=x__namespace.Separator.displayName;function Le({page:e,pageSize:t,totalPages:o,totalItems:r,startIndex:m,endIndex:c,canGoNext:f,canGoPrev:u,pageSizeOptions:g,onPageChange:a,onPageSizeChange:l,onNextPage:s,onPrevPage:p,onFirstPage:d,onLastPage:v,className:k}){let B=()=>{let b=[],W=Math.floor(2.5),$=Math.max(1,e-W),y=Math.min(o,e+W);e<=W&&(y=Math.min(o,5)),e>o-W&&($=Math.max(1,o-5+1)),$>1&&(b.push(1),$>2&&b.push("ellipsis"));for(let h=$;h<=y;h++)h!==1&&h!==o&&b.push(h);return y<o&&(y<o-1&&b.push("ellipsis"),b.push(o)),b};return r===0?null:jsxRuntime.jsxs("div",{className:i("flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-3",k),children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",m," to ",c," of ",r," items"]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"Per page:"}),jsxRuntime.jsxs(ze,{value:String(t),onValueChange:b=>l(Number(b)),children:[jsxRuntime.jsx(ue,{className:"w-20 h-8",children:jsxRuntime.jsx(Ee,{})}),jsxRuntime.jsx(fe,{children:g.map(b=>jsxRuntime.jsx(ge,{value:String(b),children:b},b))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:d,disabled:!u,title:"First page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:p,disabled:!u,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:B().map((b,T)=>b==="ellipsis"?jsxRuntime.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${T}`):jsxRuntime.jsx(S,{variant:e===b?"default":"outline",size:"icon",className:"h-8 w-8",onClick:()=>a(b),children:b},b))}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:s,disabled:!f,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:v,disabled:!f,title:"Last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})]})]})]})}function ut({data:e,columns:t,storageKey:o,getRowId:r,selectable:m=false,selectedIds:c,onSelectionChange:f,onRowClick:u,onRowContextMenu:g,sortField:a,sortOrder:l,onSort:s,actionsColumn:p,actionsColumnWidth:d=80,pageSize:v=25,pagination:k,hidePagination:B=false,className:b,rowClassName:T,enableHeaderContextMenu:W=true,lockedColumns:$=[],defaultColumnOrder:y,loading:h=false,emptyState:oe}){let de=G.useMemo(()=>{let n=[];return m&&n.push({key:"select",defaultWidth:40,minWidth:40}),t.forEach(N=>{n.push({key:N.id,defaultWidth:N.width?.default??150,minWidth:N.width?.min??80,maxWidth:N.width?.max});}),p&&n.push({key:"actions",defaultWidth:d,minWidth:60}),n},[t,m,p,d]),we=G.useMemo(()=>t.map(n=>({id:n.id,label:typeof n.header=="string"?n.header:n.id,defaultVisible:n.visibility?.default??true,locked:n.visibility?.locked})),[t]),me=G.useMemo(()=>{if(y)return y;let n=[];return m&&n.push("select"),t.forEach(N=>n.push(N.id)),p&&n.push("actions"),n},[y,t,m,p]),{getResizeHandleProps:re,getColumnStyle:Qe,getTableStyle:Dt}=Me({tableId:o,columns:de}),j=Re({columns:we,storageKey:o}),{columnOrder:Ce,moveColumn:Mt}=ke({storageKey:`${o}-order`,defaultOrder:me}),{dragState:Ae,getDragHandleProps:kt,showDropIndicator:It}=Ie(Ce,Mt,[...$,"select","actions"]),zt=Ne({data:e,pageSize:v,storageKey:o}),w=k||zt,[ne,Ke]=G.useState(null),Et=G.useCallback(n=>{W&&(n.preventDefault(),Ke({x:n.clientX,y:n.clientY}));},[W]);G.useEffect(()=>{if(!ne)return;let n=()=>Ke(null);return window.addEventListener("click",n),()=>{window.removeEventListener("click",n);}},[ne]);let et=G.useMemo(()=>!m||!c||w.paginatedData.length===0?false:w.paginatedData.every(n=>c.has(r(n))),[m,c,w.paginatedData,r]),Lt=G.useMemo(()=>{if(!m||!c)return false;let n=w.paginatedData.filter(N=>c.has(r(N)));return n.length>0&&n.length<w.paginatedData.length},[m,c,w.paginatedData,r]),Bt=G.useCallback(n=>{if(!f||!c)return;let N=new Set(c);N.has(n)?N.delete(n):N.add(n),f(N);},[c,f]),Ht=G.useCallback(()=>{if(!f)return;let n=new Set(w.paginatedData.map(r));f(n);},[w.paginatedData,r,f]),Ot=G.useCallback(()=>{f&&f(new Set);},[f]),tt=G.useCallback(n=>a!==n?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):l==="asc"?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3.5 w-3.5"}),[a,l]),ot=G.useCallback(n=>t.find(N=>N.id===n),[t]),Vt=G.useCallback(n=>{let N={columnId:n.id,isSorted:a===n.sortKey,sortDirection:a===n.sortKey?l:void 0};return typeof n.header=="function"?n.header(N):n.sortKey&&s?jsxRuntime.jsxs("button",{onClick:()=>s(n.sortKey),className:i("flex items-center gap-1 hover:text-foreground transition-colors",a===n.sortKey&&"text-foreground font-medium"),children:[n.header,tt(n.sortKey)]}):n.header},[a,l,s,tt]);return jsxRuntime.jsx(lt,{children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"overflow-auto border rounded-lg h-full",children:jsxRuntime.jsxs(Fe,{style:Dt(),className:i("resizable-table sticky-actions-table",b),children:[jsxRuntime.jsx(Ge,{className:"sticky top-0 z-20 bg-muted",children:jsxRuntime.jsxs(ce,{onContextMenu:Et,className:"border-t-0",children:[Ce.map(n=>{if(n==="select"&&m)return jsxRuntime.jsx(pe,{className:"sticky-select-header w-10 sticky left-0 z-20 bg-muted relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border",children:jsxRuntime.jsx("input",{type:"checkbox",checked:et,ref:I=>{I&&(I.indeterminate=Lt);},onChange:I=>I.target.checked?Ht():Ot(),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer",title:et?"Deselect all":"Select all visible"})},"select");let N=ot(n);return !N||!j.isColumnVisible(n)?null:jsxRuntime.jsxs(pe,{style:Qe(n),...kt(n),className:i("cursor-grab relative",Ae.draggedId===n&&"column-dragging opacity-50",It(n)&&"drop-indicator"),children:[Vt(N),jsxRuntime.jsx("div",{...re(n)})]},n)}),p&&jsxRuntime.jsx(pe,{className:"sticky right-0 z-20 bg-muted text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border",style:{width:d,minWidth:d,maxWidth:d},children:"Actions"},"actions")]})}),jsxRuntime.jsx(_e,{children:h?jsxRuntime.jsx(ce,{children:jsxRuntime.jsx(ae,{colSpan:Ce.length+(p?1:0),className:"!p-0 h-32",children:jsxRuntime.jsx("div",{className:"sticky left-0 w-screen max-w-full h-full bg-background flex justify-center items-center",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin"}),"Loading..."]})})})}):w.paginatedData.length===0?null:w.paginatedData.map(n=>{let N=r(n),I=c?.has(N)??false;return jsxRuntime.jsxs(ce,{className:i("group cursor-pointer bg-background hover:bg-muted transition-none",I&&"bg-primary/5",T?.(n)),onClick:()=>u?.(n),onContextMenu:z=>{g&&(z.preventDefault(),g(n,{x:z.clientX,y:z.clientY}));},children:[Ce.map(z=>{if(z==="select"&&m)return jsxRuntime.jsx(ae,{className:i("sticky-select-cell w-10 sticky left-0 z-10 relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border","bg-background group-hover:bg-muted",I&&"bg-primary/5 group-hover:bg-primary/10"),onClick:At=>At.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:I,onChange:()=>Bt(N),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer"})},"select");let Ue=ot(z);if(!Ue||!j.isColumnVisible(z))return null;let Wt={columnId:z,isDragging:Ae.draggedId===z};return jsxRuntime.jsx(ae,{style:Qe(z),className:i(Ue.className,Ae.draggedId===z&&"column-dragging"),children:Ue.cell(n,Wt)},z)}),p&&jsxRuntime.jsx(ae,{className:i("sticky right-0 z-10 text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border","bg-background group-hover:bg-muted",I&&"bg-primary/5 group-hover:bg-primary/10"),style:{width:d,minWidth:d,maxWidth:d},onClick:z=>z.stopPropagation(),children:p(n)},"actions")]},N)})})]})}),!h&&w.paginatedData.length===0&&jsxRuntime.jsx("div",{className:"empty-state-container flex-1 flex items-center justify-center bg-background",children:oe||jsxRuntime.jsx("span",{className:"block text-center text-muted-foreground py-8",children:"No data"})}),!B&&!h&&w.totalPages>1&&jsxRuntime.jsx(Le,{page:w.page,pageSize:w.pageSize,totalItems:w.totalItems,totalPages:w.totalPages,startIndex:w.startIndex,endIndex:w.endIndex,canGoPrev:w.canGoPrev,canGoNext:w.canGoNext,onPageChange:w.setPage,onPageSizeChange:w.setPageSize,onNextPage:w.nextPage,onPrevPage:w.prevPage,onFirstPage:"firstPage"in w?w.firstPage:()=>w.setPage(1),onLastPage:"lastPage"in w?w.lastPage:()=>w.setPage(w.totalPages),pageSizeOptions:w.pageSizeOptions}),ne&&jsxRuntime.jsxs("div",{className:"fixed z-50 min-w-[200px] overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",style:{top:ne.y,left:ne.x,maxHeight:`calc(100vh - ${ne.y}px - 20px)`},onClick:n=>n.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),j.columns.map(n=>{let N=j.isColumnVisible(n.id),I=n.locked===true;return jsxRuntime.jsxs("button",{onClick:()=>!I&&j.toggleColumn(n.id),disabled:I,className:i("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",I&&"opacity-50 cursor-not-allowed"),children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:N&&jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"})}),jsxRuntime.jsx("span",{className:"flex-1 text-left",children:n.label}),I&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},n.id)}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),jsxRuntime.jsxs("button",{onClick:()=>j.showAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs("button",{onClick:()=>j.hideAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})})}var ve=G__namespace.forwardRef(({className:e,type:t,...o},r)=>jsxRuntime.jsx("input",{type:t,className:i("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...o}));ve.displayName="Input";var Be=___namespace.Root,He=___namespace.Trigger,he=G__namespace.forwardRef(({className:e,align:t="center",sideOffset:o=4,...r},m)=>jsxRuntime.jsx(___namespace.Portal,{children:jsxRuntime.jsx(___namespace.Content,{ref:m,align:t,sideOffset:o,className:i("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...r})}));he.displayName=___namespace.Content.displayName;function Oe({page:e,pageSize:t,totalPages:o,totalItems:r,startIndex:m,endIndex:c,canGoNext:f,canGoPrev:u,pageSizeOptions:g,setPage:a,setPageSize:l,nextPage:s,prevPage:p,className:d}){return r===0?null:jsxRuntime.jsxs("div",{className:i("flex items-center gap-3 text-sm",d),children:[jsxRuntime.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground hidden lg:inline",children:"Rows:"}),jsxRuntime.jsxs(ze,{value:String(t),onValueChange:v=>l(Number(v)),children:[jsxRuntime.jsx(ue,{className:"w-16 h-8 text-xs",children:jsxRuntime.jsx(Ee,{})}),jsxRuntime.jsx(fe,{children:g.map(v=>jsxRuntime.jsx(ge,{value:String(v),children:v},v))})]})]}),o>1&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:p,disabled:!u,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsxs("span",{className:"hidden sm:inline px-2 text-muted-foreground tabular-nums min-w-[60px] text-center",children:[e," / ",o]}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:s,disabled:!f,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})})]}),jsxRuntime.jsxs("span",{className:"text-muted-foreground whitespace-nowrap hidden lg:inline",children:["Showing ",m,"\u2013",c," of ",r]})]})}function ht({title:e,description:t,titleExtra:o,search:r,onSearchChange:m,searchPlaceholder:c="Search...",filters:f,activeFilterCount:u=0,onClearFilters:g,pagination:a,actions:l,beforeTable:s,children:p,className:d,loading:v,loadingComponent:k}){let B=a&&a.totalItems>0;return jsxRuntime.jsxs("div",{className:i("flex flex-col h-full",d),children:[jsxRuntime.jsxs("div",{className:"data-table-page-header flex-shrink-0 space-y-4 pb-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"group flex items-center gap-2",children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:e}),o]}),t&&jsxRuntime.jsx("p",{className:"text-muted-foreground",children:t})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[m!==void 0&&jsxRuntime.jsxs("div",{className:"relative w-full sm:w-auto sm:min-w-[200px] sm:max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(ve,{placeholder:c,value:r||"",onChange:b=>m(b.target.value),className:"pl-9 h-9"}),r&&jsxRuntime.jsx("button",{type:"button",onClick:()=>m(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),f&&f.length>0&&jsxRuntime.jsxs(Be,{children:[jsxRuntime.jsx(He,{asChild:true,children:jsxRuntime.jsxs(S,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Filters"}),u>0&&jsxRuntime.jsx("span",{className:"rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:u})]})}),jsxRuntime.jsx(he,{className:"w-80 overflow-y-auto",align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),u>0&&g&&jsxRuntime.jsx(S,{variant:"ghost",size:"sm",onClick:g,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:f.map(b=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:b.label}),b.render()]},b.id))})]})})]}),u>0&&g&&jsxRuntime.jsxs(S,{variant:"ghost",size:"sm",onClick:g,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",title:"Clear filters",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Clear"})]}),B&&jsxRuntime.jsx(Oe,{...a}),jsxRuntime.jsx("div",{className:"flex-1"}),l&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:l})]})]}),s&&jsxRuntime.jsx("div",{className:"px-6 pb-2",children:s}),jsxRuntime.jsx("div",{className:"relative flex-1 min-h-0",children:jsxRuntime.jsx("div",{className:"data-table-scroll-container h-full",children:v?k||jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full",children:jsxRuntime.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}):p})})]})}function xt({children:e,className:t,...o}){return jsxRuntime.jsx("div",{className:i("bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700",t),...o,children:e})}function Pt({selectedCount:e,onClear:t,children:o,itemLabel:r,className:m}){if(e===0)return null;let c=r??(e===1?"item":"items");return jsxRuntime.jsx(xt,{className:i("p-3 bg-primary/5 border-primary/20",m),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"font-medium text-sm",role:"status","aria-live":"polite",children:[e," ",c," selected"]}),jsxRuntime.jsxs(S,{variant:"ghost",size:"sm",onClick:t,"aria-label":"Clear selection",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4 mr-1","aria-hidden":"true"}),"Clear"]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",role:"group","aria-label":"Batch actions",children:o})]})})}var yt=P__namespace.Root,wt=P__namespace.Trigger;var Lo=G__namespace.forwardRef(({className:e,inset:t,children:o,...r},m)=>jsxRuntime.jsxs(P__namespace.SubTrigger,{ref:m,className:i("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[o,jsxRuntime.jsx(lucideReact.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Lo.displayName=P__namespace.SubTrigger.displayName;var Bo=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(P__namespace.SubContent,{ref:o,className:i("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));Bo.displayName=P__namespace.SubContent.displayName;var $e=G__namespace.forwardRef(({className:e,sideOffset:t=4,...o},r)=>jsxRuntime.jsx(P__namespace.Portal,{children:jsxRuntime.jsx(P__namespace.Content,{ref:r,sideOffset:t,className:i("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...o})}));$e.displayName=P__namespace.Content.displayName;var xe=G__namespace.forwardRef(({className:e,inset:t,...o},r)=>jsxRuntime.jsx(P__namespace.Item,{ref:r,className:i("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...o}));xe.displayName=P__namespace.Item.displayName;var Ho=G__namespace.forwardRef(({className:e,children:t,checked:o,...r},m)=>jsxRuntime.jsxs(P__namespace.CheckboxItem,{ref:m,className:i("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:o,...r,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(P__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4"})})}),t]}));Ho.displayName=P__namespace.CheckboxItem.displayName;var Oo=G__namespace.forwardRef(({className:e,children:t,...o},r)=>jsxRuntime.jsxs(P__namespace.RadioItem,{ref:r,className:i("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(P__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Oo.displayName=P__namespace.RadioItem.displayName;var qe=G__namespace.forwardRef(({className:e,inset:t,...o},r)=>jsxRuntime.jsx(P__namespace.Label,{ref:r,className:i("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...o}));qe.displayName=P__namespace.Label.displayName;var We=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(P__namespace.Separator,{ref:o,className:i("-mx-1 my-1 h-px bg-muted",e),...t}));We.displayName=P__namespace.Separator.displayName;function Ct({columns:e,isColumnVisible:t,toggleColumn:o,showAllColumns:r,hideAllColumns:m}){let c=e.filter(u=>t(u.id)).length,f=e.filter(u=>!u.locked);return jsxRuntime.jsxs(yt,{children:[jsxRuntime.jsx(wt,{asChild:true,children:jsxRuntime.jsxs(S,{variant:"outline",size:"sm",className:"gap-2",children:[jsxRuntime.jsx(lucideReact.Columns3,{className:"h-4 w-4"}),"Columns",jsxRuntime.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",c,"/",e.length,")"]})]})}),jsxRuntime.jsxs($e,{align:"end",className:"w-48",children:[jsxRuntime.jsx(qe,{className:"font-normal text-xs text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx(We,{}),e.map(u=>{let g=t(u.id),a=u.locked===true;return jsxRuntime.jsxs(xe,{onClick:l=>{l.preventDefault(),a||o(u.id);},className:i("gap-2 cursor-pointer",a&&"opacity-50 cursor-not-allowed"),disabled:a,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:g?jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"}):jsxRuntime.jsx("div",{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("span",{className:"flex-1",children:u.label}),a&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},u.id)}),f.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(We,{}),jsxRuntime.jsxs(xe,{onClick:u=>{u.preventDefault(),r();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs(xe,{onClick:u=>{u.preventDefault(),m();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})]})}function St({search:e,onSearchChange:t,searchPlaceholder:o="Search...",filters:r,activeFilterCount:m=0,onClearFilters:c,className:f,children:u}){let a=r?.some(l=>l.type==="multi")?"w-[420px]":"w-80";return jsxRuntime.jsxs("div",{className:i("flex items-center gap-3 flex-wrap",f),children:[t!==void 0&&jsxRuntime.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(ve,{placeholder:o,value:e||"",onChange:l=>t(l.target.value),className:"pl-9 h-9"}),e&&jsxRuntime.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),r&&r.length>0&&jsxRuntime.jsxs(Be,{children:[jsxRuntime.jsx(He,{asChild:true,children:jsxRuntime.jsxs(S,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),"Filters",m>0&&jsxRuntime.jsx("span",{className:"ml-1 rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:m})]})}),jsxRuntime.jsx(he,{className:i(a,"overflow-y-auto"),align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),m>0&&c&&jsxRuntime.jsx(S,{variant:"ghost",size:"sm",onClick:c,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:r.map(l=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:l.label}),l.render()]},l.id))})]})})]}),m>0&&c&&jsxRuntime.jsxs(S,{variant:"ghost",size:"sm",onClick:c,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),"Clear"]}),jsxRuntime.jsx("div",{className:"flex-1"}),u]})}var je=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(Pe__namespace.Root,{ref:o,className:i("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:jsxRuntime.jsx(Pe__namespace.Indicator,{className:i("flex items-center justify-center text-current"),children:jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4"})})}));je.displayName=Pe__namespace.Root.displayName;function Tt({options:e,selected:t,onChange:o,maxHeight:r=200,columns:m=2,showBulkActions:c=true,className:f}){let u=d=>{let v=new Set(t);v.has(d)?v.delete(d):v.add(d),o(v);},g=()=>{o(new Set(e.map(d=>d.value)));},a=()=>{o(new Set);},l={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3"},s=e.length>0&&t.size===e.length,p=t.size===0;return jsxRuntime.jsxs("div",{className:i("space-y-2",f),children:[c&&e.length>3&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[jsxRuntime.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:g,disabled:s,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Select all"}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:p,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Clear"}),t.size>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground",children:[t.size," selected"]})]})]}),jsxRuntime.jsx("div",{className:i("overflow-y-auto",e.length>6&&"pr-1"),style:{maxHeight:`${r}px`},children:jsxRuntime.jsx("div",{className:i("grid gap-1",l[m]),children:e.map(d=>jsxRuntime.jsxs("label",{className:i("flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer","hover:bg-muted/50 transition-colors",t.has(d.value)&&"bg-muted/30"),children:[jsxRuntime.jsx(je,{checked:t.has(d.value),onCheckedChange:()=>u(d.value),className:"h-3.5 w-3.5"}),d.render?jsxRuntime.jsx("span",{className:"flex items-center gap-1.5 text-sm truncate",children:d.render()}):jsxRuntime.jsx("span",{className:"text-sm truncate",children:d.label})]},d.value))})}),e.length===0&&jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground text-center py-2",children:"No options available"})]})}exports.BatchActionsBar=Pt;exports.ColumnVisibility=Ct;exports.DataTable=ut;exports.DataTablePage=ht;exports.MultiSelectFilter=Tt;exports.Pagination=Le;exports.PaginationControls=Oe;exports.TableFilters=St;exports.useColumnDragDrop=Ie;exports.useColumnOrder=ke;exports.useColumnVisibility=Re;exports.usePagination=Ne;exports.useResizableColumns=Me;//# sourceMappingURL=data-table.js.map
|
|
1
|
+
'use strict';var G=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),ee=require('@radix-ui/react-tooltip'),lucideReact=require('lucide-react'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),x=require('@radix-ui/react-select'),_=require('@radix-ui/react-popover'),P=require('@radix-ui/react-dropdown-menu'),Pe=require('@radix-ui/react-checkbox');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var G__namespace=/*#__PURE__*/_interopNamespace(G);var ee__namespace=/*#__PURE__*/_interopNamespace(ee);var x__namespace=/*#__PURE__*/_interopNamespace(x);var ___namespace=/*#__PURE__*/_interopNamespace(_);var P__namespace=/*#__PURE__*/_interopNamespace(P);var Pe__namespace=/*#__PURE__*/_interopNamespace(Pe);var Ft=25,Gt=[10,25,50,100];function Ne({data:e,pageSize:t=Ft,storageKey:o}){let[r,m]=G.useState(()=>{if(o)try{let b=localStorage.getItem(`pagination-${o}`);if(b)return {page:1,pageSize:JSON.parse(b).pageSize||t}}catch{}return {page:1,pageSize:t}}),{page:c,pageSize:f}=r,u=G.useMemo(()=>Math.max(1,Math.ceil(e.length/f)),[e.length,f]);G.useEffect(()=>{c>u&&m(b=>({...b,page:Math.max(1,u)}));},[u,c]),G.useEffect(()=>{if(o)try{localStorage.setItem(`pagination-${o}`,JSON.stringify({pageSize:f}));}catch{}},[f,o]);let g=(c-1)*f,a=Math.min(g+f,e.length),l=G.useMemo(()=>e.slice(g,a),[e,g,a]),s=G.useCallback(b=>{m(T=>({...T,page:Math.max(1,Math.min(b,u))}));},[u]),p=G.useCallback(b=>{m({page:1,pageSize:b});},[]),d=G.useCallback(()=>{s(c+1);},[c,s]),v=G.useCallback(()=>{s(c-1);},[c,s]),k=G.useCallback(()=>{s(1);},[s]),B=G.useCallback(()=>{s(u);},[u,s]);return {paginatedData:l,page:c,pageSize:f,totalPages:u,totalItems:e.length,setPage:s,setPageSize:p,nextPage:d,prevPage:v,firstPage:k,lastPage:B,startIndex:g+1,endIndex:a,canGoNext:c<u,canGoPrev:c>1,pageSizeOptions:Gt}}function Re({columns:e,storageKey:t}){let o=`column-visibility-${t}`,[r,m]=G.useState(()=>{let a={};if(e.forEach(l=>{a[l.id]=l.defaultVisible!==false;}),typeof window>"u")return a;try{let l=localStorage.getItem(o);if(l){let s=JSON.parse(l),p={};return e.forEach(d=>{d.locked?p[d.id]=!0:s[d.id]!==void 0?p[d.id]=s[d.id]:p[d.id]=d.defaultVisible!==!1;}),p}}catch(l){console.error("Error loading column visibility state:",l);}return a});G.useEffect(()=>{if(!(typeof window>"u"))try{localStorage.setItem(o,JSON.stringify(r));}catch(a){console.error("Error saving column visibility state:",a);}},[r,o]);let c=G.useCallback(a=>e.find(s=>s.id===a)?.locked?true:r[a]!==false,[r,e]),f=G.useCallback(a=>{e.find(s=>s.id===a)?.locked||m(s=>({...s,[a]:!s[a]}));},[e]),u=G.useCallback(()=>{let a={};e.forEach(l=>{a[l.id]=true;}),m(a);},[e]),g=G.useCallback(()=>{let a={};e.forEach(l=>{a[l.id]=l.locked===true;}),m(a);},[e]);return {visibleColumns:r,isColumnVisible:c,toggleColumn:f,showAllColumns:u,hideAllColumns:g,columns:e}}var it=50,De=150,$t=3;function Me({tableId:e,columns:t,storageKey:o}){let r=o||`table-columns-${e}`,m=G.useCallback(()=>t.reduce((y,h)=>(y[h.key]=h.defaultWidth||De,y),{}),[t]),[c,f]=G.useState(()=>{try{let y=localStorage.getItem(r);if(y){let h=JSON.parse(y);return {widths:{...m(),...h},isResizing:!1,resizingColumn:null}}}catch{}return {widths:m(),isResizing:false,resizingColumn:null}}),u=G.useRef(0),g=G.useRef(0),a=G.useRef(null),l=G.useRef(false),s=G.useRef(t);G.useEffect(()=>{s.current=t;},[t]);let p=G.useCallback(y=>s.current.find(h=>h.key===y),[]);G.useEffect(()=>{try{localStorage.setItem(r,JSON.stringify(c.widths));}catch{}},[c.widths,r]);let d=G.useRef(null);d.current||(d.current={onPointerMove:y=>{if(!a.current)return;let h=y.clientX-u.current;if(!l.current){if(Math.abs(h)<$t)return;l.current=true,f(re=>({...re,isResizing:true,resizingColumn:a.current})),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}let oe=p(a.current),de=oe?.minWidth||it,we=oe?.maxWidth,me=Math.max(de,g.current+h);we&&(me=Math.min(we,me)),f(re=>({...re,widths:{...re.widths,[a.current]:me}}));},onPointerUp:()=>{a.current=null,l.current=false,f(y=>({...y,isResizing:false,resizingColumn:null})),document.removeEventListener("pointermove",d.current.onPointerMove),document.removeEventListener("pointerup",d.current.onPointerUp),document.removeEventListener("pointercancel",d.current.onPointerUp),document.body.style.cursor="",document.body.style.userSelect="";}}),G.useEffect(()=>()=>{d.current&&(document.removeEventListener("pointermove",d.current.onPointerMove),document.removeEventListener("pointerup",d.current.onPointerUp),document.removeEventListener("pointercancel",d.current.onPointerUp)),document.body.style.cursor="",document.body.style.userSelect="";},[]);let v=G.useRef(c.widths);G.useEffect(()=>{v.current=c.widths;},[c.widths]);let k=G.useCallback((y,h)=>{u.current=h,g.current=v.current[y]||De,a.current=y,l.current=false,document.addEventListener("pointermove",d.current.onPointerMove),document.addEventListener("pointerup",d.current.onPointerUp),document.addEventListener("pointercancel",d.current.onPointerUp);},[]),B=G.useCallback(y=>({onPointerDown:h=>{h.preventDefault(),h.stopPropagation(),k(y,h.clientX);},onMouseDown:h=>{h.preventDefault(),h.stopPropagation();},draggable:false,onDragStart:h=>{h.preventDefault(),h.stopPropagation();},className:"resize-handle","data-resizing":c.resizingColumn===y}),[k,c.resizingColumn]),b=G.useCallback(y=>{let h=c.widths[y]||De,de=p(y)?.minWidth||it;return {width:h,minWidth:de,position:"relative"}},[c.widths,p]),T=t.reduce((y,h)=>y+(c.widths[h.key]||h.defaultWidth||De),0),W=G.useCallback(()=>({minWidth:T}),[T]),$=G.useCallback(()=>{f(y=>({...y,widths:m()}));},[m]);return {widths:c.widths,isResizing:c.isResizing,totalWidth:T,getResizeHandleProps:B,getColumnStyle:b,getTableStyle:W,resetToDefaults:$}}function ke({storageKey:e,defaultOrder:t}){let[o,r]=G.useState(()=>{try{let g=localStorage.getItem(e);if(g){let a=JSON.parse(g),l=new Set(a),s=new Set(t),p=a.filter(v=>s.has(v)),d=t.filter(v=>!l.has(v));if(d.length>0){let v=[...p];for(let k of d){let B=t.indexOf(k),b=v.length;for(let T=0;T<v.length;T++)if(t.indexOf(v[T])>B){b=T;break}v.splice(b,0,k);}return v}return p.length>0?p:t}}catch(g){console.warn("Failed to load column order from localStorage:",g);}return t});G.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(o));}catch(g){console.warn("Failed to save column order to localStorage:",g);}},[e,o]);let m=G.useCallback((g,a)=>{g!==a&&r(l=>{let s=[...l],[p]=s.splice(g,1);return p!==void 0&&s.splice(a,0,p),s});},[]),c=G.useCallback((g,a)=>{r(l=>{let s=l.indexOf(g);if(s===-1)return l;let p=a==="left"?Math.max(0,s-1):Math.min(l.length-1,s+1);if(s===p)return l;let d=[...l],[v]=d.splice(s,1);return v!==void 0&&d.splice(p,0,v),d});},[]),f=G.useCallback(()=>{r(t);},[t]),u=G.useCallback(g=>{let a=new Map(g.map(l=>[l.id,l]));return o.map(l=>a.get(l)).filter(l=>l!==void 0)},[o]);return {columnOrder:o,moveColumn:m,moveColumnById:c,resetOrder:f,getOrderedColumns:u}}function Ie(e,t,o=[]){let[r,m]=G.useState({isDragging:false,draggedId:null,dropIndex:null}),c=G.useCallback(s=>{o.includes(s)||m({isDragging:true,draggedId:s,dropIndex:null});},[o]),f=G.useCallback((s,p)=>{if(o.includes(s))return;let d=e.indexOf(s);if(d===-1)return;let v=p.currentTarget.getBoundingClientRect(),k=v.left+v.width/2,B=p.clientX<k?d:d+1;m(b=>({...b,dropIndex:B}));},[o,e]),u=G.useCallback(()=>{if(!r.draggedId||r.dropIndex===null){m({isDragging:false,draggedId:null,dropIndex:null});return}let s=e.indexOf(r.draggedId),p=r.dropIndex;s<p&&(p=p-1),s!==-1&&p!==-1&&s!==p&&t(s,p),m({isDragging:false,draggedId:null,dropIndex:null});},[r.draggedId,r.dropIndex,e,t]),g=G.useCallback(()=>{m({isDragging:false,draggedId:null,dropIndex:null});},[]),a=G.useCallback(s=>({draggable:!o.includes(s),onDragStart:p=>{if(o.includes(s)){p.preventDefault();return}p.dataTransfer.effectAllowed="move",c(s);},onDragOver:p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",f(s,p);},onDrop:p=>{p.preventDefault(),u();},onDragEnd:g}),[o,c,f,u,g]),l=G.useCallback(s=>!r.isDragging||r.dropIndex===null?false:e.indexOf(s)===r.dropIndex,[r.isDragging,r.dropIndex,e]);return {dragState:r,getDragHandleProps:a,showDropIndicator:l}}function i(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var Fe=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:o,className:i("w-full caption-bottom text-sm",e),...t})}));Fe.displayName="Table";var Ge=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("thead",{ref:o,className:i("[&_tr]:border-b",e),...t}));Ge.displayName="TableHeader";var _e=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("tbody",{ref:o,className:i("[&_tr:last-child]:border-0",e),...t}));_e.displayName="TableBody";var jt=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("tfoot",{ref:o,className:i("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));jt.displayName="TableFooter";var ce=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("tr",{ref:o,className:i("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));ce.displayName="TableRow";var pe=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("th",{ref:o,className:i("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));pe.displayName="TableHead";var ae=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("td",{ref:o,className:i("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ae.displayName="TableCell";var Qt=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("caption",{ref:o,className:i("mt-4 text-sm text-muted-foreground",e),...t}));Qt.displayName="TableCaption";var lt=ee__namespace.Provider;var Kt=G__namespace.forwardRef(({className:e,sideOffset:t=4,...o},r)=>jsxRuntime.jsx(ee__namespace.Content,{ref:r,sideOffset:t,className:i("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",e),...o}));Kt.displayName=ee__namespace.Content.displayName;var ro=classVarianceAuthority.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),S=G__namespace.forwardRef(({className:e,variant:t,size:o,asChild:r=false,...m},c)=>jsxRuntime.jsx(r?reactSlot.Slot:"button",{className:i(ro({variant:t,size:o,className:e})),ref:c,...m}));S.displayName="Button";var ze=x__namespace.Root;var Ee=x__namespace.Value,ue=G__namespace.forwardRef(({className:e,children:t,...o},r)=>jsxRuntime.jsxs(x__namespace.Trigger,{ref:r,className:i("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...o,children:[t,jsxRuntime.jsx(x__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ue.displayName=x__namespace.Trigger.displayName;var ct=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.ScrollUpButton,{ref:o,className:i("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-4 w-4"})}));ct.displayName=x__namespace.ScrollUpButton.displayName;var pt=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.ScrollDownButton,{ref:o,className:i("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-4 w-4"})}));pt.displayName=x__namespace.ScrollDownButton.displayName;var fe=G__namespace.forwardRef(({className:e,children:t,position:o="popper",...r},m)=>jsxRuntime.jsx(x__namespace.Portal,{children:jsxRuntime.jsxs(x__namespace.Content,{ref:m,className:i("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",o==="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:o,...r,children:[jsxRuntime.jsx(ct,{}),jsxRuntime.jsx(x__namespace.Viewport,{className:i("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(pt,{})]})}));fe.displayName=x__namespace.Content.displayName;var so=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.Label,{ref:o,className:i("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));so.displayName=x__namespace.Label.displayName;var ge=G__namespace.forwardRef(({className:e,children:t,...o},r)=>jsxRuntime.jsxs(x__namespace.Item,{ref:r,className:i("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(x__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(x__namespace.ItemText,{children:t})]}));ge.displayName=x__namespace.Item.displayName;var lo=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(x__namespace.Separator,{ref:o,className:i("-mx-1 my-1 h-px bg-muted",e),...t}));lo.displayName=x__namespace.Separator.displayName;function Le({page:e,pageSize:t,totalPages:o,totalItems:r,startIndex:m,endIndex:c,canGoNext:f,canGoPrev:u,pageSizeOptions:g,onPageChange:a,onPageSizeChange:l,onNextPage:s,onPrevPage:p,onFirstPage:d,onLastPage:v,className:k}){let B=()=>{let b=[],W=Math.floor(2.5),$=Math.max(1,e-W),y=Math.min(o,e+W);e<=W&&(y=Math.min(o,5)),e>o-W&&($=Math.max(1,o-5+1)),$>1&&(b.push(1),$>2&&b.push("ellipsis"));for(let h=$;h<=y;h++)h!==1&&h!==o&&b.push(h);return y<o&&(y<o-1&&b.push("ellipsis"),b.push(o)),b};return r===0?null:jsxRuntime.jsxs("div",{className:i("flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-3",k),children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",m," to ",c," of ",r," items"]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"Per page:"}),jsxRuntime.jsxs(ze,{value:String(t),onValueChange:b=>l(Number(b)),children:[jsxRuntime.jsx(ue,{className:"w-20 h-8",children:jsxRuntime.jsx(Ee,{})}),jsxRuntime.jsx(fe,{children:g.map(b=>jsxRuntime.jsx(ge,{value:String(b),children:b},b))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:d,disabled:!u,title:"First page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:p,disabled:!u,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:B().map((b,T)=>b==="ellipsis"?jsxRuntime.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${T}`):jsxRuntime.jsx(S,{variant:e===b?"default":"outline",size:"icon",className:"h-8 w-8",onClick:()=>a(b),children:b},b))}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:s,disabled:!f,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:v,disabled:!f,title:"Last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})]})]})]})}function ut({data:e,columns:t,storageKey:o,getRowId:r,selectable:m=false,selectedIds:c,onSelectionChange:f,onRowClick:u,onRowContextMenu:g,sortField:a,sortOrder:l,onSort:s,actionsColumn:p,actionsColumnWidth:d=80,pageSize:v=25,pagination:k,hidePagination:B=false,className:b,rowClassName:T,enableHeaderContextMenu:W=true,lockedColumns:$=[],defaultColumnOrder:y,loading:h=false,emptyState:oe}){let de=G.useMemo(()=>{let n=[];return m&&n.push({key:"select",defaultWidth:40,minWidth:40}),t.forEach(N=>{n.push({key:N.id,defaultWidth:N.width?.default??150,minWidth:N.width?.min??80,maxWidth:N.width?.max});}),p&&n.push({key:"actions",defaultWidth:d,minWidth:60}),n},[t,m,p,d]),we=G.useMemo(()=>t.map(n=>({id:n.id,label:typeof n.header=="string"?n.header:n.id,defaultVisible:n.visibility?.default??true,locked:n.visibility?.locked})),[t]),me=G.useMemo(()=>{if(y)return y;let n=[];return m&&n.push("select"),t.forEach(N=>n.push(N.id)),p&&n.push("actions"),n},[y,t,m,p]),{getResizeHandleProps:re,getColumnStyle:Qe,getTableStyle:Dt}=Me({tableId:o,columns:de}),j=Re({columns:we,storageKey:o}),{columnOrder:Ce,moveColumn:Mt}=ke({storageKey:`${o}-order`,defaultOrder:me}),{dragState:Ae,getDragHandleProps:kt,showDropIndicator:It}=Ie(Ce,Mt,[...$,"select","actions"]),zt=Ne({data:e,pageSize:v,storageKey:o}),w=k||zt,[ne,Ke]=G.useState(null),Et=G.useCallback(n=>{W&&(n.preventDefault(),Ke({x:n.clientX,y:n.clientY}));},[W]);G.useEffect(()=>{if(!ne)return;let n=()=>Ke(null);return window.addEventListener("click",n),()=>{window.removeEventListener("click",n);}},[ne]);let et=G.useMemo(()=>!m||!c||w.paginatedData.length===0?false:w.paginatedData.every(n=>c.has(r(n))),[m,c,w.paginatedData,r]),Lt=G.useMemo(()=>{if(!m||!c)return false;let n=w.paginatedData.filter(N=>c.has(r(N)));return n.length>0&&n.length<w.paginatedData.length},[m,c,w.paginatedData,r]),Bt=G.useCallback(n=>{if(!f||!c)return;let N=new Set(c);N.has(n)?N.delete(n):N.add(n),f(N);},[c,f]),Ht=G.useCallback(()=>{if(!f)return;let n=new Set(w.paginatedData.map(r));f(n);},[w.paginatedData,r,f]),Ot=G.useCallback(()=>{f&&f(new Set);},[f]),tt=G.useCallback(n=>a!==n?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):l==="asc"?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3.5 w-3.5"}),[a,l]),ot=G.useCallback(n=>t.find(N=>N.id===n),[t]),Vt=G.useCallback(n=>{let N={columnId:n.id,isSorted:a===n.sortKey,sortDirection:a===n.sortKey?l:void 0};return typeof n.header=="function"?n.header(N):n.sortKey&&s?jsxRuntime.jsxs("button",{onClick:()=>s(n.sortKey),className:i("flex items-center gap-1 hover:text-foreground transition-colors",a===n.sortKey&&"text-foreground font-medium"),children:[n.header,tt(n.sortKey)]}):n.header},[a,l,s,tt]);return jsxRuntime.jsx(lt,{children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"overflow-auto border rounded-lg h-full",children:jsxRuntime.jsxs(Fe,{style:Dt(),className:i("resizable-table sticky-actions-table",b),children:[jsxRuntime.jsx(Ge,{className:"sticky top-0 z-20 bg-muted",children:jsxRuntime.jsxs(ce,{onContextMenu:Et,className:"border-t-0",children:[Ce.map(n=>{if(n==="select"&&m)return jsxRuntime.jsx(pe,{className:"sticky-select-header w-10 sticky left-0 z-20 bg-muted relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border",children:jsxRuntime.jsx("input",{type:"checkbox",checked:et,ref:I=>{I&&(I.indeterminate=Lt);},onChange:I=>I.target.checked?Ht():Ot(),className:"h-4 w-4 rounded border-border text-primary focus:ring-primary cursor-pointer",title:et?"Deselect all":"Select all visible"})},"select");let N=ot(n);return !N||!j.isColumnVisible(n)?null:jsxRuntime.jsxs(pe,{style:Qe(n),...kt(n),className:i("cursor-grab relative",Ae.draggedId===n&&"column-dragging opacity-50",It(n)&&"drop-indicator"),children:[Vt(N),jsxRuntime.jsx("div",{...re(n)})]},n)}),p&&jsxRuntime.jsx(pe,{className:"sticky right-0 z-20 bg-muted text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border",style:{width:d,minWidth:d,maxWidth:d},children:"Actions"},"actions")]})}),jsxRuntime.jsx(_e,{children:h?jsxRuntime.jsx(ce,{children:jsxRuntime.jsx(ae,{colSpan:Ce.length+(p?1:0),className:"!p-0 h-32",children:jsxRuntime.jsx("div",{className:"sticky left-0 w-screen max-w-full h-full bg-background flex justify-center items-center",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin"}),"Loading..."]})})})}):w.paginatedData.length===0?null:w.paginatedData.map(n=>{let N=r(n),I=c?.has(N)??false;return jsxRuntime.jsxs(ce,{className:i("group cursor-pointer bg-background hover:bg-muted transition-none",I&&"bg-primary/5",T?.(n)),onClick:()=>u?.(n),onContextMenu:z=>{g&&(z.preventDefault(),g(n,{x:z.clientX,y:z.clientY}));},children:[Ce.map(z=>{if(z==="select"&&m)return jsxRuntime.jsx(ae,{className:i("sticky-select-cell w-10 sticky left-0 z-10 relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border","bg-background group-hover:bg-muted",I&&"bg-primary/5 group-hover:bg-primary/10"),onClick:At=>At.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:I,onChange:()=>Bt(N),className:"h-4 w-4 rounded border-border text-primary focus:ring-primary cursor-pointer"})},"select");let Ue=ot(z);if(!Ue||!j.isColumnVisible(z))return null;let Wt={columnId:z,isDragging:Ae.draggedId===z};return jsxRuntime.jsx(ae,{style:Qe(z),className:i(Ue.className,Ae.draggedId===z&&"column-dragging"),children:Ue.cell(n,Wt)},z)}),p&&jsxRuntime.jsx(ae,{className:i("sticky right-0 z-10 text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border","bg-background group-hover:bg-muted",I&&"bg-primary/5 group-hover:bg-primary/10"),style:{width:d,minWidth:d,maxWidth:d},onClick:z=>z.stopPropagation(),children:p(n)},"actions")]},N)})})]})}),!h&&w.paginatedData.length===0&&jsxRuntime.jsx("div",{className:"empty-state-container flex-1 flex items-center justify-center bg-background",children:oe||jsxRuntime.jsx("span",{className:"block text-center text-muted-foreground py-8",children:"No data"})}),!B&&!h&&w.totalPages>1&&jsxRuntime.jsx(Le,{page:w.page,pageSize:w.pageSize,totalItems:w.totalItems,totalPages:w.totalPages,startIndex:w.startIndex,endIndex:w.endIndex,canGoPrev:w.canGoPrev,canGoNext:w.canGoNext,onPageChange:w.setPage,onPageSizeChange:w.setPageSize,onNextPage:w.nextPage,onPrevPage:w.prevPage,onFirstPage:"firstPage"in w?w.firstPage:()=>w.setPage(1),onLastPage:"lastPage"in w?w.lastPage:()=>w.setPage(w.totalPages),pageSizeOptions:w.pageSizeOptions}),ne&&jsxRuntime.jsxs("div",{className:"fixed z-50 min-w-[200px] overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",style:{top:ne.y,left:ne.x,maxHeight:`calc(100vh - ${ne.y}px - 20px)`},onClick:n=>n.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),j.columns.map(n=>{let N=j.isColumnVisible(n.id),I=n.locked===true;return jsxRuntime.jsxs("button",{onClick:()=>!I&&j.toggleColumn(n.id),disabled:I,className:i("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",I&&"opacity-50 cursor-not-allowed"),children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:N&&jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"})}),jsxRuntime.jsx("span",{className:"flex-1 text-left",children:n.label}),I&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},n.id)}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),jsxRuntime.jsxs("button",{onClick:()=>j.showAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs("button",{onClick:()=>j.hideAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})})}var ve=G__namespace.forwardRef(({className:e,type:t,...o},r)=>jsxRuntime.jsx("input",{type:t,className:i("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...o}));ve.displayName="Input";var Be=___namespace.Root,He=___namespace.Trigger,he=G__namespace.forwardRef(({className:e,align:t="center",sideOffset:o=4,...r},m)=>jsxRuntime.jsx(___namespace.Portal,{children:jsxRuntime.jsx(___namespace.Content,{ref:m,align:t,sideOffset:o,className:i("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...r})}));he.displayName=___namespace.Content.displayName;function Oe({page:e,pageSize:t,totalPages:o,totalItems:r,startIndex:m,endIndex:c,canGoNext:f,canGoPrev:u,pageSizeOptions:g,setPage:a,setPageSize:l,nextPage:s,prevPage:p,className:d}){return r===0?null:jsxRuntime.jsxs("div",{className:i("flex items-center gap-3 text-sm",d),children:[jsxRuntime.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground hidden lg:inline",children:"Rows:"}),jsxRuntime.jsxs(ze,{value:String(t),onValueChange:v=>l(Number(v)),children:[jsxRuntime.jsx(ue,{className:"w-16 h-8 text-xs",children:jsxRuntime.jsx(Ee,{})}),jsxRuntime.jsx(fe,{children:g.map(v=>jsxRuntime.jsx(ge,{value:String(v),children:v},v))})]})]}),o>1&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:p,disabled:!u,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsxs("span",{className:"hidden sm:inline px-2 text-muted-foreground tabular-nums min-w-[60px] text-center",children:[e," / ",o]}),jsxRuntime.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:s,disabled:!f,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})})]}),jsxRuntime.jsxs("span",{className:"text-muted-foreground whitespace-nowrap hidden lg:inline",children:["Showing ",m,"\u2013",c," of ",r]})]})}function ht({title:e,description:t,titleExtra:o,search:r,onSearchChange:m,searchPlaceholder:c="Search...",filters:f,activeFilterCount:u=0,onClearFilters:g,pagination:a,actions:l,beforeTable:s,children:p,className:d,loading:v,loadingComponent:k}){let B=a&&a.totalItems>0;return jsxRuntime.jsxs("div",{className:i("flex flex-col h-full",d),children:[jsxRuntime.jsxs("div",{className:"data-table-page-header flex-shrink-0 space-y-4 pb-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"group flex items-center gap-2",children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:e}),o]}),t&&jsxRuntime.jsx("p",{className:"text-muted-foreground",children:t})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[m!==void 0&&jsxRuntime.jsxs("div",{className:"relative w-full sm:w-auto sm:min-w-[200px] sm:max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(ve,{placeholder:c,value:r||"",onChange:b=>m(b.target.value),className:"pl-9 h-9"}),r&&jsxRuntime.jsx("button",{type:"button",onClick:()=>m(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),f&&f.length>0&&jsxRuntime.jsxs(Be,{children:[jsxRuntime.jsx(He,{asChild:true,children:jsxRuntime.jsxs(S,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Filters"}),u>0&&jsxRuntime.jsx("span",{className:"rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:u})]})}),jsxRuntime.jsx(he,{className:"w-80 overflow-y-auto",align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),u>0&&g&&jsxRuntime.jsx(S,{variant:"ghost",size:"sm",onClick:g,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:f.map(b=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:b.label}),b.render()]},b.id))})]})})]}),u>0&&g&&jsxRuntime.jsxs(S,{variant:"ghost",size:"sm",onClick:g,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",title:"Clear filters",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Clear"})]}),B&&jsxRuntime.jsx(Oe,{...a}),jsxRuntime.jsx("div",{className:"flex-1"}),l&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:l})]})]}),s&&jsxRuntime.jsx("div",{className:"px-6 pb-2",children:s}),jsxRuntime.jsx("div",{className:"relative flex-1 min-h-0",children:jsxRuntime.jsx("div",{className:"data-table-scroll-container h-full",children:v?k||jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full",children:jsxRuntime.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}):p})})]})}function xt({children:e,className:t,...o}){return jsxRuntime.jsx("div",{className:i("bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700",t),...o,children:e})}function Pt({selectedCount:e,onClear:t,children:o,itemLabel:r,className:m}){if(e===0)return null;let c=r??(e===1?"item":"items");return jsxRuntime.jsx(xt,{className:i("p-3 bg-primary/5 border-primary/20",m),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"font-medium text-sm",role:"status","aria-live":"polite",children:[e," ",c," selected"]}),jsxRuntime.jsxs(S,{variant:"ghost",size:"sm",onClick:t,"aria-label":"Clear selection",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4 mr-1","aria-hidden":"true"}),"Clear"]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",role:"group","aria-label":"Batch actions",children:o})]})})}var yt=P__namespace.Root,wt=P__namespace.Trigger;var Lo=G__namespace.forwardRef(({className:e,inset:t,children:o,...r},m)=>jsxRuntime.jsxs(P__namespace.SubTrigger,{ref:m,className:i("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[o,jsxRuntime.jsx(lucideReact.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Lo.displayName=P__namespace.SubTrigger.displayName;var Bo=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(P__namespace.SubContent,{ref:o,className:i("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));Bo.displayName=P__namespace.SubContent.displayName;var $e=G__namespace.forwardRef(({className:e,sideOffset:t=4,...o},r)=>jsxRuntime.jsx(P__namespace.Portal,{children:jsxRuntime.jsx(P__namespace.Content,{ref:r,sideOffset:t,className:i("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...o})}));$e.displayName=P__namespace.Content.displayName;var xe=G__namespace.forwardRef(({className:e,inset:t,...o},r)=>jsxRuntime.jsx(P__namespace.Item,{ref:r,className:i("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...o}));xe.displayName=P__namespace.Item.displayName;var Ho=G__namespace.forwardRef(({className:e,children:t,checked:o,...r},m)=>jsxRuntime.jsxs(P__namespace.CheckboxItem,{ref:m,className:i("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:o,...r,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(P__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4"})})}),t]}));Ho.displayName=P__namespace.CheckboxItem.displayName;var Oo=G__namespace.forwardRef(({className:e,children:t,...o},r)=>jsxRuntime.jsxs(P__namespace.RadioItem,{ref:r,className:i("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(P__namespace.ItemIndicator,{children:jsxRuntime.jsx(lucideReact.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Oo.displayName=P__namespace.RadioItem.displayName;var qe=G__namespace.forwardRef(({className:e,inset:t,...o},r)=>jsxRuntime.jsx(P__namespace.Label,{ref:r,className:i("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...o}));qe.displayName=P__namespace.Label.displayName;var We=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(P__namespace.Separator,{ref:o,className:i("-mx-1 my-1 h-px bg-muted",e),...t}));We.displayName=P__namespace.Separator.displayName;function Ct({columns:e,isColumnVisible:t,toggleColumn:o,showAllColumns:r,hideAllColumns:m}){let c=e.filter(u=>t(u.id)).length,f=e.filter(u=>!u.locked);return jsxRuntime.jsxs(yt,{children:[jsxRuntime.jsx(wt,{asChild:true,children:jsxRuntime.jsxs(S,{variant:"outline",size:"sm",className:"gap-2",children:[jsxRuntime.jsx(lucideReact.Columns3,{className:"h-4 w-4"}),"Columns",jsxRuntime.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",c,"/",e.length,")"]})]})}),jsxRuntime.jsxs($e,{align:"end",className:"w-48",children:[jsxRuntime.jsx(qe,{className:"font-normal text-xs text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx(We,{}),e.map(u=>{let g=t(u.id),a=u.locked===true;return jsxRuntime.jsxs(xe,{onClick:l=>{l.preventDefault(),a||o(u.id);},className:i("gap-2 cursor-pointer",a&&"opacity-50 cursor-not-allowed"),disabled:a,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:g?jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"}):jsxRuntime.jsx("div",{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("span",{className:"flex-1",children:u.label}),a&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},u.id)}),f.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(We,{}),jsxRuntime.jsxs(xe,{onClick:u=>{u.preventDefault(),r();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs(xe,{onClick:u=>{u.preventDefault(),m();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})]})}function St({search:e,onSearchChange:t,searchPlaceholder:o="Search...",filters:r,activeFilterCount:m=0,onClearFilters:c,className:f,children:u}){let a=r?.some(l=>l.type==="multi")?"w-[420px]":"w-80";return jsxRuntime.jsxs("div",{className:i("flex items-center gap-3 flex-wrap",f),children:[t!==void 0&&jsxRuntime.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(ve,{placeholder:o,value:e||"",onChange:l=>t(l.target.value),className:"pl-9 h-9"}),e&&jsxRuntime.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),r&&r.length>0&&jsxRuntime.jsxs(Be,{children:[jsxRuntime.jsx(He,{asChild:true,children:jsxRuntime.jsxs(S,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),"Filters",m>0&&jsxRuntime.jsx("span",{className:"ml-1 rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:m})]})}),jsxRuntime.jsx(he,{className:i(a,"overflow-y-auto"),align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),m>0&&c&&jsxRuntime.jsx(S,{variant:"ghost",size:"sm",onClick:c,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:r.map(l=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:l.label}),l.render()]},l.id))})]})})]}),m>0&&c&&jsxRuntime.jsxs(S,{variant:"ghost",size:"sm",onClick:c,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),"Clear"]}),jsxRuntime.jsx("div",{className:"flex-1"}),u]})}var je=G__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(Pe__namespace.Root,{ref:o,className:i("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:jsxRuntime.jsx(Pe__namespace.Indicator,{className:i("flex items-center justify-center text-current"),children:jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4"})})}));je.displayName=Pe__namespace.Root.displayName;function Tt({options:e,selected:t,onChange:o,maxHeight:r=200,columns:m=2,showBulkActions:c=true,className:f}){let u=d=>{let v=new Set(t);v.has(d)?v.delete(d):v.add(d),o(v);},g=()=>{o(new Set(e.map(d=>d.value)));},a=()=>{o(new Set);},l={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3"},s=e.length>0&&t.size===e.length,p=t.size===0;return jsxRuntime.jsxs("div",{className:i("space-y-2",f),children:[c&&e.length>3&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[jsxRuntime.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:g,disabled:s,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Select all"}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:p,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Clear"}),t.size>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground",children:[t.size," selected"]})]})]}),jsxRuntime.jsx("div",{className:i("overflow-y-auto",e.length>6&&"pr-1"),style:{maxHeight:`${r}px`},children:jsxRuntime.jsx("div",{className:i("grid gap-1",l[m]),children:e.map(d=>jsxRuntime.jsxs("label",{className:i("flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer","hover:bg-muted/50 transition-colors",t.has(d.value)&&"bg-muted/30"),children:[jsxRuntime.jsx(je,{checked:t.has(d.value),onCheckedChange:()=>u(d.value),className:"h-3.5 w-3.5"}),d.render?jsxRuntime.jsx("span",{className:"flex items-center gap-1.5 text-sm truncate",children:d.render()}):jsxRuntime.jsx("span",{className:"text-sm truncate",children:d.label})]},d.value))})}),e.length===0&&jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground text-center py-2",children:"No options available"})]})}exports.BatchActionsBar=Pt;exports.ColumnVisibility=Ct;exports.DataTable=ut;exports.DataTablePage=ht;exports.MultiSelectFilter=Tt;exports.Pagination=Le;exports.PaginationControls=Oe;exports.TableFilters=St;exports.useColumnDragDrop=Ie;exports.useColumnOrder=ke;exports.useColumnVisibility=Re;exports.usePagination=Ne;exports.useResizableColumns=Me;//# sourceMappingURL=data-table.js.map
|
|
2
2
|
//# sourceMappingURL=data-table.js.map
|