tosijs-ui 1.4.3 → 1.4.4
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/dist/data-table.js +43 -1
- package/dist/iife.js +19 -19
- package/dist/iife.js.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/data-table.js
CHANGED
|
@@ -71,6 +71,33 @@ preview.append(tosiTable({
|
|
|
71
71
|
background: #ddd;
|
|
72
72
|
}
|
|
73
73
|
```
|
|
74
|
+
```test
|
|
75
|
+
const table = await new Promise(resolve => {
|
|
76
|
+
const check = () => {
|
|
77
|
+
const t = preview.querySelector('tosi-table')
|
|
78
|
+
if (t && t.visibleRows.length > 0) return resolve(t)
|
|
79
|
+
setTimeout(check, 100)
|
|
80
|
+
}
|
|
81
|
+
check()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('table renders with data', () => {
|
|
85
|
+
expect(table.multiple).toBe(true)
|
|
86
|
+
expect(table.visibleRows.length).toBeGreaterThan(0)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('row selection works', () => {
|
|
90
|
+
const rows = table.visibleRows
|
|
91
|
+
table.deSelect()
|
|
92
|
+
table.selectRow(rows[0])
|
|
93
|
+
table.selectRow(rows[1])
|
|
94
|
+
expect(table.selectedRows.length).toBe(2)
|
|
95
|
+
expect(table.querySelectorAll('.tr[aria-selected]').length).toBe(2)
|
|
96
|
+
table.deSelect()
|
|
97
|
+
expect(table.selectedRows.length).toBe(0)
|
|
98
|
+
expect(table.querySelectorAll('.tr[aria-selected]').length).toBe(0)
|
|
99
|
+
})
|
|
100
|
+
```
|
|
74
101
|
|
|
75
102
|
> In the preceding example, the `name` column is *editable* (and *bound*, try editing something and scrolling
|
|
76
103
|
> it out of view and back) and `multiple` select is enabled. In the console, you can try `$('tosi-table').visibleRows`
|
|
@@ -282,6 +309,8 @@ export class TosiTable extends WebComponent {
|
|
|
282
309
|
};
|
|
283
310
|
selectedKey = Symbol('selected');
|
|
284
311
|
selectBinding = (elt, obj) => {
|
|
312
|
+
if (obj == null)
|
|
313
|
+
return;
|
|
285
314
|
elt.toggleAttribute('aria-selected', obj[this.selectedKey] === true);
|
|
286
315
|
};
|
|
287
316
|
maxVisibleRows = 10000;
|
|
@@ -438,10 +467,23 @@ export class TosiTable extends WebComponent {
|
|
|
438
467
|
else {
|
|
439
468
|
delete row[this.selectedKey];
|
|
440
469
|
}
|
|
470
|
+
for (const elt of Array.from(this.querySelectorAll('.tr'))) {
|
|
471
|
+
const item = getListItem(elt);
|
|
472
|
+
this.selectBinding(elt, item);
|
|
473
|
+
}
|
|
441
474
|
}
|
|
442
475
|
selectRows(rows, select = true) {
|
|
443
476
|
for (const row of rows || this.array) {
|
|
444
|
-
|
|
477
|
+
if (select) {
|
|
478
|
+
row[this.selectedKey] = true;
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
delete row[this.selectedKey];
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
for (const elt of Array.from(this.querySelectorAll('.tr'))) {
|
|
485
|
+
const item = getListItem(elt);
|
|
486
|
+
this.selectBinding(elt, item);
|
|
445
487
|
}
|
|
446
488
|
}
|
|
447
489
|
deSelect(rows) {
|