better-table 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),l=require("react/jsx-runtime");require("./styles.cjs");const Ce={search:"Buscar",searchPlaceholder:"Buscar...",noData:"No hay datos",loading:"Cargando...",page:"Página",of:"de",items:"elementos",selected:"seleccionados",rowsPerPage:"Filas por página",actions:"Acciones",sortAsc:"Ordenar ascendente",sortDesc:"Ordenar descendente",filterBy:"Filtrar por",clearFilters:"Limpiar filtros",selectAll:"Seleccionar todo",deselectAll:"Deseleccionar todo"},Te=c.createContext(null);function T(){const e=c.useContext(Te);if(!e)throw new Error("useTableContext must be used within a TableProvider");return e}function De({value:e,children:n}){return l.jsx(Te.Provider,{value:e,children:n})}function Pe(e){var n,s,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(s=Pe(e[n]))&&(a&&(a+=" "),a+=s)}else for(s in e)e[s]&&(a&&(a+=" "),a+=s);return a}function S(){for(var e,n,s=0,a="",i=arguments.length;s<i;s++)(e=arguments[s])&&(n=Pe(e))&&(a&&(a+=" "),a+=n);return a}function Je({column:e}){const{sortState:n,handleSort:s,filters:a,setFilter:i,locale:t}=T(),r=n.columnId===e.id,d=r?n.direction:null,b=c.useCallback(()=>{e.sortable!==!1&&s(e.id)},[e.id,e.sortable,s]),u=c.useCallback(h=>{const m=h.target.value;e.type==="boolean"?m===""?i(e.id,null):i(e.id,m==="true"):i(e.id,m||null)},[e.id,e.type,i]),f=c.useCallback(h=>{h.key==="Enter"&&e.sortable!==!1&&s(e.id)},[e.id,e.sortable,s]),g=()=>e.sortable===!1||e.type==="custom"?null:l.jsx("button",{className:S("bt-sort-btn",r&&"bt-active"),onClick:b,"aria-label":d==="asc"?t.sortDesc:t.sortAsc,type:"button",children:r?d==="asc"?"↑":"↓":"⇅"}),p=()=>{if(e.filterable===!1||e.type==="custom")return null;const h=a[e.id];return e.type==="boolean"?l.jsxs("select",{className:"bt-filter-select",value:h==null?"":String(h),onChange:u,"aria-label":`${t.filterBy} ${e.header}`,children:[l.jsx("option",{value:"",children:"-"}),l.jsx("option",{value:"true",children:"✅"}),l.jsx("option",{value:"false",children:"❌"})]}):l.jsx("input",{type:e.type==="number"?"number":"text",className:"bt-filter-input",placeholder:`${t.filterBy}...`,value:h!=null?String(h):"",onChange:u,"aria-label":`${t.filterBy} ${e.header}`})};return e.headerCell?l.jsx("th",{className:S("bt-th",e.align&&`bt-align-${e.align}`),style:{width:e.width},children:e.headerCell(e)}):l.jsx("th",{className:S("bt-th",e.align&&`bt-align-${e.align}`),style:{width:e.width},role:"columnheader","aria-sort":r?d==="asc"?"ascending":"descending":void 0,tabIndex:e.sortable!==!1?0:void 0,onKeyDown:e.sortable!==!1?f:void 0,children:l.jsxs("div",{className:"bt-th-content",children:[l.jsxs("div",{className:"bt-th-header",children:[l.jsx("span",{className:"bt-th-title",children:e.header}),g()]}),e.filterable!==!1&&p()]})})}const _e=c.memo(Je);function Qe(){const{columns:e,selectable:n,selectionMode:s,rowActions:a,isAllSelected:i,isPartiallySelected:t,selectAll:r,deselectAll:d,locale:b,stickyHeader:u}=T(),f=e.filter(h=>!h.hidden),g=a&&a.length>0,p=()=>{i?d():r()};return l.jsx("thead",{className:S("bt-thead",u&&"bt-sticky"),children:l.jsxs("tr",{className:"bt-tr",children:[n&&l.jsx("th",{className:"bt-th bt-checkbox-cell",children:s==="multiple"&&l.jsx("input",{type:"checkbox",className:"bt-checkbox",checked:i,ref:h=>{h&&(h.indeterminate=t)},onChange:p,"aria-label":i?b.deselectAll:b.selectAll})}),f.map(h=>l.jsx(_e,{column:h},h.id)),g&&l.jsx("th",{className:"bt-th bt-actions-cell",children:b.actions})]})})}const Fe=Qe;function M(e,n){if(!e||!n)return;const s=n.split(".");let a=e;for(const i of s){if(a==null)return;if(typeof a=="object")a=a[i];else return}return a}function we(e,n,s){return[...e].sort((a,i)=>{const t=M(a,n),r=M(i,n);if(t==null)return s==="asc"?1:-1;if(r==null)return s==="asc"?-1:1;if(typeof t=="string"&&typeof r=="string"){const f=t.localeCompare(r,void 0,{sensitivity:"base",numeric:!0});return s==="asc"?f:-f}if(typeof t=="number"&&typeof r=="number")return s==="asc"?t-r:r-t;if(typeof t=="boolean"&&typeof r=="boolean"){const f=t===r?0:t?-1:1;return s==="asc"?f:-f}if(t instanceof Date&&r instanceof Date){const f=t.getTime()-r.getTime();return s==="asc"?f:-f}const d=String(t),b=String(r),u=d.localeCompare(b);return s==="asc"?u:-u})}function Ae(e,n,s){const a=Object.entries(n).filter(([,i])=>i!=null&&i!=="");return a.length===0?e:e.filter(i=>a.every(([t,r])=>{const d=s.find(f=>f.id===t);if(!d)return!0;const b=M(i,String(d.accessor));if(b==null)return!1;switch(d.type??"string"){case"boolean":return b===r;case"number":return String(b)===String(r);case"date":if(b instanceof Date&&r){const f=new Date(String(r));return b.toDateString()===f.toDateString()}return String(b).includes(String(r));case"string":default:return String(b).toLowerCase().includes(String(r).toLowerCase())}}))}function Me(e,n,s,a){if(!n.trim())return e;const i=n.toLowerCase().trim(),t=a?s.filter(r=>a.includes(r.id)):s.filter(r=>r.type!=="custom");return e.filter(r=>t.some(d=>{const b=M(r,String(d.accessor));return b==null?!1:String(b).toLowerCase().includes(i)}))}function Ge({row:e,column:n,rowIndex:s}){const a=M(e,String(n.accessor)),t=(()=>{if(n.cell)return n.cell(a,e,s);if(a==null)return l.jsx("span",{className:"bt-cell-empty",children:"—"});switch(n.type){case"boolean":return a?"✅":"❌";case"date":if(a instanceof Date)return a.toLocaleDateString();const r=new Date(String(a));return isNaN(r.getTime())?String(a):r.toLocaleDateString();case"number":return typeof a=="number"?a.toLocaleString():a;case"string":default:return String(a)}})();return l.jsx("td",{className:S("bt-td",n.align&&`bt-align-${n.align}`),style:{width:n.width},children:t})}const Ue=c.memo(Ge);function We({row:e,rowIndex:n}){const{rowActions:s,openModal:a}=T(),i=c.useCallback(t=>{if(t.mode==="callback"&&t.onClick)t.onClick(e,n);else if(t.mode==="modal"&&t.modalContent){const r=t.modalContent;a(l.jsx(r,{data:e,onClose:()=>{}}))}else if(t.mode==="link"&&t.href){const r=typeof t.href=="function"?t.href(e):t.href;window.open(r,"_blank")}},[e,n,a]);return!s||s.length===0?null:l.jsx("td",{className:"bt-td bt-actions-cell",children:l.jsx("div",{className:"bt-actions-wrapper",children:s.map(t=>{if(t.visible&&!t.visible(e))return null;const r=t.disabled?t.disabled(e):!1;if(t.mode==="link"&&t.href){const d=typeof t.href=="function"?t.href(e):t.href;return l.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:S("bt-action-btn",t.variant&&`bt-variant-${t.variant}`),"aria-label":t.label,children:t.icon&&l.jsx("span",{className:"bt-action-icon",children:t.icon})},t.id)}return l.jsx("button",{className:S("bt-action-btn",t.variant&&`bt-variant-${t.variant}`),onClick:()=>i(t),disabled:r,"aria-label":t.label,title:t.label,type:"button",children:t.icon&&l.jsx("span",{className:"bt-action-icon",children:t.icon})},t.id)})})})}const Xe=c.memo(We);function Ye({row:e,rowIndex:n}){const{columns:s,selectable:a,rowActions:i,isSelected:t,toggleRow:r,striped:d,hoverable:b,onRowClick:u,onRowDoubleClick:f}=T(),g=s.filter(y=>!y.hidden),p=i&&i.length>0,h=a&&t(e,n),m=!!u,v=c.useCallback(()=>{u==null||u(e,n)},[e,n,u]),N=c.useCallback(()=>{f==null||f(e,n)},[e,n,f]),P=c.useCallback(()=>{r(e,n)},[e,n,r]),C=c.useCallback(y=>{y.key==="Enter"&&u&&v()},[v,u]);return l.jsxs("tr",{className:S("bt-tr",d&&"bt-striped",b&&"bt-hoverable",h&&"bt-selected",m&&"bt-clickable"),onClick:m?v:void 0,onDoubleClick:f?N:void 0,onKeyDown:m?C:void 0,tabIndex:m?0:void 0,role:m?"button":void 0,"aria-selected":a?h:void 0,children:[a&&l.jsx("td",{className:"bt-td bt-checkbox-cell",children:l.jsx("input",{type:"checkbox",className:"bt-checkbox",checked:h,onChange:P,onClick:y=>y.stopPropagation(),"aria-label":`Select row ${n+1}`})}),g.map(y=>l.jsx(Ue,{row:e,column:y,rowIndex:n},y.id)),p&&l.jsx(Xe,{row:e,rowIndex:n})]})}const Ze=c.memo(Ye);function et(){const{processedData:e,rowKey:n}=T(),s=(a,i)=>{if(typeof n=="function")return n(a,i);const t=a[n];return String(t!==void 0?t:i)};return l.jsx("tbody",{className:"bt-tbody",children:e.map((a,i)=>l.jsx(Ze,{row:a,rowIndex:i},s(a,i)))})}const tt=et;function st(){const{page:e,pageSize:n,totalPages:s,totalItems:a,goToPage:i,nextPage:t,prevPage:r,changePageSize:d,hasNextPage:b,hasPrevPage:u,startIndex:f,endIndex:g,paginationEnabled:p,pageSizeOptions:h,showSizeChanger:m,locale:v,classNames:N}=T(),P=c.useCallback(o=>{d(Number(o.target.value))},[d]),C=c.useCallback(o=>{if(o.key==="Enter"){const x=parseInt(o.target.value,10);!isNaN(x)&&x>=1&&x<=s&&i(x)}},[i,s]),y=c.useMemo(()=>{const o=[];if(s<=5)for(let j=1;j<=s;j++)o.push(j);else{o.push(1),e>3&&o.push("ellipsis");const j=Math.max(2,e-1),k=Math.min(s-1,e+1);for(let D=j;D<=k;D++)o.push(D);e<s-2&&o.push("ellipsis"),s>1&&o.push(s)}return o},[e,s]);return p?l.jsxs("div",{className:`bt-pagination ${N.pagination||""}`,children:[l.jsx("div",{className:"bt-pagination-info",children:a>0?`${f}-${g} ${v.of} ${a} ${v.items}`:`0 ${v.items}`}),l.jsxs("div",{className:"bt-pagination-controls",children:[m&&l.jsxs("div",{className:"bt-page-size",children:[l.jsxs("span",{className:"bt-page-size-label",children:[v.rowsPerPage,":"]}),l.jsx("select",{className:"bt-page-size-select",value:n,onChange:P,"aria-label":v.rowsPerPage,children:h.map(o=>l.jsx("option",{value:o,children:o},o))})]}),l.jsx("button",{className:"bt-pagination-btn",onClick:r,disabled:!u,"aria-label":"Previous page",type:"button",children:"←"}),l.jsx("div",{className:"bt-pagination-pages",children:y.map((o,x)=>o==="ellipsis"?l.jsx("span",{className:"bt-pagination-ellipsis",children:"..."},`ellipsis-${x}`):l.jsx("button",{className:`bt-pagination-btn ${e===o?"bt-active":""}`,onClick:()=>i(o),"aria-label":`${v.page} ${o}`,"aria-current":e===o?"page":void 0,type:"button",children:o},o))}),l.jsx("button",{className:"bt-pagination-btn",onClick:t,disabled:!b,"aria-label":"Next page",type:"button",children:"→"}),l.jsxs("div",{className:"bt-quick-jumper",children:[l.jsxs("span",{className:"bt-quick-jumper-label",children:[v.page,":"]}),l.jsx("input",{type:"number",className:"bt-quick-jumper-input",min:1,max:s,defaultValue:e,onKeyDown:C,"aria-label":"Jump to page"})]})]})]}):null}function at(){const{searchable:e,searchValue:n,handleSearch:s,clearSearch:a,globalActions:i,selectedRows:t,selectedCount:r,deselectAll:d,data:b,locale:u,classNames:f,selectable:g}=T(),p=c.useCallback(m=>{s(m.target.value)},[s]);return e||i&&i.length>0||g&&r>0?l.jsxs("div",{className:`bt-toolbar ${f.toolbar||""}`,children:[l.jsxs("div",{className:"bt-toolbar-left",children:[e&&l.jsxs("div",{className:"bt-search",children:[l.jsx("span",{className:"bt-search-icon",children:"🔍"}),l.jsx("input",{type:"text",className:"bt-search-input",placeholder:u.searchPlaceholder,value:n,onChange:p,"aria-label":u.search}),n&&l.jsx("button",{className:"bt-search-clear",onClick:a,"aria-label":"Clear search",type:"button",children:"✕"})]}),g&&r>0&&l.jsxs("div",{className:"bt-selection-info",children:[l.jsxs("span",{children:[r," ",u.selected]}),l.jsx("button",{className:"bt-selection-clear",onClick:d,type:"button",children:u.deselectAll})]})]}),i&&i.length>0&&l.jsx("div",{className:"bt-toolbar-right",children:l.jsx("div",{className:"bt-global-actions",children:i.map(m=>{const v=m.requiresSelection&&t.length===0;return l.jsxs("button",{className:S("bt-global-btn",m.variant&&`bt-variant-${m.variant}`),onClick:()=>m.onClick(t,b),disabled:v,title:m.label,type:"button",children:[m.icon&&l.jsx("span",{className:"bt-global-icon",children:m.icon}),l.jsx("span",{children:m.label})]},m.id)})})})]}):null}const lt=at;function nt(){const{locale:e,emptyComponent:n,columns:s,selectable:a,rowActions:i}=T(),t=s.filter(b=>!b.hidden),r=i&&i.length>0,d=t.length+(a?1:0)+(r?1:0);return n?l.jsx("tbody",{className:"bt-tbody",children:l.jsx("tr",{className:"bt-tr",children:l.jsx("td",{className:"bt-td",colSpan:d,children:n})})}):l.jsx("tbody",{className:"bt-tbody",children:l.jsx("tr",{className:"bt-tr",children:l.jsx("td",{className:"bt-td",colSpan:d,children:l.jsxs("div",{className:"bt-empty",children:[l.jsx("div",{className:"bt-empty-icon",children:"📭"}),l.jsx("div",{className:"bt-empty-text",children:e.noData})]})})})})}function it({show:e}){const{loadingComponent:n,locale:s}=T();return e?l.jsx("div",{className:"bt-loading-overlay",role:"status","aria-live":"polite",children:n||l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"bt-loading-spinner","aria-hidden":"true"}),l.jsx("span",{className:"bt-loading-text",children:s.loading})]})}):null}function rt(){const{isModalOpen:e,modalContent:n,closeModal:s}=T(),a=c.useCallback(t=>{t.target===t.currentTarget&&s()},[s]),i=c.useCallback(t=>{t.key==="Escape"&&s()},[s]);return c.useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}),[e,i]),!e||!n?null:l.jsx("div",{className:"bt-modal-backdrop",onClick:a,role:"dialog","aria-modal":"true",children:l.jsxs("div",{className:"bt-modal bt-modal-md",children:[l.jsxs("div",{className:"bt-modal-header",children:[l.jsx("h2",{className:"bt-modal-title",children:"Detalles"}),l.jsx("button",{className:"bt-modal-close",onClick:s,"aria-label":"Close modal",type:"button",children:"✕"})]}),l.jsx("div",{className:"bt-modal-body",children:n})]})})}function $e({data:e,initialSort:n,controlledSort:s,onSortChange:a}){const[i,t]=c.useState(n??{columnId:null,direction:"asc"}),r=s??i,d=c.useCallback(f=>{const g={columnId:f,direction:r.columnId===f&&r.direction==="asc"?"desc":"asc"};s||t(g),a==null||a(g)},[r,s,a]),b=c.useCallback(()=>{const f={columnId:null,direction:"asc"};s||t(f),a==null||a(f)},[s,a]);return{sortedData:c.useMemo(()=>r.columnId?we(e,r.columnId,r.direction):e,[e,r]),sortState:r,handleSort:d,clearSort:b}}function ze({data:e,columns:n,initialFilters:s,controlledFilters:a,onFilterChange:i}){const[t,r]=c.useState(s??{}),d=a??t,b=c.useCallback((p,h)=>{const m={...d};h==null||h===""?delete m[p]:m[p]=h,a||r(m),i==null||i(m)},[d,a,i]),u=c.useCallback(p=>{const h={...d};delete h[p],a||r(h),i==null||i(h)},[d,a,i]),f=c.useCallback(()=>{a||r({}),i==null||i({})},[a,i]);return{filteredData:c.useMemo(()=>Ae(e,d,n),[e,d,n]),filters:d,setFilter:b,clearFilters:f,clearFilter:u}}function Ie({data:e,config:n,onPageChange:s}){const a=n!==!1,i=n&&typeof n=="object"?n.page??1:1,t=n&&typeof n=="object"?n.pageSize??10:10,r=n&&typeof n=="object"?n.totalItems:void 0,[d,b]=c.useState(i),[u,f]=c.useState(t),g=r??e.length,p=Math.max(1,Math.ceil(g/u)),h=c.useCallback(o=>{const x=Math.max(1,Math.min(o,p));b(x),s==null||s(x,u)},[p,u,s]),m=c.useCallback(()=>{d<p&&h(d+1)},[d,p,h]),v=c.useCallback(()=>{d>1&&h(d-1)},[d,h]),N=c.useCallback(o=>{f(o),b(1),s==null||s(1,o)},[s]),P=c.useMemo(()=>{if(!a||r!==void 0)return e;const o=(d-1)*u;return e.slice(o,o+u)},[e,d,u,a,r]),C=(d-1)*u+1,y=Math.min(d*u,g);return{paginatedData:P,page:d,pageSize:u,totalPages:p,totalItems:g,goToPage:h,nextPage:m,prevPage:v,changePageSize:N,hasNextPage:d<p,hasPrevPage:d>1,startIndex:C,endIndex:y}}function Re({data:e,rowKey:n,mode:s="multiple",initialSelection:a,controlledSelection:i,onSelectionChange:t}){const[r,d]=c.useState(a??[]),b=i??r,u=c.useCallback((o,x)=>typeof n=="function"?n(o,x):String(o[n]),[n]),f=c.useMemo(()=>new Set(b.map((o,x)=>u(o,x))),[b,u]),g=c.useCallback((o,x)=>{const j=u(o,x);return f.has(j)},[u,f]),p=c.useCallback(o=>{i||d(o),t==null||t(o)},[i,t]),h=c.useCallback((o,x)=>{const j=u(o,x);let k;s==="single"?k=f.has(j)?[]:[o]:f.has(j)?k=b.filter((D,A)=>u(D,A)!==j):k=[...b,o],p(k)},[s,f,b,u,p]),m=c.useCallback((o,x)=>{if(!g(o,x)){const j=s==="single"?[o]:[...b,o];p(j)}},[g,s,b,p]),v=c.useCallback((o,x)=>{const j=u(o,x),k=b.filter((D,A)=>u(D,A)!==j);p(k)},[b,u,p]),N=c.useCallback(()=>{s==="multiple"&&p([...e])},[e,s,p]),P=c.useCallback(()=>{p([])},[p]),C=e.length>0&&b.length===e.length,y=b.length>0&&b.length<e.length;return{selectedRows:b,isSelected:g,toggleRow:h,selectRow:m,deselectRow:v,selectAll:N,deselectAll:P,isAllSelected:C,isPartiallySelected:y,selectedCount:b.length}}function Be({data:e,columns:n,searchColumns:s,initialValue:a,controlledValue:i,onSearchChange:t}){const[r,d]=c.useState(a??""),b=i??r,u=c.useCallback(p=>{i===void 0&&d(p),t==null||t(p)},[i,t]),f=c.useCallback(()=>{i===void 0&&d(""),t==null||t("")},[i,t]);return{searchedData:c.useMemo(()=>Me(e,b,n,s),[e,b,n,s]),searchValue:b,handleSearch:u,clearSearch:f}}function ct(e){const{data:n,columns:s,rowKey:a="id",rowActions:i,globalActions:t,pagination:r={pageSize:10},onPageChange:d,sort:b,onSortChange:u,filters:f,onFilterChange:g,searchable:p=!1,searchValue:h,onSearchChange:m,searchColumns:v,selectable:N,selectedRows:P,onSelectionChange:C,selectionMode:y="multiple",loading:o=!1,loadingComponent:x,emptyComponent:j,classNames:k={},styles:D={},locale:A,stickyHeader:R=!1,maxHeight:Le,bordered:$=!1,striped:B=!1,hoverable:L=!0,size:z="medium",onRowClick:O,onRowDoubleClick:E,ariaLabel:Oe,ariaDescribedBy:Ee}=e,q=c.useMemo(()=>N!==void 0?N:(t==null?void 0:t.some(Ve=>Ve.requiresSelection))||C!==void 0,[N,t,C]),K=c.useMemo(()=>({...Ce,...A}),[A]),[H,V]=c.useState(!1),[J,_]=c.useState(null),Q=c.useCallback(Ne=>{_(Ne),V(!0)},[]),F=c.useCallback(()=>{V(!1),_(null)},[]),w=c.useMemo(()=>r===!1?!1:{pageSize:10,pageSizeOptions:[10,20,50,100],showSizeChanger:!1,...r},[r]),{searchedData:qe,searchValue:G,handleSearch:U,clearSearch:W}=Be({data:n,columns:s,searchColumns:v,controlledValue:h,onSearchChange:m}),{filteredData:Ke,filters:X,setFilter:Y,clearFilters:Z}=ze({data:qe,columns:s,controlledFilters:f,onFilterChange:g}),{sortedData:ee,sortState:te,handleSort:se}=$e({data:Ke,controlledSort:b,onSortChange:u}),{selectedRows:ae,isSelected:le,toggleRow:ne,selectAll:ie,deselectAll:re,isAllSelected:ce,isPartiallySelected:oe,selectedCount:de}=Re({data:ee,rowKey:a,mode:y,controlledSelection:P,onSelectionChange:C}),{paginatedData:I,page:be,pageSize:ue,totalPages:fe,totalItems:he,goToPage:pe,nextPage:me,prevPage:ge,changePageSize:xe,hasNextPage:ve,hasPrevPage:ye,startIndex:je,endIndex:ke}=Ie({data:ee,config:w,onPageChange:d}),He=c.useMemo(()=>({data:n,processedData:I,columns:s,rowKey:a,rowActions:i,globalActions:t,sortState:te,handleSort:se,filters:X,setFilter:Y,clearFilters:Z,searchValue:G,handleSearch:U,clearSearch:W,searchable:p,selectedRows:ae,isSelected:le,toggleRow:ne,selectAll:ie,deselectAll:re,isAllSelected:ce,isPartiallySelected:oe,selectable:q,selectionMode:y,selectedCount:de,page:be,pageSize:ue,totalPages:fe,totalItems:he,goToPage:pe,nextPage:me,prevPage:ge,changePageSize:xe,hasNextPage:ve,hasPrevPage:ye,startIndex:je,endIndex:ke,paginationEnabled:r!==!1,pageSizeOptions:w&&typeof w=="object"?w.pageSizeOptions??[10,20,50,100]:[10,20,50,100],showSizeChanger:w&&typeof w=="object"?w.showSizeChanger??!1:!1,loading:o,loadingComponent:x,emptyComponent:j,locale:K,classNames:k,size:z,bordered:$,striped:B,hoverable:L,stickyHeader:R,onRowClick:O,onRowDoubleClick:E,openModal:Q,closeModal:F,modalContent:J,isModalOpen:H}),[n,I,s,a,i,t,te,se,X,Y,Z,G,U,W,p,ae,le,ne,ie,re,ce,oe,q,y,de,be,ue,fe,he,pe,me,ge,xe,ve,ye,je,ke,r,w,o,x,j,K,k,z,$,B,L,R,O,E,Q,F,J,H]),Se=I.length>0;return l.jsx(De,{value:He,children:l.jsxs("div",{className:S("bt-container",`bt-size-${z}`,o&&"bt-container-loading",k.container),style:D.container,children:[l.jsx(lt,{}),l.jsxs("div",{className:S("bt-table-wrapper",$&&"bt-bordered"),style:{maxHeight:Le},children:[l.jsxs("table",{className:S("bt-table",k.table),style:D.table,role:"grid","aria-label":Oe,"aria-describedby":Ee,"aria-busy":o,children:[l.jsx(Fe,{}),Se?l.jsx(tt,{}):l.jsx(nt,{})]}),l.jsx(it,{show:o&&Se})]}),r!==!1&&l.jsx(st,{}),l.jsx(rt,{})]})})}const ot=ct;exports.BetterTable=ot;exports.TableProvider=De;exports.defaultLocale=Ce;exports.filterData=Ae;exports.getValueFromPath=M;exports.searchData=Me;exports.sortData=we;exports.useTableContext=T;exports.useTableFilter=ze;exports.useTablePagination=Ie;exports.useTableSearch=Be;exports.useTableSelection=Re;exports.useTableSort=$e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),s=require("react/jsx-runtime");require("./styles.cjs");const Ne={search:"Buscar",searchPlaceholder:"Buscar...",noData:"No hay datos",loading:"Cargando...",page:"Página",of:"de",items:"elementos",selected:"seleccionados",rowsPerPage:"Filas por página",actions:"Acciones",sortAsc:"Ordenar ascendente",sortDesc:"Ordenar descendente",filterBy:"Filtrar por",clearFilters:"Limpiar filtros",selectAll:"Seleccionar todo",deselectAll:"Deseleccionar todo"},Pe=c.createContext(null);function P(){const e=c.useContext(Pe);if(!e)throw new Error("useTableContext must be used within a TableProvider");return e}function Te({value:e,children:a}){return s.jsx(Pe.Provider,{value:e,children:a})}function De(e){var a,l,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(a=0;a<r;a++)e[a]&&(l=De(e[a]))&&(n&&(n+=" "),n+=l)}else for(l in e)e[l]&&(n&&(n+=" "),n+=l);return n}function S(){for(var e,a,l=0,n="",r=arguments.length;l<r;l++)(e=arguments[l])&&(a=De(e))&&(n&&(n+=" "),n+=a);return n}function Ve({column:e}){const{sortState:a,handleSort:l,filters:n,setFilter:r,locale:t}=P(),i=a.columnId===e.id,d=i?a.direction:null,b=c.useCallback(()=>{e.sortable!==!1&&l(e.id)},[e.id,e.sortable,l]),u=c.useCallback(f=>{const g=f.target.value;e.type==="boolean"?g===""?r(e.id,null):r(e.id,g==="true"):r(e.id,g||null)},[e.id,e.type,r]),h=c.useCallback(f=>{f.key==="Enter"&&e.sortable!==!1&&l(e.id)},[e.id,e.sortable,l]),m=()=>e.sortable===!1||e.type==="custom"?null:s.jsx("button",{className:S("bt-sort-btn",i&&"bt-active"),onClick:b,"aria-label":d==="asc"?t.sortDesc:t.sortAsc,type:"button",children:i?d==="asc"?"↑":"↓":"⇅"}),p=()=>{if(e.filterable===!1||e.type==="custom")return null;const f=n[e.id];return e.type==="boolean"?s.jsxs("select",{className:"bt-filter-select",value:f==null?"":String(f),onChange:u,"aria-label":`${t.filterBy} ${e.header}`,children:[s.jsx("option",{value:"",children:"-"}),s.jsx("option",{value:"true",children:"✅"}),s.jsx("option",{value:"false",children:"❌"})]}):s.jsx("input",{type:e.type==="number"?"number":"text",className:"bt-filter-input",placeholder:`${t.filterBy}...`,value:f!=null?String(f):"",onChange:u,"aria-label":`${t.filterBy} ${e.header}`})};return e.headerCell?s.jsx("th",{className:S("bt-th",e.align&&`bt-align-${e.align}`),style:{width:e.width},children:e.headerCell(e)}):s.jsx("th",{className:S("bt-th",e.align&&`bt-align-${e.align}`),style:{width:e.width},role:"columnheader","aria-sort":i?d==="asc"?"ascending":"descending":void 0,tabIndex:e.sortable!==!1?0:void 0,onKeyDown:e.sortable!==!1?h:void 0,children:s.jsxs("div",{className:"bt-th-content",children:[s.jsxs("div",{className:"bt-th-header",children:[s.jsx("span",{className:"bt-th-title",children:e.header}),m()]}),e.filterable!==!1&&p()]})})}const Je=c.memo(Ve);function _e(){const{columns:e,selectable:a,selectionMode:l,rowActions:n,isAllSelected:r,isPartiallySelected:t,selectAll:i,deselectAll:d,locale:b,stickyHeader:u}=P(),h=e.filter(f=>!f.hidden),m=n&&n.length>0,p=()=>{r?d():i()};return s.jsx("thead",{className:S("bt-thead",u&&"bt-sticky"),children:s.jsxs("tr",{className:"bt-tr",children:[a&&s.jsx("th",{className:"bt-th bt-checkbox-cell",children:l==="multiple"&&s.jsx("input",{type:"checkbox",className:"bt-checkbox",checked:r,ref:f=>{f&&(f.indeterminate=t)},onChange:p,"aria-label":r?b.deselectAll:b.selectAll})}),h.map(f=>s.jsx(Je,{column:f},f.id)),m&&s.jsx("th",{className:"bt-th bt-actions-cell",children:b.actions})]})})}const Qe=_e;function M(e,a){if(!e||!a)return;const l=a.split(".");let n=e;for(const r of l){if(n==null)return;if(typeof n=="object")n=n[r];else return}return n}function we(e,a,l){return[...e].sort((n,r)=>{const t=M(n,a),i=M(r,a);if(t==null)return l==="asc"?1:-1;if(i==null)return l==="asc"?-1:1;if(typeof t=="string"&&typeof i=="string"){const h=t.localeCompare(i,void 0,{sensitivity:"base",numeric:!0});return l==="asc"?h:-h}if(typeof t=="number"&&typeof i=="number")return l==="asc"?t-i:i-t;if(typeof t=="boolean"&&typeof i=="boolean"){const h=t===i?0:t?-1:1;return l==="asc"?h:-h}if(t instanceof Date&&i instanceof Date){const h=t.getTime()-i.getTime();return l==="asc"?h:-h}const d=String(t),b=String(i),u=d.localeCompare(b);return l==="asc"?u:-u})}function Ae(e,a,l){const n=Object.entries(a).filter(([,r])=>r!=null&&r!=="");return n.length===0?e:e.filter(r=>n.every(([t,i])=>{const d=l.find(h=>h.id===t);if(!d)return!0;const b=M(r,String(d.accessor));if(b==null)return!1;switch(d.type??"string"){case"boolean":return b===i;case"number":return String(b)===String(i);case"date":if(b instanceof Date&&i){const h=new Date(String(i));return b.toDateString()===h.toDateString()}return String(b).includes(String(i));default:return String(b).toLowerCase().includes(String(i).toLowerCase())}}))}function Me(e,a,l,n){if(!a.trim())return e;const r=a.toLowerCase().trim(),t=n?l.filter(i=>n.includes(i.id)):l.filter(i=>i.type!=="custom");return e.filter(i=>t.some(d=>{const b=M(i,String(d.accessor));return b==null?!1:String(b).toLowerCase().includes(r)}))}function Ge({row:e,column:a,rowIndex:l}){const n=M(e,String(a.accessor)),t=(()=>{if(a.cell)return a.cell(n,e,l);if(n==null)return s.jsx("span",{className:"bt-cell-empty",children:"—"});switch(a.type){case"boolean":return n?"✅":"❌";case"date":if(n instanceof Date)return n.toLocaleDateString();const i=new Date(String(n));return isNaN(i.getTime())?String(n):i.toLocaleDateString();case"number":return typeof n=="number"?n.toLocaleString():n;default:return String(n)}})();return s.jsx("td",{className:S("bt-td",a.align&&`bt-align-${a.align}`),style:{width:a.width},children:t})}const Ue=c.memo(Ge);function We({row:e,rowIndex:a}){const{rowActions:l,openModal:n}=P(),r=c.useCallback(t=>{if(t.mode==="callback"&&t.onClick)t.onClick(e,a);else if(t.mode==="modal"&&t.modalContent){const i=t.modalContent;n(s.jsx(i,{data:e,onClose:()=>{}}))}else if(t.mode==="link"&&t.href){const i=typeof t.href=="function"?t.href(e):t.href;window.open(i,"_blank")}},[e,a,n]);return!l||l.length===0?null:s.jsx("td",{className:"bt-td bt-actions-cell",children:s.jsx("div",{className:"bt-actions-wrapper",children:l.map(t=>{if(t.visible&&!t.visible(e))return null;const i=t.disabled?t.disabled(e):!1;if(t.mode==="link"&&t.href){const d=typeof t.href=="function"?t.href(e):t.href;return s.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:S("bt-action-btn",t.variant&&`bt-variant-${t.variant}`),"aria-label":t.label,children:t.icon&&s.jsx("span",{className:"bt-action-icon",children:t.icon})},t.id)}return s.jsx("button",{className:S("bt-action-btn",t.variant&&`bt-variant-${t.variant}`),onClick:()=>r(t),disabled:i,"aria-label":t.label,title:t.label,type:"button",children:t.icon&&s.jsx("span",{className:"bt-action-icon",children:t.icon})},t.id)})})})}const Xe=c.memo(We);function Ye({row:e,rowIndex:a}){const{columns:l,selectable:n,rowActions:r,isSelected:t,toggleRow:i,striped:d,hoverable:b,onRowClick:u,onRowDoubleClick:h}=P(),m=l.filter(y=>!y.hidden),p=r&&r.length>0,f=n&&t(e,a),g=!!u,v=c.useCallback(()=>{u?.(e,a)},[e,a,u]),k=c.useCallback(()=>{h?.(e,a)},[e,a,h]),D=c.useCallback(()=>{i(e,a)},[e,a,i]),N=c.useCallback(y=>{y.key==="Enter"&&u&&v()},[v,u]);return s.jsxs("tr",{className:S("bt-tr",d&&"bt-striped",b&&"bt-hoverable",f&&"bt-selected",g&&"bt-clickable"),onClick:g?v:void 0,onDoubleClick:h?k:void 0,onKeyDown:g?N:void 0,tabIndex:g?0:void 0,role:g?"button":void 0,"aria-selected":n?f:void 0,children:[n&&s.jsx("td",{className:"bt-td bt-checkbox-cell",children:s.jsx("input",{type:"checkbox",className:"bt-checkbox",checked:f,onChange:D,onClick:y=>y.stopPropagation(),"aria-label":`Select row ${a+1}`})}),m.map(y=>s.jsx(Ue,{row:e,column:y,rowIndex:a},y.id)),p&&s.jsx(Xe,{row:e,rowIndex:a})]})}const Ze=c.memo(Ye);function et(){const{processedData:e,rowKey:a}=P(),l=(n,r)=>{if(typeof a=="function")return a(n,r);const t=n[a];return String(t!==void 0?t:r)};return s.jsx("tbody",{className:"bt-tbody",children:e.map((n,r)=>s.jsx(Ze,{row:n,rowIndex:r},l(n,r)))})}const tt=et;function st(){const{page:e,pageSize:a,totalPages:l,totalItems:n,goToPage:r,nextPage:t,prevPage:i,changePageSize:d,hasNextPage:b,hasPrevPage:u,startIndex:h,endIndex:m,paginationEnabled:p,pageSizeOptions:f,showSizeChanger:g,locale:v,classNames:k}=P(),D=c.useCallback(o=>{d(Number(o.target.value))},[d]),N=c.useCallback(o=>{if(o.key==="Enter"){const x=parseInt(o.target.value,10);!isNaN(x)&&x>=1&&x<=l&&r(x)}},[r,l]),y=c.useMemo(()=>{const o=[];if(l<=5)for(let C=1;C<=l;C++)o.push(C);else{o.push(1),e>3&&o.push("ellipsis");const C=Math.max(2,e-1),j=Math.min(l-1,e+1);for(let T=C;T<=j;T++)o.push(T);e<l-2&&o.push("ellipsis"),l>1&&o.push(l)}return o},[e,l]);return p?s.jsxs("div",{className:`bt-pagination ${k.pagination||""}`,children:[s.jsx("div",{className:"bt-pagination-info",children:n>0?`${h}-${m} ${v.of} ${n} ${v.items}`:`0 ${v.items}`}),s.jsxs("div",{className:"bt-pagination-controls",children:[g&&s.jsxs("div",{className:"bt-page-size",children:[s.jsxs("span",{className:"bt-page-size-label",children:[v.rowsPerPage,":"]}),s.jsx("select",{className:"bt-page-size-select",value:a,onChange:D,"aria-label":v.rowsPerPage,children:f.map(o=>s.jsx("option",{value:o,children:o},o))})]}),s.jsx("button",{className:"bt-pagination-btn",onClick:i,disabled:!u,"aria-label":"Previous page",type:"button",children:"←"}),s.jsx("div",{className:"bt-pagination-pages",children:y.map((o,x)=>o==="ellipsis"?s.jsx("span",{className:"bt-pagination-ellipsis",children:"..."},`ellipsis-${x}`):s.jsx("button",{className:`bt-pagination-btn ${e===o?"bt-active":""}`,onClick:()=>r(o),"aria-label":`${v.page} ${o}`,"aria-current":e===o?"page":void 0,type:"button",children:o},o))}),s.jsx("button",{className:"bt-pagination-btn",onClick:t,disabled:!b,"aria-label":"Next page",type:"button",children:"→"}),s.jsxs("div",{className:"bt-quick-jumper",children:[s.jsxs("span",{className:"bt-quick-jumper-label",children:[v.page,":"]}),s.jsx("input",{type:"number",className:"bt-quick-jumper-input",min:1,max:l,defaultValue:e,onKeyDown:N,"aria-label":"Jump to page"})]})]})]}):null}function at(){const{searchable:e,searchValue:a,handleSearch:l,clearSearch:n,globalActions:r,selectedRows:t,selectedCount:i,deselectAll:d,data:b,locale:u,classNames:h,selectable:m}=P(),p=c.useCallback(g=>{l(g.target.value)},[l]);return e||r&&r.length>0||m&&i>0?s.jsxs("div",{className:`bt-toolbar ${h.toolbar||""}`,children:[s.jsxs("div",{className:"bt-toolbar-left",children:[e&&s.jsxs("div",{className:"bt-search",children:[s.jsx("span",{className:"bt-search-icon",children:"🔍"}),s.jsx("input",{type:"text",className:"bt-search-input",placeholder:u.searchPlaceholder,value:a,onChange:p,"aria-label":u.search}),a&&s.jsx("button",{className:"bt-search-clear",onClick:n,"aria-label":"Clear search",type:"button",children:"✕"})]}),m&&i>0&&s.jsxs("div",{className:"bt-selection-info",children:[s.jsxs("span",{children:[i," ",u.selected]}),s.jsx("button",{className:"bt-selection-clear",onClick:d,type:"button",children:u.deselectAll})]})]}),r&&r.length>0&&s.jsx("div",{className:"bt-toolbar-right",children:s.jsx("div",{className:"bt-global-actions",children:r.map(g=>{const v=g.requiresSelection&&t.length===0;return s.jsxs("button",{className:S("bt-global-btn",g.variant&&`bt-variant-${g.variant}`),onClick:()=>g.onClick(t,b),disabled:v,title:g.label,type:"button",children:[g.icon&&s.jsx("span",{className:"bt-global-icon",children:g.icon}),s.jsx("span",{children:g.label})]},g.id)})})})]}):null}const lt=at;function nt(){const{locale:e,emptyComponent:a,columns:l,selectable:n,rowActions:r}=P(),t=l.filter(b=>!b.hidden),i=r&&r.length>0,d=t.length+(n?1:0)+(i?1:0);return a?s.jsx("tbody",{className:"bt-tbody",children:s.jsx("tr",{className:"bt-tr",children:s.jsx("td",{className:"bt-td",colSpan:d,children:a})})}):s.jsx("tbody",{className:"bt-tbody",children:s.jsx("tr",{className:"bt-tr",children:s.jsx("td",{className:"bt-td",colSpan:d,children:s.jsxs("div",{className:"bt-empty",children:[s.jsx("div",{className:"bt-empty-icon",children:"📭"}),s.jsx("div",{className:"bt-empty-text",children:e.noData})]})})})})}function it({show:e}){const{loadingComponent:a,locale:l}=P();return e?s.jsx("div",{className:"bt-loading-overlay",role:"status","aria-live":"polite",children:a||s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"bt-loading-spinner","aria-hidden":"true"}),s.jsx("span",{className:"bt-loading-text",children:l.loading})]})}):null}function rt(){const{isModalOpen:e,modalContent:a,closeModal:l}=P(),n=c.useCallback(t=>{t.target===t.currentTarget&&l()},[l]),r=c.useCallback(t=>{t.key==="Escape"&&l()},[l]);return c.useEffect(()=>(e&&(document.addEventListener("keydown",r),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",r),document.body.style.overflow=""}),[e,r]),!e||!a?null:s.jsx("div",{className:"bt-modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:s.jsxs("div",{className:"bt-modal bt-modal-md",children:[s.jsxs("div",{className:"bt-modal-header",children:[s.jsx("h2",{className:"bt-modal-title",children:"Detalles"}),s.jsx("button",{className:"bt-modal-close",onClick:l,"aria-label":"Close modal",type:"button",children:"✕"})]}),s.jsx("div",{className:"bt-modal-body",children:a})]})})}function $e({data:e,initialSort:a,controlledSort:l,onSortChange:n}){const[r,t]=c.useState(a??{columnId:null,direction:"asc"}),i=l??r,d=c.useCallback(h=>{const m={columnId:h,direction:i.columnId===h&&i.direction==="asc"?"desc":"asc"};l||t(m),n?.(m)},[i,l,n]),b=c.useCallback(()=>{const h={columnId:null,direction:"asc"};l||t(h),n?.(h)},[l,n]);return{sortedData:c.useMemo(()=>i.columnId?we(e,i.columnId,i.direction):e,[e,i]),sortState:i,handleSort:d,clearSort:b}}function ze({data:e,columns:a,initialFilters:l,controlledFilters:n,onFilterChange:r}){const[t,i]=c.useState(l??{}),d=n??t,b=c.useCallback((p,f)=>{const g={...d};f==null||f===""?delete g[p]:g[p]=f,n||i(g),r?.(g)},[d,n,r]),u=c.useCallback(p=>{const f={...d};delete f[p],n||i(f),r?.(f)},[d,n,r]),h=c.useCallback(()=>{n||i({}),r?.({})},[n,r]);return{filteredData:c.useMemo(()=>Ae(e,d,a),[e,d,a]),filters:d,setFilter:b,clearFilters:h,clearFilter:u}}function Re({data:e,config:a,onPageChange:l}){const n=a!==!1,r=a&&typeof a=="object"?a.page??1:1,t=a&&typeof a=="object"?a.pageSize??10:10,i=a&&typeof a=="object"?a.totalItems:void 0,[d,b]=c.useState(r),[u,h]=c.useState(t),m=i??e.length,p=Math.max(1,Math.ceil(m/u)),f=c.useCallback(o=>{const x=Math.max(1,Math.min(o,p));b(x),l?.(x,u)},[p,u,l]),g=c.useCallback(()=>{d<p&&f(d+1)},[d,p,f]),v=c.useCallback(()=>{d>1&&f(d-1)},[d,f]),k=c.useCallback(o=>{h(o),b(1),l?.(1,o)},[l]),D=c.useMemo(()=>{if(!n||i!==void 0)return e;const o=(d-1)*u;return e.slice(o,o+u)},[e,d,u,n,i]),N=(d-1)*u+1,y=Math.min(d*u,m);return{paginatedData:D,page:d,pageSize:u,totalPages:p,totalItems:m,goToPage:f,nextPage:g,prevPage:v,changePageSize:k,hasNextPage:d<p,hasPrevPage:d>1,startIndex:N,endIndex:y}}function Ie({data:e,rowKey:a,mode:l="multiple",initialSelection:n,controlledSelection:r,onSelectionChange:t}){const[i,d]=c.useState(n??[]),b=r??i,u=c.useCallback((o,x)=>typeof a=="function"?a(o,x):String(o[a]),[a]),h=c.useMemo(()=>new Set(b.map((o,x)=>u(o,x))),[b,u]),m=c.useCallback((o,x)=>{const C=u(o,x);return h.has(C)},[u,h]),p=c.useCallback(o=>{r||d(o),t?.(o)},[r,t]),f=c.useCallback((o,x)=>{const C=u(o,x);let j;l==="single"?j=h.has(C)?[]:[o]:h.has(C)?j=b.filter((T,A)=>u(T,A)!==C):j=[...b,o],p(j)},[l,h,b,u,p]),g=c.useCallback((o,x)=>{if(!m(o,x)){const C=l==="single"?[o]:[...b,o];p(C)}},[m,l,b,p]),v=c.useCallback((o,x)=>{const C=u(o,x),j=b.filter((T,A)=>u(T,A)!==C);p(j)},[b,u,p]),k=c.useCallback(()=>{l==="multiple"&&p([...e])},[e,l,p]),D=c.useCallback(()=>{p([])},[p]),N=e.length>0&&b.length===e.length,y=b.length>0&&b.length<e.length;return{selectedRows:b,isSelected:m,toggleRow:f,selectRow:g,deselectRow:v,selectAll:k,deselectAll:D,isAllSelected:N,isPartiallySelected:y,selectedCount:b.length}}function Be({data:e,columns:a,searchColumns:l,initialValue:n,controlledValue:r,onSearchChange:t}){const[i,d]=c.useState(n??""),b=r??i,u=c.useCallback(p=>{r===void 0&&d(p),t?.(p)},[r,t]),h=c.useCallback(()=>{r===void 0&&d(""),t?.("")},[r,t]);return{searchedData:c.useMemo(()=>Me(e,b,a,l),[e,b,a,l]),searchValue:b,handleSearch:u,clearSearch:h}}function ct(e){const{data:a,columns:l,rowKey:n="id",rowActions:r,globalActions:t,pagination:i={pageSize:10},onPageChange:d,sort:b,onSortChange:u,filters:h,onFilterChange:m,searchable:p=!1,searchValue:f,onSearchChange:g,searchColumns:v,selectable:k,selectedRows:D,onSelectionChange:N,selectionMode:y="multiple",loading:o=!1,loadingComponent:x,emptyComponent:C,classNames:j={},styles:T={},locale:A,stickyHeader:I=!1,maxHeight:Le,bordered:$=!1,striped:B=!1,hoverable:L=!0,size:z="medium",onRowClick:F,onRowDoubleClick:O,ariaLabel:Fe,ariaDescribedBy:Oe}=e,E=c.useMemo(()=>k!==void 0?k:t?.some(He=>He.requiresSelection)||N!==void 0,[k,t,N]),q=c.useMemo(()=>({...Ne,...A}),[A]),[K,H]=c.useState(!1),[V,J]=c.useState(null),_=c.useCallback(ke=>{J(ke),H(!0)},[]),Q=c.useCallback(()=>{H(!1),J(null)},[]),w=c.useMemo(()=>i===!1?!1:{pageSize:10,pageSizeOptions:[10,20,50,100],showSizeChanger:!1,...i},[i]),{searchedData:Ee,searchValue:G,handleSearch:U,clearSearch:W}=Be({data:a,columns:l,searchColumns:v,controlledValue:f,onSearchChange:g}),{filteredData:qe,filters:X,setFilter:Y,clearFilters:Z}=ze({data:Ee,columns:l,controlledFilters:h,onFilterChange:m}),{sortedData:ee,sortState:te,handleSort:se}=$e({data:qe,controlledSort:b,onSortChange:u}),{selectedRows:ae,isSelected:le,toggleRow:ne,selectAll:ie,deselectAll:re,isAllSelected:ce,isPartiallySelected:oe,selectedCount:de}=Ie({data:ee,rowKey:n,mode:y,controlledSelection:D,onSelectionChange:N}),{paginatedData:R,page:be,pageSize:ue,totalPages:he,totalItems:fe,goToPage:pe,nextPage:ge,prevPage:me,changePageSize:xe,hasNextPage:ve,hasPrevPage:ye,startIndex:Ce,endIndex:je}=Re({data:ee,config:w,onPageChange:d}),Ke=c.useMemo(()=>({data:a,processedData:R,columns:l,rowKey:n,rowActions:r,globalActions:t,sortState:te,handleSort:se,filters:X,setFilter:Y,clearFilters:Z,searchValue:G,handleSearch:U,clearSearch:W,searchable:p,selectedRows:ae,isSelected:le,toggleRow:ne,selectAll:ie,deselectAll:re,isAllSelected:ce,isPartiallySelected:oe,selectable:E,selectionMode:y,selectedCount:de,page:be,pageSize:ue,totalPages:he,totalItems:fe,goToPage:pe,nextPage:ge,prevPage:me,changePageSize:xe,hasNextPage:ve,hasPrevPage:ye,startIndex:Ce,endIndex:je,paginationEnabled:i!==!1,pageSizeOptions:w&&typeof w=="object"?w.pageSizeOptions??[10,20,50,100]:[10,20,50,100],showSizeChanger:w&&typeof w=="object"?w.showSizeChanger??!1:!1,loading:o,loadingComponent:x,emptyComponent:C,locale:q,classNames:j,size:z,bordered:$,striped:B,hoverable:L,stickyHeader:I,onRowClick:F,onRowDoubleClick:O,openModal:_,closeModal:Q,modalContent:V,isModalOpen:K}),[a,R,l,n,r,t,te,se,X,Y,Z,G,U,W,p,ae,le,ne,ie,re,ce,oe,E,y,de,be,ue,he,fe,pe,ge,me,xe,ve,ye,Ce,je,i,w,o,x,C,q,j,z,$,B,L,I,F,O,_,Q,V,K]),Se=R.length>0;return s.jsx(Te,{value:Ke,children:s.jsxs("div",{className:S("bt-container",`bt-size-${z}`,o&&"bt-container-loading",j.container),style:T.container,children:[s.jsx(lt,{}),s.jsxs("div",{className:S("bt-table-wrapper",$&&"bt-bordered"),style:{maxHeight:Le},children:[s.jsxs("table",{className:S("bt-table",j.table),style:T.table,role:"grid","aria-label":Fe,"aria-describedby":Oe,"aria-busy":o,children:[s.jsx(Qe,{}),Se?s.jsx(tt,{}):s.jsx(nt,{})]}),s.jsx(it,{show:o&&Se})]}),i!==!1&&s.jsx(st,{}),s.jsx(rt,{})]})})}const ot=ct;exports.BetterTable=ot;exports.TableProvider=Te;exports.defaultLocale=Ne;exports.filterData=Ae;exports.getValueFromPath=M;exports.searchData=Me;exports.sortData=we;exports.useTableContext=P;exports.useTableFilter=ze;exports.useTablePagination=Re;exports.useTableSearch=Be;exports.useTableSelection=Ie;exports.useTableSort=$e;
2
2
  //# sourceMappingURL=better-table.cjs.js.map