@hanzo/ui 5.4.1 → 5.5.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.
Files changed (48) hide show
  1. package/dist/dash/crud.js +2 -0
  2. package/dist/dash/crud.mjs +2 -0
  3. package/dist/dash/form.js +2 -0
  4. package/dist/dash/form.mjs +2 -0
  5. package/dist/dash/{dash-header.js → header.js} +1 -1
  6. package/dist/dash/{dash-header.mjs → header.mjs} +1 -1
  7. package/dist/dash/index.js +2 -2
  8. package/dist/dash/index.mjs +2 -2
  9. package/dist/dash/{dash-layout.js → layout.js} +1 -1
  10. package/dist/dash/{dash-layout.mjs → layout.mjs} +1 -1
  11. package/dist/dash/sidebar.js +3 -0
  12. package/dist/dash/sidebar.mjs +3 -0
  13. package/dist/dash/{dash-data-table.js → table.js} +1 -1
  14. package/dist/dash/{dash-data-table.mjs → table.mjs} +1 -1
  15. package/dist/src/dash/{dash-crud.d.ts → crud.d.ts} +9 -9
  16. package/dist/src/dash/crud.d.ts.map +1 -0
  17. package/dist/src/dash/{dash-crud.js → crud.js} +5 -5
  18. package/dist/src/dash/{dash-form.d.ts → form.d.ts} +9 -9
  19. package/dist/src/dash/form.d.ts.map +1 -0
  20. package/dist/src/dash/{dash-form.js → form.js} +1 -1
  21. package/dist/src/dash/{dash-header.d.ts → header.d.ts} +3 -3
  22. package/dist/src/dash/header.d.ts.map +1 -0
  23. package/dist/src/dash/{dash-header.js → header.js} +1 -1
  24. package/dist/src/dash/index.d.ts +12 -12
  25. package/dist/src/dash/index.d.ts.map +1 -1
  26. package/dist/src/dash/index.js +6 -6
  27. package/dist/src/dash/{dash-layout.d.ts → layout.d.ts} +5 -5
  28. package/dist/src/dash/layout.d.ts.map +1 -0
  29. package/dist/src/dash/{dash-layout.js → layout.js} +1 -1
  30. package/dist/src/dash/{dash-sidebar.d.ts → sidebar.d.ts} +3 -3
  31. package/dist/src/dash/sidebar.d.ts.map +1 -0
  32. package/dist/src/dash/{dash-sidebar.js → sidebar.js} +1 -1
  33. package/dist/src/dash/{dash-data-table.d.ts → table.d.ts} +5 -5
  34. package/dist/src/dash/table.d.ts.map +1 -0
  35. package/dist/src/dash/{dash-data-table.js → table.js} +1 -1
  36. package/package.json +1 -1
  37. package/dist/dash/dash-crud.js +0 -2
  38. package/dist/dash/dash-crud.mjs +0 -2
  39. package/dist/dash/dash-form.js +0 -2
  40. package/dist/dash/dash-form.mjs +0 -2
  41. package/dist/dash/dash-sidebar.js +0 -3
  42. package/dist/dash/dash-sidebar.mjs +0 -3
  43. package/dist/src/dash/dash-crud.d.ts.map +0 -1
  44. package/dist/src/dash/dash-data-table.d.ts.map +0 -1
  45. package/dist/src/dash/dash-form.d.ts.map +0 -1
  46. package/dist/src/dash/dash-header.d.ts.map +0 -1
  47. package/dist/src/dash/dash-layout.d.ts.map +0 -1
  48. package/dist/src/dash/dash-sidebar.d.ts.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ 'use strict';var $=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');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 $__namespace=/*#__PURE__*/_interopNamespace($);var I=Object.defineProperty;var c=(e,r)=>I(e,"name",{value:r,configurable:true});function n(...e){return tailwindMerge.twMerge(clsx.clsx(e))}c(n,"cn");function Z({columns:e,data:r,rowKey:h,selectable:i=false,selectedKeys:m,onSelectionChange:p,searchable:y=false,searchPlaceholder:b="Search...",totalRows:o,page:u=0,pageSize:P=20,onPageChange:F,onPageSizeChange:D,actions:V,loading:q=false,emptyMessage:d="No data",className:l}){let[a,g]=$__namespace.useState(""),[w,K]=$__namespace.useState(null),z=$__namespace.useMemo(()=>{if(!a)return r;let t=a.toLowerCase();return r.filter(f=>e.some(M=>(M.cell?"":String(f[M.id]??"")).toLowerCase().includes(t)))},[r,a,e]),j=$__namespace.useMemo(()=>{if(!w)return z;let{column:t,direction:f}=w;return [...z].sort((M,T)=>{let H=M[t],Q=T[t];if(H==null&&Q==null)return 0;if(H==null)return 1;if(Q==null)return -1;let Y=String(H).localeCompare(String(Q),void 0,{numeric:true});return f==="asc"?Y:-Y})},[z,w]),O=o??j.length,E=Math.max(1,Math.ceil(O/P)),L=F?j:j.slice(u*P,(u+1)*P),C=m??new Set,W=L.length>0&&L.every(t=>C.has(h(t)));function _(){p&&p(W?new Set:new Set(L.map(h)));}c(_,"toggleAll");function A(t){if(!p)return;let f=new Set(C);f.has(t)?f.delete(t):f.add(t),p(f);}c(A,"toggleRow");function G(t){K(f=>f?.column===t?f.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"});}c(G,"handleSort");let x=V?[...e,{id:"__actions",header:"",width:"auto"}]:e;return jsxRuntime.jsxs("div",{className:n("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",l),children:[(y||i)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[y&&jsxRuntime.jsx("input",{type:"text",placeholder:b,value:a,onChange:t=>g(t.target.value),className:n("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),i&&C.size>0&&jsxRuntime.jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[C.size," selected"]})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[i&&jsxRuntime.jsx("th",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:W,onChange:_,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),x.map(t=>jsxRuntime.jsx("th",{style:t.width?{width:t.width}:void 0,className:n("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",t.align==="center"&&"text-center",t.align==="right"&&"text-right",!t.align&&"text-left",t.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:t.sortable?()=>G(t.id):void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,t.sortable&&w?.column===t.id&&jsxRuntime.jsx("span",{className:"text-[10px]",children:w.direction==="asc"?"\u2191":"\u2193"})]})},t.id))]})}),jsxRuntime.jsx("tbody",{children:q?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:x.length+(i?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):L.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:x.length+(i?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:d})}):L.map(t=>{let f=h(t),M=C.has(f);return jsxRuntime.jsxs("tr",{className:n("border-b border-[var(--dash-border)] transition-colors",M?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[i&&jsxRuntime.jsx("td",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:M,onChange:()=>A(f),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),e.map(T=>jsxRuntime.jsx("td",{className:n("px-4 py-2.5",T.align==="center"&&"text-center",T.align==="right"&&"text-right"),children:T.cell?T.cell(t):String(t[T.id]??"")},T.id)),V&&jsxRuntime.jsx("td",{className:"px-4 py-2.5 text-right",children:V(t)})]},f)})})]})}),E>1&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Rows per page"}),jsxRuntime.jsx("select",{value:P,onChange:t=>D?.(Number(t.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(t=>jsxRuntime.jsx("option",{value:t,children:t},t))})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{children:["Page ",u+1," of ",E]}),jsxRuntime.jsx("button",{type:"button",disabled:u===0,onClick:()=>F?.(u-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("button",{type:"button",disabled:u>=E-1,onClick:()=>F?.(u+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}c(Z,"Table");function U({title:e,fields:r,values:h,onSubmit:i,onCancel:m,submitLabel:p="Save",cancelLabel:y="Cancel",loading:b=false,className:o}){let[u,P]=$__namespace.useState(()=>{let d={};for(let l of r)d[l.name]=h?.[l.name]??l.defaultValue??(l.type==="toggle"?false:"");return d}),[F,D]=$__namespace.useState({});function V(d,l){P(a=>({...a,[d]:l})),D(a=>{if(!a[d])return a;let g={...a};return delete g[d],g});}c(V,"setValue");async function q(d){d.preventDefault();let l={};for(let a of r){let g=u[a.name];if(a.required&&(g===""||g===null||g===void 0)&&(l[a.name]=`${a.label} is required`),a.validate){let w=a.validate(g);w&&(l[a.name]=w);}}if(Object.keys(l).length>0){D(l);return}await i(u);}return c(q,"handleSubmit"),jsxRuntime.jsxs("form",{onSubmit:q,className:n("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",o),children:[e&&jsxRuntime.jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsxRuntime.jsx("div",{className:"space-y-4",children:r.map(d=>jsxRuntime.jsx(re,{field:d,value:u[d.name],error:F[d.name],onChange:l=>V(d.name,l)},d.name))}),jsxRuntime.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsxRuntime.jsx("button",{type:"submit",disabled:b,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:b?"Saving...":p}),m&&jsxRuntime.jsx("button",{type:"button",onClick:m,disabled:b,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:y})]})]})}c(U,"Form");var J=n("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function re({field:e,value:r,error:h,onChange:i}){let m=`dash-field-${e.name}`,p=jsxRuntime.jsxs("label",{htmlFor:m,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),y=e.description?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,b=h?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:h}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxRuntime.jsxs("div",{children:[p,jsxRuntime.jsx("input",{id:m,type:e.type,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,onChange:o=>i(e.type==="number"?Number(o.target.value):o.target.value),className:n(J,h&&"border-[var(--dash-error)]")}),y,b]});case "textarea":return jsxRuntime.jsxs("div",{children:[p,jsxRuntime.jsx("textarea",{id:m,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:o=>i(o.target.value),className:n(J,"resize-y",h&&"border-[var(--dash-error)]")}),y,b]});case "select":case "relation":return jsxRuntime.jsxs("div",{children:[p,jsxRuntime.jsxs("select",{id:m,value:String(r??""),disabled:e.disabled,onChange:o=>i(o.target.value),className:n(J,h&&"border-[var(--dash-error)]"),children:[jsxRuntime.jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(o=>jsxRuntime.jsx("option",{value:o.value,children:o.label},o.value))]}),y,b]});case "toggle":return jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{id:m,type:"button",role:"switch","aria-checked":!!r,disabled:e.disabled,onClick:()=>i(!r),className:n("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",r?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsxRuntime.jsx("span",{className:n("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",r?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsxRuntime.jsx("label",{htmlFor:m,className:"text-sm text-[var(--dash-text)]",children:e.label}),y,b]});case "json":return jsxRuntime.jsxs("div",{children:[p,jsxRuntime.jsx("textarea",{id:m,value:typeof r=="string"?r:JSON.stringify(r,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:o=>{try{i(JSON.parse(o.target.value));}catch{i(o.target.value);}},className:n(J,"font-mono text-xs resize-y",h&&"border-[var(--dash-error)]")}),y,b]});case "file":return jsxRuntime.jsxs("div",{children:[p,jsxRuntime.jsx("input",{id:m,type:"file",accept:e.accept,disabled:e.disabled,onChange:o=>{let u=o.target.files?.[0];u&&i(u);},className:n("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),y,b]});default:return null}}c(re,"FieldRenderer");function we({resourceName:e,resourceNamePlural:r,columns:h,data:i,rowKey:m,fields:p,rowToValues:y,onCreate:b,onUpdate:o,onDelete:u,canCreate:P=true,canEdit:F=true,canDelete:D=true,tableProps:V,loading:q=false,className:d}){let l=r??`${e}s`,[a,g]=$__namespace.useState("list"),[w,K]=$__namespace.useState(null),[z,j]=$__namespace.useState({}),[O,E]=$__namespace.useState(null),[L,C]=$__namespace.useState(false);function W(x){let t=m(x);K(t),j(y?y(x):x),g("edit");}c(W,"handleEdit");function _(x){E(m(x));}c(_,"handleDeleteConfirm");async function A(){if(!(!O||!u)){C(true);try{await u(O);}finally{C(false),E(null);}}}c(A,"confirmDelete");function G(x){return jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[F&&o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>W(x),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors",children:"Edit"}),D&&u&&jsxRuntime.jsx("button",{type:"button",onClick:()=>_(x),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-error)] hover:bg-[var(--dash-error-dim)] transition-colors",children:"Delete"})]})}return c(G,"actionsRenderer"),a==="list"?jsxRuntime.jsxs("div",{className:n("space-y-4",d),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold text-[var(--dash-text)]",children:l}),P&&b&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{K(null),j({}),g("create");},className:n("rounded-[var(--dash-radius)] px-3 py-1.5 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]"),children:["Create ",e]})]}),jsxRuntime.jsx(Z,{columns:h,data:i,rowKey:m,actions:F||D?G:void 0,loading:q,searchable:true,emptyMessage:`No ${l.toLowerCase()} found`,...V}),O!==null&&jsxRuntime.jsx(ae,{resourceName:e,loading:L,onConfirm:A,onCancel:()=>E(null)})]}):jsxRuntime.jsxs("div",{className:n("space-y-4",d),children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>g("list"),className:"inline-flex items-center gap-1 text-sm text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:[jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to ",l]}),jsxRuntime.jsx(U,{title:a==="create"?`Create ${e}`:`Edit ${e}`,fields:p,values:a==="edit"?z:void 0,loading:L,submitLabel:a==="create"?"Create":"Save changes",onCancel:()=>g("list"),onSubmit:async x=>{C(true);try{a==="create"&&b?await b(x):a==="edit"&&w&&o&&await o(w,x),g("list");}finally{C(false);}}})]})}c(we,"Crud");function ae({resourceName:e,loading:r,onConfirm:h,onCancel:i}){return jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:jsxRuntime.jsxs("div",{className:"w-full max-w-sm rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6 shadow-lg",children:[jsxRuntime.jsxs("h3",{className:"text-lg font-semibold text-[var(--dash-text)]",children:["Delete ",e,"?"]}),jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-[var(--dash-text-muted)]",children:["This action cannot be undone. The ",e.toLowerCase()," will be permanently removed."]}),jsxRuntime.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:i,disabled:r,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:h,disabled:r,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-error)] text-white","hover:bg-red-600","disabled:opacity-50 disabled:cursor-not-allowed"),children:r?"Deleting...":"Delete"})]})]})})}c(ae,"DeleteDialog");exports.Crud=we;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import*as $ from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';var I=Object.defineProperty;var c=(e,r)=>I(e,"name",{value:r,configurable:true});function n(...e){return twMerge(clsx(e))}c(n,"cn");function Z({columns:e,data:r,rowKey:h,selectable:i=false,selectedKeys:m,onSelectionChange:p,searchable:y=false,searchPlaceholder:b="Search...",totalRows:o,page:u=0,pageSize:P=20,onPageChange:F,onPageSizeChange:D,actions:V,loading:q=false,emptyMessage:d="No data",className:l}){let[a,g]=$.useState(""),[w,K]=$.useState(null),z=$.useMemo(()=>{if(!a)return r;let t=a.toLowerCase();return r.filter(f=>e.some(M=>(M.cell?"":String(f[M.id]??"")).toLowerCase().includes(t)))},[r,a,e]),j=$.useMemo(()=>{if(!w)return z;let{column:t,direction:f}=w;return [...z].sort((M,T)=>{let H=M[t],Q=T[t];if(H==null&&Q==null)return 0;if(H==null)return 1;if(Q==null)return -1;let Y=String(H).localeCompare(String(Q),void 0,{numeric:true});return f==="asc"?Y:-Y})},[z,w]),O=o??j.length,E=Math.max(1,Math.ceil(O/P)),L=F?j:j.slice(u*P,(u+1)*P),C=m??new Set,W=L.length>0&&L.every(t=>C.has(h(t)));function _(){p&&p(W?new Set:new Set(L.map(h)));}c(_,"toggleAll");function A(t){if(!p)return;let f=new Set(C);f.has(t)?f.delete(t):f.add(t),p(f);}c(A,"toggleRow");function G(t){K(f=>f?.column===t?f.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"});}c(G,"handleSort");let x=V?[...e,{id:"__actions",header:"",width:"auto"}]:e;return jsxs("div",{className:n("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",l),children:[(y||i)&&jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[y&&jsx("input",{type:"text",placeholder:b,value:a,onChange:t=>g(t.target.value),className:n("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),i&&C.size>0&&jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[C.size," selected"]})]}),jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:"w-full text-sm",children:[jsx("thead",{children:jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[i&&jsx("th",{className:"w-10 px-4 py-2.5",children:jsx("input",{type:"checkbox",checked:W,onChange:_,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),x.map(t=>jsx("th",{style:t.width?{width:t.width}:void 0,className:n("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",t.align==="center"&&"text-center",t.align==="right"&&"text-right",!t.align&&"text-left",t.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:t.sortable?()=>G(t.id):void 0,children:jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,t.sortable&&w?.column===t.id&&jsx("span",{className:"text-[10px]",children:w.direction==="asc"?"\u2191":"\u2193"})]})},t.id))]})}),jsx("tbody",{children:q?jsx("tr",{children:jsx("td",{colSpan:x.length+(i?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):L.length===0?jsx("tr",{children:jsx("td",{colSpan:x.length+(i?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:d})}):L.map(t=>{let f=h(t),M=C.has(f);return jsxs("tr",{className:n("border-b border-[var(--dash-border)] transition-colors",M?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[i&&jsx("td",{className:"w-10 px-4 py-2.5",children:jsx("input",{type:"checkbox",checked:M,onChange:()=>A(f),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),e.map(T=>jsx("td",{className:n("px-4 py-2.5",T.align==="center"&&"text-center",T.align==="right"&&"text-right"),children:T.cell?T.cell(t):String(t[T.id]??"")},T.id)),V&&jsx("td",{className:"px-4 py-2.5 text-right",children:V(t)})]},f)})})]})}),E>1&&jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{children:"Rows per page"}),jsx("select",{value:P,onChange:t=>D?.(Number(t.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(t=>jsx("option",{value:t,children:t},t))})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{children:["Page ",u+1," of ",E]}),jsx("button",{type:"button",disabled:u===0,onClick:()=>F?.(u-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("button",{type:"button",disabled:u>=E-1,onClick:()=>F?.(u+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}c(Z,"Table");function U({title:e,fields:r,values:h,onSubmit:i,onCancel:m,submitLabel:p="Save",cancelLabel:y="Cancel",loading:b=false,className:o}){let[u,P]=$.useState(()=>{let d={};for(let l of r)d[l.name]=h?.[l.name]??l.defaultValue??(l.type==="toggle"?false:"");return d}),[F,D]=$.useState({});function V(d,l){P(a=>({...a,[d]:l})),D(a=>{if(!a[d])return a;let g={...a};return delete g[d],g});}c(V,"setValue");async function q(d){d.preventDefault();let l={};for(let a of r){let g=u[a.name];if(a.required&&(g===""||g===null||g===void 0)&&(l[a.name]=`${a.label} is required`),a.validate){let w=a.validate(g);w&&(l[a.name]=w);}}if(Object.keys(l).length>0){D(l);return}await i(u);}return c(q,"handleSubmit"),jsxs("form",{onSubmit:q,className:n("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",o),children:[e&&jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsx("div",{className:"space-y-4",children:r.map(d=>jsx(re,{field:d,value:u[d.name],error:F[d.name],onChange:l=>V(d.name,l)},d.name))}),jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsx("button",{type:"submit",disabled:b,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:b?"Saving...":p}),m&&jsx("button",{type:"button",onClick:m,disabled:b,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:y})]})]})}c(U,"Form");var J=n("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function re({field:e,value:r,error:h,onChange:i}){let m=`dash-field-${e.name}`,p=jsxs("label",{htmlFor:m,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),y=e.description?jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,b=h?jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:h}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxs("div",{children:[p,jsx("input",{id:m,type:e.type,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,onChange:o=>i(e.type==="number"?Number(o.target.value):o.target.value),className:n(J,h&&"border-[var(--dash-error)]")}),y,b]});case "textarea":return jsxs("div",{children:[p,jsx("textarea",{id:m,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:o=>i(o.target.value),className:n(J,"resize-y",h&&"border-[var(--dash-error)]")}),y,b]});case "select":case "relation":return jsxs("div",{children:[p,jsxs("select",{id:m,value:String(r??""),disabled:e.disabled,onChange:o=>i(o.target.value),className:n(J,h&&"border-[var(--dash-error)]"),children:[jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(o=>jsx("option",{value:o.value,children:o.label},o.value))]}),y,b]});case "toggle":return jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{id:m,type:"button",role:"switch","aria-checked":!!r,disabled:e.disabled,onClick:()=>i(!r),className:n("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",r?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsx("span",{className:n("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",r?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsx("label",{htmlFor:m,className:"text-sm text-[var(--dash-text)]",children:e.label}),y,b]});case "json":return jsxs("div",{children:[p,jsx("textarea",{id:m,value:typeof r=="string"?r:JSON.stringify(r,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:o=>{try{i(JSON.parse(o.target.value));}catch{i(o.target.value);}},className:n(J,"font-mono text-xs resize-y",h&&"border-[var(--dash-error)]")}),y,b]});case "file":return jsxs("div",{children:[p,jsx("input",{id:m,type:"file",accept:e.accept,disabled:e.disabled,onChange:o=>{let u=o.target.files?.[0];u&&i(u);},className:n("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),y,b]});default:return null}}c(re,"FieldRenderer");function we({resourceName:e,resourceNamePlural:r,columns:h,data:i,rowKey:m,fields:p,rowToValues:y,onCreate:b,onUpdate:o,onDelete:u,canCreate:P=true,canEdit:F=true,canDelete:D=true,tableProps:V,loading:q=false,className:d}){let l=r??`${e}s`,[a,g]=$.useState("list"),[w,K]=$.useState(null),[z,j]=$.useState({}),[O,E]=$.useState(null),[L,C]=$.useState(false);function W(x){let t=m(x);K(t),j(y?y(x):x),g("edit");}c(W,"handleEdit");function _(x){E(m(x));}c(_,"handleDeleteConfirm");async function A(){if(!(!O||!u)){C(true);try{await u(O);}finally{C(false),E(null);}}}c(A,"confirmDelete");function G(x){return jsxs("div",{className:"flex items-center justify-end gap-1",children:[F&&o&&jsx("button",{type:"button",onClick:()=>W(x),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors",children:"Edit"}),D&&u&&jsx("button",{type:"button",onClick:()=>_(x),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-error)] hover:bg-[var(--dash-error-dim)] transition-colors",children:"Delete"})]})}return c(G,"actionsRenderer"),a==="list"?jsxs("div",{className:n("space-y-4",d),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("h2",{className:"text-xl font-semibold text-[var(--dash-text)]",children:l}),P&&b&&jsxs("button",{type:"button",onClick:()=>{K(null),j({}),g("create");},className:n("rounded-[var(--dash-radius)] px-3 py-1.5 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]"),children:["Create ",e]})]}),jsx(Z,{columns:h,data:i,rowKey:m,actions:F||D?G:void 0,loading:q,searchable:true,emptyMessage:`No ${l.toLowerCase()} found`,...V}),O!==null&&jsx(ae,{resourceName:e,loading:L,onConfirm:A,onCancel:()=>E(null)})]}):jsxs("div",{className:n("space-y-4",d),children:[jsxs("button",{type:"button",onClick:()=>g("list"),className:"inline-flex items-center gap-1 text-sm text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to ",l]}),jsx(U,{title:a==="create"?`Create ${e}`:`Edit ${e}`,fields:p,values:a==="edit"?z:void 0,loading:L,submitLabel:a==="create"?"Create":"Save changes",onCancel:()=>g("list"),onSubmit:async x=>{C(true);try{a==="create"&&b?await b(x):a==="edit"&&w&&o&&await o(w,x),g("list");}finally{C(false);}}})]})}c(we,"Crud");function ae({resourceName:e,loading:r,onConfirm:h,onCancel:i}){return jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:jsxs("div",{className:"w-full max-w-sm rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6 shadow-lg",children:[jsxs("h3",{className:"text-lg font-semibold text-[var(--dash-text)]",children:["Delete ",e,"?"]}),jsxs("p",{className:"mt-2 text-sm text-[var(--dash-text-muted)]",children:["This action cannot be undone. The ",e.toLowerCase()," will be permanently removed."]}),jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[jsx("button",{type:"button",onClick:i,disabled:r,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:"Cancel"}),jsx("button",{type:"button",onClick:h,disabled:r,className:n("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-error)] text-white","hover:bg-red-600","disabled:opacity-50 disabled:cursor-not-allowed"),children:r?"Deleting...":"Delete"})]})]})})}c(ae,"DeleteDialog");export{we as Crud};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ 'use strict';var f=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');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 f__namespace=/*#__PURE__*/_interopNamespace(f);var R=Object.defineProperty;var h=(e,a)=>R(e,"name",{value:a,configurable:true});function i(...e){return tailwindMerge.twMerge(clsx.clsx(e))}h(i,"cn");function J({title:e,fields:a,values:m,onSubmit:u,onCancel:l,submitLabel:b="Save",cancelLabel:p="Cancel",loading:d=false,className:r}){let[g,N]=f__namespace.useState(()=>{let s={};for(let o of a)s[o.name]=m?.[o.name]??o.defaultValue??(o.type==="toggle"?false:"");return s}),[k,y]=f__namespace.useState({});function F(s,o){N(n=>({...n,[s]:o})),y(n=>{if(!n[s])return n;let v={...n};return delete v[s],v});}h(F,"setValue");async function S(s){s.preventDefault();let o={};for(let n of a){let v=g[n.name];if(n.required&&(v===""||v===null||v===void 0)&&(o[n.name]=`${n.label} is required`),n.validate){let w=n.validate(v);w&&(o[n.name]=w);}}if(Object.keys(o).length>0){y(o);return}await u(g);}return h(S,"handleSubmit"),jsxRuntime.jsxs("form",{onSubmit:S,className:i("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",r),children:[e&&jsxRuntime.jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsxRuntime.jsx("div",{className:"space-y-4",children:a.map(s=>jsxRuntime.jsx(E,{field:s,value:g[s.name],error:k[s.name],onChange:o=>F(s.name,o)},s.name))}),jsxRuntime.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsxRuntime.jsx("button",{type:"submit",disabled:d,className:i("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:d?"Saving...":b}),l&&jsxRuntime.jsx("button",{type:"button",onClick:l,disabled:d,className:i("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:p})]})]})}h(J,"Form");var x=i("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function E({field:e,value:a,error:m,onChange:u}){let l=`dash-field-${e.name}`,b=jsxRuntime.jsxs("label",{htmlFor:l,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),p=e.description?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,d=m?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:m}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxRuntime.jsxs("div",{children:[b,jsxRuntime.jsx("input",{id:l,type:e.type,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,onChange:r=>u(e.type==="number"?Number(r.target.value):r.target.value),className:i(x,m&&"border-[var(--dash-error)]")}),p,d]});case "textarea":return jsxRuntime.jsxs("div",{children:[b,jsxRuntime.jsx("textarea",{id:l,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:r=>u(r.target.value),className:i(x,"resize-y",m&&"border-[var(--dash-error)]")}),p,d]});case "select":case "relation":return jsxRuntime.jsxs("div",{children:[b,jsxRuntime.jsxs("select",{id:l,value:String(a??""),disabled:e.disabled,onChange:r=>u(r.target.value),className:i(x,m&&"border-[var(--dash-error)]"),children:[jsxRuntime.jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(r=>jsxRuntime.jsx("option",{value:r.value,children:r.label},r.value))]}),p,d]});case "toggle":return jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{id:l,type:"button",role:"switch","aria-checked":!!a,disabled:e.disabled,onClick:()=>u(!a),className:i("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",a?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsxRuntime.jsx("span",{className:i("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",a?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsxRuntime.jsx("label",{htmlFor:l,className:"text-sm text-[var(--dash-text)]",children:e.label}),p,d]});case "json":return jsxRuntime.jsxs("div",{children:[b,jsxRuntime.jsx("textarea",{id:l,value:typeof a=="string"?a:JSON.stringify(a,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:r=>{try{u(JSON.parse(r.target.value));}catch{u(r.target.value);}},className:i(x,"font-mono text-xs resize-y",m&&"border-[var(--dash-error)]")}),p,d]});case "file":return jsxRuntime.jsxs("div",{children:[b,jsxRuntime.jsx("input",{id:l,type:"file",accept:e.accept,disabled:e.disabled,onChange:r=>{let g=r.target.files?.[0];g&&u(g);},className:i("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),p,d]});default:return null}}h(E,"FieldRenderer");exports.Form=J;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import*as f from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';var R=Object.defineProperty;var h=(e,a)=>R(e,"name",{value:a,configurable:true});function i(...e){return twMerge(clsx(e))}h(i,"cn");function J({title:e,fields:a,values:m,onSubmit:u,onCancel:l,submitLabel:b="Save",cancelLabel:p="Cancel",loading:d=false,className:r}){let[g,N]=f.useState(()=>{let s={};for(let o of a)s[o.name]=m?.[o.name]??o.defaultValue??(o.type==="toggle"?false:"");return s}),[k,y]=f.useState({});function F(s,o){N(n=>({...n,[s]:o})),y(n=>{if(!n[s])return n;let v={...n};return delete v[s],v});}h(F,"setValue");async function S(s){s.preventDefault();let o={};for(let n of a){let v=g[n.name];if(n.required&&(v===""||v===null||v===void 0)&&(o[n.name]=`${n.label} is required`),n.validate){let w=n.validate(v);w&&(o[n.name]=w);}}if(Object.keys(o).length>0){y(o);return}await u(g);}return h(S,"handleSubmit"),jsxs("form",{onSubmit:S,className:i("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",r),children:[e&&jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsx("div",{className:"space-y-4",children:a.map(s=>jsx(E,{field:s,value:g[s.name],error:k[s.name],onChange:o=>F(s.name,o)},s.name))}),jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsx("button",{type:"submit",disabled:d,className:i("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:d?"Saving...":b}),l&&jsx("button",{type:"button",onClick:l,disabled:d,className:i("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:p})]})]})}h(J,"Form");var x=i("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function E({field:e,value:a,error:m,onChange:u}){let l=`dash-field-${e.name}`,b=jsxs("label",{htmlFor:l,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),p=e.description?jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,d=m?jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:m}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxs("div",{children:[b,jsx("input",{id:l,type:e.type,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,onChange:r=>u(e.type==="number"?Number(r.target.value):r.target.value),className:i(x,m&&"border-[var(--dash-error)]")}),p,d]});case "textarea":return jsxs("div",{children:[b,jsx("textarea",{id:l,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:r=>u(r.target.value),className:i(x,"resize-y",m&&"border-[var(--dash-error)]")}),p,d]});case "select":case "relation":return jsxs("div",{children:[b,jsxs("select",{id:l,value:String(a??""),disabled:e.disabled,onChange:r=>u(r.target.value),className:i(x,m&&"border-[var(--dash-error)]"),children:[jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(r=>jsx("option",{value:r.value,children:r.label},r.value))]}),p,d]});case "toggle":return jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{id:l,type:"button",role:"switch","aria-checked":!!a,disabled:e.disabled,onClick:()=>u(!a),className:i("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",a?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsx("span",{className:i("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",a?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsx("label",{htmlFor:l,className:"text-sm text-[var(--dash-text)]",children:e.label}),p,d]});case "json":return jsxs("div",{children:[b,jsx("textarea",{id:l,value:typeof a=="string"?a:JSON.stringify(a,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:r=>{try{u(JSON.parse(r.target.value));}catch{u(r.target.value);}},className:i(x,"font-mono text-xs resize-y",m&&"border-[var(--dash-error)]")}),p,d]});case "file":return jsxs("div",{children:[b,jsx("input",{id:l,type:"file",accept:e.accept,disabled:e.disabled,onChange:r=>{let g=r.target.files?.[0];g&&u(g);},className:i("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),p,d]});default:return null}}h(E,"FieldRenderer");export{J as Form};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- 'use strict';var r=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');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 r__namespace=/*#__PURE__*/_interopNamespace(r);var k=Object.defineProperty;var o=(a,n)=>k(a,"name",{value:n,configurable:true});function v(...a){return tailwindMerge.twMerge(clsx.clsx(a))}o(v,"cn");function E({breadcrumbs:a,searchPlaceholder:n="Search...",onSearch:u,avatarUrl:i,userName:l,userDropdown:m,onToggleTheme:p,theme:f="dark",actions:g,className:b}){let[c,x]=r__namespace.useState(false),h=r__namespace.useRef(null);return r__namespace.useEffect(()=>{if(!c)return;function t(d){h.current&&!h.current.contains(d.target)&&x(false);}return o(t,"handleClick"),document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[c]),jsxRuntime.jsxs("div",{className:v("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",b),children:[a&&a.length>0&&jsxRuntime.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:a.map((t,d)=>jsxRuntime.jsxs(r__namespace.Fragment,{children:[d>0&&jsxRuntime.jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),t.href?jsxRuntime.jsx("a",{href:t.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:t.label}):jsxRuntime.jsx("span",{className:"text-[var(--dash-text)]",children:t.label})]},d))}),jsxRuntime.jsx("div",{className:"flex-1"}),u&&jsxRuntime.jsxs("div",{className:"relative hidden sm:block",children:[jsxRuntime.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:n,onChange:t=>u(t.target.value),className:v("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),g,p&&jsxRuntime.jsx("button",{type:"button",onClick:p,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${f==="dark"?"light":"dark"} mode`,children:f==="dark"?jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(i||l)&&jsxRuntime.jsxs("div",{className:"relative",ref:h,children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(t=>!t),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:i?jsxRuntime.jsx("img",{src:i,alt:l??"User",className:"h-7 w-7 rounded-full object-cover"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(l??"?")[0].toUpperCase()})}),c&&m&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:m})]})]})}o(E,"DashHeader");exports.DashHeader=E;
2
+ 'use strict';var r=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');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 r__namespace=/*#__PURE__*/_interopNamespace(r);var k=Object.defineProperty;var o=(a,n)=>k(a,"name",{value:n,configurable:true});function v(...a){return tailwindMerge.twMerge(clsx.clsx(a))}o(v,"cn");function W({breadcrumbs:a,searchPlaceholder:n="Search...",onSearch:u,avatarUrl:i,userName:l,userDropdown:m,onToggleTheme:p,theme:f="dark",actions:g,className:b}){let[c,x]=r__namespace.useState(false),h=r__namespace.useRef(null);return r__namespace.useEffect(()=>{if(!c)return;function t(d){h.current&&!h.current.contains(d.target)&&x(false);}return o(t,"handleClick"),document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[c]),jsxRuntime.jsxs("div",{className:v("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",b),children:[a&&a.length>0&&jsxRuntime.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:a.map((t,d)=>jsxRuntime.jsxs(r__namespace.Fragment,{children:[d>0&&jsxRuntime.jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),t.href?jsxRuntime.jsx("a",{href:t.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:t.label}):jsxRuntime.jsx("span",{className:"text-[var(--dash-text)]",children:t.label})]},d))}),jsxRuntime.jsx("div",{className:"flex-1"}),u&&jsxRuntime.jsxs("div",{className:"relative hidden sm:block",children:[jsxRuntime.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:n,onChange:t=>u(t.target.value),className:v("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),g,p&&jsxRuntime.jsx("button",{type:"button",onClick:p,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${f==="dark"?"light":"dark"} mode`,children:f==="dark"?jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(i||l)&&jsxRuntime.jsxs("div",{className:"relative",ref:h,children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(t=>!t),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:i?jsxRuntime.jsx("img",{src:i,alt:l??"User",className:"h-7 w-7 rounded-full object-cover"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(l??"?")[0].toUpperCase()})}),c&&m&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:m})]})]})}o(W,"Header");exports.Header=W;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import*as r from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';var k=Object.defineProperty;var o=(a,n)=>k(a,"name",{value:n,configurable:true});function v(...a){return twMerge(clsx(a))}o(v,"cn");function E({breadcrumbs:a,searchPlaceholder:n="Search...",onSearch:u,avatarUrl:i,userName:l,userDropdown:m,onToggleTheme:p,theme:f="dark",actions:g,className:b}){let[c,x]=r.useState(false),h=r.useRef(null);return r.useEffect(()=>{if(!c)return;function t(d){h.current&&!h.current.contains(d.target)&&x(false);}return o(t,"handleClick"),document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[c]),jsxs("div",{className:v("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",b),children:[a&&a.length>0&&jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:a.map((t,d)=>jsxs(r.Fragment,{children:[d>0&&jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),t.href?jsx("a",{href:t.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:t.label}):jsx("span",{className:"text-[var(--dash-text)]",children:t.label})]},d))}),jsx("div",{className:"flex-1"}),u&&jsxs("div",{className:"relative hidden sm:block",children:[jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("input",{type:"text",placeholder:n,onChange:t=>u(t.target.value),className:v("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),g,p&&jsx("button",{type:"button",onClick:p,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${f==="dark"?"light":"dark"} mode`,children:f==="dark"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(i||l)&&jsxs("div",{className:"relative",ref:h,children:[jsx("button",{type:"button",onClick:()=>x(t=>!t),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:i?jsx("img",{src:i,alt:l??"User",className:"h-7 w-7 rounded-full object-cover"}):jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(l??"?")[0].toUpperCase()})}),c&&m&&jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:m})]})]})}o(E,"DashHeader");export{E as DashHeader};
2
+ import*as r from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';var k=Object.defineProperty;var o=(a,n)=>k(a,"name",{value:n,configurable:true});function v(...a){return twMerge(clsx(a))}o(v,"cn");function W({breadcrumbs:a,searchPlaceholder:n="Search...",onSearch:u,avatarUrl:i,userName:l,userDropdown:m,onToggleTheme:p,theme:f="dark",actions:g,className:b}){let[c,x]=r.useState(false),h=r.useRef(null);return r.useEffect(()=>{if(!c)return;function t(d){h.current&&!h.current.contains(d.target)&&x(false);}return o(t,"handleClick"),document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[c]),jsxs("div",{className:v("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",b),children:[a&&a.length>0&&jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:a.map((t,d)=>jsxs(r.Fragment,{children:[d>0&&jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),t.href?jsx("a",{href:t.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:t.label}):jsx("span",{className:"text-[var(--dash-text)]",children:t.label})]},d))}),jsx("div",{className:"flex-1"}),u&&jsxs("div",{className:"relative hidden sm:block",children:[jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("input",{type:"text",placeholder:n,onChange:t=>u(t.target.value),className:v("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),g,p&&jsx("button",{type:"button",onClick:p,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${f==="dark"?"light":"dark"} mode`,children:f==="dark"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(i||l)&&jsxs("div",{className:"relative",ref:h,children:[jsx("button",{type:"button",onClick:()=>x(t=>!t),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:i?jsx("img",{src:i,alt:l??"User",className:"h-7 w-7 rounded-full object-cover"}):jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(l??"?")[0].toUpperCase()})}),c&&m&&jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:m})]})]})}o(W,"Header");export{W as Header};
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- 'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),q=require('react');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 q__namespace=/*#__PURE__*/_interopNamespace(q);var ie=Object.defineProperty;var i=(e,a)=>ie(e,"name",{value:a,configurable:true});function r(...e){return tailwindMerge.twMerge(clsx.clsx(e))}i(r,"cn");function ce({sidebar:e,header:a,children:l,sidebarCollapsed:s=false,onSidebarCollapse:n,className:c}){return jsxRuntime.jsxs("div",{className:r("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsxRuntime.jsx("aside",{className:r("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",s?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[a&&jsxRuntime.jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:a}),jsxRuntime.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:l})]}),!s&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>n?.(true)})]})}i(ce,"DashLayout");function ue({size:e=28}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4 4h4v6h8V4h4v16h-4v-6H8v6H4V4z",fill:"currentColor"})})}i(ue,"HanzoMark");function he({logo:e,groups:a,userMenu:l,collapsed:s=false,onToggleCollapse:n,onNavigate:c,className:o}){return jsxRuntime.jsxs("nav",{className:r("flex h-full flex-col","bg-[var(--dash-surface)] text-[var(--dash-text)]",o),children:[jsxRuntime.jsxs("div",{className:r("flex h-[var(--dash-header-height)] items-center border-b border-[var(--dash-border)]",s?"justify-center px-2":"px-4"),children:[e??jsxRuntime.jsx(ue,{}),!s&&n&&jsxRuntime.jsx("button",{type:"button",onClick:n,className:"ml-auto rounded p-1 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]","aria-label":"Collapse sidebar",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),s&&n&&jsxRuntime.jsx("button",{type:"button",onClick:n,className:"absolute -right-3 top-4 z-50 hidden rounded-full border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 text-[var(--dash-text-dim)] hover:text-[var(--dash-text)] lg:flex","aria-label":"Expand sidebar",children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:a.map((m,d)=>jsxRuntime.jsx(me,{group:m,collapsed:s,onNavigate:c},d))}),l&&jsxRuntime.jsx("div",{className:"border-t border-[var(--dash-border)] p-2",children:l})]})}i(he,"DashSidebar");function me({group:e,collapsed:a,onNavigate:l}){let[s,n]=q__namespace.useState(e.defaultOpen!==false),c=e.collapsible!==false&&!!e.title;return jsxRuntime.jsxs("div",{className:"mb-1",children:[e.title&&!a&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>c&&n(o=>!o),className:r("flex w-full items-center px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-[var(--dash-text-dim)]",c&&"cursor-pointer hover:text-[var(--dash-text-muted)]"),children:[jsxRuntime.jsx("span",{className:"flex-1 text-left",children:e.title}),c&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",className:r("transition-transform",s?"rotate-0":"-rotate-90"),children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(s||a)&&jsxRuntime.jsx("ul",{className:"space-y-0.5 px-2",children:e.items.map(o=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>l?.(o.href),title:a?o.label:void 0,className:r("flex w-full items-center gap-2 rounded-[var(--dash-radius-sm)] px-2 py-1.5 text-sm transition-colors",o.active?"bg-[var(--dash-primary)] text-[var(--dash-primary-text)]":"text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]",a&&"justify-center px-0"),children:[o.icon&&jsxRuntime.jsx("span",{className:"flex h-5 w-5 items-center justify-center flex-shrink-0",children:o.icon}),!a&&jsxRuntime.jsx("span",{className:"flex-1 truncate text-left",children:o.label}),!a&&o.badge!==void 0&&jsxRuntime.jsx("span",{className:"ml-auto rounded-full bg-[var(--dash-primary)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--dash-primary-text)]",children:o.badge})]})},o.href))})]})}i(me,"SidebarGroup");function ve({breadcrumbs:e,searchPlaceholder:a="Search...",onSearch:l,avatarUrl:s,userName:n,userDropdown:c,onToggleTheme:o,theme:m="dark",actions:d,className:v}){let[D,C]=q__namespace.useState(false),R=q__namespace.useRef(null);return q__namespace.useEffect(()=>{if(!D)return;function b(P){R.current&&!R.current.contains(P.target)&&C(false);}return i(b,"handleClick"),document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[D]),jsxRuntime.jsxs("div",{className:r("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",v),children:[e&&e.length>0&&jsxRuntime.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:e.map((b,P)=>jsxRuntime.jsxs(q__namespace.Fragment,{children:[P>0&&jsxRuntime.jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),b.href?jsxRuntime.jsx("a",{href:b.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:b.label}):jsxRuntime.jsx("span",{className:"text-[var(--dash-text)]",children:b.label})]},P))}),jsxRuntime.jsx("div",{className:"flex-1"}),l&&jsxRuntime.jsxs("div",{className:"relative hidden sm:block",children:[jsxRuntime.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:a,onChange:b=>l(b.target.value),className:r("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),d,o&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${m==="dark"?"light":"dark"} mode`,children:m==="dark"?jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(s||n)&&jsxRuntime.jsxs("div",{className:"relative",ref:R,children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>C(b=>!b),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:s?jsxRuntime.jsx("img",{src:s,alt:n??"User",className:"h-7 w-7 rounded-full object-cover"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(n??"?")[0].toUpperCase()})}),D&&c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:c})]})]})}i(ve,"DashHeader");function te({columns:e,data:a,rowKey:l,selectable:s=false,selectedKeys:n,onSelectionChange:c,searchable:o=false,searchPlaceholder:m="Search...",totalRows:d,page:v=0,pageSize:D=20,onPageChange:C,onPageSizeChange:R,actions:b,loading:P=false,emptyMessage:f="No data",className:x}){let[u,w]=q__namespace.useState(""),[S,A]=q__namespace.useState(null),G=q__namespace.useMemo(()=>{if(!u)return a;let t=u.toLowerCase();return a.filter(k=>e.some(O=>(O.cell?"":String(k[O.id]??"")).toLowerCase().includes(t)))},[a,u,e]),W=q__namespace.useMemo(()=>{if(!S)return G;let{column:t,direction:k}=S;return [...G].sort((O,E)=>{let Z=O[t],ee=E[t];if(Z==null&&ee==null)return 0;if(Z==null)return 1;if(ee==null)return -1;let se=String(Z).localeCompare(String(ee),void 0,{numeric:true});return k==="asc"?se:-se})},[G,S]),I=d??W.length,z=Math.max(1,Math.ceil(I/D)),j=C?W:W.slice(v*D,(v+1)*D),M=n??new Set,J=j.length>0&&j.every(t=>M.has(l(t)));function U(){c&&c(J?new Set:new Set(j.map(l)));}i(U,"toggleAll");function X(t){if(!c)return;let k=new Set(M);k.has(t)?k.delete(t):k.add(t),c(k);}i(X,"toggleRow");function Y(t){A(k=>k?.column===t?k.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"});}i(Y,"handleSort");let N=b?[...e,{id:"__actions",header:"",width:"auto"}]:e;return jsxRuntime.jsxs("div",{className:r("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",x),children:[(o||s)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[o&&jsxRuntime.jsx("input",{type:"text",placeholder:m,value:u,onChange:t=>w(t.target.value),className:r("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),s&&M.size>0&&jsxRuntime.jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[M.size," selected"]})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[s&&jsxRuntime.jsx("th",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:J,onChange:U,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),N.map(t=>jsxRuntime.jsx("th",{style:t.width?{width:t.width}:void 0,className:r("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",t.align==="center"&&"text-center",t.align==="right"&&"text-right",!t.align&&"text-left",t.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:t.sortable?()=>Y(t.id):void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,t.sortable&&S?.column===t.id&&jsxRuntime.jsx("span",{className:"text-[10px]",children:S.direction==="asc"?"\u2191":"\u2193"})]})},t.id))]})}),jsxRuntime.jsx("tbody",{children:P?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):j.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:f})}):j.map(t=>{let k=l(t),O=M.has(k);return jsxRuntime.jsxs("tr",{className:r("border-b border-[var(--dash-border)] transition-colors",O?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[s&&jsxRuntime.jsx("td",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:O,onChange:()=>X(k),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),e.map(E=>jsxRuntime.jsx("td",{className:r("px-4 py-2.5",E.align==="center"&&"text-center",E.align==="right"&&"text-right"),children:E.cell?E.cell(t):String(t[E.id]??"")},E.id)),b&&jsxRuntime.jsx("td",{className:"px-4 py-2.5 text-right",children:b(t)})]},k)})})]})}),z>1&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Rows per page"}),jsxRuntime.jsx("select",{value:D,onChange:t=>R?.(Number(t.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(t=>jsxRuntime.jsx("option",{value:t,children:t},t))})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{children:["Page ",v+1," of ",z]}),jsxRuntime.jsx("button",{type:"button",disabled:v===0,onClick:()=>C?.(v-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("button",{type:"button",disabled:v>=z-1,onClick:()=>C?.(v+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}i(te,"DashDataTable");function re({title:e,fields:a,values:l,onSubmit:s,onCancel:n,submitLabel:c="Save",cancelLabel:o="Cancel",loading:m=false,className:d}){let[v,D]=q__namespace.useState(()=>{let f={};for(let x of a)f[x.name]=l?.[x.name]??x.defaultValue??(x.type==="toggle"?false:"");return f}),[C,R]=q__namespace.useState({});function b(f,x){D(u=>({...u,[f]:x})),R(u=>{if(!u[f])return u;let w={...u};return delete w[f],w});}i(b,"setValue");async function P(f){f.preventDefault();let x={};for(let u of a){let w=v[u.name];if(u.required&&(w===""||w===null||w===void 0)&&(x[u.name]=`${u.label} is required`),u.validate){let S=u.validate(w);S&&(x[u.name]=S);}}if(Object.keys(x).length>0){R(x);return}await s(v);}return i(P,"handleSubmit"),jsxRuntime.jsxs("form",{onSubmit:P,className:r("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",d),children:[e&&jsxRuntime.jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsxRuntime.jsx("div",{className:"space-y-4",children:a.map(f=>jsxRuntime.jsx(pe,{field:f,value:v[f.name],error:C[f.name],onChange:x=>b(f.name,x)},f.name))}),jsxRuntime.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsxRuntime.jsx("button",{type:"submit",disabled:m,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Saving...":c}),n&&jsxRuntime.jsx("button",{type:"button",onClick:n,disabled:m,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:o})]})]})}i(re,"DashForm");var Q=r("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function pe({field:e,value:a,error:l,onChange:s}){let n=`dash-field-${e.name}`,c=jsxRuntime.jsxs("label",{htmlFor:n,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),o=e.description?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,m=l?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:l}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("input",{id:n,type:e.type,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,onChange:d=>s(e.type==="number"?Number(d.target.value):d.target.value),className:r(Q,l&&"border-[var(--dash-error)]")}),o,m]});case "textarea":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("textarea",{id:n,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:d=>s(d.target.value),className:r(Q,"resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "select":case "relation":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsxs("select",{id:n,value:String(a??""),disabled:e.disabled,onChange:d=>s(d.target.value),className:r(Q,l&&"border-[var(--dash-error)]"),children:[jsxRuntime.jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(d=>jsxRuntime.jsx("option",{value:d.value,children:d.label},d.value))]}),o,m]});case "toggle":return jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{id:n,type:"button",role:"switch","aria-checked":!!a,disabled:e.disabled,onClick:()=>s(!a),className:r("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",a?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsxRuntime.jsx("span",{className:r("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",a?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsxRuntime.jsx("label",{htmlFor:n,className:"text-sm text-[var(--dash-text)]",children:e.label}),o,m]});case "json":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("textarea",{id:n,value:typeof a=="string"?a:JSON.stringify(a,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:d=>{try{s(JSON.parse(d.target.value));}catch{s(d.target.value);}},className:r(Q,"font-mono text-xs resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "file":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("input",{id:n,type:"file",accept:e.accept,disabled:e.disabled,onChange:d=>{let v=d.target.files?.[0];v&&s(v);},className:r("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),o,m]});default:return null}}i(pe,"FieldRenderer");function be({resourceName:e,resourceNamePlural:a,columns:l,data:s,rowKey:n,fields:c,rowToValues:o,onCreate:m,onUpdate:d,onDelete:v,canCreate:D=true,canEdit:C=true,canDelete:R=true,tableProps:b,loading:P=false,className:f}){let x=a??`${e}s`,[u,w]=q__namespace.useState("list"),[S,A]=q__namespace.useState(null),[G,W]=q__namespace.useState({}),[I,z]=q__namespace.useState(null),[j,M]=q__namespace.useState(false);function J(N){let t=n(N);A(t),W(o?o(N):N),w("edit");}i(J,"handleEdit");function U(N){z(n(N));}i(U,"handleDeleteConfirm");async function X(){if(!(!I||!v)){M(true);try{await v(I);}finally{M(false),z(null);}}}i(X,"confirmDelete");function Y(N){return jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[C&&d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>J(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors",children:"Edit"}),R&&v&&jsxRuntime.jsx("button",{type:"button",onClick:()=>U(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-error)] hover:bg-[var(--dash-error-dim)] transition-colors",children:"Delete"})]})}return i(Y,"actionsRenderer"),u==="list"?jsxRuntime.jsxs("div",{className:r("space-y-4",f),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold text-[var(--dash-text)]",children:x}),D&&m&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{A(null),W({}),w("create");},className:r("rounded-[var(--dash-radius)] px-3 py-1.5 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]"),children:["Create ",e]})]}),jsxRuntime.jsx(te,{columns:l,data:s,rowKey:n,actions:C||R?Y:void 0,loading:P,searchable:true,emptyMessage:`No ${x.toLowerCase()} found`,...b}),I!==null&&jsxRuntime.jsx(fe,{resourceName:e,loading:j,onConfirm:X,onCancel:()=>z(null)})]}):jsxRuntime.jsxs("div",{className:r("space-y-4",f),children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>w("list"),className:"inline-flex items-center gap-1 text-sm text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:[jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to ",x]}),jsxRuntime.jsx(re,{title:u==="create"?`Create ${e}`:`Edit ${e}`,fields:c,values:u==="edit"?G:void 0,loading:j,submitLabel:u==="create"?"Create":"Save changes",onCancel:()=>w("list"),onSubmit:async N=>{M(true);try{u==="create"&&m?await m(N):u==="edit"&&S&&d&&await d(S,N),w("list");}finally{M(false);}}})]})}i(be,"DashCrud");function fe({resourceName:e,loading:a,onConfirm:l,onCancel:s}){return jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:jsxRuntime.jsxs("div",{className:"w-full max-w-sm rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6 shadow-lg",children:[jsxRuntime.jsxs("h3",{className:"text-lg font-semibold text-[var(--dash-text)]",children:["Delete ",e,"?"]}),jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-[var(--dash-text-muted)]",children:["This action cannot be undone. The ",e.toLowerCase()," will be permanently removed."]}),jsxRuntime.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:s,disabled:a,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:l,disabled:a,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-error)] text-white","hover:bg-red-600","disabled:opacity-50 disabled:cursor-not-allowed"),children:a?"Deleting...":"Delete"})]})]})})}i(fe,"DeleteDialog");
3
- exports.DashCrud=be;exports.DashDataTable=te;exports.DashForm=re;exports.DashHeader=ve;exports.DashLayout=ce;exports.DashSidebar=he;
2
+ 'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),q=require('react');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 q__namespace=/*#__PURE__*/_interopNamespace(q);var ie=Object.defineProperty;var i=(e,r)=>ie(e,"name",{value:r,configurable:true});function a(...e){return tailwindMerge.twMerge(clsx.clsx(e))}i(a,"cn");function ce({sidebar:e,header:r,children:l,sidebarCollapsed:s=false,onSidebarCollapse:n,className:c}){return jsxRuntime.jsxs("div",{className:a("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsxRuntime.jsx("aside",{className:a("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",s?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[r&&jsxRuntime.jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:r}),jsxRuntime.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:l})]}),!s&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>n?.(true)})]})}i(ce,"Layout");function ue({size:e=28}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4 4h4v6h8V4h4v16h-4v-6H8v6H4V4z",fill:"currentColor"})})}i(ue,"HanzoMark");function he({logo:e,groups:r,userMenu:l,collapsed:s=false,onToggleCollapse:n,onNavigate:c,className:o}){return jsxRuntime.jsxs("nav",{className:a("flex h-full flex-col","bg-[var(--dash-surface)] text-[var(--dash-text)]",o),children:[jsxRuntime.jsxs("div",{className:a("flex h-[var(--dash-header-height)] items-center border-b border-[var(--dash-border)]",s?"justify-center px-2":"px-4"),children:[e??jsxRuntime.jsx(ue,{}),!s&&n&&jsxRuntime.jsx("button",{type:"button",onClick:n,className:"ml-auto rounded p-1 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]","aria-label":"Collapse sidebar",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),s&&n&&jsxRuntime.jsx("button",{type:"button",onClick:n,className:"absolute -right-3 top-4 z-50 hidden rounded-full border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 text-[var(--dash-text-dim)] hover:text-[var(--dash-text)] lg:flex","aria-label":"Expand sidebar",children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:r.map((m,d)=>jsxRuntime.jsx(me,{group:m,collapsed:s,onNavigate:c},d))}),l&&jsxRuntime.jsx("div",{className:"border-t border-[var(--dash-border)] p-2",children:l})]})}i(he,"Sidebar");function me({group:e,collapsed:r,onNavigate:l}){let[s,n]=q__namespace.useState(e.defaultOpen!==false),c=e.collapsible!==false&&!!e.title;return jsxRuntime.jsxs("div",{className:"mb-1",children:[e.title&&!r&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>c&&n(o=>!o),className:a("flex w-full items-center px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-[var(--dash-text-dim)]",c&&"cursor-pointer hover:text-[var(--dash-text-muted)]"),children:[jsxRuntime.jsx("span",{className:"flex-1 text-left",children:e.title}),c&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",className:a("transition-transform",s?"rotate-0":"-rotate-90"),children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(s||r)&&jsxRuntime.jsx("ul",{className:"space-y-0.5 px-2",children:e.items.map(o=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>l?.(o.href),title:r?o.label:void 0,className:a("flex w-full items-center gap-2 rounded-[var(--dash-radius-sm)] px-2 py-1.5 text-sm transition-colors",o.active?"bg-[var(--dash-primary)] text-[var(--dash-primary-text)]":"text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]",r&&"justify-center px-0"),children:[o.icon&&jsxRuntime.jsx("span",{className:"flex h-5 w-5 items-center justify-center flex-shrink-0",children:o.icon}),!r&&jsxRuntime.jsx("span",{className:"flex-1 truncate text-left",children:o.label}),!r&&o.badge!==void 0&&jsxRuntime.jsx("span",{className:"ml-auto rounded-full bg-[var(--dash-primary)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--dash-primary-text)]",children:o.badge})]})},o.href))})]})}i(me,"SidebarGroup");function ve({breadcrumbs:e,searchPlaceholder:r="Search...",onSearch:l,avatarUrl:s,userName:n,userDropdown:c,onToggleTheme:o,theme:m="dark",actions:d,className:v}){let[C,R]=q__namespace.useState(false),S=q__namespace.useRef(null);return q__namespace.useEffect(()=>{if(!C)return;function b(M){S.current&&!S.current.contains(M.target)&&R(false);}return i(b,"handleClick"),document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[C]),jsxRuntime.jsxs("div",{className:a("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",v),children:[e&&e.length>0&&jsxRuntime.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:e.map((b,M)=>jsxRuntime.jsxs(q__namespace.Fragment,{children:[M>0&&jsxRuntime.jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),b.href?jsxRuntime.jsx("a",{href:b.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:b.label}):jsxRuntime.jsx("span",{className:"text-[var(--dash-text)]",children:b.label})]},M))}),jsxRuntime.jsx("div",{className:"flex-1"}),l&&jsxRuntime.jsxs("div",{className:"relative hidden sm:block",children:[jsxRuntime.jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsxRuntime.jsx("input",{type:"text",placeholder:r,onChange:b=>l(b.target.value),className:a("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),d,o&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${m==="dark"?"light":"dark"} mode`,children:m==="dark"?jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(s||n)&&jsxRuntime.jsxs("div",{className:"relative",ref:S,children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>R(b=>!b),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:s?jsxRuntime.jsx("img",{src:s,alt:n??"User",className:"h-7 w-7 rounded-full object-cover"}):jsxRuntime.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(n??"?")[0].toUpperCase()})}),C&&c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:c})]})]})}i(ve,"Header");function te({columns:e,data:r,rowKey:l,selectable:s=false,selectedKeys:n,onSelectionChange:c,searchable:o=false,searchPlaceholder:m="Search...",totalRows:d,page:v=0,pageSize:C=20,onPageChange:R,onPageSizeChange:S,actions:b,loading:M=false,emptyMessage:f="No data",className:x}){let[u,w]=q__namespace.useState(""),[L,A]=q__namespace.useState(null),G=q__namespace.useMemo(()=>{if(!u)return r;let t=u.toLowerCase();return r.filter(k=>e.some(O=>(O.cell?"":String(k[O.id]??"")).toLowerCase().includes(t)))},[r,u,e]),W=q__namespace.useMemo(()=>{if(!L)return G;let{column:t,direction:k}=L;return [...G].sort((O,E)=>{let Z=O[t],ee=E[t];if(Z==null&&ee==null)return 0;if(Z==null)return 1;if(ee==null)return -1;let se=String(Z).localeCompare(String(ee),void 0,{numeric:true});return k==="asc"?se:-se})},[G,L]),I=d??W.length,z=Math.max(1,Math.ceil(I/C)),j=R?W:W.slice(v*C,(v+1)*C),F=n??new Set,J=j.length>0&&j.every(t=>F.has(l(t)));function U(){c&&c(J?new Set:new Set(j.map(l)));}i(U,"toggleAll");function X(t){if(!c)return;let k=new Set(F);k.has(t)?k.delete(t):k.add(t),c(k);}i(X,"toggleRow");function Y(t){A(k=>k?.column===t?k.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"});}i(Y,"handleSort");let N=b?[...e,{id:"__actions",header:"",width:"auto"}]:e;return jsxRuntime.jsxs("div",{className:a("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",x),children:[(o||s)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[o&&jsxRuntime.jsx("input",{type:"text",placeholder:m,value:u,onChange:t=>w(t.target.value),className:a("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),s&&F.size>0&&jsxRuntime.jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[F.size," selected"]})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[s&&jsxRuntime.jsx("th",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:J,onChange:U,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),N.map(t=>jsxRuntime.jsx("th",{style:t.width?{width:t.width}:void 0,className:a("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",t.align==="center"&&"text-center",t.align==="right"&&"text-right",!t.align&&"text-left",t.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:t.sortable?()=>Y(t.id):void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,t.sortable&&L?.column===t.id&&jsxRuntime.jsx("span",{className:"text-[10px]",children:L.direction==="asc"?"\u2191":"\u2193"})]})},t.id))]})}),jsxRuntime.jsx("tbody",{children:M?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):j.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:f})}):j.map(t=>{let k=l(t),O=F.has(k);return jsxRuntime.jsxs("tr",{className:a("border-b border-[var(--dash-border)] transition-colors",O?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[s&&jsxRuntime.jsx("td",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:O,onChange:()=>X(k),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),e.map(E=>jsxRuntime.jsx("td",{className:a("px-4 py-2.5",E.align==="center"&&"text-center",E.align==="right"&&"text-right"),children:E.cell?E.cell(t):String(t[E.id]??"")},E.id)),b&&jsxRuntime.jsx("td",{className:"px-4 py-2.5 text-right",children:b(t)})]},k)})})]})}),z>1&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Rows per page"}),jsxRuntime.jsx("select",{value:C,onChange:t=>S?.(Number(t.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(t=>jsxRuntime.jsx("option",{value:t,children:t},t))})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{children:["Page ",v+1," of ",z]}),jsxRuntime.jsx("button",{type:"button",disabled:v===0,onClick:()=>R?.(v-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("button",{type:"button",disabled:v>=z-1,onClick:()=>R?.(v+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}i(te,"Table");function ae({title:e,fields:r,values:l,onSubmit:s,onCancel:n,submitLabel:c="Save",cancelLabel:o="Cancel",loading:m=false,className:d}){let[v,C]=q__namespace.useState(()=>{let f={};for(let x of r)f[x.name]=l?.[x.name]??x.defaultValue??(x.type==="toggle"?false:"");return f}),[R,S]=q__namespace.useState({});function b(f,x){C(u=>({...u,[f]:x})),S(u=>{if(!u[f])return u;let w={...u};return delete w[f],w});}i(b,"setValue");async function M(f){f.preventDefault();let x={};for(let u of r){let w=v[u.name];if(u.required&&(w===""||w===null||w===void 0)&&(x[u.name]=`${u.label} is required`),u.validate){let L=u.validate(w);L&&(x[u.name]=L);}}if(Object.keys(x).length>0){S(x);return}await s(v);}return i(M,"handleSubmit"),jsxRuntime.jsxs("form",{onSubmit:M,className:a("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",d),children:[e&&jsxRuntime.jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsxRuntime.jsx("div",{className:"space-y-4",children:r.map(f=>jsxRuntime.jsx(pe,{field:f,value:v[f.name],error:R[f.name],onChange:x=>b(f.name,x)},f.name))}),jsxRuntime.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsxRuntime.jsx("button",{type:"submit",disabled:m,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Saving...":c}),n&&jsxRuntime.jsx("button",{type:"button",onClick:n,disabled:m,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:o})]})]})}i(ae,"Form");var Q=a("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function pe({field:e,value:r,error:l,onChange:s}){let n=`dash-field-${e.name}`,c=jsxRuntime.jsxs("label",{htmlFor:n,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),o=e.description?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,m=l?jsxRuntime.jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:l}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("input",{id:n,type:e.type,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,onChange:d=>s(e.type==="number"?Number(d.target.value):d.target.value),className:a(Q,l&&"border-[var(--dash-error)]")}),o,m]});case "textarea":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("textarea",{id:n,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:d=>s(d.target.value),className:a(Q,"resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "select":case "relation":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsxs("select",{id:n,value:String(r??""),disabled:e.disabled,onChange:d=>s(d.target.value),className:a(Q,l&&"border-[var(--dash-error)]"),children:[jsxRuntime.jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(d=>jsxRuntime.jsx("option",{value:d.value,children:d.label},d.value))]}),o,m]});case "toggle":return jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("button",{id:n,type:"button",role:"switch","aria-checked":!!r,disabled:e.disabled,onClick:()=>s(!r),className:a("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",r?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsxRuntime.jsx("span",{className:a("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",r?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsxRuntime.jsx("label",{htmlFor:n,className:"text-sm text-[var(--dash-text)]",children:e.label}),o,m]});case "json":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("textarea",{id:n,value:typeof r=="string"?r:JSON.stringify(r,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:d=>{try{s(JSON.parse(d.target.value));}catch{s(d.target.value);}},className:a(Q,"font-mono text-xs resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "file":return jsxRuntime.jsxs("div",{children:[c,jsxRuntime.jsx("input",{id:n,type:"file",accept:e.accept,disabled:e.disabled,onChange:d=>{let v=d.target.files?.[0];v&&s(v);},className:a("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),o,m]});default:return null}}i(pe,"FieldRenderer");function be({resourceName:e,resourceNamePlural:r,columns:l,data:s,rowKey:n,fields:c,rowToValues:o,onCreate:m,onUpdate:d,onDelete:v,canCreate:C=true,canEdit:R=true,canDelete:S=true,tableProps:b,loading:M=false,className:f}){let x=r??`${e}s`,[u,w]=q__namespace.useState("list"),[L,A]=q__namespace.useState(null),[G,W]=q__namespace.useState({}),[I,z]=q__namespace.useState(null),[j,F]=q__namespace.useState(false);function J(N){let t=n(N);A(t),W(o?o(N):N),w("edit");}i(J,"handleEdit");function U(N){z(n(N));}i(U,"handleDeleteConfirm");async function X(){if(!(!I||!v)){F(true);try{await v(I);}finally{F(false),z(null);}}}i(X,"confirmDelete");function Y(N){return jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[R&&d&&jsxRuntime.jsx("button",{type:"button",onClick:()=>J(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors",children:"Edit"}),S&&v&&jsxRuntime.jsx("button",{type:"button",onClick:()=>U(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-error)] hover:bg-[var(--dash-error-dim)] transition-colors",children:"Delete"})]})}return i(Y,"actionsRenderer"),u==="list"?jsxRuntime.jsxs("div",{className:a("space-y-4",f),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold text-[var(--dash-text)]",children:x}),C&&m&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{A(null),W({}),w("create");},className:a("rounded-[var(--dash-radius)] px-3 py-1.5 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]"),children:["Create ",e]})]}),jsxRuntime.jsx(te,{columns:l,data:s,rowKey:n,actions:R||S?Y:void 0,loading:M,searchable:true,emptyMessage:`No ${x.toLowerCase()} found`,...b}),I!==null&&jsxRuntime.jsx(fe,{resourceName:e,loading:j,onConfirm:X,onCancel:()=>z(null)})]}):jsxRuntime.jsxs("div",{className:a("space-y-4",f),children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>w("list"),className:"inline-flex items-center gap-1 text-sm text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:[jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to ",x]}),jsxRuntime.jsx(ae,{title:u==="create"?`Create ${e}`:`Edit ${e}`,fields:c,values:u==="edit"?G:void 0,loading:j,submitLabel:u==="create"?"Create":"Save changes",onCancel:()=>w("list"),onSubmit:async N=>{F(true);try{u==="create"&&m?await m(N):u==="edit"&&L&&d&&await d(L,N),w("list");}finally{F(false);}}})]})}i(be,"Crud");function fe({resourceName:e,loading:r,onConfirm:l,onCancel:s}){return jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:jsxRuntime.jsxs("div",{className:"w-full max-w-sm rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6 shadow-lg",children:[jsxRuntime.jsxs("h3",{className:"text-lg font-semibold text-[var(--dash-text)]",children:["Delete ",e,"?"]}),jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-[var(--dash-text-muted)]",children:["This action cannot be undone. The ",e.toLowerCase()," will be permanently removed."]}),jsxRuntime.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:s,disabled:r,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:l,disabled:r,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-error)] text-white","hover:bg-red-600","disabled:opacity-50 disabled:cursor-not-allowed"),children:r?"Deleting...":"Delete"})]})]})})}i(fe,"DeleteDialog");
3
+ exports.Crud=be;exports.Form=ae;exports.Header=ve;exports.Layout=ce;exports.Sidebar=he;exports.Table=te;
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';import*as q from'react';var ie=Object.defineProperty;var i=(e,a)=>ie(e,"name",{value:a,configurable:true});function r(...e){return twMerge(clsx(e))}i(r,"cn");function ce({sidebar:e,header:a,children:l,sidebarCollapsed:s=false,onSidebarCollapse:n,className:c}){return jsxs("div",{className:r("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsx("aside",{className:r("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",s?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[a&&jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:a}),jsx("main",{className:"flex-1 overflow-y-auto p-6",children:l})]}),!s&&jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>n?.(true)})]})}i(ce,"DashLayout");function ue({size:e=28}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4 4h4v6h8V4h4v16h-4v-6H8v6H4V4z",fill:"currentColor"})})}i(ue,"HanzoMark");function he({logo:e,groups:a,userMenu:l,collapsed:s=false,onToggleCollapse:n,onNavigate:c,className:o}){return jsxs("nav",{className:r("flex h-full flex-col","bg-[var(--dash-surface)] text-[var(--dash-text)]",o),children:[jsxs("div",{className:r("flex h-[var(--dash-header-height)] items-center border-b border-[var(--dash-border)]",s?"justify-center px-2":"px-4"),children:[e??jsx(ue,{}),!s&&n&&jsx("button",{type:"button",onClick:n,className:"ml-auto rounded p-1 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]","aria-label":"Collapse sidebar",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),s&&n&&jsx("button",{type:"button",onClick:n,className:"absolute -right-3 top-4 z-50 hidden rounded-full border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 text-[var(--dash-text-dim)] hover:text-[var(--dash-text)] lg:flex","aria-label":"Expand sidebar",children:jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto py-2",children:a.map((m,d)=>jsx(me,{group:m,collapsed:s,onNavigate:c},d))}),l&&jsx("div",{className:"border-t border-[var(--dash-border)] p-2",children:l})]})}i(he,"DashSidebar");function me({group:e,collapsed:a,onNavigate:l}){let[s,n]=q.useState(e.defaultOpen!==false),c=e.collapsible!==false&&!!e.title;return jsxs("div",{className:"mb-1",children:[e.title&&!a&&jsxs("button",{type:"button",onClick:()=>c&&n(o=>!o),className:r("flex w-full items-center px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-[var(--dash-text-dim)]",c&&"cursor-pointer hover:text-[var(--dash-text-muted)]"),children:[jsx("span",{className:"flex-1 text-left",children:e.title}),c&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",className:r("transition-transform",s?"rotate-0":"-rotate-90"),children:jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(s||a)&&jsx("ul",{className:"space-y-0.5 px-2",children:e.items.map(o=>jsx("li",{children:jsxs("button",{type:"button",onClick:()=>l?.(o.href),title:a?o.label:void 0,className:r("flex w-full items-center gap-2 rounded-[var(--dash-radius-sm)] px-2 py-1.5 text-sm transition-colors",o.active?"bg-[var(--dash-primary)] text-[var(--dash-primary-text)]":"text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]",a&&"justify-center px-0"),children:[o.icon&&jsx("span",{className:"flex h-5 w-5 items-center justify-center flex-shrink-0",children:o.icon}),!a&&jsx("span",{className:"flex-1 truncate text-left",children:o.label}),!a&&o.badge!==void 0&&jsx("span",{className:"ml-auto rounded-full bg-[var(--dash-primary)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--dash-primary-text)]",children:o.badge})]})},o.href))})]})}i(me,"SidebarGroup");function ve({breadcrumbs:e,searchPlaceholder:a="Search...",onSearch:l,avatarUrl:s,userName:n,userDropdown:c,onToggleTheme:o,theme:m="dark",actions:d,className:v}){let[D,C]=q.useState(false),R=q.useRef(null);return q.useEffect(()=>{if(!D)return;function b(P){R.current&&!R.current.contains(P.target)&&C(false);}return i(b,"handleClick"),document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[D]),jsxs("div",{className:r("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",v),children:[e&&e.length>0&&jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:e.map((b,P)=>jsxs(q.Fragment,{children:[P>0&&jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),b.href?jsx("a",{href:b.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:b.label}):jsx("span",{className:"text-[var(--dash-text)]",children:b.label})]},P))}),jsx("div",{className:"flex-1"}),l&&jsxs("div",{className:"relative hidden sm:block",children:[jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("input",{type:"text",placeholder:a,onChange:b=>l(b.target.value),className:r("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),d,o&&jsx("button",{type:"button",onClick:o,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${m==="dark"?"light":"dark"} mode`,children:m==="dark"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(s||n)&&jsxs("div",{className:"relative",ref:R,children:[jsx("button",{type:"button",onClick:()=>C(b=>!b),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:s?jsx("img",{src:s,alt:n??"User",className:"h-7 w-7 rounded-full object-cover"}):jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(n??"?")[0].toUpperCase()})}),D&&c&&jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:c})]})]})}i(ve,"DashHeader");function te({columns:e,data:a,rowKey:l,selectable:s=false,selectedKeys:n,onSelectionChange:c,searchable:o=false,searchPlaceholder:m="Search...",totalRows:d,page:v=0,pageSize:D=20,onPageChange:C,onPageSizeChange:R,actions:b,loading:P=false,emptyMessage:f="No data",className:x}){let[u,w]=q.useState(""),[S,A]=q.useState(null),G=q.useMemo(()=>{if(!u)return a;let t=u.toLowerCase();return a.filter(k=>e.some(O=>(O.cell?"":String(k[O.id]??"")).toLowerCase().includes(t)))},[a,u,e]),W=q.useMemo(()=>{if(!S)return G;let{column:t,direction:k}=S;return [...G].sort((O,E)=>{let Z=O[t],ee=E[t];if(Z==null&&ee==null)return 0;if(Z==null)return 1;if(ee==null)return -1;let se=String(Z).localeCompare(String(ee),void 0,{numeric:true});return k==="asc"?se:-se})},[G,S]),I=d??W.length,z=Math.max(1,Math.ceil(I/D)),j=C?W:W.slice(v*D,(v+1)*D),M=n??new Set,J=j.length>0&&j.every(t=>M.has(l(t)));function U(){c&&c(J?new Set:new Set(j.map(l)));}i(U,"toggleAll");function X(t){if(!c)return;let k=new Set(M);k.has(t)?k.delete(t):k.add(t),c(k);}i(X,"toggleRow");function Y(t){A(k=>k?.column===t?k.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"});}i(Y,"handleSort");let N=b?[...e,{id:"__actions",header:"",width:"auto"}]:e;return jsxs("div",{className:r("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",x),children:[(o||s)&&jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[o&&jsx("input",{type:"text",placeholder:m,value:u,onChange:t=>w(t.target.value),className:r("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),s&&M.size>0&&jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[M.size," selected"]})]}),jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:"w-full text-sm",children:[jsx("thead",{children:jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[s&&jsx("th",{className:"w-10 px-4 py-2.5",children:jsx("input",{type:"checkbox",checked:J,onChange:U,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),N.map(t=>jsx("th",{style:t.width?{width:t.width}:void 0,className:r("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",t.align==="center"&&"text-center",t.align==="right"&&"text-right",!t.align&&"text-left",t.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:t.sortable?()=>Y(t.id):void 0,children:jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,t.sortable&&S?.column===t.id&&jsx("span",{className:"text-[10px]",children:S.direction==="asc"?"\u2191":"\u2193"})]})},t.id))]})}),jsx("tbody",{children:P?jsx("tr",{children:jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):j.length===0?jsx("tr",{children:jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:f})}):j.map(t=>{let k=l(t),O=M.has(k);return jsxs("tr",{className:r("border-b border-[var(--dash-border)] transition-colors",O?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[s&&jsx("td",{className:"w-10 px-4 py-2.5",children:jsx("input",{type:"checkbox",checked:O,onChange:()=>X(k),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),e.map(E=>jsx("td",{className:r("px-4 py-2.5",E.align==="center"&&"text-center",E.align==="right"&&"text-right"),children:E.cell?E.cell(t):String(t[E.id]??"")},E.id)),b&&jsx("td",{className:"px-4 py-2.5 text-right",children:b(t)})]},k)})})]})}),z>1&&jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{children:"Rows per page"}),jsx("select",{value:D,onChange:t=>R?.(Number(t.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(t=>jsx("option",{value:t,children:t},t))})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{children:["Page ",v+1," of ",z]}),jsx("button",{type:"button",disabled:v===0,onClick:()=>C?.(v-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("button",{type:"button",disabled:v>=z-1,onClick:()=>C?.(v+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}i(te,"DashDataTable");function re({title:e,fields:a,values:l,onSubmit:s,onCancel:n,submitLabel:c="Save",cancelLabel:o="Cancel",loading:m=false,className:d}){let[v,D]=q.useState(()=>{let f={};for(let x of a)f[x.name]=l?.[x.name]??x.defaultValue??(x.type==="toggle"?false:"");return f}),[C,R]=q.useState({});function b(f,x){D(u=>({...u,[f]:x})),R(u=>{if(!u[f])return u;let w={...u};return delete w[f],w});}i(b,"setValue");async function P(f){f.preventDefault();let x={};for(let u of a){let w=v[u.name];if(u.required&&(w===""||w===null||w===void 0)&&(x[u.name]=`${u.label} is required`),u.validate){let S=u.validate(w);S&&(x[u.name]=S);}}if(Object.keys(x).length>0){R(x);return}await s(v);}return i(P,"handleSubmit"),jsxs("form",{onSubmit:P,className:r("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",d),children:[e&&jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsx("div",{className:"space-y-4",children:a.map(f=>jsx(pe,{field:f,value:v[f.name],error:C[f.name],onChange:x=>b(f.name,x)},f.name))}),jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsx("button",{type:"submit",disabled:m,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Saving...":c}),n&&jsx("button",{type:"button",onClick:n,disabled:m,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:o})]})]})}i(re,"DashForm");var Q=r("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function pe({field:e,value:a,error:l,onChange:s}){let n=`dash-field-${e.name}`,c=jsxs("label",{htmlFor:n,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),o=e.description?jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,m=l?jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:l}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxs("div",{children:[c,jsx("input",{id:n,type:e.type,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,onChange:d=>s(e.type==="number"?Number(d.target.value):d.target.value),className:r(Q,l&&"border-[var(--dash-error)]")}),o,m]});case "textarea":return jsxs("div",{children:[c,jsx("textarea",{id:n,value:String(a??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:d=>s(d.target.value),className:r(Q,"resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "select":case "relation":return jsxs("div",{children:[c,jsxs("select",{id:n,value:String(a??""),disabled:e.disabled,onChange:d=>s(d.target.value),className:r(Q,l&&"border-[var(--dash-error)]"),children:[jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(d=>jsx("option",{value:d.value,children:d.label},d.value))]}),o,m]});case "toggle":return jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{id:n,type:"button",role:"switch","aria-checked":!!a,disabled:e.disabled,onClick:()=>s(!a),className:r("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",a?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsx("span",{className:r("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",a?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsx("label",{htmlFor:n,className:"text-sm text-[var(--dash-text)]",children:e.label}),o,m]});case "json":return jsxs("div",{children:[c,jsx("textarea",{id:n,value:typeof a=="string"?a:JSON.stringify(a,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:d=>{try{s(JSON.parse(d.target.value));}catch{s(d.target.value);}},className:r(Q,"font-mono text-xs resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "file":return jsxs("div",{children:[c,jsx("input",{id:n,type:"file",accept:e.accept,disabled:e.disabled,onChange:d=>{let v=d.target.files?.[0];v&&s(v);},className:r("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),o,m]});default:return null}}i(pe,"FieldRenderer");function be({resourceName:e,resourceNamePlural:a,columns:l,data:s,rowKey:n,fields:c,rowToValues:o,onCreate:m,onUpdate:d,onDelete:v,canCreate:D=true,canEdit:C=true,canDelete:R=true,tableProps:b,loading:P=false,className:f}){let x=a??`${e}s`,[u,w]=q.useState("list"),[S,A]=q.useState(null),[G,W]=q.useState({}),[I,z]=q.useState(null),[j,M]=q.useState(false);function J(N){let t=n(N);A(t),W(o?o(N):N),w("edit");}i(J,"handleEdit");function U(N){z(n(N));}i(U,"handleDeleteConfirm");async function X(){if(!(!I||!v)){M(true);try{await v(I);}finally{M(false),z(null);}}}i(X,"confirmDelete");function Y(N){return jsxs("div",{className:"flex items-center justify-end gap-1",children:[C&&d&&jsx("button",{type:"button",onClick:()=>J(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors",children:"Edit"}),R&&v&&jsx("button",{type:"button",onClick:()=>U(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-error)] hover:bg-[var(--dash-error-dim)] transition-colors",children:"Delete"})]})}return i(Y,"actionsRenderer"),u==="list"?jsxs("div",{className:r("space-y-4",f),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("h2",{className:"text-xl font-semibold text-[var(--dash-text)]",children:x}),D&&m&&jsxs("button",{type:"button",onClick:()=>{A(null),W({}),w("create");},className:r("rounded-[var(--dash-radius)] px-3 py-1.5 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]"),children:["Create ",e]})]}),jsx(te,{columns:l,data:s,rowKey:n,actions:C||R?Y:void 0,loading:P,searchable:true,emptyMessage:`No ${x.toLowerCase()} found`,...b}),I!==null&&jsx(fe,{resourceName:e,loading:j,onConfirm:X,onCancel:()=>z(null)})]}):jsxs("div",{className:r("space-y-4",f),children:[jsxs("button",{type:"button",onClick:()=>w("list"),className:"inline-flex items-center gap-1 text-sm text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to ",x]}),jsx(re,{title:u==="create"?`Create ${e}`:`Edit ${e}`,fields:c,values:u==="edit"?G:void 0,loading:j,submitLabel:u==="create"?"Create":"Save changes",onCancel:()=>w("list"),onSubmit:async N=>{M(true);try{u==="create"&&m?await m(N):u==="edit"&&S&&d&&await d(S,N),w("list");}finally{M(false);}}})]})}i(be,"DashCrud");function fe({resourceName:e,loading:a,onConfirm:l,onCancel:s}){return jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:jsxs("div",{className:"w-full max-w-sm rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6 shadow-lg",children:[jsxs("h3",{className:"text-lg font-semibold text-[var(--dash-text)]",children:["Delete ",e,"?"]}),jsxs("p",{className:"mt-2 text-sm text-[var(--dash-text-muted)]",children:["This action cannot be undone. The ",e.toLowerCase()," will be permanently removed."]}),jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[jsx("button",{type:"button",onClick:s,disabled:a,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:"Cancel"}),jsx("button",{type:"button",onClick:l,disabled:a,className:r("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-error)] text-white","hover:bg-red-600","disabled:opacity-50 disabled:cursor-not-allowed"),children:a?"Deleting...":"Delete"})]})]})})}i(fe,"DeleteDialog");
3
- export{be as DashCrud,te as DashDataTable,re as DashForm,ve as DashHeader,ce as DashLayout,he as DashSidebar};
2
+ import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';import*as q from'react';var ie=Object.defineProperty;var i=(e,r)=>ie(e,"name",{value:r,configurable:true});function a(...e){return twMerge(clsx(e))}i(a,"cn");function ce({sidebar:e,header:r,children:l,sidebarCollapsed:s=false,onSidebarCollapse:n,className:c}){return jsxs("div",{className:a("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsx("aside",{className:a("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",s?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[r&&jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:r}),jsx("main",{className:"flex-1 overflow-y-auto p-6",children:l})]}),!s&&jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>n?.(true)})]})}i(ce,"Layout");function ue({size:e=28}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4 4h4v6h8V4h4v16h-4v-6H8v6H4V4z",fill:"currentColor"})})}i(ue,"HanzoMark");function he({logo:e,groups:r,userMenu:l,collapsed:s=false,onToggleCollapse:n,onNavigate:c,className:o}){return jsxs("nav",{className:a("flex h-full flex-col","bg-[var(--dash-surface)] text-[var(--dash-text)]",o),children:[jsxs("div",{className:a("flex h-[var(--dash-header-height)] items-center border-b border-[var(--dash-border)]",s?"justify-center px-2":"px-4"),children:[e??jsx(ue,{}),!s&&n&&jsx("button",{type:"button",onClick:n,className:"ml-auto rounded p-1 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]","aria-label":"Collapse sidebar",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),s&&n&&jsx("button",{type:"button",onClick:n,className:"absolute -right-3 top-4 z-50 hidden rounded-full border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 text-[var(--dash-text-dim)] hover:text-[var(--dash-text)] lg:flex","aria-label":"Expand sidebar",children:jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto py-2",children:r.map((m,d)=>jsx(me,{group:m,collapsed:s,onNavigate:c},d))}),l&&jsx("div",{className:"border-t border-[var(--dash-border)] p-2",children:l})]})}i(he,"Sidebar");function me({group:e,collapsed:r,onNavigate:l}){let[s,n]=q.useState(e.defaultOpen!==false),c=e.collapsible!==false&&!!e.title;return jsxs("div",{className:"mb-1",children:[e.title&&!r&&jsxs("button",{type:"button",onClick:()=>c&&n(o=>!o),className:a("flex w-full items-center px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-[var(--dash-text-dim)]",c&&"cursor-pointer hover:text-[var(--dash-text-muted)]"),children:[jsx("span",{className:"flex-1 text-left",children:e.title}),c&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",className:a("transition-transform",s?"rotate-0":"-rotate-90"),children:jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(s||r)&&jsx("ul",{className:"space-y-0.5 px-2",children:e.items.map(o=>jsx("li",{children:jsxs("button",{type:"button",onClick:()=>l?.(o.href),title:r?o.label:void 0,className:a("flex w-full items-center gap-2 rounded-[var(--dash-radius-sm)] px-2 py-1.5 text-sm transition-colors",o.active?"bg-[var(--dash-primary)] text-[var(--dash-primary-text)]":"text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]",r&&"justify-center px-0"),children:[o.icon&&jsx("span",{className:"flex h-5 w-5 items-center justify-center flex-shrink-0",children:o.icon}),!r&&jsx("span",{className:"flex-1 truncate text-left",children:o.label}),!r&&o.badge!==void 0&&jsx("span",{className:"ml-auto rounded-full bg-[var(--dash-primary)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--dash-primary-text)]",children:o.badge})]})},o.href))})]})}i(me,"SidebarGroup");function ve({breadcrumbs:e,searchPlaceholder:r="Search...",onSearch:l,avatarUrl:s,userName:n,userDropdown:c,onToggleTheme:o,theme:m="dark",actions:d,className:v}){let[C,R]=q.useState(false),S=q.useRef(null);return q.useEffect(()=>{if(!C)return;function b(M){S.current&&!S.current.contains(M.target)&&R(false);}return i(b,"handleClick"),document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[C]),jsxs("div",{className:a("flex h-[var(--dash-header-height)] items-center gap-4 px-4","bg-[var(--dash-surface)] text-[var(--dash-text)]",v),children:[e&&e.length>0&&jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:e.map((b,M)=>jsxs(q.Fragment,{children:[M>0&&jsx("span",{className:"text-[var(--dash-text-dim)]",children:"/"}),b.href?jsx("a",{href:b.href,className:"text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:b.label}):jsx("span",{className:"text-[var(--dash-text)]",children:b.label})]},M))}),jsx("div",{className:"flex-1"}),l&&jsxs("div",{className:"relative hidden sm:block",children:[jsxs("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--dash-text-dim)]",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"7",cy:"7",r:"5.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M11 11l3 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jsx("input",{type:"text",placeholder:r,onChange:b=>l(b.target.value),className:a("h-8 w-56 rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] pl-8 pr-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","transition-colors")})]}),d,o&&jsx("button",{type:"button",onClick:o,className:"rounded-[var(--dash-radius-sm)] p-1.5 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors","aria-label":`Switch to ${m==="dark"?"light":"dark"} mode`,children:m==="dark"?jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsx("circle",{cx:"8",cy:"8",r:"3.5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 1v2M8 13v2M1 8h2M13 8h2M3.05 3.05l1.41 1.41M11.54 11.54l1.41 1.41M3.05 12.95l1.41-1.41M11.54 4.46l1.41-1.41",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M14 9.5A6.5 6.5 0 016.5 2 5.5 5.5 0 1014 9.5z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(s||n)&&jsxs("div",{className:"relative",ref:S,children:[jsx("button",{type:"button",onClick:()=>R(b=>!b),className:"flex items-center gap-2 rounded-[var(--dash-radius-sm)] p-1 hover:bg-[var(--dash-surface-hover)] transition-colors",children:s?jsx("img",{src:s,alt:n??"User",className:"h-7 w-7 rounded-full object-cover"}):jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--dash-primary)] text-xs font-medium text-[var(--dash-primary-text)]",children:(n??"?")[0].toUpperCase()})}),C&&c&&jsx("div",{className:"absolute right-0 top-full z-50 mt-1 min-w-48 rounded-[var(--dash-radius)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 shadow-lg",children:c})]})]})}i(ve,"Header");function te({columns:e,data:r,rowKey:l,selectable:s=false,selectedKeys:n,onSelectionChange:c,searchable:o=false,searchPlaceholder:m="Search...",totalRows:d,page:v=0,pageSize:C=20,onPageChange:R,onPageSizeChange:S,actions:b,loading:M=false,emptyMessage:f="No data",className:x}){let[u,w]=q.useState(""),[L,A]=q.useState(null),G=q.useMemo(()=>{if(!u)return r;let t=u.toLowerCase();return r.filter(k=>e.some(O=>(O.cell?"":String(k[O.id]??"")).toLowerCase().includes(t)))},[r,u,e]),W=q.useMemo(()=>{if(!L)return G;let{column:t,direction:k}=L;return [...G].sort((O,E)=>{let Z=O[t],ee=E[t];if(Z==null&&ee==null)return 0;if(Z==null)return 1;if(ee==null)return -1;let se=String(Z).localeCompare(String(ee),void 0,{numeric:true});return k==="asc"?se:-se})},[G,L]),I=d??W.length,z=Math.max(1,Math.ceil(I/C)),j=R?W:W.slice(v*C,(v+1)*C),F=n??new Set,J=j.length>0&&j.every(t=>F.has(l(t)));function U(){c&&c(J?new Set:new Set(j.map(l)));}i(U,"toggleAll");function X(t){if(!c)return;let k=new Set(F);k.has(t)?k.delete(t):k.add(t),c(k);}i(X,"toggleRow");function Y(t){A(k=>k?.column===t?k.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"});}i(Y,"handleSort");let N=b?[...e,{id:"__actions",header:"",width:"auto"}]:e;return jsxs("div",{className:a("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",x),children:[(o||s)&&jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[o&&jsx("input",{type:"text",placeholder:m,value:u,onChange:t=>w(t.target.value),className:a("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),s&&F.size>0&&jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[F.size," selected"]})]}),jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:"w-full text-sm",children:[jsx("thead",{children:jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[s&&jsx("th",{className:"w-10 px-4 py-2.5",children:jsx("input",{type:"checkbox",checked:J,onChange:U,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),N.map(t=>jsx("th",{style:t.width?{width:t.width}:void 0,className:a("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",t.align==="center"&&"text-center",t.align==="right"&&"text-right",!t.align&&"text-left",t.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:t.sortable?()=>Y(t.id):void 0,children:jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,t.sortable&&L?.column===t.id&&jsx("span",{className:"text-[10px]",children:L.direction==="asc"?"\u2191":"\u2193"})]})},t.id))]})}),jsx("tbody",{children:M?jsx("tr",{children:jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):j.length===0?jsx("tr",{children:jsx("td",{colSpan:N.length+(s?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:f})}):j.map(t=>{let k=l(t),O=F.has(k);return jsxs("tr",{className:a("border-b border-[var(--dash-border)] transition-colors",O?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[s&&jsx("td",{className:"w-10 px-4 py-2.5",children:jsx("input",{type:"checkbox",checked:O,onChange:()=>X(k),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),e.map(E=>jsx("td",{className:a("px-4 py-2.5",E.align==="center"&&"text-center",E.align==="right"&&"text-right"),children:E.cell?E.cell(t):String(t[E.id]??"")},E.id)),b&&jsx("td",{className:"px-4 py-2.5 text-right",children:b(t)})]},k)})})]})}),z>1&&jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{children:"Rows per page"}),jsx("select",{value:C,onChange:t=>S?.(Number(t.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(t=>jsx("option",{value:t,children:t},t))})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{children:["Page ",v+1," of ",z]}),jsx("button",{type:"button",disabled:v===0,onClick:()=>R?.(v-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("button",{type:"button",disabled:v>=z-1,onClick:()=>R?.(v+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}i(te,"Table");function ae({title:e,fields:r,values:l,onSubmit:s,onCancel:n,submitLabel:c="Save",cancelLabel:o="Cancel",loading:m=false,className:d}){let[v,C]=q.useState(()=>{let f={};for(let x of r)f[x.name]=l?.[x.name]??x.defaultValue??(x.type==="toggle"?false:"");return f}),[R,S]=q.useState({});function b(f,x){C(u=>({...u,[f]:x})),S(u=>{if(!u[f])return u;let w={...u};return delete w[f],w});}i(b,"setValue");async function M(f){f.preventDefault();let x={};for(let u of r){let w=v[u.name];if(u.required&&(w===""||w===null||w===void 0)&&(x[u.name]=`${u.label} is required`),u.validate){let L=u.validate(w);L&&(x[u.name]=L);}}if(Object.keys(x).length>0){S(x);return}await s(v);}return i(M,"handleSubmit"),jsxs("form",{onSubmit:M,className:a("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6",d),children:[e&&jsx("h3",{className:"mb-4 text-lg font-semibold text-[var(--dash-text)]",children:e}),jsx("div",{className:"space-y-4",children:r.map(f=>jsx(pe,{field:f,value:v[f.name],error:R[f.name],onChange:x=>b(f.name,x)},f.name))}),jsxs("div",{className:"mt-6 flex items-center gap-3",children:[jsx("button",{type:"submit",disabled:m,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Saving...":c}),n&&jsx("button",{type:"button",onClick:n,disabled:m,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:o})]})]})}i(ae,"Form");var Q=a("w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 py-2 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors");function pe({field:e,value:r,error:l,onChange:s}){let n=`dash-field-${e.name}`,c=jsxs("label",{htmlFor:n,className:"mb-1 block text-sm font-medium text-[var(--dash-text)]",children:[e.label,e.required&&jsx("span",{className:"ml-0.5 text-[var(--dash-error)]",children:"*"})]}),o=e.description?jsx("p",{className:"mt-1 text-xs text-[var(--dash-text-dim)]",children:e.description}):null,m=l?jsx("p",{className:"mt-1 text-xs text-[var(--dash-error)]",children:l}):null;switch(e.type){case "text":case "email":case "password":case "number":return jsxs("div",{children:[c,jsx("input",{id:n,type:e.type,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,onChange:d=>s(e.type==="number"?Number(d.target.value):d.target.value),className:a(Q,l&&"border-[var(--dash-error)]")}),o,m]});case "textarea":return jsxs("div",{children:[c,jsx("textarea",{id:n,value:String(r??""),placeholder:e.placeholder,disabled:e.disabled,rows:e.rows??3,onChange:d=>s(d.target.value),className:a(Q,"resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "select":case "relation":return jsxs("div",{children:[c,jsxs("select",{id:n,value:String(r??""),disabled:e.disabled,onChange:d=>s(d.target.value),className:a(Q,l&&"border-[var(--dash-error)]"),children:[jsx("option",{value:"",children:e.placeholder??"Select..."}),(e.options??[]).map(d=>jsx("option",{value:d.value,children:d.label},d.value))]}),o,m]});case "toggle":return jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{id:n,type:"button",role:"switch","aria-checked":!!r,disabled:e.disabled,onClick:()=>s(!r),className:a("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full transition-colors","focus:outline-none focus:ring-2 focus:ring-[var(--dash-primary)] focus:ring-offset-2 focus:ring-offset-[var(--dash-surface)]",r?"bg-[var(--dash-primary)]":"bg-[var(--dash-border)]",e.disabled&&"opacity-50 cursor-not-allowed"),children:jsx("span",{className:a("pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",r?"translate-x-4":"translate-x-0.5","mt-0.5")})}),jsx("label",{htmlFor:n,className:"text-sm text-[var(--dash-text)]",children:e.label}),o,m]});case "json":return jsxs("div",{children:[c,jsx("textarea",{id:n,value:typeof r=="string"?r:JSON.stringify(r,null,2),placeholder:e.placeholder??"{}",disabled:e.disabled,rows:e.rows??6,onChange:d=>{try{s(JSON.parse(d.target.value));}catch{s(d.target.value);}},className:a(Q,"font-mono text-xs resize-y",l&&"border-[var(--dash-error)]")}),o,m]});case "file":return jsxs("div",{children:[c,jsx("input",{id:n,type:"file",accept:e.accept,disabled:e.disabled,onChange:d=>{let v=d.target.files?.[0];v&&s(v);},className:a("w-full text-sm text-[var(--dash-text-muted)]","file:mr-3 file:rounded-[var(--dash-radius-sm)] file:border-0 file:bg-[var(--dash-primary)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--dash-primary-text)]","file:cursor-pointer hover:file:bg-[var(--dash-primary-hover)]")}),o,m]});default:return null}}i(pe,"FieldRenderer");function be({resourceName:e,resourceNamePlural:r,columns:l,data:s,rowKey:n,fields:c,rowToValues:o,onCreate:m,onUpdate:d,onDelete:v,canCreate:C=true,canEdit:R=true,canDelete:S=true,tableProps:b,loading:M=false,className:f}){let x=r??`${e}s`,[u,w]=q.useState("list"),[L,A]=q.useState(null),[G,W]=q.useState({}),[I,z]=q.useState(null),[j,F]=q.useState(false);function J(N){let t=n(N);A(t),W(o?o(N):N),w("edit");}i(J,"handleEdit");function U(N){z(n(N));}i(U,"handleDeleteConfirm");async function X(){if(!(!I||!v)){F(true);try{await v(I);}finally{F(false),z(null);}}}i(X,"confirmDelete");function Y(N){return jsxs("div",{className:"flex items-center justify-end gap-1",children:[R&&d&&jsx("button",{type:"button",onClick:()=>J(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)] transition-colors",children:"Edit"}),S&&v&&jsx("button",{type:"button",onClick:()=>U(N),className:"rounded-[var(--dash-radius-sm)] px-2 py-1 text-xs text-[var(--dash-error)] hover:bg-[var(--dash-error-dim)] transition-colors",children:"Delete"})]})}return i(Y,"actionsRenderer"),u==="list"?jsxs("div",{className:a("space-y-4",f),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("h2",{className:"text-xl font-semibold text-[var(--dash-text)]",children:x}),C&&m&&jsxs("button",{type:"button",onClick:()=>{A(null),W({}),w("create");},className:a("rounded-[var(--dash-radius)] px-3 py-1.5 text-sm font-medium transition-colors","bg-[var(--dash-primary)] text-[var(--dash-primary-text)]","hover:bg-[var(--dash-primary-hover)]"),children:["Create ",e]})]}),jsx(te,{columns:l,data:s,rowKey:n,actions:R||S?Y:void 0,loading:M,searchable:true,emptyMessage:`No ${x.toLowerCase()} found`,...b}),I!==null&&jsx(fe,{resourceName:e,loading:j,onConfirm:X,onCancel:()=>z(null)})]}):jsxs("div",{className:a("space-y-4",f),children:[jsxs("button",{type:"button",onClick:()=>w("list"),className:"inline-flex items-center gap-1 text-sm text-[var(--dash-text-muted)] hover:text-[var(--dash-text)] transition-colors",children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back to ",x]}),jsx(ae,{title:u==="create"?`Create ${e}`:`Edit ${e}`,fields:c,values:u==="edit"?G:void 0,loading:j,submitLabel:u==="create"?"Create":"Save changes",onCancel:()=>w("list"),onSubmit:async N=>{F(true);try{u==="create"&&m?await m(N):u==="edit"&&L&&d&&await d(L,N),w("list");}finally{F(false);}}})]})}i(be,"Crud");function fe({resourceName:e,loading:r,onConfirm:l,onCancel:s}){return jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:jsxs("div",{className:"w-full max-w-sm rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)] p-6 shadow-lg",children:[jsxs("h3",{className:"text-lg font-semibold text-[var(--dash-text)]",children:["Delete ",e,"?"]}),jsxs("p",{className:"mt-2 text-sm text-[var(--dash-text-muted)]",children:["This action cannot be undone. The ",e.toLowerCase()," will be permanently removed."]}),jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[jsx("button",{type:"button",onClick:s,disabled:r,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","border border-[var(--dash-border)] text-[var(--dash-text-muted)]","hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]"),children:"Cancel"}),jsx("button",{type:"button",onClick:l,disabled:r,className:a("rounded-[var(--dash-radius)] px-4 py-2 text-sm font-medium transition-colors","bg-[var(--dash-error)] text-white","hover:bg-red-600","disabled:opacity-50 disabled:cursor-not-allowed"),children:r?"Deleting...":"Delete"})]})]})})}i(fe,"DeleteDialog");
3
+ export{be as Crud,ae as Form,ve as Header,ce as Layout,he as Sidebar,te as Table};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- 'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');var n=Object.defineProperty;var r=(e,a)=>n(e,"name",{value:a,configurable:true});function s(...e){return tailwindMerge.twMerge(clsx.clsx(e))}r(s,"cn");function N({sidebar:e,header:a,children:t,sidebarCollapsed:d=false,onSidebarCollapse:i,className:c}){return jsxRuntime.jsxs("div",{className:s("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsxRuntime.jsx("aside",{className:s("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",d?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[a&&jsxRuntime.jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:a}),jsxRuntime.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:t})]}),!d&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>i?.(true)})]})}r(N,"DashLayout");exports.DashLayout=N;
2
+ 'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');var n=Object.defineProperty;var r=(e,a)=>n(e,"name",{value:a,configurable:true});function d(...e){return tailwindMerge.twMerge(clsx.clsx(e))}r(d,"cn");function N({sidebar:e,header:a,children:t,sidebarCollapsed:s=false,onSidebarCollapse:i,className:c}){return jsxRuntime.jsxs("div",{className:d("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsxRuntime.jsx("aside",{className:d("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",s?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[a&&jsxRuntime.jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:a}),jsxRuntime.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:t})]}),!s&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>i?.(true)})]})}r(N,"Layout");exports.Layout=N;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';var n=Object.defineProperty;var r=(e,a)=>n(e,"name",{value:a,configurable:true});function s(...e){return twMerge(clsx(e))}r(s,"cn");function N({sidebar:e,header:a,children:t,sidebarCollapsed:d=false,onSidebarCollapse:i,className:c}){return jsxs("div",{className:s("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsx("aside",{className:s("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",d?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[a&&jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:a}),jsx("main",{className:"flex-1 overflow-y-auto p-6",children:t})]}),!d&&jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>i?.(true)})]})}r(N,"DashLayout");export{N as DashLayout};
2
+ import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';var n=Object.defineProperty;var r=(e,a)=>n(e,"name",{value:a,configurable:true});function d(...e){return twMerge(clsx(e))}r(d,"cn");function N({sidebar:e,header:a,children:t,sidebarCollapsed:s=false,onSidebarCollapse:i,className:c}){return jsxs("div",{className:d("flex h-screen overflow-hidden","bg-[var(--dash-bg)] text-[var(--dash-text)]",c),children:[jsx("aside",{className:d("flex-shrink-0 overflow-y-auto overflow-x-hidden transition-[width] duration-200","border-r border-[var(--dash-border)] bg-[var(--dash-surface)]",s?"w-[var(--dash-sidebar-collapsed-width)]":"w-[var(--dash-sidebar-width)]"),children:e}),jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[a&&jsx("header",{className:"flex-shrink-0 border-b border-[var(--dash-border)] bg-[var(--dash-surface)]",children:a}),jsx("main",{className:"flex-1 overflow-y-auto p-6",children:t})]}),!s&&jsx("div",{className:"fixed inset-0 z-40 bg-black/60 lg:hidden",onClick:()=>i?.(true)})]})}r(N,"Layout");export{N as Layout};
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ 'use strict';var u=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');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 u__namespace=/*#__PURE__*/_interopNamespace(u);var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:true});function i(...t){return tailwindMerge.twMerge(clsx.clsx(t))}n(i,"cn");function b({size:t=28}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4 4h4v6h8V4h4v16h-4v-6H8v6H4V4z",fill:"currentColor"})})}n(b,"HanzoMark");function L({logo:t,groups:r,userMenu:v,collapsed:o=false,onToggleCollapse:s,onNavigate:l,className:a}){return jsxRuntime.jsxs("nav",{className:i("flex h-full flex-col","bg-[var(--dash-surface)] text-[var(--dash-text)]",a),children:[jsxRuntime.jsxs("div",{className:i("flex h-[var(--dash-header-height)] items-center border-b border-[var(--dash-border)]",o?"justify-center px-2":"px-4"),children:[t??jsxRuntime.jsx(b,{}),!o&&s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:"ml-auto rounded p-1 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]","aria-label":"Collapse sidebar",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),o&&s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:"absolute -right-3 top-4 z-50 hidden rounded-full border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 text-[var(--dash-text-dim)] hover:text-[var(--dash-text)] lg:flex","aria-label":"Expand sidebar",children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:r.map((h,c)=>jsxRuntime.jsx(m,{group:h,collapsed:o,onNavigate:l},c))}),v&&jsxRuntime.jsx("div",{className:"border-t border-[var(--dash-border)] p-2",children:v})]})}n(L,"Sidebar");function m({group:t,collapsed:r,onNavigate:v}){let[o,s]=u__namespace.useState(t.defaultOpen!==false),l=t.collapsible!==false&&!!t.title;return jsxRuntime.jsxs("div",{className:"mb-1",children:[t.title&&!r&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>l&&s(a=>!a),className:i("flex w-full items-center px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-[var(--dash-text-dim)]",l&&"cursor-pointer hover:text-[var(--dash-text-muted)]"),children:[jsxRuntime.jsx("span",{className:"flex-1 text-left",children:t.title}),l&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",className:i("transition-transform",o?"rotate-0":"-rotate-90"),children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(o||r)&&jsxRuntime.jsx("ul",{className:"space-y-0.5 px-2",children:t.items.map(a=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>v?.(a.href),title:r?a.label:void 0,className:i("flex w-full items-center gap-2 rounded-[var(--dash-radius-sm)] px-2 py-1.5 text-sm transition-colors",a.active?"bg-[var(--dash-primary)] text-[var(--dash-primary-text)]":"text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]",r&&"justify-center px-0"),children:[a.icon&&jsxRuntime.jsx("span",{className:"flex h-5 w-5 items-center justify-center flex-shrink-0",children:a.icon}),!r&&jsxRuntime.jsx("span",{className:"flex-1 truncate text-left",children:a.label}),!r&&a.badge!==void 0&&jsxRuntime.jsx("span",{className:"ml-auto rounded-full bg-[var(--dash-primary)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--dash-primary-text)]",children:a.badge})]})},a.href))})]})}n(m,"SidebarGroup");
3
+ exports.Sidebar=L;
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import*as u from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx}from'react/jsx-runtime';var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:true});function i(...t){return twMerge(clsx(t))}n(i,"cn");function b({size:t=28}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4 4h4v6h8V4h4v16h-4v-6H8v6H4V4z",fill:"currentColor"})})}n(b,"HanzoMark");function L({logo:t,groups:r,userMenu:v,collapsed:o=false,onToggleCollapse:s,onNavigate:l,className:a}){return jsxs("nav",{className:i("flex h-full flex-col","bg-[var(--dash-surface)] text-[var(--dash-text)]",a),children:[jsxs("div",{className:i("flex h-[var(--dash-header-height)] items-center border-b border-[var(--dash-border)]",o?"justify-center px-2":"px-4"),children:[t??jsx(b,{}),!o&&s&&jsx("button",{type:"button",onClick:s,className:"ml-auto rounded p-1 text-[var(--dash-text-dim)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]","aria-label":"Collapse sidebar",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),o&&s&&jsx("button",{type:"button",onClick:s,className:"absolute -right-3 top-4 z-50 hidden rounded-full border border-[var(--dash-border)] bg-[var(--dash-surface)] p-1 text-[var(--dash-text-dim)] hover:text-[var(--dash-text)] lg:flex","aria-label":"Expand sidebar",children:jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),jsx("div",{className:"flex-1 overflow-y-auto py-2",children:r.map((h,c)=>jsx(m,{group:h,collapsed:o,onNavigate:l},c))}),v&&jsx("div",{className:"border-t border-[var(--dash-border)] p-2",children:v})]})}n(L,"Sidebar");function m({group:t,collapsed:r,onNavigate:v}){let[o,s]=u.useState(t.defaultOpen!==false),l=t.collapsible!==false&&!!t.title;return jsxs("div",{className:"mb-1",children:[t.title&&!r&&jsxs("button",{type:"button",onClick:()=>l&&s(a=>!a),className:i("flex w-full items-center px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-[var(--dash-text-dim)]",l&&"cursor-pointer hover:text-[var(--dash-text-muted)]"),children:[jsx("span",{className:"flex-1 text-left",children:t.title}),l&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",className:i("transition-transform",o?"rotate-0":"-rotate-90"),children:jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),(o||r)&&jsx("ul",{className:"space-y-0.5 px-2",children:t.items.map(a=>jsx("li",{children:jsxs("button",{type:"button",onClick:()=>v?.(a.href),title:r?a.label:void 0,className:i("flex w-full items-center gap-2 rounded-[var(--dash-radius-sm)] px-2 py-1.5 text-sm transition-colors",a.active?"bg-[var(--dash-primary)] text-[var(--dash-primary-text)]":"text-[var(--dash-text-muted)] hover:bg-[var(--dash-surface-hover)] hover:text-[var(--dash-text)]",r&&"justify-center px-0"),children:[a.icon&&jsx("span",{className:"flex h-5 w-5 items-center justify-center flex-shrink-0",children:a.icon}),!r&&jsx("span",{className:"flex-1 truncate text-left",children:a.label}),!r&&a.badge!==void 0&&jsx("span",{className:"ml-auto rounded-full bg-[var(--dash-primary)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--dash-primary-text)]",children:a.badge})]})},a.href))})]})}n(m,"SidebarGroup");
3
+ export{L as Sidebar};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- 'use strict';var u=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');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 u__namespace=/*#__PURE__*/_interopNamespace(u);var J=Object.defineProperty;var i=(s,h)=>J(s,"name",{value:h,configurable:true});function c(...s){return tailwindMerge.twMerge(clsx.clsx(s))}i(c,"cn");function ee({columns:s,data:h,rowKey:f,selectable:l=false,selectedKeys:P,onSelectionChange:m,searchable:D=false,searchPlaceholder:j="Search...",totalRows:z,page:o=0,pageSize:g=20,onPageChange:w,onPageSizeChange:B,actions:y,loading:V=false,emptyMessage:W="No data",className:_}){let[x,q]=u__namespace.useState(""),[p,A]=u__namespace.useState(null),N=u__namespace.useMemo(()=>{if(!x)return h;let e=x.toLowerCase();return h.filter(r=>s.some(d=>(d.cell?"":String(r[d.id]??"")).toLowerCase().includes(e)))},[h,x,s]),k=u__namespace.useMemo(()=>{if(!p)return N;let{column:e,direction:r}=p;return [...N].sort((d,n)=>{let C=d[e],T=n[e];if(C==null&&T==null)return 0;if(C==null)return 1;if(T==null)return -1;let M=String(C).localeCompare(String(T),void 0,{numeric:true});return r==="asc"?M:-M})},[N,p]),E=z??k.length,S=Math.max(1,Math.ceil(E/g)),b=w?k:k.slice(o*g,(o+1)*g),v=P??new Set,L=b.length>0&&b.every(e=>v.has(f(e)));function F(){m&&m(L?new Set:new Set(b.map(f)));}i(F,"toggleAll");function G(e){if(!m)return;let r=new Set(v);r.has(e)?r.delete(e):r.add(e),m(r);}i(G,"toggleRow");function H(e){A(r=>r?.column===e?r.direction==="asc"?{column:e,direction:"desc"}:null:{column:e,direction:"asc"});}i(H,"handleSort");let R=y?[...s,{id:"__actions",header:"",width:"auto"}]:s;return jsxRuntime.jsxs("div",{className:c("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",_),children:[(D||l)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[D&&jsxRuntime.jsx("input",{type:"text",placeholder:j,value:x,onChange:e=>q(e.target.value),className:c("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),l&&v.size>0&&jsxRuntime.jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[v.size," selected"]})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[l&&jsxRuntime.jsx("th",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:L,onChange:F,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),R.map(e=>jsxRuntime.jsx("th",{style:e.width?{width:e.width}:void 0,className:c("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",e.align==="center"&&"text-center",e.align==="right"&&"text-right",!e.align&&"text-left",e.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:e.sortable?()=>H(e.id):void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.header,e.sortable&&p?.column===e.id&&jsxRuntime.jsx("span",{className:"text-[10px]",children:p.direction==="asc"?"\u2191":"\u2193"})]})},e.id))]})}),jsxRuntime.jsx("tbody",{children:V?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:R.length+(l?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):b.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:R.length+(l?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:W})}):b.map(e=>{let r=f(e),d=v.has(r);return jsxRuntime.jsxs("tr",{className:c("border-b border-[var(--dash-border)] transition-colors",d?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[l&&jsxRuntime.jsx("td",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:d,onChange:()=>G(r),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),s.map(n=>jsxRuntime.jsx("td",{className:c("px-4 py-2.5",n.align==="center"&&"text-center",n.align==="right"&&"text-right"),children:n.cell?n.cell(e):String(e[n.id]??"")},n.id)),y&&jsxRuntime.jsx("td",{className:"px-4 py-2.5 text-right",children:y(e)})]},r)})})]})}),S>1&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Rows per page"}),jsxRuntime.jsx("select",{value:g,onChange:e=>B?.(Number(e.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(e=>jsxRuntime.jsx("option",{value:e,children:e},e))})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{children:["Page ",o+1," of ",S]}),jsxRuntime.jsx("button",{type:"button",disabled:o===0,onClick:()=>w?.(o-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("button",{type:"button",disabled:o>=S-1,onClick:()=>w?.(o+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}i(ee,"DashDataTable");exports.DashDataTable=ee;
2
+ 'use strict';var u=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime');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 u__namespace=/*#__PURE__*/_interopNamespace(u);var J=Object.defineProperty;var i=(s,h)=>J(s,"name",{value:h,configurable:true});function c(...s){return tailwindMerge.twMerge(clsx.clsx(s))}i(c,"cn");function ee({columns:s,data:h,rowKey:f,selectable:l=false,selectedKeys:j,onSelectionChange:m,searchable:L=false,searchPlaceholder:z="Search...",totalRows:B,page:o=0,pageSize:g=20,onPageChange:w,onPageSizeChange:V,actions:y,loading:W=false,emptyMessage:_="No data",className:q}){let[x,A]=u__namespace.useState(""),[p,D]=u__namespace.useState(null),N=u__namespace.useMemo(()=>{if(!x)return h;let e=x.toLowerCase();return h.filter(r=>s.some(d=>(d.cell?"":String(r[d.id]??"")).toLowerCase().includes(e)))},[h,x,s]),k=u__namespace.useMemo(()=>{if(!p)return N;let{column:e,direction:r}=p;return [...N].sort((d,n)=>{let C=d[e],T=n[e];if(C==null&&T==null)return 0;if(C==null)return 1;if(T==null)return -1;let P=String(C).localeCompare(String(T),void 0,{numeric:true});return r==="asc"?P:-P})},[N,p]),E=B??k.length,S=Math.max(1,Math.ceil(E/g)),b=w?k:k.slice(o*g,(o+1)*g),v=j??new Set,M=b.length>0&&b.every(e=>v.has(f(e)));function F(){m&&m(M?new Set:new Set(b.map(f)));}i(F,"toggleAll");function G(e){if(!m)return;let r=new Set(v);r.has(e)?r.delete(e):r.add(e),m(r);}i(G,"toggleRow");function H(e){D(r=>r?.column===e?r.direction==="asc"?{column:e,direction:"desc"}:null:{column:e,direction:"asc"});}i(H,"handleSort");let R=y?[...s,{id:"__actions",header:"",width:"auto"}]:s;return jsxRuntime.jsxs("div",{className:c("rounded-[var(--dash-radius-lg)] border border-[var(--dash-border)] bg-[var(--dash-surface)]",q),children:[(L||l)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--dash-border)] px-4 py-3",children:[L&&jsxRuntime.jsx("input",{type:"text",placeholder:z,value:x,onChange:e=>A(e.target.value),className:c("h-8 w-64 max-w-full rounded-[var(--dash-radius-sm)] border border-[var(--dash-border)] bg-[var(--dash-bg)] px-3 text-sm text-[var(--dash-text)]","placeholder:text-[var(--dash-text-dim)]","focus:border-[var(--dash-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--dash-primary)]")}),l&&v.size>0&&jsxRuntime.jsxs("span",{className:"text-xs text-[var(--dash-text-muted)]",children:[v.size," selected"]})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"border-b border-[var(--dash-border)]",children:[l&&jsxRuntime.jsx("th",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:M,onChange:F,className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),R.map(e=>jsxRuntime.jsx("th",{style:e.width?{width:e.width}:void 0,className:c("px-4 py-2.5 text-[var(--dash-text-dim)] font-medium",e.align==="center"&&"text-center",e.align==="right"&&"text-right",!e.align&&"text-left",e.sortable&&"cursor-pointer select-none hover:text-[var(--dash-text-muted)]"),onClick:e.sortable?()=>H(e.id):void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.header,e.sortable&&p?.column===e.id&&jsxRuntime.jsx("span",{className:"text-[10px]",children:p.direction==="asc"?"\u2191":"\u2193"})]})},e.id))]})}),jsxRuntime.jsx("tbody",{children:W?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:R.length+(l?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:"Loading..."})}):b.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:R.length+(l?1:0),className:"px-4 py-8 text-center text-[var(--dash-text-dim)]",children:_})}):b.map(e=>{let r=f(e),d=v.has(r);return jsxRuntime.jsxs("tr",{className:c("border-b border-[var(--dash-border)] transition-colors",d?"bg-[var(--dash-surface-active)]":"hover:bg-[var(--dash-surface-hover)]"),children:[l&&jsxRuntime.jsx("td",{className:"w-10 px-4 py-2.5",children:jsxRuntime.jsx("input",{type:"checkbox",checked:d,onChange:()=>G(r),className:"h-4 w-4 rounded border-[var(--dash-border)] accent-[var(--dash-primary)]"})}),s.map(n=>jsxRuntime.jsx("td",{className:c("px-4 py-2.5",n.align==="center"&&"text-center",n.align==="right"&&"text-right"),children:n.cell?n.cell(e):String(e[n.id]??"")},n.id)),y&&jsxRuntime.jsx("td",{className:"px-4 py-2.5 text-right",children:y(e)})]},r)})})]})}),S>1&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--dash-border)] px-4 py-2.5 text-xs text-[var(--dash-text-muted)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Rows per page"}),jsxRuntime.jsx("select",{value:g,onChange:e=>V?.(Number(e.target.value)),className:"h-7 rounded border border-[var(--dash-border)] bg-[var(--dash-bg)] px-2 text-xs text-[var(--dash-text)] focus:outline-none",children:[10,20,50,100].map(e=>jsxRuntime.jsx("option",{value:e,children:e},e))})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{children:["Page ",o+1," of ",S]}),jsxRuntime.jsx("button",{type:"button",disabled:o===0,onClick:()=>w?.(o-1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M10 4L6 8l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("button",{type:"button",disabled:o>=S-1,onClick:()=>w?.(o+1),className:"rounded p-1 hover:bg-[var(--dash-surface-hover)] disabled:opacity-30 disabled:cursor-not-allowed",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})]})}i(ee,"Table");exports.Table=ee;