better-table 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -18
- package/dist/better-table.cjs.js +1 -1
- package/dist/better-table.cjs.js.map +1 -1
- package/dist/better-table.css +1 -1
- package/dist/better-table.es.js +2225 -980
- package/dist/better-table.es.js.map +1 -1
- package/dist/components/BetterTable/__tests__/helpers/test-data.d.ts +125 -0
- package/dist/components/BetterTable/components/TableActionOverflow.d.ts +16 -0
- package/dist/components/BetterTable/components/TableColumnVisibility.d.ts +4 -0
- package/dist/components/BetterTable/components/TableExpandedRow.d.ts +8 -0
- package/dist/components/BetterTable/components/TableFilterPanel.d.ts +7 -0
- package/dist/components/BetterTable/components/TableFloatingFilter.d.ts +8 -0
- package/dist/components/BetterTable/components/TableRow.d.ts +2 -1
- package/dist/components/BetterTable/components/TableVirtualBody.d.ts +10 -0
- package/dist/components/BetterTable/components/index.d.ts +6 -0
- package/dist/components/BetterTable/constants.d.ts +20 -0
- package/dist/components/BetterTable/context/TableContext.d.ts +15 -65
- package/dist/components/BetterTable/context/TableDataContext.d.ts +18 -0
- package/dist/components/BetterTable/context/TableFilterContext.d.ts +17 -0
- package/dist/components/BetterTable/context/TablePaginationContext.d.ts +19 -0
- package/dist/components/BetterTable/context/TableSelectionContext.d.ts +15 -0
- package/dist/components/BetterTable/context/TableSortContext.d.ts +10 -0
- package/dist/components/BetterTable/context/TableUIContext.d.ts +33 -0
- package/dist/components/BetterTable/context/index.d.ts +14 -2
- package/dist/components/BetterTable/hooks/index.d.ts +6 -0
- package/dist/components/BetterTable/hooks/useColumnResize.d.ts +23 -0
- package/dist/components/BetterTable/hooks/useColumnVisibility.d.ts +24 -0
- package/dist/components/BetterTable/hooks/useExpandableRows.d.ts +19 -0
- package/dist/components/BetterTable/hooks/useFocusTrap.d.ts +6 -0
- package/dist/components/BetterTable/hooks/useMediaQuery.d.ts +8 -0
- package/dist/components/BetterTable/hooks/useTableFilter.d.ts +5 -3
- package/dist/components/BetterTable/hooks/useTablePagination.d.ts +3 -1
- package/dist/components/BetterTable/hooks/useTableSearch.d.ts +3 -1
- package/dist/components/BetterTable/hooks/useTableSort.d.ts +14 -2
- package/dist/components/BetterTable/hooks/useVirtualization.d.ts +25 -0
- package/dist/components/BetterTable/index.d.ts +5 -4
- package/dist/components/BetterTable/types.d.ts +178 -5
- package/dist/components/BetterTable/utils/sortData.d.ts +8 -1
- package/dist/index.d.ts +6 -5
- package/package.json +24 -15
package/README.md
CHANGED
|
@@ -2,13 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
A modern, flexible, and fully typed data table component for React.
|
|
4
4
|
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- 🔍 **Search & Filter** — Global search with debounce + floating filters / filter panel / both
|
|
8
|
+
- 📊 **Sorting** — Single & multi-sort with 3-state cycle (asc → desc → unsorted)
|
|
9
|
+
- 👁️ **Column Visibility** — Interactive toggle to show/hide columns at runtime
|
|
10
|
+
- 🔄 **Column Resizing** — Drag-to-resize with min/max width constraints
|
|
11
|
+
- 📂 **Expandable Rows** — Detail rows with controlled/uncontrolled + accordion mode
|
|
12
|
+
- ⚡ **Virtualization** — Built-in row virtualization for large datasets (zero deps)
|
|
13
|
+
- 🌐 **Server-Side Mode** — Delegate sorting, filtering, pagination to your API
|
|
14
|
+
- 📌 **Sticky Headers** — Headers stay visible when scrolling
|
|
15
|
+
- ✅ **Selection** — Single or multiple row selection with global actions
|
|
16
|
+
- 🎬 **Row Actions** — Callbacks, modals, links + overflow menu
|
|
17
|
+
- 📱 **Responsive** — Card layout for mobile, collapsible toolbar
|
|
18
|
+
- 📄 **Pagination** — Configurable page sizes, quick jumper
|
|
19
|
+
- 🌍 **i18n** — Preset locales (EN/ES/PT) + custom overrides
|
|
20
|
+
- 🎨 **Customizable** — CSS variables, custom renderers, class overrides
|
|
21
|
+
- ♿ **Accessible** — ARIA labels, `aria-live` announcements, focus trap in modals
|
|
22
|
+
- 💪 **TypeScript** — Full type safety with generics
|
|
23
|
+
|
|
5
24
|
## 📚 Documentation
|
|
6
25
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
26
|
+
| Document | Description |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| [Architecture](./docs/architecture.md) | Design patterns and technical decisions |
|
|
29
|
+
| [Components](./docs/components.md) | Detailed API reference for all components |
|
|
30
|
+
| [Interaction Flows](./docs/interaction-flows.md) | Sequence diagrams and component interactions |
|
|
31
|
+
| [Known Issues](./docs/known-issues.md) | Known bugs, limitations and workarounds |
|
|
32
|
+
| [Development](./docs/development.md) | Contributing guide and local setup |
|
|
33
|
+
| [Roadmap](./docs/ROADMAP.md) | Future improvements and features |
|
|
34
|
+
| [Changelog](./CHANGELOG.md) | Version history |
|
|
12
35
|
|
|
13
36
|
## 🚀 Quick Start
|
|
14
37
|
|
|
@@ -16,23 +39,169 @@ A modern, flexible, and fully typed data table component for React.
|
|
|
16
39
|
npm install better-table
|
|
17
40
|
```
|
|
18
41
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
### Basic Usage
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { BetterTable } from "better-table";
|
|
46
|
+
import "better-table/styles.css";
|
|
22
47
|
|
|
23
48
|
const MyTable = () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
const data = [
|
|
50
|
+
{ id: 1, name: "Juan", email: "juan@example.com", active: true },
|
|
51
|
+
{ id: 2, name: "María", email: "maria@example.com", active: false },
|
|
52
|
+
];
|
|
28
53
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
const columns = [
|
|
55
|
+
{ id: "name", accessor: "name", header: "Name", sortable: true },
|
|
56
|
+
{ id: "email", accessor: "email", header: "Email" },
|
|
57
|
+
{ id: "active", accessor: "active", header: "Status", type: "boolean" },
|
|
58
|
+
];
|
|
33
59
|
|
|
34
|
-
|
|
60
|
+
return <BetterTable data={data} columns={columns} rowKey="id" />;
|
|
35
61
|
};
|
|
36
62
|
```
|
|
37
63
|
|
|
38
|
-
|
|
64
|
+
### Column Resizing
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<BetterTable
|
|
68
|
+
data={users}
|
|
69
|
+
columns={[
|
|
70
|
+
{ id: "name", accessor: "name", header: "Name", resizable: true, minWidth: 100 },
|
|
71
|
+
{ id: "email", accessor: "email", header: "Email", resizable: true },
|
|
72
|
+
]}
|
|
73
|
+
rowKey="id"
|
|
74
|
+
resizable
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Expandable Rows
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<BetterTable
|
|
82
|
+
data={users}
|
|
83
|
+
columns={columns}
|
|
84
|
+
rowKey="id"
|
|
85
|
+
expandable={{
|
|
86
|
+
render: (row) => <div>Details for {row.name}</div>,
|
|
87
|
+
accordion: true,
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Server-Side Data
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<BetterTable
|
|
96
|
+
data={serverData}
|
|
97
|
+
columns={columns}
|
|
98
|
+
rowKey="id"
|
|
99
|
+
manualPagination
|
|
100
|
+
manualSorting
|
|
101
|
+
pagination={{ pageSize: 10, totalItems: total }}
|
|
102
|
+
onPageChange={(page, size) => fetchData({ page, size })}
|
|
103
|
+
onSortChange={(sort) => fetchData({ sort })}
|
|
104
|
+
/>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Virtualization
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
// Auto-enables when pagination={false} and dataset > 500 rows
|
|
111
|
+
<BetterTable
|
|
112
|
+
data={largeDataset}
|
|
113
|
+
columns={columns}
|
|
114
|
+
rowKey="id"
|
|
115
|
+
pagination={false}
|
|
116
|
+
stickyHeader
|
|
117
|
+
/>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Multi-Sort & Column Visibility
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
<BetterTable
|
|
124
|
+
data={users}
|
|
125
|
+
columns={columns}
|
|
126
|
+
rowKey="id"
|
|
127
|
+
multiSort
|
|
128
|
+
columnVisibility
|
|
129
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Filter Modes
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
<BetterTable data={data} columns={columns} filterMode="floating" /> {/* default */}
|
|
136
|
+
<BetterTable data={data} columns={columns} filterMode="panel" />
|
|
137
|
+
<BetterTable data={data} columns={columns} filterMode="both" />
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Internationalization (i18n)
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<BetterTable data={data} columns={columns} locale="es" />
|
|
144
|
+
<BetterTable data={data} columns={columns} locale={{ noData: "Nothing to show" }} />
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 🎨 Customization
|
|
148
|
+
|
|
149
|
+
### CSS Variables
|
|
150
|
+
|
|
151
|
+
```css
|
|
152
|
+
:root {
|
|
153
|
+
--bt-primary-color: #3b82f6;
|
|
154
|
+
--bt-border-color: #e5e7eb;
|
|
155
|
+
--bt-hover-bg: #f3f4f6;
|
|
156
|
+
--bt-selected-bg: #dbeafe;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Custom Class Names
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
<BetterTable
|
|
164
|
+
data={data}
|
|
165
|
+
columns={columns}
|
|
166
|
+
classNames={{
|
|
167
|
+
container: "my-table-container",
|
|
168
|
+
table: "my-table",
|
|
169
|
+
row: "my-row",
|
|
170
|
+
cell: "my-cell",
|
|
171
|
+
}}
|
|
172
|
+
/>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 📦 API Reference
|
|
176
|
+
|
|
177
|
+
See [Components Documentation](./docs/components.md) for complete API reference.
|
|
178
|
+
|
|
179
|
+
### Main Props
|
|
180
|
+
|
|
181
|
+
| Prop | Type | Default | Description |
|
|
182
|
+
| --- | --- | --- | --- |
|
|
183
|
+
| `data` | `T[]` | - | Array of data to display |
|
|
184
|
+
| `columns` | `Column<T>[]` | - | Column configuration |
|
|
185
|
+
| `rowKey` | `keyof T \| Function` | `'id'` | Unique key for rows |
|
|
186
|
+
| `searchable` | `boolean` | `false` | Enable search toolbar |
|
|
187
|
+
| `searchDebounceMs` | `number` | `300` | Search debounce delay (ms) |
|
|
188
|
+
| `filterMode` | `'floating' \| 'panel' \| 'both'` | `'floating'` | Filter display mode |
|
|
189
|
+
| `multiSort` | `boolean` | `false` | Enable multi-column sorting |
|
|
190
|
+
| `columnVisibility` | `boolean` | `false` | Show column visibility toggle |
|
|
191
|
+
| `resizable` | `boolean` | `false` | Enable column resizing |
|
|
192
|
+
| `expandable` | `ExpandableConfig<T>` | - | Expandable row config |
|
|
193
|
+
| `virtualize` | `boolean` | auto | Enable row virtualization |
|
|
194
|
+
| `stickyHeader` | `boolean` | `false` | Sticky table header |
|
|
195
|
+
| `manualSorting` | `boolean` | `false` | Skip client-side sorting |
|
|
196
|
+
| `manualFiltering` | `boolean` | `false` | Skip client-side filtering |
|
|
197
|
+
| `manualPagination` | `boolean` | `false` | Skip client-side pagination |
|
|
198
|
+
| `pagination` | `PaginationConfig \| false` | `{ pageSize: 10 }` | Pagination settings |
|
|
199
|
+
| `selectionMode` | `'single' \| 'multiple'` | - | Selection mode |
|
|
200
|
+
| `rowActions` | `RowAction<T>[]` | `[]` | Per-row actions |
|
|
201
|
+
| `globalActions` | `GlobalAction<T>[]` | `[]` | Global toolbar actions |
|
|
202
|
+
| `locale` | `LocaleKey \| TableLocale` | `'en'` | Locale preset or custom strings |
|
|
203
|
+
| `loading` | `boolean` | `false` | Loading state |
|
|
204
|
+
|
|
205
|
+
## 📄 License
|
|
206
|
+
|
|
207
|
+
Apache-2.0
|
package/dist/better-table.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),t=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"},De=d.createContext(null);function D(){const e=d.useContext(De);if(!e)throw new Error("useTableContext must be used within a TableProvider");return e}function Te({value:e,children:s}){return t.jsx(De.Provider,{value:e,children:s})}function Pe(e){var s,n,l="";if(typeof e=="string"||typeof e=="number")l+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(s=0;s<r;s++)e[s]&&(n=Pe(e[s]))&&(l&&(l+=" "),l+=n)}else for(n in e)e[n]&&(l&&(l+=" "),l+=n);return l}function S(){for(var e,s,n=0,l="",r=arguments.length;n<r;n++)(e=arguments[n])&&(s=Pe(e))&&(l&&(l+=" "),l+=s);return l}function He({column:e}){const{sortState:s,handleSort:n,filters:l,setFilter:r,locale:a}=D(),i=s.columnId===e.id,u=i?s.direction:null,o=d.useCallback(()=>{e.sortable!==!1&&n(e.id)},[e.id,e.sortable,n]),h=d.useCallback(f=>{const C=f.target.value;e.type==="boolean"?C===""?r(e.id,null):r(e.id,C==="true"):r(e.id,C||null)},[e.id,e.type,r]),p=d.useCallback(f=>{f.key==="Enter"&&e.sortable!==!1&&n(e.id)},[e.id,e.sortable,n]),x=()=>e.sortable===!1||e.type==="custom"?null:t.jsx("button",{className:S("bt-sort-btn",i&&"bt-active"),onClick:o,"aria-label":u==="asc"?a.sortDesc:a.sortAsc,type:"button",children:i?u==="asc"?"↑":"↓":"⇅"}),g=()=>{if(e.filterable===!1||e.type==="custom")return null;const f=l[e.id];return e.type==="boolean"?t.jsxs("select",{className:"bt-filter-select",value:f==null?"":String(f),onChange:h,"aria-label":`${a.filterBy} ${e.header}`,children:[t.jsx("option",{value:"",children:"-"}),t.jsx("option",{value:"true",children:"✅"}),t.jsx("option",{value:"false",children:"❌"})]}):t.jsx("input",{type:e.type==="number"?"number":"text",className:"bt-filter-input",placeholder:`${a.filterBy}...`,value:f!=null?String(f):"",onChange:h,"aria-label":`${a.filterBy} ${e.header}`})};return e.headerCell?t.jsx("th",{className:S("bt-th",e.align&&`bt-align-${e.align}`),style:{width:e.width},children:e.headerCell(e)}):t.jsx("th",{className:S("bt-th",e.align&&`bt-align-${e.align}`),style:{width:e.width},role:"columnheader","aria-sort":i?u==="asc"?"ascending":"descending":void 0,tabIndex:e.sortable!==!1?0:void 0,onKeyDown:e.sortable!==!1?p:void 0,children:t.jsxs("div",{className:"bt-th-content",children:[t.jsxs("div",{className:"bt-th-header",children:[t.jsx("span",{className:"bt-th-title",children:e.header}),x()]}),e.filterable!==!1&&g()]})})}const _e=d.memo(He);function Je(){const{columns:e,selectable:s,selectionMode:n,rowActions:l,isAllSelected:r,isPartiallySelected:a,selectAll:i,deselectAll:u,locale:o,stickyHeader:h}=D(),p=e.filter(f=>!f.hidden),x=l&&l.length>0,g=()=>{r?u():i()};return t.jsx("thead",{className:S("bt-thead",h&&"bt-sticky"),children:t.jsxs("tr",{className:"bt-tr",children:[s&&t.jsx("th",{className:"bt-th bt-checkbox-cell",children:n==="multiple"&&t.jsx("input",{type:"checkbox",className:"bt-checkbox",checked:r,ref:f=>{f&&(f.indeterminate=a)},onChange:g,"aria-label":r?o.deselectAll:o.selectAll})}),p.map(f=>t.jsx(_e,{column:f},f.id)),x&&t.jsx("th",{className:"bt-th bt-actions-cell",children:o.actions})]})})}const Qe=Je;function M(e,s){if(!e||!s)return;const n=s.split(".");let l=e;for(const r of n){if(l==null)return;if(typeof l=="object")l=l[r];else return}return l}function Ae(e,s,n){return[...e].sort((l,r)=>{const a=M(l,s),i=M(r,s);if(a==null)return n==="asc"?1:-1;if(i==null)return n==="asc"?-1:1;if(typeof a=="string"&&typeof i=="string"){const p=a.localeCompare(i,void 0,{sensitivity:"base",numeric:!0});return n==="asc"?p:-p}if(typeof a=="number"&&typeof i=="number")return n==="asc"?a-i:i-a;if(typeof a=="boolean"&&typeof i=="boolean"){const p=a===i?0:a?-1:1;return n==="asc"?p:-p}if(a instanceof Date&&i instanceof Date){const p=a.getTime()-i.getTime();return n==="asc"?p:-p}const u=String(a),o=String(i),h=u.localeCompare(o);return n==="asc"?h:-h})}function Me(e,s,n){const l=Object.entries(s).filter(([,r])=>r!=null&&r!=="");return l.length===0?e:e.filter(r=>l.every(([a,i])=>{const u=n.find(p=>p.id===a);if(!u)return!0;const o=M(r,String(u.accessor));if(o==null)return!1;switch(u.type??"string"){case"boolean":return o===i;case"number":return String(o)===String(i);case"date":if(o instanceof Date&&i){const p=new Date(String(i));return o.toDateString()===p.toDateString()}return String(o).includes(String(i));default:return String(o).toLowerCase().includes(String(i).toLowerCase())}}))}function we(e,s,n,l){if(!s.trim())return e;const r=s.toLowerCase().trim(),a=l?n.filter(i=>l.includes(i.id)):n.filter(i=>i.type!=="custom");return e.filter(i=>a.some(u=>{const o=M(i,String(u.accessor));return o==null?!1:String(o).toLowerCase().includes(r)}))}function Ge({row:e,column:s,rowIndex:n}){const l=M(e,String(s.accessor)),a=(()=>{if(s.cell)return s.cell(l,e,n);if(l==null)return t.jsx("span",{className:"bt-cell-empty",children:"—"});switch(s.type){case"boolean":return l?"✅":"❌";case"date":if(l instanceof Date)return l.toLocaleDateString();const i=new Date(String(l));return isNaN(i.getTime())?String(l):i.toLocaleDateString();case"number":return typeof l=="number"?l.toLocaleString():l;default:return String(l)}})();return t.jsx("td",{className:S("bt-td",s.align&&`bt-align-${s.align}`),style:{width:s.width},children:a})}const Ue=d.memo(Ge);function We({row:e,rowIndex:s}){const{rowActions:n,openModal:l}=D(),r=d.useCallback(a=>{if(a.mode==="callback"&&a.onClick)a.onClick(e,s);else if(a.mode==="modal"&&a.modalContent){const i=a.modalContent;l(t.jsx(i,{data:e,onClose:()=>{}}))}else if(a.mode==="link"&&a.href){const i=typeof a.href=="function"?a.href(e):a.href;window.open(i,"_blank")}},[e,s,l]);return!n||n.length===0?null:t.jsx("td",{className:"bt-td bt-actions-cell",children:t.jsx("div",{className:"bt-actions-wrapper",children:n.map(a=>{if(a.visible&&!a.visible(e))return null;const i=a.disabled?a.disabled(e):!1;if(a.mode==="link"&&a.href){const u=typeof a.href=="function"?a.href(e):a.href;return t.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:S("bt-action-btn",a.variant&&`bt-variant-${a.variant}`),"aria-label":a.label,children:a.icon&&t.jsx("span",{className:"bt-action-icon",children:a.icon})},a.id)}return t.jsx("button",{className:S("bt-action-btn",a.variant&&`bt-variant-${a.variant}`),onClick:()=>r(a),disabled:i,"aria-label":a.label,title:a.label,type:"button",children:a.icon&&t.jsx("span",{className:"bt-action-icon",children:a.icon})},a.id)})})})}const Xe=d.memo(We);function Ye({row:e,rowIndex:s}){const{columns:n,selectable:l,rowActions:r,isSelected:a,toggleRow:i,striped:u,hoverable:o,onRowClick:h,onRowDoubleClick:p}=D(),x=n.filter(j=>!j.hidden),g=r&&r.length>0,f=l&&a(e,s),C=!!h,y=d.useCallback(()=>{h?.(e,s)},[e,s,h]),k=d.useCallback(()=>{p?.(e,s)},[e,s,p]),P=d.useCallback(()=>{i(e,s)},[e,s,i]),N=d.useCallback(j=>{j.key==="Enter"&&h&&y()},[y,h]);return t.jsxs("tr",{className:S("bt-tr",u&&"bt-striped",o&&"bt-hoverable",f&&"bt-selected",C&&"bt-clickable"),onClick:C?y:void 0,onDoubleClick:p?k:void 0,onKeyDown:C?N:void 0,tabIndex:C?0:void 0,role:C?"button":void 0,"aria-selected":l?f:void 0,children:[l&&t.jsx("td",{className:"bt-td bt-checkbox-cell",children:t.jsx("input",{type:"checkbox",className:"bt-checkbox",checked:f,onChange:P,onClick:j=>j.stopPropagation(),"aria-label":`Select row ${s+1}`})}),x.map(j=>t.jsx(Ue,{row:e,column:j,rowIndex:s},j.id)),g&&t.jsx(Xe,{row:e,rowIndex:s})]})}const Ze=d.memo(Ye);function et(){const{processedData:e,rowKey:s}=D(),n=(l,r)=>{if(typeof s=="function")return s(l,r);const a=l[s];return String(a!==void 0?a:r)};return t.jsx("tbody",{className:"bt-tbody",children:e.map((l,r)=>t.jsx(Ze,{row:l,rowIndex:r},n(l,r)))})}const tt=et;function st({row:e,rowIndex:s}){const{columns:n,selectable:l,rowActions:r,isSelected:a,toggleRow:i,hoverable:u,onRowClick:o,openModal:h}=D(),p=n.filter(c=>!c.hidden),x=r&&r.length>0,g=l&&a(e,s),f=p[0],C=p.slice(1),y=d.useCallback(()=>{i(e,s)},[e,s,i]),k=d.useCallback(()=>{o?.(e,s)},[e,s,o]),P=d.useCallback(c=>{c.key==="Enter"&&o&&k()},[k,o]),N=d.useCallback(c=>{if(c.mode==="callback"&&c.onClick)c.onClick(e,s);else if(c.mode==="modal"&&c.modalContent){const m=c.modalContent;h(t.jsx(m,{data:e,onClose:()=>{}}))}else if(c.mode==="link"&&c.href){const m=typeof c.href=="function"?c.href(e):c.href;window.open(m,"_blank")}},[e,s,h]),j=(c,m)=>{if(c.cell)return c.cell(m,e,s);if(m==null)return t.jsx("span",{className:"bt-card-value-empty",children:"—"});switch(c.type){case"boolean":return m?"✅":"❌";case"date":if(m instanceof Date)return m.toLocaleDateString();const v=new Date(String(m));return isNaN(v.getTime())?String(m):v.toLocaleDateString();case"number":return typeof m=="number"?m.toLocaleString():String(m);default:return String(m)}},b=f?M(e,String(f.accessor)):"";return t.jsxs("div",{className:S("bt-card",u&&"bt-hoverable",g&&"bt-selected",o&&"bt-clickable"),onClick:o?k:void 0,onKeyDown:o?P:void 0,tabIndex:o?0:void 0,role:o?"button":void 0,"aria-selected":l?g:void 0,children:[t.jsxs("div",{className:"bt-card-header",children:[l&&t.jsx("input",{type:"checkbox",className:"bt-checkbox",checked:g,onChange:y,onClick:c=>c.stopPropagation(),"aria-label":`Select row ${s+1}`}),t.jsx("span",{className:"bt-card-title",children:f?j(f,b):`Item ${s+1}`})]}),C.map(c=>{const m=M(e,String(c.accessor)),v=j(c,m);return t.jsxs("div",{className:"bt-card-row",children:[t.jsx("span",{className:"bt-card-label",children:c.header}),t.jsx("span",{className:"bt-card-value",children:v})]},c.id)}),x&&t.jsx("div",{className:"bt-card-actions",children:r.map(c=>{if(c.visible&&!c.visible(e))return null;const m=c.disabled?c.disabled(e):!1;if(c.mode==="link"&&c.href){const v=typeof c.href=="function"?c.href(e):c.href;return t.jsxs("a",{href:v,target:"_blank",rel:"noopener noreferrer",className:S("bt-action-btn",c.variant&&`bt-variant-${c.variant}`),onClick:T=>T.stopPropagation(),children:[c.icon&&t.jsx("span",{className:"bt-action-icon",children:c.icon}),t.jsx("span",{children:c.label})]},c.id)}return t.jsxs("button",{className:S("bt-action-btn",c.variant&&`bt-variant-${c.variant}`),onClick:v=>{v.stopPropagation(),N(c)},disabled:m,type:"button",children:[c.icon&&t.jsx("span",{className:"bt-action-icon",children:c.icon}),t.jsx("span",{children:c.label})]},c.id)})})]})}const at=d.memo(st);function lt(){const{processedData:e,rowKey:s}=D(),n=(l,r)=>{if(typeof s=="function")return s(l,r);const a=l[s];return String(a!==void 0?a:r)};return t.jsx("div",{className:"bt-cards",children:e.map((l,r)=>t.jsx(at,{row:l,rowIndex:r},n(l,r)))})}const nt=lt;function rt(){const{page:e,pageSize:s,totalPages:n,totalItems:l,goToPage:r,nextPage:a,prevPage:i,changePageSize:u,hasNextPage:o,hasPrevPage:h,startIndex:p,endIndex:x,paginationEnabled:g,pageSizeOptions:f,showSizeChanger:C,locale:y,classNames:k}=D(),P=d.useCallback(b=>{u(Number(b.target.value))},[u]),N=d.useCallback(b=>{if(b.key==="Enter"){const c=parseInt(b.target.value,10);!isNaN(c)&&c>=1&&c<=n&&r(c)}},[r,n]),j=d.useMemo(()=>{const b=[];if(n<=5)for(let m=1;m<=n;m++)b.push(m);else{b.push(1),e>3&&b.push("ellipsis");const m=Math.max(2,e-1),v=Math.min(n-1,e+1);for(let T=m;T<=v;T++)b.push(T);e<n-2&&b.push("ellipsis"),n>1&&b.push(n)}return b},[e,n]);return g?t.jsxs("div",{className:`bt-pagination ${k.pagination||""}`,children:[t.jsx("div",{className:"bt-pagination-info",children:l>0?`${p}-${x} ${y.of} ${l} ${y.items}`:`0 ${y.items}`}),t.jsxs("div",{className:"bt-pagination-controls",children:[C&&t.jsxs("div",{className:"bt-page-size",children:[t.jsxs("span",{className:"bt-page-size-label",children:[y.rowsPerPage,":"]}),t.jsx("select",{className:"bt-page-size-select",value:s,onChange:P,"aria-label":y.rowsPerPage,children:f.map(b=>t.jsx("option",{value:b,children:b},b))})]}),t.jsx("button",{className:"bt-pagination-btn",onClick:i,disabled:!h,"aria-label":"Previous page",type:"button",children:"←"}),t.jsx("div",{className:"bt-pagination-pages",children:j.map((b,c)=>b==="ellipsis"?t.jsx("span",{className:"bt-pagination-ellipsis",children:"..."},`ellipsis-${c}`):t.jsx("button",{className:`bt-pagination-btn ${e===b?"bt-active":""}`,onClick:()=>r(b),"aria-label":`${y.page} ${b}`,"aria-current":e===b?"page":void 0,type:"button",children:b},b))}),t.jsx("button",{className:"bt-pagination-btn",onClick:a,disabled:!o,"aria-label":"Next page",type:"button",children:"→"}),t.jsxs("div",{className:"bt-quick-jumper",children:[t.jsxs("span",{className:"bt-quick-jumper-label",children:[y.page,":"]}),t.jsx("input",{type:"number",className:"bt-quick-jumper-input",min:1,max:n,defaultValue:e,onKeyDown:N,"aria-label":"Jump to page"})]})]})]}):null}function it(){const{searchable:e,searchValue:s,handleSearch:n,clearSearch:l,globalActions:r,selectedRows:a,selectedCount:i,deselectAll:u,data:o,locale:h,classNames:p,selectable:x}=D(),g=d.useCallback(C=>{n(C.target.value)},[n]);return e||r&&r.length>0||x&&i>0?t.jsxs("div",{className:`bt-toolbar ${p.toolbar||""}`,children:[t.jsxs("div",{className:"bt-toolbar-left",children:[e&&t.jsxs("div",{className:"bt-search",children:[t.jsx("span",{className:"bt-search-icon",children:"🔍"}),t.jsx("input",{type:"text",className:"bt-search-input",placeholder:h.searchPlaceholder,value:s,onChange:g,"aria-label":h.search}),s&&t.jsx("button",{className:"bt-search-clear",onClick:l,"aria-label":"Clear search",type:"button",children:"✕"})]}),x&&i>0&&t.jsxs("div",{className:"bt-selection-info",children:[t.jsxs("span",{children:[i," ",h.selected]}),t.jsx("button",{className:"bt-selection-clear",onClick:u,type:"button",children:h.deselectAll})]})]}),r&&r.length>0&&t.jsx("div",{className:"bt-toolbar-right",children:t.jsx("div",{className:"bt-global-actions",children:r.map(C=>{const y=C.requiresSelection&&a.length===0;return t.jsxs("button",{className:S("bt-global-btn",C.variant&&`bt-variant-${C.variant}`),onClick:()=>C.onClick(a,o),disabled:y,title:C.label,type:"button",children:[C.icon&&t.jsx("span",{className:"bt-global-icon",children:C.icon}),t.jsx("span",{children:C.label})]},C.id)})})})]}):null}const ct=it;function ot(){const{locale:e,emptyComponent:s,columns:n,selectable:l,rowActions:r}=D(),a=n.filter(o=>!o.hidden),i=r&&r.length>0,u=a.length+(l?1:0)+(i?1:0);return s?t.jsx("tbody",{className:"bt-tbody",children:t.jsx("tr",{className:"bt-tr",children:t.jsx("td",{className:"bt-td",colSpan:u,children:s})})}):t.jsx("tbody",{className:"bt-tbody",children:t.jsx("tr",{className:"bt-tr",children:t.jsx("td",{className:"bt-td",colSpan:u,children:t.jsxs("div",{className:"bt-empty",children:[t.jsx("div",{className:"bt-empty-icon",children:"📭"}),t.jsx("div",{className:"bt-empty-text",children:e.noData})]})})})})}function dt({show:e}){const{loadingComponent:s,locale:n}=D();return e?t.jsx("div",{className:"bt-loading-overlay",role:"status","aria-live":"polite",children:s||t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bt-loading-spinner","aria-hidden":"true"}),t.jsx("span",{className:"bt-loading-text",children:n.loading})]})}):null}function bt(){const{isModalOpen:e,modalContent:s,closeModal:n}=D(),l=d.useCallback(a=>{a.target===a.currentTarget&&n()},[n]),r=d.useCallback(a=>{a.key==="Escape"&&n()},[n]);return d.useEffect(()=>(e&&(document.addEventListener("keydown",r),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",r),document.body.style.overflow=""}),[e,r]),!e||!s?null:t.jsx("div",{className:"bt-modal-backdrop",onClick:l,role:"dialog","aria-modal":"true",children:t.jsxs("div",{className:"bt-modal bt-modal-md",children:[t.jsxs("div",{className:"bt-modal-header",children:[t.jsx("h2",{className:"bt-modal-title",children:"Detalles"}),t.jsx("button",{className:"bt-modal-close",onClick:n,"aria-label":"Close modal",type:"button",children:"✕"})]}),t.jsx("div",{className:"bt-modal-body",children:s})]})})}function $e({data:e,initialSort:s,controlledSort:n,onSortChange:l}){const[r,a]=d.useState(s??{columnId:null,direction:"asc"}),i=n??r,u=d.useCallback(p=>{const x={columnId:p,direction:i.columnId===p&&i.direction==="asc"?"desc":"asc"};n||a(x),l?.(x)},[i,n,l]),o=d.useCallback(()=>{const p={columnId:null,direction:"asc"};n||a(p),l?.(p)},[n,l]);return{sortedData:d.useMemo(()=>i.columnId?Ae(e,i.columnId,i.direction):e,[e,i]),sortState:i,handleSort:u,clearSort:o}}function Re({data:e,columns:s,initialFilters:n,controlledFilters:l,onFilterChange:r}){const[a,i]=d.useState(n??{}),u=l??a,o=d.useCallback((g,f)=>{const C={...u};f==null||f===""?delete C[g]:C[g]=f,l||i(C),r?.(C)},[u,l,r]),h=d.useCallback(g=>{const f={...u};delete f[g],l||i(f),r?.(f)},[u,l,r]),p=d.useCallback(()=>{l||i({}),r?.({})},[l,r]);return{filteredData:d.useMemo(()=>Me(e,u,s),[e,u,s]),filters:u,setFilter:o,clearFilters:p,clearFilter:h}}function ze({data:e,config:s,onPageChange:n}){const l=s!==!1,r=s&&typeof s=="object"?s.page??1:1,a=s&&typeof s=="object"?s.pageSize??10:10,i=s&&typeof s=="object"?s.totalItems:void 0,[u,o]=d.useState(r),[h,p]=d.useState(a),x=i??e.length,g=Math.max(1,Math.ceil(x/h)),f=d.useCallback(b=>{const c=Math.max(1,Math.min(b,g));o(c),n?.(c,h)},[g,h,n]),C=d.useCallback(()=>{u<g&&f(u+1)},[u,g,f]),y=d.useCallback(()=>{u>1&&f(u-1)},[u,f]),k=d.useCallback(b=>{p(b),o(1),n?.(1,b)},[n]),P=d.useMemo(()=>{if(!l||i!==void 0)return e;const b=(u-1)*h;return e.slice(b,b+h)},[e,u,h,l,i]),N=(u-1)*h+1,j=Math.min(u*h,x);return{paginatedData:P,page:u,pageSize:h,totalPages:g,totalItems:x,goToPage:f,nextPage:C,prevPage:y,changePageSize:k,hasNextPage:u<g,hasPrevPage:u>1,startIndex:N,endIndex:j}}function Le({data:e,rowKey:s,mode:n="multiple",initialSelection:l,controlledSelection:r,onSelectionChange:a}){const[i,u]=d.useState(l??[]),o=r??i,h=d.useCallback((b,c)=>typeof s=="function"?s(b,c):String(b[s]),[s]),p=d.useMemo(()=>new Set(o.map((b,c)=>h(b,c))),[o,h]),x=d.useCallback((b,c)=>{const m=h(b,c);return p.has(m)},[h,p]),g=d.useCallback(b=>{r||u(b),a?.(b)},[r,a]),f=d.useCallback((b,c)=>{const m=h(b,c);let v;n==="single"?v=p.has(m)?[]:[b]:p.has(m)?v=o.filter((T,w)=>h(T,w)!==m):v=[...o,b],g(v)},[n,p,o,h,g]),C=d.useCallback((b,c)=>{if(!x(b,c)){const m=n==="single"?[b]:[...o,b];g(m)}},[x,n,o,g]),y=d.useCallback((b,c)=>{const m=h(b,c),v=o.filter((T,w)=>h(T,w)!==m);g(v)},[o,h,g]),k=d.useCallback(()=>{n==="multiple"&&g([...e])},[e,n,g]),P=d.useCallback(()=>{g([])},[g]),N=e.length>0&&o.length===e.length,j=o.length>0&&o.length<e.length;return{selectedRows:o,isSelected:x,toggleRow:f,selectRow:C,deselectRow:y,selectAll:k,deselectAll:P,isAllSelected:N,isPartiallySelected:j,selectedCount:o.length}}function Ie({data:e,columns:s,searchColumns:n,initialValue:l,controlledValue:r,onSearchChange:a}){const[i,u]=d.useState(l??""),o=r??i,h=d.useCallback(g=>{r===void 0&&u(g),a?.(g)},[r,a]),p=d.useCallback(()=>{r===void 0&&u(""),a?.("")},[r,a]);return{searchedData:d.useMemo(()=>we(e,o,s,n),[e,o,s,n]),searchValue:o,handleSearch:h,clearSearch:p}}function ut(e){const{data:s,columns:n,rowKey:l="id",rowActions:r,globalActions:a,pagination:i={pageSize:10},onPageChange:u,sort:o,onSortChange:h,filters:p,onFilterChange:x,searchable:g=!1,searchValue:f,onSearchChange:C,searchColumns:y,selectable:k,selectedRows:P,onSelectionChange:N,selectionMode:j="multiple",loading:b=!1,loadingComponent:c,emptyComponent:m,classNames:v={},styles:T={},locale:w,stickyHeader:E=!1,maxHeight:Be,bordered:$=!1,striped:R=!1,hoverable:z=!0,size:L="medium",onRowClick:F,onRowDoubleClick:K,ariaLabel:Ee,ariaDescribedBy:Fe}=e,O=d.useMemo(()=>k!==void 0?k:a?.some(qe=>qe.requiresSelection)||N!==void 0,[k,a,N]),V=d.useMemo(()=>({...Ne,...w}),[w]),[q,H]=d.useState(!1),[_,J]=d.useState(null),Q=d.useCallback(Se=>{J(Se),H(!0)},[]),G=d.useCallback(()=>{H(!1),J(null)},[]),A=d.useMemo(()=>i===!1?!1:{pageSize:10,pageSizeOptions:[10,20,50,100],showSizeChanger:!1,...i},[i]),{searchedData:Ke,searchValue:U,handleSearch:W,clearSearch:X}=Ie({data:s,columns:n,searchColumns:y,controlledValue:f,onSearchChange:C}),{filteredData:Oe,filters:Y,setFilter:Z,clearFilters:ee}=Re({data:Ke,columns:n,controlledFilters:p,onFilterChange:x}),{sortedData:te,sortState:se,handleSort:ae}=$e({data:Oe,controlledSort:o,onSortChange:h}),{selectedRows:le,isSelected:ne,toggleRow:re,selectAll:ie,deselectAll:ce,isAllSelected:oe,isPartiallySelected:de,selectedCount:be}=Le({data:te,rowKey:l,mode:j,controlledSelection:P,onSelectionChange:N}),{paginatedData:I,page:ue,pageSize:he,totalPages:fe,totalItems:pe,goToPage:ge,nextPage:me,prevPage:Ce,changePageSize:xe,hasNextPage:ve,hasPrevPage:ye,startIndex:je,endIndex:ke}=ze({data:te,config:A,onPageChange:u}),Ve=d.useMemo(()=>({data:s,processedData:I,columns:n,rowKey:l,rowActions:r,globalActions:a,sortState:se,handleSort:ae,filters:Y,setFilter:Z,clearFilters:ee,searchValue:U,handleSearch:W,clearSearch:X,searchable:g,selectedRows:le,isSelected:ne,toggleRow:re,selectAll:ie,deselectAll:ce,isAllSelected:oe,isPartiallySelected:de,selectable:O,selectionMode:j,selectedCount:be,page:ue,pageSize:he,totalPages:fe,totalItems:pe,goToPage:ge,nextPage:me,prevPage:Ce,changePageSize:xe,hasNextPage:ve,hasPrevPage:ye,startIndex:je,endIndex:ke,paginationEnabled:i!==!1,pageSizeOptions:A&&typeof A=="object"?A.pageSizeOptions??[10,20,50,100]:[10,20,50,100],showSizeChanger:A&&typeof A=="object"?A.showSizeChanger??!1:!1,loading:b,loadingComponent:c,emptyComponent:m,locale:V,classNames:v,size:L,bordered:$,striped:R,hoverable:z,stickyHeader:E,onRowClick:F,onRowDoubleClick:K,openModal:Q,closeModal:G,modalContent:_,isModalOpen:q}),[s,I,n,l,r,a,se,ae,Y,Z,ee,U,W,X,g,le,ne,re,ie,ce,oe,de,O,j,be,ue,he,fe,pe,ge,me,Ce,xe,ve,ye,je,ke,i,A,b,c,m,V,v,L,$,R,z,E,F,K,Q,G,_,q]),B=I.length>0;return t.jsx(Te,{value:Ve,children:t.jsxs("div",{className:S("bt-container",`bt-size-${L}`,R&&"bt-striped",$&&"bt-bordered",z&&"bt-hoverable",b&&"bt-container-loading",v.container),style:T.container,children:[t.jsx(ct,{}),t.jsxs("div",{className:"bt-table-wrapper",style:{maxHeight:Be},children:[t.jsxs("table",{className:S("bt-table",v.table),style:T.table,role:"grid","aria-label":Ee,"aria-describedby":Fe,"aria-busy":b,children:[t.jsx(Qe,{}),B?t.jsx(tt,{}):t.jsx(ot,{})]}),B&&t.jsx(nt,{}),t.jsx(dt,{show:b&&B})]}),i!==!1&&t.jsx(rt,{}),t.jsx(bt,{})]})})}const ht=ut;exports.BetterTable=ht;exports.TableProvider=Te;exports.defaultLocale=Ne;exports.filterData=Me;exports.getValueFromPath=M;exports.searchData=we;exports.sortData=Ae;exports.useTableContext=D;exports.useTableFilter=Re;exports.useTablePagination=ze;exports.useTableSearch=Ie;exports.useTableSelection=Le;exports.useTableSort=$e;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),t=require("react/jsx-runtime"),ps=require("react-dom");require("./styles.cjs");const vt=l.createContext(null);function E(){const e=l.useContext(vt);if(!e)throw new Error("useTableData must be used within a TableProvider");return e}const ms=vt.Provider,jt=l.createContext(null);function Ct(){const e=l.useContext(jt);if(!e)throw new Error("useTableSortContext must be used within a TableProvider");return e}const gs=jt.Provider,yt=l.createContext(null);function Q(){const e=l.useContext(yt);if(!e)throw new Error("useTableFilterContext must be used within a TableProvider");return e}const xs=yt.Provider,wt=l.createContext(null);function z(){const e=l.useContext(wt);if(!e)throw new Error("useTableSelectionContext must be used within a TableProvider");return e}const vs=wt.Provider,kt=l.createContext(null);function St(){const e=l.useContext(kt);if(!e)throw new Error("useTablePaginationContext must be used within a TableProvider");return e}const js=kt.Provider,Nt=l.createContext(null);function L(){const e=l.useContext(Nt);if(!e)throw new Error("useTableUI must be used within a TableProvider");return e}const Cs=Nt.Provider;function Tt({data:e,sort:s,filter:n,selection:a,pagination:o,ui:r,children:i}){return t.jsx(ms,{value:e,children:t.jsx(gs,{value:s,children:t.jsx(xs,{value:n,children:t.jsx(vs,{value:a,children:t.jsx(js,{value:o,children:t.jsx(Cs,{value:r,children:i})})})})})})}function Pt(e){var s,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(s=0;s<o;s++)e[s]&&(n=Pt(e[s]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function T(){for(var e,s,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(s=Pt(e))&&(a&&(a+=" "),a+=s);return a}function ys(){return t.jsxs("svg",{className:"bt-sort-icon",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M7 2.5L10 5.5H4L7 2.5Z",fill:"currentColor",opacity:"0.4"}),t.jsx("path",{d:"M7 11.5L4 8.5H10L7 11.5Z",fill:"currentColor",opacity:"0.4"})]})}function ws(){return t.jsxs("svg",{className:"bt-sort-icon",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M7 2.5L10 5.5H4L7 2.5Z",fill:"currentColor"}),t.jsx("path",{d:"M7 11.5L4 8.5H10L7 11.5Z",fill:"currentColor",opacity:"0.2"})]})}function ks(){return t.jsxs("svg",{className:"bt-sort-icon",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M7 2.5L10 5.5H4L7 2.5Z",fill:"currentColor",opacity:"0.2"}),t.jsx("path",{d:"M7 11.5L4 8.5H10L7 11.5Z",fill:"currentColor"})]})}function Ss({column:e}){const{sortState:s,handleSort:n,multiSortState:a,isMultiSort:o}=Ct(),{locale:r,resizable:i,startResize:u,getColumnWidth:d}=L(),c=e.resizable!==void 0?e.resizable:i,b=l.useCallback(C=>{C.preventDefault(),C.stopPropagation(),u(e.id,C.clientX)},[e.id,u]),h=s.columnId===e.id,f=o?a.findIndex(C=>C.columnId===e.id):-1,p=f>=0,v=p?a[f].direction:null,g=o&&a.length>1&&p,N=o?p:h,k=o?v:h?s.direction:null,y=l.useCallback(()=>{e.sortable!==!1&&n(e.id)},[e.id,e.sortable,n]),j=l.useCallback(C=>{C.key==="Enter"&&e.sortable!==!1&&n(e.id)},[e.id,e.sortable,n]),x=()=>{if(e.sortable===!1||e.type==="custom")return null;const C=N?k==="asc"?ws:ks:ys;return t.jsxs("button",{className:T("bt-sort-btn",N&&"bt-active"),onClick:y,"aria-label":k==="asc"?r.sortDesc:r.sortAsc,type:"button",children:[t.jsx(C,{}),g&&t.jsx("span",{className:"bt-sort-priority","aria-label":`${r.sortPriority} ${f+1}`,children:f+1})]})};if(e.headerCell){const C=d(e.id);return t.jsxs("th",{className:T("bt-th",e.align&&`bt-align-${e.align}`,c&&"bt-th-resizable"),style:{width:C??e.width},"data-column-id":e.id,children:[e.headerCell(e),c&&t.jsx("div",{className:"bt-resize-handle",onMouseDown:b,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.header}`})]})}return t.jsxs("th",{className:T("bt-th",e.align&&`bt-align-${e.align}`,N&&"bt-sorted",c&&"bt-th-resizable"),style:{width:d(e.id)??e.width},"data-column-id":e.id,role:"columnheader","aria-sort":N?k==="asc"?"ascending":"descending":void 0,tabIndex:e.sortable!==!1?0:void 0,onKeyDown:e.sortable!==!1?j:void 0,children:[t.jsx("div",{className:"bt-th-content",children:t.jsxs("div",{className:"bt-th-header",children:[t.jsx("span",{className:"bt-th-title",children:e.header}),x()]})}),c&&t.jsx("div",{className:"bt-resize-handle",onMouseDown:b,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.header}`})]})}const Ns=l.memo(Ss),pt=()=>t.jsx("svg",{className:"bt-ff-icon",width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M1.5 2h13L9.5 8.5V14l-3-1.5V8.5z"})});function Ts(){const{visibleColumns:e,rowActions:s,expandableEnabled:n}=E(),{filters:a,setFilter:o}=Q(),{selectable:r,selectionMode:i}=z(),{locale:u,stickyHeader:d}=L(),c=s&&s.length>0;return e.some(h=>h.filterable!==!1&&h.type!=="custom")?t.jsxs("tr",{className:T("bt-tr","bt-floating-filter-row",d&&"bt-sticky-filter"),children:[n&&t.jsx("th",{className:"bt-th bt-floating-filter-cell bt-expand-cell"}),r&&i==="multiple"&&t.jsx("th",{className:"bt-th bt-floating-filter-cell bt-checkbox-cell"}),r&&i==="single"&&t.jsx("th",{className:"bt-th bt-floating-filter-cell bt-checkbox-cell"}),e.map(h=>t.jsx("th",{className:T("bt-th","bt-floating-filter-cell",h.align&&`bt-align-${h.align}`),style:{width:h.width},children:h.filterable!==!1&&h.type!=="custom"?t.jsx(Ds,{column:h,value:a[h.id],setFilter:o,locale:u}):null},h.id)),c&&t.jsx("th",{className:"bt-th bt-floating-filter-cell bt-actions-cell"})]}):null}function Ps({column:e,value:s,setFilter:n,locale:a}){const o=l.useCallback(d=>{const c=d.target.value;e.type==="boolean"?c===""?n(e.id,null):n(e.id,c==="true"):n(e.id,c||null)},[e.id,e.type,n]),r=l.useCallback((d,c)=>{const h={...s??{},[d]:c||void 0};n(e.id,h)},[e.id,s,n]),i=`bt-ff-${e.id}`,u=l.useMemo(()=>{if(s==null)return!1;if(typeof s=="object"){const d=s;return!!(d.from||d.to)}return s!==""},[s]);if(e.type==="boolean")return t.jsxs("div",{className:T("bt-ff-wrapper",u&&"bt-ff-active"),children:[t.jsx(pt,{}),t.jsxs("select",{id:i,name:i,className:"bt-floating-filter-select",value:s==null?"":String(s),onChange:o,"aria-label":`${a.filterBy} ${e.header}`,children:[t.jsx("option",{value:"",children:"—"}),t.jsx("option",{value:"true",children:"✅"}),t.jsx("option",{value:"false",children:"❌"})]})]});if(e.type==="date"){const d=s??{};return t.jsxs("div",{className:T("bt-floating-filter-dates",u&&"bt-ff-active"),children:[t.jsx("input",{id:`${i}-from`,name:`${i}-from`,type:"date",className:"bt-floating-filter-input",value:d.from??"",onChange:c=>r("from",c.target.value),"aria-label":`${a.dateFrom} ${e.header}`,title:a.dateFrom}),t.jsx("span",{className:"bt-ff-date-sep",children:"–"}),t.jsx("input",{id:`${i}-to`,name:`${i}-to`,type:"date",className:"bt-floating-filter-input",value:d.to??"",onChange:c=>r("to",c.target.value),"aria-label":`${a.dateTo} ${e.header}`,title:a.dateTo})]})}return t.jsxs("div",{className:T("bt-ff-wrapper",u&&"bt-ff-active"),children:[t.jsx(pt,{}),t.jsx("input",{id:i,name:i,type:e.type==="number"?"number":"text",className:"bt-floating-filter-input",placeholder:"...",value:s!=null?String(s):"",onChange:o,"aria-label":`${a.filterBy} ${e.header}`})]})}const Ds=l.memo(Ps),Ms=l.memo(Ts);function Ls(){const{visibleColumns:e,rowActions:s,expandableEnabled:n}=E(),{selectable:a,selectionMode:o,isAllSelected:r,isPartiallySelected:i,selectAll:u,deselectAll:d}=z(),{locale:c,stickyHeader:b}=L(),{filterMode:h}=Q(),f=s&&s.length>0,p=h==="floating"||h==="both",v=()=>{r?d():u()};return t.jsxs("thead",{className:T("bt-thead",b&&"bt-sticky"),children:[t.jsxs("tr",{className:"bt-tr",children:[n&&t.jsx("th",{className:"bt-th bt-expand-cell","aria-label":"Expand"}),a&&t.jsx("th",{className:"bt-th bt-checkbox-cell",children:o==="multiple"&&t.jsx("input",{id:"bt-select-all",name:"bt-select-all",type:"checkbox",className:"bt-checkbox",checked:r,ref:g=>{g&&(g.indeterminate=i)},onChange:v,"aria-label":r?c.deselectAll:c.selectAll})}),e.map(g=>t.jsx(Ns,{column:g},g.id)),f&&t.jsx("th",{className:"bt-th bt-actions-cell",children:c.actions})]}),p&&t.jsx(Ms,{})]})}const As=Ls;function I(e,s){if(!e||!s)return;const n=s.split(".");let a=e;for(const o of n){if(a==null)return;if(typeof a=="object")a=a[o];else return}return a}function Dt(e,s,n){if(e==null)return n==="asc"?1:-1;if(s==null)return n==="asc"?-1:1;if(typeof e=="string"&&typeof s=="string"){const i=e.localeCompare(s,void 0,{sensitivity:"base",numeric:!0});return n==="asc"?i:-i}if(typeof e=="number"&&typeof s=="number")return n==="asc"?e-s:s-e;if(typeof e=="boolean"&&typeof s=="boolean"){const i=e===s?0:e?-1:1;return n==="asc"?i:-i}if(e instanceof Date&&s instanceof Date){const i=e.getTime()-s.getTime();return n==="asc"?i:-i}const a=String(e),o=String(s),r=a.localeCompare(o);return n==="asc"?r:-r}function Mt(e,s,n){return[...e].sort((a,o)=>{const r=I(a,s),i=I(o,s);return Dt(r,i,n)})}function Es(e,s){const n=s.filter(a=>a.columnId!==null);return n.length===0?e:[...e].sort((a,o)=>{for(const r of n){const i=I(a,r.columnId),u=I(o,r.columnId),d=Dt(i,u,r.direction);if(d!==0)return d}return 0})}function te(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){const s=new Date(e);return isNaN(s.getTime())?null:s}return null}function Lt(e,s,n){const a=Object.entries(s).filter(([,o])=>o!=null&&o!=="");return a.length===0?e:e.filter(o=>a.every(([r,i])=>{const u=n.find(b=>b.id===r);if(!u)return!0;const d=I(o,String(u.accessor));if(d==null)return!1;switch(u.type??"string"){case"boolean":return d===i;case"number":return String(d)===String(i);case"date":{const b=te(d);if(!b)return!1;if(i&&typeof i=="object"&&("from"in i||"to"in i)){const f=i;if(f.from){const p=te(f.from);if(p&&b<p)return!1}if(f.to){const p=te(f.to);if(p){const v=new Date(p);if(v.setHours(23,59,59,999),b>v)return!1}}return!0}const h=te(i);return h?b.toDateString()===h.toDateString():String(d).includes(String(i))}default:return String(d).toLowerCase().includes(String(i).toLowerCase())}}))}function At(e,s,n,a){if(!s.trim())return e;const o=s.toLowerCase().trim(),r=a?n.filter(i=>a.includes(i.id)||a.includes(String(i.accessor))):n.filter(i=>i.type!=="custom");return e.filter(i=>r.some(u=>{const d=I(i,String(u.accessor));return d==null?!1:String(d).toLowerCase().includes(o)}))}function Is({row:e,column:s,rowIndex:n}){const{resizable:a,getColumnWidth:o}=L(),r=I(e,String(s.accessor)),u=(()=>{if(s.cell)return s.cell(r,e,n);if(r==null)return t.jsx("span",{className:"bt-cell-empty",children:"—"});switch(s.type){case"boolean":return r?"✅":"❌";case"date":if(r instanceof Date)return r.toLocaleDateString();const c=new Date(String(r));return isNaN(c.getTime())?String(r):c.toLocaleDateString();case"number":return typeof r=="number"?r.toLocaleString():r;default:return String(r)}})(),d=a?o(s.id)??s.width:s.width;return t.jsx("td",{className:T("bt-td",s.align&&`bt-align-${s.align}`),style:{width:d},children:u})}const Rs=l.memo(Is),Fs="📦";function $s({actions:e,row:s,rowIndex:n,onActionClick:a,direction:o="down"}){const{locale:r}=L(),[i,u]=l.useState(!1),[d,c]=l.useState({top:0,left:0,openUp:!1}),b=l.useRef(null),h=l.useRef(null),f=l.useCallback(j=>{j.stopPropagation(),u(x=>{if(!x&&b.current){const C=b.current.getBoundingClientRect(),S=window.innerHeight-C.bottom,P=o==="up"||S<200;c({top:P?C.top:C.bottom,left:C.right,openUp:P})}return!x})},[o]);l.useEffect(()=>{if(!i)return;const j=x=>{const C=x.target;b.current&&!b.current.contains(C)&&h.current&&!h.current.contains(C)&&u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[i]),l.useEffect(()=>{if(!i)return;const j=x=>{x.key==="Escape"&&u(!1)};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[i]),l.useEffect(()=>{if(!i)return;const j=()=>u(!1);return window.addEventListener("scroll",j,!0),()=>window.removeEventListener("scroll",j,!0)},[i]);const p=e.filter(j=>j.variant!=="danger"),v=e.filter(j=>j.variant==="danger"),g=[...p,...v],N=p.length>0&&v.length>0,k=p.length,y=d.openUp?{position:"fixed",bottom:window.innerHeight-d.top,right:window.innerWidth-d.left}:{position:"fixed",top:d.top,right:window.innerWidth-d.left};return t.jsxs("div",{className:"bt-overflow-container",children:[t.jsx("button",{ref:b,className:"bt-action-btn bt-overflow-trigger",onClick:f,"aria-label":r.moreActions,"aria-expanded":i,"aria-haspopup":"menu",title:r.moreActions,type:"button",children:t.jsx("span",{className:"bt-overflow-icon",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("circle",{cx:"3",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"13",cy:"8",r:"1.5"})]})})}),i&&ps.createPortal(t.jsx("div",{ref:h,className:T("bt-overflow-menu",d.openUp&&"bt-overflow-menu-up"),style:y,role:"menu",children:g.map((j,x)=>{if(j.visible&&!j.visible(s))return null;const C=j.disabled?j.disabled(s):!1,S=j.icon??Fs,P=N&&x===k;return t.jsxs(l.Fragment,{children:[P&&t.jsx("div",{className:"bt-overflow-separator",role:"separator"}),j.mode==="link"&&j.href?t.jsxs("a",{href:typeof j.href=="function"?j.href(s):j.href,target:"_blank",rel:"noopener noreferrer",className:T("bt-overflow-item",j.variant==="danger"&&"bt-overflow-item-danger"),role:"menuitem",onClick:m=>{m.stopPropagation(),u(!1)},children:[t.jsx("span",{className:"bt-overflow-item-icon",children:S}),t.jsx("span",{className:"bt-overflow-item-label",children:j.label})]}):t.jsxs("button",{className:T("bt-overflow-item",j.variant==="danger"&&"bt-overflow-item-danger"),role:"menuitem",disabled:C,onClick:m=>{m.stopPropagation(),a(j),u(!1)},type:"button",children:[t.jsx("span",{className:"bt-overflow-item-icon",children:S}),t.jsx("span",{className:"bt-overflow-item-label",children:j.label})]})]},j.id)})}),document.body)]})}const Et=l.memo($s),zs="📦";function Os({row:e,rowIndex:s}){const{rowActions:n,maxVisibleActions:a}=E(),{openModal:o,closeModal:r}=L(),i=l.useCallback(c=>{if(c.mode==="callback"&&c.onClick)c.onClick(e,s);else if(c.mode==="modal"&&c.modalContent){const b=c.modalContent;o(t.jsx(b,{data:e,onClose:r}))}else if(c.mode==="link"&&c.href){const b=typeof c.href=="function"?c.href(e):c.href;window.open(b,"_blank")}},[e,s,o,r]),{inlineActions:u,overflowActions:d}=l.useMemo(()=>{if(!n)return{inlineActions:[],overflowActions:[]};const c=n.filter(h=>!h.visible||h.visible(e));if(c.length<=a)return{inlineActions:c,overflowActions:[]};const b=a-1;return{inlineActions:c.slice(0,b),overflowActions:c.slice(b)}},[n,a,e]);return!n||n.length===0?null:t.jsx("td",{className:"bt-td bt-actions-cell",children:t.jsxs("div",{className:"bt-actions-wrapper",children:[u.map(c=>{const b=c.disabled?c.disabled(e):!1,h=c.icon??zs;if(c.mode==="link"&&c.href){const f=typeof c.href=="function"?c.href(e):c.href;return t.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:T("bt-action-btn bt-action-icon-only",c.variant&&`bt-variant-${c.variant}`),"aria-label":c.label,title:c.label,children:t.jsx("span",{className:"bt-action-icon",children:h})},c.id)}return t.jsx("button",{className:T("bt-action-btn bt-action-icon-only",c.variant&&`bt-variant-${c.variant}`),onClick:()=>i(c),disabled:b,"aria-label":c.label,title:c.label,type:"button",children:t.jsx("span",{className:"bt-action-icon",children:h})},c.id)}),d.length>0&&t.jsx(Et,{actions:d,row:e,rowIndex:s,onActionClick:i,direction:"down"})]})})}const Bs=l.memo(Os);function Ws({row:e,rowIndex:s,rowKey:n}){const{visibleColumns:a,rowActions:o,expandableEnabled:r,isExpanded:i,toggleExpand:u}=E(),{selectable:d,isSelected:c,toggleRow:b}=z(),{striped:h,hoverable:f,onRowClick:p,onRowDoubleClick:v,locale:g}=L(),N=o&&o.length>0,k=d&&c(e,s),y=!!p,j=r&&i(n),x=l.useCallback(()=>{p?.(e,s)},[e,s,p]),C=l.useCallback(()=>{v?.(e,s)},[e,s,v]),S=l.useCallback(()=>{b(e,s)},[e,s,b]),P=l.useCallback(()=>{u(n)},[n,u]),m=l.useCallback(w=>{w.key==="Enter"&&p&&x()},[x,p]);return t.jsxs("tr",{className:T("bt-tr",h&&"bt-striped",f&&"bt-hoverable",k&&"bt-selected",y&&"bt-clickable",j&&"bt-expanded"),onClick:y?x:void 0,onDoubleClick:v?C:void 0,onKeyDown:y?m:void 0,tabIndex:y?0:void 0,role:y?"button":void 0,"aria-selected":d?k:void 0,"aria-expanded":r?j:void 0,children:[r&&t.jsx("td",{className:"bt-td bt-expand-cell",children:t.jsx("button",{type:"button",className:T("bt-expand-button",j&&"bt-expand-button-expanded"),onClick:w=>{w.stopPropagation(),P()},"aria-label":j?g.collapseRow:g.expandRow,"aria-expanded":j,children:t.jsx("svg",{className:"bt-expand-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t.jsx("path",{d:"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),d&&t.jsx("td",{className:"bt-td bt-checkbox-cell",children:t.jsx("input",{id:`bt-row-select-${s}`,name:`bt-row-select-${s}`,type:"checkbox",className:"bt-checkbox",checked:k,onChange:S,onClick:w=>w.stopPropagation(),"aria-label":`Select row ${s+1}`})}),a.map(w=>t.jsx(Rs,{row:e,column:w,rowIndex:s},w.id)),N&&t.jsx(Bs,{row:e,rowIndex:s})]})}const It=l.memo(Ws);function Hs({row:e,rowIndex:s}){const{visibleColumns:n,rowActions:a,expandableRender:o}=E(),{selectable:r}=z();if(!o)return null;const i=a&&a.length>0,u=1+(r?1:0)+n.length+(i?1:0);return t.jsx("tr",{className:"bt-tr bt-expanded-row",role:"row",children:t.jsx("td",{className:"bt-td bt-expanded-content",colSpan:u,children:o(e,s)})})}const Vs=Hs;function Us(){const{processedData:e,rowKey:s,expandableEnabled:n,isExpanded:a}=E(),o=(r,i)=>{if(typeof s=="function")return s(r,i);const u=r[s];return String(u!==void 0?u:i)};return t.jsx("tbody",{className:"bt-tbody",children:e.map((r,i)=>{const u=o(r,i),d=n&&a(u);return t.jsxs(l.Fragment,{children:[t.jsx(It,{row:r,rowIndex:i,rowKey:u}),d&&t.jsx(Vs,{row:r,rowIndex:i})]},u)})})}const _s=Us,qs="📦";function Ks({row:e,rowIndex:s}){const{visibleColumns:n,rowActions:a,maxVisibleActions:o}=E(),{selectable:r,isSelected:i,toggleRow:u}=z(),{hoverable:d,onRowClick:c,openModal:b,closeModal:h}=L(),f=a&&a.length>0,p=r&&i(e,s),v=n[0],g=n.slice(1),{inlineActions:N,overflowActions:k}=l.useMemo(()=>{if(!a)return{inlineActions:[],overflowActions:[]};const m=a.filter(A=>!A.visible||A.visible(e));if(m.length<=o)return{inlineActions:m,overflowActions:[]};const w=o-1;return{inlineActions:m.slice(0,w),overflowActions:m.slice(w)}},[a,o,e]),y=l.useCallback(()=>{u(e,s)},[e,s,u]),j=l.useCallback(()=>{c?.(e,s)},[e,s,c]),x=l.useCallback(m=>{m.key==="Enter"&&c&&j()},[j,c]),C=l.useCallback(m=>{if(m.mode==="callback"&&m.onClick)m.onClick(e,s);else if(m.mode==="modal"&&m.modalContent){const w=m.modalContent;b(t.jsx(w,{data:e,onClose:h}))}else if(m.mode==="link"&&m.href){const w=typeof m.href=="function"?m.href(e):m.href;window.open(w,"_blank")}},[e,s,b,h]),S=(m,w)=>{if(m.cell)return m.cell(w,e,s);if(w==null)return t.jsx("span",{className:"bt-card-value-empty",children:"—"});switch(m.type){case"boolean":return w?"✅":"❌";case"date":if(w instanceof Date)return w.toLocaleDateString();const A=new Date(String(w));return isNaN(A.getTime())?String(w):A.toLocaleDateString();case"number":return typeof w=="number"?w.toLocaleString():String(w);default:return String(w)}},P=v?I(e,String(v.accessor)):"";return t.jsxs("div",{className:T("bt-card",d&&"bt-hoverable",p&&"bt-selected",c&&"bt-clickable"),onClick:c?j:void 0,onKeyDown:c?x:void 0,tabIndex:c?0:void 0,role:c?"button":void 0,"aria-selected":r?p:void 0,children:[t.jsxs("div",{className:"bt-card-header",children:[r&&t.jsx("input",{id:`bt-card-select-${s}`,name:`bt-card-select-${s}`,type:"checkbox",className:"bt-checkbox",checked:p,onChange:y,onClick:m=>m.stopPropagation(),"aria-label":`Select row ${s+1}`}),t.jsx("span",{className:"bt-card-title",children:v?S(v,P):`Item ${s+1}`})]}),g.map(m=>{const w=I(e,String(m.accessor)),A=S(m,w);return t.jsxs("div",{className:"bt-card-row",children:[t.jsx("span",{className:"bt-card-label",children:m.header}),t.jsx("span",{className:"bt-card-value",children:A})]},m.id)}),f&&t.jsxs("div",{className:"bt-card-actions",children:[N.map(m=>{const w=m.disabled?m.disabled(e):!1,A=m.icon??qs;if(m.mode==="link"&&m.href){const R=typeof m.href=="function"?m.href(e):m.href;return t.jsx("a",{href:R,target:"_blank",rel:"noopener noreferrer",className:T("bt-action-btn bt-action-icon-only",m.variant&&`bt-variant-${m.variant}`),"aria-label":m.label,title:m.label,onClick:O=>O.stopPropagation(),children:t.jsx("span",{className:"bt-action-icon",children:A})},m.id)}return t.jsx("button",{className:T("bt-action-btn bt-action-icon-only",m.variant&&`bt-variant-${m.variant}`),onClick:R=>{R.stopPropagation(),C(m)},disabled:w,"aria-label":m.label,title:m.label,type:"button",children:t.jsx("span",{className:"bt-action-icon",children:A})},m.id)}),k.length>0&&t.jsx(Et,{actions:k,row:e,rowIndex:s,onActionClick:C,direction:"up"})]})]})}const Zs=l.memo(Ks);function Qs(){const{processedData:e,rowKey:s}=E(),n=(a,o)=>{if(typeof s=="function")return s(a,o);const r=a[s];return String(r!==void 0?r:o)};return t.jsx("div",{className:"bt-cards",children:e.map((a,o)=>t.jsx(Zs,{row:a,rowIndex:o},n(a,o)))})}const Xs=Qs;function mt(){return t.jsx("svg",{className:"bt-fp-icon",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M1.5 2H10.5L7 5.87V9.5L5 8.5V5.87L1.5 2Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function Gs({open:e}){const{columns:s,locale:n}=L(),{filters:a,setFilter:o,clearFilter:r,clearFilters:i}=Q(),u=s.filter(c=>c.filterable!==!1&&c.type!=="custom"&&!c.hidden);if(!e||u.length===0)return null;const d=Object.keys(a).length;return t.jsxs("div",{className:"bt-filter-panel",role:"region","aria-label":n.filterBy,children:[t.jsx("div",{className:"bt-filter-panel-grid",children:u.map(c=>t.jsx(Ys,{column:c,value:a[c.id],setFilter:o,clearFilter:r,locale:n},c.id))}),d>0&&t.jsx("div",{className:"bt-filter-panel-footer",children:t.jsx("button",{className:"bt-filter-panel-clear",onClick:i,type:"button",children:n.clearFilters})})]})}function Js({column:e,value:s,setFilter:n,locale:a}){const o=l.useCallback(b=>{const h=b.target.value;e.type==="boolean"?h===""?n(e.id,null):n(e.id,h==="true"):n(e.id,h||null)},[e.id,e.type,n]),r=l.useCallback((b,h)=>{const p={...s??{},[b]:h||void 0};n(e.id,p)},[e.id,s,n]),i=s!=null&&s!=="",u=i&&typeof s=="object"&&("from"in s||"to"in s)&&!!(s.from||s.to),d=e.type==="date"?u:i,c=()=>{const b=`bt-filter-${e.id}`;if(e.type==="boolean")return t.jsxs("div",{className:T("bt-fp-wrapper",d&&"bt-fp-active"),children:[t.jsx(mt,{}),t.jsxs("select",{id:b,name:b,className:"bt-filter-select",value:s==null?"":String(s),onChange:o,"aria-label":`${a.filterBy} ${e.header}`,children:[t.jsx("option",{value:"",children:"—"}),t.jsx("option",{value:"true",children:"✅"}),t.jsx("option",{value:"false",children:"❌"})]})]});if(e.type==="date"){const h=s??{};return t.jsxs("div",{className:T("bt-fp-wrapper bt-filter-field-dates",d&&"bt-fp-active"),children:[t.jsx("input",{id:`${b}-from`,name:`${b}-from`,type:"date",className:"bt-filter-input",value:h.from??"",onChange:f=>r("from",f.target.value),"aria-label":`${a.dateFrom} ${e.header}`,placeholder:a.dateFrom}),t.jsx("span",{className:"bt-filter-field-separator",children:"–"}),t.jsx("input",{id:`${b}-to`,name:`${b}-to`,type:"date",className:"bt-filter-input",value:h.to??"",onChange:f=>r("to",f.target.value),"aria-label":`${a.dateTo} ${e.header}`,placeholder:a.dateTo})]})}return t.jsxs("div",{className:T("bt-fp-wrapper",d&&"bt-fp-active"),children:[t.jsx(mt,{}),t.jsx("input",{id:b,name:b,type:e.type==="number"?"number":"text",className:"bt-filter-input",placeholder:"...",value:s!=null?String(s):"",onChange:o,"aria-label":`${a.filterBy} ${e.header}`})]})};return t.jsxs("div",{className:T("bt-filter-field",d&&"bt-filter-field-active"),children:[t.jsx("label",{className:"bt-filter-field-label",htmlFor:`bt-filter-${e.id}`,children:e.header}),c()]})}const Ys=l.memo(Js),en=l.memo(Gs);function tn(){return t.jsxs("svg",{className:"bt-columns-svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"1.5",y:"2",width:"4",height:"10",rx:"1",stroke:"currentColor",strokeWidth:"1.3"}),t.jsx("rect",{x:"8.5",y:"2",width:"4",height:"10",rx:"1",stroke:"currentColor",strokeWidth:"1.3"})]})}function sn(){return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 6L5 8.5L9.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function nn(){const{columns:e,hiddenColumnIds:s,toggleColumn:n,showAllColumns:a,isColumnVisible:o,locale:r,columnVisibilityEnabled:i}=L(),[u,d]=l.useState(!1),c=l.useRef(null),b=l.useRef(null),h=s.size;l.useEffect(()=>{if(!u)return;const v=N=>{c.current&&!c.current.contains(N.target)&&d(!1)},g=N=>{N.key==="Escape"&&(d(!1),b.current?.focus())};return document.addEventListener("mousedown",v),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",g)}},[u]);const f=l.useCallback(()=>{d(v=>!v)},[]);if(!i)return null;const p=e.filter(v=>v.type!=="custom");return t.jsxs("div",{className:"bt-column-visibility",ref:c,children:[t.jsxs("button",{ref:b,className:T("bt-column-visibility-btn",u&&"bt-column-visibility-btn-active"),onClick:f,"aria-expanded":u,"aria-haspopup":"true","aria-label":r.columns,title:r.columns,type:"button",children:[t.jsx(tn,{}),t.jsx("span",{className:"bt-column-visibility-label",children:r.columns}),h>0&&t.jsx("span",{className:"bt-column-visibility-badge",children:h})]}),u&&t.jsxs("div",{className:"bt-column-visibility-dropdown",role:"menu",children:[t.jsxs("div",{className:"bt-column-visibility-header",children:[t.jsx("span",{className:"bt-column-visibility-title",children:r.columns}),h>0&&t.jsx("button",{className:"bt-column-visibility-show-all",onClick:a,type:"button",children:r.showAllColumns})]}),t.jsx("div",{className:"bt-column-visibility-list",children:p.map(v=>{const g=o(v.id);return t.jsxs("button",{className:T("bt-column-visibility-item",!g&&"bt-column-visibility-item-hidden"),onClick:()=>n(v.id),role:"menuitemcheckbox","aria-checked":g,type:"button",children:[t.jsx("span",{className:T("bt-column-visibility-check",g&&"bt-column-visibility-check-active"),children:g&&t.jsx(sn,{})}),t.jsx("span",{className:"bt-column-visibility-item-label",children:v.header})]},v.id)})})]})]})}const an=nn;function ln(){return t.jsx("svg",{className:"bt-pagination-svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M9 3L5 7L9 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function rn(){return t.jsx("svg",{className:"bt-pagination-svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M5 3L9 7L5 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function on(){const{page:e,pageSize:s,totalPages:n,totalItems:a,goToPage:o,nextPage:r,prevPage:i,changePageSize:u,hasNextPage:d,hasPrevPage:c,startIndex:b,endIndex:h,paginationEnabled:f,pageSizeOptions:p,showSizeChanger:v}=St(),{locale:g,classNames:N}=L(),k=l.useCallback(x=>{u(Number(x.target.value))},[u]),y=l.useCallback(x=>{if(x.key==="Enter"){const C=parseInt(x.target.value,10);!isNaN(C)&&C>=1&&C<=n&&o(C)}},[o,n]),j=l.useMemo(()=>{const x=[];if(n<=5)for(let S=1;S<=n;S++)x.push(S);else{x.push(1),e>3&&x.push("ellipsis");const S=Math.max(2,e-1),P=Math.min(n-1,e+1);for(let m=S;m<=P;m++)x.push(m);e<n-2&&x.push("ellipsis"),n>1&&x.push(n)}return x},[e,n]);return f?t.jsxs("div",{className:`bt-pagination ${N.pagination||""}`,children:[t.jsx("div",{className:"bt-pagination-info",children:a>0?`${b}-${h} ${g.of} ${a} ${g.items}`:`0 ${g.items}`}),t.jsxs("div",{className:"bt-pagination-controls",children:[v&&t.jsxs("div",{className:"bt-page-size",children:[t.jsxs("label",{className:"bt-page-size-label",htmlFor:"bt-page-size",children:[g.rowsPerPage,":"]}),t.jsx("select",{id:"bt-page-size",name:"bt-page-size",className:"bt-page-size-select",value:s,onChange:k,"aria-label":g.rowsPerPage,children:p.map(x=>t.jsx("option",{value:x,children:x},x))})]}),t.jsx("button",{className:"bt-pagination-btn",onClick:i,disabled:!c,"aria-label":g.previousPage,type:"button",children:t.jsx(ln,{})}),t.jsx("div",{className:"bt-pagination-pages",children:j.map((x,C)=>x==="ellipsis"?t.jsx("span",{className:"bt-pagination-ellipsis",children:"..."},`ellipsis-${C}`):t.jsx("button",{className:`bt-pagination-btn ${e===x?"bt-active":""}`,onClick:()=>o(x),"aria-label":`${g.page} ${x}`,"aria-current":e===x?"page":void 0,type:"button",children:x},x))}),t.jsx("button",{className:"bt-pagination-btn",onClick:r,disabled:!d,"aria-label":g.nextPage,type:"button",children:t.jsx(rn,{})}),t.jsxs("div",{className:"bt-quick-jumper",children:[t.jsxs("label",{className:"bt-quick-jumper-label",htmlFor:"bt-quick-jumper",children:[g.page,":"]}),t.jsxs("div",{className:"bt-qj-wrapper",children:[t.jsx("input",{id:"bt-quick-jumper",name:"bt-quick-jumper",type:"number",className:"bt-quick-jumper-input",min:1,max:n,defaultValue:e,onKeyDown:y,"aria-label":g.jumpToPage},e),t.jsx("span",{className:"bt-qj-hint","aria-hidden":"true",children:"↵"})]})]})]})]}):null}function Rt(e){const[s,n]=l.useState(()=>typeof window>"u"?!1:window.matchMedia(e).matches);return l.useEffect(()=>{if(typeof window>"u")return;const a=window.matchMedia(e);n(a.matches);const o=r=>n(r.matches);return a.addEventListener("change",o),()=>a.removeEventListener("change",o)},[e]),s}function gt(){return t.jsxs("svg",{className:"bt-search-svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M9.5 9.5L13 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function xt(){return t.jsx("svg",{className:"bt-clear-svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M3 3L9 9M9 3L3 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function cn(){return t.jsx("svg",{className:"bt-check-svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 6L5 8.5L9.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function dn(){return t.jsx("svg",{className:"bt-filter-toggle-svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M1 2.5H11L7.5 6.5V10L4.5 9V6.5L1 2.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function un(){const{searchable:e,searchValue:s,handleSearch:n,clearSearch:a,filters:o,filterPanelOpen:r,toggleFilterPanel:i,hasFilterableColumns:u,filterMode:d}=Q(),{selectable:c,selectedRows:b,selectedCount:h,deselectAll:f}=z(),{data:p,globalActions:v}=E(),{locale:g,classNames:N,columnVisibilityEnabled:k}=L(),y=Rt("(max-width: 640px)"),[j,x]=l.useState(!1),C=l.useRef(null),S=Object.keys(o).length,P=l.useCallback(M=>{n(M.target.value)},[n]),m=l.useCallback(()=>{x(M=>(M?s&&a():setTimeout(()=>C.current?.focus(),50),!M))},[s,a]);l.useEffect(()=>{s&&!j&&x(!0)},[s,j]);const w=u&&(d==="panel"||d==="both");if(!(e||w||k||v&&v.length>0||c&&h>0))return null;const R=y&&e&&!j,O=e&&(!y||j);return t.jsxs("div",{className:T("bt-toolbar",N.toolbar),children:[t.jsxs("div",{className:"bt-toolbar-left",children:[R&&t.jsx("button",{className:"bt-search-toggle",onClick:m,"aria-label":g.search,title:g.search,type:"button",children:t.jsx(gt,{})}),O&&t.jsxs("div",{className:T("bt-search",y&&"bt-search-mobile"),children:[t.jsx("span",{className:"bt-search-icon",children:t.jsx(gt,{})}),t.jsx("input",{id:"bt-search",name:"bt-search",ref:C,type:"text",className:"bt-search-input",placeholder:g.searchPlaceholder,value:s,onChange:P,"aria-label":g.search}),(s||y)&&t.jsx("button",{className:"bt-search-clear",onClick:y?m:a,"aria-label":g.clearSearch,type:"button",children:t.jsx(xt,{})})]}),w&&t.jsxs("button",{className:T("bt-filter-toggle",r&&"bt-filter-toggle-active"),onClick:i,"aria-expanded":r,"aria-label":g.filterBy,title:g.filterBy,type:"button",children:[t.jsx("span",{className:"bt-filter-toggle-icon",children:t.jsx(dn,{})}),!y&&t.jsx("span",{children:g.filterBy}),S>0&&t.jsx("span",{className:"bt-filter-toggle-badge",children:S})]}),t.jsx(an,{}),c&&h>0&&t.jsxs("div",{className:"bt-selection-info",children:[t.jsx(cn,{}),t.jsxs("span",{className:"bt-selection-count",children:[h," ",y?"sel.":g.selected]}),t.jsx("button",{className:"bt-selection-clear",onClick:f,type:"button",children:y?t.jsx(xt,{}):g.deselectAll})]})]}),v&&v.length>0&&t.jsx("div",{className:"bt-toolbar-right",children:t.jsx("div",{className:"bt-global-actions",children:v.map(M=>{const se=M.requiresSelection&&b.length===0;return t.jsxs("button",{className:T("bt-global-btn",M.variant&&`bt-variant-${M.variant}`,y&&"bt-global-btn-mobile"),onClick:()=>M.onClick(b,p),disabled:se,title:M.label,"aria-label":M.label,type:"button",children:[M.icon&&t.jsx("span",{className:"bt-global-icon",children:M.icon}),!y&&t.jsx("span",{children:M.label})]},M.id)})})})]})}const bn=un;function hn(){return t.jsxs("svg",{className:"bt-empty-svg",width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"12",y:"18",width:"40",height:"32",rx:"3",stroke:"currentColor",strokeWidth:"2",opacity:"0.3"}),t.jsx("path",{d:"M12 28H52",stroke:"currentColor",strokeWidth:"2",opacity:"0.2"}),t.jsx("path",{d:"M24 38H40",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",opacity:"0.4"}),t.jsx("path",{d:"M28 44H36",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",opacity:"0.25"}),t.jsx("circle",{cx:"32",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"2",opacity:"0.2"})]})}function fn(){const{locale:e,emptyComponent:s}=L(),{visibleColumns:n,rowActions:a}=E(),{selectable:o}=z(),r=a&&a.length>0,i=n.length+(o?1:0)+(r?1:0);return s?t.jsx("tbody",{className:"bt-tbody",children:t.jsx("tr",{className:"bt-tr",children:t.jsx("td",{className:"bt-td",colSpan:i,children:s})})}):t.jsx("tbody",{className:"bt-tbody",children:t.jsx("tr",{className:"bt-tr",children:t.jsx("td",{className:"bt-td",colSpan:i,children:t.jsxs("div",{className:"bt-empty",children:[t.jsx("div",{className:"bt-empty-icon",children:t.jsx(hn,{})}),t.jsx("div",{className:"bt-empty-text",children:e.noData})]})})})})}function pn({show:e}){const{loadingComponent:s,locale:n}=L();return e?t.jsx("div",{className:"bt-loading-overlay",role:"status","aria-live":"polite",children:s||t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bt-loading-spinner","aria-hidden":"true"}),t.jsx("span",{className:"bt-loading-text",children:n.loading})]})}):null}const mn=['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"]):not([disabled])'].join(", ");function gn(e,s){const n=l.useRef(null),a=l.useCallback(()=>e.current?Array.from(e.current.querySelectorAll(mn)):[],[e]);l.useEffect(()=>{if(!s)return;n.current=document.activeElement;const r=setTimeout(()=>{const i=a();i.length>0&&i[0].focus()},0);return()=>{clearTimeout(r),n.current&&typeof n.current.focus=="function"&&n.current.focus()}},[s,a]),l.useEffect(()=>{if(!s)return;const o=r=>{if(r.key!=="Tab")return;const i=a();if(i.length===0)return;const u=i[0],d=i[i.length-1];r.shiftKey?document.activeElement===u&&(r.preventDefault(),d.focus()):document.activeElement===d&&(r.preventDefault(),u.focus())};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[s,a])}function xn(){return t.jsx("svg",{className:"bt-modal-close-svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function vn(){const{isModalOpen:e,modalContent:s,closeModal:n,locale:a}=L(),o=l.useRef(null);gn(o,e);const r=l.useCallback(u=>{u.target===u.currentTarget&&n()},[n]),i=l.useCallback(u=>{u.key==="Escape"&&n()},[n]);return l.useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}),[e,i]),!e||!s?null:t.jsx("div",{className:"bt-modal-backdrop",onClick:r,role:"dialog","aria-modal":"true",children:t.jsxs("div",{className:"bt-modal bt-modal-md",ref:o,children:[t.jsxs("div",{className:"bt-modal-header",children:[t.jsx("h2",{className:"bt-modal-title",children:a.details}),t.jsx("button",{className:"bt-modal-close",onClick:n,"aria-label":a.closeModal,type:"button",children:t.jsx(xn,{})})]}),t.jsx("div",{className:"bt-modal-body",children:s})]})})}function jn({startIndex:e,endIndex:s,totalHeight:n,offsetTop:a}){const{processedData:o,rowKey:r}=E(),i=(c,b)=>{if(typeof r=="function")return r(c,b);const h=c[r];return String(h!==void 0?h:b)},u=o.slice(e,s),d=n-a-u.length*(n/o.length);return t.jsxs("tbody",{className:"bt-tbody",children:[a>0&&t.jsx("tr",{"aria-hidden":"true",children:t.jsx("td",{style:{height:a,padding:0,border:"none"}})}),u.map((c,b)=>{const h=e+b;return t.jsx(It,{row:c,rowIndex:h,rowKey:i(c,h)},i(c,h))}),d>0&&t.jsx("tr",{"aria-hidden":"true",children:t.jsx("td",{style:{height:d,padding:0,border:"none"}})})]})}const Cn=jn,he={search:"Search",searchPlaceholder:"Search...",noData:"No data",loading:"Loading...",page:"Page",of:"of",items:"items",selected:"selected",rowsPerPage:"Rows per page",actions:"Actions",sortAsc:"Sort ascending",sortDesc:"Sort descending",filterBy:"Filter by",clearFilters:"Clear filters",dateFrom:"From",dateTo:"To",selectAll:"Select all",deselectAll:"Deselect all",moreActions:"More actions",clearSearch:"Clear search",closeModal:"Close",previousPage:"Previous page",nextPage:"Next page",jumpToPage:"Go to page",details:"Details",columns:"Columns",showAllColumns:"Show all",hideColumn:"Hide column",sortPriority:"Sort priority",clearSort:"Clear sort",resultsFound:"{count} results found",noResultsFound:"No results found",rowsSelected:"{count} rows selected",expandRow:"Expand row",collapseRow:"Collapse row"},Ft={en:he,es:{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",dateFrom:"Desde",dateTo:"Hasta",selectAll:"Seleccionar todo",deselectAll:"Deseleccionar todo",moreActions:"Más acciones",clearSearch:"Limpiar búsqueda",closeModal:"Cerrar",previousPage:"Página anterior",nextPage:"Página siguiente",jumpToPage:"Ir a página",details:"Detalles",columns:"Columnas",showAllColumns:"Mostrar todas",hideColumn:"Ocultar columna",sortPriority:"Prioridad de orden",clearSort:"Quitar orden",resultsFound:"{count} resultados encontrados",noResultsFound:"No se encontraron resultados",rowsSelected:"{count} filas seleccionadas",expandRow:"Expandir fila",collapseRow:"Colapsar fila"},pt:{search:"Pesquisar",searchPlaceholder:"Pesquisar...",noData:"Sem dados",loading:"Carregando...",page:"Página",of:"de",items:"itens",selected:"selecionados",rowsPerPage:"Linhas por página",actions:"Ações",sortAsc:"Ordenar ascendente",sortDesc:"Ordenar descendente",filterBy:"Filtrar por",clearFilters:"Limpar filtros",dateFrom:"De",dateTo:"Até",selectAll:"Selecionar tudo",deselectAll:"Desselecionar tudo",moreActions:"Mais ações",clearSearch:"Limpar pesquisa",closeModal:"Fechar",previousPage:"Página anterior",nextPage:"Próxima página",jumpToPage:"Ir para página",details:"Detalhes",columns:"Colunas",showAllColumns:"Mostrar todas",hideColumn:"Ocultar coluna",sortPriority:"Prioridade de ordem",clearSort:"Remover ordem",resultsFound:"{count} resultados encontrados",noResultsFound:"Nenhum resultado encontrado",rowsSelected:"{count} linhas selecionadas",expandRow:"Expandir linha",collapseRow:"Recolher linha"}};function $t({data:e,initialSort:s,controlledSort:n,onSortChange:a,multiSort:o=!1,controlledMultiSort:r,onMultiSortChange:i,manual:u=!1}){const[d,c]=l.useState(s??{columnId:null,direction:"asc"}),[b,h]=l.useState([]),f=n??d,p=r??b,v=l.useCallback(k=>{if(o){const y=p.findIndex(S=>S.columnId===k);let j;y>=0?p[y].direction==="asc"?(j=[...p],j[y]={columnId:k,direction:"desc"}):j=p.filter((P,m)=>m!==y):j=[...p,{columnId:k,direction:"asc"}],r||h(j),i?.(j);const x=j[0],C=x?{columnId:x.columnId,direction:x.direction}:{columnId:null,direction:"asc"};n||c(C),a?.(C)}else{let y;f.columnId!==k?y={columnId:k,direction:"asc"}:f.direction==="asc"?y={columnId:k,direction:"desc"}:y={columnId:null,direction:"asc"},n||c(y),a?.(y)}},[f,p,n,r,a,i,o]),g=l.useCallback(()=>{const k={columnId:null,direction:"asc"};n||c(k),a?.(k),o&&(r||h([]),i?.([]))},[n,r,a,i,o]);return{sortedData:l.useMemo(()=>u?e:o&&p.length>0?Es(e,p):f.columnId?Mt(e,f.columnId,f.direction):e,[e,f,p,o,u]),sortState:f,handleSort:v,clearSort:g,multiSortState:p,isMultiSort:o}}function zt({data:e,columns:s,initialFilters:n,controlledFilters:a,onFilterChange:o,manual:r=!1}){const[i,u]=l.useState(n??{}),d=a??i,c=l.useCallback((p,v)=>{const g={...d};if(v!==null&&typeof v=="object"&&"from"in v){const N=v;!N.from&&!N.to?delete g[p]:g[p]=v}else v==null||v===""?delete g[p]:g[p]=v;a||u(g),o?.(g)},[d,a,o]),b=l.useCallback(p=>{const v={...d};delete v[p],a||u(v),o?.(v)},[d,a,o]),h=l.useCallback(()=>{a||u({}),o?.({})},[a,o]);return{filteredData:l.useMemo(()=>r?e:Lt(e,d,s),[e,d,s,r]),filters:d,setFilter:c,clearFilters:h,clearFilter:b}}function Ot({data:e,config:s,onPageChange:n,manual:a=!1}){const o=s!==!1,r=s&&typeof s=="object"?s.page??1:1,i=s&&typeof s=="object"?s.pageSize??10:10,u=s&&typeof s=="object"?s.totalItems:void 0,[d,c]=l.useState(r),[b,h]=l.useState(i),f=u??e.length,p=Math.max(1,Math.ceil(f/b)),v=l.useCallback(C=>{const S=Math.max(1,Math.min(C,p));c(S),n?.(S,b)},[p,b,n]),g=l.useCallback(()=>{d<p&&v(d+1)},[d,p,v]),N=l.useCallback(()=>{d>1&&v(d-1)},[d,v]),k=l.useCallback(C=>{h(C),c(1),n?.(1,C)},[n]),y=l.useMemo(()=>{if(!o||a||u!==void 0)return e;const C=(d-1)*b;return e.slice(C,C+b)},[e,d,b,o,a,u]),j=(d-1)*b+1,x=Math.min(d*b,f);return{paginatedData:y,page:d,pageSize:b,totalPages:p,totalItems:f,goToPage:v,nextPage:g,prevPage:N,changePageSize:k,hasNextPage:d<p,hasPrevPage:d>1,startIndex:j,endIndex:x}}function Bt({data:e,rowKey:s,mode:n="multiple",initialSelection:a,controlledSelection:o,onSelectionChange:r}){const[i,u]=l.useState(a??[]),d=o??i,c=l.useCallback((x,C)=>typeof s=="function"?s(x,C):String(x[s]),[s]),b=l.useMemo(()=>new Set(d.map((x,C)=>c(x,C))),[d,c]),h=l.useCallback((x,C)=>{const S=c(x,C);return b.has(S)},[c,b]),f=l.useCallback(x=>{o||u(x),r?.(x)},[o,r]),p=l.useCallback((x,C)=>{const S=c(x,C);let P;n==="single"?P=b.has(S)?[]:[x]:b.has(S)?P=d.filter((m,w)=>c(m,w)!==S):P=[...d,x],f(P)},[n,b,d,c,f]),v=l.useCallback((x,C)=>{if(!h(x,C)){const S=n==="single"?[x]:[...d,x];f(S)}},[h,n,d,f]),g=l.useCallback((x,C)=>{const S=c(x,C),P=d.filter((m,w)=>c(m,w)!==S);f(P)},[d,c,f]),N=l.useCallback(()=>{n==="multiple"&&f([...e])},[e,n,f]),k=l.useCallback(()=>{f([])},[f]),y=e.length>0&&d.length===e.length,j=d.length>0&&d.length<e.length;return{selectedRows:d,isSelected:h,toggleRow:p,selectRow:v,deselectRow:g,selectAll:N,deselectAll:k,isAllSelected:y,isPartiallySelected:j,selectedCount:d.length}}function Wt({data:e,columns:s,searchColumns:n,initialValue:a,controlledValue:o,onSearchChange:r,debounceMs:i=0,manual:u=!1}){const[d,c]=l.useState(a??""),[b,h]=l.useState(a??""),f=l.useRef(null),p=o??d;l.useEffect(()=>{if(i<=0){h(p);return}return f.current=setTimeout(()=>{h(p)},i),()=>{f.current&&clearTimeout(f.current)}},[p,i]);const v=l.useCallback(k=>{o===void 0&&c(k),r?.(k)},[o,r]),g=l.useCallback(()=>{o===void 0&&c(""),f.current&&clearTimeout(f.current),h(""),r?.("")},[o,r]);return{searchedData:l.useMemo(()=>u?e:At(e,b,s,n),[e,b,s,n,u]),searchValue:p,handleSearch:v,clearSearch:g}}function Ht({columns:e,controlledHiddenColumns:s,onColumnVisibilityChange:n}){const[a,o]=l.useState(()=>e.filter(h=>h.hidden).map(h=>h.id)),r=s??a,i=l.useMemo(()=>new Set(r),[r]),u=l.useCallback(h=>{const f=i.has(h)?r.filter(p=>p!==h):[...r,h];s||o(f),n?.(f)},[r,i,s,n]),d=l.useCallback(()=>{s||o([]),n?.([])},[s,n]),c=l.useCallback(h=>!i.has(h),[i]);return{visibleColumns:l.useMemo(()=>e.filter(h=>!i.has(h.id)),[e,i]),hiddenColumnIds:i,toggleColumn:u,showAllColumns:d,isColumnVisible:c,hiddenColumns:r}}const yn=50;function wn({columns:e,enabled:s,minWidth:n=yn,maxWidth:a,onColumnResize:o,tableRef:r}){const[i,u]=l.useState({}),[d,c]=l.useState(!1),b=l.useRef(null),h=l.useCallback(g=>{if(!r.current)return 150;const N=r.current.querySelector(`th[data-column-id="${g}"]`);return N?N.getBoundingClientRect().width:150},[r]),f=l.useCallback((g,N)=>{if(!s)return;const k=i[g]??h(g);b.current={columnId:g,startX:N,startWidth:k},c(!0)},[s,i,h]);l.useEffect(()=>{if(!d)return;const g=k=>{if(!b.current)return;k.preventDefault();const{columnId:y,startX:j,startWidth:x}=b.current,C=k.clientX-j;let S=Math.max(x+C,n);a!==void 0&&(S=Math.min(S,a));const P=e.find(m=>m.id===y);if(P){const m=P.minWidth??n,w=P.maxWidth??a;S=Math.max(S,m),w!==void 0&&(S=Math.min(S,w))}u(m=>({...m,[y]:S}))},N=()=>{if(b.current){const{columnId:k}=b.current,y=i[k];y!==void 0&&o&&o(k,y)}b.current=null,c(!1)};return document.addEventListener("mousemove",g),document.addEventListener("mouseup",N),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",N),document.body.style.userSelect="",document.body.style.cursor=""}},[d,i,e,n,a,o]);const p=l.useCallback(g=>i[g],[i]),v=l.useCallback(()=>{u({})},[]);return{columnWidths:i,isResizing:d,startResize:f,getColumnWidth:p,resetColumnWidths:v}}function kn({containerRef:e,itemCount:s,rowHeight:n,buffer:a,enabled:o}){const[r,i]=l.useState(0),[u,d]=l.useState(0);l.useEffect(()=>{if(!o)return;const b=e.current;if(!b)return;const h=()=>{i(b.scrollTop)};d(b.clientHeight),i(b.scrollTop),b.addEventListener("scroll",h,{passive:!0});const f=new ResizeObserver(p=>{for(const v of p)d(v.contentRect.height)});return f.observe(b),()=>{b.removeEventListener("scroll",h),f.disconnect()}},[e,o]);const c=l.useCallback(()=>{e.current&&(e.current.scrollTop=0,i(0))},[e]);return l.useEffect(()=>{o&&c()},[s,o,c]),l.useMemo(()=>{if(!o||s===0)return{totalHeight:0,startIndex:0,endIndex:s,offsetTop:0};const b=s*n,h=Math.floor(r/n),f=Math.ceil(u/n),p=Math.max(0,h-a),v=Math.min(s,h+f+a),g=p*n;return{totalHeight:b,startIndex:p,endIndex:v,offsetTop:g}},[o,s,n,r,u,a])}function Sn({controlledExpandedRows:e,onExpandChange:s,accordion:n=!1}){const[a,o]=l.useState([]),r=e!==void 0,i=r?e:a,u=l.useMemo(()=>new Set(i),[i]),d=l.useCallback(f=>{r||o(f),s?.(f)},[r,s]),c=l.useCallback(f=>u.has(f),[u]),b=l.useCallback(f=>{u.has(f)?d(i.filter(p=>p!==f)):d(n?[f]:[...i,f])},[u,i,n,d]),h=l.useCallback(()=>{d([])},[d]);return{expandedRowKeys:u,isExpanded:c,toggleExpand:b,collapseAll:h}}const Nn=500,Tn=48,Pn=5;function Dn(e){const{data:s,columns:n,rowKey:a="id",rowActions:o,globalActions:r,maxVisibleActions:i=3,pagination:u={pageSize:10},onPageChange:d,sort:c,onSortChange:b,multiSort:h=!1,multiSortState:f,onMultiSortChange:p,filters:v,onFilterChange:g,filterMode:N="floating",searchable:k=!1,searchValue:y,onSearchChange:j,searchColumns:x,searchDebounceMs:C=300,manualSorting:S=!1,manualFiltering:P=!1,manualPagination:m=!1,selectable:w,selectedRows:A,onSelectionChange:R,selectionMode:O="multiple",columnVisibility:M=!1,hiddenColumns:se,onColumnVisibilityChange:Vt,loading:H=!1,loadingComponent:fe,emptyComponent:pe,classNames:X={},styles:me={},locale:V,stickyHeader:ge=!1,maxHeight:xe,bordered:ne=!1,striped:ae=!1,hoverable:le=!0,size:ie="medium",onRowClick:ve,onRowDoubleClick:je,resizable:U=!1,onColumnResize:Ut,minColumnWidth:_t,maxColumnWidth:qt,expandable:_,expandedRows:Kt,onExpandChange:Zt,ariaLabel:Qt,ariaDescribedBy:Xt,virtualize:re,rowHeight:Gt=Tn,virtualBuffer:Jt=Pn}=e,q=l.useMemo(()=>w!==void 0?w:r?.some(be=>be.requiresSelection)||R!==void 0,[w,r,R]),B=l.useMemo(()=>({...typeof V=="string"?Ft[V]:he,...typeof V=="object"?V:{}}),[V]),[Ce,ye]=l.useState(!1),[we,ke]=l.useState(null),[oe,Yt]=l.useState(!1),Se=l.useCallback(()=>{Yt(D=>!D)},[]),Ne=l.useMemo(()=>n.some(D=>D.filterable!==!1&&D.type!=="custom"&&!D.hidden),[n]),Te=l.useCallback(D=>{ke(D),ye(!0)},[]),Pe=l.useCallback(()=>{ye(!1),ke(null)},[]),F=l.useMemo(()=>u===!1?!1:{pageSize:10,pageSizeOptions:[10,20,50,100],showSizeChanger:!1,...u},[u]),{searchedData:es,searchValue:G,handleSearch:De,clearSearch:Me}=Wt({data:s,columns:n,searchColumns:x,controlledValue:y,onSearchChange:j,debounceMs:C,manual:P}),{filteredData:ts,filters:J,setFilter:Le,clearFilter:Ae,clearFilters:Ee}=zt({data:es,columns:n,controlledFilters:v,onFilterChange:g,manual:P}),{sortedData:$,sortState:Ie,handleSort:Re,clearSort:Fe,multiSortState:$e,isMultiSort:ze}=$t({data:ts,controlledSort:c,onSortChange:b,multiSort:h,controlledMultiSort:f,onMultiSortChange:p,manual:S}),{visibleColumns:Y,hiddenColumnIds:Oe,toggleColumn:Be,showAllColumns:We,isColumnVisible:He}=Ht({columns:n,controlledHiddenColumns:se,onColumnVisibilityChange:Vt}),{selectedRows:Ve,isSelected:Ue,toggleRow:_e,selectAll:qe,deselectAll:Ke,isAllSelected:Ze,isPartiallySelected:Qe,selectedCount:K}=Bt({data:$,rowKey:a,mode:O,controlledSelection:A,onSelectionChange:R}),{paginatedData:ss,page:Xe,pageSize:Ge,totalPages:Je,totalItems:Ye,goToPage:et,nextPage:tt,prevPage:st,changePageSize:nt,hasNextPage:at,hasPrevPage:lt,startIndex:it,endIndex:rt}=Ot({data:$,config:F,onPageChange:d,manual:m}),ce=u===!1,ee=l.useMemo(()=>re!==void 0?re:ce&&$.length>Nn,[re,ce,$.length]),ot=l.useRef(null),ct=l.useRef(null),{columnWidths:dt,isResizing:ut,startResize:bt,getColumnWidth:de}=wn({columns:Y,enabled:U,minWidth:_t,maxWidth:qt,onColumnResize:Ut,tableRef:ct}),{isExpanded:ht,toggleExpand:ft}=Sn({controlledExpandedRows:Kt,onExpandChange:Zt,accordion:_?.accordion}),Z=ce?$:ss,{totalHeight:ns,startIndex:as,endIndex:ls,offsetTop:is}=kn({containerRef:ot,itemCount:Z.length,rowHeight:Gt,buffer:Jt,enabled:ee}),rs=l.useMemo(()=>({data:s,processedData:Z,columns:n,visibleColumns:Y,rowKey:a,rowActions:o,globalActions:r,maxVisibleActions:i,expandableRender:_?.render,isExpanded:ht,toggleExpand:ft,expandableEnabled:_!==void 0}),[s,Z,n,Y,a,o,r,i,_,ht,ft]),os=l.useMemo(()=>({sortState:Ie,handleSort:Re,multiSortState:$e,isMultiSort:ze,clearSort:Fe}),[Ie,Re,$e,ze,Fe]),cs=l.useMemo(()=>({filters:J,setFilter:Le,clearFilter:Ae,clearFilters:Ee,searchValue:G,handleSearch:De,clearSearch:Me,searchable:k,filterPanelOpen:oe,toggleFilterPanel:Se,hasFilterableColumns:Ne,filterMode:N}),[J,Le,Ae,Ee,G,De,Me,k,oe,Se,Ne,N]),ds=l.useMemo(()=>({selectedRows:Ve,isSelected:Ue,toggleRow:_e,selectAll:qe,deselectAll:Ke,isAllSelected:Ze,isPartiallySelected:Qe,selectedCount:K,selectable:q,selectionMode:O}),[Ve,Ue,_e,qe,Ke,Ze,Qe,K,q,O]),us=l.useMemo(()=>({page:Xe,pageSize:Ge,totalPages:Je,totalItems:Ye,goToPage:et,nextPage:tt,prevPage:st,changePageSize:nt,hasNextPage:at,hasPrevPage:lt,startIndex:it,endIndex:rt,paginationEnabled:u!==!1,pageSizeOptions:F&&typeof F=="object"?F.pageSizeOptions??[10,20,50,100]:[10,20,50,100],showSizeChanger:F&&typeof F=="object"?F.showSizeChanger??!1:!1}),[Xe,Ge,Je,Ye,et,tt,st,nt,at,lt,it,rt,u,F]),bs=l.useMemo(()=>({locale:B,classNames:X,size:ie,bordered:ne,striped:ae,hoverable:le,stickyHeader:ge,loading:H,loadingComponent:fe,emptyComponent:pe,onRowClick:ve,onRowDoubleClick:je,openModal:Te,closeModal:Pe,modalContent:we,isModalOpen:Ce,columnVisibilityEnabled:M,hiddenColumnIds:Oe,toggleColumn:Be,showAllColumns:We,isColumnVisible:He,columns:n,resizable:U,columnWidths:dt,isResizing:ut,startResize:bt,getColumnWidth:de}),[B,X,ie,ne,ae,le,ge,H,fe,pe,ve,je,Te,Pe,we,Ce,M,Oe,Be,We,He,n,U,dt,ut,bt,de]),ue=Z.length>0,hs=Rt("(max-width: 640px)"),fs=l.useMemo(()=>{const D=[],W=G.length>0,be=Object.keys(J).length>0;return(W||be)&&($.length===0?D.push(B.noResultsFound):D.push(B.resultsFound.replace("{count}",String($.length)))),q&&K>0&&D.push(B.rowsSelected.replace("{count}",String(K))),D.join(". ")},[$.length,G,J,q,K,B]);return t.jsx(Tt,{data:rs,sort:os,filter:cs,selection:ds,pagination:us,ui:bs,children:t.jsxs("div",{className:T("bt-container",`bt-size-${ie}`,ae&&"bt-striped",ne&&"bt-bordered",le&&"bt-hoverable",H&&"bt-container-loading",X.container),style:me.container,children:[t.jsx(bn,{}),(N==="panel"||N==="both")&&t.jsx(en,{open:oe}),t.jsxs("div",{ref:ot,className:"bt-table-wrapper",style:{maxHeight:xe,...ee&&!xe?{maxHeight:"80vh",overflow:"auto"}:{}},children:[hs?ue&&t.jsx(Xs,{}):t.jsxs("table",{ref:ct,className:T("bt-table",U&&"bt-table-resizable",X.table),style:me.table,role:"grid","aria-label":Qt,"aria-describedby":Xt,"aria-busy":H,"aria-rowcount":ee?Z.length:void 0,children:[U&&t.jsxs("colgroup",{children:[_&&t.jsx("col",{style:{width:40}}),q&&t.jsx("col",{style:{width:40}}),Y.map(D=>{const W=de(D.id);return t.jsx("col",{style:W!==void 0?{width:W}:D.width!==void 0?{width:D.width}:void 0},D.id)}),o&&o.length>0&&t.jsx("col",{})]}),t.jsx(As,{}),ue?ee?t.jsx(Cn,{startIndex:as,endIndex:ls,totalHeight:ns,offsetTop:is}):t.jsx(_s,{}):t.jsx(fn,{})]}),t.jsx(pn,{show:H&&ue})]}),u!==!1&&t.jsx(on,{}),t.jsx(vn,{}),t.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"bt-sr-only",children:fs})]})})}const Mn=Dn;exports.BetterTable=Mn;exports.TableProvider=Tt;exports.defaultLocale=he;exports.filterData=Lt;exports.getValueFromPath=I;exports.locales=Ft;exports.searchData=At;exports.sortData=Mt;exports.useColumnVisibility=Ht;exports.useTableData=E;exports.useTableFilter=zt;exports.useTableFilterContext=Q;exports.useTablePagination=Ot;exports.useTablePaginationContext=St;exports.useTableSearch=Wt;exports.useTableSelection=Bt;exports.useTableSelectionContext=z;exports.useTableSort=$t;exports.useTableSortContext=Ct;exports.useTableUI=L;
|
|
2
2
|
//# sourceMappingURL=better-table.cjs.js.map
|