@gulibs/react-vtable 0.0.7 → 0.0.9

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.
@@ -5,6 +5,6 @@ interface SearchProps<T = any> extends ProTableSearch {
5
5
  onReset?: () => void;
6
6
  loading?: boolean;
7
7
  }
8
- export declare function Search<T = any>({ columns, onSearch, onReset, loading, filterType, searchText, resetText, submitText, defaultCollapsed, collapsed: controlledCollapsed, onCollapse, optionRender, }: SearchProps<T>): import("react/jsx-runtime").JSX.Element;
8
+ export declare function Search<T = any>({ columns, onSearch, onReset, loading, filterType, searchText, resetText, submitText, defaultCollapsed, collapsed: controlledCollapsed, onCollapse, optionRender, }: SearchProps<T>): import("react/jsx-runtime").JSX.Element | null;
9
9
  export {};
10
10
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../lib/components/search.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAazD,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc;IACnD,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,EAC9B,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,UAAoB,EACpB,UAAU,EACV,SAAS,EACT,UAAU,EACV,gBAAuB,EACvB,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EACV,YAAY,GACb,EAAE,WAAW,CAAC,CAAC,CAAC,2CAkThB"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../lib/components/search.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAazD,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc;IACnD,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,EAC9B,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,UAAoB,EACpB,UAAU,EACV,SAAS,EACT,UAAU,EACV,gBAAuB,EACvB,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EACV,YAAY,GACb,EAAE,WAAW,CAAC,CAAC,CAAC,kDA8ThB"}
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../lib/components/ui/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAK1D,iBAAS,MAAM,CAAC,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,2CAEnD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAEpD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAEpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,IAAgB,EAChB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,GAAG;IACxD,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CACzB,2CAiBA;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,QAAmB,EACnB,KAAgB,EAChB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,2CA6BtD;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAQpD;AAED,iBAAS,UAAU,CAAC,EAClB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,2CAkBnD;AAED,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,SAAS,CAAC,2CAQxD;AAED,iBAAS,oBAAoB,CAAC,EAC5B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,cAAc,CAAC,2CAa7D;AAED,iBAAS,sBAAsB,CAAC,EAC9B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,gBAAgB,CAAC,2CAa/D;AAED,OAAO,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,WAAW,GACZ,CAAC"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../lib/components/ui/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAK1D,iBAAS,MAAM,CAAC,EACd,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,2CAEnD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAEpD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAEpD;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,IAAgB,EAChB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,GAAG;IACxD,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CACzB,2CAiBA;AAED,iBAAS,aAAa,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,QAAmB,EACnB,KAAgB,EAChB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,2CA+BtD;AAED,iBAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAQpD;AAED,iBAAS,UAAU,CAAC,EAClB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,2CAkBnD;AAED,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,SAAS,CAAC,2CAQxD;AAED,iBAAS,oBAAoB,CAAC,EAC5B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,cAAc,CAAC,2CAa7D;AAED,iBAAS,sBAAsB,CAAC,EAC9B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,gBAAgB,CAAC,2CAa/D;AAED,OAAO,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,WAAW,GACZ,CAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- require('./index.css');var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`@tanstack/react-table`);l=s(l);let u=require(`clsx`);u=s(u);let d=require(`tailwind-merge`);d=s(d);let f=require(`date-fns`);f=s(f);let p=require(`@radix-ui/react-slot`);p=s(p);let m=require(`class-variance-authority`);m=s(m);let h=require(`react/jsx-runtime`);h=s(h);let g=require(`@radix-ui/react-avatar`);g=s(g);let _=require(`@radix-ui/react-switch`);_=s(_);let v=require(`@radix-ui/react-progress`);v=s(v);let y=require(`@radix-ui/react-checkbox`);y=s(y);let b=require(`lucide-react`);b=s(b);let x=require(`@radix-ui/react-dropdown-menu`);x=s(x);let S=require(`@radix-ui/react-tooltip`);S=s(S);let C=require(`@tabler/icons-react`);C=s(C);let w=require(`@dnd-kit/core`);w=s(w);let T=require(`@dnd-kit/sortable`);T=s(T);let E=require(`@dnd-kit/utilities`);E=s(E);let D=require(`@dnd-kit/modifiers`);D=s(D);let O=require(`@radix-ui/react-select`);O=s(O);let k=require(`react-day-picker`);k=s(k);let A=require(`@radix-ui/react-popover`);A=s(A);let j=require(`@radix-ui/react-label`);j=s(j);let M=require(`react-hook-form`);M=s(M);let N=require(`framer-motion`);N=s(N);function ee(e){return e.filter(e=>!e.hideInSearch&&(e.search===!0||typeof e.search==`object`))}function P(e){return e.filter(e=>!e.hideInTable)}function te(e=`id`){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function ne(e,t){if(!e||typeof e!=`object`)return t??e;if(!t||typeof t!=`object`)return e;let n=Array.isArray(e)?[...e]:{...e};return Object.keys(t).forEach(r=>{let i=t[r],a=e[r];typeof i==`object`&&i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp)&&typeof a==`object`&&a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp)?n[r]=ne(a,i):n[r]=i}),n}function F(e,t){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>e(...r),t)}}function re(e,t){let n=!1;return function(...r){n||(e(...r),n=!0,setTimeout(()=>n=!1,t))}}function ie(e,t=2){return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e)}async function I(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`),document.body.removeChild(t),!0}catch{return document.body.removeChild(t),!1}}}function L(e){return e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:typeof e==`object`?Object.keys(e).length===0:!1}function R(e,t,n){if(!t)return e;let r=t.split(`.`),i=e;for(let e of r){if(i==null)return n;i=i[e]}return i??n}function z(e,t,n){if(!t)return;let r=t.split(`.`),i=r.pop();if(!i)return;let a=e;for(let e of r)(!(e in a)||typeof a[e]!=`object`)&&(a[e]={}),a=a[e];a[i]=n}function ae(e,t){if(!t)return Array.from(new Set(e));let n=new Set;return e.filter(e=>{let r=e[t];return n.has(r)?!1:(n.add(r),!0)})}function oe(e,t){return e.reduce((e,n)=>{let r=typeof t==`function`?t(n):String(n[t]);return e[r]||(e[r]=[]),e[r].push(n),e},{})}function se(e){return new Promise(t=>setTimeout(t,e))}function ce(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]}function le(){return`#`+Math.floor(Math.random()*16777215).toString(16).padStart(6,`0`)}function ue(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function de(e){let t=new URLSearchParams;return Object.entries(e).forEach(([e,n])=>{n!=null&&t.append(e,String(n))}),t.toString()}var fe=(0,m.cva)(`inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function pe({className:e,variant:t,asChild:n=!1,...r}){return(0,h.jsx)(n?p.Slot:`span`,{"data-slot":`badge`,className:B(fe({variant:t}),e),...r})}function me({className:e,...t}){return(0,h.jsx)(g.Root,{"data-slot":`avatar`,className:B(`relative flex size-8 shrink-0 overflow-hidden rounded-full`,e),...t})}function he({className:e,...t}){return(0,h.jsx)(g.Image,{"data-slot":`avatar-image`,className:B(`aspect-square size-full`,e),...t})}function ge({className:e,...t}){return(0,h.jsx)(g.Fallback,{"data-slot":`avatar-fallback`,className:B(`bg-muted flex size-full items-center justify-center rounded-full`,e),...t})}function _e({className:e,...t}){return(0,h.jsx)(_.Root,{"data-slot":`switch`,className:B(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,h.jsx)(_.Thumb,{"data-slot":`switch-thumb`,className:B(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}function ve({className:e,value:t,...n}){return(0,h.jsx)(v.Root,{"data-slot":`progress`,className:B(`bg-primary/20 relative h-2 w-full overflow-hidden rounded-full`,e),...n,children:(0,h.jsx)(v.Indicator,{"data-slot":`progress-indicator`,className:`bg-primary h-full w-full flex-1 transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})})}var ye={text:{render:e=>e??`-`},textarea:{render:e=>e??`-`},number:{render:e=>e==null?`-`:new Intl.NumberFormat().format(e)},money:{render:(e,t)=>{if(e==null)return`-`;let n=t?.currency??`USD`;return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:n}).format(e)}},percent:{render:e=>e==null?`-`:`${e}%`},date:{render:(e,t)=>{if(!e)return`-`;let n=t?.format??`yyyy-MM-dd`;return(0,f.format)(new Date(e),n)}},dateTime:{render:(e,t)=>{if(!e)return`-`;let n=t?.format??`yyyy-MM-dd HH:mm:ss`;return(0,f.format)(new Date(e),n)}},dateRange:{render:(e,t)=>{if(!e||!Array.isArray(e)||e.length!==2)return`-`;let n=t?.format??`yyyy-MM-dd`;return`${(0,f.format)(new Date(e[0]),n)} ~ ${(0,f.format)(new Date(e[1]),n)}`}},select:{render:(e,t)=>(t?.options??[]).find(t=>t.value===e)?.label??e??`-`},tags:{render:(e,t)=>Array.isArray(e)?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,n)=>(0,h.jsx)(pe,{variant:t?.variant??`secondary`,children:e},n))}):`-`},avatar:{render:(e,t)=>{let n=t?.size??32;return(0,h.jsxs)(me,{style:{width:n,height:n},children:[(0,h.jsx)(he,{src:e,alt:t?.alt}),(0,h.jsx)(ge,{children:t?.fallback??`U`})]})}},image:{render:(e,t)=>{if(!e)return`-`;let n=t?.width??80,r=t?.height??80;return(0,h.jsx)(`img`,{src:e,alt:t?.alt??`image`,style:{width:n,height:r,objectFit:`cover`},className:`rounded`})}},switch:{render:(e,t)=>(0,h.jsx)(_e,{checked:!!e,disabled:t?.disabled??!0,onCheckedChange:t?.onChange})},code:{render:e=>e?(0,h.jsx)(`code`,{className:`relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm`,children:e}):`-`},fromNow:{render:e=>{if(!e)return`-`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/(1e3*60*60*24));return r===0?`Today`:r===1?`Yesterday`:r<7?`${r} days ago`:r<30?`${Math.floor(r/7)} weeks ago`:r<365?`${Math.floor(r/30)} months ago`:`${Math.floor(r/365)} years ago`}},status:{render:(e,t)=>{if(!e)return`-`;if(t?.valueEnum&&t.valueEnum[e]){let n=t.valueEnum[e];return(0,h.jsx)(pe,{variant:n.status||`default`,style:{backgroundColor:n.color,borderColor:n.color},children:n.text})}let n={success:{text:`Success`,variant:`default`},error:{text:`Error`,variant:`destructive`},warning:{text:`Warning`,variant:`secondary`},processing:{text:`Processing`,variant:`outline`},default:{text:e,variant:`default`}},r=n[e]||n.default;return(0,h.jsx)(pe,{variant:r.variant,children:r.text})}},progress:{render:(e,t)=>{if(e==null)return`-`;let n=Number(e),r=t?.showInfo??!0;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(ve,{value:n,className:`flex-1`}),r&&(0,h.jsxs)(`span`,{className:`text-sm text-muted-foreground min-w-12`,children:[n,`%`]})]})}},custom:{render:(e,t)=>t?.render?.(e)??e??`-`},email:{render:e=>e?(0,h.jsx)(`a`,{href:`mailto:${e}`,className:`text-blue-600 hover:text-blue-800 underline`,children:e}):`-`},phone:{render:e=>e?(0,h.jsx)(`a`,{href:`tel:${e}`,className:`text-blue-600 hover:text-blue-800 underline`,children:e}):`-`},url:{render:e=>e?(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 hover:text-blue-800 underline`,children:e}):`-`},color:{render:e=>e?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`w-4 h-4 rounded border`,style:{backgroundColor:e}}),(0,h.jsx)(`span`,{className:`font-mono text-sm`,children:e})]}):`-`},rate:{render:(e,t)=>{if(e==null)return`-`;let n=t?.max??5,r=Math.floor(e),i=e%1>=.5;return(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Array.from({length:n},(e,t)=>(0,h.jsx)(`span`,{className:B(`text-lg`,t<r?`text-yellow-400`:`text-gray-300`),children:`★`},t)),i&&(0,h.jsx)(`span`,{className:`text-lg text-yellow-400`,children:`☆`}),(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground ml-1`,children:e.toFixed(1)})]})}}};function be(e,t,n){let r=ye[e];return r?r.render(t,n):(console.warn(`Unknown valueType: ${e}`),t??`-`)}function xe(e,t,n){let r=ye[e];return r?.renderFormItem?r.renderFormItem(t,n):null}function Se(e,t){ye[e]=t}function B(...e){return(0,d.twMerge)((0,u.clsx)(e))}function Ce({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,h.jsx)(`table`,{"data-slot":`table`,className:B(`w-full caption-bottom text-sm`,e),...t})})}function we({className:e,...t}){return(0,h.jsx)(`thead`,{"data-slot":`table-header`,className:B(`[&_tr]:border-b`,e),...t})}function Te({className:e,...t}){return(0,h.jsx)(`tbody`,{"data-slot":`table-body`,className:B(`[&_tr:last-child]:border-0`,e),...t})}function Ee({className:e,...t}){return(0,h.jsx)(`tfoot`,{"data-slot":`table-footer`,className:B(`bg-muted/50 border-t font-medium [&>tr]:last:border-b-0`,e),...t})}function V({className:e,...t}){return(0,h.jsx)(`tr`,{"data-slot":`table-row`,className:B(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,e),...t})}function De({className:e,...t}){return(0,h.jsx)(`th`,{"data-slot":`table-head`,className:B(`text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function H({className:e,...t}){return(0,h.jsx)(`td`,{"data-slot":`table-cell`,className:B(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Oe({className:e,...t}){return(0,h.jsx)(`caption`,{"data-slot":`table-caption`,className:B(`text-muted-foreground mt-4 text-sm`,e),...t})}function ke({className:e,...t}){return(0,h.jsx)(y.Root,{"data-slot":`checkbox`,className:B(`peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,h.jsx)(y.Indicator,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none`,children:(0,h.jsx)(b.CheckIcon,{className:`size-3.5`})})})}function Ae({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`skeleton`,className:B(`bg-accent animate-pulse rounded-md`,e),...t})}function je({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card`,className:B(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm`,e),...t})}function Me({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-header`,className:B(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function Ne({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-title`,className:B(`leading-none font-semibold`,e),...t})}function Pe({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-description`,className:B(`text-muted-foreground text-sm`,e),...t})}function Fe({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-action`,className:B(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function Ie({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-content`,className:B(`px-6`,e),...t})}function Le({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-footer`,className:B(`flex items-center px-6 [.border-t]:pt-6`,e),...t})}var Re=(0,m.cva)(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function U({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,h.jsx)(r?p.Slot:`button`,{"data-slot":`button`,className:B(Re({variant:t,size:n,className:e})),...i})}function ze(e,t){switch(t.type){case`SET_LOADING`:return{...e,loading:t.payload};case`SET_DATA`:return{...e,data:t.payload.data,total:t.payload.total??e.total};case`SET_PAGINATION`:return{...e,current:t.payload.current??e.current,pageSize:t.payload.pageSize??e.pageSize};case`SET_FILTERS`:return{...e,filters:t.payload};case`SET_SORTER`:return{...e,sorter:t.payload};case`SET_SELECTION`:return{...e,selectedRowKeys:t.payload.keys,selectedRows:t.payload.rows};case`START_EDIT`:return{...e,editingKey:t.payload.key,editingRecord:t.payload.record};case`CANCEL_EDIT`:return{...e,editingKey:null,editingRecord:null};case`SAVE_EDIT`:return{...e,editingKey:null,editingRecord:null,data:e.data.map(e=>e.id===t.payload.id?t.payload:e)};case`RESET`:return{...e,current:1,filters:{},sorter:{},selectedRowKeys:[],selectedRows:[],editingKey:null,editingRecord:null};default:return e}}function Be(e){let{columns:t=[],dataSource:n,request:r,params:i={},postData:a,defaultData:o=[],loading:s,rowKey:u=`id`,rowSelection:d,pagination:f,onLoad:p,onLoadingChange:m,onRequestError:h}=e,g={loading:s??!1,data:n??o,total:n?.length??0,current:f===!1?1:f?.current??1,pageSize:f===!1?10:f?.pageSize??10,filters:{},sorter:{},selectedRowKeys:d===!1?[]:d?.selectedRowKeys??[],selectedRows:[],editingKey:null,editingRecord:null},[_,v]=(0,c.useReducer)(ze,g),y=(0,c.useRef)(null),[b,x]=c.default.useState([]),[S,C]=c.default.useState([]),[w,T]=c.default.useState({}),[E,D]=c.default.useState({}),O=(0,c.useCallback)(e=>typeof u==`function`?String(u(e)):String(e[u]),[u]),k=(0,c.useCallback)(async e=>{if(r){v({type:`SET_LOADING`,payload:!0}),m?.(!0);try{let t={current:e?.current??_.current,pageSize:e?.pageSize??_.pageSize,...i,..._.filters,..._.sorter},n=await r(t),o=n.data||[];a&&(o=a(o)),v({type:`SET_DATA`,payload:{data:o,total:n.total}}),e&&v({type:`SET_PAGINATION`,payload:e}),p?.(o)}catch(e){console.error(`ProTable request error:`,e),h?.(e)}finally{v({type:`SET_LOADING`,payload:!1}),m?.(!1)}}},[r,i,_.current,_.pageSize,_.filters,_.sorter,a,p,m,h]),A=(0,c.useMemo)(()=>t.filter(e=>!e.hideInTable).map(e=>({id:e.key||String(e.dataIndex),accessorKey:e.dataIndex,header:e.title,cell:e.render?({row:t,getValue:n})=>e.render?.(n(),t.original,t.index):({getValue:e})=>e(),enableSorting:!!e.sorter,filterFn:e.onFilter?((t,n,r)=>{let i=t.getValue(n);return e.onFilter(i,t.original)}):((e,t,n)=>{if(!n||n.length===0)return!0;let r=e.getValue(t);return n.includes(r)}),...e})),[t]),j=(0,l.useReactTable)({data:_.data,columns:A,state:{sorting:b,columnFilters:S,columnVisibility:w,rowSelection:E,pagination:{pageIndex:_.current-1,pageSize:_.pageSize}},onSortingChange:x,onColumnFiltersChange:C,onColumnVisibilityChange:T,onRowSelectionChange:D,getCoreRowModel:(0,l.getCoreRowModel)(),getFilteredRowModel:(0,l.getFilteredRowModel)(),getPaginationRowModel:(0,l.getPaginationRowModel)(),getSortedRowModel:(0,l.getSortedRowModel)(),getRowId:O,manualPagination:!!r,pageCount:Math.ceil(_.total/_.pageSize),columnResizeMode:`onChange`}),M=(0,c.useCallback)((e,t)=>{r?k({current:e,pageSize:t}):v({type:`SET_PAGINATION`,payload:{current:e,pageSize:t}}),f!==!1&&f?.onChange?.(e,t)},[r,k,f]),N=(0,c.useCallback)(e=>{v({type:`SET_FILTERS`,payload:e}),r&&k({current:1})},[r,k]),ee=(0,c.useCallback)(()=>{v({type:`RESET`}),r&&k({current:1})},[r,k]);(0,c.useEffect)(()=>{if(r&&b.length>0){let e=b[0].id,t=b[0].desc?`desc`:`asc`;v({type:`SET_SORTER`,payload:{field:e,order:t}}),k({current:1})}},[b,r]);let P={reload:async(e=!1)=>{await k(e?{current:1}:void 0)},reloadAndRest:async()=>{v({type:`RESET`}),await k({current:1})},reset:()=>{v({type:`RESET`})},clearSelected:()=>{D({}),v({type:`SET_SELECTION`,payload:{keys:[],rows:[]}})},startEditable:e=>{let t=_.data.find(t=>O(t)===String(e));return t?(v({type:`START_EDIT`,payload:{key:e,record:t}}),!0):!1},cancelEditable:e=>(v({type:`CANCEL_EDIT`}),!0),saveEditable:(e,t)=>(v({type:`SAVE_EDIT`,payload:t}),!0),getRowData:e=>_.data.find(t=>O(t)===String(e)),getTableData:()=>_.data,setTableData:e=>{v({type:`SET_DATA`,payload:{data:e}})}};return(0,c.useEffect)(()=>{y.current&&Object.assign(y.current,P)}),(0,c.useEffect)(()=>{r&&!n&&k()},[]),(0,c.useEffect)(()=>{n&&v({type:`SET_DATA`,payload:{data:n,total:n.length}})},[n]),{table:j,state:_,dispatch:v,actions:P,handlers:{handlePaginationChange:M,handleSearch:N,handleReset:ee}}}function Ve(e){let{columns:t,rowSelection:n,draggable:r,editable:i}=e,[a,o]=(0,c.useState)(()=>t.filter(e=>!e.hideInTable).map(e=>e.key||String(e.dataIndex))),[s,l]=(0,c.useState)({}),u=(0,c.useMemo)(()=>t.filter(e=>!e.hideInSearch&&(e.search===!0||typeof e.search==`object`)),[t]);return{tableColumns:(0,c.useMemo)(()=>{let e=[];return r&&e.push({id:`__drag__`,header:``,cell:()=>null,size:40,enableSorting:!1,enableHiding:!1}),n&&e.push({id:`__select__`,header:()=>null,cell:()=>null,size:40,enableSorting:!1,enableHiding:!1}),t.forEach(t=>{if(t.hideInTable)return;let n=t.key||String(t.dataIndex),r=s[n]||{},a={id:n,accessorKey:t.dataIndex,header:t.title,cell:({getValue:e,row:n})=>{let a=e();return i&&t.editable&&(typeof t.editable==`function`?t.editable(n.original):t.editable)?a:t.render?t.render(a,n.original,n.index):t.valueType?be(t.valueType,a,{...t,...r}):a},enableSorting:!!t.sorter,enableHiding:!0,size:t.width,...r};e.push(a)}),i&&e.push({id:`__actions__`,header:`Actions`,cell:()=>null,size:120,enableSorting:!1,enableHiding:!1}),e},[t,n,r,i,s]),searchColumns:u,visibleColumns:a,setVisibleColumns:o,columnSettings:s,updateColumnSettings:(e,t)=>{l(n=>({...n,[e]:{...n[e],...t}}))}}}function W({className:e,type:t,...n}){return(0,h.jsx)(`input`,{type:t,"data-slot":`input`,className:B(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...n})}function G({...e}){return(0,h.jsx)(x.Root,{"data-slot":`dropdown-menu`,...e})}function He({...e}){return(0,h.jsx)(x.Portal,{"data-slot":`dropdown-menu-portal`,...e})}function K({...e}){return(0,h.jsx)(x.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function q({className:e,sideOffset:t=4,...n}){return(0,h.jsx)(x.Portal,{children:(0,h.jsx)(x.Content,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md`,e),...n})})}function Ue({...e}){return(0,h.jsx)(x.Group,{"data-slot":`dropdown-menu-group`,...e})}function J({className:e,inset:t,variant:n=`default`,...r}){return(0,h.jsx)(x.Item,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:B(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive! [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function We({className:e,children:t,checked:n,...r}){return(0,h.jsxs)(x.CheckboxItem,{"data-slot":`dropdown-menu-checkbox-item`,className:B(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,h.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,h.jsx)(x.ItemIndicator,{children:(0,h.jsx)(b.CheckIcon,{className:`size-4`})})}),t]})}function Ge({...e}){return(0,h.jsx)(x.RadioGroup,{"data-slot":`dropdown-menu-radio-group`,...e})}function Ke({className:e,children:t,...n}){return(0,h.jsxs)(x.RadioItem,{"data-slot":`dropdown-menu-radio-item`,className:B(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,h.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,h.jsx)(x.ItemIndicator,{children:(0,h.jsx)(b.CircleIcon,{className:`size-2 fill-current`})})}),t]})}function qe({className:e,inset:t,...n}){return(0,h.jsx)(x.Label,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:B(`px-2 py-1.5 text-sm font-medium data-inset:pl-8`,e),...n})}function Y({className:e,...t}){return(0,h.jsx)(x.Separator,{"data-slot":`dropdown-menu-separator`,className:B(`bg-border -mx-1 my-1 h-px`,e),...t})}function Je({className:e,...t}){return(0,h.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:B(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ye({...e}){return(0,h.jsx)(x.Sub,{"data-slot":`dropdown-menu-sub`,...e})}function Xe({className:e,inset:t,children:n,...r}){return(0,h.jsxs)(x.SubTrigger,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:B(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,h.jsx)(b.ChevronRightIcon,{className:`ml-auto size-4`})]})}function Ze({className:e,...t}){return(0,h.jsx)(x.SubContent,{"data-slot":`dropdown-menu-sub-content`,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg`,e),...t})}function Qe({delayDuration:e=0,...t}){return(0,h.jsx)(S.Provider,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function X({...e}){return(0,h.jsx)(Qe,{children:(0,h.jsx)(S.Root,{"data-slot":`tooltip`,...e})})}function Z({...e}){return(0,h.jsx)(S.Trigger,{"data-slot":`tooltip-trigger`,...e})}function Q({className:e,sideOffset:t=0,children:n,...r}){return(0,h.jsx)(S.Portal,{children:(0,h.jsxs)(S.Content,{"data-slot":`tooltip-content`,sideOffset:t,className:B(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,h.jsx)(S.Arrow,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}const $e={search:{searchText:`Search`,resetText:`Reset`,submitText:`Submit`,expandText:`Expand`,collapseText:`Collapse`,selectPlaceholder:`Select`,inputPlaceholder:`Enter`},pagination:{total:(e,t)=>`Page ${t[0]}-${t[1]} of ${e}`,items:`items`,page:`Page`,of:`of`,showTotal:`Show`},toolbar:{reload:`Reload`,density:`Density`,columnSetting:`Column Setting`,fullScreen:`Full Screen`,exitFullScreen:`Exit Full Screen`,compact:`Compact`,default:`Default`,comfortable:`Comfortable`,searchPlaceholder:`Search...`},columnSetting:{title:`Column Setting`,fixedLeft:`Fixed Left`,fixedRight:`Fixed Right`,noFixed:`No Fixed`,show:`Show`,hide:`Hide`,reset:`Reset`},batchActions:{selected:`selected`,clear:`Clear`,delete:`Delete`,export:`Export`},editable:{save:`Save`,cancel:`Cancel`,edit:`Edit`,delete:`Delete`},common:{confirm:`Confirm`,cancel:`Cancel`,noData:`No data available`,loading:`Loading...`,selectAll:`Select all`,copySuccess:`Copied successfully`}};var et=(0,c.createContext)(void 0);function tt({locale:e,children:t}){let n=c.default.useMemo(()=>{let t=(e,n)=>{let r={...e};for(let i in n)n[i]&&typeof n[i]==`object`&&!Array.isArray(n[i])?r[i]=t(e[i]||{},n[i]):r[i]=n[i];return r};return t($e,e||{})},[e]);return(0,h.jsx)(et.Provider,{value:{locale:n},children:t})}function nt(){let e=(0,c.useContext)(et);if(e===void 0)throw Error(`useLocale must be used within a LocaleProvider`);return e.locale}function rt({id:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=(0,T.useSortable)({id:e}),c={transform:E.CSS.Transform.toString(a),transition:o,opacity:s?.6:1};return(0,h.jsxs)(`div`,{ref:i,style:c,className:`flex items-center`,children:[(0,h.jsx)(`div`,{...r,...n,role:`button`,tabIndex:0,"aria-label":`Drag column`,className:`mr-2 p-1 rounded hover:bg-muted/20 cursor-move flex items-center justify-center`,children:(0,h.jsx)(C.IconGripVertical,{className:`h-4 w-4`})}),(0,h.jsx)(`div`,{className:`flex-1`,children:t})]})}function it({table:e,columns:t,visibleColumns:n,onVisibleChange:r,fixedColumns:i={},onFixedChange:a,onOrderChange:o}){let s=nt(),l=t.filter(e=>e.enableHiding!==!1&&!e.hideInTable),u=l.map(e=>e.key||String(e.dataIndex)),[d,f]=(0,c.useState)(()=>({...i||{}}));(0,c.useEffect)(()=>{f({...i||{}})},[i]);let p=(t,i)=>{r(i?Array.from(new Set([...n,t])):n.filter(e=>e!==t));try{if(e&&typeof e.getAllColumns==`function`){let n=e.getAllColumns().filter(e=>e.accessorFn!==void 0&&e.getCanHide()).find(e=>e.id===t);n&&typeof n.toggleVisibility==`function`&&n.toggleVisibility(i)}}catch{}},m=(e,t)=>{f(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),a?.(e,t)};return(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:(0,h.jsx)(C.IconSettings,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{align:`end`,className:`w-64`,children:[(0,h.jsx)(qe,{children:s.columnSetting.title}),(0,h.jsx)(Y,{}),(0,h.jsx)(`div`,{className:`max-h-96 overflow-y-auto`,children:(0,h.jsx)(w.DndContext,{collisionDetection:w.closestCenter,modifiers:[D.restrictToVerticalAxis],onDragEnd:e=>{let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=l.findIndex(e=>(e.key||String(e.dataIndex))===n.id),a=l.findIndex(e=>(e.key||String(e.dataIndex))===r.id);if(i!==-1&&a!==-1&&typeof o==`function`){let e=[...l],[n]=e.splice(i,1);e.splice(a,0,n);let r=[],s=new Map(e.map(e=>[e.key||String(e.dataIndex),e]));for(let n of t){let t=n.key||String(n.dataIndex);if(s.has(t)){let t=e.shift();r.push(t)}else r.push(n)}e.length>0&&r.push(...e),o(r)}},autoScroll:{enabled:!1},children:(0,h.jsx)(T.SortableContext,{items:u,strategy:T.verticalListSortingStrategy,children:l.map(e=>{let t=e.key||String(e.dataIndex),r=n.includes(t),i=d?.[t]??void 0;return(0,h.jsx)(rt,{id:t,children:(0,h.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5 hover:bg-muted`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:e=>{e.stopPropagation(),p(t,!r)},"aria-pressed":r,title:r?s.columnSetting.hide:s.columnSetting.show,children:r?(0,h.jsx)(C.IconEye,{className:`h-4 w-4`}):(0,h.jsx)(C.IconEyeOff,{className:`h-4 w-4`})}),(0,h.jsx)(`span`,{className:B(`text-sm`,!r&&`text-muted-foreground line-through`),children:e.title??t})]}),(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,children:i?(0,h.jsx)(C.IconPin,{className:`h-4 w-4`}):(0,h.jsx)(C.IconPinEnd,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{side:`left`,children:[(0,h.jsx)(J,{onClick:()=>m(t,void 0),children:s.columnSetting.noFixed}),(0,h.jsx)(J,{onClick:()=>m(t,`left`),children:s.columnSetting.fixedLeft}),(0,h.jsx)(J,{onClick:()=>m(t,`right`),children:s.columnSetting.fixedRight})]})]})]})},t)})})})}),(0,h.jsx)(Y,{}),(0,h.jsxs)(`div`,{className:`flex gap-2 p-2`,children:[(0,h.jsxs)(U,{size:`sm`,variant:`outline`,className:`flex-1`,onClick:()=>r(u),children:[s.columnSetting.show,` All`]}),(0,h.jsxs)(U,{size:`sm`,variant:`outline`,className:`flex-1`,onClick:()=>r([]),children:[s.columnSetting.hide,` All`]})]})]})]})}function at({title:e,subTitle:t,search:n,actions:r=[],settings:i=!0,filter:a,table:o,columns:s,loading:l,onReload:u,fullScreen:d=!1,onFullScreenChange:f,density:p=`middle`,onDensityChange:m,visibleColumns:g=[],onVisibleColumnsChange:_,columnSettings:v,onColumnSettingsChange:y}){let x=nt(),[S,C]=c.default.useState(``),w=e=>{e.preventDefault(),typeof n==`object`&&n.onSearch&&n.onSearch(S)},T=e=>{e.key===`Enter`&&(e.preventDefault(),typeof n==`object`&&n.onSearch&&n.onSearch(S))},E=Array.isArray(i)?i:i===!0?[`columnSettings`,`density`,`reload`,`fullScreen`]:[];return(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 py-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e&&(0,h.jsx)(`h3`,{className:`text-lg font-semibold leading-none`,children:e}),t&&(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:t})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,h.jsxs)(`form`,{onSubmit:w,className:`relative`,children:[(0,h.jsx)(W,{placeholder:typeof n==`object`?n.placeholder:x.toolbar.searchPlaceholder,value:S,onChange:e=>C(e.target.value),onKeyDown:T,className:`h-8 w-[200px] pr-8`}),(0,h.jsx)(b.Search,{className:`absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`})]}),r.map((e,t)=>(0,h.jsx)(c.default.Fragment,{children:e},t)),E.length>0&&(0,h.jsx)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:(0,h.jsxs)(Qe,{children:[E.includes(`reload`)&&(0,h.jsxs)(X,{children:[(0,h.jsx)(Z,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:u,disabled:l,children:(0,h.jsx)(b.RotateCw,{className:`h-4 w-4 ${l?`animate-spin`:``}`})})}),(0,h.jsx)(Q,{children:(0,h.jsx)(`p`,{children:x.toolbar.reload})})]}),E.includes(`density`)&&(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:(0,h.jsx)(b.Settings2,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{align:`end`,children:[(0,h.jsx)(qe,{children:x.toolbar.density}),(0,h.jsx)(Y,{}),(0,h.jsx)(We,{checked:p===`small`,onCheckedChange:()=>m?.(`small`),children:x.toolbar.compact}),(0,h.jsx)(We,{checked:p===`middle`,onCheckedChange:()=>m?.(`middle`),children:x.toolbar.default}),(0,h.jsx)(We,{checked:p===`large`,onCheckedChange:()=>m?.(`large`),children:x.toolbar.comfortable})]})]}),E.includes(`columnSettings`)&&_&&(0,h.jsx)(it,{table:o,columns:s,visibleColumns:g,onVisibleChange:_,fixedColumns:v?.fixed||{},onFixedChange:(e,t)=>y?.(e,{fixed:t}),onOrderChange:e=>y?.(`order`,e)}),E.includes(`fullScreen`)&&(0,h.jsxs)(X,{children:[(0,h.jsx)(Z,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>f?.(!d),children:d?(0,h.jsx)(b.Minimize2,{className:`h-4 w-4`}):(0,h.jsx)(b.Maximize2,{className:`h-4 w-4`})})}),(0,h.jsx)(Q,{children:(0,h.jsx)(`p`,{children:d?x.toolbar.exitFullScreen:x.toolbar.fullScreen})})]})]})})]})]}),a&&(0,h.jsx)(`div`,{className:`border-t pt-3`,children:a})]})}function ot({column:e,value:t=[],onChange:n,onClear:r}){let[i,a]=(0,c.useState)(!1),o=Array.isArray(t)?t:[],s=(e,t)=>{t?n?.([...o,e]):n?.(o.filter(t=>t!==e))},l=()=>{n?.([]),r?.(),a(!1)},u=o.length>0;return(0,h.jsxs)(G,{open:i,onOpenChange:a,children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`sm`,className:B(`h-6 w-6 p-0 hover:bg-muted`,u&&`bg-primary/10 text-primary`),children:(0,h.jsx)(b.Filter,{className:`h-3 w-3`})})}),(0,h.jsx)(q,{align:`start`,className:`w-48`,children:(0,h.jsxs)(`div`,{className:`p-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,h.jsxs)(`span`,{className:`text-sm font-medium`,children:[`筛选 `,e.title]}),u&&(0,h.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:l,children:(0,h.jsx)(b.X,{className:`h-3 w-3`})})]}),(0,h.jsx)(`div`,{className:`space-y-1 max-h-48 overflow-y-auto`,children:e.filters?.map(t=>(0,h.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,h.jsx)(ke,{id:`filter-${e.key||e.dataIndex}-${t.value}`,checked:o.includes(t.value),onCheckedChange:e=>s(t.value,!!e)}),(0,h.jsx)(`label`,{htmlFor:`filter-${e.key||e.dataIndex}-${t.value}`,className:`text-sm cursor-pointer flex-1`,children:t.text})]},String(t.value)))})]})})]})}function st({...e}){return(0,h.jsx)(O.Root,{"data-slot":`select`,...e})}function ct({...e}){return(0,h.jsx)(O.Group,{"data-slot":`select-group`,...e})}function lt({...e}){return(0,h.jsx)(O.Value,{"data-slot":`select-value`,...e})}function ut({className:e,size:t=`default`,children:n,...r}){return(0,h.jsxs)(O.Trigger,{"data-slot":`select-trigger`,"data-size":t,className:B(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,h.jsx)(O.Icon,{asChild:!0,children:(0,h.jsx)(b.ChevronDownIcon,{className:`size-4 opacity-50`})})]})}function dt({className:e,children:t,position:n=`popper`,align:r=`center`,...i}){return(0,h.jsx)(O.Portal,{children:(0,h.jsxs)(O.Content,{"data-slot":`select-content`,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,h.jsx)(mt,{}),(0,h.jsx)(O.Viewport,{className:B(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,h.jsx)(ht,{})]})})}function ft({className:e,...t}){return(0,h.jsx)(O.Label,{"data-slot":`select-label`,className:B(`text-muted-foreground px-2 py-1.5 text-xs`,e),...t})}function $({className:e,children:t,...n}){return(0,h.jsxs)(O.Item,{"data-slot":`select-item`,className:B(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,h.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,h.jsx)(O.ItemIndicator,{children:(0,h.jsx)(b.CheckIcon,{className:`size-4`})})}),(0,h.jsx)(O.ItemText,{children:t})]})}function pt({className:e,...t}){return(0,h.jsx)(O.Separator,{"data-slot":`select-separator`,className:B(`bg-border pointer-events-none -mx-1 my-1 h-px`,e),...t})}function mt({className:e,...t}){return(0,h.jsx)(O.ScrollUpButton,{"data-slot":`select-scroll-up-button`,className:B(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,h.jsx)(b.ChevronUpIcon,{className:`size-4`})})}function ht({className:e,...t}){return(0,h.jsx)(O.ScrollDownButton,{"data-slot":`select-scroll-down-button`,className:B(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,h.jsx)(b.ChevronDownIcon,{className:`size-4`})})}var gt=768;function _t(){let[e,t]=c.useState(void 0);return c.useEffect(()=>{let e=window.matchMedia(`(max-width: ${gt-1}px)`),n=()=>{t(window.innerWidth<gt)};return e.addEventListener(`change`,n),t(window.innerWidth<gt),()=>e.removeEventListener(`change`,n)},[]),!!e}function vt({current:e=1,pageSize:t=10,total:n=0,showSizeChanger:r=!0,showQuickJumper:i=!1,showTotal:a,pageSizeOptions:o=[`10`,`20`,`50`,`100`],size:s=`default`,simple:c=!1,disabled:l=!1,onChange:u,onShowSizeChange:d,onPaginationChange:f}){let p=nt(),m=_t(),g=Math.max(1,Math.ceil(n/t)),_=Math.min(Math.max(e,1),g),v=l||_<=1,y=l||_>=g,b=e=>{let n=Math.min(Math.max(e,1),g);n!==_&&(u?.(n,t),f?.(n,t))},x=e=>{let t=Number(e);d?.(_,t),f?.(1,t)};if(c||m)return(0,h.jsxs)(`div`,{className:B(`flex w-full flex-col gap-2 rounded-lg border border-border/60 bg-card/60 p-3`,!m&&c&&`w-auto flex-row items-center justify-center gap-2 border-none bg-transparent p-0`),children:[(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,m?`justify-between`:`justify-center`),children:[(0,h.jsx)(U,{variant:`outline`,size:s===`small`||m?`sm`:`default`,onClick:()=>b(_-1),disabled:v,children:(0,h.jsx)(C.IconChevronLeft,{className:`h-4 w-4`})}),(0,h.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[p.pagination.page,` `,_,` `,p.pagination.of,` `,g]}),(0,h.jsx)(U,{variant:`outline`,size:s===`small`||m?`sm`:`default`,onClick:()=>b(_+1),disabled:y,children:(0,h.jsx)(C.IconChevronRight,{className:`h-4 w-4`})})]}),r&&!c&&(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md bg-background/80 px-2 py-1 text-xs text-muted-foreground`,children:[(0,h.jsx)(`span`,{children:p.pagination.showTotal}),(0,h.jsxs)(st,{value:String(t),onValueChange:x,disabled:l,children:[(0,h.jsx)(ut,{size:`sm`,className:`h-8 w-[110px]`,id:`rows-per-page-mobile`,children:(0,h.jsx)(lt,{placeholder:t})}),(0,h.jsx)(dt,{children:o.map(e=>(0,h.jsx)($,{value:e,children:e},e))})]})]})]});let S=(_-1)*t+1,w=Math.min(_*t,n);return(0,h.jsxs)(`div`,{className:B(`px-4 py-3`,m?`flex flex-col gap-3 rounded-lg border border-border/60 bg-card/60`:`flex items-center justify-between`),children:[(0,h.jsx)(`div`,{className:`flex flex-1 items-center gap-4`,children:a?(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:a(n,[S,w])}):(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:p.pagination.total?.(n,[S,w])})}),(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,m&&`flex-wrap justify-between gap-3`),children:[r&&(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,m&&`order-2 w-full justify-between`),children:[(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:p.pagination.showTotal}),(0,h.jsxs)(st,{value:String(t),onValueChange:x,disabled:l,children:[(0,h.jsx)(ut,{size:`sm`,className:B(`h-8 w-20`,m&&`w-[120px]`),id:`rows-per-page`,children:(0,h.jsx)(lt,{})}),(0,h.jsx)(dt,{children:o.map(e=>(0,h.jsx)($,{value:e,children:e},e))})]}),(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:p.pagination.items})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(1),disabled:v,children:(0,h.jsx)(C.IconChevronsLeft,{className:`h-4 w-4`})}),(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(_-1),disabled:v,children:(0,h.jsx)(C.IconChevronLeft,{className:`h-4 w-4`})}),(0,h.jsxs)(`span`,{className:`px-2 text-sm`,children:[p.pagination.page,` `,_,` `,p.pagination.of,` `,g]}),(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(_+1),disabled:y,children:(0,h.jsx)(C.IconChevronRight,{className:`h-4 w-4`})}),(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(g),disabled:y,children:(0,h.jsx)(C.IconChevronsRight,{className:`h-4 w-4`})})]}),i&&(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:p.pagination.page}),(0,h.jsx)(`input`,{type:`number`,min:1,max:g,className:`h-8 w-[50px] rounded border px-2 text-center text-sm`,onKeyDown:e=>{if(e.key===`Enter`){let t=Number(e.target.value);t>=1&&t<=g&&b(t)}},disabled:l})]})]})]})}function yt({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,formatters:a,components:o,...s}){let c=(0,k.getDefaultClassNames)();return(0,h.jsx)(k.DayPicker,{showOutsideDays:n,className:B(`bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:e=>e.toLocaleString(`default`,{month:`short`}),...a},classNames:{root:B(`w-fit`,c.root),months:B(`flex gap-4 flex-col md:flex-row relative`,c.months),month:B(`flex flex-col w-full gap-4`,c.month),nav:B(`flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between`,c.nav),button_previous:B(Re({variant:i}),`size-(--cell-size) aria-disabled:opacity-50 p-0 select-none`,c.button_previous),button_next:B(Re({variant:i}),`size-(--cell-size) aria-disabled:opacity-50 p-0 select-none`,c.button_next),month_caption:B(`flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)`,c.month_caption),dropdowns:B(`w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5`,c.dropdowns),dropdown_root:B(`relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md`,c.dropdown_root),dropdown:B(`absolute bg-popover inset-0 opacity-0`,c.dropdown),caption_label:B(`select-none font-medium`,r===`label`?`text-sm`:`rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5`,c.caption_label),table:`w-full border-collapse`,weekdays:B(`flex`,c.weekdays),weekday:B(`text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none`,c.weekday),week:B(`flex w-full mt-2`,c.week),week_number_header:B(`select-none w-(--cell-size)`,c.week_number_header),week_number:B(`text-[0.8rem] select-none text-muted-foreground`,c.week_number),day:B(`relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none`,c.day),range_start:B(`rounded-l-md bg-accent`,c.range_start),range_middle:B(`rounded-none`,c.range_middle),range_end:B(`rounded-r-md bg-accent`,c.range_end),today:B(`bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none`,c.today),outside:B(`text-muted-foreground aria-selected:text-muted-foreground`,c.outside),disabled:B(`text-muted-foreground opacity-50`,c.disabled),hidden:B(`invisible`,c.hidden),...t},components:{Root:({className:e,rootRef:t,...n})=>(0,h.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:B(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,h.jsx)(b.ChevronLeftIcon,{className:B(`size-4`,e),...n}):t===`right`?(0,h.jsx)(b.ChevronRightIcon,{className:B(`size-4`,e),...n}):(0,h.jsx)(b.ChevronDownIcon,{className:B(`size-4`,e),...n}),DayButton:bt,WeekNumber:({children:e,...t})=>(0,h.jsx)(`td`,{...t,children:(0,h.jsx)(`div`,{className:`flex size-(--cell-size) items-center justify-center text-center`,children:e})}),...o},...s})}function bt({className:e,day:t,modifiers:n,...r}){let i=(0,k.getDefaultClassNames)(),a=c.useRef(null);return c.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),(0,h.jsx)(U,{ref:a,variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:B(`data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70`,i.day,e),...r})}function xt({...e}){return(0,h.jsx)(A.Root,{"data-slot":`popover`,...e})}function St({...e}){return(0,h.jsx)(A.Trigger,{"data-slot":`popover-trigger`,...e})}function Ct({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,h.jsx)(A.Portal,{children:(0,h.jsx)(A.Content,{"data-slot":`popover-content`,align:t,sideOffset:n,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden`,e),...r})})}function wt({...e}){return(0,h.jsx)(A.Anchor,{"data-slot":`popover-anchor`,...e})}function Tt({value:e,onChange:t,placeholder:n=`Pick a date`,className:r,disabled:i,fromDate:a,toDate:o,formatStr:s=`PPP`,align:c=`start`,sideOffset:l=4}){return(0,h.jsxs)(xt,{children:[(0,h.jsx)(St,{asChild:!0,children:(0,h.jsxs)(U,{variant:`outline`,className:B(`h-8 w-full justify-start text-left font-normal`,!e&&`text-muted-foreground`,r),disabled:i,children:[(0,h.jsx)(b.Calendar,{className:`mr-2 h-4 w-4`}),e?(0,f.format)(e,s):(0,h.jsx)(`span`,{children:n})]})}),(0,h.jsx)(Ct,{className:`w-auto p-0`,align:c,sideOffset:l,children:(0,h.jsx)(yt,{mode:`single`,selected:e,onSelect:t,disabled:i,fromDate:a,toDate:o,initialFocus:!0})})]})}function Et({value:e,onChange:t,placeholder:n=`Pick a date range`,className:r,disabled:i,fromDate:a,toDate:o,formatStr:s=`LLL dd, y`,align:c=`start`,sideOffset:l=4,numberOfMonths:u=2}){return(0,h.jsx)(`div`,{className:B(`w-full`,r),children:(0,h.jsxs)(xt,{children:[(0,h.jsx)(St,{asChild:!0,children:(0,h.jsxs)(U,{id:`date`,variant:`outline`,className:B(`h-8 w-full justify-start text-left font-normal`,!e&&`text-muted-foreground`),disabled:i,children:[(0,h.jsx)(b.Calendar,{className:`mr-2 h-4 w-4`}),e?.from?e.to?(0,h.jsxs)(h.Fragment,{children:[(0,f.format)(e.from,s),` -`,` `,(0,f.format)(e.to,s)]}):(0,f.format)(e.from,s):(0,h.jsx)(`span`,{children:n})]})}),(0,h.jsx)(Ct,{className:`w-auto p-0`,align:c,sideOffset:l,children:(0,h.jsx)(yt,{initialFocus:!0,mode:`range`,defaultMonth:e?.from,selected:e,onSelect:t,numberOfMonths:u,disabled:i,fromDate:a,toDate:o})})]})})}function Dt({className:e,...t}){return(0,h.jsx)(j.Root,{"data-slot":`label`,className:B(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Ot({columns:e,onSearch:t,onReset:n,loading:r,filterType:i=`query`,searchText:a,resetText:o,submitText:s,defaultCollapsed:l=!0,collapsed:u,onCollapse:d,optionRender:f}){let p=nt(),{control:m,register:g,handleSubmit:_,reset:v,watch:y}=(0,M.useForm)({defaultValues:{}}),[x,S]=(0,c.useState)(u??l),C=u!==void 0,w=C?u:x;(0,c.useEffect)(()=>{C&&S(u??l)},[u]);let T=()=>{C||S(!x),d?.(!w)},E=e=>{t?.(e)},D=()=>{v({}),n?.()},O=e=>{let t=e.key||String(e.dataIndex);switch(e.valueType){case`select`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:n})=>(0,h.jsxs)(st,{value:n.value,onValueChange:e=>n.onChange(e),children:[(0,h.jsx)(ut,{className:`h-8 w-full`,children:(0,h.jsx)(lt,{placeholder:`${p.search.selectPlaceholder} ${e.title}`})}),(0,h.jsx)(dt,{children:e.valueEnum?Object.entries(e.valueEnum).map(([e,n])=>(0,h.jsx)($,{value:e,children:n.text},`${t}-${e}`)):e.filters?.map(e=>(0,h.jsx)($,{value:e.value,children:e.text},`${t}-filter-${String(e.value)}`))})]})});case`date`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(Tt,{value:t.value,onChange:e=>t.onChange(e),className:`h-8 w-full`,placeholder:`${p.search.selectPlaceholder} ${e.title}`,formatStr:`PP`})});case`dateTime`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(Tt,{value:t.value,onChange:e=>t.onChange(e),className:`h-8 w-full`,placeholder:`${p.search.selectPlaceholder} ${e.title}`,formatStr:`PPp`})});case`dateRange`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(Et,{value:t.value,onChange:e=>t.onChange(e),className:`w-full`,placeholder:`${p.search.selectPlaceholder} ${e.title} range`,numberOfMonths:2})});case`number`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(W,{type:`number`,value:t.value??``,onChange:e=>t.onChange(e.target.value?Number(e.target.value):void 0),placeholder:`${p.search.inputPlaceholder} ${e.title}`,className:`h-8 w-full`})});case`switch`:return(0,h.jsx)(M.Controller,{control:m,name:t,defaultValue:!1,render:({field:e})=>(0,h.jsx)(`div`,{className:`flex items-center h-8`,children:(0,h.jsx)(_e,{id:t,checked:!!e.value,onCheckedChange:t=>e.onChange(t)})})});default:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(W,{value:t.value??``,onChange:e=>t.onChange(e.target.value),placeholder:`${p.search.inputPlaceholder} ${e.title}`,className:`h-8 w-full`})})}};if(i===`light`)return(0,h.jsxs)(`form`,{className:`flex items-center gap-2 px-4 py-2`,onSubmit:_(E),children:[(0,h.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,h.jsx)(W,{placeholder:a||p.search.searchText,...g(`keyword`),onKeyDown:e=>{e.key},className:`h-8 pr-8`}),(0,h.jsx)(b.Search,{className:`absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`})]}),(0,h.jsx)(U,{size:`sm`,type:`submit`,disabled:r,children:s||p.search.submitText}),(0,h.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{D()},children:o||p.search.resetText})]});let k=e,A=e.length>3,j=[(0,h.jsxs)(U,{size:`sm`,onClick:_(E),disabled:r,children:[(0,h.jsx)(b.Search,{className:`mr-1 h-4 w-4`}),s||p.search.submitText]},`search`),(0,h.jsxs)(U,{size:`sm`,variant:`outline`,onClick:D,children:[(0,h.jsx)(b.RotateCw,{className:`mr-1 h-4 w-4`}),o||p.search.resetText]},`reset`)];A&&j.push((0,h.jsx)(U,{size:`sm`,variant:`ghost`,onClick:T,children:w?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(b.ChevronDown,{className:`mr-1 h-4 w-4`}),p.search.expandText]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(b.ChevronUp,{className:`mr-1 h-4 w-4`}),p.search.collapseText]})},`collapse`));let N=f?f({collapsed:w},y(),j):j;return(0,h.jsxs)(`form`,{className:`border-b bg-muted/30 px-4 py-3 overflow-visible`,onSubmit:_(E),children:[(0,h.jsx)(`div`,{className:B(`grid gap-4 transition-all duration-300 ease-in-out`,`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,w?`max-h-15`:`max-h-[500px]`),style:{overflow:w?`clip`:`visible`},children:k.map(e=>{let t=e.key||String(e.dataIndex),n=e.formItemProps?.required;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,h.jsxs)(Dt,{htmlFor:t,className:`text-sm font-medium`,children:[e.title,n&&(0,h.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,h.jsx)(`div`,{className:`w-full min-w-0`,children:e.renderFormItem?e.renderFormItem(y()[t],{}):O(e)})]},t)})}),(0,h.jsx)(`div`,{className:`mt-3 flex items-center justify-end gap-2`,children:N})]})}var kt=(0,m.cva)(`relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90`}},defaultVariants:{variant:`default`}});function At({className:e,variant:t,...n}){return(0,h.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:B(kt({variant:t}),e),...n})}function jt({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`alert-title`,className:B(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),...t})}function Mt({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`alert-description`,className:B(`text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed`,e),...t})}function Nt({selectedCount:e,selectedRows:t,onDelete:n,onExport:r,onExportExcel:i,onExportCSV:a,onEmail:o,onArchive:s,customActions:c=[],disabled:l=!1,className:u}){if(e===0)return null;let d=()=>{n&&t.length>0&&n(t)},f=()=>{r&&t.length>0&&r(t)},p=()=>{i&&t.length>0&&i(t)},m=()=>{a&&t.length>0&&a(t)},g=()=>{o&&t.length>0&&o(t)},_=()=>{s&&t.length>0&&s(t)},v=n||r||i||a||o||s,y=c.length>0;return(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,u),children:[v&&(0,h.jsxs)(h.Fragment,{children:[n&&(0,h.jsxs)(U,{variant:`destructive`,size:`sm`,onClick:d,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Trash2,{className:`h-3 w-3 mr-1`}),`删除 (`,e,`)`]}),r&&(0,h.jsxs)(U,{variant:`outline`,size:`sm`,onClick:f,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Download,{className:`h-3 w-3 mr-1`}),`导出`]}),(i||a)&&(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsxs)(U,{variant:`outline`,size:`sm`,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.FileText,{className:`h-3 w-3 mr-1`}),`导出格式`]})}),(0,h.jsxs)(q,{align:`start`,children:[i&&(0,h.jsxs)(J,{onClick:p,children:[(0,h.jsx)(b.FileText,{className:`h-4 w-4 mr-2`}),`Excel (.xlsx)`]}),a&&(0,h.jsxs)(J,{onClick:m,children:[(0,h.jsx)(b.FileText,{className:`h-4 w-4 mr-2`}),`CSV (.csv)`]})]})]}),o&&(0,h.jsxs)(U,{variant:`outline`,size:`sm`,onClick:g,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Mail,{className:`h-3 w-3 mr-1`}),`发送邮件`]}),s&&(0,h.jsxs)(U,{variant:`outline`,size:`sm`,onClick:_,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Archive,{className:`h-3 w-3 mr-1`}),`归档`]})]}),y&&(0,h.jsx)(h.Fragment,{children:c.map(e=>(0,h.jsxs)(U,{variant:e.variant||`outline`,size:`sm`,onClick:()=>e.onClick(t),disabled:l,className:`h-8`,children:[e.icon&&(0,h.jsx)(`span`,{className:`mr-1`,children:e.icon}),e.label]},e.key))}),(v||y)&&(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`sm`,disabled:l,className:`h-8 w-8 p-0`,children:(0,h.jsx)(b.MoreHorizontal,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{align:`end`,children:[n&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(J,{onClick:d,className:`text-destructive`,children:[(0,h.jsx)(b.Trash2,{className:`h-4 w-4 mr-2`}),`删除选中项`]}),(0,h.jsx)(Y,{})]}),r&&(0,h.jsxs)(J,{onClick:f,children:[(0,h.jsx)(b.Download,{className:`h-4 w-4 mr-2`}),`导出数据`]}),o&&(0,h.jsxs)(J,{onClick:g,children:[(0,h.jsx)(b.Mail,{className:`h-4 w-4 mr-2`}),`发送邮件`]}),s&&(0,h.jsxs)(J,{onClick:_,children:[(0,h.jsx)(b.Archive,{className:`h-4 w-4 mr-2`}),`归档`]}),c.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Y,{}),c.map(e=>(0,h.jsxs)(J,{onClick:()=>e.onClick(t),children:[e.icon&&(0,h.jsx)(`span`,{className:`mr-2`,children:e.icon}),e.label]},e.key))]})]})]})]})}function Pt({selectedCount:e,selectedRows:t=[],onClear:n,actions:r=[],alwaysShow:i=!1,batchActions:a}){let o=nt();return(0,h.jsx)(N.AnimatePresence,{children:(i||e>0)&&(0,h.jsx)(N.motion.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.18},children:(0,h.jsx)(At,{className:`mb-4`,children:(0,h.jsxs)(Mt,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,h.jsx)(`span`,{className:`text-sm leading-none`,children:e>0?(0,h.jsxs)(h.Fragment,{children:[o.batchActions.selected,` `,(0,h.jsx)(`strong`,{children:e}),` row(s)`]}):o.batchActions.selected}),e>0&&(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a&&(0,h.jsx)(Nt,{selectedCount:e,selectedRows:t,...a}),r.map((e,t)=>(0,h.jsx)(c.default.Fragment,{children:e},t))]})]}),e>0&&(0,h.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,h.jsx)(C.IconX,{className:`mr-1 h-3 w-3`}),o.batchActions.clear]})]})})},`batch-actions`)})}var Ft=c.forwardRef(({className:e,...t},n)=>(0,h.jsx)(`textarea`,{className:B(`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));Ft.displayName=`Textarea`;function It({value:e,record:t,column:n,isEditing:r,onSave:i,onCancel:a,onStartEdit:o}){let[s,l]=(0,c.useState)(e),[u,d]=(0,c.useState)(!0);(0,c.useEffect)(()=>{l(e)},[e]);let p=()=>{u&&i(s)},m=()=>{l(e),a()},g=e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),m())};return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`flex-1`,children:(()=>{let{valueType:e,fieldProps:t={}}=n;switch(e){case`text`:return(0,h.jsx)(W,{value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,...t});case`number`:return(0,h.jsx)(W,{type:`number`,value:s||``,onChange:e=>{let t=e.target.value===``?null:Number(e.target.value);l(t),d(e.target.value===``||!isNaN(Number(e.target.value)))},onKeyDown:g,className:`h-8`,...t});case`select`:let{valueEnum:e}=n;return(0,h.jsxs)(st,{value:s||``,onValueChange:l,children:[(0,h.jsx)(ut,{className:`h-8`,children:(0,h.jsx)(lt,{placeholder:`请选择`})}),(0,h.jsx)(dt,{children:e&&Object.entries(e).map(([e,t])=>(0,h.jsx)($,{value:e,children:t.text},e))})]});case`switch`:return(0,h.jsx)(_e,{checked:!!s,onCheckedChange:l,...t});case`date`:return(0,h.jsxs)(xt,{children:[(0,h.jsx)(St,{asChild:!0,children:(0,h.jsxs)(U,{variant:`outline`,className:B(`h-8 justify-start text-left font-normal`,!s&&`text-muted-foreground`),children:[(0,h.jsx)(b.CalendarIcon,{className:`mr-2 h-4 w-4`}),s?(0,f.format)(s,`yyyy-MM-dd`):`选择日期`]})}),(0,h.jsx)(Ct,{className:`w-auto p-0`,children:(0,h.jsx)(yt,{mode:`single`,selected:s,onSelect:l,initialFocus:!0})})]});case`textarea`:return(0,h.jsx)(Ft,{value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`min-h-[60px]`,...t});case`money`:return(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`¥`}),(0,h.jsx)(W,{type:`number`,value:s||``,onChange:e=>{let t=e.target.value===``?null:Number(e.target.value);l(t),d(e.target.value===``||!isNaN(Number(e.target.value)))},onKeyDown:g,className:`h-8`,placeholder:`0.00`,...t})]});case`percent`:return(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(W,{type:`number`,value:s||``,onChange:e=>{let t=e.target.value===``?null:Number(e.target.value);l(t),d(e.target.value===``||!isNaN(Number(e.target.value)))},onKeyDown:g,className:`h-8`,placeholder:`0`,...t}),(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`%`})]});case`email`:return(0,h.jsx)(W,{type:`email`,value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,placeholder:`example@email.com`,...t});case`phone`:return(0,h.jsx)(W,{type:`tel`,value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,placeholder:`+86 138 0000 0000`,...t});case`url`:return(0,h.jsx)(W,{type:`url`,value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,placeholder:`https://example.com`,...t});default:return(0,h.jsx)(W,{value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,...t})}})()}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0`,onClick:p,disabled:!u,children:(0,h.jsx)(b.Check,{className:`h-3 w-3`})}),(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0`,onClick:m,children:(0,h.jsx)(b.X,{className:`h-3 w-3`})})]})]}):(0,h.jsx)(`div`,{className:`cursor-pointer hover:bg-muted/50 rounded px-2 py-1 min-h-[32px] flex items-center`,onClick:o,children:(()=>n.render?n.render(e,t,0):(n.valueType,e))()})}function Lt({record:e,config:t,editable:n,onEdit:r,onSave:i,onCancel:a,onDelete:o,onAdd:s,onRemove:l}){let{isEditing:u}=t;return n?.actionRender?(0,h.jsx)(`div`,{className:`flex items-center gap-1`,children:n.actionRender(e,t).map((e,t)=>(0,h.jsx)(c.default.Fragment,{children:e},t))}):(0,h.jsx)(`div`,{className:`flex items-center justify-center`,children:(()=>u?(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:i,children:[(0,h.jsx)(b.Save,{className:`h-3 w-3 mr-1`}),`保存`]}),(0,h.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:a,children:[(0,h.jsx)(b.X,{className:`h-3 w-3 mr-1`}),`取消`]})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:r,children:[(0,h.jsx)(b.Edit,{className:`h-3 w-3 mr-1`}),`编辑`]}),o&&(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-destructive hover:text-destructive`,onClick:o,title:`删除`,children:(0,h.jsx)(b.Trash2,{className:`h-3 w-3`})}),s&&(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:s,children:(0,h.jsx)(b.Plus,{className:`h-3 w-3`})}),l&&(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:l,children:(0,h.jsx)(b.Minus,{className:`h-3 w-3`})})]}))()})}function Rt({value:e,className:t,size:n=`sm`,showText:r=!1,onCopy:i}){let[a,o]=(0,c.useState)(!1),s=async()=>{try{let t=typeof e==`string`?e:JSON.stringify(e);await navigator.clipboard.writeText(t),o(!0),i?.(e),setTimeout(()=>o(!1),2e3)}catch(t){console.error(`Failed to copy:`,t);try{let t=document.createElement(`textarea`);t.value=typeof e==`string`?e:JSON.stringify(e),document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),o(!0),i?.(e),setTimeout(()=>o(!1),2e3)}catch(e){console.error(`Fallback copy failed:`,e)}}},l={sm:`h-6 w-6 p-0`,md:`h-8 w-8 p-0`,lg:`h-10 w-10 p-0`},u={sm:`h-3 w-3`,md:`h-4 w-4`,lg:`h-5 w-5`};return(0,h.jsxs)(U,{variant:`ghost`,size:`sm`,className:B(l[n],`hover:bg-muted/50 transition-colors`,t),onClick:s,title:a?`已复制`:`复制`,children:[a?(0,h.jsx)(b.Check,{className:B(u[n],`text-green-600`)}):(0,h.jsx)(b.Copy,{className:B(u[n],`text-muted-foreground`)}),r&&(0,h.jsx)(`span`,{className:`ml-1 text-xs`,children:a?`已复制`:`复制`})]})}var zt=(e,t,n)=>{if(!e.fixed)return{};let r=0;if(e.fixed===`left`){for(let e=0;e<t;e++)n[e].fixed===`left`&&(r+=n[e].width||100);return{position:`sticky`,left:r,zIndex:1,backgroundColor:`var(--background)`}}if(e.fixed===`right`){for(let e=t+1;e<n.length;e++)n[e].fixed===`right`&&(r+=n[e].width||100);return{position:`sticky`,right:r,zIndex:1,backgroundColor:`var(--background)`}}return{}},Bt=(e,t,n)=>{if(!e.fixed)return``;let r=[];return e.fixed===`left`&&(r.push(`pro-table-cell-fix-left`),(t===n.length-1||!n.slice(t+1).some(e=>e.fixed===`left`))&&r.push(`pro-table-cell-fix-left-last`)),e.fixed===`right`&&(r.push(`pro-table-cell-fix-right`),(t===0||!n.slice(0,t).some(e=>e.fixed===`right`))&&r.push(`pro-table-cell-fix-right-first`)),r.join(` `)};function Vt({row:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=(0,T.useSortable)({id:e.id}),c={transform:E.CSS.Transform.toString(a),transition:o,opacity:s?.5:1};return(0,h.jsxs)(V,{ref:i,style:c,"data-state":e.getIsSelected&&e.getIsSelected()?`selected`:void 0,...n,children:[(0,h.jsx)(H,{className:`w-8`,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-6 w-6 cursor-move`,...r,children:(0,h.jsx)(b.GripVertical,{className:`h-3 w-3`})})}),t]})}const Ht=(0,c.forwardRef)((e,t)=>{let{columns:n=[],className:r,style:i,tableClassName:a,tableStyle:o,size:s=`middle`,bordered:u=!1,loading:d=!1,toolbar:f,pagination:p,rowSelection:m,draggable:g,editable:_,headerTitle:v,headerSubTitle:y,footer:x,onRow:S,search:C,cardBordered:E=!1,cardProps:O,tableRender:k,tableExtraRender:A,onSubmit:j,onReset:M,scroll:N,sticky:P,tableLayout:te,locale:ne}=e,[F,re]=(0,c.useState)(()=>n);(0,c.useEffect)(()=>{re(n)},[n]);let ie={...e,columns:F},{table:I,state:L,actions:R,handlers:z}=Be(ie),{request:ae}=ie,{visibleColumns:oe,setVisibleColumns:se,columnSettings:ce,updateColumnSettings:le}=Ve({columns:F,rowSelection:!!m,draggable:!!g,editable:!!_}),[ue,de]=(0,c.useState)(s),[fe,pe]=(0,c.useState)(!1),me=(0,w.useSensors)((0,w.useSensor)(w.PointerSensor),(0,w.useSensor)(w.KeyboardSensor));(0,c.useImperativeHandle)(t,()=>R,[R]);let he=e=>{if(g&&typeof g==`object`&&typeof g.onDragEnd==`function`){let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=I.getRowModel().rows,i=r.findIndex(e=>String(e.id)===String(t.id)),a=r.findIndex(e=>String(e.id)===String(n.id));if(i!==-1&&a!==-1){let t=[...L.data],[n]=t.splice(i,1);t.splice(a,0,n);try{R.setTableData(t)}catch(e){console.warn(`setTableData unavailable`,e)}try{g.onDragEnd({active:{id:e.active.id},over:e.over?{id:e.over.id}:null,items:t,oldIndex:0,newIndex:0})}catch(e){console.error(`draggable.onDragEnd error:`,e)}}}},ge=()=>{try{I.toggleAllRowsSelected?.(!1)}catch{}R.clearSelected()},_e=e=>{z.handleSearch(e),j?.(e)},ve=()=>{z.handleReset(),M?.()},ye=(e,t)=>{if(I.setColumnFilters(n=>({...n,[e]:t})),ae){let n={...L.filters};t.length>0?n[e]=t:delete n[e],z.handleSearch(n)}},xe=e=>{if(I.setColumnFilters(t=>t.filter(t=>t.id!==e)),ae){let t={...L.filters};delete t[e],z.handleSearch(t)}},Se=(e,t)=>{if(e===`order`&&Array.isArray(t)){re(t);return}if(typeof e==`string`&&t&&t.fixed!==void 0){let n=e,r=t.fixed;re(e=>e.map(e=>(e.key||String(e.dataIndex))===n?{...e,fixed:r}:e));return}le(e,t)},Ee={small:`text-xs [&_th]:py-1.5 [&_td]:py-1`,middle:`text-sm [&_th]:py-2 [&_td]:py-2`,large:`text-base [&_th]:py-3 [&_td]:py-3`},Oe=()=>(0,h.jsx)(V,{children:(0,h.jsx)(H,{colSpan:F.length+(m?1:0)+(g?1:0),className:`h-32 text-center`,children:(0,h.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-2`,children:(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`No data available`})})})}),Me=()=>(0,h.jsx)(h.Fragment,{children:[...[,,,,,]].map((e,t)=>(0,h.jsxs)(V,{children:[g&&(0,h.jsx)(H,{children:(0,h.jsx)(Ae,{className:`h-4 w-4`})}),m&&(0,h.jsx)(H,{children:(0,h.jsx)(Ae,{className:`h-4 w-4`})}),F.map((e,t)=>(0,h.jsx)(H,{children:(0,h.jsx)(Ae,{className:`h-4 w-full`})},t))]},t))}),Ne=e=>{let t=e.original.id||e.original.key||e.id,n=L.editingKey===t;return(0,h.jsxs)(h.Fragment,{children:[m&&(0,h.jsx)(H,{className:`w-8`,children:(0,h.jsx)(ke,{checked:e.getIsSelected?.()??!1,onCheckedChange:t=>e.toggleSelected?.(!!t),"aria-label":`Select row`})}),e.getVisibleCells().map((r,i)=>{let a=F.find(e=>(e.key||String(e.dataIndex))===r.column.id),o=zt(a,i,F),s=Bt(a,i,F);return _&&a?.editable&&n?(0,h.jsx)(H,{className:B(`align-middle`,a?.align&&`text-${a.align}`,s),style:{width:a?.width,...o},children:(0,h.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,h.jsx)(`div`,{className:`flex-1 min-w-0`,children:(()=>{let i=(0,h.jsx)(`div`,{className:B(a?.ellipsis&&(()=>{if(typeof a.ellipsis==`object`&&a.ellipsis.multiline){let e=a.ellipsis.rows||2;return{1:`line-clamp-1`,2:`line-clamp-2`,3:`line-clamp-3`,4:`line-clamp-4`,5:`line-clamp-5`}[e]||`line-clamp-2`}return`truncate`})()),children:(0,h.jsx)(It,{value:r.getValue(),record:e.original,column:a,isEditing:n,onSave:n=>{let r={...e.original,[a.dataIndex]:n};R.saveEditable(t,r),_?.onSave&&_.onSave(t,r,e.original)},onCancel:()=>R.cancelEditable(t),onStartEdit:()=>R.startEditable(t)})}),o=!!a?.ellipsis;if(a?.tooltip&&!n){let t=typeof a.tooltip==`object`?a.tooltip:{};if(t.disabled)return i;let n;if(typeof a.tooltip==`object`&&t.content!==void 0)n=typeof t.content==`function`?t.content(r.getValue(),e.original,e.index):t.content;else if(o){let t=a?.dataIndex?e.original[a.dataIndex]:r.getValue();n=typeof t==`object`&&t?JSON.stringify(t,null,2):String(t??``)}else n=r.getValue();return(0,h.jsxs)(X,{delayDuration:t.delayDuration,children:[(0,h.jsx)(Z,{asChild:!0,children:i}),(0,h.jsx)(Q,{side:t.side||`top`,align:t.align,children:n})]})}return i})()})})},r.id):(0,h.jsx)(H,{className:B(`align-middle`,a?.align&&`text-${a.align}`,s),style:{width:a?.width,...o},children:(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`flex-1 min-w-0`,children:(()=>{let t=(0,h.jsx)(`div`,{className:B(a?.ellipsis&&(()=>{if(typeof a.ellipsis==`object`&&a.ellipsis.multiline){let e=a.ellipsis.rows||2;return{1:`line-clamp-1`,2:`line-clamp-2`,3:`line-clamp-3`,4:`line-clamp-4`,5:`line-clamp-5`}[e]||`line-clamp-2`}return`truncate`})()),children:a?.valueType?be(a.valueType,r.getValue(),a):(0,l.flexRender)(r.column.columnDef.cell,r.getContext())}),n=!!a?.ellipsis;if(a?.tooltip){let i=typeof a.tooltip==`object`?a.tooltip:{};if(i.disabled)return t;let o;if(typeof a.tooltip==`object`&&i.content!==void 0)o=typeof i.content==`function`?i.content(r.getValue(),e.original,e.index):i.content;else if(n){let t=a?.dataIndex?e.original[a.dataIndex]:r.getValue();o=typeof t==`object`&&t?JSON.stringify(t,null,2):String(t??``)}else o=r.getValue();return(0,h.jsxs)(X,{delayDuration:i.delayDuration,children:[(0,h.jsx)(Z,{asChild:!0,children:t}),(0,h.jsx)(Q,{side:i.side||`top`,align:i.align,children:o})]})}return t})()}),a?.copyable&&(0,h.jsx)(Rt,{value:r.getValue(),size:`sm`,onCopy:e=>{console.log(`复制成功:`,e)}})]})},r.id)}),_&&(0,h.jsx)(H,{className:`w-32`,children:(0,h.jsx)(Lt,{record:e.original,config:{isEditing:n,editingKey:L.editingKey||``},editable:_,onEdit:()=>R.startEditable(t),onSave:()=>{R.cancelEditable(t)},onCancel:()=>R.cancelEditable(t),onDelete:_.onDelete?()=>{_.onDelete&&_.onDelete(t,e.original)}:void 0})})]})},Pe=(e,t)=>{let n=S?.(e.original,t)||{};return g?(0,h.jsx)(Vt,{row:e,children:Ne(e)},e.id):(0,h.jsx)(V,{"data-state":e.getIsSelected&&e.getIsSelected()?`selected`:void 0,...n,children:Ne(e)},e.id)},Fe=(0,h.jsx)(`div`,{className:B(`relative`,N?.x&&`overflow-x-auto`,N?.y&&`overflow-y-auto`),style:{maxHeight:N?.y,maxWidth:N?.x?`${N.x}px`:void 0},children:(0,h.jsx)(`div`,{className:B(`rounded-md`,u&&`border`),children:(0,h.jsx)(w.DndContext,{sensors:me,collisionDetection:w.closestCenter,modifiers:[D.restrictToVerticalAxis],onDragEnd:he,children:(0,h.jsxs)(Ce,{className:B(Ee[ue],a,P&&`sticky-header`),style:{...o,tableLayout:te||(N?.x?`fixed`:`auto`),maxWidth:N?.x?`${N.x}px`:void 0,...P&&{position:`relative`}},children:[(0,h.jsx)(we,{className:B(P&&`sticky top-0 z-10 bg-background`),style:P?{position:`sticky`,top:typeof P==`object`&&P.offsetHeader||0,zIndex:10}:void 0,children:I.getHeaderGroups().map(e=>(0,h.jsxs)(V,{children:[g&&(0,h.jsx)(De,{className:`w-8`}),m&&(0,h.jsx)(De,{className:`w-8`,children:(0,h.jsx)(ke,{checked:I.getIsAllPageRowsSelected?.()??!1,onCheckedChange:e=>I.toggleAllPageRowsSelected?.(!!e),"aria-label":`Select all`})}),e.headers.map((e,t)=>{let n=F.find(t=>(t.key||String(t.dataIndex))===e.column.id),r=zt(n,t,F),i=Bt(n,t,F),a=n?.headerEllipsis??n?.ellipsis,o=n?.headerTooltip??n?.tooltip;return(0,h.jsx)(De,{style:{width:n?.width||e.column.getSize(),...r},className:B(`font-medium`,n?.align&&`text-${n.align}`,a&&`whitespace-normal`,i),children:e.isPlaceholder?null:(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(()=>{let r=(0,l.flexRender)(e.column.columnDef.header,e.getContext()),i=(0,h.jsx)(`span`,{className:B(`flex-1 min-w-0`,a&&(()=>{if(typeof a==`object`&&a.multiline){let e=a.rows||2;return{1:`line-clamp-1`,2:`line-clamp-2`,3:`line-clamp-3`,4:`line-clamp-4`,5:`line-clamp-5`}[e]||`line-clamp-2`}return`truncate`})()),children:r});if(o){let e=typeof o==`object`?o:{};if(e.disabled)return i;let a;return a=typeof o==`object`&&e.content!==void 0?typeof e.content==`function`?e.content(r,n||{},t):e.content:r,(0,h.jsxs)(X,{delayDuration:e.delayDuration,children:[(0,h.jsx)(Z,{asChild:!0,children:i}),(0,h.jsx)(Q,{side:e.side||`top`,align:e.align,children:a})]})}return i})(),(0,h.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e.column.getCanSort()&&(0,h.jsxs)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-muted`,onClick:()=>e.column.toggleSorting(),children:[e.column.getIsSorted()===`asc`&&(0,h.jsx)(b.ArrowUp,{className:`h-3 w-3`}),e.column.getIsSorted()===`desc`&&(0,h.jsx)(b.ArrowDown,{className:`h-3 w-3`}),!e.column.getIsSorted()&&(0,h.jsx)(b.ArrowUpDown,{className:`h-3 w-3 opacity-50`})]}),n?.filters&&n.filters.length>0&&(0,h.jsx)(ot,{column:{key:n.key,dataIndex:String(n.dataIndex),title:n.title,filters:n.filters},value:Array.isArray(I.getColumn(n.key||String(n.dataIndex))?.getFilterValue())?I.getColumn(n.key||String(n.dataIndex))?.getFilterValue():[],onChange:e=>ye(n.key||String(n.dataIndex),e),onClear:()=>xe(n.key||String(n.dataIndex))})]})]})},e.id)})]},e.id))}),(0,h.jsx)(Te,{children:d?Me():L.data.length===0?Oe():g?(0,h.jsx)(T.SortableContext,{items:I.getRowModel().rows.map(e=>e.id),strategy:T.verticalListSortingStrategy,children:I.getRowModel().rows.map((e,t)=>Pe(e,t))}):I.getRowModel().rows.map((e,t)=>Pe(e,t))})]})})})}),Le=k?k(e,Fe,{toolbar:f!==!1,search:C!==!1,table:!0}):Fe,Re=B(`flex flex-col gap-4 transition-all duration-300 ease-in-out`,fe?`fixed inset-0 z-50 bg-background p-4 transform scale-100`:`transform scale-100`,r),ze=(0,h.jsx)(tt,{locale:ne,children:(0,h.jsxs)(`div`,{className:Re,style:i,children:[C!==!1&&(()=>{let e=ee(F);return e.length>0&&(0,h.jsx)(Ot,{...typeof C==`object`?C:{},columns:e,onSearch:_e,onReset:ve,loading:L.loading})})(),f!==!1&&(0,h.jsx)(at,{...typeof f==`object`?f:{},title:v,subTitle:y,table:I,columns:F,loading:L.loading,onReload:()=>R.reload(),fullScreen:fe,onFullScreenChange:pe,density:ue,onDensityChange:de,visibleColumns:oe,onVisibleColumnsChange:se,columnSettings:ce,onColumnSettingsChange:Se}),m&&(0,h.jsx)(Pt,{selectedCount:I.getFilteredSelectedRowModel().rows.length,selectedRows:I.getFilteredSelectedRowModel().rows.map(e=>e.original),onClear:ge,alwaysShow:m.alwaysShowAlert,batchActions:m.batchActions}),A?.(e,L.data),Le,x&&(0,h.jsx)(`div`,{className:`px-4`,children:x(L.data)}),p!==!1&&(0,h.jsx)(vt,{...typeof p==`object`?p:{},current:L.current,pageSize:L.pageSize,total:L.total,onPaginationChange:z.handlePaginationChange})]})});return E?(0,h.jsx)(je,{...O,className:B(O?.className),children:(0,h.jsx)(Ie,{children:ze})}):ze});var Ut=new Map;function Wt(e,t={}){let{manual:n=!1,defaultParams:r={},onSuccess:i,onError:a,debounceWait:o=0,retryCount:s=0,cacheKey:l,cacheTime:u=300*1e3}=t,[d,f]=(0,c.useState)([]),[p,m]=(0,c.useState)(!n),[h,g]=(0,c.useState)(null),[_,v]=(0,c.useState)(0),y=(0,c.useRef)(r),b=(0,c.useRef)(0),x=(0,c.useRef)(null),S=(0,c.useRef)(null),C=(0,c.useCallback)(async t=>{x.current&&x.current.abort(),S.current&&clearTimeout(S.current);let n=async()=>{let r=t||y.current;if(y.current=r,l){let e=Ut.get(l);if(e&&Date.now()-e.timestamp<u){f(e.data.data),v(e.data.total||0),m(!1);return}}m(!0),g(null),x.current=new AbortController;try{let t=await e(r);if(!x.current.signal.aborted){let e=t.data||[];f(e),v(t.total||e.length),l&&Ut.set(l,{data:t,timestamp:Date.now()}),i?.(e,t),b.current=0}}catch(e){if(!x.current.signal.aborted){let t=e;g(t),a?.(t),b.current<s&&(b.current++,setTimeout(()=>n(),1e3*2**b.current))}}finally{x.current.signal.aborted||m(!1)}};o>0?S.current=setTimeout(n,o):await n()},[e,i,a,s,l,u]),w=(0,c.useCallback)(async()=>{await C(y.current)},[C]),T=(0,c.useCallback)(()=>{x.current&&x.current.abort(),S.current&&clearTimeout(S.current),m(!1)},[]),E=(0,c.useCallback)(e=>{f(e),v(e.length)},[]);return(0,c.useEffect)(()=>(n||C(),()=>{T()}),[]),{data:d,loading:p,error:h,total:_,run:C,refresh:w,cancel:T,mutate:E}}const Gt={search:{searchText:`搜索`,resetText:`重置`,submitText:`提交`,expandText:`展开`,collapseText:`收起`,selectPlaceholder:`请选择`,inputPlaceholder:`请输入`},pagination:{total:(e,t)=>`第 ${t[0]}-${t[1]} 条,共 ${e} 条`,items:`条`,page:`页`,of:`共`,showTotal:`显示`},toolbar:{reload:`刷新`,density:`密度`,columnSetting:`列设置`,fullScreen:`全屏`,exitFullScreen:`退出全屏`,compact:`紧凑`,default:`默认`,comfortable:`舒适`,searchPlaceholder:`搜索...`},columnSetting:{title:`列设置`,fixedLeft:`固定左侧`,fixedRight:`固定右侧`,noFixed:`不固定`,show:`显示`,hide:`隐藏`,reset:`重置`},batchActions:{selected:`已选择`,clear:`清空`,delete:`删除`,export:`导出`},editable:{save:`保存`,cancel:`取消`,edit:`编辑`,delete:`删除`},common:{confirm:`确认`,cancel:`取消`,noData:`暂无数据`,loading:`加载中...`,selectAll:`全选`,copySuccess:`复制成功`}};exports.Alert=At,exports.AlertDescription=Mt,exports.AlertTitle=jt,exports.Avatar=me,exports.AvatarFallback=ge,exports.AvatarImage=he,exports.Badge=pe,exports.BatchActions=Pt,exports.Button=U,exports.Calendar=yt,exports.CalendarDayButton=bt,exports.Card=je,exports.CardAction=Fe,exports.CardContent=Ie,exports.CardDescription=Pe,exports.CardFooter=Le,exports.CardHeader=Me,exports.CardTitle=Ne,exports.Checkbox=ke,exports.ColumnSetting=it,exports.DatePicker=Tt,exports.DateRangePicker=Et,exports.DropdownMenu=G,exports.DropdownMenuCheckboxItem=We,exports.DropdownMenuContent=q,exports.DropdownMenuGroup=Ue,exports.DropdownMenuItem=J,exports.DropdownMenuLabel=qe,exports.DropdownMenuPortal=He,exports.DropdownMenuRadioGroup=Ge,exports.DropdownMenuRadioItem=Ke,exports.DropdownMenuSeparator=Y,exports.DropdownMenuShortcut=Je,exports.DropdownMenuSub=Ye,exports.DropdownMenuSubContent=Ze,exports.DropdownMenuSubTrigger=Xe,exports.DropdownMenuTrigger=K,exports.Input=W,exports.Label=Dt,exports.Pagination=vt,exports.Popover=xt,exports.PopoverAnchor=wt,exports.PopoverContent=Ct,exports.PopoverTrigger=St,exports.ProTable=Ht,exports.Progress=ve,exports.Search=Ot,exports.Select=st,exports.SelectContent=dt,exports.SelectGroup=ct,exports.SelectItem=$,exports.SelectLabel=ft,exports.SelectScrollDownButton=ht,exports.SelectScrollUpButton=mt,exports.SelectSeparator=pt,exports.SelectTrigger=ut,exports.SelectValue=lt,exports.Skeleton=Ae,exports.Switch=_e,exports.Table=Ce,exports.TableBody=Te,exports.TableCaption=Oe,exports.TableCell=H,exports.TableFooter=Ee,exports.TableHead=De,exports.TableHeader=we,exports.TableRow=V,exports.ToolBar=at,exports.Tooltip=X,exports.TooltipContent=Q,exports.TooltipProvider=Qe,exports.TooltipTrigger=Z,exports.badgeVariants=fe,exports.buttonVariants=Re,exports.cn=B,exports.copyToClipboard=I,exports.debounce=F,exports.deepMerge=ne,exports.en_US=$e,exports.extractSearchColumns=ee,exports.extractTableColumns=P,exports.formatFileSize=ce,exports.formatNumber=ie,exports.generateId=te,exports.generateRandomColor=le,exports.getNestedValue=R,exports.groupBy=oe,exports.isEmpty=L,exports.parseQueryString=ue,exports.registerValueType=Se,exports.renderFormItem=xe,exports.renderValue=be,exports.setNestedValue=z,exports.sleep=se,exports.stringifyQuery=de,exports.throttle=re,exports.uniqueArray=ae,exports.useColumns=Ve,exports.useProTable=Be,exports.useRequest=Wt,exports.zh_CN=Gt;
1
+ require('./index.css');var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`@tanstack/react-table`);l=s(l);let u=require(`clsx`);u=s(u);let d=require(`tailwind-merge`);d=s(d);let f=require(`date-fns`);f=s(f);let p=require(`@radix-ui/react-slot`);p=s(p);let m=require(`class-variance-authority`);m=s(m);let h=require(`react/jsx-runtime`);h=s(h);let g=require(`@radix-ui/react-avatar`);g=s(g);let _=require(`@radix-ui/react-switch`);_=s(_);let v=require(`@radix-ui/react-progress`);v=s(v);let y=require(`@radix-ui/react-checkbox`);y=s(y);let b=require(`lucide-react`);b=s(b);let x=require(`@radix-ui/react-dropdown-menu`);x=s(x);let S=require(`@radix-ui/react-tooltip`);S=s(S);let C=require(`@tabler/icons-react`);C=s(C);let w=require(`@dnd-kit/core`);w=s(w);let T=require(`@dnd-kit/sortable`);T=s(T);let E=require(`@dnd-kit/utilities`);E=s(E);let D=require(`@dnd-kit/modifiers`);D=s(D);let O=require(`@radix-ui/react-select`);O=s(O);let k=require(`react-day-picker`);k=s(k);let A=require(`@radix-ui/react-popover`);A=s(A);let j=require(`@radix-ui/react-label`);j=s(j);let M=require(`react-hook-form`);M=s(M);let N=require(`framer-motion`);N=s(N);function ee(e){return e.filter(e=>!e.hideInSearch&&(e.search===!0||typeof e.search==`object`))}function P(e){return e.filter(e=>!e.hideInTable)}function te(e=`id`){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function ne(e,t){if(!e||typeof e!=`object`)return t??e;if(!t||typeof t!=`object`)return e;let n=Array.isArray(e)?[...e]:{...e};return Object.keys(t).forEach(r=>{let i=t[r],a=e[r];typeof i==`object`&&i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp)&&typeof a==`object`&&a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp)?n[r]=ne(a,i):n[r]=i}),n}function F(e,t){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>e(...r),t)}}function re(e,t){let n=!1;return function(...r){n||(e(...r),n=!0,setTimeout(()=>n=!1,t))}}function ie(e,t=2){return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e)}async function I(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`),document.body.removeChild(t),!0}catch{return document.body.removeChild(t),!1}}}function L(e){return e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:typeof e==`object`?Object.keys(e).length===0:!1}function R(e,t,n){if(!t)return e;let r=t.split(`.`),i=e;for(let e of r){if(i==null)return n;i=i[e]}return i??n}function z(e,t,n){if(!t)return;let r=t.split(`.`),i=r.pop();if(!i)return;let a=e;for(let e of r)(!(e in a)||typeof a[e]!=`object`)&&(a[e]={}),a=a[e];a[i]=n}function ae(e,t){if(!t)return Array.from(new Set(e));let n=new Set;return e.filter(e=>{let r=e[t];return n.has(r)?!1:(n.add(r),!0)})}function oe(e,t){return e.reduce((e,n)=>{let r=typeof t==`function`?t(n):String(n[t]);return e[r]||(e[r]=[]),e[r].push(n),e},{})}function se(e){return new Promise(t=>setTimeout(t,e))}function ce(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]}function le(){return`#`+Math.floor(Math.random()*16777215).toString(16).padStart(6,`0`)}function ue(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function de(e){let t=new URLSearchParams;return Object.entries(e).forEach(([e,n])=>{n!=null&&t.append(e,String(n))}),t.toString()}var fe=(0,m.cva)(`inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`}},defaultVariants:{variant:`default`}});function pe({className:e,variant:t,asChild:n=!1,...r}){return(0,h.jsx)(n?p.Slot:`span`,{"data-slot":`badge`,className:B(fe({variant:t}),e),...r})}function me({className:e,...t}){return(0,h.jsx)(g.Root,{"data-slot":`avatar`,className:B(`relative flex size-8 shrink-0 overflow-hidden rounded-full`,e),...t})}function he({className:e,...t}){return(0,h.jsx)(g.Image,{"data-slot":`avatar-image`,className:B(`aspect-square size-full`,e),...t})}function ge({className:e,...t}){return(0,h.jsx)(g.Fallback,{"data-slot":`avatar-fallback`,className:B(`bg-muted flex size-full items-center justify-center rounded-full`,e),...t})}function _e({className:e,...t}){return(0,h.jsx)(_.Root,{"data-slot":`switch`,className:B(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,h.jsx)(_.Thumb,{"data-slot":`switch-thumb`,className:B(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}function ve({className:e,value:t,...n}){return(0,h.jsx)(v.Root,{"data-slot":`progress`,className:B(`bg-primary/20 relative h-2 w-full overflow-hidden rounded-full`,e),...n,children:(0,h.jsx)(v.Indicator,{"data-slot":`progress-indicator`,className:`bg-primary h-full w-full flex-1 transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})})}var ye={text:{render:e=>e??`-`},textarea:{render:e=>e??`-`},number:{render:e=>e==null?`-`:new Intl.NumberFormat().format(e)},money:{render:(e,t)=>{if(e==null)return`-`;let n=t?.currency??`USD`;return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:n}).format(e)}},percent:{render:e=>e==null?`-`:`${e}%`},date:{render:(e,t)=>{if(!e)return`-`;let n=t?.format??`yyyy-MM-dd`;return(0,f.format)(new Date(e),n)}},dateTime:{render:(e,t)=>{if(!e)return`-`;let n=t?.format??`yyyy-MM-dd HH:mm:ss`;return(0,f.format)(new Date(e),n)}},dateRange:{render:(e,t)=>{if(!e||!Array.isArray(e)||e.length!==2)return`-`;let n=t?.format??`yyyy-MM-dd`;return`${(0,f.format)(new Date(e[0]),n)} ~ ${(0,f.format)(new Date(e[1]),n)}`}},select:{render:(e,t)=>(t?.options??[]).find(t=>t.value===e)?.label??e??`-`},tags:{render:(e,t)=>Array.isArray(e)?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,n)=>(0,h.jsx)(pe,{variant:t?.variant??`secondary`,children:e},n))}):`-`},avatar:{render:(e,t)=>{let n=t?.size??32;return(0,h.jsxs)(me,{style:{width:n,height:n},children:[(0,h.jsx)(he,{src:e,alt:t?.alt}),(0,h.jsx)(ge,{children:t?.fallback??`U`})]})}},image:{render:(e,t)=>{if(!e)return`-`;let n=t?.width??80,r=t?.height??80;return(0,h.jsx)(`img`,{src:e,alt:t?.alt??`image`,style:{width:n,height:r,objectFit:`cover`},className:`rounded`})}},switch:{render:(e,t)=>(0,h.jsx)(_e,{checked:!!e,disabled:t?.disabled??!0,onCheckedChange:t?.onChange})},code:{render:e=>e?(0,h.jsx)(`code`,{className:`relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm`,children:e}):`-`},fromNow:{render:e=>{if(!e)return`-`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/(1e3*60*60*24));return r===0?`Today`:r===1?`Yesterday`:r<7?`${r} days ago`:r<30?`${Math.floor(r/7)} weeks ago`:r<365?`${Math.floor(r/30)} months ago`:`${Math.floor(r/365)} years ago`}},status:{render:(e,t)=>{if(!e)return`-`;if(t?.valueEnum&&t.valueEnum[e]){let n=t.valueEnum[e];return(0,h.jsx)(pe,{variant:n.status||`default`,style:{backgroundColor:n.color,borderColor:n.color},children:n.text})}let n={success:{text:`Success`,variant:`default`},error:{text:`Error`,variant:`destructive`},warning:{text:`Warning`,variant:`secondary`},processing:{text:`Processing`,variant:`outline`},default:{text:e,variant:`default`}},r=n[e]||n.default;return(0,h.jsx)(pe,{variant:r.variant,children:r.text})}},progress:{render:(e,t)=>{if(e==null)return`-`;let n=Number(e),r=t?.showInfo??!0;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(ve,{value:n,className:`flex-1`}),r&&(0,h.jsxs)(`span`,{className:`text-sm text-muted-foreground min-w-12`,children:[n,`%`]})]})}},custom:{render:(e,t)=>t?.render?.(e)??e??`-`},email:{render:e=>e?(0,h.jsx)(`a`,{href:`mailto:${e}`,className:`text-blue-600 hover:text-blue-800 underline`,children:e}):`-`},phone:{render:e=>e?(0,h.jsx)(`a`,{href:`tel:${e}`,className:`text-blue-600 hover:text-blue-800 underline`,children:e}):`-`},url:{render:e=>e?(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 hover:text-blue-800 underline`,children:e}):`-`},color:{render:e=>e?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`w-4 h-4 rounded border`,style:{backgroundColor:e}}),(0,h.jsx)(`span`,{className:`font-mono text-sm`,children:e})]}):`-`},rate:{render:(e,t)=>{if(e==null)return`-`;let n=t?.max??5,r=Math.floor(e),i=e%1>=.5;return(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Array.from({length:n},(e,t)=>(0,h.jsx)(`span`,{className:B(`text-lg`,t<r?`text-yellow-400`:`text-gray-300`),children:`★`},t)),i&&(0,h.jsx)(`span`,{className:`text-lg text-yellow-400`,children:`☆`}),(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground ml-1`,children:e.toFixed(1)})]})}}};function be(e,t,n){let r=ye[e];return r?r.render(t,n):(console.warn(`Unknown valueType: ${e}`),t??`-`)}function xe(e,t,n){let r=ye[e];return r?.renderFormItem?r.renderFormItem(t,n):null}function Se(e,t){ye[e]=t}function B(...e){return(0,d.twMerge)((0,u.clsx)(e))}function Ce({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,h.jsx)(`table`,{"data-slot":`table`,className:B(`w-full caption-bottom text-sm`,e),...t})})}function we({className:e,...t}){return(0,h.jsx)(`thead`,{"data-slot":`table-header`,className:B(`[&_tr]:border-b`,e),...t})}function Te({className:e,...t}){return(0,h.jsx)(`tbody`,{"data-slot":`table-body`,className:B(`[&_tr:last-child]:border-0`,e),...t})}function Ee({className:e,...t}){return(0,h.jsx)(`tfoot`,{"data-slot":`table-footer`,className:B(`bg-muted/50 border-t font-medium [&>tr]:last:border-b-0`,e),...t})}function V({className:e,...t}){return(0,h.jsx)(`tr`,{"data-slot":`table-row`,className:B(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,e),...t})}function De({className:e,...t}){return(0,h.jsx)(`th`,{"data-slot":`table-head`,className:B(`text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function H({className:e,...t}){return(0,h.jsx)(`td`,{"data-slot":`table-cell`,className:B(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Oe({className:e,...t}){return(0,h.jsx)(`caption`,{"data-slot":`table-caption`,className:B(`text-muted-foreground mt-4 text-sm`,e),...t})}function ke({className:e,...t}){return(0,h.jsx)(y.Root,{"data-slot":`checkbox`,className:B(`peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,h.jsx)(y.Indicator,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none`,children:(0,h.jsx)(b.CheckIcon,{className:`size-3.5`})})})}function Ae({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`skeleton`,className:B(`bg-accent animate-pulse rounded-md`,e),...t})}function je({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card`,className:B(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm`,e),...t})}function Me({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-header`,className:B(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function Ne({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-title`,className:B(`leading-none font-semibold`,e),...t})}function Pe({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-description`,className:B(`text-muted-foreground text-sm`,e),...t})}function Fe({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-action`,className:B(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function Ie({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-content`,className:B(`px-6`,e),...t})}function Le({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`card-footer`,className:B(`flex items-center px-6 [.border-t]:pt-6`,e),...t})}var Re=(0,m.cva)(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function U({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,h.jsx)(r?p.Slot:`button`,{"data-slot":`button`,className:B(Re({variant:t,size:n,className:e})),...i})}function ze(e,t){switch(t.type){case`SET_LOADING`:return{...e,loading:t.payload};case`SET_DATA`:return{...e,data:t.payload.data,total:t.payload.total??e.total};case`SET_PAGINATION`:return{...e,current:t.payload.current??e.current,pageSize:t.payload.pageSize??e.pageSize};case`SET_FILTERS`:return{...e,filters:t.payload};case`SET_SORTER`:return{...e,sorter:t.payload};case`SET_SELECTION`:return{...e,selectedRowKeys:t.payload.keys,selectedRows:t.payload.rows};case`START_EDIT`:return{...e,editingKey:t.payload.key,editingRecord:t.payload.record};case`CANCEL_EDIT`:return{...e,editingKey:null,editingRecord:null};case`SAVE_EDIT`:return{...e,editingKey:null,editingRecord:null,data:e.data.map(e=>e.id===t.payload.id?t.payload:e)};case`RESET`:return{...e,current:1,filters:{},sorter:{},selectedRowKeys:[],selectedRows:[],editingKey:null,editingRecord:null};default:return e}}function Be(e){let{columns:t=[],dataSource:n,request:r,params:i={},postData:a,defaultData:o=[],loading:s,rowKey:u=`id`,rowSelection:d,pagination:f,onLoad:p,onLoadingChange:m,onRequestError:h}=e,g={loading:s??!1,data:n??o,total:n?.length??0,current:f===!1?1:f?.current??1,pageSize:f===!1?10:f?.pageSize??10,filters:{},sorter:{},selectedRowKeys:d===!1?[]:d?.selectedRowKeys??[],selectedRows:[],editingKey:null,editingRecord:null},[_,v]=(0,c.useReducer)(ze,g),y=(0,c.useRef)(null),[b,x]=c.default.useState([]),[S,C]=c.default.useState([]),[w,T]=c.default.useState({}),[E,D]=c.default.useState({}),O=(0,c.useCallback)(e=>typeof u==`function`?String(u(e)):String(e[u]),[u]),k=(0,c.useCallback)(async e=>{if(r){v({type:`SET_LOADING`,payload:!0}),m?.(!0);try{let t={current:e?.current??_.current,pageSize:e?.pageSize??_.pageSize,...i,..._.filters,..._.sorter},n=await r(t),o=n.data||[];a&&(o=a(o)),v({type:`SET_DATA`,payload:{data:o,total:n.total}}),e&&v({type:`SET_PAGINATION`,payload:e}),p?.(o)}catch(e){console.error(`ProTable request error:`,e),h?.(e)}finally{v({type:`SET_LOADING`,payload:!1}),m?.(!1)}}},[r,i,_.current,_.pageSize,_.filters,_.sorter,a,p,m,h]),A=(0,c.useMemo)(()=>t.filter(e=>!e.hideInTable).map(e=>({id:e.key||String(e.dataIndex),accessorKey:e.dataIndex,header:e.title,cell:e.render?({row:t,getValue:n})=>e.render?.(n(),t.original,t.index):({getValue:e})=>e(),enableSorting:!!e.sorter,filterFn:e.onFilter?((t,n,r)=>{let i=t.getValue(n);return e.onFilter(i,t.original)}):((e,t,n)=>{if(!n||n.length===0)return!0;let r=e.getValue(t);return n.includes(r)}),...e})),[t]),j=(0,l.useReactTable)({data:_.data,columns:A,state:{sorting:b,columnFilters:S,columnVisibility:w,rowSelection:E,pagination:{pageIndex:_.current-1,pageSize:_.pageSize}},onSortingChange:x,onColumnFiltersChange:C,onColumnVisibilityChange:T,onRowSelectionChange:D,getCoreRowModel:(0,l.getCoreRowModel)(),getFilteredRowModel:(0,l.getFilteredRowModel)(),getPaginationRowModel:(0,l.getPaginationRowModel)(),getSortedRowModel:(0,l.getSortedRowModel)(),getRowId:O,manualPagination:!!r,pageCount:Math.ceil(_.total/_.pageSize),columnResizeMode:`onChange`}),M=(0,c.useCallback)((e,t)=>{r?k({current:e,pageSize:t}):v({type:`SET_PAGINATION`,payload:{current:e,pageSize:t}}),f!==!1&&f?.onChange?.(e,t)},[r,k,f]),N=(0,c.useCallback)(e=>{v({type:`SET_FILTERS`,payload:e}),r&&k({current:1})},[r,k]),ee=(0,c.useCallback)(()=>{v({type:`RESET`}),r&&k({current:1})},[r,k]);(0,c.useEffect)(()=>{if(r&&b.length>0){let e=b[0].id,t=b[0].desc?`desc`:`asc`;v({type:`SET_SORTER`,payload:{field:e,order:t}}),k({current:1})}},[b,r]);let P={reload:async(e=!1)=>{await k(e?{current:1}:void 0)},reloadAndRest:async()=>{v({type:`RESET`}),await k({current:1})},reset:()=>{v({type:`RESET`})},clearSelected:()=>{D({}),v({type:`SET_SELECTION`,payload:{keys:[],rows:[]}})},startEditable:e=>{let t=_.data.find(t=>O(t)===String(e));return t?(v({type:`START_EDIT`,payload:{key:e,record:t}}),!0):!1},cancelEditable:e=>(v({type:`CANCEL_EDIT`}),!0),saveEditable:(e,t)=>(v({type:`SAVE_EDIT`,payload:t}),!0),getRowData:e=>_.data.find(t=>O(t)===String(e)),getTableData:()=>_.data,setTableData:e=>{v({type:`SET_DATA`,payload:{data:e}})}};return(0,c.useEffect)(()=>{y.current&&Object.assign(y.current,P)}),(0,c.useEffect)(()=>{r&&!n&&k()},[]),(0,c.useEffect)(()=>{n&&v({type:`SET_DATA`,payload:{data:n,total:n.length}})},[n]),{table:j,state:_,dispatch:v,actions:P,handlers:{handlePaginationChange:M,handleSearch:N,handleReset:ee}}}function Ve(e){let{columns:t,rowSelection:n,draggable:r,editable:i}=e,[a,o]=(0,c.useState)(()=>t.filter(e=>!e.hideInTable).map(e=>e.key||String(e.dataIndex))),[s,l]=(0,c.useState)({}),u=(0,c.useMemo)(()=>t.filter(e=>!e.hideInSearch&&(e.search===!0||typeof e.search==`object`)),[t]);return{tableColumns:(0,c.useMemo)(()=>{let e=[];return r&&e.push({id:`__drag__`,header:``,cell:()=>null,size:40,enableSorting:!1,enableHiding:!1}),n&&e.push({id:`__select__`,header:()=>null,cell:()=>null,size:40,enableSorting:!1,enableHiding:!1}),t.forEach(t=>{if(t.hideInTable)return;let n=t.key||String(t.dataIndex),r=s[n]||{},a={id:n,accessorKey:t.dataIndex,header:t.title,cell:({getValue:e,row:n})=>{let a=e();return i&&t.editable&&(typeof t.editable==`function`?t.editable(n.original):t.editable)?a:t.render?t.render(a,n.original,n.index):t.valueType?be(t.valueType,a,{...t,...r}):a},enableSorting:!!t.sorter,enableHiding:!0,size:t.width,...r};e.push(a)}),i&&e.push({id:`__actions__`,header:`Actions`,cell:()=>null,size:120,enableSorting:!1,enableHiding:!1}),e},[t,n,r,i,s]),searchColumns:u,visibleColumns:a,setVisibleColumns:o,columnSettings:s,updateColumnSettings:(e,t)=>{l(n=>({...n,[e]:{...n[e],...t}}))}}}function W({className:e,type:t,...n}){return(0,h.jsx)(`input`,{type:t,"data-slot":`input`,className:B(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...n})}function G({...e}){return(0,h.jsx)(x.Root,{"data-slot":`dropdown-menu`,...e})}function He({...e}){return(0,h.jsx)(x.Portal,{"data-slot":`dropdown-menu-portal`,...e})}function K({...e}){return(0,h.jsx)(x.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function q({className:e,sideOffset:t=4,...n}){return(0,h.jsx)(x.Portal,{children:(0,h.jsx)(x.Content,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md`,e),...n})})}function Ue({...e}){return(0,h.jsx)(x.Group,{"data-slot":`dropdown-menu-group`,...e})}function J({className:e,inset:t,variant:n=`default`,...r}){return(0,h.jsx)(x.Item,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:B(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive! [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function We({className:e,children:t,checked:n,...r}){return(0,h.jsxs)(x.CheckboxItem,{"data-slot":`dropdown-menu-checkbox-item`,className:B(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,h.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,h.jsx)(x.ItemIndicator,{children:(0,h.jsx)(b.CheckIcon,{className:`size-4`})})}),t]})}function Ge({...e}){return(0,h.jsx)(x.RadioGroup,{"data-slot":`dropdown-menu-radio-group`,...e})}function Ke({className:e,children:t,...n}){return(0,h.jsxs)(x.RadioItem,{"data-slot":`dropdown-menu-radio-item`,className:B(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,h.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,h.jsx)(x.ItemIndicator,{children:(0,h.jsx)(b.CircleIcon,{className:`size-2 fill-current`})})}),t]})}function qe({className:e,inset:t,...n}){return(0,h.jsx)(x.Label,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:B(`px-2 py-1.5 text-sm font-medium data-inset:pl-8`,e),...n})}function Y({className:e,...t}){return(0,h.jsx)(x.Separator,{"data-slot":`dropdown-menu-separator`,className:B(`bg-border -mx-1 my-1 h-px`,e),...t})}function Je({className:e,...t}){return(0,h.jsx)(`span`,{"data-slot":`dropdown-menu-shortcut`,className:B(`text-muted-foreground ml-auto text-xs tracking-widest`,e),...t})}function Ye({...e}){return(0,h.jsx)(x.Sub,{"data-slot":`dropdown-menu-sub`,...e})}function Xe({className:e,inset:t,children:n,...r}){return(0,h.jsxs)(x.SubTrigger,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:B(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,h.jsx)(b.ChevronRightIcon,{className:`ml-auto size-4`})]})}function Ze({className:e,...t}){return(0,h.jsx)(x.SubContent,{"data-slot":`dropdown-menu-sub-content`,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg`,e),...t})}function Qe({delayDuration:e=0,...t}){return(0,h.jsx)(S.Provider,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function X({...e}){return(0,h.jsx)(Qe,{children:(0,h.jsx)(S.Root,{"data-slot":`tooltip`,...e})})}function Z({...e}){return(0,h.jsx)(S.Trigger,{"data-slot":`tooltip-trigger`,...e})}function Q({className:e,sideOffset:t=0,children:n,...r}){return(0,h.jsx)(S.Portal,{children:(0,h.jsxs)(S.Content,{"data-slot":`tooltip-content`,sideOffset:t,className:B(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,h.jsx)(S.Arrow,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}const $e={search:{searchText:`Search`,resetText:`Reset`,submitText:`Submit`,expandText:`Expand`,collapseText:`Collapse`,selectPlaceholder:`Select`,inputPlaceholder:`Enter`},pagination:{total:(e,t)=>`Page ${t[0]}-${t[1]} of ${e}`,items:`items`,page:`Page`,of:`of`,showTotal:`Show`},toolbar:{reload:`Reload`,density:`Density`,columnSetting:`Column Setting`,fullScreen:`Full Screen`,exitFullScreen:`Exit Full Screen`,compact:`Compact`,default:`Default`,comfortable:`Comfortable`,searchPlaceholder:`Search...`},columnSetting:{title:`Column Setting`,fixedLeft:`Fixed Left`,fixedRight:`Fixed Right`,noFixed:`No Fixed`,show:`Show`,hide:`Hide`,reset:`Reset`},batchActions:{selected:`selected`,clear:`Clear`,delete:`Delete`,export:`Export`},editable:{save:`Save`,cancel:`Cancel`,edit:`Edit`,delete:`Delete`},common:{confirm:`Confirm`,cancel:`Cancel`,noData:`No data available`,loading:`Loading...`,selectAll:`Select all`,copySuccess:`Copied successfully`}};var et=(0,c.createContext)(void 0);function tt({locale:e,children:t}){let n=c.default.useMemo(()=>{let t=(e,n)=>{let r={...e};for(let i in n)n[i]&&typeof n[i]==`object`&&!Array.isArray(n[i])?r[i]=t(e[i]||{},n[i]):r[i]=n[i];return r};return t($e,e||{})},[e]);return(0,h.jsx)(et.Provider,{value:{locale:n},children:t})}function nt(){let e=(0,c.useContext)(et);if(e===void 0)throw Error(`useLocale must be used within a LocaleProvider`);return e.locale}function rt({id:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=(0,T.useSortable)({id:e}),c={transform:E.CSS.Transform.toString(a),transition:o,opacity:s?.6:1};return(0,h.jsxs)(`div`,{ref:i,style:c,className:`flex items-center`,children:[(0,h.jsx)(`div`,{...r,...n,role:`button`,tabIndex:0,"aria-label":`Drag column`,className:`mr-2 p-1 rounded hover:bg-muted/20 cursor-move flex items-center justify-center`,children:(0,h.jsx)(C.IconGripVertical,{className:`h-4 w-4`})}),(0,h.jsx)(`div`,{className:`flex-1`,children:t})]})}function it({table:e,columns:t,visibleColumns:n,onVisibleChange:r,fixedColumns:i={},onFixedChange:a,onOrderChange:o}){let s=nt(),l=t.filter(e=>e.enableHiding!==!1&&!e.hideInTable),u=l.map(e=>e.key||String(e.dataIndex)),[d,f]=(0,c.useState)(()=>({...i||{}}));(0,c.useEffect)(()=>{f({...i||{}})},[i]);let p=(t,i)=>{r(i?Array.from(new Set([...n,t])):n.filter(e=>e!==t));try{if(e&&typeof e.getAllColumns==`function`){let n=e.getAllColumns().filter(e=>e.accessorFn!==void 0&&e.getCanHide()).find(e=>e.id===t);n&&typeof n.toggleVisibility==`function`&&n.toggleVisibility(i)}}catch{}},m=(e,t)=>{f(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),a?.(e,t)};return(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:(0,h.jsx)(C.IconSettings,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{align:`end`,className:`w-64`,children:[(0,h.jsx)(qe,{children:s.columnSetting.title}),(0,h.jsx)(Y,{}),(0,h.jsx)(`div`,{className:`max-h-96 overflow-y-auto`,children:(0,h.jsx)(w.DndContext,{collisionDetection:w.closestCenter,modifiers:[D.restrictToVerticalAxis],onDragEnd:e=>{let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=l.findIndex(e=>(e.key||String(e.dataIndex))===n.id),a=l.findIndex(e=>(e.key||String(e.dataIndex))===r.id);if(i!==-1&&a!==-1&&typeof o==`function`){let e=[...l],[n]=e.splice(i,1);e.splice(a,0,n);let r=[],s=new Map(e.map(e=>[e.key||String(e.dataIndex),e]));for(let n of t){let t=n.key||String(n.dataIndex);if(s.has(t)){let t=e.shift();r.push(t)}else r.push(n)}e.length>0&&r.push(...e),o(r)}},autoScroll:{enabled:!1},children:(0,h.jsx)(T.SortableContext,{items:u,strategy:T.verticalListSortingStrategy,children:l.map(e=>{let t=e.key||String(e.dataIndex),r=n.includes(t),i=d?.[t]??void 0;return(0,h.jsx)(rt,{id:t,children:(0,h.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5 hover:bg-muted`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:e=>{e.stopPropagation(),p(t,!r)},"aria-pressed":r,title:r?s.columnSetting.hide:s.columnSetting.show,children:r?(0,h.jsx)(C.IconEye,{className:`h-4 w-4`}):(0,h.jsx)(C.IconEyeOff,{className:`h-4 w-4`})}),(0,h.jsx)(`span`,{className:B(`text-sm`,!r&&`text-muted-foreground line-through`),children:e.title??t})]}),(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,children:i?(0,h.jsx)(C.IconPin,{className:`h-4 w-4`}):(0,h.jsx)(C.IconPinEnd,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{side:`left`,children:[(0,h.jsx)(J,{onClick:()=>m(t,void 0),children:s.columnSetting.noFixed}),(0,h.jsx)(J,{onClick:()=>m(t,`left`),children:s.columnSetting.fixedLeft}),(0,h.jsx)(J,{onClick:()=>m(t,`right`),children:s.columnSetting.fixedRight})]})]})]})},t)})})})}),(0,h.jsx)(Y,{}),(0,h.jsxs)(`div`,{className:`flex gap-2 p-2`,children:[(0,h.jsxs)(U,{size:`sm`,variant:`outline`,className:`flex-1`,onClick:()=>r(u),children:[s.columnSetting.show,` All`]}),(0,h.jsxs)(U,{size:`sm`,variant:`outline`,className:`flex-1`,onClick:()=>r([]),children:[s.columnSetting.hide,` All`]})]})]})]})}function at({title:e,subTitle:t,search:n,actions:r=[],settings:i=!0,filter:a,table:o,columns:s,loading:l,onReload:u,fullScreen:d=!1,onFullScreenChange:f,density:p=`middle`,onDensityChange:m,visibleColumns:g=[],onVisibleColumnsChange:_,columnSettings:v,onColumnSettingsChange:y}){let x=nt(),[S,C]=c.default.useState(``),w=e=>{e.preventDefault(),typeof n==`object`&&n.onSearch&&n.onSearch(S)},T=e=>{e.key===`Enter`&&(e.preventDefault(),typeof n==`object`&&n.onSearch&&n.onSearch(S))},E=Array.isArray(i)?i:i===!0?[`columnSettings`,`density`,`reload`,`fullScreen`]:[];return(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 py-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e&&(0,h.jsx)(`h3`,{className:`text-lg font-semibold leading-none`,children:e}),t&&(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:t})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,h.jsxs)(`form`,{onSubmit:w,className:`relative`,children:[(0,h.jsx)(W,{placeholder:typeof n==`object`?n.placeholder:x.toolbar.searchPlaceholder,value:S,onChange:e=>C(e.target.value),onKeyDown:T,className:`h-8 w-[200px] pr-8`}),(0,h.jsx)(b.Search,{className:`absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`})]}),r.map((e,t)=>(0,h.jsx)(c.default.Fragment,{children:e},t)),E.length>0&&(0,h.jsx)(`div`,{className:`flex items-center gap-1 border-l pl-2`,children:(0,h.jsxs)(Qe,{children:[E.includes(`reload`)&&(0,h.jsxs)(X,{children:[(0,h.jsx)(Z,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:u,disabled:l,children:(0,h.jsx)(b.RotateCw,{className:`h-4 w-4 ${l?`animate-spin`:``}`})})}),(0,h.jsx)(Q,{children:(0,h.jsx)(`p`,{children:x.toolbar.reload})})]}),E.includes(`density`)&&(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:(0,h.jsx)(b.Settings2,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{align:`end`,children:[(0,h.jsx)(qe,{children:x.toolbar.density}),(0,h.jsx)(Y,{}),(0,h.jsx)(We,{checked:p===`small`,onCheckedChange:()=>m?.(`small`),children:x.toolbar.compact}),(0,h.jsx)(We,{checked:p===`middle`,onCheckedChange:()=>m?.(`middle`),children:x.toolbar.default}),(0,h.jsx)(We,{checked:p===`large`,onCheckedChange:()=>m?.(`large`),children:x.toolbar.comfortable})]})]}),E.includes(`columnSettings`)&&_&&(0,h.jsx)(it,{table:o,columns:s,visibleColumns:g,onVisibleChange:_,fixedColumns:v?.fixed||{},onFixedChange:(e,t)=>y?.(e,{fixed:t}),onOrderChange:e=>y?.(`order`,e)}),E.includes(`fullScreen`)&&(0,h.jsxs)(X,{children:[(0,h.jsx)(Z,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>f?.(!d),children:d?(0,h.jsx)(b.Minimize2,{className:`h-4 w-4`}):(0,h.jsx)(b.Maximize2,{className:`h-4 w-4`})})}),(0,h.jsx)(Q,{children:(0,h.jsx)(`p`,{children:d?x.toolbar.exitFullScreen:x.toolbar.fullScreen})})]})]})})]})]}),a&&(0,h.jsx)(`div`,{className:`border-t pt-3`,children:a})]})}function ot({column:e,value:t=[],onChange:n,onClear:r}){let[i,a]=(0,c.useState)(!1),o=Array.isArray(t)?t:[],s=(e,t)=>{t?n?.([...o,e]):n?.(o.filter(t=>t!==e))},l=()=>{n?.([]),r?.(),a(!1)},u=o.length>0;return(0,h.jsxs)(G,{open:i,onOpenChange:a,children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`sm`,className:B(`h-6 w-6 p-0 hover:bg-muted`,u&&`bg-primary/10 text-primary`),children:(0,h.jsx)(b.Filter,{className:`h-3 w-3`})})}),(0,h.jsx)(q,{align:`start`,className:`w-48`,children:(0,h.jsxs)(`div`,{className:`p-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,h.jsxs)(`span`,{className:`text-sm font-medium`,children:[`筛选 `,e.title]}),u&&(0,h.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:l,children:(0,h.jsx)(b.X,{className:`h-3 w-3`})})]}),(0,h.jsx)(`div`,{className:`space-y-1 max-h-48 overflow-y-auto`,children:e.filters?.map(t=>(0,h.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,h.jsx)(ke,{id:`filter-${e.key||e.dataIndex}-${t.value}`,checked:o.includes(t.value),onCheckedChange:e=>s(t.value,!!e)}),(0,h.jsx)(`label`,{htmlFor:`filter-${e.key||e.dataIndex}-${t.value}`,className:`text-sm cursor-pointer flex-1`,children:t.text})]},String(t.value)))})]})})]})}function st({...e}){return(0,h.jsx)(O.Root,{"data-slot":`select`,...e})}function ct({...e}){return(0,h.jsx)(O.Group,{"data-slot":`select-group`,...e})}function lt({...e}){return(0,h.jsx)(O.Value,{"data-slot":`select-value`,...e})}function ut({className:e,size:t=`default`,children:n,...r}){return(0,h.jsxs)(O.Trigger,{"data-slot":`select-trigger`,"data-size":t,className:B(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,h.jsx)(O.Icon,{asChild:!0,children:(0,h.jsx)(b.ChevronDownIcon,{className:`size-4 opacity-50`})})]})}function dt({className:e,children:t,position:n=`popper`,align:r=`center`,...i}){return(0,h.jsx)(O.Portal,{children:(0,h.jsxs)(O.Content,{"data-slot":`select-content`,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,n===`popper`&&!e?.includes(`w-`)&&`w-[var(--radix-select-trigger-width)]`,e),position:n,align:r,...i,children:[(0,h.jsx)(mt,{}),(0,h.jsx)(O.Viewport,{className:B(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,h.jsx)(ht,{})]})})}function ft({className:e,...t}){return(0,h.jsx)(O.Label,{"data-slot":`select-label`,className:B(`text-muted-foreground px-2 py-1.5 text-xs`,e),...t})}function $({className:e,children:t,...n}){return(0,h.jsxs)(O.Item,{"data-slot":`select-item`,className:B(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,h.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,h.jsx)(O.ItemIndicator,{children:(0,h.jsx)(b.CheckIcon,{className:`size-4`})})}),(0,h.jsx)(O.ItemText,{children:t})]})}function pt({className:e,...t}){return(0,h.jsx)(O.Separator,{"data-slot":`select-separator`,className:B(`bg-border pointer-events-none -mx-1 my-1 h-px`,e),...t})}function mt({className:e,...t}){return(0,h.jsx)(O.ScrollUpButton,{"data-slot":`select-scroll-up-button`,className:B(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,h.jsx)(b.ChevronUpIcon,{className:`size-4`})})}function ht({className:e,...t}){return(0,h.jsx)(O.ScrollDownButton,{"data-slot":`select-scroll-down-button`,className:B(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,h.jsx)(b.ChevronDownIcon,{className:`size-4`})})}var gt=768;function _t(){let[e,t]=c.useState(void 0);return c.useEffect(()=>{let e=window.matchMedia(`(max-width: ${gt-1}px)`),n=()=>{t(window.innerWidth<gt)};return e.addEventListener(`change`,n),t(window.innerWidth<gt),()=>e.removeEventListener(`change`,n)},[]),!!e}function vt({current:e=1,pageSize:t=10,total:n=0,showSizeChanger:r=!0,showQuickJumper:i=!1,showTotal:a,pageSizeOptions:o=[`10`,`20`,`50`,`100`],size:s=`default`,simple:c=!1,disabled:l=!1,onChange:u,onShowSizeChange:d,onPaginationChange:f}){let p=nt(),m=_t(),g=Math.max(1,Math.ceil(n/t)),_=Math.min(Math.max(e,1),g),v=l||_<=1,y=l||_>=g,b=e=>{let n=Math.min(Math.max(e,1),g);n!==_&&(u?.(n,t),f?.(n,t))},x=e=>{let t=Number(e);d?.(_,t),f?.(1,t)};if(c||m)return(0,h.jsxs)(`div`,{className:B(`flex w-full flex-col gap-2 rounded-lg border border-border/60 bg-card/60 p-3`,!m&&c&&`w-auto flex-row items-center justify-center gap-2 border-none bg-transparent p-0`),children:[(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,m?`justify-between`:`justify-center`),children:[(0,h.jsx)(U,{variant:`outline`,size:s===`small`||m?`sm`:`default`,onClick:()=>b(_-1),disabled:v,children:(0,h.jsx)(C.IconChevronLeft,{className:`h-4 w-4`})}),(0,h.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[p.pagination.page,` `,_,` `,p.pagination.of,` `,g]}),(0,h.jsx)(U,{variant:`outline`,size:s===`small`||m?`sm`:`default`,onClick:()=>b(_+1),disabled:y,children:(0,h.jsx)(C.IconChevronRight,{className:`h-4 w-4`})})]}),r&&!c&&(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md bg-background/80 px-2 py-1 text-xs text-muted-foreground`,children:[(0,h.jsx)(`span`,{children:p.pagination.showTotal}),(0,h.jsxs)(st,{value:String(t),onValueChange:x,disabled:l,children:[(0,h.jsx)(ut,{size:`sm`,className:`h-8 w-[110px]`,id:`rows-per-page-mobile`,children:(0,h.jsx)(lt,{placeholder:t})}),(0,h.jsx)(dt,{children:o.map(e=>(0,h.jsx)($,{value:e,children:e},e))})]})]})]});let S=(_-1)*t+1,w=Math.min(_*t,n);return(0,h.jsxs)(`div`,{className:B(`px-4 py-3`,m?`flex flex-col gap-3 rounded-lg border border-border/60 bg-card/60`:`flex items-center justify-between`),children:[(0,h.jsx)(`div`,{className:`flex flex-1 items-center gap-4`,children:a?(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:a(n,[S,w])}):(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:p.pagination.total?.(n,[S,w])})}),(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,m&&`flex-wrap justify-between gap-3`),children:[r&&(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,m&&`order-2 w-full justify-between`),children:[(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:p.pagination.showTotal}),(0,h.jsxs)(st,{value:String(t),onValueChange:x,disabled:l,children:[(0,h.jsx)(ut,{size:`sm`,className:B(`h-8 w-20`,m&&`w-[120px]`),id:`rows-per-page`,children:(0,h.jsx)(lt,{})}),(0,h.jsx)(dt,{children:o.map(e=>(0,h.jsx)($,{value:e,children:e},e))})]}),(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground leading-none`,children:p.pagination.items})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(1),disabled:v,children:(0,h.jsx)(C.IconChevronsLeft,{className:`h-4 w-4`})}),(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(_-1),disabled:v,children:(0,h.jsx)(C.IconChevronLeft,{className:`h-4 w-4`})}),(0,h.jsxs)(`span`,{className:`px-2 text-sm`,children:[p.pagination.page,` `,_,` `,p.pagination.of,` `,g]}),(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(_+1),disabled:y,children:(0,h.jsx)(C.IconChevronRight,{className:`h-4 w-4`})}),(0,h.jsx)(U,{variant:`outline`,size:`icon`,className:`h-8 w-8`,onClick:()=>b(g),disabled:y,children:(0,h.jsx)(C.IconChevronsRight,{className:`h-4 w-4`})})]}),i&&(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:p.pagination.page}),(0,h.jsx)(`input`,{type:`number`,min:1,max:g,className:`h-8 w-[50px] rounded border px-2 text-center text-sm`,onKeyDown:e=>{if(e.key===`Enter`){let t=Number(e.target.value);t>=1&&t<=g&&b(t)}},disabled:l})]})]})]})}function yt({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,formatters:a,components:o,...s}){let c=(0,k.getDefaultClassNames)();return(0,h.jsx)(k.DayPicker,{showOutsideDays:n,className:B(`bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:e=>e.toLocaleString(`default`,{month:`short`}),...a},classNames:{root:B(`w-fit`,c.root),months:B(`flex gap-4 flex-col md:flex-row relative`,c.months),month:B(`flex flex-col w-full gap-4`,c.month),nav:B(`flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between`,c.nav),button_previous:B(Re({variant:i}),`size-(--cell-size) aria-disabled:opacity-50 p-0 select-none`,c.button_previous),button_next:B(Re({variant:i}),`size-(--cell-size) aria-disabled:opacity-50 p-0 select-none`,c.button_next),month_caption:B(`flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)`,c.month_caption),dropdowns:B(`w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5`,c.dropdowns),dropdown_root:B(`relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md`,c.dropdown_root),dropdown:B(`absolute bg-popover inset-0 opacity-0`,c.dropdown),caption_label:B(`select-none font-medium`,r===`label`?`text-sm`:`rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5`,c.caption_label),table:`w-full border-collapse`,weekdays:B(`flex`,c.weekdays),weekday:B(`text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none`,c.weekday),week:B(`flex w-full mt-2`,c.week),week_number_header:B(`select-none w-(--cell-size)`,c.week_number_header),week_number:B(`text-[0.8rem] select-none text-muted-foreground`,c.week_number),day:B(`relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none`,c.day),range_start:B(`rounded-l-md bg-accent`,c.range_start),range_middle:B(`rounded-none`,c.range_middle),range_end:B(`rounded-r-md bg-accent`,c.range_end),today:B(`bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none`,c.today),outside:B(`text-muted-foreground aria-selected:text-muted-foreground`,c.outside),disabled:B(`text-muted-foreground opacity-50`,c.disabled),hidden:B(`invisible`,c.hidden),...t},components:{Root:({className:e,rootRef:t,...n})=>(0,h.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:B(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,h.jsx)(b.ChevronLeftIcon,{className:B(`size-4`,e),...n}):t===`right`?(0,h.jsx)(b.ChevronRightIcon,{className:B(`size-4`,e),...n}):(0,h.jsx)(b.ChevronDownIcon,{className:B(`size-4`,e),...n}),DayButton:bt,WeekNumber:({children:e,...t})=>(0,h.jsx)(`td`,{...t,children:(0,h.jsx)(`div`,{className:`flex size-(--cell-size) items-center justify-center text-center`,children:e})}),...o},...s})}function bt({className:e,day:t,modifiers:n,...r}){let i=(0,k.getDefaultClassNames)(),a=c.useRef(null);return c.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),(0,h.jsx)(U,{ref:a,variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:B(`data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70`,i.day,e),...r})}function xt({...e}){return(0,h.jsx)(A.Root,{"data-slot":`popover`,...e})}function St({...e}){return(0,h.jsx)(A.Trigger,{"data-slot":`popover-trigger`,...e})}function Ct({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,h.jsx)(A.Portal,{children:(0,h.jsx)(A.Content,{"data-slot":`popover-content`,align:t,sideOffset:n,className:B(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden`,e),...r})})}function wt({...e}){return(0,h.jsx)(A.Anchor,{"data-slot":`popover-anchor`,...e})}function Tt({value:e,onChange:t,placeholder:n=`Pick a date`,className:r,disabled:i,fromDate:a,toDate:o,formatStr:s=`PPP`,align:c=`start`,sideOffset:l=4}){return(0,h.jsxs)(xt,{children:[(0,h.jsx)(St,{asChild:!0,children:(0,h.jsxs)(U,{variant:`outline`,className:B(`h-8 w-full justify-start text-left font-normal`,!e&&`text-muted-foreground`,r),disabled:i,children:[(0,h.jsx)(b.Calendar,{className:`mr-2 h-4 w-4`}),e?(0,f.format)(e,s):(0,h.jsx)(`span`,{children:n})]})}),(0,h.jsx)(Ct,{className:`w-auto p-0`,align:c,sideOffset:l,children:(0,h.jsx)(yt,{mode:`single`,selected:e,onSelect:t,disabled:i,fromDate:a,toDate:o,initialFocus:!0})})]})}function Et({value:e,onChange:t,placeholder:n=`Pick a date range`,className:r,disabled:i,fromDate:a,toDate:o,formatStr:s=`LLL dd, y`,align:c=`start`,sideOffset:l=4,numberOfMonths:u=2}){return(0,h.jsx)(`div`,{className:B(`w-full`,r),children:(0,h.jsxs)(xt,{children:[(0,h.jsx)(St,{asChild:!0,children:(0,h.jsxs)(U,{id:`date`,variant:`outline`,className:B(`h-8 w-full justify-start text-left font-normal`,!e&&`text-muted-foreground`),disabled:i,children:[(0,h.jsx)(b.Calendar,{className:`mr-2 h-4 w-4`}),e?.from?e.to?(0,h.jsxs)(h.Fragment,{children:[(0,f.format)(e.from,s),` -`,` `,(0,f.format)(e.to,s)]}):(0,f.format)(e.from,s):(0,h.jsx)(`span`,{children:n})]})}),(0,h.jsx)(Ct,{className:`w-auto p-0`,align:c,sideOffset:l,children:(0,h.jsx)(yt,{initialFocus:!0,mode:`range`,defaultMonth:e?.from,selected:e,onSelect:t,numberOfMonths:u,disabled:i,fromDate:a,toDate:o})})]})})}function Dt({className:e,...t}){return(0,h.jsx)(j.Root,{"data-slot":`label`,className:B(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Ot({columns:e,onSearch:t,onReset:n,loading:r,filterType:i=`query`,searchText:a,resetText:o,submitText:s,defaultCollapsed:l=!0,collapsed:u,onCollapse:d,optionRender:f}){let p=nt(),{control:m,register:g,handleSubmit:_,reset:v,watch:y}=(0,M.useForm)({defaultValues:{}}),[x,S]=(0,c.useState)(u??l),C=u!==void 0,w=C?u:x;(0,c.useEffect)(()=>{C&&S(u??l)},[u]);let T=()=>{C||S(!x),d?.(!w)},E=e=>{t?.(e)},D=()=>{v({}),n?.()},O=e=>{let t=e.key||String(e.dataIndex);switch(e.valueType){case`select`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:n})=>(0,h.jsxs)(st,{value:n.value,onValueChange:e=>n.onChange(e),children:[(0,h.jsx)(ut,{size:`sm`,className:`h-8 w-full`,children:(0,h.jsx)(lt,{placeholder:`${p.search.selectPlaceholder} ${e.title}`})}),(0,h.jsx)(dt,{position:`popper`,className:`w-[var(--radix-select-trigger-width)]`,children:e.valueEnum?Object.entries(e.valueEnum).map(([e,n])=>(0,h.jsx)($,{value:e,children:n.text},`${t}-${e}`)):e.filters?.map(e=>(0,h.jsx)($,{value:e.value,children:e.text},`${t}-filter-${String(e.value)}`))})]})});case`date`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(Tt,{value:t.value,onChange:e=>t.onChange(e),className:`h-8 w-full`,placeholder:`${p.search.selectPlaceholder} ${e.title}`,formatStr:`PP`})});case`dateTime`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(Tt,{value:t.value,onChange:e=>t.onChange(e),className:`h-8 w-full`,placeholder:`${p.search.selectPlaceholder} ${e.title}`,formatStr:`PPp`})});case`dateRange`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(Et,{value:t.value,onChange:e=>t.onChange(e),className:`w-full`,placeholder:`${p.search.selectPlaceholder} ${e.title} range`,numberOfMonths:2})});case`number`:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(W,{type:`number`,value:t.value??``,onChange:e=>t.onChange(e.target.value?Number(e.target.value):void 0),placeholder:`${p.search.inputPlaceholder} ${e.title}`,className:`h-8 w-full`})});case`switch`:return(0,h.jsx)(M.Controller,{control:m,name:t,defaultValue:!1,render:({field:e})=>(0,h.jsx)(`div`,{className:`flex items-center h-8`,children:(0,h.jsx)(_e,{id:t,checked:!!e.value,onCheckedChange:t=>e.onChange(t)})})});default:return(0,h.jsx)(M.Controller,{control:m,name:t,render:({field:t})=>(0,h.jsx)(W,{value:t.value??``,onChange:e=>t.onChange(e.target.value),placeholder:`${p.search.inputPlaceholder} ${e.title}`,className:`h-8 w-full`})})}};if(i===`light`)return(0,h.jsxs)(`form`,{className:`flex items-center gap-2 px-4 py-2`,onSubmit:_(E),children:[(0,h.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,h.jsx)(W,{placeholder:a||p.search.searchText,...g(`keyword`),onKeyDown:e=>{e.key},className:`h-8 pr-8`}),(0,h.jsx)(b.Search,{className:`absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`})]}),(0,h.jsx)(U,{size:`sm`,type:`submit`,disabled:r,children:s||p.search.submitText}),(0,h.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{D()},children:o||p.search.resetText})]});let k=e.filter(e=>!e.hideInSearch&&(e.search===!0||typeof e.search==`object`));if(k.length===0)return null;let A=k.length>3,j=[(0,h.jsxs)(U,{size:`sm`,onClick:_(E),disabled:r,children:[(0,h.jsx)(b.Search,{className:`mr-1 h-4 w-4`}),s||p.search.submitText]},`search`),(0,h.jsxs)(U,{size:`sm`,variant:`outline`,onClick:D,children:[(0,h.jsx)(b.RotateCw,{className:`mr-1 h-4 w-4`}),o||p.search.resetText]},`reset`)];A&&j.push((0,h.jsx)(U,{size:`sm`,variant:`ghost`,onClick:T,children:w?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(b.ChevronDown,{className:`mr-1 h-4 w-4`}),p.search.expandText]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(b.ChevronUp,{className:`mr-1 h-4 w-4`}),p.search.collapseText]})},`collapse`));let N=f?f({collapsed:w},y(),j):j;return(0,h.jsxs)(`form`,{className:`border-b bg-muted/30 px-4 py-3 overflow-visible`,onSubmit:_(E),children:[(0,h.jsx)(`div`,{className:B(`grid gap-4 transition-all duration-300 ease-in-out`,`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,w?`max-h-15`:`max-h-[500px]`),style:{overflow:w?`clip`:`visible`},children:k.map(e=>{let t=e.key||String(e.dataIndex),n=e.formItemProps?.required;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,h.jsxs)(Dt,{htmlFor:t,className:`text-sm font-medium`,children:[e.title,n&&(0,h.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,h.jsx)(`div`,{className:`w-full min-w-0`,children:e.renderFormItem?e.renderFormItem(y()[t],{}):O(e)})]},t)})}),(0,h.jsx)(`div`,{className:`mt-3 flex items-center justify-end gap-2`,children:N})]})}var kt=(0,m.cva)(`relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90`}},defaultVariants:{variant:`default`}});function At({className:e,variant:t,...n}){return(0,h.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:B(kt({variant:t}),e),...n})}function jt({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`alert-title`,className:B(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),...t})}function Mt({className:e,...t}){return(0,h.jsx)(`div`,{"data-slot":`alert-description`,className:B(`text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed`,e),...t})}function Nt({selectedCount:e,selectedRows:t,onDelete:n,onExport:r,onExportExcel:i,onExportCSV:a,onEmail:o,onArchive:s,customActions:c=[],disabled:l=!1,className:u}){if(e===0)return null;let d=()=>{n&&t.length>0&&n(t)},f=()=>{r&&t.length>0&&r(t)},p=()=>{i&&t.length>0&&i(t)},m=()=>{a&&t.length>0&&a(t)},g=()=>{o&&t.length>0&&o(t)},_=()=>{s&&t.length>0&&s(t)},v=n||r||i||a||o||s,y=c.length>0;return(0,h.jsxs)(`div`,{className:B(`flex items-center gap-2`,u),children:[v&&(0,h.jsxs)(h.Fragment,{children:[n&&(0,h.jsxs)(U,{variant:`destructive`,size:`sm`,onClick:d,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Trash2,{className:`h-3 w-3 mr-1`}),`删除 (`,e,`)`]}),r&&(0,h.jsxs)(U,{variant:`outline`,size:`sm`,onClick:f,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Download,{className:`h-3 w-3 mr-1`}),`导出`]}),(i||a)&&(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsxs)(U,{variant:`outline`,size:`sm`,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.FileText,{className:`h-3 w-3 mr-1`}),`导出格式`]})}),(0,h.jsxs)(q,{align:`start`,children:[i&&(0,h.jsxs)(J,{onClick:p,children:[(0,h.jsx)(b.FileText,{className:`h-4 w-4 mr-2`}),`Excel (.xlsx)`]}),a&&(0,h.jsxs)(J,{onClick:m,children:[(0,h.jsx)(b.FileText,{className:`h-4 w-4 mr-2`}),`CSV (.csv)`]})]})]}),o&&(0,h.jsxs)(U,{variant:`outline`,size:`sm`,onClick:g,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Mail,{className:`h-3 w-3 mr-1`}),`发送邮件`]}),s&&(0,h.jsxs)(U,{variant:`outline`,size:`sm`,onClick:_,disabled:l,className:`h-8`,children:[(0,h.jsx)(b.Archive,{className:`h-3 w-3 mr-1`}),`归档`]})]}),y&&(0,h.jsx)(h.Fragment,{children:c.map(e=>(0,h.jsxs)(U,{variant:e.variant||`outline`,size:`sm`,onClick:()=>e.onClick(t),disabled:l,className:`h-8`,children:[e.icon&&(0,h.jsx)(`span`,{className:`mr-1`,children:e.icon}),e.label]},e.key))}),(v||y)&&(0,h.jsxs)(G,{children:[(0,h.jsx)(K,{asChild:!0,children:(0,h.jsx)(U,{variant:`ghost`,size:`sm`,disabled:l,className:`h-8 w-8 p-0`,children:(0,h.jsx)(b.MoreHorizontal,{className:`h-4 w-4`})})}),(0,h.jsxs)(q,{align:`end`,children:[n&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(J,{onClick:d,className:`text-destructive`,children:[(0,h.jsx)(b.Trash2,{className:`h-4 w-4 mr-2`}),`删除选中项`]}),(0,h.jsx)(Y,{})]}),r&&(0,h.jsxs)(J,{onClick:f,children:[(0,h.jsx)(b.Download,{className:`h-4 w-4 mr-2`}),`导出数据`]}),o&&(0,h.jsxs)(J,{onClick:g,children:[(0,h.jsx)(b.Mail,{className:`h-4 w-4 mr-2`}),`发送邮件`]}),s&&(0,h.jsxs)(J,{onClick:_,children:[(0,h.jsx)(b.Archive,{className:`h-4 w-4 mr-2`}),`归档`]}),c.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Y,{}),c.map(e=>(0,h.jsxs)(J,{onClick:()=>e.onClick(t),children:[e.icon&&(0,h.jsx)(`span`,{className:`mr-2`,children:e.icon}),e.label]},e.key))]})]})]})]})}function Pt({selectedCount:e,selectedRows:t=[],onClear:n,actions:r=[],alwaysShow:i=!1,batchActions:a}){let o=nt();return(0,h.jsx)(N.AnimatePresence,{children:(i||e>0)&&(0,h.jsx)(N.motion.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.18},children:(0,h.jsx)(At,{className:`mb-4`,children:(0,h.jsxs)(Mt,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,h.jsx)(`span`,{className:`text-sm leading-none`,children:e>0?(0,h.jsxs)(h.Fragment,{children:[o.batchActions.selected,` `,(0,h.jsx)(`strong`,{children:e}),` row(s)`]}):o.batchActions.selected}),e>0&&(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a&&(0,h.jsx)(Nt,{selectedCount:e,selectedRows:t,...a}),r.map((e,t)=>(0,h.jsx)(c.default.Fragment,{children:e},t))]})]}),e>0&&(0,h.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,h.jsx)(C.IconX,{className:`mr-1 h-3 w-3`}),o.batchActions.clear]})]})})},`batch-actions`)})}var Ft=c.forwardRef(({className:e,...t},n)=>(0,h.jsx)(`textarea`,{className:B(`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));Ft.displayName=`Textarea`;function It({value:e,record:t,column:n,isEditing:r,onSave:i,onCancel:a,onStartEdit:o}){let[s,l]=(0,c.useState)(e),[u,d]=(0,c.useState)(!0);(0,c.useEffect)(()=>{l(e)},[e]);let p=()=>{u&&i(s)},m=()=>{l(e),a()},g=e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),m())};return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`flex-1`,children:(()=>{let{valueType:e,fieldProps:t={}}=n;switch(e){case`text`:return(0,h.jsx)(W,{value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,...t});case`number`:return(0,h.jsx)(W,{type:`number`,value:s||``,onChange:e=>{let t=e.target.value===``?null:Number(e.target.value);l(t),d(e.target.value===``||!isNaN(Number(e.target.value)))},onKeyDown:g,className:`h-8`,...t});case`select`:let{valueEnum:e}=n;return(0,h.jsxs)(st,{value:s||``,onValueChange:l,children:[(0,h.jsx)(ut,{className:`h-8`,children:(0,h.jsx)(lt,{placeholder:`请选择`})}),(0,h.jsx)(dt,{children:e&&Object.entries(e).map(([e,t])=>(0,h.jsx)($,{value:e,children:t.text},e))})]});case`switch`:return(0,h.jsx)(_e,{checked:!!s,onCheckedChange:l,...t});case`date`:return(0,h.jsxs)(xt,{children:[(0,h.jsx)(St,{asChild:!0,children:(0,h.jsxs)(U,{variant:`outline`,className:B(`h-8 justify-start text-left font-normal`,!s&&`text-muted-foreground`),children:[(0,h.jsx)(b.CalendarIcon,{className:`mr-2 h-4 w-4`}),s?(0,f.format)(s,`yyyy-MM-dd`):`选择日期`]})}),(0,h.jsx)(Ct,{className:`w-auto p-0`,children:(0,h.jsx)(yt,{mode:`single`,selected:s,onSelect:l,initialFocus:!0})})]});case`textarea`:return(0,h.jsx)(Ft,{value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`min-h-[60px]`,...t});case`money`:return(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`¥`}),(0,h.jsx)(W,{type:`number`,value:s||``,onChange:e=>{let t=e.target.value===``?null:Number(e.target.value);l(t),d(e.target.value===``||!isNaN(Number(e.target.value)))},onKeyDown:g,className:`h-8`,placeholder:`0.00`,...t})]});case`percent`:return(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(W,{type:`number`,value:s||``,onChange:e=>{let t=e.target.value===``?null:Number(e.target.value);l(t),d(e.target.value===``||!isNaN(Number(e.target.value)))},onKeyDown:g,className:`h-8`,placeholder:`0`,...t}),(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`%`})]});case`email`:return(0,h.jsx)(W,{type:`email`,value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,placeholder:`example@email.com`,...t});case`phone`:return(0,h.jsx)(W,{type:`tel`,value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,placeholder:`+86 138 0000 0000`,...t});case`url`:return(0,h.jsx)(W,{type:`url`,value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,placeholder:`https://example.com`,...t});default:return(0,h.jsx)(W,{value:s||``,onChange:e=>l(e.target.value),onKeyDown:g,className:`h-8`,...t})}})()}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0`,onClick:p,disabled:!u,children:(0,h.jsx)(b.Check,{className:`h-3 w-3`})}),(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0`,onClick:m,children:(0,h.jsx)(b.X,{className:`h-3 w-3`})})]})]}):(0,h.jsx)(`div`,{className:`cursor-pointer hover:bg-muted/50 rounded px-2 py-1 min-h-[32px] flex items-center`,onClick:o,children:(()=>n.render?n.render(e,t,0):(n.valueType,e))()})}function Lt({record:e,config:t,editable:n,onEdit:r,onSave:i,onCancel:a,onDelete:o,onAdd:s,onRemove:l}){let{isEditing:u}=t;return n?.actionRender?(0,h.jsx)(`div`,{className:`flex items-center gap-1`,children:n.actionRender(e,t).map((e,t)=>(0,h.jsx)(c.default.Fragment,{children:e},t))}):(0,h.jsx)(`div`,{className:`flex items-center justify-center`,children:(()=>u?(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:i,children:[(0,h.jsx)(b.Save,{className:`h-3 w-3 mr-1`}),`保存`]}),(0,h.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:a,children:[(0,h.jsx)(b.X,{className:`h-3 w-3 mr-1`}),`取消`]})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:r,children:[(0,h.jsx)(b.Edit,{className:`h-3 w-3 mr-1`}),`编辑`]}),o&&(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-destructive hover:text-destructive`,onClick:o,title:`删除`,children:(0,h.jsx)(b.Trash2,{className:`h-3 w-3`})}),s&&(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:s,children:(0,h.jsx)(b.Plus,{className:`h-3 w-3`})}),l&&(0,h.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:l,children:(0,h.jsx)(b.Minus,{className:`h-3 w-3`})})]}))()})}function Rt({value:e,className:t,size:n=`sm`,showText:r=!1,onCopy:i}){let[a,o]=(0,c.useState)(!1),s=async()=>{try{let t=typeof e==`string`?e:JSON.stringify(e);await navigator.clipboard.writeText(t),o(!0),i?.(e),setTimeout(()=>o(!1),2e3)}catch(t){console.error(`Failed to copy:`,t);try{let t=document.createElement(`textarea`);t.value=typeof e==`string`?e:JSON.stringify(e),document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),o(!0),i?.(e),setTimeout(()=>o(!1),2e3)}catch(e){console.error(`Fallback copy failed:`,e)}}},l={sm:`h-6 w-6 p-0`,md:`h-8 w-8 p-0`,lg:`h-10 w-10 p-0`},u={sm:`h-3 w-3`,md:`h-4 w-4`,lg:`h-5 w-5`};return(0,h.jsxs)(U,{variant:`ghost`,size:`sm`,className:B(l[n],`hover:bg-muted/50 transition-colors`,t),onClick:s,title:a?`已复制`:`复制`,children:[a?(0,h.jsx)(b.Check,{className:B(u[n],`text-green-600`)}):(0,h.jsx)(b.Copy,{className:B(u[n],`text-muted-foreground`)}),r&&(0,h.jsx)(`span`,{className:`ml-1 text-xs`,children:a?`已复制`:`复制`})]})}var zt=(e,t,n)=>{if(!e||!e.fixed)return{};let r=0;if(e.fixed===`left`){for(let e=0;e<t;e++)if(n[e].fixed===`left`){let t=n[e];typeof t.width==`number`?r+=t.width:typeof t.width==`string`?r+=parseInt(t.width):r+=100}return{position:`sticky`,left:r,zIndex:1,backgroundColor:`var(--background)`}}if(e.fixed===`right`){for(let e=t+1;e<n.length;e++)if(n[e].fixed===`right`&&n[e].fixed===`left`){let t=n[e];typeof t.width==`number`?r+=t.width:typeof t.width==`string`?r+=parseInt(t.width):r+=100}return{position:`sticky`,right:r,zIndex:1,backgroundColor:`var(--background)`}}return{}},Bt=(e,t,n)=>{if(!e.fixed)return``;let r=[];return e.fixed===`left`&&(r.push(`pro-table-cell-fix-left`),(t===n.length-1||!n.slice(t+1).some(e=>e.fixed===`left`))&&r.push(`pro-table-cell-fix-left-last`)),e.fixed===`right`&&(r.push(`pro-table-cell-fix-right`),(t===0||!n.slice(0,t).some(e=>e.fixed===`right`))&&r.push(`pro-table-cell-fix-right-first`)),r.join(` `)};function Vt({row:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=(0,T.useSortable)({id:e.id}),c={transform:E.CSS.Transform.toString(a),transition:o,opacity:s?.5:1};return(0,h.jsxs)(V,{ref:i,style:c,"data-state":e.getIsSelected&&e.getIsSelected()?`selected`:void 0,...n,children:[(0,h.jsx)(H,{className:`w-8`,children:(0,h.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-6 w-6 cursor-move`,...r,children:(0,h.jsx)(b.GripVertical,{className:`h-3 w-3`})})}),t]})}const Ht=(0,c.forwardRef)((e,t)=>{let{columns:n=[],className:r,style:i,tableClassName:a,tableStyle:o,size:s=`middle`,bordered:u=!1,loading:d=!1,toolbar:f,pagination:p,rowSelection:m,draggable:g,editable:_,headerTitle:v,headerSubTitle:y,footer:x,onRow:S,search:C,cardBordered:E=!1,cardProps:O,tableRender:k,tableExtraRender:A,onSubmit:j,onReset:M,scroll:N,sticky:P,tableLayout:te,locale:ne}=e,[F,re]=(0,c.useState)(()=>n);(0,c.useEffect)(()=>{re(n)},[n]);let ie={...e,columns:F},{table:I,state:L,actions:R,handlers:z}=Be(ie),{request:ae}=ie,{visibleColumns:oe,setVisibleColumns:se,columnSettings:ce,updateColumnSettings:le}=Ve({columns:F,rowSelection:!!m,draggable:!!g,editable:!!_}),[ue,de]=(0,c.useState)(s),[fe,pe]=(0,c.useState)(!1),me=(0,w.useSensors)((0,w.useSensor)(w.PointerSensor),(0,w.useSensor)(w.KeyboardSensor));(0,c.useImperativeHandle)(t,()=>R,[R]);let he=e=>{if(g&&typeof g==`object`&&typeof g.onDragEnd==`function`){let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=I.getRowModel().rows,i=r.findIndex(e=>String(e.id)===String(t.id)),a=r.findIndex(e=>String(e.id)===String(n.id));if(i!==-1&&a!==-1){let t=[...L.data],[n]=t.splice(i,1);t.splice(a,0,n);try{R.setTableData(t)}catch(e){console.warn(`setTableData unavailable`,e)}try{g.onDragEnd({active:{id:e.active.id},over:e.over?{id:e.over.id}:null,items:t,oldIndex:0,newIndex:0})}catch(e){console.error(`draggable.onDragEnd error:`,e)}}}},ge=()=>{try{I.toggleAllRowsSelected?.(!1)}catch{}R.clearSelected()},_e=e=>{z.handleSearch(e),j?.(e)},ve=()=>{z.handleReset(),M?.()},ye=(e,t)=>{if(I.setColumnFilters(n=>({...n,[e]:t})),ae){let n={...L.filters};t.length>0?n[e]=t:delete n[e],z.handleSearch(n)}},xe=e=>{if(I.setColumnFilters(t=>t.filter(t=>t.id!==e)),ae){let t={...L.filters};delete t[e],z.handleSearch(t)}},Se=(e,t)=>{if(e===`order`&&Array.isArray(t)){re(t);return}if(typeof e==`string`&&t&&t.fixed!==void 0){let n=e,r=t.fixed;re(e=>e.map(e=>(e.key||String(e.dataIndex))===n?{...e,fixed:r}:e));return}le(e,t)},Ee={small:`text-xs [&_th]:py-1.5 [&_td]:py-1`,middle:`text-sm [&_th]:py-2 [&_td]:py-2`,large:`text-base [&_th]:py-3 [&_td]:py-3`},Oe=()=>(0,h.jsx)(V,{children:(0,h.jsx)(H,{colSpan:F.length+(m?1:0)+(g?1:0),className:`h-32 text-center`,children:(0,h.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-2`,children:(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`No data available`})})})}),Me=()=>(0,h.jsx)(h.Fragment,{children:[...[,,,,,]].map((e,t)=>(0,h.jsxs)(V,{children:[g&&(0,h.jsx)(H,{children:(0,h.jsx)(Ae,{className:`h-4 w-4`})}),m&&(0,h.jsx)(H,{children:(0,h.jsx)(Ae,{className:`h-4 w-4`})}),F.map((e,t)=>(0,h.jsx)(H,{children:(0,h.jsx)(Ae,{className:`h-4 w-full`})},t))]},t))}),Ne=e=>{let t=e.original.id||e.original.key||e.id,n=L.editingKey===t;return(0,h.jsxs)(h.Fragment,{children:[m&&(0,h.jsx)(H,{className:`w-8`,children:(0,h.jsx)(ke,{checked:e.getIsSelected?.()??!1,onCheckedChange:t=>e.toggleSelected?.(!!t),"aria-label":`Select row`})}),e.getVisibleCells().map((r,i)=>{let a=F.find(e=>(e.key||String(e.dataIndex))===r.column.id),o=zt(a,i,F),s=Bt(a,i,F);return _&&a?.editable&&n?(0,h.jsx)(H,{className:B(`align-middle`,a?.align&&`text-${a.align}`,s),style:{width:a?.width,...o},children:(0,h.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,h.jsx)(`div`,{className:`flex-1 min-w-0`,children:(()=>{let i=(0,h.jsx)(`div`,{className:B(a?.ellipsis&&(()=>{if(typeof a.ellipsis==`object`&&a.ellipsis.multiline){let e=a.ellipsis.rows||2;return{1:`line-clamp-1`,2:`line-clamp-2`,3:`line-clamp-3`,4:`line-clamp-4`,5:`line-clamp-5`}[e]||`line-clamp-2`}return`truncate`})()),children:(0,h.jsx)(It,{value:r.getValue(),record:e.original,column:a,isEditing:n,onSave:n=>{let r={...e.original,[a.dataIndex]:n};R.saveEditable(t,r),_?.onSave&&_.onSave(t,r,e.original)},onCancel:()=>R.cancelEditable(t),onStartEdit:()=>R.startEditable(t)})}),o=!!a?.ellipsis;if(a?.tooltip&&!n){let t=typeof a.tooltip==`object`?a.tooltip:{};if(t.disabled)return i;let n;if(typeof a.tooltip==`object`&&t.content!==void 0)n=typeof t.content==`function`?t.content(r.getValue(),e.original,e.index):t.content;else if(o){let t=a?.dataIndex?e.original[a.dataIndex]:r.getValue();n=typeof t==`object`&&t?JSON.stringify(t,null,2):String(t??``)}else n=r.getValue();return(0,h.jsxs)(X,{delayDuration:t.delayDuration,children:[(0,h.jsx)(Z,{asChild:!0,children:i}),(0,h.jsx)(Q,{side:t.side||`top`,align:t.align,children:n})]})}return i})()})})},r.id):(0,h.jsx)(H,{className:B(`align-middle`,a?.align&&`text-${a.align}`,s),style:{width:a?.width,...o},children:(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`flex-1 min-w-0`,children:(()=>{let t=(0,h.jsx)(`div`,{className:B(a?.ellipsis&&(()=>{if(typeof a.ellipsis==`object`&&a.ellipsis.multiline){let e=a.ellipsis.rows||2;return{1:`line-clamp-1`,2:`line-clamp-2`,3:`line-clamp-3`,4:`line-clamp-4`,5:`line-clamp-5`}[e]||`line-clamp-2`}return`truncate`})()),children:a?.valueType?be(a.valueType,r.getValue(),a):(0,l.flexRender)(r.column.columnDef.cell,r.getContext())}),n=!!a?.ellipsis;if(a?.tooltip){let i=typeof a.tooltip==`object`?a.tooltip:{};if(i.disabled)return t;let o;if(typeof a.tooltip==`object`&&i.content!==void 0)o=typeof i.content==`function`?i.content(r.getValue(),e.original,e.index):i.content;else if(n){let t=a?.dataIndex?e.original[a.dataIndex]:r.getValue();o=typeof t==`object`&&t?JSON.stringify(t,null,2):String(t??``)}else o=r.getValue();return(0,h.jsxs)(X,{delayDuration:i.delayDuration,children:[(0,h.jsx)(Z,{asChild:!0,children:t}),(0,h.jsx)(Q,{side:i.side||`top`,align:i.align,children:o})]})}return t})()}),a?.copyable&&(0,h.jsx)(Rt,{value:r.getValue(),size:`sm`,onCopy:e=>{console.log(`复制成功:`,e)}})]})},r.id)}),_&&(0,h.jsx)(H,{className:`w-32`,children:(0,h.jsx)(Lt,{record:e.original,config:{isEditing:n,editingKey:L.editingKey||``},editable:_,onEdit:()=>R.startEditable(t),onSave:()=>{R.cancelEditable(t)},onCancel:()=>R.cancelEditable(t),onDelete:_.onDelete?()=>{_.onDelete&&_.onDelete(t,e.original)}:void 0})})]})},Pe=(e,t)=>{let n=S?.(e.original,t)||{};return g?(0,h.jsx)(Vt,{row:e,children:Ne(e)},e.id):(0,h.jsx)(V,{"data-state":e.getIsSelected&&e.getIsSelected()?`selected`:void 0,...n,children:Ne(e)},e.id)},Fe=(0,h.jsx)(`div`,{className:B(`relative`,N?.x&&`overflow-x-auto`,N?.y&&`overflow-y-auto`),style:{maxHeight:N?.y,maxWidth:N?.x?`${N.x}px`:void 0},children:(0,h.jsx)(`div`,{className:B(`rounded-md`,u&&`border`),children:(0,h.jsx)(w.DndContext,{sensors:me,collisionDetection:w.closestCenter,modifiers:[D.restrictToVerticalAxis],onDragEnd:he,children:(0,h.jsxs)(Ce,{className:B(Ee[ue],a,P&&`sticky-header`),style:{...o,tableLayout:te||(N?.x?`fixed`:`auto`),maxWidth:N?.x?`${N.x}px`:void 0,...P&&{position:`relative`}},children:[(0,h.jsx)(we,{className:B(P&&`sticky top-0 z-10 bg-background`),style:P?{position:`sticky`,top:typeof P==`object`&&P.offsetHeader||0,zIndex:10}:void 0,children:I.getHeaderGroups().map(e=>(0,h.jsxs)(V,{children:[g&&(0,h.jsx)(De,{className:`w-8`}),m&&(0,h.jsx)(De,{className:`w-8`,children:(0,h.jsx)(ke,{checked:I.getIsAllPageRowsSelected?.()??!1,onCheckedChange:e=>I.toggleAllPageRowsSelected?.(!!e),"aria-label":`Select all`})}),e.headers.map((e,t)=>{let n=F.find(t=>(t.key||String(t.dataIndex))===e.column.id),r=zt(n,t,F),i=Bt(n,t,F),a=n?.headerEllipsis??n?.ellipsis,o=n?.headerTooltip??n?.tooltip;return(0,h.jsx)(De,{style:{width:n?.width||e.column.getSize(),...r},className:B(`font-medium`,n?.align&&`text-${n.align}`,a&&`whitespace-normal`,i),children:e.isPlaceholder?null:(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(()=>{let r=(0,l.flexRender)(e.column.columnDef.header,e.getContext()),i=(0,h.jsx)(`span`,{className:B(`flex-1 min-w-0`,a&&(()=>{if(typeof a==`object`&&a.multiline){let e=a.rows||2;return{1:`line-clamp-1`,2:`line-clamp-2`,3:`line-clamp-3`,4:`line-clamp-4`,5:`line-clamp-5`}[e]||`line-clamp-2`}return`truncate`})()),children:r});if(o){let e=typeof o==`object`?o:{};if(e.disabled)return i;let a;return a=typeof o==`object`&&e.content!==void 0?typeof e.content==`function`?e.content(r,n||{},t):e.content:r,(0,h.jsxs)(X,{delayDuration:e.delayDuration,children:[(0,h.jsx)(Z,{asChild:!0,children:i}),(0,h.jsx)(Q,{side:e.side||`top`,align:e.align,children:a})]})}return i})(),(0,h.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e.column.getCanSort()&&(0,h.jsxs)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-muted`,onClick:()=>e.column.toggleSorting(),children:[e.column.getIsSorted()===`asc`&&(0,h.jsx)(b.ArrowUp,{className:`h-3 w-3`}),e.column.getIsSorted()===`desc`&&(0,h.jsx)(b.ArrowDown,{className:`h-3 w-3`}),!e.column.getIsSorted()&&(0,h.jsx)(b.ArrowUpDown,{className:`h-3 w-3 opacity-50`})]}),n?.filters&&n.filters.length>0&&(0,h.jsx)(ot,{column:{key:n.key,dataIndex:String(n.dataIndex),title:n.title,filters:n.filters},value:Array.isArray(I.getColumn(n.key||String(n.dataIndex))?.getFilterValue())?I.getColumn(n.key||String(n.dataIndex))?.getFilterValue():[],onChange:e=>ye(n.key||String(n.dataIndex),e),onClear:()=>xe(n.key||String(n.dataIndex))})]})]})},e.id)})]},e.id))}),(0,h.jsx)(Te,{children:d?Me():L.data.length===0?Oe():g?(0,h.jsx)(T.SortableContext,{items:I.getRowModel().rows.map(e=>e.id),strategy:T.verticalListSortingStrategy,children:I.getRowModel().rows.map((e,t)=>Pe(e,t))}):I.getRowModel().rows.map((e,t)=>Pe(e,t))})]})})})}),Le=k?k(e,Fe,{toolbar:f!==!1,search:C!==!1,table:!0}):Fe,Re=B(`flex flex-col gap-4 transition-all duration-300 ease-in-out`,fe?`fixed inset-0 z-50 bg-background p-4 transform scale-100`:`transform scale-100`,r),ze=(0,h.jsx)(tt,{locale:ne,children:(0,h.jsxs)(`div`,{className:Re,style:i,children:[C!==!1&&(()=>{let e=ee(F);return(e.length>0||typeof C==`object`&&!!C)&&(0,h.jsx)(Ot,{...typeof C==`object`?C:{},columns:e,onSearch:_e,onReset:ve,loading:L.loading})})(),f!==!1&&(0,h.jsx)(at,{...typeof f==`object`?f:{},title:v,subTitle:y,table:I,columns:F,loading:L.loading,onReload:()=>R.reload(),fullScreen:fe,onFullScreenChange:pe,density:ue,onDensityChange:de,visibleColumns:oe,onVisibleColumnsChange:se,columnSettings:ce,onColumnSettingsChange:Se}),m&&(0,h.jsx)(Pt,{selectedCount:I.getFilteredSelectedRowModel().rows.length,selectedRows:I.getFilteredSelectedRowModel().rows.map(e=>e.original),onClear:ge,alwaysShow:m.alwaysShowAlert,batchActions:m.batchActions}),A?.(e,L.data),Le,x&&(0,h.jsx)(`div`,{className:`px-4`,children:x(L.data)}),p!==!1&&(0,h.jsx)(vt,{...typeof p==`object`?p:{},current:L.current,pageSize:L.pageSize,total:L.total,onPaginationChange:z.handlePaginationChange})]})});return E?(0,h.jsx)(je,{...O,className:B(O?.className),children:(0,h.jsx)(Ie,{children:ze})}):ze});var Ut=new Map;function Wt(e,t={}){let{manual:n=!1,defaultParams:r={},onSuccess:i,onError:a,debounceWait:o=0,retryCount:s=0,cacheKey:l,cacheTime:u=300*1e3}=t,[d,f]=(0,c.useState)([]),[p,m]=(0,c.useState)(!n),[h,g]=(0,c.useState)(null),[_,v]=(0,c.useState)(0),y=(0,c.useRef)(r),b=(0,c.useRef)(0),x=(0,c.useRef)(null),S=(0,c.useRef)(null),C=(0,c.useCallback)(async t=>{x.current&&x.current.abort(),S.current&&clearTimeout(S.current);let n=async()=>{let r=t||y.current;if(y.current=r,l){let e=Ut.get(l);if(e&&Date.now()-e.timestamp<u){f(e.data.data),v(e.data.total||0),m(!1);return}}m(!0),g(null),x.current=new AbortController;try{let t=await e(r);if(!x.current.signal.aborted){let e=t.data||[];f(e),v(t.total||e.length),l&&Ut.set(l,{data:t,timestamp:Date.now()}),i?.(e,t),b.current=0}}catch(e){if(!x.current.signal.aborted){let t=e;g(t),a?.(t),b.current<s&&(b.current++,setTimeout(()=>n(),1e3*2**b.current))}}finally{x.current.signal.aborted||m(!1)}};o>0?S.current=setTimeout(n,o):await n()},[e,i,a,s,l,u]),w=(0,c.useCallback)(async()=>{await C(y.current)},[C]),T=(0,c.useCallback)(()=>{x.current&&x.current.abort(),S.current&&clearTimeout(S.current),m(!1)},[]),E=(0,c.useCallback)(e=>{f(e),v(e.length)},[]);return(0,c.useEffect)(()=>(n||C(),()=>{T()}),[]),{data:d,loading:p,error:h,total:_,run:C,refresh:w,cancel:T,mutate:E}}const Gt={search:{searchText:`搜索`,resetText:`重置`,submitText:`提交`,expandText:`展开`,collapseText:`收起`,selectPlaceholder:`请选择`,inputPlaceholder:`请输入`},pagination:{total:(e,t)=>`第 ${t[0]}-${t[1]} 条,共 ${e} 条`,items:`条`,page:`页`,of:`共`,showTotal:`显示`},toolbar:{reload:`刷新`,density:`密度`,columnSetting:`列设置`,fullScreen:`全屏`,exitFullScreen:`退出全屏`,compact:`紧凑`,default:`默认`,comfortable:`舒适`,searchPlaceholder:`搜索...`},columnSetting:{title:`列设置`,fixedLeft:`固定左侧`,fixedRight:`固定右侧`,noFixed:`不固定`,show:`显示`,hide:`隐藏`,reset:`重置`},batchActions:{selected:`已选择`,clear:`清空`,delete:`删除`,export:`导出`},editable:{save:`保存`,cancel:`取消`,edit:`编辑`,delete:`删除`},common:{confirm:`确认`,cancel:`取消`,noData:`暂无数据`,loading:`加载中...`,selectAll:`全选`,copySuccess:`复制成功`}};exports.Alert=At,exports.AlertDescription=Mt,exports.AlertTitle=jt,exports.Avatar=me,exports.AvatarFallback=ge,exports.AvatarImage=he,exports.Badge=pe,exports.BatchActions=Pt,exports.Button=U,exports.Calendar=yt,exports.CalendarDayButton=bt,exports.Card=je,exports.CardAction=Fe,exports.CardContent=Ie,exports.CardDescription=Pe,exports.CardFooter=Le,exports.CardHeader=Me,exports.CardTitle=Ne,exports.Checkbox=ke,exports.ColumnSetting=it,exports.DatePicker=Tt,exports.DateRangePicker=Et,exports.DropdownMenu=G,exports.DropdownMenuCheckboxItem=We,exports.DropdownMenuContent=q,exports.DropdownMenuGroup=Ue,exports.DropdownMenuItem=J,exports.DropdownMenuLabel=qe,exports.DropdownMenuPortal=He,exports.DropdownMenuRadioGroup=Ge,exports.DropdownMenuRadioItem=Ke,exports.DropdownMenuSeparator=Y,exports.DropdownMenuShortcut=Je,exports.DropdownMenuSub=Ye,exports.DropdownMenuSubContent=Ze,exports.DropdownMenuSubTrigger=Xe,exports.DropdownMenuTrigger=K,exports.Input=W,exports.Label=Dt,exports.Pagination=vt,exports.Popover=xt,exports.PopoverAnchor=wt,exports.PopoverContent=Ct,exports.PopoverTrigger=St,exports.ProTable=Ht,exports.Progress=ve,exports.Search=Ot,exports.Select=st,exports.SelectContent=dt,exports.SelectGroup=ct,exports.SelectItem=$,exports.SelectLabel=ft,exports.SelectScrollDownButton=ht,exports.SelectScrollUpButton=mt,exports.SelectSeparator=pt,exports.SelectTrigger=ut,exports.SelectValue=lt,exports.Skeleton=Ae,exports.Switch=_e,exports.Table=Ce,exports.TableBody=Te,exports.TableCaption=Oe,exports.TableCell=H,exports.TableFooter=Ee,exports.TableHead=De,exports.TableHeader=we,exports.TableRow=V,exports.ToolBar=at,exports.Tooltip=X,exports.TooltipContent=Q,exports.TooltipProvider=Qe,exports.TooltipTrigger=Z,exports.badgeVariants=fe,exports.buttonVariants=Re,exports.cn=B,exports.copyToClipboard=I,exports.debounce=F,exports.deepMerge=ne,exports.en_US=$e,exports.extractSearchColumns=ee,exports.extractTableColumns=P,exports.formatFileSize=ce,exports.formatNumber=ie,exports.generateId=te,exports.generateRandomColor=le,exports.getNestedValue=R,exports.groupBy=oe,exports.isEmpty=L,exports.parseQueryString=ue,exports.registerValueType=Se,exports.renderFormItem=xe,exports.renderValue=be,exports.setNestedValue=z,exports.sleep=se,exports.stringifyQuery=de,exports.throttle=re,exports.uniqueArray=ae,exports.useColumns=Ve,exports.useProTable=Be,exports.useRequest=Wt,exports.zh_CN=Gt;
package/dist/index.js CHANGED
@@ -626,7 +626,7 @@ function useProTable(e) {
626
626
  selectedRows: [],
627
627
  editingKey: null,
628
628
  editingRecord: null
629
- }, [E, D] = useReducer(proTableReducer, T), O = useRef(null), [k, A] = React.useState([]), [j, Ln] = React.useState([]), [M, N] = React.useState({}), [P, F] = React.useState({}), I = useCallback((e) => typeof y == "function" ? String(y(e)) : String(e[y]), [y]), L = useCallback(async (e) => {
629
+ }, [E, D] = useReducer(proTableReducer, T), O = useRef(null), [k, A] = React.useState([]), [j, M] = React.useState([]), [N, P] = React.useState({}), [F, I] = React.useState({}), L = useCallback((e) => typeof y == "function" ? String(y(e)) : String(e[y]), [y]), R = useCallback(async (e) => {
630
630
  if (a) {
631
631
  D({
632
632
  type: "SET_LOADING",
@@ -670,7 +670,7 @@ function useProTable(e) {
670
670
  S,
671
671
  C,
672
672
  w
673
- ]), R = useMemo(() => n.filter((e) => !e.hideInTable).map((e) => ({
673
+ ]), Ln = useMemo(() => n.filter((e) => !e.hideInTable).map((e) => ({
674
674
  id: e.key || String(e.dataIndex),
675
675
  accessorKey: e.dataIndex,
676
676
  header: e.title,
@@ -687,31 +687,31 @@ function useProTable(e) {
687
687
  ...e
688
688
  })), [n]), z = useReactTable({
689
689
  data: E.data,
690
- columns: R,
690
+ columns: Ln,
691
691
  state: {
692
692
  sorting: k,
693
693
  columnFilters: j,
694
- columnVisibility: M,
695
- rowSelection: P,
694
+ columnVisibility: N,
695
+ rowSelection: F,
696
696
  pagination: {
697
697
  pageIndex: E.current - 1,
698
698
  pageSize: E.pageSize
699
699
  }
700
700
  },
701
701
  onSortingChange: A,
702
- onColumnFiltersChange: Ln,
703
- onColumnVisibilityChange: N,
704
- onRowSelectionChange: F,
702
+ onColumnFiltersChange: M,
703
+ onColumnVisibilityChange: P,
704
+ onRowSelectionChange: I,
705
705
  getCoreRowModel: getCoreRowModel(),
706
706
  getFilteredRowModel: getFilteredRowModel(),
707
707
  getPaginationRowModel: getPaginationRowModel(),
708
708
  getSortedRowModel: getSortedRowModel(),
709
- getRowId: I,
709
+ getRowId: L,
710
710
  manualPagination: !!a,
711
711
  pageCount: Math.ceil(E.total / E.pageSize),
712
712
  columnResizeMode: "onChange"
713
713
  }), B = useCallback((e, t) => {
714
- a ? L({
714
+ a ? R({
715
715
  current: e,
716
716
  pageSize: t
717
717
  }) : D({
@@ -723,16 +723,16 @@ function useProTable(e) {
723
723
  }), x !== !1 && x?.onChange?.(e, t);
724
724
  }, [
725
725
  a,
726
- L,
726
+ R,
727
727
  x
728
728
  ]), V = useCallback((e) => {
729
729
  D({
730
730
  type: "SET_FILTERS",
731
731
  payload: e
732
- }), a && L({ current: 1 });
733
- }, [a, L]), H = useCallback(() => {
734
- D({ type: "RESET" }), a && L({ current: 1 });
735
- }, [a, L]);
732
+ }), a && R({ current: 1 });
733
+ }, [a, R]), H = useCallback(() => {
734
+ D({ type: "RESET" }), a && R({ current: 1 });
735
+ }, [a, R]);
736
736
  useEffect(() => {
737
737
  if (a && k.length > 0) {
738
738
  let e = k[0].id, t = k[0].desc ? "desc" : "asc";
@@ -742,21 +742,21 @@ function useProTable(e) {
742
742
  field: e,
743
743
  order: t
744
744
  }
745
- }), L({ current: 1 });
745
+ }), R({ current: 1 });
746
746
  }
747
747
  }, [k, a]);
748
748
  let U = {
749
749
  reload: async (e = !1) => {
750
- await L(e ? { current: 1 } : void 0);
750
+ await R(e ? { current: 1 } : void 0);
751
751
  },
752
752
  reloadAndRest: async () => {
753
- D({ type: "RESET" }), await L({ current: 1 });
753
+ D({ type: "RESET" }), await R({ current: 1 });
754
754
  },
755
755
  reset: () => {
756
756
  D({ type: "RESET" });
757
757
  },
758
758
  clearSelected: () => {
759
- F({}), D({
759
+ I({}), D({
760
760
  type: "SET_SELECTION",
761
761
  payload: {
762
762
  keys: [],
@@ -765,7 +765,7 @@ function useProTable(e) {
765
765
  });
766
766
  },
767
767
  startEditable: (e) => {
768
- let t = E.data.find((t) => I(t) === String(e));
768
+ let t = E.data.find((t) => L(t) === String(e));
769
769
  return t ? (D({
770
770
  type: "START_EDIT",
771
771
  payload: {
@@ -779,7 +779,7 @@ function useProTable(e) {
779
779
  type: "SAVE_EDIT",
780
780
  payload: t
781
781
  }), !0),
782
- getRowData: (e) => E.data.find((t) => I(t) === String(e)),
782
+ getRowData: (e) => E.data.find((t) => L(t) === String(e)),
783
783
  getTableData: () => E.data,
784
784
  setTableData: (e) => {
785
785
  D({
@@ -791,7 +791,7 @@ function useProTable(e) {
791
791
  return useEffect(() => {
792
792
  O.current && Object.assign(O.current, U);
793
793
  }), useEffect(() => {
794
- a && !r && L();
794
+ a && !r && R();
795
795
  }, []), useEffect(() => {
796
796
  r && D({
797
797
  type: "SET_DATA",
@@ -1463,7 +1463,7 @@ function SelectTrigger({ className: e, size: t = "default", children: n,...r })
1463
1463
  function SelectContent({ className: e, children: t, position: n = "popper", align: r = "center",...i }) {
1464
1464
  return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(SelectPrimitive.Content, {
1465
1465
  "data-slot": "select-content",
1466
- className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md", n === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", e),
1466
+ className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md", n === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", n === "popper" && !e?.includes("w-") && "w-[var(--radix-select-trigger-width)]", e),
1467
1467
  position: n,
1468
1468
  align: r,
1469
1469
  ...i,
@@ -1898,15 +1898,20 @@ function Search({ columns: e, onSearch: t, onReset: n, loading: r, filterType: i
1898
1898
  value: n.value,
1899
1899
  onValueChange: (e) => n.onChange(e),
1900
1900
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
1901
+ size: "sm",
1901
1902
  className: "h-8 w-full",
1902
1903
  children: /* @__PURE__ */ jsx(SelectValue, { placeholder: `${m.search.selectPlaceholder} ${e.title}` })
1903
- }), /* @__PURE__ */ jsx(SelectContent, { children: e.valueEnum ? Object.entries(e.valueEnum).map(([e, n]) => /* @__PURE__ */ jsx(SelectItem, {
1904
- value: e,
1905
- children: n.text
1906
- }, `${t}-${e}`)) : e.filters?.map((e) => /* @__PURE__ */ jsx(SelectItem, {
1907
- value: e.value,
1908
- children: e.text
1909
- }, `${t}-filter-${String(e.value)}`)) })]
1904
+ }), /* @__PURE__ */ jsx(SelectContent, {
1905
+ position: "popper",
1906
+ className: "w-[var(--radix-select-trigger-width)]",
1907
+ children: e.valueEnum ? Object.entries(e.valueEnum).map(([e, n]) => /* @__PURE__ */ jsx(SelectItem, {
1908
+ value: e,
1909
+ children: n.text
1910
+ }, `${t}-${e}`)) : e.filters?.map((e) => /* @__PURE__ */ jsx(SelectItem, {
1911
+ value: e.value,
1912
+ children: e.text
1913
+ }, `${t}-filter-${String(e.value)}`))
1914
+ })]
1910
1915
  })
1911
1916
  });
1912
1917
  case "date": return /* @__PURE__ */ jsx(Controller, {
@@ -2009,7 +2014,9 @@ function Search({ columns: e, onSearch: t, onReset: n, loading: r, filterType: i
2009
2014
  })
2010
2015
  ]
2011
2016
  });
2012
- let j = e, Ln = e.length > 3, M = [/* @__PURE__ */ jsxs(Button, {
2017
+ let j = e.filter((e) => !e.hideInSearch && (e.search === !0 || typeof e.search == "object"));
2018
+ if (j.length === 0) return null;
2019
+ let M = j.length > 3, N = [/* @__PURE__ */ jsxs(Button, {
2013
2020
  size: "sm",
2014
2021
  onClick: _(O),
2015
2022
  disabled: r,
@@ -2020,13 +2027,13 @@ function Search({ columns: e, onSearch: t, onReset: n, loading: r, filterType: i
2020
2027
  onClick: k,
2021
2028
  children: [/* @__PURE__ */ jsx(RotateCw, { className: "mr-1 h-4 w-4" }), s || m.search.resetText]
2022
2029
  }, "reset")];
2023
- Ln && M.push(/* @__PURE__ */ jsx(Button, {
2030
+ M && N.push(/* @__PURE__ */ jsx(Button, {
2024
2031
  size: "sm",
2025
2032
  variant: "ghost",
2026
2033
  onClick: D,
2027
2034
  children: E ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ChevronDown, { className: "mr-1 h-4 w-4" }), m.search.expandText] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ChevronUp, { className: "mr-1 h-4 w-4" }), m.search.collapseText] })
2028
2035
  }, "collapse"));
2029
- let N = p ? p({ collapsed: E }, y(), M) : M;
2036
+ let P = p ? p({ collapsed: E }, y(), N) : N;
2030
2037
  return /* @__PURE__ */ jsxs("form", {
2031
2038
  className: "border-b bg-muted/30 px-4 py-3 overflow-visible",
2032
2039
  onSubmit: _(O),
@@ -2052,7 +2059,7 @@ function Search({ columns: e, onSearch: t, onReset: n, loading: r, filterType: i
2052
2059
  })
2053
2060
  }), /* @__PURE__ */ jsx("div", {
2054
2061
  className: "mt-3 flex items-center justify-end gap-2",
2055
- children: N
2062
+ children: P
2056
2063
  })]
2057
2064
  });
2058
2065
  }
@@ -2534,10 +2541,13 @@ function CopyButton({ value: e, className: t, size: n = "sm", showText: r = !1,
2534
2541
  });
2535
2542
  }
2536
2543
  var getFixedStyle = (e, t, n) => {
2537
- if (!e.fixed) return {};
2544
+ if (!e || !e.fixed) return {};
2538
2545
  let r = 0;
2539
2546
  if (e.fixed === "left") {
2540
- for (let e = 0; e < t; e++) n[e].fixed === "left" && (r += n[e].width || 100);
2547
+ for (let e = 0; e < t; e++) if (n[e].fixed === "left") {
2548
+ let t = n[e];
2549
+ typeof t.width == "number" ? r += t.width : typeof t.width == "string" ? r += parseInt(t.width) : r += 100;
2550
+ }
2541
2551
  return {
2542
2552
  position: "sticky",
2543
2553
  left: r,
@@ -2546,7 +2556,10 @@ var getFixedStyle = (e, t, n) => {
2546
2556
  };
2547
2557
  }
2548
2558
  if (e.fixed === "right") {
2549
- for (let e = t + 1; e < n.length; e++) n[e].fixed === "right" && (r += n[e].width || 100);
2559
+ for (let e = t + 1; e < n.length; e++) if (n[e].fixed === "right" && n[e].fixed === "left") {
2560
+ let t = n[e];
2561
+ typeof t.width == "number" ? r += t.width : typeof t.width == "string" ? r += parseInt(t.width) : r += 100;
2562
+ }
2550
2563
  return {
2551
2564
  position: "sticky",
2552
2565
  right: r,
@@ -2584,7 +2597,7 @@ function DraggableRow({ row: e, children: t }) {
2584
2597
  });
2585
2598
  }
2586
2599
  const ProTable = forwardRef((e, t) => {
2587
- let { columns: n = [], className: r, style: i, tableClassName: a, tableStyle: c, size: l = "middle", bordered: u = !1, loading: p = !1, toolbar: m, pagination: h, rowSelection: g, draggable: _, editable: v, headerTitle: y, headerSubTitle: b, footer: x, onRow: S, search: E, cardBordered: D = !1, cardProps: O, tableRender: k, tableExtraRender: A, onSubmit: N, onReset: P, scroll: F, sticky: I, tableLayout: L, locale: R } = e, [z, B] = useState(() => n);
2600
+ let { columns: n = [], className: r, style: i, tableClassName: a, tableStyle: c, size: l = "middle", bordered: u = !1, loading: p = !1, toolbar: m, pagination: h, rowSelection: g, draggable: _, editable: v, headerTitle: y, headerSubTitle: b, footer: x, onRow: S, search: E, cardBordered: D = !1, cardProps: O, tableRender: k, tableExtraRender: A, onSubmit: P, onReset: F, scroll: I, sticky: L, tableLayout: R, locale: Ln } = e, [z, B] = useState(() => n);
2588
2601
  useEffect(() => {
2589
2602
  B(n);
2590
2603
  }, [n]);
@@ -2630,9 +2643,9 @@ const ProTable = forwardRef((e, t) => {
2630
2643
  } catch {}
2631
2644
  W.clearSelected();
2632
2645
  }, qn = (e) => {
2633
- G.handleSearch(e), N?.(e);
2646
+ G.handleSearch(e), P?.(e);
2634
2647
  }, Jn = () => {
2635
- G.handleReset(), P?.();
2648
+ G.handleReset(), F?.();
2636
2649
  }, Yn = (e, t) => {
2637
2650
  if (H.setColumnFilters((n) => ({
2638
2651
  ...n,
@@ -2854,10 +2867,10 @@ const ProTable = forwardRef((e, t) => {
2854
2867
  children: Y(e)
2855
2868
  }, e.id);
2856
2869
  }, Q = /* @__PURE__ */ jsx("div", {
2857
- className: cn("relative", F?.x && "overflow-x-auto", F?.y && "overflow-y-auto"),
2870
+ className: cn("relative", I?.x && "overflow-x-auto", I?.y && "overflow-y-auto"),
2858
2871
  style: {
2859
- maxHeight: F?.y,
2860
- maxWidth: F?.x ? `${F.x}px` : void 0
2872
+ maxHeight: I?.y,
2873
+ maxWidth: I?.x ? `${I.x}px` : void 0
2861
2874
  },
2862
2875
  children: /* @__PURE__ */ jsx("div", {
2863
2876
  className: cn("rounded-md", u && "border"),
@@ -2867,18 +2880,18 @@ const ProTable = forwardRef((e, t) => {
2867
2880
  modifiers: [restrictToVerticalAxis],
2868
2881
  onDragEnd: Gn,
2869
2882
  children: /* @__PURE__ */ jsxs(Table, {
2870
- className: cn(Qn[q], a, I && "sticky-header"),
2883
+ className: cn(Qn[q], a, L && "sticky-header"),
2871
2884
  style: {
2872
2885
  ...c,
2873
- tableLayout: L || (F?.x ? "fixed" : "auto"),
2874
- maxWidth: F?.x ? `${F.x}px` : void 0,
2875
- ...I && { position: "relative" }
2886
+ tableLayout: R || (I?.x ? "fixed" : "auto"),
2887
+ maxWidth: I?.x ? `${I.x}px` : void 0,
2888
+ ...L && { position: "relative" }
2876
2889
  },
2877
2890
  children: [/* @__PURE__ */ jsx(TableHeader, {
2878
- className: cn(I && "sticky top-0 z-10 bg-background"),
2879
- style: I ? {
2891
+ className: cn(L && "sticky top-0 z-10 bg-background"),
2892
+ style: L ? {
2880
2893
  position: "sticky",
2881
- top: typeof I == "object" && I.offsetHeader || 0,
2894
+ top: typeof L == "object" && L.offsetHeader || 0,
2882
2895
  zIndex: 10
2883
2896
  } : void 0,
2884
2897
  children: H.getHeaderGroups().map((e) => /* @__PURE__ */ jsxs(TableRow, { children: [
@@ -2976,14 +2989,14 @@ const ProTable = forwardRef((e, t) => {
2976
2989
  search: E !== !1,
2977
2990
  table: !0
2978
2991
  }) : Q, nr = cn("flex flex-col gap-4 transition-all duration-300 ease-in-out", J ? "fixed inset-0 z-50 bg-background p-4 transform scale-100" : "transform scale-100", r), $ = /* @__PURE__ */ jsx(LocaleProvider, {
2979
- locale: R,
2992
+ locale: Ln,
2980
2993
  children: /* @__PURE__ */ jsxs("div", {
2981
2994
  className: nr,
2982
2995
  style: i,
2983
2996
  children: [
2984
2997
  E !== !1 && (() => {
2985
2998
  let e = extractSearchColumns(z);
2986
- return e.length > 0 && /* @__PURE__ */ jsx(Search, {
2999
+ return (e.length > 0 || typeof E == "object" && !!E) && /* @__PURE__ */ jsx(Search, {
2987
3000
  ...typeof E == "object" ? E : {},
2988
3001
  columns: e,
2989
3002
  onSearch: qn,
@@ -1 +1 @@
1
- {"version":3,"file":"pro-table.d.ts","sourceRoot":"","sources":["../lib/pro-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAKN,MAAM,OAAO,CAAC;AAef,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AAkCxE,OAAO,2BAA2B,CAAC;AAyHnC,eAAO,MAAM,QAAQ,EAghChB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;CAAE,KAC7D,KAAK,CAAC,YAAY,CAAC"}
1
+ {"version":3,"file":"pro-table.d.ts","sourceRoot":"","sources":["../lib/pro-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAKN,MAAM,OAAO,CAAC;AAef,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AAkCxE,OAAO,2BAA2B,CAAC;AA8InC,eAAO,MAAM,QAAQ,EAqhChB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;CAAE,KAC7D,KAAK,CAAC,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gulibs/react-vtable",
3
3
  "private": false,
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",