@ninebone/datagrid 0.0.10 → 0.0.12
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/css/nine-table.css +75 -22
- package/dist/nine-table.js +165 -65
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +11 -9
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +6 -3
package/dist/css/nine-table.css
CHANGED
|
@@ -506,34 +506,64 @@ cell-row-indicator {
|
|
|
506
506
|
pointer-events: none;
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
.
|
|
509
|
+
.row-status {
|
|
510
|
+
display: inline-block;
|
|
510
511
|
position: absolute;
|
|
511
|
-
right:
|
|
512
|
+
right: 0;
|
|
512
513
|
top: 1px;
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
width: 4px;
|
|
515
|
+
height: 4px;
|
|
516
|
+
border-radius: 50%;
|
|
516
517
|
}
|
|
517
518
|
}
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
cell-row-indicator.is-insert .row-status {
|
|
522
|
+
background-color: #333;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
cell-row-indicator.is-update .row-status {
|
|
526
|
+
background-color: darkgoldenrod;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
cell-row-indicator.is-delete .row-status {
|
|
530
|
+
background-color: red;
|
|
531
|
+
}
|
|
518
532
|
:host {
|
|
519
533
|
--cell-selection-bg: rgba(37, 99, 235, 0.08);
|
|
520
534
|
--cell-selection-border-color: #2563eb;
|
|
521
535
|
}
|
|
522
536
|
|
|
523
537
|
tbody {
|
|
524
|
-
|
|
525
|
-
|
|
538
|
+
|
|
539
|
+
tr.selected {
|
|
540
|
+
cell-row-indicator {
|
|
541
|
+
border-left: 2px solid darkgoldenrod;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
cell-row-indicator {
|
|
545
|
+
border-left: 2px solid darkgoldenrod;
|
|
546
|
+
}
|
|
526
547
|
}
|
|
527
548
|
|
|
528
|
-
.selected
|
|
529
|
-
|
|
549
|
+
th.selected, td.selected {
|
|
550
|
+
.selected {
|
|
551
|
+
background-color: var(--cell-selection-bg);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.selected-start {
|
|
555
|
+
background-color: transparent;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.selected-top { border-top: 2px solid var(--cell-selection-border-color); }
|
|
559
|
+
.selected-bottom { border-bottom: 2px solid var(--cell-selection-border-color); }
|
|
560
|
+
.selected-left { border-left: 2px solid var(--cell-selection-border-color); }
|
|
561
|
+
.selected-right { border-right: 2px solid var(--cell-selection-border-color); }
|
|
530
562
|
}
|
|
531
563
|
|
|
532
|
-
.selected-top { border-top: 2px solid var(--cell-selection-border-color); }
|
|
533
|
-
.selected-bottom { border-bottom: 2px solid var(--cell-selection-border-color); }
|
|
534
|
-
.selected-left { border-left: 2px solid var(--cell-selection-border-color); }
|
|
535
|
-
.selected-right { border-right: 2px solid var(--cell-selection-border-color); }
|
|
536
564
|
}
|
|
565
|
+
|
|
566
|
+
|
|
537
567
|
nine-table-col-expand {
|
|
538
568
|
position: absolute;
|
|
539
569
|
right: 2px;
|
|
@@ -1496,31 +1526,54 @@ nine-table-sheets-footer {
|
|
|
1496
1526
|
}
|
|
1497
1527
|
|
|
1498
1528
|
|
|
1529
|
+
|
|
1499
1530
|
.asc::after,
|
|
1500
1531
|
.desc::after {
|
|
1501
|
-
|
|
1502
|
-
|
|
1532
|
+
z-index: 1;
|
|
1503
1533
|
content: "";
|
|
1504
1534
|
display: inline-block;
|
|
1505
|
-
width:
|
|
1506
|
-
height:
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1535
|
+
width: 10px;
|
|
1536
|
+
height: 10px;
|
|
1537
|
+
position: absolute;
|
|
1538
|
+
left: 50%;
|
|
1539
|
+
top: -2px;
|
|
1540
|
+
transform: translateX(-50%);
|
|
1510
1541
|
background-repeat: no-repeat;
|
|
1511
1542
|
background-position: center;
|
|
1512
1543
|
background-size: contain;
|
|
1513
1544
|
}
|
|
1514
1545
|
|
|
1515
1546
|
.asc::after {
|
|
1516
|
-
--sort-icon-color: #2563eb;
|
|
1517
1547
|
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 16 16"><path fill="%232563eb" d="M8 3L3 11h10L8 3z"/></svg>');
|
|
1518
1548
|
}
|
|
1519
1549
|
|
|
1520
1550
|
.desc::after {
|
|
1521
|
-
--sort-icon-color: #dc2626;
|
|
1522
1551
|
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 16 16"><path fill="%23dc2626" d="M8 13L3 5h10l-5 8z"/></svg>');
|
|
1523
1552
|
}
|
|
1553
|
+
|
|
1554
|
+
|
|
1555
|
+
tbody.body td *:first-child, tbody.body th *:first-child {
|
|
1556
|
+
transform: translate(0, 0);
|
|
1557
|
+
transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1.35), opacity 0.4s ease-out;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
tbody.body .sorting-anim-asc *:first-child {
|
|
1561
|
+
transform: translate(0px, 20px);
|
|
1562
|
+
opacity: 0.2;
|
|
1563
|
+
transition: none;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
tbody.body .sorting-anim-desc *:first-child {
|
|
1567
|
+
transform: translate(0px, -30px);
|
|
1568
|
+
opacity: 0.2;
|
|
1569
|
+
transition: none;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
tbody.body .sorting-anim-none *:first-child {
|
|
1573
|
+
transform: translate(0px, 0px);
|
|
1574
|
+
opacity: 0.2;
|
|
1575
|
+
transition: none;
|
|
1576
|
+
}
|
|
1524
1577
|
table {
|
|
1525
1578
|
--table-th-bg: #f9fafb;
|
|
1526
1579
|
--table-th-color: #111827;
|
package/dist/nine-table.js
CHANGED
|
@@ -56,15 +56,16 @@ var n = new class extends e.constructor {
|
|
|
56
56
|
}(), r = {
|
|
57
57
|
META: { INDEX: {
|
|
58
58
|
ROWID: 0,
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
ROW_STATE: 1,
|
|
60
|
+
FILTER: 2,
|
|
61
|
+
GROUP: 3
|
|
61
62
|
} },
|
|
62
63
|
ROW_STATE: {
|
|
63
|
-
EMPTY:
|
|
64
|
-
NORMAL:
|
|
65
|
-
INSERT:
|
|
66
|
-
UPDATE:
|
|
67
|
-
DELETE:
|
|
64
|
+
EMPTY: 0,
|
|
65
|
+
NORMAL: 1,
|
|
66
|
+
INSERT: 2,
|
|
67
|
+
UPDATE: 3,
|
|
68
|
+
DELETE: 9
|
|
68
69
|
},
|
|
69
70
|
EVENT: {
|
|
70
71
|
LOAD: "load",
|
|
@@ -99,7 +100,7 @@ var n = new class extends e.constructor {
|
|
|
99
100
|
constructor(e, t) {
|
|
100
101
|
this.#e = e, this.#t = t, this.#a();
|
|
101
102
|
}
|
|
102
|
-
#i = () => (this.#t.rawRecords || []).filter((e) =>
|
|
103
|
+
#i = () => (this.#t.rawRecords || []).filter((e) => e.m._[r.META.INDEX.ROW_STATE] !== r.ROW_STATE.DELETE);
|
|
103
104
|
get count() {
|
|
104
105
|
return this.length;
|
|
105
106
|
}
|
|
@@ -121,14 +122,14 @@ var n = new class extends e.constructor {
|
|
|
121
122
|
};
|
|
122
123
|
get = (e, t) => {
|
|
123
124
|
let n = this.#i();
|
|
124
|
-
if (e == null) return this.#
|
|
125
|
+
if (e == null) return this.#d(n);
|
|
125
126
|
if (e < 0 || e >= n.length) return null;
|
|
126
127
|
let r = n[e], i = this.getHostFields();
|
|
127
128
|
if (t != null) {
|
|
128
129
|
let e = i.indexOf(t);
|
|
129
130
|
return e >= 0 ? r.v[e] : null;
|
|
130
131
|
}
|
|
131
|
-
return this.#
|
|
132
|
+
return this.#d(r);
|
|
132
133
|
};
|
|
133
134
|
getAll = () => this.#t.rawRecords || [];
|
|
134
135
|
getHostFields = () => typeof this.#e.fields?.get == "function" ? this.#e.fields.get() : [];
|
|
@@ -142,7 +143,7 @@ var n = new class extends e.constructor {
|
|
|
142
143
|
});
|
|
143
144
|
};
|
|
144
145
|
get source() {
|
|
145
|
-
return this.#
|
|
146
|
+
return this.#d(this.#t.rawRecords);
|
|
146
147
|
}
|
|
147
148
|
set source(e) {
|
|
148
149
|
this.set(e);
|
|
@@ -203,7 +204,12 @@ var n = new class extends e.constructor {
|
|
|
203
204
|
{},
|
|
204
205
|
{}
|
|
205
206
|
],
|
|
206
|
-
_: [
|
|
207
|
+
_: [
|
|
208
|
+
t,
|
|
209
|
+
r.ROW_STATE.EMPTY,
|
|
210
|
+
[],
|
|
211
|
+
[]
|
|
212
|
+
]
|
|
207
213
|
});
|
|
208
214
|
reset = () => {
|
|
209
215
|
this.#t.rawRecords = [], this.#o();
|
|
@@ -221,43 +227,54 @@ var n = new class extends e.constructor {
|
|
|
221
227
|
}), n.push(r);
|
|
222
228
|
}), n;
|
|
223
229
|
};
|
|
224
|
-
#l = (
|
|
225
|
-
let
|
|
226
|
-
|
|
227
|
-
}),
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
#l = (e) => (Array.isArray(e) || (e = [e]), e.forEach((e) => {
|
|
231
|
+
let t = this.nextId;
|
|
232
|
+
e.m = this.#s(t), e.__ng = e.m, e.__ng.rowid = t, e.m._[r.META.INDEX.ROWID] = t, e.m._[r.META.INDEX.ROW_STATE] = r.ROW_STATE.EMPTY;
|
|
233
|
+
}), e);
|
|
234
|
+
#u = (e) => this.#t.rawRecords.findIndex((t) => !t || !t.m || !t.m._ ? !1 : t.m._[r.META.INDEX.ROWID] === e);
|
|
235
|
+
add = (e, t = !0) => {
|
|
236
|
+
e === void 0 && (e = {});
|
|
237
|
+
let n = this.#c(e);
|
|
238
|
+
this.#t.rawRecords = this.#t.rawRecords.concat(this.#l(n));
|
|
232
239
|
let i = this.count() - 1;
|
|
233
|
-
return
|
|
234
|
-
let
|
|
235
|
-
|
|
240
|
+
return t && n.forEach((e, t) => {
|
|
241
|
+
let n = this.#t.rawRecords[this.#t.rawRecords.length - 1 - t];
|
|
242
|
+
n && (n.m._[r.META.INDEX.ROW_STATE] = r.ROW_STATE.INSERT);
|
|
236
243
|
}), this.#o(), i;
|
|
237
244
|
};
|
|
238
|
-
|
|
245
|
+
insert = (e, t, n = !0) => {
|
|
246
|
+
t === void 0 && (t = {});
|
|
247
|
+
let i = this.#c(t);
|
|
248
|
+
if (i.length === 0) return -1;
|
|
249
|
+
let a = this.#u(e), o = this.#l(i);
|
|
250
|
+
return this.#t.rawRecords.splice(a, 0, ...o), n && o.forEach((e, t) => {
|
|
251
|
+
let n = this.#t.rawRecords[a + t];
|
|
252
|
+
n && n.m && n.m._ && (n.m._[r.META.INDEX.ROW_STATE] = r.ROW_STATE.INSERT);
|
|
253
|
+
}), this.#o(), o[0].m._[r.META.INDEX.ROWID];
|
|
254
|
+
};
|
|
255
|
+
remove = (e) => {
|
|
256
|
+
let t = [];
|
|
257
|
+
t = Array.isArray(e) ? at : [parseInt(e, 10)];
|
|
239
258
|
let n = [];
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
259
|
+
t.forEach((e) => {
|
|
260
|
+
n.push(this.#u(e));
|
|
261
|
+
});
|
|
262
|
+
let i = this.#t.rawRecords;
|
|
263
|
+
n.sort((e, t) => t - e).forEach((e) => {
|
|
264
|
+
let t = i[e].m._[r.META.INDEX.ROWID];
|
|
265
|
+
i[e].m._[r.META.INDEX.ROW_STATE] === r.ROW_STATE.INSERT ? this.#t.rawRecords = this.#t.rawRecords.filter((e) => e.m._[r.META.INDEX.ROWID] !== t) : this.#t.rawRecords.forEach((e) => {
|
|
266
|
+
e.m._[r.META.INDEX.ROWID] === t && (e.m._[r.META.INDEX.ROW_STATE] = r.ROW_STATE.DELETE);
|
|
267
|
+
});
|
|
249
268
|
}), this.#o();
|
|
250
269
|
};
|
|
251
|
-
setValue = (t, n
|
|
252
|
-
|
|
253
|
-
let i = this.getHostFields().indexOf(
|
|
270
|
+
setValue = (e, t, n) => {
|
|
271
|
+
e = parseInt(e, 10);
|
|
272
|
+
let i = this.getHostFields().indexOf(t);
|
|
254
273
|
if (i < 0) return;
|
|
255
|
-
let a = this.#
|
|
256
|
-
|
|
257
|
-
let o = a.v[i];
|
|
258
|
-
o !== r && a.__ng.rowState !== e.ROW_STATE.INSERT && (a.__ng.o.hasOwnProperty(n) || (a.__ng.o[n] = o), a.__ng.rowState = e.ROW_STATE.UPDATE), a.v[i] = r;
|
|
274
|
+
let a = this.#u(e), o = this.#t.rawRecords[a];
|
|
275
|
+
o && (o.v[i] !== n && o.m._[r.META.INDEX.ROW_STATE] !== r.ROW_STATE.INSERT && (o.m._[r.META.INDEX.ROW_STATE] = r.ROW_STATE.UPDATE), o.v[i] = n);
|
|
259
276
|
};
|
|
260
|
-
#
|
|
277
|
+
#d = (e) => {
|
|
261
278
|
if (!e) return e;
|
|
262
279
|
let t = !Array.isArray(e), n = t ? [e] : e, r = this.getHostFields(), i = n.filter((e) => !e.__ng?.deleted).map((e) => {
|
|
263
280
|
let t = {};
|
|
@@ -1156,6 +1173,18 @@ var m = {
|
|
|
1156
1173
|
endCol: s
|
|
1157
1174
|
}, this.render();
|
|
1158
1175
|
}
|
|
1176
|
+
get minRow() {
|
|
1177
|
+
return this.#t.startRow;
|
|
1178
|
+
}
|
|
1179
|
+
get maxRow() {
|
|
1180
|
+
return this.#t.endRow;
|
|
1181
|
+
}
|
|
1182
|
+
get minCol() {
|
|
1183
|
+
return this.#t.startCol;
|
|
1184
|
+
}
|
|
1185
|
+
get maxCol() {
|
|
1186
|
+
return this.#t.endCol;
|
|
1187
|
+
}
|
|
1159
1188
|
refresh = () => {
|
|
1160
1189
|
this.render();
|
|
1161
1190
|
};
|
|
@@ -1170,12 +1199,12 @@ var m = {
|
|
|
1170
1199
|
}), e < 0 || t < 0 || i.forEach((i) => {
|
|
1171
1200
|
Array.from(i.querySelectorAll("tbody tr")).filter((e) => e.style.display !== "none").forEach((i) => {
|
|
1172
1201
|
let { matrixRow: a } = this.#n(i);
|
|
1173
|
-
a < 0 || i.querySelectorAll("td, th").forEach((i) => {
|
|
1202
|
+
a < 0 || (a >= e && a <= n && i.classList.add("selected"), i.querySelectorAll("td, th").forEach((i) => {
|
|
1174
1203
|
let o = parseInt(i.dataset.col, 10);
|
|
1175
1204
|
if (isNaN(o)) return;
|
|
1176
1205
|
let s = parseInt(i.rowSpan || 1, 10), c = parseInt(i.colSpan || 1, 10), l = a + s - 1, u = o + c - 1;
|
|
1177
1206
|
l >= e && a <= n && u >= t && o <= r && (i.classList.add("selected"), a <= e && i.classList.add("selected-top"), l >= n && i.classList.add("selected-bottom"), o <= t && i.classList.add("selected-left"), u >= r && i.classList.add("selected-right"));
|
|
1178
|
-
});
|
|
1207
|
+
}));
|
|
1179
1208
|
});
|
|
1180
1209
|
});
|
|
1181
1210
|
};
|
|
@@ -2200,10 +2229,19 @@ var k = class {
|
|
|
2200
2229
|
}) : c ? u >= 0 ? this.#n[u].asc = !1 : this.#n.push({
|
|
2201
2230
|
...d,
|
|
2202
2231
|
asc: !1
|
|
2203
|
-
}) : this.#n = this.#n.filter((e) => !(e.colIndex === n && e.subRowIndex === i || e.colName === o)), this.#a();
|
|
2232
|
+
}) : this.#n = this.#n.filter((e) => !(e.colIndex === n && e.subRowIndex === i || e.colName === o)), this.#a(t);
|
|
2204
2233
|
}
|
|
2205
|
-
#a() {
|
|
2206
|
-
this.#e.view
|
|
2234
|
+
#a(e) {
|
|
2235
|
+
this.#e.view.setSorting(this.#n), this.#o(), this.#e.invalidate(), requestAnimationFrame(() => {
|
|
2236
|
+
let t = this.#e.querySelectorAll("tbody.body th, tbody.body td");
|
|
2237
|
+
t.forEach((t) => {
|
|
2238
|
+
t.classList.remove("sorting-anim-asc", "sorting-anim-desc", "sorting-anim-none"), e.classList.contains("asc") ? t.classList.add("sorting-anim-asc") : e.classList.contains("desc") ? t.classList.add("sorting-anim-desc") : t.classList.add("sorting-anim-none");
|
|
2239
|
+
}), requestAnimationFrame(() => {
|
|
2240
|
+
t.forEach((e) => {
|
|
2241
|
+
e.classList.remove("sorting-anim-asc", "sorting-anim-desc", "sorting-anim-none");
|
|
2242
|
+
});
|
|
2243
|
+
});
|
|
2244
|
+
});
|
|
2207
2245
|
}
|
|
2208
2246
|
#o() {
|
|
2209
2247
|
this.#e.querySelectorAll("thead th, thead td").forEach((e) => {
|
|
@@ -2550,6 +2588,9 @@ var k = class {
|
|
|
2550
2588
|
get #m() {
|
|
2551
2589
|
return this.#t.hasAttribute("simple") || this.#t.getAttribute("theme") === "simple";
|
|
2552
2590
|
}
|
|
2591
|
+
scrollTo = (e, t) => {
|
|
2592
|
+
this.rowManager.scrollToDataRow(e, "top", t);
|
|
2593
|
+
};
|
|
2553
2594
|
recompileAndRefresh() {
|
|
2554
2595
|
this.#f.table && (v.recompile(this.#f.table), [
|
|
2555
2596
|
"left",
|
|
@@ -2811,10 +2852,11 @@ var N = class {
|
|
|
2811
2852
|
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = this.#e.getAttribute("auto-height") === "true", n = e.length, r = e.map((e, t) => {
|
|
2812
2853
|
let r = t === 0 ? "active" : "", i = e.id || `sheet${t + 1}`;
|
|
2813
2854
|
return `<nine-table-sheet class="${r}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>` + (t < n - 1 ? `<nine-splitter class="h" data-split-index="${t}"></nine-splitter>` : "");
|
|
2814
|
-
}).join(""), i = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.
|
|
2855
|
+
}).join(""), i = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.0.12/dist/css/nine-table.css\";"];
|
|
2815
2856
|
nine["nine-table"] && nine["nine-table"].cssFile && i.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
|
|
2816
2857
|
<style>
|
|
2817
2858
|
${i.join("\n")}
|
|
2859
|
+
${this.#e.customStyle}
|
|
2818
2860
|
</style>
|
|
2819
2861
|
|
|
2820
2862
|
<nine-table-toolbar></nine-table-toolbar>
|
|
@@ -2877,16 +2919,17 @@ var N = class {
|
|
|
2877
2919
|
#t;
|
|
2878
2920
|
#n;
|
|
2879
2921
|
#r = 0;
|
|
2922
|
+
#i = "";
|
|
2880
2923
|
constructor() {
|
|
2881
|
-
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.0.
|
|
2924
|
+
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.0.12"), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this);
|
|
2882
2925
|
}
|
|
2883
2926
|
connectedCallback() {
|
|
2884
2927
|
setTimeout(() => {
|
|
2885
|
-
this.#r = this.querySelectorAll("table")?.length, this.fields = new s(this), this.exprEngine = new P(this), this.#
|
|
2928
|
+
this.#r = this.querySelectorAll("table")?.length, this.fields = new s(this), this.exprEngine = new P(this), this.#o(), this.#n = new N(this), this.#a();
|
|
2886
2929
|
});
|
|
2887
2930
|
}
|
|
2888
2931
|
disconnectedCallback() {}
|
|
2889
|
-
#
|
|
2932
|
+
#a = () => {
|
|
2890
2933
|
let e = 0, t = setInterval(() => {
|
|
2891
2934
|
e++;
|
|
2892
2935
|
let n = this.shadow.querySelectorAll("nine-table-sheet");
|
|
@@ -2913,9 +2956,58 @@ var N = class {
|
|
|
2913
2956
|
get row() {
|
|
2914
2957
|
return this.#t.row;
|
|
2915
2958
|
}
|
|
2959
|
+
get customStyle() {
|
|
2960
|
+
return this.#i;
|
|
2961
|
+
}
|
|
2962
|
+
scrollTo = (e, t) => {
|
|
2963
|
+
this.#e.querySelectorAll("nine-table-sheet.active").forEach((n) => {
|
|
2964
|
+
n.scrollTo(e, t);
|
|
2965
|
+
});
|
|
2966
|
+
};
|
|
2967
|
+
currentRow = () => {
|
|
2968
|
+
let e = this.currentRows();
|
|
2969
|
+
return e.length === 0 ? -1 : e[0];
|
|
2970
|
+
};
|
|
2971
|
+
currentRows = () => {
|
|
2972
|
+
let e = [];
|
|
2973
|
+
return this.#e.querySelectorAll("nine-table-sheet.active").forEach((t) => {
|
|
2974
|
+
let n = t.view.getArray(t.selection.minRow).m._[r.META.INDEX.ROWID];
|
|
2975
|
+
e.push(n);
|
|
2976
|
+
}), e;
|
|
2977
|
+
};
|
|
2978
|
+
addRow = (e, t = !0) => this.data.add(e, t);
|
|
2979
|
+
insertRow = (e, t, n = !0) => {
|
|
2980
|
+
let i = this.#e.querySelector("nine-table-sheet.active");
|
|
2981
|
+
if (!i) return;
|
|
2982
|
+
let a = i.view.get(e).m._[r.META.INDEX.ROWID], o = this.data.insert(a, t, n);
|
|
2983
|
+
return i.view.getArray().findIndex((e) => !e || !e.m || !e.m._ ? !1 : e.m._[r.META.INDEX.ROWID] === o);
|
|
2984
|
+
};
|
|
2985
|
+
removeRow = (e) => {
|
|
2986
|
+
let t = this.#e.querySelector("nine-table-sheet.active");
|
|
2987
|
+
if (!t) return;
|
|
2988
|
+
let n = t.view.get(e).m._[r.META.INDEX.ROWID];
|
|
2989
|
+
this.data.remove(n);
|
|
2990
|
+
};
|
|
2991
|
+
currentIndex = () => {
|
|
2992
|
+
let e = this.currentIndexs();
|
|
2993
|
+
return e.length === 0 ? -1 : e[0];
|
|
2994
|
+
};
|
|
2995
|
+
currentIndexs = () => {
|
|
2996
|
+
let e = [];
|
|
2997
|
+
return this.#e.querySelectorAll("nine-table-sheet.active").forEach((t) => {
|
|
2998
|
+
e.push(t.selection.minRow);
|
|
2999
|
+
}), e;
|
|
3000
|
+
};
|
|
2916
3001
|
addProvider(e) {
|
|
2917
|
-
e
|
|
2918
|
-
|
|
3002
|
+
if (!e || typeof e != "object") return;
|
|
3003
|
+
let { style: t, ...n } = e;
|
|
3004
|
+
if (t && typeof t == "string") {
|
|
3005
|
+
this.#i = t;
|
|
3006
|
+
let e = this.#e.getElementById("nine-table-scoped-custom-style");
|
|
3007
|
+
e && (e.textContent = t);
|
|
3008
|
+
}
|
|
3009
|
+
Object.keys(n).length > 0 && setTimeout(() => {
|
|
3010
|
+
Object.entries(n).forEach(([e, t]) => {
|
|
2919
3011
|
typeof t == "function" && (this[e] = t);
|
|
2920
3012
|
}), this.rerenderer();
|
|
2921
3013
|
});
|
|
@@ -2945,7 +3037,7 @@ var N = class {
|
|
|
2945
3037
|
get activeSheet() {
|
|
2946
3038
|
return this.shadow.querySelector("nine-table-sheet.active") || null;
|
|
2947
3039
|
}
|
|
2948
|
-
#
|
|
3040
|
+
#o() {
|
|
2949
3041
|
let e = /* @__PURE__ */ new Set();
|
|
2950
3042
|
this.querySelectorAll("[data-source]").forEach((t) => {
|
|
2951
3043
|
let n = t.getAttribute("data-source");
|
|
@@ -3085,10 +3177,8 @@ var I = class extends HTMLElement {
|
|
|
3085
3177
|
}
|
|
3086
3178
|
set value(e) {
|
|
3087
3179
|
if (!this.#r || !this.#e?.data) return;
|
|
3088
|
-
let t = parseInt(this.#
|
|
3089
|
-
|
|
3090
|
-
let r = this.getAttribute("update-row-state") !== "false";
|
|
3091
|
-
this.#e.data.setValue(t, n, e, r);
|
|
3180
|
+
let t = parseInt(this.#n.dataset.row, 10), n = this.#r.dataset.bind;
|
|
3181
|
+
!isNaN(t) && n && this.#e.data.setValue(t, n, e);
|
|
3092
3182
|
}
|
|
3093
3183
|
get row() {
|
|
3094
3184
|
return parseInt(this.#r?.dataset?.row, 10);
|
|
@@ -3875,27 +3965,37 @@ var X = class extends R {
|
|
|
3875
3965
|
super();
|
|
3876
3966
|
}
|
|
3877
3967
|
connectedCallback() {
|
|
3878
|
-
this.#r(), super.connectedCallback(), this.cell && (this.cell.removeAttribute("tabindex"), this.cell.dataset.bind = "rowState"), this.#e = this.querySelector(".ng-row-main"), this.#t = this.querySelector(".ng-row-sub"), this.#n = this.querySelector(".
|
|
3968
|
+
this.#r(), super.connectedCallback(), this.cell && (this.cell.removeAttribute("tabindex"), this.cell.dataset.bind = "rowState"), this.#e = this.querySelector(".ng-row-main"), this.#t = this.querySelector(".ng-row-sub"), this.#n = this.querySelector(".row-status");
|
|
3879
3969
|
}
|
|
3880
3970
|
#r = () => {
|
|
3881
|
-
this.innerHTML = "\n <span class=\"ng-row-main\"></span>\n <span class=\"ng-row-sub\"></span>\n <span class=\"
|
|
3971
|
+
this.innerHTML = "\n <span class=\"ng-row-main\"></span>\n <span class=\"ng-row-sub\"></span>\n <span class=\"row-status\"></span>\n ";
|
|
3882
3972
|
};
|
|
3883
3973
|
refresh = () => {
|
|
3884
3974
|
if (!this.cell || !this.tr) return;
|
|
3975
|
+
this.classList.remove("is-insert", "is-update", "is-delete");
|
|
3885
3976
|
let e = this.row;
|
|
3886
3977
|
if (isNaN(e)) return;
|
|
3887
3978
|
let t = this.tr.data;
|
|
3888
|
-
t
|
|
3889
|
-
|
|
3979
|
+
if (t) switch (t.m._[r.META.INDEX.ROW_STATE]) {
|
|
3980
|
+
case r.ROW_STATE.INSERT:
|
|
3981
|
+
this.classList.add("is-insert");
|
|
3982
|
+
break;
|
|
3983
|
+
case r.ROW_STATE.UPDATE:
|
|
3984
|
+
this.classList.add("is-update");
|
|
3985
|
+
break;
|
|
3986
|
+
case r.ROW_STATE.DELETE: this.classList.add("is-delete");
|
|
3987
|
+
}
|
|
3988
|
+
let n = this.index + 1, i = n.toLocaleString();
|
|
3890
3989
|
if (n >= 1e4) {
|
|
3891
|
-
let e =
|
|
3990
|
+
let e = i.length - 4, t = i.substring(0, e + 1), n = i.substring(e + 1);
|
|
3892
3991
|
this.#e.innerHTML = `
|
|
3893
3992
|
<span class="ng-row-prefix">${t}</span>
|
|
3894
3993
|
<span class="ng-row-suffix">${n}</span>
|
|
3994
|
+
<div class="row-status"></div>
|
|
3895
3995
|
`;
|
|
3896
|
-
} else this.#e.innerHTML = `${
|
|
3897
|
-
let
|
|
3898
|
-
this.#t.innerHTML = e, this.#t.style.display =
|
|
3996
|
+
} else this.#e.innerHTML = `${i}`;
|
|
3997
|
+
let a = !!this.sheet.querySelector("thead .asc,thead .desc"), o = !!this.sheet.querySelector("thead nine-table-filter-button.filtered");
|
|
3998
|
+
this.#t.innerHTML = e, this.#t.style.display = a || o ? "" : "none";
|
|
3899
3999
|
};
|
|
3900
4000
|
};
|
|
3901
4001
|
customElements.get("cell-row-indicator") || customElements.define("cell-row-indicator", X);
|