@ninebone/datagrid 0.0.24 → 0.1.2
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 +111 -5
- package/dist/css/nine-table.css +119 -26
- package/dist/nine-table.js +291 -141
- package/dist/nine-table.js.map +1 -1
- package/dist/nine-table.umd.js +12 -16
- package/dist/nine-table.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-table.js
CHANGED
|
@@ -287,12 +287,12 @@ var n = new class extends e.constructor {
|
|
|
287
287
|
}
|
|
288
288
|
}));
|
|
289
289
|
};
|
|
290
|
-
setValue = (e, t, n) => {
|
|
290
|
+
setValue = (e, t, n, i = !0) => {
|
|
291
291
|
e = parseInt(e, 10);
|
|
292
|
-
let
|
|
293
|
-
if (
|
|
294
|
-
let
|
|
295
|
-
|
|
292
|
+
let a = this.getHostFields().indexOf(t);
|
|
293
|
+
if (a < 0) return;
|
|
294
|
+
let o = this.#u(e), s = this.#t.rawRecords[o];
|
|
295
|
+
s && (s.v[a] !== n && i && s.m._[r.META.INDEX.ROW_STATE] !== r.ROW_STATE.INSERT && (s.m._[r.META.INDEX.ROW_STATE] = r.ROW_STATE.UPDATE), s.v[a] = n);
|
|
296
296
|
};
|
|
297
297
|
getChangedData = (e) => {
|
|
298
298
|
let t = this.#t.rawRecords;
|
|
@@ -1004,7 +1004,9 @@ var m = {
|
|
|
1004
1004
|
});
|
|
1005
1005
|
let e = this.#n.querySelector(".ng-sheet-body");
|
|
1006
1006
|
e && (this.#o = e.clientHeight, this.#m(), this.#g(), this.#u(e.scrollTop, !0), e.addEventListener("scroll", (t) => {
|
|
1007
|
-
if (this.#
|
|
1007
|
+
if (this.#n.querySelectorAll("cell-combo-panel").forEach((e) => {
|
|
1008
|
+
e.classList.remove("active");
|
|
1009
|
+
}), this.#c) return;
|
|
1008
1010
|
let n = this.#n.template.height || 0;
|
|
1009
1011
|
(this.#n.view.getArray()?.length || 0) * n <= e.clientHeight || (this.#u(e.scrollTop), this.#n.querySelector("nine-table-vscrollbar").refresh());
|
|
1010
1012
|
}, { passive: !0 }));
|
|
@@ -1027,7 +1029,9 @@ var m = {
|
|
|
1027
1029
|
destroy = () => {
|
|
1028
1030
|
this.#a &&= (this.#a.disconnect(), null);
|
|
1029
1031
|
};
|
|
1030
|
-
#m = () => {
|
|
1032
|
+
#m = () => {
|
|
1033
|
+
this.#h();
|
|
1034
|
+
};
|
|
1031
1035
|
#h = () => {
|
|
1032
1036
|
if (this.#o > 0 && this.#n.template.height > 0) {
|
|
1033
1037
|
let e = Math.ceil(this.#o / this.#n.template.height), t = this.#e;
|
|
@@ -1063,7 +1067,6 @@ var m = {
|
|
|
1063
1067
|
});
|
|
1064
1068
|
if (n.length === 0) return;
|
|
1065
1069
|
let r = e.querySelector("tbody.body");
|
|
1066
|
-
if (!r) return;
|
|
1067
1070
|
r.querySelectorAll("tr").forEach((e) => e.remove());
|
|
1068
1071
|
let i = document.createDocumentFragment();
|
|
1069
1072
|
for (let e = 0; e < this.#s; e++) n.forEach((e) => i.appendChild(e.cloneNode(!0)));
|
|
@@ -1125,16 +1128,17 @@ var m = {
|
|
|
1125
1128
|
}
|
|
1126
1129
|
}, y = class {
|
|
1127
1130
|
#e;
|
|
1128
|
-
#t
|
|
1131
|
+
#t;
|
|
1132
|
+
#n = {
|
|
1129
1133
|
startRow: -1,
|
|
1130
1134
|
startCol: -1,
|
|
1131
1135
|
endRow: -1,
|
|
1132
1136
|
endCol: -1
|
|
1133
1137
|
};
|
|
1134
1138
|
constructor(e) {
|
|
1135
|
-
this.#e = e, this.#
|
|
1139
|
+
this.#e = e, this.#t = e.getRootNode().host, this.#i();
|
|
1136
1140
|
}
|
|
1137
|
-
#
|
|
1141
|
+
#r(e) {
|
|
1138
1142
|
if (!e) return {
|
|
1139
1143
|
dataRow: -1,
|
|
1140
1144
|
subRowIndex: -1,
|
|
@@ -1163,45 +1167,57 @@ var m = {
|
|
|
1163
1167
|
n && (n.classList.add("selected-start"), n.closest("tr")?.classList.add("selected-start"));
|
|
1164
1168
|
}
|
|
1165
1169
|
setRange(e, t, n, r) {
|
|
1166
|
-
let i = Math.min(e, n), a = Math.max(e, n), o = Math.min(t, r), s = Math.max(t, r)
|
|
1170
|
+
let i = Math.min(e, n), a = Math.max(e, n), o = Math.min(t, r), s = Math.max(t, r);
|
|
1171
|
+
this.#t.tagName === "NINE-TABLE-SIMPLE" && (o = 1, s = 10);
|
|
1172
|
+
let c = this.#e.querySelectorAll(".ng-container-left, .ng-container-body, .ng-container-right"), l = !0, u = 0;
|
|
1167
1173
|
for (; l && u < 5;) l = !1, u++, c.forEach((e) => {
|
|
1168
1174
|
Array.from(e.querySelectorAll("tbody tr")).filter((e) => e.style.display !== "none").forEach((e) => {
|
|
1169
|
-
let { matrixRow: t } = this.#
|
|
1175
|
+
let { matrixRow: t } = this.#r(e);
|
|
1170
1176
|
t < 0 || e.querySelectorAll("td, th").forEach((e) => {
|
|
1171
1177
|
let n = parseInt(e.dataset.col, 10);
|
|
1172
|
-
if (isNaN(n))
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1178
|
+
if (!isNaN(n) && this.#e.querySelector(`col[data-col="${n}"]`).style.display !== "none") {
|
|
1179
|
+
let r = parseInt(e.rowSpan || 1, 10), c = parseInt(e.colSpan || 1, 10), u = t + r - 1, d = n + c - 1;
|
|
1180
|
+
if (u >= i && t <= a && d >= o && n <= s) {
|
|
1181
|
+
let e = Math.min(i, t), r = Math.max(a, u), c = Math.min(o, n), f = Math.max(s, d);
|
|
1182
|
+
(e !== i || r !== a || c !== o || f !== s) && (i = e, a = r, o = c, s = f, l = !0);
|
|
1183
|
+
}
|
|
1177
1184
|
}
|
|
1178
1185
|
});
|
|
1179
1186
|
});
|
|
1180
1187
|
});
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1188
|
+
let d = (e) => Number.isFinite(e) ? e : -1;
|
|
1189
|
+
this.#n = {
|
|
1190
|
+
startRow: d(i),
|
|
1191
|
+
startCol: d(o),
|
|
1192
|
+
endRow: d(a),
|
|
1193
|
+
endCol: d(s)
|
|
1186
1194
|
}, this.render();
|
|
1187
1195
|
}
|
|
1196
|
+
clear = () => {
|
|
1197
|
+
this.#n = {
|
|
1198
|
+
startRow: -1,
|
|
1199
|
+
startCol: -1,
|
|
1200
|
+
endRow: -1,
|
|
1201
|
+
endCol: -1
|
|
1202
|
+
};
|
|
1203
|
+
};
|
|
1188
1204
|
get minRow() {
|
|
1189
|
-
return this.#
|
|
1205
|
+
return this.#n.startRow;
|
|
1190
1206
|
}
|
|
1191
1207
|
get maxRow() {
|
|
1192
|
-
return this.#
|
|
1208
|
+
return this.#n.endRow;
|
|
1193
1209
|
}
|
|
1194
1210
|
get minCol() {
|
|
1195
|
-
return this.#
|
|
1211
|
+
return this.#n.startCol;
|
|
1196
1212
|
}
|
|
1197
1213
|
get maxCol() {
|
|
1198
|
-
return this.#
|
|
1214
|
+
return this.#n.endCol;
|
|
1199
1215
|
}
|
|
1200
1216
|
refresh = () => {
|
|
1201
1217
|
this.render();
|
|
1202
1218
|
};
|
|
1203
1219
|
render = () => {
|
|
1204
|
-
let { startRow: e, startCol: t, endRow: n, endCol: r } = this.#
|
|
1220
|
+
let { startRow: e, startCol: t, endRow: n, endCol: r } = this.#n, i = this.#e.querySelectorAll(".ng-container-left, .ng-container-body, .ng-container-right");
|
|
1205
1221
|
i.forEach((e) => {
|
|
1206
1222
|
e.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right, .selected-start").forEach((e) => {
|
|
1207
1223
|
e.classList.remove("selected", "selected-top", "selected-bottom", "selected-left", "selected-right", "selected-start");
|
|
@@ -1210,7 +1226,7 @@ var m = {
|
|
|
1210
1226
|
});
|
|
1211
1227
|
}), e < 0 || t < 0 || i.forEach((i) => {
|
|
1212
1228
|
Array.from(i.querySelectorAll("tbody tr")).filter((e) => e.style.display !== "none").forEach((a) => {
|
|
1213
|
-
let { matrixRow: o } = this.#
|
|
1229
|
+
let { matrixRow: o } = this.#r(a);
|
|
1214
1230
|
o < 0 || (o >= e && o <= n && i.querySelectorAll(`tbody tr[data-index="${a.dataset.index}"]`).forEach((e) => {
|
|
1215
1231
|
e.classList.add("selected");
|
|
1216
1232
|
}), a.querySelectorAll("td, th").forEach((i) => {
|
|
@@ -1222,14 +1238,14 @@ var m = {
|
|
|
1222
1238
|
});
|
|
1223
1239
|
});
|
|
1224
1240
|
};
|
|
1225
|
-
#
|
|
1241
|
+
#i() {
|
|
1226
1242
|
let e = this.#e.querySelector(".ng-sheet-body");
|
|
1227
1243
|
e && e.addEventListener("mousedown", (e) => {
|
|
1228
1244
|
if (e.button !== 0) return;
|
|
1229
1245
|
let t = e.target.closest("td, th");
|
|
1230
1246
|
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
1231
1247
|
this.#e.style.userSelect = "none", this.#e.style.webkitUserSelect = "none";
|
|
1232
|
-
let n = t.closest("tr"), { matrixRow: r } = this.#
|
|
1248
|
+
let n = t.closest("tr"), { matrixRow: r } = this.#r(n), i = parseInt(t.dataset.col, 10);
|
|
1233
1249
|
if (r < 0) {
|
|
1234
1250
|
this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "";
|
|
1235
1251
|
return;
|
|
@@ -1248,7 +1264,7 @@ var m = {
|
|
|
1248
1264
|
}
|
|
1249
1265
|
}
|
|
1250
1266
|
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
1251
|
-
let n = t.closest("tr"), { matrixRow: s } = this.#
|
|
1267
|
+
let n = t.closest("tr"), { matrixRow: s } = this.#r(n), c = parseInt(t.dataset.col, 10);
|
|
1252
1268
|
s < 0 || (a !== s || o !== c) && (a = s, o = c, this.setRange(r, i, s, c));
|
|
1253
1269
|
}, c = () => {
|
|
1254
1270
|
this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "", document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c);
|
|
@@ -1286,7 +1302,7 @@ var m = {
|
|
|
1286
1302
|
});
|
|
1287
1303
|
break;
|
|
1288
1304
|
case "ArrowRight":
|
|
1289
|
-
this.#m(t) || t.scrollIntoView({
|
|
1305
|
+
this.#m(t) && this.#p(t) || t.scrollIntoView({
|
|
1290
1306
|
inline: "nearest",
|
|
1291
1307
|
block: "nearest"
|
|
1292
1308
|
});
|
|
@@ -1449,14 +1465,20 @@ var m = {
|
|
|
1449
1465
|
let t = e.target.closest("td, th");
|
|
1450
1466
|
t && t.dataset.index !== void 0 && t.dataset.col !== void 0 && (t.querySelector("cell-row-indicator") ? this.#e.row.focus(t.dataset.index) : this.currentCell = t);
|
|
1451
1467
|
}), this.#e.addEventListener("keydown", (e) => {
|
|
1452
|
-
|
|
1468
|
+
let t = e.target.closest("td,th");
|
|
1469
|
+
t && this.#e.contains(t) && (this.#t.tagName === "NINE-TABLE-SIMPLE" ? [
|
|
1470
|
+
"ArrowUp",
|
|
1471
|
+
"ArrowDown",
|
|
1472
|
+
"ArrowLeft",
|
|
1473
|
+
"ArrowRight"
|
|
1474
|
+
].includes(e.code) && this.moveCell(e) : [
|
|
1453
1475
|
"Enter",
|
|
1454
1476
|
"Tab",
|
|
1455
1477
|
"ArrowUp",
|
|
1456
1478
|
"ArrowDown",
|
|
1457
1479
|
"ArrowLeft",
|
|
1458
1480
|
"ArrowRight"
|
|
1459
|
-
].includes(e.code)
|
|
1481
|
+
].includes(e.code) ? this.moveCell(e) : ["Space"].includes(e.code) && e.preventDefault());
|
|
1460
1482
|
});
|
|
1461
1483
|
}
|
|
1462
1484
|
}, x = 2, S = class {
|
|
@@ -1495,9 +1517,7 @@ var m = {
|
|
|
1495
1517
|
e.style.width = `${r}px`;
|
|
1496
1518
|
}) : (t.style.flex = `0 0 ${r}px`, t.style.width = `${r}px`, t.style.minWidth = `${r}px`, t.style.maxWidth = `${r}px`, n.forEach((e) => {
|
|
1497
1519
|
e.style.width = `${r}px`, e.style.minWidth = `${r}px`, e.style.maxWidth = `${r}px`, Object.entries(i).forEach(([t, n]) => {
|
|
1498
|
-
e.querySelectorAll(`th[data-col="${t}"], td[data-col="${t}"]`).forEach((e) => {
|
|
1499
|
-
e.style.width = `${n}px`, e.style.minWidth = `${n}px`, e.style.maxWidth = `${n}px`;
|
|
1500
|
-
});
|
|
1520
|
+
e.querySelectorAll(`th[data-col="${t}"], td[data-col="${t}"]`).forEach((e) => {});
|
|
1501
1521
|
});
|
|
1502
1522
|
}));
|
|
1503
1523
|
});
|
|
@@ -2187,7 +2207,7 @@ var w = class {
|
|
|
2187
2207
|
}
|
|
2188
2208
|
}
|
|
2189
2209
|
e.m._[r.META.INDEX.FILTER][n] = o;
|
|
2190
|
-
}), this.#e.invalidate();
|
|
2210
|
+
}), this.#e.selection.clear(), this.#e.invalidate();
|
|
2191
2211
|
}
|
|
2192
2212
|
};
|
|
2193
2213
|
customElements.get("nine-table-filter-panel") || customElements.define("nine-table-filter-panel", E), customElements.get("nine-table-filter-button") || customElements.define("nine-table-filter-button", D);
|
|
@@ -2511,7 +2531,7 @@ var k = class {
|
|
|
2511
2531
|
});
|
|
2512
2532
|
}
|
|
2513
2533
|
static #u(e, t) {
|
|
2514
|
-
let n = e.getAttribute("row-indicator") === "true" ? 48 :
|
|
2534
|
+
let n = e.getAttribute("row-indicator") === "true" ? 48 : 4, r = e.querySelector("colgroup"), i = document.createElement("col");
|
|
2515
2535
|
i.setAttribute("fixed", "left"), i.setAttribute("width", n), i.style.width = `${n}px`, r.prepend(i), e.querySelectorAll("thead, tbody, tfoot").forEach((e) => {
|
|
2516
2536
|
let t = Array.from(e.querySelectorAll("tr"));
|
|
2517
2537
|
if (t.length === 0) return;
|
|
@@ -2528,10 +2548,7 @@ var k = class {
|
|
|
2528
2548
|
let r = n + t, a = e.querySelector(`colgroup col[data-col="${r}"]`);
|
|
2529
2549
|
a && (i += parseInt(a.getAttribute("width"), 10) || 100);
|
|
2530
2550
|
}
|
|
2531
|
-
|
|
2532
|
-
let e = `${i}px`;
|
|
2533
|
-
t.style.width = e, t.style.minWidth = e, t.style.maxWidth = e;
|
|
2534
|
-
}
|
|
2551
|
+
i > 0 && `${i}`;
|
|
2535
2552
|
});
|
|
2536
2553
|
}
|
|
2537
2554
|
}, M = class {
|
|
@@ -2540,16 +2557,52 @@ var k = class {
|
|
|
2540
2557
|
constructor(e) {
|
|
2541
2558
|
this.#e = e, this.#t = e.getRootNode().host;
|
|
2542
2559
|
}
|
|
2560
|
+
col = {
|
|
2561
|
+
setWidth: (e, t, n = null) => {
|
|
2562
|
+
Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)).forEach((e) => {
|
|
2563
|
+
e.setAttribute("width", t), e.style.width = `${t}px`;
|
|
2564
|
+
});
|
|
2565
|
+
},
|
|
2566
|
+
getWidth: (e) => {
|
|
2567
|
+
let t = this.#e.querySelector(`table colgroup col[data-col="${e}"]`);
|
|
2568
|
+
return t && parseInt(t.getAttribute("width") || t.style.width, 10) || 0;
|
|
2569
|
+
},
|
|
2570
|
+
measureAutoFitColumnWidth: (e, t) => {
|
|
2571
|
+
let n = this.#t.fields.get().indexOf(t.dataset.bind), r = window.getComputedStyle(t).font || "12px sans-serif", i = 32;
|
|
2572
|
+
return this.#e.view.getArray().forEach((e, a) => {
|
|
2573
|
+
let o = String(t.dataset.expr ? this.#t.exprEngine.evaluate(t.dataset.expr, e, a) : e.v[n] ?? "").trim(), s = nine.measureTextSize(o, r);
|
|
2574
|
+
s.width && s.width > i && (i = s.width);
|
|
2575
|
+
}), i;
|
|
2576
|
+
},
|
|
2577
|
+
autoFit: (e) => {
|
|
2578
|
+
let t = this.#e.querySelector(`thead th[data-col="${e}"]`), n = this.#e.querySelector(`tbody.body [data-col="${e}"]`);
|
|
2579
|
+
t && n && this.#t.execute(() => {
|
|
2580
|
+
let r = this.col.measureAutoFitColumnWidth(t, n);
|
|
2581
|
+
r !== null && this.col.setWidth(e, r);
|
|
2582
|
+
});
|
|
2583
|
+
},
|
|
2584
|
+
setVisible: (e, t) => {
|
|
2585
|
+
this.#e.querySelectorAll(`table colgroup col[data-col="${e}"], th[data-col="${e}"], td[data-col="${e}"]`).forEach((e) => {
|
|
2586
|
+
e.style.display = t ? "" : "none";
|
|
2587
|
+
}), this.#e.rowManager?.refresh();
|
|
2588
|
+
}
|
|
2589
|
+
};
|
|
2543
2590
|
row = {
|
|
2544
|
-
at: () => Math.floor(this.#e.selection.minRow / this.#e.template.length),
|
|
2545
|
-
focus: (e) => {
|
|
2546
|
-
this.#e.row.isVisible(e)
|
|
2547
|
-
|
|
2548
|
-
|
|
2591
|
+
at: () => this.#e.selection.minRow < 0 ? -1 : Math.floor(this.#e.selection.minRow / this.#e.template.length),
|
|
2592
|
+
focus: async (e, t) => {
|
|
2593
|
+
this.#e.row.isVisible(e) ? await new Promise((e) => requestAnimationFrame(e)) : await new Promise((t) => {
|
|
2594
|
+
this.#e.row.moveTo(e, () => {
|
|
2595
|
+
t();
|
|
2596
|
+
});
|
|
2597
|
+
});
|
|
2598
|
+
let n = this.#e.querySelectorAll(`tbody.body tr[data-index="${e}"]`), r = Array.from(n, (e) => parseInt(e.dataset.matrixRow, 10)).filter((e) => !isNaN(e)), i = [];
|
|
2599
|
+
if (n.forEach((e) => {
|
|
2549
2600
|
e.querySelectorAll("td, th").forEach((e) => {
|
|
2550
|
-
parseInt(e.dataset.col, 10) != 0 &&
|
|
2601
|
+
parseInt(e.dataset.col, 10) != 0 && i.push(parseInt(e.dataset.col, 10));
|
|
2551
2602
|
});
|
|
2552
|
-
}),
|
|
2603
|
+
}), r.length === 0 || i.length === 0) return;
|
|
2604
|
+
let a = this.#e.selection.setRange(Math.min(...r), Math.min(...i), Math.max(...r), Math.max(...i));
|
|
2605
|
+
return typeof t == "function" && t(), a;
|
|
2553
2606
|
},
|
|
2554
2607
|
isVisible: (e) => {
|
|
2555
2608
|
let t = this.#e.querySelector(".ng-sheet-body"), n = t.querySelectorAll(`.ng-container-body tbody.body tr[data-index="${e}"]`);
|
|
@@ -2566,7 +2619,9 @@ var k = class {
|
|
|
2566
2619
|
},
|
|
2567
2620
|
add: (e, t) => this.#t.data.add(e, t),
|
|
2568
2621
|
moveTo: (e, t) => {
|
|
2569
|
-
this.#e.row.isVisible(e)
|
|
2622
|
+
this.#e.row.isVisible(e) ? typeof t == "function" && t() : this.#e.scrollTo(e, () => {
|
|
2623
|
+
typeof t == "function" && t();
|
|
2624
|
+
});
|
|
2570
2625
|
},
|
|
2571
2626
|
insert: (e, t, n = !0) => {
|
|
2572
2627
|
let i = this.#e.view.get(e).m._[r.META.INDEX.ROWID], a = this.#t.data.insert(i, t, n);
|
|
@@ -2755,18 +2810,24 @@ var k = class {
|
|
|
2755
2810
|
}
|
|
2756
2811
|
};
|
|
2757
2812
|
generateTemplate = (e, t) => {
|
|
2758
|
-
|
|
2813
|
+
let n = (e) => {
|
|
2814
|
+
if (["NINE-TABLE-SIMPLE"].includes(this.#t.tagName)) {
|
|
2815
|
+
let t = this.#t.closest("nine-table-filter-panel, cell-combo-panel");
|
|
2816
|
+
t && (e ? t.classList.add("active") : t.classList.remove("active"));
|
|
2817
|
+
}
|
|
2818
|
+
};
|
|
2819
|
+
if (n(!0), this.#e = t, this.#p = {
|
|
2759
2820
|
table: v.compile(e),
|
|
2760
2821
|
tbody: { tr: e.querySelectorAll("tbody tr") }
|
|
2761
2822
|
}, this.querySelector(".ng-container-body").appendChild(this.#p.table), this.#h.height = this.#h.length = 0, this.#h.heights = [], this.querySelectorAll(".ng-container-body tbody.body tr").forEach((e) => {
|
|
2762
|
-
this.#h.height += e.offsetHeight || 0, this.#h.heights.push(e.offsetHeight || 0);
|
|
2823
|
+
this.#h.height += Math.max(e.offsetHeight || 0, 28), this.#h.heights.push(e.offsetHeight || 0);
|
|
2763
2824
|
}), this.#h.length = this.#h.heights.length, this.#e === 0) {
|
|
2764
2825
|
let e = parseInt(this.#t.getAttribute("display-min-rows"), 10), t = parseInt(this.#t.getAttribute("display-max-rows"), 10), n = (this.querySelector("nine-table-toolbar")?.offsetHeight || 0) + (this.querySelector("nine-table-footer")?.offsetHeight || 0) + (this.querySelector("thead")?.offsetHeight || 0) + (this.querySelector("tfoot")?.offsetHeight || 0) + (this.querySelector("tbody.head")?.offsetHeight || 0);
|
|
2765
2826
|
this.#t.getAttribute("auto-height") !== "true" && isNaN(e) && isNaN(t) || this.#t.setAttribute("scroll-bar", "none"), isNaN(e) || (this.#t.style.minHeight = n + this.#h.height * e + "px"), isNaN(t) || (this.#t.style.maxHeight = n + this.#h.height * t + "px");
|
|
2766
2827
|
}
|
|
2767
2828
|
this.querySelectorAll("tbody.body tr").forEach((e) => {
|
|
2768
2829
|
e.style.display = "none";
|
|
2769
|
-
}), this.querySelector(".ng-container-body table").remove();
|
|
2830
|
+
}), this.querySelector(".ng-container-body table").remove(), n(!1);
|
|
2770
2831
|
};
|
|
2771
2832
|
generate = () => {
|
|
2772
2833
|
this.#b(), this.#y(), this.#w(), this.#E(), [
|
|
@@ -2787,7 +2848,7 @@ var k = class {
|
|
|
2787
2848
|
}), this.#n.initialize(), this.isAutoFitCol ? this.autoFit(!0) : this.querySelector("nine-table-hscrollbar").refresh(), this.#u.initialize(), this.loaded = !0;
|
|
2788
2849
|
};
|
|
2789
2850
|
#y = () => {
|
|
2790
|
-
[
|
|
2851
|
+
this.#t.classList.contains("combo-list") || [
|
|
2791
2852
|
"left",
|
|
2792
2853
|
"right",
|
|
2793
2854
|
"body"
|
|
@@ -2848,12 +2909,14 @@ var k = class {
|
|
|
2848
2909
|
t && (t.scrollTop = e);
|
|
2849
2910
|
};
|
|
2850
2911
|
#S = () => {
|
|
2851
|
-
this.#C(), this.#r = new y(this), this.#i = new b(this), this.#a = new S(this), this.#o = new w(this), this.#s = new T(this), this.#f = new A(this), this.#l = new O(this), this.#u = new h(this), this.#g || (this.#c = new k(this)), this.#m.mainBody.addEventListener("scroll", () => {
|
|
2852
|
-
this.
|
|
2912
|
+
this.#C(), this.#r = new y(this), this.#i = new b(this), this.#a = new S(this), this.#o = new w(this), this.#s = new T(this), this.#f = new A(this), this.#l = new O(this), this.#u = new h(this), this.#g || (this.#c = new k(this)), this.#m.mainBody.addEventListener("scroll", (e) => {
|
|
2913
|
+
this.querySelectorAll("nine-table-filter-panel,cell-combo-panel").forEach((e) => {
|
|
2914
|
+
e.classList.remove("active");
|
|
2915
|
+
}), this.querySelector("nine-table-hscrollbar").refresh();
|
|
2853
2916
|
});
|
|
2854
2917
|
};
|
|
2855
2918
|
#C = () => {
|
|
2856
|
-
this.innerHTML = "\n <div class=\"ng-sheet-body\">\n <div class=\"ng-sheet-body-content\">\n <div class=\"ng-container-left\"></div>\n <div class=\"ng-container-body\">\n \n </div>\n <div class=\"ng-container-right\"></div>\n </div>\n <div class=\"ng-virtual-height-holder\"></div>\n </div>\n\n <div class=\"nodata-overlay\">Data Not Found</div>\n\n <nine-table-vscrollbar></nine-table-vscrollbar>\n <nine-table-hscrollbar></nine-table-hscrollbar>\n <div class=\"scroll-edge\"></div>\n \n <nine-table-col-resizer-panel></nine-table-col-resizer-panel>\n \n <div class=\"ng-col-mover-grip\"></div>\n <div class=\"ng-col-mover-indi\"></div>\n ", this.#m = {
|
|
2919
|
+
this.setAttribute("tabindex", "0"), this.innerHTML = "\n <div class=\"ng-sheet-body\">\n <div class=\"ng-sheet-body-content\">\n <div class=\"ng-container-left\"></div>\n <div class=\"ng-container-body\">\n \n </div>\n <div class=\"ng-container-right\"></div>\n </div>\n <div class=\"ng-virtual-height-holder\"></div>\n </div>\n\n <div class=\"nodata-overlay\">Data Not Found</div>\n\n <nine-table-vscrollbar></nine-table-vscrollbar>\n <nine-table-hscrollbar></nine-table-hscrollbar>\n <div class=\"scroll-edge\"></div>\n \n <nine-table-col-resizer-panel></nine-table-col-resizer-panel>\n \n \n <div class=\"ng-col-mover-grip\"></div>\n <div class=\"ng-col-mover-indi\"></div>\n ", this.#m = {
|
|
2857
2920
|
mainBody: this.querySelector(".ng-sheet-body .ng-container-body"),
|
|
2858
2921
|
hscrollbar: this.querySelector("nine-table-hscrollbar"),
|
|
2859
2922
|
vscrollbar: this.querySelector("nine-table-vscrollbar"),
|
|
@@ -2930,7 +2993,7 @@ var P = class {
|
|
|
2930
2993
|
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = e.length, n = e.map((e, n) => {
|
|
2931
2994
|
let r = n === 0 ? "active" : "", i = e.id || `sheet${n + 1}`;
|
|
2932
2995
|
return `<nine-table-sheet class="${r}" data-index="${n}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>` + (n < t - 1 ? `<nine-splitter class="h" data-split-index="${n}"></nine-splitter>` : "");
|
|
2933
|
-
}).join(""), r = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.
|
|
2996
|
+
}).join(""), r = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/datagrid@0.1.2/dist/css/nine-table.css\";"];
|
|
2934
2997
|
nine["nine-table"] && nine["nine-table"].cssFile && r.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
|
|
2935
2998
|
<style>
|
|
2936
2999
|
${r.join("\n")}
|
|
@@ -2980,9 +3043,8 @@ var P = class {
|
|
|
2980
3043
|
#i = () => {
|
|
2981
3044
|
this.#e.shadowRoot.querySelectorAll("nine-table-sheet").forEach((e) => {
|
|
2982
3045
|
if (e.index === 0) {
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
this.#e.style.height = r + i + "px";
|
|
3046
|
+
let t = (e.querySelector("thead")?.offsetHeight || 0) + (e.querySelector("tfoot")?.offsetHeight || 0) + (e.querySelector("tbody.head")?.offsetHeight || 0), n = this.#e.offsetHeight - e.offsetHeight + t, r = Math.min(e.template.height * e.view.count(), window.innerHeight * .8);
|
|
3047
|
+
this.#e.style.height = n + r + "px";
|
|
2986
3048
|
}
|
|
2987
3049
|
});
|
|
2988
3050
|
};
|
|
@@ -3044,7 +3106,7 @@ var P = class {
|
|
|
3044
3106
|
}, L = class {
|
|
3045
3107
|
#e;
|
|
3046
3108
|
constructor(e) {
|
|
3047
|
-
this.#e = e, ["row"].forEach((e) => {
|
|
3109
|
+
this.#e = e, ["col", "row"].forEach((e) => {
|
|
3048
3110
|
this[e] = new Proxy({}, { get: (t, n) => {
|
|
3049
3111
|
let r = this.#t();
|
|
3050
3112
|
if (!r || !r[e]) return;
|
|
@@ -3068,7 +3130,7 @@ var P = class {
|
|
|
3068
3130
|
#i;
|
|
3069
3131
|
#a = 0;
|
|
3070
3132
|
constructor() {
|
|
3071
|
-
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.
|
|
3133
|
+
super(), ["NINE-TABLE"].includes(this.tagName) && n.log("Welcome nine-table", "0.1.2"), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this), this.#r = new I(this), this.#i = new L(this), this.#c();
|
|
3072
3134
|
}
|
|
3073
3135
|
connectedCallback() {
|
|
3074
3136
|
setTimeout(() => {
|
|
@@ -3189,6 +3251,9 @@ var z = class extends HTMLElement {
|
|
|
3189
3251
|
constructor() {
|
|
3190
3252
|
super();
|
|
3191
3253
|
}
|
|
3254
|
+
get #a() {
|
|
3255
|
+
return this.#r.getAttribute("update-row-state") === "false";
|
|
3256
|
+
}
|
|
3192
3257
|
get host() {
|
|
3193
3258
|
return this.#e;
|
|
3194
3259
|
}
|
|
@@ -3275,7 +3340,7 @@ var z = class extends HTMLElement {
|
|
|
3275
3340
|
set value(e) {
|
|
3276
3341
|
if (!this.#r || !this.#e?.data) return;
|
|
3277
3342
|
let t = parseInt(this.#n.dataset.row, 10), n = this.#r.dataset.bind;
|
|
3278
|
-
!isNaN(t) && n && this.#e.data.setValue(t, n, e);
|
|
3343
|
+
!isNaN(t) && n && this.#e.data.setValue(t, n, e, this.#a);
|
|
3279
3344
|
}
|
|
3280
3345
|
get row() {
|
|
3281
3346
|
return parseInt(this.#r?.dataset?.row, 10);
|
|
@@ -3843,23 +3908,31 @@ var Y = class extends HTMLElement {
|
|
|
3843
3908
|
#t;
|
|
3844
3909
|
#n;
|
|
3845
3910
|
#r = !1;
|
|
3911
|
+
#i;
|
|
3912
|
+
#a;
|
|
3913
|
+
#o;
|
|
3846
3914
|
constructor() {
|
|
3847
3915
|
super();
|
|
3848
3916
|
}
|
|
3849
3917
|
connectedCallback() {
|
|
3850
|
-
this.#
|
|
3918
|
+
this.#x(), this.#i = this.querySelector("nine-table-simple"), setTimeout(() => {
|
|
3919
|
+
this.#a = this.#i.shadowRoot.querySelector("nine-table-sheet"), this.#b();
|
|
3920
|
+
});
|
|
3851
3921
|
}
|
|
3852
|
-
#
|
|
3922
|
+
#s = (e, t, n, i) => {
|
|
3853
3923
|
let a = this.querySelector("nine-table-simple");
|
|
3854
3924
|
if (!a || !e || e.length === 0) return;
|
|
3855
|
-
let o = this.#e.getAttribute("items"), s = [];
|
|
3925
|
+
let o = this.#e.closest("th,td").getAttribute("items"), s = [];
|
|
3856
3926
|
s = o ? o.split(",").map((e) => e.trim()) : [n].filter(Boolean);
|
|
3857
|
-
let c = s.length;
|
|
3858
|
-
|
|
3927
|
+
let c = s.length, l = a.shadowRoot.querySelector("nine-table-sheet");
|
|
3928
|
+
l.source.table.querySelectorAll("colgroup col, tbody td").forEach((e, t) => {
|
|
3929
|
+
let n = parseInt(e.dataset.col, 10);
|
|
3930
|
+
n >= 2 && (e.style.display = n - 2 >= c ? "none" : "");
|
|
3931
|
+
}), a.shadowRoot.querySelectorAll("table colgroup col").forEach((e, t) => {
|
|
3859
3932
|
let n = parseInt(e.dataset.col, 10);
|
|
3860
3933
|
n >= 2 && (e.style.display = n - 2 >= c ? "none" : "");
|
|
3861
3934
|
});
|
|
3862
|
-
let
|
|
3935
|
+
let u = e.map((e) => {
|
|
3863
3936
|
let n = {
|
|
3864
3937
|
CHK: "N",
|
|
3865
3938
|
k: t && e[t] !== void 0 ? e[t] : e[0] === void 0 ? "" : e[0]
|
|
@@ -3868,58 +3941,130 @@ var Y = class extends HTMLElement {
|
|
|
3868
3941
|
n[`tmp${r + 1}`] = e[t] === void 0 ? e[r] === void 0 ? "" : e[r] : e[t];
|
|
3869
3942
|
}), n;
|
|
3870
3943
|
});
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3944
|
+
a.addEventListener(r.EVENT.ROW_ADDED, () => {
|
|
3945
|
+
setTimeout(() => {
|
|
3946
|
+
this.style.opacity = "", this.classList.add("active"), a.shadowRoot.querySelectorAll("colgroup col").forEach((e, t) => {
|
|
3947
|
+
let n = parseInt(e.dataset.col, 10);
|
|
3948
|
+
n >= 2 && e.style.display !== "none" && l.col.autoFit(n);
|
|
3949
|
+
});
|
|
3950
|
+
let e = this.#i.fields.get();
|
|
3951
|
+
if (i) {
|
|
3952
|
+
let t = this.#e.value ? String(this.#e.value).split(this.#o).map((e) => e.trim()) : [], n = e.indexOf("k"), r = e.indexOf("CHK");
|
|
3953
|
+
this.#i.data.getArray().forEach((e) => {
|
|
3954
|
+
e.v[r] = t.includes(String(e.v[n])) ? "Y" : "N";
|
|
3955
|
+
});
|
|
3956
|
+
let i = this.#a.view.getArray().findIndex((e, r) => e.v[n] === t[0]);
|
|
3957
|
+
this.#_(i);
|
|
3958
|
+
} else {
|
|
3959
|
+
let t = this.#e.value, n = e.indexOf("k"), r = this.#a.view.getArray().findIndex((e, r) => e.v[n] === t);
|
|
3960
|
+
this.#_(r);
|
|
3961
|
+
}
|
|
3962
|
+
});
|
|
3963
|
+
}, { once: !0 }), i && this.#e.value, u.length * this.#a.template.height >= this.offsetHeight ? this.classList.add("expand") : this.classList.remove("expand"), a.data.set(u);
|
|
3964
|
+
};
|
|
3965
|
+
#c = (e) => {
|
|
3966
|
+
let t = e.closest(".ng-sheet-body"), n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
3967
|
+
return r.bottom - n.bottom >= n.top - r.top;
|
|
3968
|
+
};
|
|
3969
|
+
#l = (e, t = 0) => {
|
|
3970
|
+
let n = e.closest(".ng-sheet-body"), r = e.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
3971
|
+
return (t ? i.bottom - r.bottom : r.top - i.top) - 5;
|
|
3972
|
+
};
|
|
3973
|
+
#u = (e) => {
|
|
3974
|
+
let t = e.closest("th,td"), n = t.closest(".ng-sheet-body"), r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = r.left - i.left, o = this.offsetWidth;
|
|
3975
|
+
return a + o > i.width && (a = Math.max(0, i.width - o - 2)), a < 0 && (a = 5), a;
|
|
3877
3976
|
};
|
|
3878
3977
|
open = (e, t, n, r, i, a) => {
|
|
3879
|
-
this.#e = e, this.#t = n, this.#n = r, this.#r = !0, this.classList.add("active")
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
if (!c || !s) return;
|
|
3885
|
-
let l = c.getBoundingClientRect(), u = s.getBoundingClientRect(), d = l.left - u.left, f = l.bottom - u.top + 2, p = this.offsetWidth || 250, m = this.offsetHeight || 250;
|
|
3886
|
-
if (d + p > u.width && (d = Math.max(0, u.width - p - 5)), d < 0 && (d = 5), f + m > u.height) {
|
|
3887
|
-
let e = l.top - u.top - m - 2;
|
|
3888
|
-
f = e >= 0 ? e : Math.max(0, u.height - m - 5);
|
|
3889
|
-
}
|
|
3890
|
-
this.style.left = `${d}px`, this.style.top = `${f}px`, setTimeout(() => {
|
|
3891
|
-
this.#i(t, n, r, i, a);
|
|
3892
|
-
let e = o.shadowRoot.querySelector(".ng-container-body table tbody.body");
|
|
3893
|
-
e.__hasClickEvent ||= (e.addEventListener("mousedown", (e) => {
|
|
3894
|
-
e.target.closest("tr") && (i || this.#a(e));
|
|
3895
|
-
}), !0);
|
|
3978
|
+
this.#e = e, this.#t = n, this.#n = r, this.#r = !0, this.#o = a, this.classList.add("active"), this.style.opacity = "0", setTimeout(() => {
|
|
3979
|
+
if (!this.querySelector("nine-table-simple") || !t) return;
|
|
3980
|
+
this.querySelector(".search-input").value = "", this.querySelector("#chkAll").checked = !0;
|
|
3981
|
+
let a = e.closest(".ng-sheet-body"), o = e.getBoundingClientRect(), s = a.getBoundingClientRect(), c = this.#c(e), l = this.#l(e, c), u = this.#u(e), d = c ? o.bottom - s.top : o.top - s.top - l;
|
|
3982
|
+
this.style.height = `${l}px`, this.style.left = `${u}px`, this.style.top = `${d}px`, i ? (this.classList.add("multi"), this.#i.classList.add("multi")) : (this.classList.remove("multi"), this.#i.classList.remove("multi")), this.#s(t, n, r, i);
|
|
3896
3983
|
}, 100);
|
|
3897
3984
|
};
|
|
3898
3985
|
close = () => {
|
|
3899
3986
|
this.classList.remove("active"), this.#r = !1, this.#e && this.#e.cell && this.#e.cell.focus();
|
|
3900
3987
|
};
|
|
3901
|
-
#
|
|
3902
|
-
let t = e.target.closest("
|
|
3903
|
-
this.#
|
|
3988
|
+
#d = (e) => {
|
|
3989
|
+
let t = e.target.closest("th,td");
|
|
3990
|
+
if (this.#i.classList.contains("multi")) {
|
|
3991
|
+
let e = parseInt(t?.dataset.index, 10);
|
|
3992
|
+
this.#g(e);
|
|
3993
|
+
} else parseInt(t?.dataset.col, 10) >= 2 && this.#h();
|
|
3904
3994
|
};
|
|
3905
|
-
#
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3995
|
+
#f = (e) => {
|
|
3996
|
+
switch (e.code) {
|
|
3997
|
+
case "Enter":
|
|
3998
|
+
case "ArrowDown":
|
|
3999
|
+
let e = this.#i.row.at();
|
|
4000
|
+
e < 0 ? this.#_(0) : this.#_(e);
|
|
4001
|
+
break;
|
|
4002
|
+
case "Tab": this.#_(this.#i.row.at());
|
|
4003
|
+
}
|
|
3910
4004
|
};
|
|
3911
|
-
#
|
|
3912
|
-
let t
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
4005
|
+
#p = (e) => {
|
|
4006
|
+
let t;
|
|
4007
|
+
switch (e.code) {
|
|
4008
|
+
case "Escape":
|
|
4009
|
+
this.close();
|
|
4010
|
+
break;
|
|
4011
|
+
case "Enter":
|
|
4012
|
+
this.classList.contains("multi") ? this.#m() : this.#h();
|
|
4013
|
+
break;
|
|
4014
|
+
case "Tab":
|
|
4015
|
+
this.classList.contains("expand") && (e.preventDefault(), this.querySelector("input[type='text']").focus());
|
|
4016
|
+
break;
|
|
4017
|
+
case "ArrowDown":
|
|
4018
|
+
t = this.#i.row.at(), t < 0 && this.#_(0);
|
|
4019
|
+
break;
|
|
4020
|
+
case "Space": e.preventDefault(), ["TH", "TD"].includes(e.target.tagName) && this.#g(this.#i.row.at());
|
|
4021
|
+
}
|
|
3916
4022
|
};
|
|
3917
|
-
#
|
|
3918
|
-
let t = e.
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
4023
|
+
#m = () => {
|
|
4024
|
+
let e = this.#i.fields.get(), t = e.indexOf("k"), n = e.indexOf("CHK"), r = [];
|
|
4025
|
+
this.#a.view.getArray().forEach((e) => {
|
|
4026
|
+
e.v[n] === "Y" && r.push(e.v[t]);
|
|
4027
|
+
}), this.#e.value = r.join(this.#o), this.#e.sheet.rowManager.refresh(!0), this.close();
|
|
4028
|
+
};
|
|
4029
|
+
#h = () => {
|
|
4030
|
+
let e = this.#i.row.at();
|
|
4031
|
+
if (e >= 0) {
|
|
4032
|
+
let t = this.#a.view.get(e);
|
|
4033
|
+
this.#e.value = t.k, this.#e.sheet.rowManager.refresh(!0), this.close();
|
|
4034
|
+
}
|
|
4035
|
+
};
|
|
4036
|
+
#g = (e) => {
|
|
4037
|
+
if (this.#i.classList.contains("multi") && e >= 0) {
|
|
4038
|
+
let t = this.#a.view.get(e);
|
|
4039
|
+
this.#i.data.setValue(t.m._[r.META.INDEX.ROWID], "CHK", t.CHK === "Y" ? "N" : "Y"), this.#i.refresh();
|
|
4040
|
+
}
|
|
4041
|
+
};
|
|
4042
|
+
#_ = (e) => {
|
|
4043
|
+
e === -1 ? (this.#a.row.focus(-1, () => {}), setTimeout(() => {
|
|
4044
|
+
this.#a.selection.clear(), this.#a.navigation.currentCell = this.#a.querySelector("tr[data-index=\"0\"] td[data-col=\"2\"]"), this.#a.focus(), this.#a.invalidate();
|
|
4045
|
+
})) : this.#a.row.focus(e, () => {
|
|
4046
|
+
setTimeout(() => {
|
|
4047
|
+
let t = this.#a.querySelector(`tr[data-index="${e}"] td[data-col="2"]`);
|
|
4048
|
+
this.#a.navigation.currentCell = t, t.focus(), this.#a.invalidate();
|
|
4049
|
+
});
|
|
4050
|
+
});
|
|
4051
|
+
};
|
|
4052
|
+
#v = (e) => {
|
|
4053
|
+
let t = this.#i.fields.get().indexOf("CHK");
|
|
4054
|
+
this.#i.data.getArray().forEach((n) => {
|
|
4055
|
+
n.v[t] = e.target.checked ? "Y" : "N";
|
|
4056
|
+
}), this.#a.invalidate();
|
|
4057
|
+
};
|
|
4058
|
+
#y = (e) => {
|
|
4059
|
+
let t = e.target.value.toLowerCase().trim();
|
|
4060
|
+
if (!t) this.#a.filtering.clear();
|
|
4061
|
+
else {
|
|
4062
|
+
let e = this.#i.data.getArray(), n = this.#i.fields.get(), r = "tmp1", i = n.indexOf(r), a = [];
|
|
4063
|
+
e.forEach((e) => {
|
|
4064
|
+
let n = i >= 0 && e.v ? e.v[i] : "";
|
|
4065
|
+
String(n).replace(/<[^>]*>?/gm, "").toLowerCase().includes(t) && a.push(n);
|
|
4066
|
+
}), this.#a.filtering.set({ [r]: [...new Set(a)] });
|
|
4067
|
+
}
|
|
3923
4068
|
};
|
|
3924
4069
|
get isOpen() {
|
|
3925
4070
|
return this.#r;
|
|
@@ -3927,13 +4072,13 @@ var Y = class extends HTMLElement {
|
|
|
3927
4072
|
get targetCell() {
|
|
3928
4073
|
return this.#e;
|
|
3929
4074
|
}
|
|
3930
|
-
#
|
|
3931
|
-
this.querySelector(".search-input").addEventListener("input", this.#
|
|
4075
|
+
#b = () => {
|
|
4076
|
+
this.querySelector(".search-input").addEventListener("input", this.#y), this.querySelector(".search-input").addEventListener("keydown", this.#f), this.querySelector("#btnOk").addEventListener("click", this.#m), this.querySelector("#chkAll").addEventListener("change", this.#v), this.#a.addEventListener("keydown", this.#p), this.#a.addEventListener("click", this.#d), document.addEventListener("mousedown", (e) => {
|
|
3932
4077
|
(e.composedPath ? e.composedPath() : []).includes(this) || this.close();
|
|
3933
4078
|
});
|
|
3934
4079
|
};
|
|
3935
|
-
#
|
|
3936
|
-
this.innerHTML = "\n <
|
|
4080
|
+
#x = () => {
|
|
4081
|
+
this.innerHTML = "\n <input type=\"text\" class=\"search-input\" placeholder=\"Search...\" />\n \n <nine-table-simple class=\"combo-list\" theme=\"simple\">\n <table auto-fit-col=\"true\">\n <colgroup>\n <col width=\"30\" fixed=\"left\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"100\" />\n <col width=\"0\" />\n </colgroup>\n <tbody>\n <tr>\n <td cell-type=\"checkbox\" data-bind=\"CHK\"></td>\n <td data-bind=\"tmp1\" />\n <td data-bind=\"tmp2\" />\n <td data-bind=\"tmp3\" />\n <td data-bind=\"tmp4\" />\n <td data-bind=\"tmp5\" />\n <td data-bind=\"tmp6\" />\n <td data-bind=\"tmp7\" />\n <td data-bind=\"tmp8\" />\n <td data-bind=\"tmp9\" />\n <td data-bind=\"tmp10\" />\n <td data-bind=\"k\" />\n </tr>\n </tbody>\n </table>\n </nine-table-simple>\n \n <div class=\"footer\">\n <label for=\"chkAll\"><input id=\"chkAll\" type=\"checkbox\" checked><span>Select All</span></label>\n <button id=\"btnOk\">OK</button>\n </div>\n ";
|
|
3937
4082
|
};
|
|
3938
4083
|
};
|
|
3939
4084
|
customElements.get("cell-combo-panel") || customElements.define("cell-combo-panel", Y);
|
|
@@ -3950,34 +4095,16 @@ var X = class extends H {
|
|
|
3950
4095
|
super();
|
|
3951
4096
|
}
|
|
3952
4097
|
connectedCallback() {
|
|
3953
|
-
|
|
4098
|
+
super.connectedCallback(), this.#l();
|
|
3954
4099
|
}
|
|
3955
4100
|
rerenderer = () => {
|
|
3956
|
-
this.#
|
|
3957
|
-
};
|
|
3958
|
-
#s = () => {
|
|
3959
|
-
if (!super.sheet || !super.cell) return;
|
|
3960
|
-
let e = super.cell?.getAttribute("data-source");
|
|
3961
|
-
e && (this.#t = super.getExprValue(e, super.tr.data, super.tr.dataset.row));
|
|
3962
|
-
};
|
|
3963
|
-
#c = () => {
|
|
3964
|
-
this.querySelectorAll("button").forEach((e) => {
|
|
3965
|
-
e.addEventListener("click", (e) => {
|
|
3966
|
-
e.stopPropagation(), this.#l();
|
|
3967
|
-
});
|
|
3968
|
-
});
|
|
3969
|
-
};
|
|
3970
|
-
#l = () => {
|
|
3971
|
-
this.#o || (this.#o = super.sheet.querySelector("cell-combo-panel"), this.#o || (this.#o = document.createElement("cell-combo-panel"), super.sheet.appendChild(this.#o))), this.#o.isOpen && this.#o.targetCell === this ? this.#o.close() : this.#o.open(this, this.#t, this.#n, this.#r, this.#i, this.#a);
|
|
3972
|
-
};
|
|
3973
|
-
#u = () => {
|
|
3974
|
-
this.innerHTML = "\n <button class=\"btn1\" type=\"button\" tabindex=\"-1\">Select</button>\n <button class=\"btn2\" type=\"button\" tabindex=\"-1\"></button>\n ", this.#e = this.querySelector(".btn1");
|
|
4101
|
+
this.#u(), this.refresh();
|
|
3975
4102
|
};
|
|
3976
4103
|
refresh = () => {
|
|
3977
4104
|
let e = super.refresh();
|
|
3978
|
-
return this.#e && (this.#e.textContent = this.#
|
|
4105
|
+
return this.#e && (this.#e.textContent = this.#s() || "Select", this.#c()), e;
|
|
3979
4106
|
};
|
|
3980
|
-
#
|
|
4107
|
+
#s = () => {
|
|
3981
4108
|
if (!this.value || !Array.isArray(this.#t)) return "";
|
|
3982
4109
|
if (this.#i) {
|
|
3983
4110
|
let e = String(this.value).split(this.#a);
|
|
@@ -3988,7 +4115,7 @@ var X = class extends H {
|
|
|
3988
4115
|
return e ? e[this.#r] : this.value;
|
|
3989
4116
|
}
|
|
3990
4117
|
};
|
|
3991
|
-
#
|
|
4118
|
+
#c = () => {
|
|
3992
4119
|
if (!super.cell || (super.cell.classList.remove("invalid"), this.value === null || this.value === void 0 || this.value === "" || !Array.isArray(this.#t))) return;
|
|
3993
4120
|
let e = this.#i ? String(this.value).split(this.#a) : [this.value];
|
|
3994
4121
|
for (let t of e) if (this.#t.findIndex((e) => String(t) === String(e[this.#n])) < 0) {
|
|
@@ -3996,6 +4123,29 @@ var X = class extends H {
|
|
|
3996
4123
|
break;
|
|
3997
4124
|
}
|
|
3998
4125
|
};
|
|
4126
|
+
#l = () => {
|
|
4127
|
+
this.#d(), this.#n = this.cell.getAttribute("key-name") || "k", this.#r = this.cell.getAttribute("value-name") || "v", this.#i = this.cell.getAttribute("multi") === "true", this.#a = this.cell.getAttribute("multi-separator") || ",", this.#u(), this.#f();
|
|
4128
|
+
};
|
|
4129
|
+
#u = () => {
|
|
4130
|
+
if (!super.sheet || !super.cell) return;
|
|
4131
|
+
let e = super.cell?.getAttribute("data-source");
|
|
4132
|
+
e && (this.#t = super.getExprValue(e, super.tr.data, super.tr.dataset.row));
|
|
4133
|
+
};
|
|
4134
|
+
#d = () => {
|
|
4135
|
+
this.innerHTML = "\n <button class=\"btn1\" type=\"button\" tabindex=\"-1\">Select</button>\n <button class=\"btn2\" type=\"button\" tabindex=\"-1\"></button>\n ", this.#e = this.querySelector(".btn1");
|
|
4136
|
+
};
|
|
4137
|
+
#f = () => {
|
|
4138
|
+
this.querySelectorAll("button").forEach((e) => {
|
|
4139
|
+
e.addEventListener("click", (e) => {
|
|
4140
|
+
e.stopPropagation(), this.#p();
|
|
4141
|
+
});
|
|
4142
|
+
}), this.cell.addEventListener("keydown", (e) => {
|
|
4143
|
+
["Space"].includes(e.code) && this.#p();
|
|
4144
|
+
});
|
|
4145
|
+
};
|
|
4146
|
+
#p = () => {
|
|
4147
|
+
this.#o || (this.#o = super.sheet.querySelector("cell-combo-panel"), this.#o || (this.#o = document.createElement("cell-combo-panel"), super.sheet.appendChild(this.#o))), this.#o.isOpen && this.#o.targetCell === this ? this.#o.close() : this.#o.open(this, this.#t, this.#n, this.#r, this.#i, this.#a);
|
|
4148
|
+
};
|
|
3999
4149
|
get dataSource() {
|
|
4000
4150
|
return this.#t;
|
|
4001
4151
|
}
|