@mikestools/usetable 0.0.4 → 0.0.5

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 CHANGED
@@ -13,20 +13,21 @@ A Vue 3 composable for HTML table manipulation with native DOM APIs. Two-layer a
13
13
 
14
14
  ### Core Features
15
15
 
16
- | Feature | Description |
17
- |------------------|-------------------------------------------|
18
- | 📋 **Headers** | Set, update, add, remove header cells |
19
- | ➕ **Rows** | Add, remove, update, move, swap rows |
20
- | 📊 **Columns** | Add, remove, move, swap columns |
21
- | 🔲 **Cells** | Get, set individual cell values |
22
- | ☑️ **Selection** | Row and cell selection with range support |
23
- | 🎯 **Focus** | Cell focus with keyboard navigation |
24
- | 📝 **Footer** | Footer row for totals/summaries |
25
- | 🗄️ **Records** | Work with typed records by ID |
26
- | 🔔 **Events** | Granular change callbacks |
27
- | ⌨️ **Keyboard** | Arrow key cell navigation |
28
- | **Reactive** | Vue computed properties |
29
- | 🔄 **Sync** | Sync with pre-existing DOM tables |
16
+ | Feature | Description |
17
+ |------------------|-----------------------------------------------|
18
+ | 📋 **Headers** | Set, update, add, remove header cells |
19
+ | ➕ **Rows** | Add, remove, update, move, swap rows |
20
+ | 📐 **Sections** | Section-specific row ops (thead/tfoot/tbody) |
21
+ | 📊 **Columns** | Add, remove, move, swap columns |
22
+ | 🔲 **Cells** | Get, set individual cell values |
23
+ | ☑️ **Selection** | Row and cell selection with range support |
24
+ | 🎯 **Focus** | Cell focus with keyboard navigation |
25
+ | 📝 **Footer** | Footer row for totals/summaries |
26
+ | 🗄️ **Records** | Work with typed records by ID |
27
+ | 🔔 **Events** | Granular change callbacks |
28
+ | ⌨️ **Keyboard** | Arrow key cell navigation |
29
+ | **Reactive** | Vue computed properties |
30
+ | 🔄 **Sync** | Sync with pre-existing DOM tables |
30
31
 
31
32
  ## Installation
32
33
 
@@ -190,6 +191,33 @@ getRowId(index: number): string | undefined
190
191
  getRowIndex(id: string): number
191
192
  ```
192
193
 
194
+ #### Section-Specific Row Methods
195
+
196
+ Methods using native `HTMLTableSectionElement` APIs for direct section manipulation:
197
+
198
+ ```typescript
199
+ // Generic section methods
200
+ getSectionRows(section: HTMLTableSectionElement): HTMLCollectionOf<HTMLTableRowElement>
201
+ insertSectionRow(section: HTMLTableSectionElement, data: RowData, index?: number, id?: string): HTMLTableRowElement
202
+ deleteSectionRow(section: HTMLTableSectionElement, index: number): CellValue[] | undefined
203
+ getSectionRowCount(section: HTMLTableSectionElement): number
204
+
205
+ // thead-specific
206
+ addHeadRow(data: RowData, index?: number): HTMLTableRowElement
207
+ removeHeadRow(index: number): CellValue[] | undefined
208
+ getHeadRowCount(): number
209
+
210
+ // tfoot-specific
211
+ addFootRow(data: RowData, index?: number): HTMLTableRowElement
212
+ removeFootRow(index: number): CellValue[] | undefined
213
+ getFootRowCount(): number
214
+
215
+ // tbody-specific (supports multiple tbodies)
216
+ addBodyRow(data: RowData, tbodyIndex?: number, rowIndex?: number, id?: string): HTMLTableRowElement
217
+ removeBodyRow(rowIndex: number, tbodyIndex?: number): CellValue[] | undefined
218
+ getBodyRowCount(tbodyIndex?: number): number
219
+ ```
220
+
193
221
  #### Column Methods
194
222
 
195
223
  ```typescript
package/dist/index.d.ts CHANGED
@@ -227,6 +227,32 @@ export declare interface TableInstance {
227
227
  deleteTFoot(): void;
228
228
  /** Create a new tbody */
229
229
  createTBody(): HTMLTableSectionElement;
230
+ /** Get rows from a specific section (thead, tbody, or tfoot) */
231
+ getSectionRows(section: HTMLTableSectionElement): HTMLCollectionOf<HTMLTableRowElement>;
232
+ /** Insert a row in a specific section at the given index */
233
+ insertSectionRow(section: HTMLTableSectionElement, data: RowData, index?: number, id?: string): HTMLTableRowElement;
234
+ /** Delete a row from a specific section at the given index */
235
+ deleteSectionRow(section: HTMLTableSectionElement, index: number): CellValue[] | undefined;
236
+ /** Get row count for a specific section */
237
+ getSectionRowCount(section: HTMLTableSectionElement): number;
238
+ /** Add row to thead */
239
+ addHeadRow(data: RowData, index?: number): HTMLTableRowElement;
240
+ /** Remove row from thead */
241
+ removeHeadRow(index: number): CellValue[] | undefined;
242
+ /** Get head row count */
243
+ getHeadRowCount(): number;
244
+ /** Add row to tfoot */
245
+ addFootRow(data: RowData, index?: number): HTMLTableRowElement;
246
+ /** Remove row from tfoot */
247
+ removeFootRow(index: number): CellValue[] | undefined;
248
+ /** Get foot row count */
249
+ getFootRowCount(): number;
250
+ /** Add row to specific tbody */
251
+ addBodyRow(data: RowData, tbodyIndex?: number, rowIndex?: number, id?: string): HTMLTableRowElement;
252
+ /** Remove row from specific tbody */
253
+ removeBodyRow(rowIndex: number, tbodyIndex?: number): CellValue[] | undefined;
254
+ /** Get body row count for a specific tbody */
255
+ getBodyRowCount(tbodyIndex?: number): number;
230
256
  /** Set all headers */
231
257
  setHeaders(headers: readonly string[]): void;
232
258
  /** Set single header */
@@ -410,6 +436,32 @@ export declare interface UseTableReturn {
410
436
  deleteTFoot(): void;
411
437
  /** Create a new tbody */
412
438
  createTBody(): HTMLTableSectionElement;
439
+ /** Get rows from a specific section (thead, tbody, or tfoot) */
440
+ getSectionRows(section: HTMLTableSectionElement): HTMLCollectionOf<HTMLTableRowElement>;
441
+ /** Insert a row in a specific section at the given index */
442
+ insertSectionRow(section: HTMLTableSectionElement, data: RowData, index?: number, id?: string): HTMLTableRowElement;
443
+ /** Delete a row from a specific section at the given index */
444
+ deleteSectionRow(section: HTMLTableSectionElement, index: number): CellValue[] | undefined;
445
+ /** Get row count for a specific section */
446
+ getSectionRowCount(section: HTMLTableSectionElement): number;
447
+ /** Add row to thead */
448
+ addHeadRow(data: RowData, index?: number): HTMLTableRowElement;
449
+ /** Remove row from thead */
450
+ removeHeadRow(index: number): CellValue[] | undefined;
451
+ /** Get head row count */
452
+ getHeadRowCount(): number;
453
+ /** Add row to tfoot */
454
+ addFootRow(data: RowData, index?: number): HTMLTableRowElement;
455
+ /** Remove row from tfoot */
456
+ removeFootRow(index: number): CellValue[] | undefined;
457
+ /** Get foot row count */
458
+ getFootRowCount(): number;
459
+ /** Add row to specific tbody */
460
+ addBodyRow(data: RowData, tbodyIndex?: number, rowIndex?: number, id?: string): HTMLTableRowElement;
461
+ /** Remove row from specific tbody */
462
+ removeBodyRow(rowIndex: number, tbodyIndex?: number): CellValue[] | undefined;
463
+ /** Get body row count for a specific tbody */
464
+ getBodyRowCount(tbodyIndex?: number): number;
413
465
  /** Set all headers */
414
466
  setHeaders(headers: readonly string[]): void;
415
467
  /** Set single header */
package/dist/usetable.js CHANGED
@@ -1,20 +1,20 @@
1
- import { ref as N, computed as U, onUnmounted as ut } from "vue";
1
+ import { ref as j, computed as A, onUnmounted as ut } from "vue";
2
2
  function dt() {
3
3
  return crypto.randomUUID();
4
4
  }
5
- function S(l, C) {
5
+ function T(l, C) {
6
6
  l.textContent = "", C != null && (C instanceof Node ? l.appendChild(C) : l.textContent = String(C));
7
7
  }
8
- function A(l) {
8
+ function U(l) {
9
9
  return l.childNodes.length === 1 && l.firstChild instanceof HTMLElement ? l.firstChild : l.textContent ?? "";
10
10
  }
11
11
  function oe(l) {
12
12
  const C = document.createElement("th");
13
13
  return C.scope = "col", C.textContent = l, C;
14
14
  }
15
- function it(l, C, H) {
16
- let c = H?.idGenerator ?? dt;
17
- const F = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), D = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set();
15
+ function it(l, C, m) {
16
+ let c = m?.idGenerator ?? dt;
17
+ const B = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Set(), H = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set();
18
18
  function E() {
19
19
  const e = l.tBodies;
20
20
  return e.length > 0 ? e[0] : l.createTBody();
@@ -28,35 +28,35 @@ function it(l, C, H) {
28
28
  }
29
29
  return e;
30
30
  }
31
- function P(e, o, n) {
32
- F.forEach((s) => s(e, o, n)), y();
31
+ function V(e, o, n) {
32
+ B.forEach((s) => s(e, o, n)), y();
33
33
  }
34
- function j(e, o, n) {
35
- f.forEach((s) => s(e, o, n)), y();
34
+ function M(e, o, n) {
35
+ w.forEach((s) => s(e, o, n)), y();
36
36
  }
37
37
  function z(e, o, n, s) {
38
38
  h.forEach((a) => a(e, o, n, s)), y();
39
39
  }
40
- function V(e, o, n, s) {
41
- D.forEach((a) => a(e, o, n, s)), y();
40
+ function N(e, o, n, s) {
41
+ F.forEach((a) => a(e, o, n, s)), y();
42
42
  }
43
- function T() {
44
- const e = d.getHeaders();
45
- p.forEach((o) => o(e));
43
+ function D() {
44
+ const e = i.getHeaders();
45
+ H.forEach((o) => o(e));
46
46
  }
47
47
  function y() {
48
48
  if (I.size > 0) {
49
- const e = d.getData();
49
+ const e = i.getData();
50
50
  I.forEach((o) => o(e));
51
51
  }
52
52
  }
53
- function L(e) {
53
+ function b(e) {
54
54
  const o = [];
55
55
  for (let n = 0; n < e.cells.length; n++)
56
- o.push(A(e.cells[n]));
56
+ o.push(U(e.cells[n]));
57
57
  return o;
58
58
  }
59
- const d = {
59
+ const i = {
60
60
  // ======================================================================
61
61
  // ELEMENT ACCESS
62
62
  // ======================================================================
@@ -89,12 +89,12 @@ function it(l, C, H) {
89
89
  return n;
90
90
  },
91
91
  getCell(e, o) {
92
- const n = d.getRow(e);
92
+ const n = i.getRow(e);
93
93
  if (n)
94
94
  return n.cells[o];
95
95
  },
96
96
  getCellByRowId(e, o) {
97
- const n = d.getRowById(e);
97
+ const n = i.getRowById(e);
98
98
  if (n)
99
99
  return n.cells[o];
100
100
  },
@@ -110,48 +110,48 @@ function it(l, C, H) {
110
110
  return n;
111
111
  },
112
112
  getHeader(e) {
113
- return d.getHeaders()[e];
113
+ return i.getHeaders()[e];
114
114
  },
115
115
  getData() {
116
- return v().map(L);
116
+ return v().map(b);
117
117
  },
118
118
  getRowData(e) {
119
- const o = d.getRow(e);
119
+ const o = i.getRow(e);
120
120
  if (o)
121
- return L(o);
121
+ return b(o);
122
122
  },
123
123
  getRowDataById(e) {
124
- const o = d.getRowById(e);
124
+ const o = i.getRowById(e);
125
125
  if (o)
126
- return L(o);
126
+ return b(o);
127
127
  },
128
128
  getCellValue(e, o) {
129
- const n = d.getCell(e, o);
129
+ const n = i.getCell(e, o);
130
130
  if (n)
131
- return A(n);
131
+ return U(n);
132
132
  },
133
133
  getColumnData(e) {
134
134
  return v().map((n) => {
135
135
  const s = n.cells[e];
136
- return s ? A(s) : void 0;
136
+ return s ? U(s) : void 0;
137
137
  });
138
138
  },
139
139
  getFooterData() {
140
140
  const e = l.tFoot;
141
141
  if (!(!e || e.rows.length === 0))
142
- return L(e.rows[0]);
142
+ return b(e.rows[0]);
143
143
  },
144
144
  getRowCount() {
145
145
  return v().length;
146
146
  },
147
147
  getColumnCount() {
148
- const e = d.getHeaders();
148
+ const e = i.getHeaders();
149
149
  if (e.length > 0) return e.length;
150
150
  const o = v();
151
151
  return o.length > 0 ? o[0].cells.length : 0;
152
152
  },
153
153
  getRowId(e) {
154
- return d.getRow(e)?.dataset.id;
154
+ return i.getRow(e)?.dataset.id;
155
155
  },
156
156
  getRowIndex(e) {
157
157
  const o = v();
@@ -179,7 +179,7 @@ function it(l, C, H) {
179
179
  return l.createTHead();
180
180
  },
181
181
  deleteTHead() {
182
- l.deleteTHead(), T();
182
+ l.deleteTHead(), D();
183
183
  },
184
184
  createTFoot() {
185
185
  return l.createTFoot();
@@ -191,6 +191,80 @@ function it(l, C, H) {
191
191
  return l.createTBody();
192
192
  },
193
193
  // ======================================================================
194
+ // SECTION-SPECIFIC ROW METHODS
195
+ // ======================================================================
196
+ getSectionRows(e) {
197
+ return e.rows;
198
+ },
199
+ insertSectionRow(e, o, n, s) {
200
+ const a = n ?? e.rows.length, d = e.insertRow(a);
201
+ s ? d.dataset.id = s : e === l.tBodies[0] && (d.dataset.id = c());
202
+ for (const g of o) {
203
+ const f = d.insertCell();
204
+ T(f, g);
205
+ }
206
+ return l.tBodies && Array.from(l.tBodies).includes(e) && V([...o], a, d.dataset.id), d;
207
+ },
208
+ deleteSectionRow(e, o) {
209
+ if (o < 0 || o >= e.rows.length) return;
210
+ const n = e.rows[o], s = b(n), a = n.dataset.id;
211
+ return e.deleteRow(o), l.tBodies && Array.from(l.tBodies).includes(e) && M(s, o, a), s;
212
+ },
213
+ getSectionRowCount(e) {
214
+ return e.rows.length;
215
+ },
216
+ addHeadRow(e, o) {
217
+ let n = l.tHead;
218
+ return n || (n = l.createTHead()), i.insertSectionRow(n, e, o);
219
+ },
220
+ removeHeadRow(e) {
221
+ const o = l.tHead;
222
+ if (!o) return;
223
+ const n = i.deleteSectionRow(o, e);
224
+ return n && D(), n;
225
+ },
226
+ getHeadRowCount() {
227
+ const e = l.tHead;
228
+ return e ? e.rows.length : 0;
229
+ },
230
+ addFootRow(e, o) {
231
+ let n = l.tFoot;
232
+ n || (n = l.createTFoot());
233
+ const s = i.insertSectionRow(n, e, o);
234
+ return y(), s;
235
+ },
236
+ removeFootRow(e) {
237
+ const o = l.tFoot;
238
+ if (!o) return;
239
+ const n = i.deleteSectionRow(o, e);
240
+ return n && y(), n;
241
+ },
242
+ getFootRowCount() {
243
+ const e = l.tFoot;
244
+ return e ? e.rows.length : 0;
245
+ },
246
+ addBodyRow(e, o, n, s) {
247
+ const a = l.tBodies;
248
+ let d;
249
+ return o !== void 0 && o >= 0 && o < a.length ? d = a[o] : d = E(), i.insertSectionRow(d, e, n, s);
250
+ },
251
+ removeBodyRow(e, o) {
252
+ const n = l.tBodies;
253
+ if (n.length === 0) return;
254
+ let s;
255
+ return o !== void 0 && o >= 0 && o < n.length ? s = n[o] : s = n[0], i.deleteSectionRow(s, e);
256
+ },
257
+ getBodyRowCount(e) {
258
+ const o = l.tBodies;
259
+ if (o.length === 0) return 0;
260
+ if (e !== void 0 && e >= 0 && e < o.length)
261
+ return o[e].rows.length;
262
+ let n = 0;
263
+ for (let s = 0; s < o.length; s++)
264
+ n += o[s].rows.length;
265
+ return n;
266
+ },
267
+ // ======================================================================
194
268
  // HEADER METHODS
195
269
  // ======================================================================
196
270
  setHeaders(e) {
@@ -200,83 +274,83 @@ function it(l, C, H) {
200
274
  const n = o.insertRow();
201
275
  for (const s of e)
202
276
  n.appendChild(oe(s));
203
- T();
277
+ D();
204
278
  },
205
279
  setHeader(e, o) {
206
280
  const n = l.tHead;
207
281
  if (!n || n.rows.length === 0) return;
208
282
  const s = n.rows[0].cells[e];
209
- s && (s.textContent = o, T());
283
+ s && (s.textContent = o, D());
210
284
  },
211
285
  addHeader(e, o) {
212
286
  let n = l.tHead;
213
287
  n || (n = l.createTHead(), n.insertRow()), n.rows.length === 0 && n.insertRow();
214
288
  const s = n.rows[0], a = oe(e);
215
- o === void 0 || o >= s.cells.length ? s.appendChild(a) : s.insertBefore(a, s.cells[o]), T();
289
+ o === void 0 || o >= s.cells.length ? s.appendChild(a) : s.insertBefore(a, s.cells[o]), D();
216
290
  },
217
291
  removeHeader(e) {
218
292
  const o = l.tHead;
219
293
  if (!o || o.rows.length === 0) return;
220
294
  const n = o.rows[0];
221
- e >= 0 && e < n.cells.length && (n.deleteCell(e), T());
295
+ e >= 0 && e < n.cells.length && (n.deleteCell(e), D());
222
296
  },
223
297
  // ======================================================================
224
298
  // ROW METHODS
225
299
  // ======================================================================
226
300
  addRow(e, o, n) {
227
- const s = E(), a = o ?? s.rows.length, i = s.insertRow(a), g = n ?? c();
228
- i.dataset.id = g;
229
- for (const w of e) {
230
- const B = i.insertCell();
231
- S(B, w);
301
+ const s = E(), a = o ?? s.rows.length, d = s.insertRow(a), g = n ?? c();
302
+ d.dataset.id = g;
303
+ for (const f of e) {
304
+ const S = d.insertCell();
305
+ T(S, f);
232
306
  }
233
- return P([...e], a, g), i;
307
+ return V([...e], a, g), d;
234
308
  },
235
309
  removeRow(e) {
236
310
  const o = v();
237
311
  if (e < 0 || e >= o.length) return;
238
- const n = o[e], s = L(n), a = n.dataset.id;
239
- return n.remove(), j(s, e, a), s;
312
+ const n = o[e], s = b(n), a = n.dataset.id;
313
+ return n.remove(), M(s, e, a), s;
240
314
  },
241
315
  removeRowById(e) {
242
- const o = d.getRowIndex(e);
316
+ const o = i.getRowIndex(e);
243
317
  if (o !== -1)
244
- return d.removeRow(o);
318
+ return i.removeRow(o);
245
319
  },
246
320
  updateRow(e, o) {
247
- const n = d.getRow(e);
321
+ const n = i.getRow(e);
248
322
  if (!n) return;
249
- const s = L(n), a = n.dataset.id;
250
- for (let i = 0; i < o.length; i++) {
251
- let g = n.cells[i];
252
- g || (g = n.insertCell()), S(g, o[i]);
323
+ const s = b(n), a = n.dataset.id;
324
+ for (let d = 0; d < o.length; d++) {
325
+ let g = n.cells[d];
326
+ g || (g = n.insertCell()), T(g, o[d]);
253
327
  }
254
328
  for (; n.cells.length > o.length; )
255
329
  n.deleteCell(n.cells.length - 1);
256
330
  z(e, s, [...o], a);
257
331
  },
258
332
  updateRowById(e, o) {
259
- const n = d.getRowIndex(e);
260
- n !== -1 && d.updateRow(n, o);
333
+ const n = i.getRowIndex(e);
334
+ n !== -1 && i.updateRow(n, o);
261
335
  },
262
336
  moveRow(e, o) {
263
337
  const n = v();
264
338
  if (e < 0 || e >= n.length || o < 0 || o >= n.length || e === o) return;
265
339
  const s = n[e], a = s.parentElement;
266
340
  if (o > e) {
267
- const i = n[o];
268
- a.insertBefore(s, i.nextSibling);
341
+ const d = n[o];
342
+ a.insertBefore(s, d.nextSibling);
269
343
  } else {
270
- const i = n[o];
271
- a.insertBefore(s, i);
344
+ const d = n[o];
345
+ a.insertBefore(s, d);
272
346
  }
273
347
  y();
274
348
  },
275
349
  swapRows(e, o) {
276
350
  const n = v();
277
351
  if (e < 0 || e >= n.length || o < 0 || o >= n.length || e === o) return;
278
- const s = n[e], a = n[o], i = s.parentElement, g = document.createElement("tr");
279
- i.insertBefore(g, s), i.insertBefore(s, a), i.insertBefore(a, g), g.remove(), y();
352
+ const s = n[e], a = n[o], d = s.parentElement, g = document.createElement("tr");
353
+ d.insertBefore(g, s), d.insertBefore(s, a), d.insertBefore(a, g), g.remove(), y();
280
354
  },
281
355
  clearRows() {
282
356
  const e = l.tBodies;
@@ -291,21 +365,21 @@ function it(l, C, H) {
291
365
  // COLUMN METHODS
292
366
  // ======================================================================
293
367
  addColumn(e, o, n) {
294
- d.addHeader(e, n);
368
+ i.addHeader(e, n);
295
369
  const s = v();
296
- for (const i of s) {
297
- const g = i.insertCell(n ?? i.cells.length);
298
- S(g, o ?? "");
370
+ for (const d of s) {
371
+ const g = d.insertCell(n ?? d.cells.length);
372
+ T(g, o ?? "");
299
373
  }
300
374
  const a = l.tFoot;
301
375
  if (a && a.rows.length > 0) {
302
- const i = a.rows[0], g = i.insertCell(n ?? i.cells.length);
303
- S(g, "");
376
+ const d = a.rows[0], g = d.insertCell(n ?? d.cells.length);
377
+ T(g, "");
304
378
  }
305
379
  y();
306
380
  },
307
381
  removeColumn(e) {
308
- d.removeHeader(e);
382
+ i.removeHeader(e);
309
383
  const o = v();
310
384
  for (const s of o)
311
385
  e >= 0 && e < s.cells.length && s.deleteCell(e);
@@ -317,52 +391,52 @@ function it(l, C, H) {
317
391
  y();
318
392
  },
319
393
  moveColumn(e, o) {
320
- const n = d.getColumnCount();
394
+ const n = i.getColumnCount();
321
395
  if (e < 0 || e >= n || o < 0 || o >= n || e === o) return;
322
- const s = (w) => {
323
- if (e >= w.cells.length) return;
324
- const B = w.cells[e];
325
- o >= w.cells.length ? w.appendChild(B) : o > e ? w.insertBefore(B, w.cells[o + 1]) : w.insertBefore(B, w.cells[o]);
396
+ const s = (f) => {
397
+ if (e >= f.cells.length) return;
398
+ const S = f.cells[e];
399
+ o >= f.cells.length ? f.appendChild(S) : o > e ? f.insertBefore(S, f.cells[o + 1]) : f.insertBefore(S, f.cells[o]);
326
400
  }, a = l.tHead;
327
401
  if (a)
328
- for (let w = 0; w < a.rows.length; w++)
329
- s(a.rows[w]);
330
- const i = v();
331
- for (const w of i)
332
- s(w);
402
+ for (let f = 0; f < a.rows.length; f++)
403
+ s(a.rows[f]);
404
+ const d = v();
405
+ for (const f of d)
406
+ s(f);
333
407
  const g = l.tFoot;
334
408
  if (g)
335
- for (let w = 0; w < g.rows.length; w++)
336
- s(g.rows[w]);
337
- T(), y();
409
+ for (let f = 0; f < g.rows.length; f++)
410
+ s(g.rows[f]);
411
+ D(), y();
338
412
  },
339
413
  swapColumns(e, o) {
340
- const n = d.getColumnCount();
414
+ const n = i.getColumnCount();
341
415
  if (e < 0 || e >= n || o < 0 || o >= n || e === o) return;
342
- const s = (w) => {
343
- if (e >= w.cells.length || o >= w.cells.length) return;
344
- const B = w.cells[e], G = w.cells[o], K = document.createElement("td");
345
- w.insertBefore(K, B), w.insertBefore(B, G), w.insertBefore(G, K), K.remove();
416
+ const s = (f) => {
417
+ if (e >= f.cells.length || o >= f.cells.length) return;
418
+ const S = f.cells[e], G = f.cells[o], K = document.createElement("td");
419
+ f.insertBefore(K, S), f.insertBefore(S, G), f.insertBefore(G, K), K.remove();
346
420
  }, a = l.tHead;
347
421
  if (a)
348
- for (let w = 0; w < a.rows.length; w++)
349
- s(a.rows[w]);
350
- const i = v();
351
- for (const w of i)
352
- s(w);
422
+ for (let f = 0; f < a.rows.length; f++)
423
+ s(a.rows[f]);
424
+ const d = v();
425
+ for (const f of d)
426
+ s(f);
353
427
  const g = l.tFoot;
354
428
  if (g)
355
- for (let w = 0; w < g.rows.length; w++)
356
- s(g.rows[w]);
357
- T(), y();
429
+ for (let f = 0; f < g.rows.length; f++)
430
+ s(g.rows[f]);
431
+ D(), y();
358
432
  },
359
433
  setColumnData(e, o) {
360
434
  const n = v();
361
435
  for (let s = 0; s < n.length && s < o.length; s++) {
362
436
  const a = n[s].cells[e];
363
437
  if (a) {
364
- const i = A(a);
365
- S(a, o[s]), i !== o[s] && V(s, e, i, o[s]);
438
+ const d = U(a);
439
+ T(a, o[s]), d !== o[s] && N(s, e, d, o[s]);
366
440
  }
367
441
  }
368
442
  },
@@ -370,20 +444,20 @@ function it(l, C, H) {
370
444
  // CELL METHODS
371
445
  // ======================================================================
372
446
  setCell(e, o, n) {
373
- const s = d.getCell(e, o);
447
+ const s = i.getCell(e, o);
374
448
  if (!s) return;
375
- const a = A(s);
376
- S(s, n), V(e, o, a, n);
449
+ const a = U(s);
450
+ T(s, n), N(e, o, a, n);
377
451
  },
378
452
  setCellByRowId(e, o, n) {
379
- const s = d.getRowIndex(e);
380
- s !== -1 && d.setCell(s, o, n);
453
+ const s = i.getRowIndex(e);
454
+ s !== -1 && i.setCell(s, o, n);
381
455
  },
382
456
  setCellRange(e, o, n) {
383
457
  for (let s = 0; s < n.length; s++) {
384
458
  const a = n[s];
385
- for (let i = 0; i < a.length; i++)
386
- d.setCell(e + s, o + i, a[i]);
459
+ for (let d = 0; d < a.length; d++)
460
+ i.setCell(e + s, o + d, a[d]);
387
461
  }
388
462
  },
389
463
  // ======================================================================
@@ -396,20 +470,20 @@ function it(l, C, H) {
396
470
  const n = o.insertRow();
397
471
  for (const s of e) {
398
472
  const a = n.insertCell();
399
- S(a, s);
473
+ T(a, s);
400
474
  }
401
475
  },
402
476
  setFooterCell(e, o) {
403
477
  const n = l.tFoot;
404
478
  if (!n || n.rows.length === 0) return;
405
479
  const s = n.rows[0].cells[e];
406
- s && S(s, o);
480
+ s && T(s, o);
407
481
  },
408
482
  getFooterCell(e) {
409
483
  const o = l.tFoot;
410
484
  if (!o || o.rows.length === 0) return;
411
485
  const n = o.rows[0].cells[e];
412
- return n ? A(n) : void 0;
486
+ return n ? U(n) : void 0;
413
487
  },
414
488
  clearFooter() {
415
489
  const e = l.tFoot;
@@ -431,14 +505,14 @@ function it(l, C, H) {
431
505
  // BULK OPERATIONS
432
506
  // ======================================================================
433
507
  setData(e) {
434
- d.clearRows();
508
+ i.clearRows();
435
509
  const o = E();
436
510
  for (const n of e) {
437
511
  const s = o.insertRow();
438
512
  s.dataset.id = c();
439
513
  for (const a of n) {
440
- const i = s.insertCell();
441
- S(i, a);
514
+ const d = s.insertCell();
515
+ T(d, a);
442
516
  }
443
517
  }
444
518
  y();
@@ -446,7 +520,7 @@ function it(l, C, H) {
446
520
  reset() {
447
521
  for (l.deleteCaption(), l.deleteTHead(), l.deleteTFoot(); l.tBodies.length > 0; )
448
522
  l.removeChild(l.tBodies[0]);
449
- T(), y();
523
+ D(), y();
450
524
  },
451
525
  sync() {
452
526
  const e = v();
@@ -457,34 +531,34 @@ function it(l, C, H) {
457
531
  // RECORD-BASED OPERATIONS
458
532
  // ======================================================================
459
533
  setRecords(e, o) {
460
- d.clearRows();
534
+ i.clearRows();
461
535
  const n = E();
462
536
  for (const s of e) {
463
537
  const a = n.insertRow();
464
538
  a.dataset.id = s.id;
465
- for (const i of o) {
466
- const g = a.insertCell(), w = typeof i == "function" ? i(s) : s[i];
467
- S(g, w);
539
+ for (const d of o) {
540
+ const g = a.insertCell(), f = typeof d == "function" ? d(s) : s[d];
541
+ T(g, f);
468
542
  }
469
543
  }
470
544
  y();
471
545
  },
472
546
  getRecordData(e) {
473
- return d.getRowDataById(e);
547
+ return i.getRowDataById(e);
474
548
  },
475
549
  addRecord(e, o, n) {
476
- const s = "id" in e && typeof e.id == "string" && e.id.length > 0 ? e.id : c(), a = { ...e, id: s }, i = o.map((g) => typeof g == "function" ? g(a) : a[g]);
477
- return d.addRow(i, n, s), s;
550
+ const s = "id" in e && typeof e.id == "string" && e.id.length > 0 ? e.id : c(), a = { ...e, id: s }, d = o.map((g) => typeof g == "function" ? g(a) : a[g]);
551
+ return i.addRow(d, n, s), s;
478
552
  },
479
553
  updateRecordRow(e, o) {
480
- const n = d.getRowIndex(e);
481
- return n === -1 ? !1 : (d.updateRow(n, o), !0);
554
+ const n = i.getRowIndex(e);
555
+ return n === -1 ? !1 : (i.updateRow(n, o), !0);
482
556
  },
483
557
  removeRecord(e) {
484
- return d.removeRowById(e) !== void 0;
558
+ return i.removeRowById(e) !== void 0;
485
559
  },
486
560
  hasRecord(e) {
487
- return d.getRowIndex(e) !== -1;
561
+ return i.getRowIndex(e) !== -1;
488
562
  },
489
563
  // ======================================================================
490
564
  // ID GENERATOR
@@ -499,19 +573,19 @@ function it(l, C, H) {
499
573
  // EVENT HOOKS
500
574
  // ======================================================================
501
575
  onRowAdd(e) {
502
- return F.add(e), () => F.delete(e);
576
+ return B.add(e), () => B.delete(e);
503
577
  },
504
578
  onRowRemove(e) {
505
- return f.add(e), () => f.delete(e);
579
+ return w.add(e), () => w.delete(e);
506
580
  },
507
581
  onRowUpdate(e) {
508
582
  return h.add(e), () => h.delete(e);
509
583
  },
510
584
  onCellChange(e) {
511
- return D.add(e), () => D.delete(e);
585
+ return F.add(e), () => F.delete(e);
512
586
  },
513
587
  onHeaderChange(e) {
514
- return p.add(e), () => p.delete(e);
588
+ return H.add(e), () => H.delete(e);
515
589
  },
516
590
  onDataChange(e) {
517
591
  return I.add(e), () => I.delete(e);
@@ -520,141 +594,141 @@ function it(l, C, H) {
520
594
  // CLEANUP
521
595
  // ======================================================================
522
596
  destroy() {
523
- F.clear(), f.clear(), h.clear(), D.clear(), p.clear(), I.clear();
597
+ B.clear(), w.clear(), h.clear(), F.clear(), H.clear(), I.clear();
524
598
  }
525
599
  };
526
- return H?.caption && d.setCaption(H.caption), H?.headers && d.setHeaders(H.headers), C && d.setData(C), H?.footer && d.setFooter(H.footer), d.sync(), d;
600
+ return m?.caption && i.setCaption(m.caption), m?.headers && i.setHeaders(m.headers), C && i.setData(C), m?.footer && i.setFooter(m.footer), i.sync(), i;
527
601
  }
528
- function Ct(l, C, H) {
529
- const c = it(l.value, C, H), F = N(0), f = () => {
530
- F.value++;
531
- }, h = N(/* @__PURE__ */ new Set()), D = N(/* @__PURE__ */ new Set()), p = N(null), I = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), v = U(() => (F.value, c.element)), P = U(() => (F.value, c.getHeaders())), j = U(() => (F.value, c.getData())), z = U(() => (F.value, c.getRowCount())), V = U(() => (F.value, c.getColumnCount())), T = U(() => (F.value, c.getAllRowIds())), y = U(() => (F.value, c.getFooterData())), L = U(() => (F.value, c.getCaptionText())), d = () => {
532
- I.forEach((t) => t(h.value, D.value));
602
+ function Rt(l, C, m) {
603
+ const c = it(l.value, C, m), B = j(0), w = () => {
604
+ B.value++;
605
+ }, h = j(/* @__PURE__ */ new Set()), F = j(/* @__PURE__ */ new Set()), H = j(null), I = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), v = A(() => (B.value, c.element)), V = A(() => (B.value, c.getHeaders())), M = A(() => (B.value, c.getData())), z = A(() => (B.value, c.getRowCount())), N = A(() => (B.value, c.getColumnCount())), D = A(() => (B.value, c.getAllRowIds())), y = A(() => (B.value, c.getFooterData())), b = A(() => (B.value, c.getCaptionText())), i = () => {
606
+ I.forEach((t) => t(h.value, F.value));
533
607
  }, e = () => {
534
- E.forEach((t) => t(p.value));
535
- }, o = (t, r) => `${t},${r}`, n = c.onDataChange(() => f()), s = c.onHeaderChange(() => f()), a = (t) => {
608
+ E.forEach((t) => t(H.value));
609
+ }, o = (t, r) => `${t},${r}`, n = c.onDataChange(() => w()), s = c.onHeaderChange(() => w()), a = (t) => {
536
610
  if (t < 0 || t >= c.getRowCount()) return;
537
611
  const r = new Set(h.value);
538
- r.add(t), h.value = r, d();
539
- }, i = (t) => {
612
+ r.add(t), h.value = r, i();
613
+ }, d = (t) => {
540
614
  const r = new Set(h.value);
541
- r.delete(t), h.value = r, d();
615
+ r.delete(t), h.value = r, i();
542
616
  }, g = (t) => {
543
- h.value.has(t) ? i(t) : a(t);
544
- }, w = () => {
617
+ h.value.has(t) ? d(t) : a(t);
618
+ }, f = () => {
545
619
  const t = c.getRowCount(), r = /* @__PURE__ */ new Set();
546
620
  for (let u = 0; u < t; u++)
547
621
  r.add(u);
548
- h.value = r, d();
549
- }, B = () => {
550
- h.value = /* @__PURE__ */ new Set(), d();
622
+ h.value = r, i();
623
+ }, S = () => {
624
+ h.value = /* @__PURE__ */ new Set(), i();
551
625
  }, G = (t, r) => {
552
- const u = Math.min(t, r), R = Math.max(t, r), m = c.getRowCount(), M = new Set(h.value);
553
- for (let k = u; k <= R && k < m; k++)
554
- k >= 0 && M.add(k);
555
- h.value = M, d();
626
+ const u = Math.min(t, r), R = Math.max(t, r), p = c.getRowCount(), P = new Set(h.value);
627
+ for (let k = u; k <= R && k < p; k++)
628
+ k >= 0 && P.add(k);
629
+ h.value = P, i();
556
630
  }, K = (t) => h.value.has(t), $ = () => Array.from(h.value).sort((t, r) => t - r), ne = () => $().map((t) => c.getRowData(t)).filter((t) => t !== void 0), J = (t, r) => {
557
- const u = o(t, r), R = new Set(D.value);
558
- R.add(u), D.value = R, d();
631
+ const u = o(t, r), R = new Set(F.value);
632
+ R.add(u), F.value = R, i();
559
633
  }, O = (t, r) => {
560
- const u = o(t, r), R = new Set(D.value);
561
- R.delete(u), D.value = R, d();
634
+ const u = o(t, r), R = new Set(F.value);
635
+ R.delete(u), F.value = R, i();
562
636
  }, re = (t, r) => {
563
637
  const u = o(t, r);
564
- D.value.has(u) ? O(t, r) : J(t, r);
565
- }, se = (t, r) => D.value.has(o(t, r)), _ = () => {
566
- h.value = /* @__PURE__ */ new Set(), D.value = /* @__PURE__ */ new Set(), d();
567
- }, b = (t, r) => {
638
+ F.value.has(u) ? O(t, r) : J(t, r);
639
+ }, se = (t, r) => F.value.has(o(t, r)), _ = () => {
640
+ h.value = /* @__PURE__ */ new Set(), F.value = /* @__PURE__ */ new Set(), i();
641
+ }, L = (t, r) => {
568
642
  const u = c.getRowCount(), R = c.getColumnCount();
569
643
  if (t < 0 || t >= u || r < 0 || r >= R) return;
570
- p.value = { row: t, column: r };
571
- const m = c.getCell(t, r);
572
- m && (m.tabIndex = 0, m.focus()), e();
644
+ H.value = { row: t, column: r };
645
+ const p = c.getCell(t, r);
646
+ p && (p.tabIndex = 0, p.focus()), e();
573
647
  }, Q = () => {
574
- p.value = null, e();
575
- }, ce = () => p.value ? { ...p.value } : null, le = (t, r) => {
576
- const u = p.value;
648
+ H.value = null, e();
649
+ }, ce = () => H.value ? { ...H.value } : null, le = (t, r) => {
650
+ const u = H.value;
577
651
  return u !== null && u.row === t && u.column === r;
578
652
  }, W = () => {
579
- const t = p.value;
580
- return !t || t.row <= 0 ? !1 : (b(t.row - 1, t.column), !0);
653
+ const t = H.value;
654
+ return !t || t.row <= 0 ? !1 : (L(t.row - 1, t.column), !0);
581
655
  }, X = () => {
582
- const t = p.value;
656
+ const t = H.value;
583
657
  if (!t) return !1;
584
658
  const r = c.getRowCount();
585
- return t.row >= r - 1 ? !1 : (b(t.row + 1, t.column), !0);
659
+ return t.row >= r - 1 ? !1 : (L(t.row + 1, t.column), !0);
586
660
  }, Y = () => {
587
- const t = p.value;
588
- return !t || t.column <= 0 ? !1 : (b(t.row, t.column - 1), !0);
661
+ const t = H.value;
662
+ return !t || t.column <= 0 ? !1 : (L(t.row, t.column - 1), !0);
589
663
  }, Z = () => {
590
- const t = p.value;
664
+ const t = H.value;
591
665
  if (!t) return !1;
592
666
  const r = c.getColumnCount();
593
- return t.column >= r - 1 ? !1 : (b(t.row, t.column + 1), !0);
667
+ return t.column >= r - 1 ? !1 : (L(t.row, t.column + 1), !0);
594
668
  }, x = () => {
595
669
  const t = c.getRowCount(), r = c.getColumnCount();
596
- t > 0 && r > 0 && b(0, 0);
670
+ t > 0 && r > 0 && L(0, 0);
597
671
  }, ee = () => {
598
672
  const t = c.getRowCount(), r = c.getColumnCount();
599
- t > 0 && r > 0 && b(t - 1, r - 1);
673
+ t > 0 && r > 0 && L(t - 1, r - 1);
600
674
  }, ae = () => {
601
675
  const t = c.element, r = (u) => {
602
- const R = p.value;
676
+ const R = H.value;
603
677
  if (!R) return;
604
- let m = !1;
678
+ let p = !1;
605
679
  switch (u.key) {
606
680
  case "ArrowUp":
607
- m = W();
681
+ p = W();
608
682
  break;
609
683
  case "ArrowDown":
610
- m = X();
684
+ p = X();
611
685
  break;
612
686
  case "ArrowLeft":
613
- m = Y();
687
+ p = Y();
614
688
  break;
615
689
  case "ArrowRight":
616
- m = Z();
690
+ p = Z();
617
691
  break;
618
692
  case "Home":
619
- u.ctrlKey ? x() : b(R.row, 0), m = !0;
693
+ u.ctrlKey ? x() : L(R.row, 0), p = !0;
620
694
  break;
621
695
  case "End":
622
696
  if (u.ctrlKey)
623
697
  ee();
624
698
  else {
625
- const M = c.getColumnCount();
626
- b(R.row, M - 1);
699
+ const P = c.getColumnCount();
700
+ L(R.row, P - 1);
627
701
  }
628
- m = !0;
702
+ p = !0;
629
703
  break;
630
704
  case "Enter":
631
705
  case " ":
632
- u.shiftKey ? G(R.row, R.row) : u.ctrlKey || u.metaKey ? g(R.row) : (B(), a(R.row)), m = !0;
706
+ u.shiftKey ? G(R.row, R.row) : u.ctrlKey || u.metaKey ? g(R.row) : (S(), a(R.row)), p = !0;
633
707
  break;
634
708
  case "Escape":
635
- _(), m = !0;
709
+ _(), p = !0;
636
710
  break;
637
711
  case "a":
638
- (u.ctrlKey || u.metaKey) && (h.value.size === c.getRowCount() ? B() : w(), m = !0);
712
+ (u.ctrlKey || u.metaKey) && (h.value.size === c.getRowCount() ? S() : f(), p = !0);
639
713
  break;
640
714
  }
641
- m && (u.preventDefault(), u.stopPropagation());
715
+ p && (u.preventDefault(), u.stopPropagation());
642
716
  };
643
717
  return t.addEventListener("keydown", r), () => {
644
718
  t.removeEventListener("keydown", r);
645
719
  };
646
720
  }, ue = (t, r) => {
647
- c.setRecords(t, r), f();
721
+ c.setRecords(t, r), w();
648
722
  }, de = (t) => c.getRecordData(t), ie = (t, r, u) => {
649
723
  const R = c.addRecord(t, r, u);
650
- return f(), R;
724
+ return w(), R;
651
725
  }, we = (t, r) => {
652
726
  const u = c.updateRecordRow(t, r);
653
- return u && f(), u;
727
+ return u && w(), u;
654
728
  }, fe = (t) => {
655
729
  const r = c.removeRecord(t);
656
- return r && f(), r;
657
- }, ge = (t) => c.hasRecord(t), Ce = () => $().map((r) => c.getRowId(r)).filter((r) => r !== void 0), Re = (t) => {
730
+ return r && w(), r;
731
+ }, ge = (t) => c.hasRecord(t), Re = () => $().map((r) => c.getRowId(r)).filter((r) => r !== void 0), Ce = (t) => {
658
732
  for (const r of t) {
659
733
  const u = c.getRowIndex(r);
660
734
  u !== -1 && a(u);
@@ -662,65 +736,65 @@ function Ct(l, C, H) {
662
736
  }, he = (t) => {
663
737
  for (const r of t) {
664
738
  const u = c.getRowIndex(r);
665
- u !== -1 && i(u);
739
+ u !== -1 && d(u);
666
740
  }
667
741
  }, ve = (t) => {
668
- c.setHeaders(t), f();
742
+ c.setHeaders(t), w();
669
743
  }, pe = (t, r) => {
670
- c.setHeader(t, r), f();
744
+ c.setHeader(t, r), w();
671
745
  }, ye = (t, r) => {
672
- c.addHeader(t, r), f();
673
- }, me = (t) => {
674
- c.removeHeader(t), f();
675
- }, He = (t, r, u) => {
746
+ c.addHeader(t, r), w();
747
+ }, He = (t) => {
748
+ c.removeHeader(t), w();
749
+ }, me = (t, r, u) => {
676
750
  const R = c.addRow(t, r, u);
677
- return f(), R;
678
- }, Fe = (t) => {
751
+ return w(), R;
752
+ }, Be = (t) => {
679
753
  const r = c.removeRow(t);
680
- return r && f(), r;
681
- }, De = (t) => {
754
+ return r && w(), r;
755
+ }, Fe = (t) => {
682
756
  const r = c.removeRowById(t);
683
- return r && f(), r;
684
- }, Be = (t, r) => {
685
- c.updateRow(t, r), f();
686
- }, Ie = (t, r) => {
687
- c.updateRowById(t, r), f();
688
- }, Te = (t, r) => {
689
- c.moveRow(t, r), f();
757
+ return r && w(), r;
690
758
  }, Se = (t, r) => {
691
- c.swapRows(t, r), f();
759
+ c.updateRow(t, r), w();
760
+ }, De = (t, r) => {
761
+ c.updateRowById(t, r), w();
762
+ }, Te = (t, r) => {
763
+ c.moveRow(t, r), w();
764
+ }, Ie = (t, r) => {
765
+ c.swapRows(t, r), w();
692
766
  }, Ee = () => {
693
- c.clearRows(), f();
767
+ c.clearRows(), w();
694
768
  }, be = (t, r, u) => {
695
- c.addColumn(t, r, u), f();
769
+ c.addColumn(t, r, u), w();
696
770
  }, Le = (t) => {
697
- c.removeColumn(t), f();
698
- }, Ue = (t, r) => {
699
- c.moveColumn(t, r), f();
771
+ c.removeColumn(t), w();
700
772
  }, Ae = (t, r) => {
701
- c.swapColumns(t, r), f();
773
+ c.moveColumn(t, r), w();
774
+ }, Ue = (t, r) => {
775
+ c.swapColumns(t, r), w();
702
776
  }, Ge = (t, r) => {
703
- c.setColumnData(t, r), f();
777
+ c.setColumnData(t, r), w();
704
778
  }, Ke = (t, r) => c.getCellValue(t, r), ke = (t, r, u) => {
705
- c.setCell(t, r, u), f();
779
+ c.setCell(t, r, u), w();
706
780
  }, Ve = (t, r, u) => {
707
- c.setCellByRowId(t, r, u), f();
781
+ c.setCellByRowId(t, r, u), w();
708
782
  }, Me = (t, r, u) => {
709
- c.setCellRange(t, r, u), f();
783
+ c.setCellRange(t, r, u), w();
710
784
  }, Ne = (t, r) => c.getCell(t, r), Pe = (t) => c.getRowData(t), je = (t) => c.getRowDataById(t), ze = (t) => c.getRow(t), $e = (t) => c.getRowById(t), _e = (t) => c.getRowId(t), qe = (t) => c.getRowIndex(t), Je = (t) => c.getColumnData(t), Oe = (t) => {
711
- c.setFooter(t), f();
785
+ c.setFooter(t), w();
712
786
  }, Qe = (t, r) => {
713
- c.setFooterCell(t, r), f();
787
+ c.setFooterCell(t, r), w();
714
788
  }, We = (t) => c.getFooterCell(t), Xe = () => {
715
- c.clearFooter(), f();
789
+ c.clearFooter(), w();
716
790
  }, Ye = (t) => {
717
- c.setCaption(t), f();
791
+ c.setCaption(t), w();
718
792
  }, Ze = (t) => {
719
- c.setData(t), f();
793
+ c.setData(t), w();
720
794
  }, xe = () => {
721
- c.reset(), _(), Q(), f();
795
+ c.reset(), _(), Q(), w();
722
796
  }, et = () => {
723
- c.sync(), f();
797
+ c.sync(), w();
724
798
  }, tt = (t) => c.onRowAdd(t), ot = (t) => c.onRowRemove(t), nt = (t) => c.onRowUpdate(t), rt = (t) => c.onCellChange(t), st = (t) => c.onHeaderChange(t), ct = (t) => c.onDataChange(t), lt = (t) => (I.add(t), () => I.delete(t)), at = (t) => (E.add(t), () => E.delete(t)), te = () => {
725
799
  n(), s(), I.clear(), E.clear(), c.destroy();
726
800
  };
@@ -731,56 +805,94 @@ function Ct(l, C, H) {
731
805
  instance: c,
732
806
  // Reactive state
733
807
  element: v,
734
- headers: P,
735
- data: j,
808
+ headers: V,
809
+ data: M,
736
810
  rowCount: z,
737
- columnCount: V,
738
- rowIds: T,
811
+ columnCount: N,
812
+ rowIds: D,
739
813
  footerData: y,
740
- captionText: L,
741
- version: F,
814
+ captionText: b,
815
+ version: B,
742
816
  // Selection state
743
817
  selection: {
744
818
  rows: h,
745
- cells: D
819
+ cells: F
746
820
  },
747
821
  // Focus state
748
822
  focus: {
749
- cell: p
823
+ cell: H
750
824
  },
751
825
  // Structure methods
752
826
  createCaption: () => c.createCaption(),
753
827
  deleteCaption: () => {
754
- c.deleteCaption(), f();
828
+ c.deleteCaption(), w();
755
829
  },
756
830
  createTHead: () => c.createTHead(),
757
831
  deleteTHead: () => {
758
- c.deleteTHead(), f();
832
+ c.deleteTHead(), w();
759
833
  },
760
834
  createTFoot: () => c.createTFoot(),
761
835
  deleteTFoot: () => {
762
- c.deleteTFoot(), f();
836
+ c.deleteTFoot(), w();
763
837
  },
764
838
  createTBody: () => c.createTBody(),
839
+ // Section-specific row methods
840
+ getSectionRows: (t) => c.getSectionRows(t),
841
+ insertSectionRow: (t, r, u, R) => {
842
+ const p = c.insertSectionRow(t, r, u, R);
843
+ return w(), p;
844
+ },
845
+ deleteSectionRow: (t, r) => {
846
+ const u = c.deleteSectionRow(t, r);
847
+ return u && w(), u;
848
+ },
849
+ getSectionRowCount: (t) => c.getSectionRowCount(t),
850
+ addHeadRow: (t, r) => {
851
+ const u = c.addHeadRow(t, r);
852
+ return w(), u;
853
+ },
854
+ removeHeadRow: (t) => {
855
+ const r = c.removeHeadRow(t);
856
+ return r && w(), r;
857
+ },
858
+ getHeadRowCount: () => c.getHeadRowCount(),
859
+ addFootRow: (t, r) => {
860
+ const u = c.addFootRow(t, r);
861
+ return w(), u;
862
+ },
863
+ removeFootRow: (t) => {
864
+ const r = c.removeFootRow(t);
865
+ return r && w(), r;
866
+ },
867
+ getFootRowCount: () => c.getFootRowCount(),
868
+ addBodyRow: (t, r, u, R) => {
869
+ const p = c.addBodyRow(t, r, u, R);
870
+ return w(), p;
871
+ },
872
+ removeBodyRow: (t, r) => {
873
+ const u = c.removeBodyRow(t, r);
874
+ return u && w(), u;
875
+ },
876
+ getBodyRowCount: (t) => c.getBodyRowCount(t),
765
877
  // Header methods
766
878
  setHeaders: ve,
767
879
  setHeader: pe,
768
880
  addHeader: ye,
769
- removeHeader: me,
881
+ removeHeader: He,
770
882
  // Row methods
771
- addRow: He,
772
- removeRow: Fe,
773
- removeRowById: De,
774
- updateRow: Be,
775
- updateRowById: Ie,
883
+ addRow: me,
884
+ removeRow: Be,
885
+ removeRowById: Fe,
886
+ updateRow: Se,
887
+ updateRowById: De,
776
888
  moveRow: Te,
777
- swapRows: Se,
889
+ swapRows: Ie,
778
890
  clearRows: Ee,
779
891
  // Column methods
780
892
  addColumn: be,
781
893
  removeColumn: Le,
782
- moveColumn: Ue,
783
- swapColumns: Ae,
894
+ moveColumn: Ae,
895
+ swapColumns: Ue,
784
896
  setColumnData: Ge,
785
897
  // Cell methods
786
898
  getCell: Ke,
@@ -809,10 +921,10 @@ function Ct(l, C, H) {
809
921
  sync: et,
810
922
  // Selection methods
811
923
  selectRow: a,
812
- deselectRow: i,
924
+ deselectRow: d,
813
925
  toggleRowSelection: g,
814
- selectAllRows: w,
815
- deselectAllRows: B,
926
+ selectAllRows: f,
927
+ deselectAllRows: S,
816
928
  selectRowRange: G,
817
929
  isRowSelected: K,
818
930
  getSelectedRowIndices: $,
@@ -823,7 +935,7 @@ function Ct(l, C, H) {
823
935
  isCellSelected: se,
824
936
  clearSelection: _,
825
937
  // Focus methods
826
- focusCell: b,
938
+ focusCell: L,
827
939
  clearFocus: Q,
828
940
  getFocusedCell: ce,
829
941
  isCellFocused: le,
@@ -841,8 +953,8 @@ function Ct(l, C, H) {
841
953
  updateRecordRow: we,
842
954
  removeRecord: fe,
843
955
  hasRecord: ge,
844
- getSelectedRecordIds: Ce,
845
- selectRecords: Re,
956
+ getSelectedRecordIds: Re,
957
+ selectRecords: Ce,
846
958
  deselectRecords: he,
847
959
  // ID generator
848
960
  setIdGenerator: (t) => c.setIdGenerator(t),
@@ -864,7 +976,7 @@ const q = /* @__PURE__ */ Symbol("idGenerated");
864
976
  function wt() {
865
977
  return crypto.randomUUID();
866
978
  }
867
- function Rt(l, C = wt) {
979
+ function Ct(l, C = wt) {
868
980
  return "id" in l && typeof l.id == "string" && l.id.length > 0 ? l : {
869
981
  ...l,
870
982
  id: C(),
@@ -878,26 +990,26 @@ function ht(l) {
878
990
  return typeof l == "string" && l.length > 0;
879
991
  }
880
992
  function vt(l, C) {
881
- return l.find((H) => H.id === C);
993
+ return l.find((m) => m.id === C);
882
994
  }
883
995
  function pt(l, C) {
884
- return l.findIndex((H) => H.id === C);
996
+ return l.findIndex((m) => m.id === C);
885
997
  }
886
998
  function yt(l) {
887
999
  if (!ft(l))
888
1000
  return l;
889
- const { id: C, ...H } = l;
890
- return H;
1001
+ const { id: C, ...m } = l;
1002
+ return m;
891
1003
  }
892
1004
  export {
893
1005
  q as ID_GENERATED,
894
1006
  it as createTable,
895
- Rt as ensureId,
1007
+ Ct as ensureId,
896
1008
  vt as findById,
897
1009
  wt as generateId,
898
1010
  pt as indexById,
899
1011
  ht as isValidId,
900
1012
  yt as stripGeneratedId,
901
- Ct as useTable,
1013
+ Rt as useTable,
902
1014
  ft as wasIdGenerated
903
1015
  };
@@ -1 +1 @@
1
- (function(m,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],p):(m=typeof globalThis<"u"?globalThis:m||self,p(m.useTable={},m.Vue))})(this,(function(m,p){"use strict";function ce(){return crypto.randomUUID()}function S(l,C){l.textContent="",C!=null&&(C instanceof Node?l.appendChild(C):l.textContent=String(C))}function U(l){return l.childNodes.length===1&&l.firstChild instanceof HTMLElement?l.firstChild:l.textContent??""}function O(l){const C=document.createElement("th");return C.scope="col",C.textContent=l,C}function J(l,C,D){let c=D?.idGenerator??ce;const F=new Set,f=new Set,h=new Set,T=new Set,y=new Set,E=new Set;function L(){const e=l.tBodies;return e.length>0?e[0]:l.createTBody()}function v(){const e=[],o=l.tBodies;for(let n=0;n<o.length;n++){const s=o[n];for(let a=0;a<s.rows.length;a++)e.push(s.rows[a])}return e}function P(e,o,n){F.forEach(s=>s(e,o,n)),I()}function z(e,o,n){f.forEach(s=>s(e,o,n)),I()}function _(e,o,n,s){h.forEach(a=>a(e,o,n,s)),I()}function N(e,o,n,s){T.forEach(a=>a(e,o,n,s)),I()}function b(){const e=u.getHeaders();y.forEach(o=>o(e))}function I(){if(E.size>0){const e=u.getData();E.forEach(o=>o(e))}}function A(e){const o=[];for(let n=0;n<e.cells.length;n++)o.push(U(e.cells[n]));return o}const u={element:l,getCaption(){return l.caption},getTHead(){return l.tHead},getTFoot(){return l.tFoot},getTBodies(){return l.tBodies},getPrimaryTBody(){return L()},getBodyRows(){return v()},getRow(e){return v()[e]},getRowById(e){const o=v();for(const n of o)if(n.dataset.id===e)return n},getCell(e,o){const n=u.getRow(e);if(n)return n.cells[o]},getCellByRowId(e,o){const n=u.getRowById(e);if(n)return n.cells[o]},getHeaders(){const e=l.tHead;if(!e||e.rows.length===0)return[];const o=e.rows[0],n=[];for(let s=0;s<o.cells.length;s++)n.push(o.cells[s].textContent??"");return n},getHeader(e){return u.getHeaders()[e]},getData(){return v().map(A)},getRowData(e){const o=u.getRow(e);if(o)return A(o)},getRowDataById(e){const o=u.getRowById(e);if(o)return A(o)},getCellValue(e,o){const n=u.getCell(e,o);if(n)return U(n)},getColumnData(e){return v().map(n=>{const s=n.cells[e];return s?U(s):void 0})},getFooterData(){const e=l.tFoot;if(!(!e||e.rows.length===0))return A(e.rows[0])},getRowCount(){return v().length},getColumnCount(){const e=u.getHeaders();if(e.length>0)return e.length;const o=v();return o.length>0?o[0].cells.length:0},getRowId(e){return u.getRow(e)?.dataset.id},getRowIndex(e){const o=v();for(let n=0;n<o.length;n++)if(o[n].dataset.id===e)return n;return-1},getAllRowIds(){const e=v(),o=[];for(const n of e)n.dataset.id&&o.push(n.dataset.id);return o},createCaption(){return l.createCaption()},deleteCaption(){l.deleteCaption()},createTHead(){return l.createTHead()},deleteTHead(){l.deleteTHead(),b()},createTFoot(){return l.createTFoot()},deleteTFoot(){l.deleteTFoot()},createTBody(){return l.createTBody()},setHeaders(e){let o=l.tHead;for(o||(o=l.createTHead());o.rows.length>0;)o.deleteRow(0);const n=o.insertRow();for(const s of e)n.appendChild(O(s));b()},setHeader(e,o){const n=l.tHead;if(!n||n.rows.length===0)return;const s=n.rows[0].cells[e];s&&(s.textContent=o,b())},addHeader(e,o){let n=l.tHead;n||(n=l.createTHead(),n.insertRow()),n.rows.length===0&&n.insertRow();const s=n.rows[0],a=O(e);o===void 0||o>=s.cells.length?s.appendChild(a):s.insertBefore(a,s.cells[o]),b()},removeHeader(e){const o=l.tHead;if(!o||o.rows.length===0)return;const n=o.rows[0];e>=0&&e<n.cells.length&&(n.deleteCell(e),b())},addRow(e,o,n){const s=L(),a=o??s.rows.length,i=s.insertRow(a),g=n??c();i.dataset.id=g;for(const w of e){const B=i.insertCell();S(B,w)}return P([...e],a,g),i},removeRow(e){const o=v();if(e<0||e>=o.length)return;const n=o[e],s=A(n),a=n.dataset.id;return n.remove(),z(s,e,a),s},removeRowById(e){const o=u.getRowIndex(e);if(o!==-1)return u.removeRow(o)},updateRow(e,o){const n=u.getRow(e);if(!n)return;const s=A(n),a=n.dataset.id;for(let i=0;i<o.length;i++){let g=n.cells[i];g||(g=n.insertCell()),S(g,o[i])}for(;n.cells.length>o.length;)n.deleteCell(n.cells.length-1);_(e,s,[...o],a)},updateRowById(e,o){const n=u.getRowIndex(e);n!==-1&&u.updateRow(n,o)},moveRow(e,o){const n=v();if(e<0||e>=n.length||o<0||o>=n.length||e===o)return;const s=n[e],a=s.parentElement;if(o>e){const i=n[o];a.insertBefore(s,i.nextSibling)}else{const i=n[o];a.insertBefore(s,i)}I()},swapRows(e,o){const n=v();if(e<0||e>=n.length||o<0||o>=n.length||e===o)return;const s=n[e],a=n[o],i=s.parentElement,g=document.createElement("tr");i.insertBefore(g,s),i.insertBefore(s,a),i.insertBefore(a,g),g.remove(),I()},clearRows(){const e=l.tBodies;for(let o=0;o<e.length;o++){const n=e[o];for(;n.rows.length>0;)n.deleteRow(0)}I()},addColumn(e,o,n){u.addHeader(e,n);const s=v();for(const i of s){const g=i.insertCell(n??i.cells.length);S(g,o??"")}const a=l.tFoot;if(a&&a.rows.length>0){const i=a.rows[0],g=i.insertCell(n??i.cells.length);S(g,"")}I()},removeColumn(e){u.removeHeader(e);const o=v();for(const s of o)e>=0&&e<s.cells.length&&s.deleteCell(e);const n=l.tFoot;if(n&&n.rows.length>0){const s=n.rows[0];e>=0&&e<s.cells.length&&s.deleteCell(e)}I()},moveColumn(e,o){const n=u.getColumnCount();if(e<0||e>=n||o<0||o>=n||e===o)return;const s=w=>{if(e>=w.cells.length)return;const B=w.cells[e];o>=w.cells.length?w.appendChild(B):o>e?w.insertBefore(B,w.cells[o+1]):w.insertBefore(B,w.cells[o])},a=l.tHead;if(a)for(let w=0;w<a.rows.length;w++)s(a.rows[w]);const i=v();for(const w of i)s(w);const g=l.tFoot;if(g)for(let w=0;w<g.rows.length;w++)s(g.rows[w]);b(),I()},swapColumns(e,o){const n=u.getColumnCount();if(e<0||e>=n||o<0||o>=n||e===o)return;const s=w=>{if(e>=w.cells.length||o>=w.cells.length)return;const B=w.cells[e],K=w.cells[o],V=document.createElement("td");w.insertBefore(V,B),w.insertBefore(B,K),w.insertBefore(K,V),V.remove()},a=l.tHead;if(a)for(let w=0;w<a.rows.length;w++)s(a.rows[w]);const i=v();for(const w of i)s(w);const g=l.tFoot;if(g)for(let w=0;w<g.rows.length;w++)s(g.rows[w]);b(),I()},setColumnData(e,o){const n=v();for(let s=0;s<n.length&&s<o.length;s++){const a=n[s].cells[e];if(a){const i=U(a);S(a,o[s]),i!==o[s]&&N(s,e,i,o[s])}}},setCell(e,o,n){const s=u.getCell(e,o);if(!s)return;const a=U(s);S(s,n),N(e,o,a,n)},setCellByRowId(e,o,n){const s=u.getRowIndex(e);s!==-1&&u.setCell(s,o,n)},setCellRange(e,o,n){for(let s=0;s<n.length;s++){const a=n[s];for(let i=0;i<a.length;i++)u.setCell(e+s,o+i,a[i])}},setFooter(e){let o=l.tFoot;for(o||(o=l.createTFoot());o.rows.length>0;)o.deleteRow(0);const n=o.insertRow();for(const s of e){const a=n.insertCell();S(a,s)}},setFooterCell(e,o){const n=l.tFoot;if(!n||n.rows.length===0)return;const s=n.rows[0].cells[e];s&&S(s,o)},getFooterCell(e){const o=l.tFoot;if(!o||o.rows.length===0)return;const n=o.rows[0].cells[e];return n?U(n):void 0},clearFooter(){const e=l.tFoot;if(e)for(;e.rows.length>0;)e.deleteRow(0)},setCaption(e){const o=l.createCaption();o.textContent=e},getCaptionText(){return l.caption?.textContent??void 0},setData(e){u.clearRows();const o=L();for(const n of e){const s=o.insertRow();s.dataset.id=c();for(const a of n){const i=s.insertCell();S(i,a)}}I()},reset(){for(l.deleteCaption(),l.deleteTHead(),l.deleteTFoot();l.tBodies.length>0;)l.removeChild(l.tBodies[0]);b(),I()},sync(){const e=v();for(const o of e)o.dataset.id||(o.dataset.id=c())},setRecords(e,o){u.clearRows();const n=L();for(const s of e){const a=n.insertRow();a.dataset.id=s.id;for(const i of o){const g=a.insertCell(),w=typeof i=="function"?i(s):s[i];S(g,w)}}I()},getRecordData(e){return u.getRowDataById(e)},addRecord(e,o,n){const s="id"in e&&typeof e.id=="string"&&e.id.length>0?e.id:c(),a={...e,id:s},i=o.map(g=>typeof g=="function"?g(a):a[g]);return u.addRow(i,n,s),s},updateRecordRow(e,o){const n=u.getRowIndex(e);return n===-1?!1:(u.updateRow(n,o),!0)},removeRecord(e){return u.removeRowById(e)!==void 0},hasRecord(e){return u.getRowIndex(e)!==-1},setIdGenerator(e){c=e},generateId(){return c()},onRowAdd(e){return F.add(e),()=>F.delete(e)},onRowRemove(e){return f.add(e),()=>f.delete(e)},onRowUpdate(e){return h.add(e),()=>h.delete(e)},onCellChange(e){return T.add(e),()=>T.delete(e)},onHeaderChange(e){return y.add(e),()=>y.delete(e)},onDataChange(e){return E.add(e),()=>E.delete(e)},destroy(){F.clear(),f.clear(),h.clear(),T.clear(),y.clear(),E.clear()}};return D?.caption&&u.setCaption(D.caption),D?.headers&&u.setHeaders(D.headers),C&&u.setData(C),D?.footer&&u.setFooter(D.footer),u.sync(),u}function le(l,C,D){const c=J(l.value,C,D),F=p.ref(0),f=()=>{F.value++},h=p.ref(new Set),T=p.ref(new Set),y=p.ref(null),E=new Set,L=new Set,v=p.computed(()=>(F.value,c.element)),P=p.computed(()=>(F.value,c.getHeaders())),z=p.computed(()=>(F.value,c.getData())),_=p.computed(()=>(F.value,c.getRowCount())),N=p.computed(()=>(F.value,c.getColumnCount())),b=p.computed(()=>(F.value,c.getAllRowIds())),I=p.computed(()=>(F.value,c.getFooterData())),A=p.computed(()=>(F.value,c.getCaptionText())),u=()=>{E.forEach(t=>t(h.value,T.value))},e=()=>{L.forEach(t=>t(y.value))},o=(t,r)=>`${t},${r}`,n=c.onDataChange(()=>f()),s=c.onHeaderChange(()=>f()),a=t=>{if(t<0||t>=c.getRowCount())return;const r=new Set(h.value);r.add(t),h.value=r,u()},i=t=>{const r=new Set(h.value);r.delete(t),h.value=r,u()},g=t=>{h.value.has(t)?i(t):a(t)},w=()=>{const t=c.getRowCount(),r=new Set;for(let d=0;d<t;d++)r.add(d);h.value=r,u()},B=()=>{h.value=new Set,u()},K=(t,r)=>{const d=Math.min(t,r),R=Math.max(t,r),H=c.getRowCount(),j=new Set(h.value);for(let k=d;k<=R&&k<H;k++)k>=0&&j.add(k);h.value=j,u()},V=t=>h.value.has(t),$=()=>Array.from(h.value).sort((t,r)=>t-r),fe=()=>$().map(t=>c.getRowData(t)).filter(t=>t!==void 0),X=(t,r)=>{const d=o(t,r),R=new Set(T.value);R.add(d),T.value=R,u()},Y=(t,r)=>{const d=o(t,r),R=new Set(T.value);R.delete(d),T.value=R,u()},ge=(t,r)=>{const d=o(t,r);T.value.has(d)?Y(t,r):X(t,r)},Ce=(t,r)=>T.value.has(o(t,r)),q=()=>{h.value=new Set,T.value=new Set,u()},G=(t,r)=>{const d=c.getRowCount(),R=c.getColumnCount();if(t<0||t>=d||r<0||r>=R)return;y.value={row:t,column:r};const H=c.getCell(t,r);H&&(H.tabIndex=0,H.focus()),e()},Z=()=>{y.value=null,e()},Re=()=>y.value?{...y.value}:null,he=(t,r)=>{const d=y.value;return d!==null&&d.row===t&&d.column===r},x=()=>{const t=y.value;return!t||t.row<=0?!1:(G(t.row-1,t.column),!0)},ee=()=>{const t=y.value;if(!t)return!1;const r=c.getRowCount();return t.row>=r-1?!1:(G(t.row+1,t.column),!0)},te=()=>{const t=y.value;return!t||t.column<=0?!1:(G(t.row,t.column-1),!0)},oe=()=>{const t=y.value;if(!t)return!1;const r=c.getColumnCount();return t.column>=r-1?!1:(G(t.row,t.column+1),!0)},ne=()=>{const t=c.getRowCount(),r=c.getColumnCount();t>0&&r>0&&G(0,0)},re=()=>{const t=c.getRowCount(),r=c.getColumnCount();t>0&&r>0&&G(t-1,r-1)},ve=()=>{const t=c.element,r=d=>{const R=y.value;if(!R)return;let H=!1;switch(d.key){case"ArrowUp":H=x();break;case"ArrowDown":H=ee();break;case"ArrowLeft":H=te();break;case"ArrowRight":H=oe();break;case"Home":d.ctrlKey?ne():G(R.row,0),H=!0;break;case"End":if(d.ctrlKey)re();else{const j=c.getColumnCount();G(R.row,j-1)}H=!0;break;case"Enter":case" ":d.shiftKey?K(R.row,R.row):d.ctrlKey||d.metaKey?g(R.row):(B(),a(R.row)),H=!0;break;case"Escape":q(),H=!0;break;case"a":(d.ctrlKey||d.metaKey)&&(h.value.size===c.getRowCount()?B():w(),H=!0);break}H&&(d.preventDefault(),d.stopPropagation())};return t.addEventListener("keydown",r),()=>{t.removeEventListener("keydown",r)}},pe=(t,r)=>{c.setRecords(t,r),f()},ye=t=>c.getRecordData(t),me=(t,r,d)=>{const R=c.addRecord(t,r,d);return f(),R},Ie=(t,r)=>{const d=c.updateRecordRow(t,r);return d&&f(),d},He=t=>{const r=c.removeRecord(t);return r&&f(),r},De=t=>c.hasRecord(t),Fe=()=>$().map(r=>c.getRowId(r)).filter(r=>r!==void 0),Te=t=>{for(const r of t){const d=c.getRowIndex(r);d!==-1&&a(d)}},Be=t=>{for(const r of t){const d=c.getRowIndex(r);d!==-1&&i(d)}},Se=t=>{c.setHeaders(t),f()},Ee=(t,r)=>{c.setHeader(t,r),f()},be=(t,r)=>{c.addHeader(t,r),f()},Le=t=>{c.removeHeader(t),f()},Ge=(t,r,d)=>{const R=c.addRow(t,r,d);return f(),R},Ae=t=>{const r=c.removeRow(t);return r&&f(),r},Ue=t=>{const r=c.removeRowById(t);return r&&f(),r},Ke=(t,r)=>{c.updateRow(t,r),f()},Ve=(t,r)=>{c.updateRowById(t,r),f()},ke=(t,r)=>{c.moveRow(t,r),f()},Me=(t,r)=>{c.swapRows(t,r),f()},Ne=()=>{c.clearRows(),f()},je=(t,r,d)=>{c.addColumn(t,r,d),f()},Pe=t=>{c.removeColumn(t),f()},ze=(t,r)=>{c.moveColumn(t,r),f()},_e=(t,r)=>{c.swapColumns(t,r),f()},$e=(t,r)=>{c.setColumnData(t,r),f()},qe=(t,r)=>c.getCellValue(t,r),Oe=(t,r,d)=>{c.setCell(t,r,d),f()},Je=(t,r,d)=>{c.setCellByRowId(t,r,d),f()},Qe=(t,r,d)=>{c.setCellRange(t,r,d),f()},We=(t,r)=>c.getCell(t,r),Xe=t=>c.getRowData(t),Ye=t=>c.getRowDataById(t),Ze=t=>c.getRow(t),xe=t=>c.getRowById(t),et=t=>c.getRowId(t),tt=t=>c.getRowIndex(t),ot=t=>c.getColumnData(t),nt=t=>{c.setFooter(t),f()},rt=(t,r)=>{c.setFooterCell(t,r),f()},st=t=>c.getFooterCell(t),ct=()=>{c.clearFooter(),f()},lt=t=>{c.setCaption(t),f()},at=t=>{c.setData(t),f()},dt=()=>{c.reset(),q(),Z(),f()},ut=()=>{c.sync(),f()},it=t=>c.onRowAdd(t),wt=t=>c.onRowRemove(t),ft=t=>c.onRowUpdate(t),gt=t=>c.onCellChange(t),Ct=t=>c.onHeaderChange(t),Rt=t=>c.onDataChange(t),ht=t=>(E.add(t),()=>E.delete(t)),vt=t=>(L.add(t),()=>L.delete(t)),se=()=>{n(),s(),E.clear(),L.clear(),c.destroy()};return p.onUnmounted(()=>{se()}),{instance:c,element:v,headers:P,data:z,rowCount:_,columnCount:N,rowIds:b,footerData:I,captionText:A,version:F,selection:{rows:h,cells:T},focus:{cell:y},createCaption:()=>c.createCaption(),deleteCaption:()=>{c.deleteCaption(),f()},createTHead:()=>c.createTHead(),deleteTHead:()=>{c.deleteTHead(),f()},createTFoot:()=>c.createTFoot(),deleteTFoot:()=>{c.deleteTFoot(),f()},createTBody:()=>c.createTBody(),setHeaders:Se,setHeader:Ee,addHeader:be,removeHeader:Le,addRow:Ge,removeRow:Ae,removeRowById:Ue,updateRow:Ke,updateRowById:Ve,moveRow:ke,swapRows:Me,clearRows:Ne,addColumn:je,removeColumn:Pe,moveColumn:ze,swapColumns:_e,setColumnData:$e,getCell:qe,setCell:Oe,setCellByRowId:Je,setCellRange:Qe,getCellElement:We,getRowData:Xe,getRowDataById:Ye,getRowElement:Ze,getRowById:xe,getRowId:et,getRowIndex:tt,getColumnData:ot,setFooter:nt,setFooterCell:rt,getFooterCell:st,clearFooter:ct,setCaption:lt,setData:at,reset:dt,sync:ut,selectRow:a,deselectRow:i,toggleRowSelection:g,selectAllRows:w,deselectAllRows:B,selectRowRange:K,isRowSelected:V,getSelectedRowIndices:$,getSelectedRowData:fe,selectCell:X,deselectCell:Y,toggleCellSelection:ge,isCellSelected:Ce,clearSelection:q,focusCell:G,clearFocus:Z,getFocusedCell:Re,isCellFocused:he,moveFocusUp:x,moveFocusDown:ee,moveFocusLeft:te,moveFocusRight:oe,moveFocusToFirst:ne,moveFocusToLast:re,enableKeyboardNavigation:ve,setRecords:pe,getRecordData:ye,addRecord:me,updateRecordRow:Ie,removeRecord:He,hasRecord:De,getSelectedRecordIds:Fe,selectRecords:Te,deselectRecords:Be,setIdGenerator:t=>c.setIdGenerator(t),generateId:()=>c.generateId(),onRowAdd:it,onRowRemove:wt,onRowUpdate:ft,onCellChange:gt,onHeaderChange:Ct,onDataChange:Rt,onSelectionChange:ht,onFocusChange:vt,destroy:se}}const M=Symbol("idGenerated");function Q(){return crypto.randomUUID()}function ae(l,C=Q){return"id"in l&&typeof l.id=="string"&&l.id.length>0?l:{...l,id:C(),[M]:!0}}function W(l){return M in l&&l[M]===!0}function de(l){return typeof l=="string"&&l.length>0}function ue(l,C){return l.find(D=>D.id===C)}function ie(l,C){return l.findIndex(D=>D.id===C)}function we(l){if(!W(l))return l;const{id:C,...D}=l;return D}m.ID_GENERATED=M,m.createTable=J,m.ensureId=ae,m.findById=ue,m.generateId=Q,m.indexById=ie,m.isValidId=de,m.stripGeneratedId=we,m.useTable=le,m.wasIdGenerated=W,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(H,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],m):(H=typeof globalThis<"u"?globalThis:H||self,m(H.useTable={},H.Vue))})(this,(function(H,m){"use strict";function ce(){return crypto.randomUUID()}function I(l,C){l.textContent="",C!=null&&(C instanceof Node?l.appendChild(C):l.textContent=String(C))}function U(l){return l.childNodes.length===1&&l.firstChild instanceof HTMLElement?l.firstChild:l.textContent??""}function O(l){const C=document.createElement("th");return C.scope="col",C.textContent=l,C}function J(l,C,F){let c=F?.idGenerator??ce;const S=new Set,w=new Set,h=new Set,D=new Set,B=new Set,b=new Set;function A(){const e=l.tBodies;return e.length>0?e[0]:l.createTBody()}function v(){const e=[],o=l.tBodies;for(let n=0;n<o.length;n++){const s=o[n];for(let a=0;a<s.rows.length;a++)e.push(s.rows[a])}return e}function N(e,o,n){S.forEach(s=>s(e,o,n)),y()}function j(e,o,n){w.forEach(s=>s(e,o,n)),y()}function _(e,o,n,s){h.forEach(a=>a(e,o,n,s)),y()}function P(e,o,n,s){D.forEach(a=>a(e,o,n,s)),y()}function E(){const e=i.getHeaders();B.forEach(o=>o(e))}function y(){if(b.size>0){const e=i.getData();b.forEach(o=>o(e))}}function L(e){const o=[];for(let n=0;n<e.cells.length;n++)o.push(U(e.cells[n]));return o}const i={element:l,getCaption(){return l.caption},getTHead(){return l.tHead},getTFoot(){return l.tFoot},getTBodies(){return l.tBodies},getPrimaryTBody(){return A()},getBodyRows(){return v()},getRow(e){return v()[e]},getRowById(e){const o=v();for(const n of o)if(n.dataset.id===e)return n},getCell(e,o){const n=i.getRow(e);if(n)return n.cells[o]},getCellByRowId(e,o){const n=i.getRowById(e);if(n)return n.cells[o]},getHeaders(){const e=l.tHead;if(!e||e.rows.length===0)return[];const o=e.rows[0],n=[];for(let s=0;s<o.cells.length;s++)n.push(o.cells[s].textContent??"");return n},getHeader(e){return i.getHeaders()[e]},getData(){return v().map(L)},getRowData(e){const o=i.getRow(e);if(o)return L(o)},getRowDataById(e){const o=i.getRowById(e);if(o)return L(o)},getCellValue(e,o){const n=i.getCell(e,o);if(n)return U(n)},getColumnData(e){return v().map(n=>{const s=n.cells[e];return s?U(s):void 0})},getFooterData(){const e=l.tFoot;if(!(!e||e.rows.length===0))return L(e.rows[0])},getRowCount(){return v().length},getColumnCount(){const e=i.getHeaders();if(e.length>0)return e.length;const o=v();return o.length>0?o[0].cells.length:0},getRowId(e){return i.getRow(e)?.dataset.id},getRowIndex(e){const o=v();for(let n=0;n<o.length;n++)if(o[n].dataset.id===e)return n;return-1},getAllRowIds(){const e=v(),o=[];for(const n of e)n.dataset.id&&o.push(n.dataset.id);return o},createCaption(){return l.createCaption()},deleteCaption(){l.deleteCaption()},createTHead(){return l.createTHead()},deleteTHead(){l.deleteTHead(),E()},createTFoot(){return l.createTFoot()},deleteTFoot(){l.deleteTFoot()},createTBody(){return l.createTBody()},getSectionRows(e){return e.rows},insertSectionRow(e,o,n,s){const a=n??e.rows.length,u=e.insertRow(a);s?u.dataset.id=s:e===l.tBodies[0]&&(u.dataset.id=c());for(const g of o){const f=u.insertCell();I(f,g)}return l.tBodies&&Array.from(l.tBodies).includes(e)&&N([...o],a,u.dataset.id),u},deleteSectionRow(e,o){if(o<0||o>=e.rows.length)return;const n=e.rows[o],s=L(n),a=n.dataset.id;return e.deleteRow(o),l.tBodies&&Array.from(l.tBodies).includes(e)&&j(s,o,a),s},getSectionRowCount(e){return e.rows.length},addHeadRow(e,o){let n=l.tHead;return n||(n=l.createTHead()),i.insertSectionRow(n,e,o)},removeHeadRow(e){const o=l.tHead;if(!o)return;const n=i.deleteSectionRow(o,e);return n&&E(),n},getHeadRowCount(){const e=l.tHead;return e?e.rows.length:0},addFootRow(e,o){let n=l.tFoot;n||(n=l.createTFoot());const s=i.insertSectionRow(n,e,o);return y(),s},removeFootRow(e){const o=l.tFoot;if(!o)return;const n=i.deleteSectionRow(o,e);return n&&y(),n},getFootRowCount(){const e=l.tFoot;return e?e.rows.length:0},addBodyRow(e,o,n,s){const a=l.tBodies;let u;return o!==void 0&&o>=0&&o<a.length?u=a[o]:u=A(),i.insertSectionRow(u,e,n,s)},removeBodyRow(e,o){const n=l.tBodies;if(n.length===0)return;let s;return o!==void 0&&o>=0&&o<n.length?s=n[o]:s=n[0],i.deleteSectionRow(s,e)},getBodyRowCount(e){const o=l.tBodies;if(o.length===0)return 0;if(e!==void 0&&e>=0&&e<o.length)return o[e].rows.length;let n=0;for(let s=0;s<o.length;s++)n+=o[s].rows.length;return n},setHeaders(e){let o=l.tHead;for(o||(o=l.createTHead());o.rows.length>0;)o.deleteRow(0);const n=o.insertRow();for(const s of e)n.appendChild(O(s));E()},setHeader(e,o){const n=l.tHead;if(!n||n.rows.length===0)return;const s=n.rows[0].cells[e];s&&(s.textContent=o,E())},addHeader(e,o){let n=l.tHead;n||(n=l.createTHead(),n.insertRow()),n.rows.length===0&&n.insertRow();const s=n.rows[0],a=O(e);o===void 0||o>=s.cells.length?s.appendChild(a):s.insertBefore(a,s.cells[o]),E()},removeHeader(e){const o=l.tHead;if(!o||o.rows.length===0)return;const n=o.rows[0];e>=0&&e<n.cells.length&&(n.deleteCell(e),E())},addRow(e,o,n){const s=A(),a=o??s.rows.length,u=s.insertRow(a),g=n??c();u.dataset.id=g;for(const f of e){const T=u.insertCell();I(T,f)}return N([...e],a,g),u},removeRow(e){const o=v();if(e<0||e>=o.length)return;const n=o[e],s=L(n),a=n.dataset.id;return n.remove(),j(s,e,a),s},removeRowById(e){const o=i.getRowIndex(e);if(o!==-1)return i.removeRow(o)},updateRow(e,o){const n=i.getRow(e);if(!n)return;const s=L(n),a=n.dataset.id;for(let u=0;u<o.length;u++){let g=n.cells[u];g||(g=n.insertCell()),I(g,o[u])}for(;n.cells.length>o.length;)n.deleteCell(n.cells.length-1);_(e,s,[...o],a)},updateRowById(e,o){const n=i.getRowIndex(e);n!==-1&&i.updateRow(n,o)},moveRow(e,o){const n=v();if(e<0||e>=n.length||o<0||o>=n.length||e===o)return;const s=n[e],a=s.parentElement;if(o>e){const u=n[o];a.insertBefore(s,u.nextSibling)}else{const u=n[o];a.insertBefore(s,u)}y()},swapRows(e,o){const n=v();if(e<0||e>=n.length||o<0||o>=n.length||e===o)return;const s=n[e],a=n[o],u=s.parentElement,g=document.createElement("tr");u.insertBefore(g,s),u.insertBefore(s,a),u.insertBefore(a,g),g.remove(),y()},clearRows(){const e=l.tBodies;for(let o=0;o<e.length;o++){const n=e[o];for(;n.rows.length>0;)n.deleteRow(0)}y()},addColumn(e,o,n){i.addHeader(e,n);const s=v();for(const u of s){const g=u.insertCell(n??u.cells.length);I(g,o??"")}const a=l.tFoot;if(a&&a.rows.length>0){const u=a.rows[0],g=u.insertCell(n??u.cells.length);I(g,"")}y()},removeColumn(e){i.removeHeader(e);const o=v();for(const s of o)e>=0&&e<s.cells.length&&s.deleteCell(e);const n=l.tFoot;if(n&&n.rows.length>0){const s=n.rows[0];e>=0&&e<s.cells.length&&s.deleteCell(e)}y()},moveColumn(e,o){const n=i.getColumnCount();if(e<0||e>=n||o<0||o>=n||e===o)return;const s=f=>{if(e>=f.cells.length)return;const T=f.cells[e];o>=f.cells.length?f.appendChild(T):o>e?f.insertBefore(T,f.cells[o+1]):f.insertBefore(T,f.cells[o])},a=l.tHead;if(a)for(let f=0;f<a.rows.length;f++)s(a.rows[f]);const u=v();for(const f of u)s(f);const g=l.tFoot;if(g)for(let f=0;f<g.rows.length;f++)s(g.rows[f]);E(),y()},swapColumns(e,o){const n=i.getColumnCount();if(e<0||e>=n||o<0||o>=n||e===o)return;const s=f=>{if(e>=f.cells.length||o>=f.cells.length)return;const T=f.cells[e],K=f.cells[o],V=document.createElement("td");f.insertBefore(V,T),f.insertBefore(T,K),f.insertBefore(K,V),V.remove()},a=l.tHead;if(a)for(let f=0;f<a.rows.length;f++)s(a.rows[f]);const u=v();for(const f of u)s(f);const g=l.tFoot;if(g)for(let f=0;f<g.rows.length;f++)s(g.rows[f]);E(),y()},setColumnData(e,o){const n=v();for(let s=0;s<n.length&&s<o.length;s++){const a=n[s].cells[e];if(a){const u=U(a);I(a,o[s]),u!==o[s]&&P(s,e,u,o[s])}}},setCell(e,o,n){const s=i.getCell(e,o);if(!s)return;const a=U(s);I(s,n),P(e,o,a,n)},setCellByRowId(e,o,n){const s=i.getRowIndex(e);s!==-1&&i.setCell(s,o,n)},setCellRange(e,o,n){for(let s=0;s<n.length;s++){const a=n[s];for(let u=0;u<a.length;u++)i.setCell(e+s,o+u,a[u])}},setFooter(e){let o=l.tFoot;for(o||(o=l.createTFoot());o.rows.length>0;)o.deleteRow(0);const n=o.insertRow();for(const s of e){const a=n.insertCell();I(a,s)}},setFooterCell(e,o){const n=l.tFoot;if(!n||n.rows.length===0)return;const s=n.rows[0].cells[e];s&&I(s,o)},getFooterCell(e){const o=l.tFoot;if(!o||o.rows.length===0)return;const n=o.rows[0].cells[e];return n?U(n):void 0},clearFooter(){const e=l.tFoot;if(e)for(;e.rows.length>0;)e.deleteRow(0)},setCaption(e){const o=l.createCaption();o.textContent=e},getCaptionText(){return l.caption?.textContent??void 0},setData(e){i.clearRows();const o=A();for(const n of e){const s=o.insertRow();s.dataset.id=c();for(const a of n){const u=s.insertCell();I(u,a)}}y()},reset(){for(l.deleteCaption(),l.deleteTHead(),l.deleteTFoot();l.tBodies.length>0;)l.removeChild(l.tBodies[0]);E(),y()},sync(){const e=v();for(const o of e)o.dataset.id||(o.dataset.id=c())},setRecords(e,o){i.clearRows();const n=A();for(const s of e){const a=n.insertRow();a.dataset.id=s.id;for(const u of o){const g=a.insertCell(),f=typeof u=="function"?u(s):s[u];I(g,f)}}y()},getRecordData(e){return i.getRowDataById(e)},addRecord(e,o,n){const s="id"in e&&typeof e.id=="string"&&e.id.length>0?e.id:c(),a={...e,id:s},u=o.map(g=>typeof g=="function"?g(a):a[g]);return i.addRow(u,n,s),s},updateRecordRow(e,o){const n=i.getRowIndex(e);return n===-1?!1:(i.updateRow(n,o),!0)},removeRecord(e){return i.removeRowById(e)!==void 0},hasRecord(e){return i.getRowIndex(e)!==-1},setIdGenerator(e){c=e},generateId(){return c()},onRowAdd(e){return S.add(e),()=>S.delete(e)},onRowRemove(e){return w.add(e),()=>w.delete(e)},onRowUpdate(e){return h.add(e),()=>h.delete(e)},onCellChange(e){return D.add(e),()=>D.delete(e)},onHeaderChange(e){return B.add(e),()=>B.delete(e)},onDataChange(e){return b.add(e),()=>b.delete(e)},destroy(){S.clear(),w.clear(),h.clear(),D.clear(),B.clear(),b.clear()}};return F?.caption&&i.setCaption(F.caption),F?.headers&&i.setHeaders(F.headers),C&&i.setData(C),F?.footer&&i.setFooter(F.footer),i.sync(),i}function le(l,C,F){const c=J(l.value,C,F),S=m.ref(0),w=()=>{S.value++},h=m.ref(new Set),D=m.ref(new Set),B=m.ref(null),b=new Set,A=new Set,v=m.computed(()=>(S.value,c.element)),N=m.computed(()=>(S.value,c.getHeaders())),j=m.computed(()=>(S.value,c.getData())),_=m.computed(()=>(S.value,c.getRowCount())),P=m.computed(()=>(S.value,c.getColumnCount())),E=m.computed(()=>(S.value,c.getAllRowIds())),y=m.computed(()=>(S.value,c.getFooterData())),L=m.computed(()=>(S.value,c.getCaptionText())),i=()=>{b.forEach(t=>t(h.value,D.value))},e=()=>{A.forEach(t=>t(B.value))},o=(t,r)=>`${t},${r}`,n=c.onDataChange(()=>w()),s=c.onHeaderChange(()=>w()),a=t=>{if(t<0||t>=c.getRowCount())return;const r=new Set(h.value);r.add(t),h.value=r,i()},u=t=>{const r=new Set(h.value);r.delete(t),h.value=r,i()},g=t=>{h.value.has(t)?u(t):a(t)},f=()=>{const t=c.getRowCount(),r=new Set;for(let d=0;d<t;d++)r.add(d);h.value=r,i()},T=()=>{h.value=new Set,i()},K=(t,r)=>{const d=Math.min(t,r),R=Math.max(t,r),p=c.getRowCount(),z=new Set(h.value);for(let k=d;k<=R&&k<p;k++)k>=0&&z.add(k);h.value=z,i()},V=t=>h.value.has(t),$=()=>Array.from(h.value).sort((t,r)=>t-r),fe=()=>$().map(t=>c.getRowData(t)).filter(t=>t!==void 0),X=(t,r)=>{const d=o(t,r),R=new Set(D.value);R.add(d),D.value=R,i()},Y=(t,r)=>{const d=o(t,r),R=new Set(D.value);R.delete(d),D.value=R,i()},ge=(t,r)=>{const d=o(t,r);D.value.has(d)?Y(t,r):X(t,r)},Re=(t,r)=>D.value.has(o(t,r)),q=()=>{h.value=new Set,D.value=new Set,i()},G=(t,r)=>{const d=c.getRowCount(),R=c.getColumnCount();if(t<0||t>=d||r<0||r>=R)return;B.value={row:t,column:r};const p=c.getCell(t,r);p&&(p.tabIndex=0,p.focus()),e()},Z=()=>{B.value=null,e()},Ce=()=>B.value?{...B.value}:null,he=(t,r)=>{const d=B.value;return d!==null&&d.row===t&&d.column===r},x=()=>{const t=B.value;return!t||t.row<=0?!1:(G(t.row-1,t.column),!0)},ee=()=>{const t=B.value;if(!t)return!1;const r=c.getRowCount();return t.row>=r-1?!1:(G(t.row+1,t.column),!0)},te=()=>{const t=B.value;return!t||t.column<=0?!1:(G(t.row,t.column-1),!0)},oe=()=>{const t=B.value;if(!t)return!1;const r=c.getColumnCount();return t.column>=r-1?!1:(G(t.row,t.column+1),!0)},ne=()=>{const t=c.getRowCount(),r=c.getColumnCount();t>0&&r>0&&G(0,0)},re=()=>{const t=c.getRowCount(),r=c.getColumnCount();t>0&&r>0&&G(t-1,r-1)},ve=()=>{const t=c.element,r=d=>{const R=B.value;if(!R)return;let p=!1;switch(d.key){case"ArrowUp":p=x();break;case"ArrowDown":p=ee();break;case"ArrowLeft":p=te();break;case"ArrowRight":p=oe();break;case"Home":d.ctrlKey?ne():G(R.row,0),p=!0;break;case"End":if(d.ctrlKey)re();else{const z=c.getColumnCount();G(R.row,z-1)}p=!0;break;case"Enter":case" ":d.shiftKey?K(R.row,R.row):d.ctrlKey||d.metaKey?g(R.row):(T(),a(R.row)),p=!0;break;case"Escape":q(),p=!0;break;case"a":(d.ctrlKey||d.metaKey)&&(h.value.size===c.getRowCount()?T():f(),p=!0);break}p&&(d.preventDefault(),d.stopPropagation())};return t.addEventListener("keydown",r),()=>{t.removeEventListener("keydown",r)}},pe=(t,r)=>{c.setRecords(t,r),w()},ye=t=>c.getRecordData(t),me=(t,r,d)=>{const R=c.addRecord(t,r,d);return w(),R},Be=(t,r)=>{const d=c.updateRecordRow(t,r);return d&&w(),d},He=t=>{const r=c.removeRecord(t);return r&&w(),r},Fe=t=>c.hasRecord(t),Se=()=>$().map(r=>c.getRowId(r)).filter(r=>r!==void 0),De=t=>{for(const r of t){const d=c.getRowIndex(r);d!==-1&&a(d)}},Te=t=>{for(const r of t){const d=c.getRowIndex(r);d!==-1&&u(d)}},Ie=t=>{c.setHeaders(t),w()},Ee=(t,r)=>{c.setHeader(t,r),w()},be=(t,r)=>{c.addHeader(t,r),w()},Ae=t=>{c.removeHeader(t),w()},Le=(t,r,d)=>{const R=c.addRow(t,r,d);return w(),R},Ge=t=>{const r=c.removeRow(t);return r&&w(),r},Ue=t=>{const r=c.removeRowById(t);return r&&w(),r},Ke=(t,r)=>{c.updateRow(t,r),w()},Ve=(t,r)=>{c.updateRowById(t,r),w()},ke=(t,r)=>{c.moveRow(t,r),w()},Me=(t,r)=>{c.swapRows(t,r),w()},Ne=()=>{c.clearRows(),w()},je=(t,r,d)=>{c.addColumn(t,r,d),w()},Pe=t=>{c.removeColumn(t),w()},ze=(t,r)=>{c.moveColumn(t,r),w()},_e=(t,r)=>{c.swapColumns(t,r),w()},$e=(t,r)=>{c.setColumnData(t,r),w()},qe=(t,r)=>c.getCellValue(t,r),Oe=(t,r,d)=>{c.setCell(t,r,d),w()},Je=(t,r,d)=>{c.setCellByRowId(t,r,d),w()},Qe=(t,r,d)=>{c.setCellRange(t,r,d),w()},We=(t,r)=>c.getCell(t,r),Xe=t=>c.getRowData(t),Ye=t=>c.getRowDataById(t),Ze=t=>c.getRow(t),xe=t=>c.getRowById(t),et=t=>c.getRowId(t),tt=t=>c.getRowIndex(t),ot=t=>c.getColumnData(t),nt=t=>{c.setFooter(t),w()},rt=(t,r)=>{c.setFooterCell(t,r),w()},st=t=>c.getFooterCell(t),ct=()=>{c.clearFooter(),w()},lt=t=>{c.setCaption(t),w()},at=t=>{c.setData(t),w()},dt=()=>{c.reset(),q(),Z(),w()},ut=()=>{c.sync(),w()},it=t=>c.onRowAdd(t),wt=t=>c.onRowRemove(t),ft=t=>c.onRowUpdate(t),gt=t=>c.onCellChange(t),Rt=t=>c.onHeaderChange(t),Ct=t=>c.onDataChange(t),ht=t=>(b.add(t),()=>b.delete(t)),vt=t=>(A.add(t),()=>A.delete(t)),se=()=>{n(),s(),b.clear(),A.clear(),c.destroy()};return m.onUnmounted(()=>{se()}),{instance:c,element:v,headers:N,data:j,rowCount:_,columnCount:P,rowIds:E,footerData:y,captionText:L,version:S,selection:{rows:h,cells:D},focus:{cell:B},createCaption:()=>c.createCaption(),deleteCaption:()=>{c.deleteCaption(),w()},createTHead:()=>c.createTHead(),deleteTHead:()=>{c.deleteTHead(),w()},createTFoot:()=>c.createTFoot(),deleteTFoot:()=>{c.deleteTFoot(),w()},createTBody:()=>c.createTBody(),getSectionRows:t=>c.getSectionRows(t),insertSectionRow:(t,r,d,R)=>{const p=c.insertSectionRow(t,r,d,R);return w(),p},deleteSectionRow:(t,r)=>{const d=c.deleteSectionRow(t,r);return d&&w(),d},getSectionRowCount:t=>c.getSectionRowCount(t),addHeadRow:(t,r)=>{const d=c.addHeadRow(t,r);return w(),d},removeHeadRow:t=>{const r=c.removeHeadRow(t);return r&&w(),r},getHeadRowCount:()=>c.getHeadRowCount(),addFootRow:(t,r)=>{const d=c.addFootRow(t,r);return w(),d},removeFootRow:t=>{const r=c.removeFootRow(t);return r&&w(),r},getFootRowCount:()=>c.getFootRowCount(),addBodyRow:(t,r,d,R)=>{const p=c.addBodyRow(t,r,d,R);return w(),p},removeBodyRow:(t,r)=>{const d=c.removeBodyRow(t,r);return d&&w(),d},getBodyRowCount:t=>c.getBodyRowCount(t),setHeaders:Ie,setHeader:Ee,addHeader:be,removeHeader:Ae,addRow:Le,removeRow:Ge,removeRowById:Ue,updateRow:Ke,updateRowById:Ve,moveRow:ke,swapRows:Me,clearRows:Ne,addColumn:je,removeColumn:Pe,moveColumn:ze,swapColumns:_e,setColumnData:$e,getCell:qe,setCell:Oe,setCellByRowId:Je,setCellRange:Qe,getCellElement:We,getRowData:Xe,getRowDataById:Ye,getRowElement:Ze,getRowById:xe,getRowId:et,getRowIndex:tt,getColumnData:ot,setFooter:nt,setFooterCell:rt,getFooterCell:st,clearFooter:ct,setCaption:lt,setData:at,reset:dt,sync:ut,selectRow:a,deselectRow:u,toggleRowSelection:g,selectAllRows:f,deselectAllRows:T,selectRowRange:K,isRowSelected:V,getSelectedRowIndices:$,getSelectedRowData:fe,selectCell:X,deselectCell:Y,toggleCellSelection:ge,isCellSelected:Re,clearSelection:q,focusCell:G,clearFocus:Z,getFocusedCell:Ce,isCellFocused:he,moveFocusUp:x,moveFocusDown:ee,moveFocusLeft:te,moveFocusRight:oe,moveFocusToFirst:ne,moveFocusToLast:re,enableKeyboardNavigation:ve,setRecords:pe,getRecordData:ye,addRecord:me,updateRecordRow:Be,removeRecord:He,hasRecord:Fe,getSelectedRecordIds:Se,selectRecords:De,deselectRecords:Te,setIdGenerator:t=>c.setIdGenerator(t),generateId:()=>c.generateId(),onRowAdd:it,onRowRemove:wt,onRowUpdate:ft,onCellChange:gt,onHeaderChange:Rt,onDataChange:Ct,onSelectionChange:ht,onFocusChange:vt,destroy:se}}const M=Symbol("idGenerated");function Q(){return crypto.randomUUID()}function ae(l,C=Q){return"id"in l&&typeof l.id=="string"&&l.id.length>0?l:{...l,id:C(),[M]:!0}}function W(l){return M in l&&l[M]===!0}function de(l){return typeof l=="string"&&l.length>0}function ue(l,C){return l.find(F=>F.id===C)}function ie(l,C){return l.findIndex(F=>F.id===C)}function we(l){if(!W(l))return l;const{id:C,...F}=l;return F}H.ID_GENERATED=M,H.createTable=J,H.ensureId=ae,H.findById=ue,H.generateId=Q,H.indexById=ie,H.isValidId=de,H.stripGeneratedId=we,H.useTable=le,H.wasIdGenerated=W,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikestools/usetable",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Vue 3 composable for table operations",
5
5
  "private": false,
6
6
  "type": "module",